1

I think TexStudio is trying to optimize space but I don't know how to stop it.The proof is supposed to be at the end of the document, but it ends up being placed near the beginning.

\documentclass{article}
\usepackage{amsthm}
\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]

\newtheorem{theorem}{Theorem}
\newtheorem{corollary}{Corollary}[theorem]
\newtheorem{lemma}[theorem]{Lemma}
\usepackage{tikz}
\usetikzlibrary{automata, positioning, arrows}
\tikzset{
    ->, % makes the edges directed
    %>=stealth’, % makes the arrow heads bold
    node distance=3cm, % specifies the minimum distance between two nodes. Change if necessary.
    every state/.style={thick, fill=gray!10}, % sets the properties for each ’state’ node
    initial text=$ $, % sets the text that appears on the start arrow
}
    \begin{document}

        \begin{figure}[ht] % ’ht’ tells LaTeX to place the figure ’here’ or at the top of the page
        \centering % centers the figure
        \begin{tikzpicture}
        \node[state, initial] (q1) {$q_1$};
        \node[state, accepting, right of=q1] (q2) {$q_2$};
        \node[state,right of=q2] (q3) {$q_3$};
        \draw 
        (q1) edge[bend right, below] node{b} (q3)
        (q1) edge[above] node{a} (q2)
        (q2) edge[loop above] node{a,b} (q2)
        (q3) edge[loop above] node{a, b} (q3);
        \end{tikzpicture}
        \caption{ $\{w$: $w$ starts with an $a\}$}
        1.4 e
        \label{fig:my_label}
    \end{figure}
    \begin{figure}
    \centering 
        \begin{tikzpicture}
        \node[state, initial, accepting] (s1) {$s_1$};
        \node[state, accepting, right of=s1] (s2) {$s_2$};
        \node[state,right of=s2] (s3) {$s_3$};
        \draw 
        (s1) edge[loop below] node{a} (s1)
        (s1) edge[above] node{b} (s2)
        (s2) edge[loop below] node{a} (s2)
        (s2) edge[above] node{b} (s3)
        (s3) edge[loop above] node{a, b} (s3);
        \path (current bounding box.north) ++ (0,1cm);
        \end{tikzpicture}
        \caption{$\{w$: $w$ has at most one $b\}$}
        1.4 e
        \label{fig:my_label2}
    \end{figure}
    \begin{figure}
    \centering

        \begin{tikzpicture}
        \node[state, initial] (s1q1) {$s_1, q_1$};
        \node[state, accepting, right of=s1q1] (s1q2) {$s_1, q_2$};
        \node[state, below of=s1q1] (s2q3) {$s_2, q_3$};
        \node[state, accepting,below of=s1q2] (s2q2) {$s_2, q_2$};
        \node[state, below of=s2q3] (s3q3) {$s_3, q_3$};
        \node[state, below of=s2q2] (s3q2) {$s_3, q_2$};

        \draw 
        (s1q1) edge[above] node{a} (s1q2)
        (s1q1) edge[right] node{b} (s2q3)
        (s1q2) edge[loop above] node{a} (s1q2)
        (s1q2) edge[right] node{b} (s2q2)
        (s2q3) edge[loop left] node{a} (s2q3)
        (s2q3) edge[left] node{b} (s3q3)
        (s3q3) edge[loop left] node{a, b} (s3q3)
        (s2q2) edge[loop left] node{a} (s2q2)
        (s2q2) edge[left] node{b} (s3q2)
        (s3q2) edge[loop left] node{a, b} (s3q2);
        \path (current bounding box.north) ++ (0,1cm);  
        \end{tikzpicture}
        \caption{$\{w$: $w$ starts with an $a$ and $w$ has at most one $b\}$}
        \label{fig:my_label23}
        where ($s_3$, $q_1$), ($s_2$, $q_1$), and ($s_1$, $q_3$) have been optimized out. \\
        1.4 e Final
    \end{figure}

    \begin{figure}[ht] % ’ht’ tells LaTeX to place the figure ’here’ or at the top of the page
        \centering % centers the figure
        \begin{tikzpicture}
        \node[state, initial] (q1) {$q_{even}$};
        \node[state, accepting, right of=q1] (q2) {$q_{odd}$};
        \draw 
        (q1) edge[bend left, above] node{a} (q2)
        (q1) edge[loop above] node{b} (q1)
        (q2) edge[bend left, below] node{a} (q1)
        (q2) edge[loop above] node{b} (q2);
        \end{tikzpicture}
        \caption{$\{w$: $w$ has an odd number of $a$'s$\}$}
        1.4 f
        \label{fig:my_label5}   
    \end{figure}
\begin{figure}
\centering  
        \begin{tikzpicture}
        \node[state, initial] (s1) {$s_1$};
        \node[state, accepting, right of=s1] (s2) {$s_2$};
        \draw 
        (s1) edge[loop above] node{$a$} (s1)
        (s1) edge[bend left, above] node{$b$} (s2)
        (s2) edge[bend left, below] node{$a$} (s1)
        (s2) edge[loop above] node{$b$} (s2);
        \path (current bounding box.north) ++ (0,1cm);
        \end{tikzpicture}
        \caption{$\{w$: $w$ ends with $b\}$}
        1.4 f
        \label{fig:my_label4}
        \end{figure}
    \begin{figure}
        \centering  
        \begin{tikzpicture}
        \node[state, initial] (s1qe) {$s_1, q_{even}$};
        \node[state, right of=s1qe] (s2qe) {$s_2, q_{even}$};
        \node[state, below of=s1qe] (s1qo) {$s_1, q_{odd}$};
        \node[state, accepting, right of=s1qo] (s2qo) {$s_2, q_{odd}$};
        \draw 
        (s1qe) edge[bend left, left] node{$a$} (s1qo)
        (s1qe) edge[bend left, above] node{$b$} (s2qe)
        (s2qe) edge[bend left, below] node{$a$} (s1qo)
        (s2qe) edge[loop above] node{$b$} (s2qe)
        (s1qo) edge[bend left, left] node{$a$} (s1qe)
        (s1qo) edge[bend right, below] node{$b$} (s2qo)
        (s2qo) edge[bend right, right] node{$a$} (s1qe)
        (s2qo) edge[bend right, right] node{$b$} (s2qe);
        \path (current bounding box.north) ++ (0,1cm);
        \end{tikzpicture}
        \caption{$\{w$: $w$ has an odd number of $a$'s and ends with a $b\}$}
        1.4 f, Final.
        \label{fig:my_label7}   
    \end{figure}
    \begin{figure}[ht] % ’ht’ tells LaTeX to place the figure ’here’ or at the top of the page
    \centering % centers the figure
    \begin{tikzpicture}
    \node[state, initial] (q1) {$q_{even}$};
    \node[state, accepting, right of=q1] (q2) {$q_{odd}$};
    \draw 
    (q1) edge[bend left, above] node{a} (q2)
    (q1) edge[loop above] node{b} (q1)
    (q2) edge[bend left, below] node{a} (q1)
    (q2) edge[loop above] node{b} (q2);
    \end{tikzpicture}
    \caption{$\{w$: $w$ has an odd number of $a$'s$\}$}
    1.4 g
    \label{fig:my_labela}
\end{figure}
\begin{figure}
    \centering 
    \begin{tikzpicture}
    \node[state, initial, accepting] (se) {$s_{even}$};
    \node[state, right of=se] (so) {$s_{odd}$};
    \draw 
    (se) edge[bend left, above] node{$a, b$} (so)
    (so) edge[bend left, above] node{$a, b$} (se);
    \path (current bounding box.north) ++ (0,1cm);
    \end{tikzpicture}
    \caption{$\{w$: $w$ an even length $\}$}
    1.4 g
    \label{fig:my_label10}  
\end{figure}
\begin{figure}
    \centering 

    \begin{tikzpicture}
    \node[state, initial] (seqe) {$s_{even}, q_{even}$};
    \node[state, right of=seqe] (soqo) {$s_{odd}, q_{odd}$};
    \node[state, below of=seqe] (soqe) {$s_{odd}, q_{even}$};
    \node[state, accepting, right of=soqe] (seqo) {$s_{even}, q_{odd}$};
    \draw 
    (seqe) edge[bend left, above] node{$a$} (soqo)
    (seqe) edge[bend left, left] node{$b$} (soqe)
    (soqe) edge[bend left, above] node{$a$} (seqo)
    (soqe) edge[bend left, left] node{$b$} (seqe)
    (soqo) edge[bend left, below] node{$a$} (seqe)
    (soqo) edge[bend left, left] node{$b$} (seqo)
    (seqo) edge[bend left, below] node{$a$} (soqe)
    (s2qo) edge[bend left, left] node{$b$} (soqo);
    \path (current bounding box.north) ++ (0,1cm);
    \end{tikzpicture}
    \caption{$\{w$: $w$ has an odd number of $a$'s and an even length $\}$}
    1.4 g, Final.
    \label{fig:my_labelo}   
 \end{figure}


    \begin{figure}[ht] % ’ht’ tells LaTeX to place the figure ’here’ or at the top of the page
        \centering % centers the figure 
        \begin{tikzpicture}
        \node[state, initial] (q1) {$q_1$};
        \node[state, right of=q1] (q2) {$q_2$};
        \node[state, accepting, right of=q2] (q3) {$q_3$};
        \draw 
        (q1) edge[above] node{a} (q2)
        (q1) edge[loop above] node{b} (q1)
        (q2) edge[loop above] node{a} (q2)
        (q2) edge[above] node{b} (q3)
        (q3) edge[loop above] node{a, b} (q3);
        \end{tikzpicture}
        \caption{$\{w$: $w$ contains $ab\}$}
        1.5 c
        \label{fig:my_labeltable}
    \end{figure}
        \begin{figure}
            \centering  

        \begin{tikzpicture}
        \node[state, initial] (s1) {$s_1$};
        \node[state, right of=s1] (s2) {$s_2$};
        \node[state, accepting, right of=s2] (s3) {$s_3$};
        \draw 
        (s1) edge[loop above] node{a} (s1)
        (s1) edge[above] node{b} (s2)
        (s2) edge[above] node{a} (s3)
        (s2) edge[loop above] node{b} (s2)
        (s3) edge[loop above] node{a, b} (s3);
        \path (current bounding box.north) ++ (0,1cm);
        \end{tikzpicture}
        \caption{$\{w$: $w$ contains $ba\}$}
        1.5 c
        \label{fig:my_labelol}
     \end{figure}
        \begin{figure}
            \centering 

        \begin{tikzpicture}
        \node[state, initial] (q1s1) {$q_1, s_1$};
        \node[state, right of=q1s1] (q1s2) {$q_1, s_2$};
        \node[state, below of=s1q1] (q2s2) {$q_2, s_2$};
        \node[state, below of=q1s2] (q2s3) {$q_2, s_3$};
        \node[state, below of=q2s2] (q3s2) {$q_3, s_2$};
        \node[state, accepting, below of=q2s3] (q3s3) {$q_3, s_2$};

        \draw 
        (q1s1) edge[left] node{a} (q2s2)
        (q1s1) edge[above] node{b} (q1s2)
        (q1s2) edge[right] node{a} (q2s3)
        (q1s2) edge[right] node{b} (q2s2)
        (q2s2) edge[above] node{a} (q2s3)
        (q2s2) edge[right] node{b} (q3s2)
        (q2s3) edge[loop right] node{a} (q2s3)
        (q2s3) edge[right] node{b} (q3s3)
        (q3s2) edge[below] node{a} (q3s3)
        (q3s2) edge[loop below] node{b} (q3s2)
        (q3s3) edge[loop below] node{a, b} (q3s3);
        \path (current bounding box.north) ++ (0,1cm);  
        \end{tikzpicture}
        \caption{$\{w$: $w$ contains $ab$ and $ba\}$};
        \label{fig:my_labelp}
        where ($q_1$, $s_3$), ($q_2$, $s_1$), and ($q_3$, $s_1$) have been optimized out. \\
        1.5 c
    \end{figure}
    \begin{figure}
        \centering

    \begin{tikzpicture}
    \node[state, accepting,initial] (q1s1) {$q_1, s_1$};
    \node[state, accepting,right of=q1s1] (q1s2) {$q_1, s_2$};
    \node[state, accepting,below of=s1q1] (q2s2) {$q_2, s_2$};
    \node[state, accepting,below of=q1s2] (q2s3) {$q_2, s_3$};
    \node[state, accepting,below of=q2s2] (q3s2) {$q_3, s_2$};
    \node[state,  below of=q2s3] (q3s3) {$q_3, s_2$};

    \draw 
    (q1s1) edge[left] node{a} (q2s2)
    (q1s1) edge[above] node{b} (q1s2)
    (q1s2) edge[right] node{a} (q2s3)
    (q1s2) edge[right] node{b} (q2s2)
    (q2s2) edge[above] node{a} (q2s3)
    (q2s2) edge[right] node{b} (q3s2)
    (q2s3) edge[loop right] node{a} (q2s3)
    (q2s3) edge[right] node{b} (q3s3)
    (q3s2) edge[below] node{a} (q3s3)
    (q3s2) edge[loop below] node{b} (q3s2)
    (q3s3) edge[loop below] node{a, b} (q3s3);
    \path (current bounding box.north) ++ (0,1cm);  
    \end{tikzpicture}
    \caption{$\{w$: $w$ does not contain $ab$ nor $ba\}$};
    \label{fig:my_labelhp}
    where ($q_1$, $s_3$), ($q_2$, $s_1$), and ($q_3$, $s_1$) have been optimized out. \\
    1.5 c, Final.
 \end{figure}
 \begin{figure}

        \centering
    \begin{tikzpicture}
        \node[state, initial] (1) {$1$};
        \node[state, right of =1] (2) {$2$};
        \node[state, accepting, right of =2] (3) {$3$};
        \node[state, right of =3] (4) {$4$};
        \draw
        (1) edge[above] node{a} (2)
        (1) edge[loop above] node{b} (1)
        (2) edge[above] node{a} (3)
        (2) edge[loop above] node{b} (2)
        (3) edge[above] node{a} (4)
        (3) edge[loop above] node{b} (3)
        (4) edge[loop above] node{a, b} (4);
        \path (current bounding box.north) ++ (0,1cm);
    \end{tikzpicture}
    \caption{$\{w$: $w$ contains exactly two $a$'s$\}$}
    1.5 g
    \label{fig:my_label14}
\end{figure}
\begin{figure}
    \centering

    \begin{tikzpicture}
    \node[state, accepting, initial] (1) {$1$};
    \node[state, accepting, right of =1] (2) {$2$};
    \node[state,  right of =2] (3) {$3$};
    \node[state, accepting, right of =3] (4) {$4$};
    \draw
    (1) edge[above] node{a} (2)
    (1) edge[loop above] node{b} (1)
    (2) edge[above] node{a} (3)
    (2) edge[loop above] node{b} (2)
    (3) edge[above] node{a} (4)
    (3) edge[loop above] node{b} (3)
    (4) edge[loop above] node{a, b} (4);
    \path (current bounding box.north) ++ (0,1cm);
    \end{tikzpicture}
    \caption{$\{w$: $w$ does not contain exactly two $a$'s$\}$}
    1.5 g, Final.
    \label{fig:my_label15}
\end{figure}
\begin{figure}
    \centering

    \begin{tikzpicture}
        \node[state, initial](1) {$1$};
        \node[state,accepting,right of=1](2) {$2$};
        \node[state,accepting,below of=1](3) {$3$};
        \node[state,below of=2](4) {4};
        \draw
        (1) edge[above] node{a} (2)
        (1) edge[left] node{b} (3)
        (2) edge[right] node{a,b} (4)
        (3) edge[above] node{a,b} (4)
        (4) edge[loop below] node{a,b} (4);
        \path (current bounding box.north) ++ (0,1cm);
    \end{tikzpicture}
        \caption{$\{w$: $w$ is $a$ or $b\}$}
        1.5 h
    \label{fig:my_label16}
\end{figure}
\begin{figure}
\centering

\begin{tikzpicture}
\node[state,accepting, initial](1) {$1$};
\node[state,right of=1](2) {$2$};
\node[state,below of=1](3) {$3$};
\node[state,accepting,below of=2](4) {4};
\draw
(1) edge[above] node{a} (2)
(1) edge[left] node{b} (3)
(2) edge[right] node{a,b} (4)
(3) edge[above] node{a,b} (4)
(4) edge[loop below] node{a,b} (4);
\path (current bounding box.north) ++ (0,1cm);
\end{tikzpicture}
\caption{$\{w$: $w$ is not $a$ or $b\}$}
1.5 h, Final.
\label{fig:my_label17}
\end{figure}
\begin{figure}
    \centering

    \begin{tikzpicture}
    \node[state, initial, accepting](1){$1$};
    \node[state,accepting, right of=1](2){$2$};
    \node[state, below of=2](3){$3$};
    \draw
    (1) edge[above] node{0} (2)
    (1) edge[below] node{1} (3)
    (2) edge[right] node{0,1} (3)
    (3) edge[loop below] node{0,1} (3); 
    \path (current bounding box.north) ++ (0,1cm);  
    \end{tikzpicture}
        \caption{$\{w$: $w$ is $0$ or $\epsilon\}$}
        1.6 k
    \label{fig:my_label18}
\end{figure}

\begin{figure}
    \centering

    \begin{tikzpicture}
        \node[state, initial, accepting](q1){$q_1$};
        \node[state, accepting,right of=q1](q2){$q_2$};
        \node[state, accepting, right of=q2](q3){$q_3$};
        \node[state, accepting,right of=q3](q4){$q_4$};
        \node[state, below of=q1](q5){$q_5$};
        \node[state,right of=q5](q6){$q_6$};
        \node[state, accepting, right of=q6](q7){$q_7$};
        \node[state,right of=q7](q8){$q_8$};
        \draw
        (q1) edge[bend left, left] node{0} (q5)
        (q1) edge[above] node{1} (q2)
        (q2) edge[bend left, left] node{0} (q6)
        (q2) edge[above] node{1} (q3)
        (q3) edge[bend left, left] node{0} (q7)
        (q3) edge[above] node{1} (q4)
        (q4) edge[bend left, left] node{0} (q8)
        (q4) edge[loop above] node{1} (q4)
        (q5) edge[bend left, left] node{0} (q1)
        (q5) edge[above] node{1} (q6)
        (q6) edge[bend left, left] node{0} (q2)
        (q6) edge[above] node{1} (q7)
        (q7) edge[bend left, left] node{0} (q3)
        (q7) edge[above] node{1} (q8)
        (q8) edge[bend left, left] node{0} (q4)
        (q8) edge[loop below] node{1} (q8);
        \path (current bounding box.north) ++ (0,1cm);
    \end{tikzpicture}
        \caption{$\{w$: $w$ contains an even number of $0$'s or exactly two $1$'s$\}$}
        1.6 l

    \label{fig:my_label19}
\end{figure}
\begin{figure}
    \centering

    \begin{tikzpicture}
        \node[state, initial](q1){$q_1$};
        \path (current bounding box.north) ++ (0,1cm);
    \end{tikzpicture}
    \caption{The Empty Set}
    1.6 m
\end{figure}
\begin{figure}
    \centering
    \begin{tikzpicture}
        \node[state, initial](q1) {$q_1$};
        \node[state, right of=q1](q2) {$q_2$};
        \node[state, right of=q2](q3) {$q_3$};
        \node[state,right of=q3](q4) {$q_4$};
        \node[state, accepting, right of=q4](q5){$q_5$};
        \draw
        (q1) edge[above] node{0} (q2)
        (q1) edge[loop above] node{0,1} (q1)
        (q2) edge[above] node{1} (q3)
        (q3) edge[above] node{0} (q4)
        (q4) edge[above] node{1} (q5)
        (q5) edge[loop above] node{0,1} (q5);
        \path (current bounding box.north) ++ (0,1cm);
    \end{tikzpicture}
    \caption{$\{w$: $w$ contains the sub-string $0101\}$}
    1.7 b
\end{figure}
\begin{figure}
    \centering

    \begin{tikzpicture}
        \node[state, initial] (q2) {$q_1$};
        \node[state,accepting, below right of=q1](q2) {$q_2$};
        \node[state, right of=q2](q3) {$q_3$};
        \node[state, above right of=q1](q4) {$q_4$};
        \node[state, right of=q4](q5){$q_5$};
        \node[state, accepting, right of=q5](q6) {$q_6$};
        \draw
        (q1) edge[above] node{$\epsilon$} (q2)
        (q1) edge[above] node{$\epsilon$} (q4)
        (q2) edge[bend left, above] node{0} (q3)
        (q2) edge[loop below] node{1} (q2)
        (q3) edge[bend left, below] node{0} (q2)
        (q3) edge[loop below] node{1} (q3)
        (q4) edge[loop above] node{0} (q4)
        (q4) edge[above] node{1} (q5)
        (q5) edge[loop above] node{0} (q5)
        (q5) edge[above] node{1} (q6)
        (q6) edge[loop above] node{0} (q6);
    \end{tikzpicture}
    \caption{$\{w$: $w$ contains an even number of $0$'s or exactly two $1$'s$\}$}
    1.7 c
\end{figure}


    \begin{theorem}
        If $M$ = $(Q,\Sigma,\delta,q_0,F)$ is a $DFA$ that recognizes language $B$
        Then $M'$ = $(Q,\Sigma,\delta,q_0,\bar{F})$ recognizes language $\bar{B}$.
    \end{theorem}
    \begin{proof}
        \label{P}
        \begin{enumerate}
            \item
            $M$ = $(Q,\Sigma,\delta,q_0,F)$ is a $DFA$ that recognizes language $B$, so
            $B$ = $\{w$: $w$ is accepted by $M\}$.
            \item 
            Machine $M'$ = $(Q,\Sigma,\delta,q_0,\bar{F})$ is 
            identical to $M$ accept that it's set of acceptance states $\bar{F}$ are the complement of $F$. 
            \item 
            By the properties of $DFA$'s, $M'$ must accept only strings rejected by $M$ as well as all strings rejected by $M$. Thus, $M'$ recognizes $\bar{B}$.
        \end{enumerate}

    \end{proof}
\begin{corollary}
    By \ref{P}, if some language $B$ is regular, then $\bar{B}$ is also regular. Making the class of regular languages closed under complement.
\end{corollary}

\end{document}
6
  • 2
    you have posted a lot of code but not in a form that anyone can run to see the problem. i see a lot of figures which are quite likely to float to the end of the document as you have [ht] but it's impossible to say anything without a usable example. texstudio is not involved, that is just the editor you used to write the file. Jan 31, 2020 at 22:17
  • I apologize for the form of the code, I am still learning how to properly post. Big blocks get broken up by the code window, though that issues seems to have been fixed. Jan 31, 2020 at 22:28
  • Also, thanks for the suggestion. However, Removing [ht] has not solved the problem. Jan 31, 2020 at 22:29
  • 1
    I fixed the markuo but really you should post much smaller examples. For example the position of a figure just depends on its size not its content, so you could remove (for the example) all the tikzpicture and replace them by \vspace{3cm} or whatever size shows the effect. But the only reason to use a figure environment is to specify that the content may be moved, so figures floating past your proof is working as designed. Jan 31, 2020 at 22:41
  • probably you just want to put \clearpage after your figures before the theorem so they do not float past the theorem. without\clearpage the [ht] are forcing the figures to the end as its main effect is to forbid [p] ie placing the figure on a float page Jan 31, 2020 at 22:48

1 Answer 1

2

Float options, like [ht], are just a suggestion. Your images will be put wherever LaTeX "thinks" they fit better.

If you want a fixed position for you tikzpicture you can:

  1. Do not put it inside a float, as a figure, just insert them directly in the text

  2. Keep the figures and \usepackage{float}, and use option [H], that is a "hard here" for figures.

    I tryed your code with the second option and it worked fine:

\documentclass{article}
\usepackage{amsthm}
\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]
\usepackage{float}
\newtheorem{theorem}{Theorem}
\newtheorem{corollary}{Corollary}[theorem]
\newtheorem{lemma}[theorem]{Lemma}
\usepackage{tikz}
\usetikzlibrary{automata, positioning, arrows}
\tikzset{
    ->, % makes the edges directed
    %>=stealth’, % makes the arrow heads bold
    node distance=3cm, % specifies the minimum distance between two nodes. Change if necessary.
    every state/.style={thick, fill=gray!10}, % sets the properties for each ’state’ node
    initial text=$ $, % sets the text that appears on the start arrow
}
    \begin{document}

        \begin{figure}[H] % ’ht’ tells LaTeX to place the figure ’here’ or at the top of the page
        \centering % centers the figure
        \begin{tikzpicture}
        \node[state, initial] (q1) {$q_1$};
        \node[state, accepting, right of=q1] (q2) {$q_2$};
        \node[state,right of=q2] (q3) {$q_3$};
        \draw 
        (q1) edge[bend right, below] node{b} (q3)
        (q1) edge[above] node{a} (q2)
        (q2) edge[loop above] node{a,b} (q2)
        (q3) edge[loop above] node{a, b} (q3);
        \end{tikzpicture}
        \caption{ $\{w$: $w$ starts with an $a\}$}
        1.4 e
        \label{fig:my_label}
    \end{figure}
    \begin{figure}[H]
    \centering 
        \begin{tikzpicture}
        \node[state, initial, accepting] (s1) {$s_1$};
        \node[state, accepting, right of=s1] (s2) {$s_2$};
        \node[state,right of=s2] (s3) {$s_3$};
        \draw 
        (s1) edge[loop below] node{a} (s1)
        (s1) edge[above] node{b} (s2)
        (s2) edge[loop below] node{a} (s2)
        (s2) edge[above] node{b} (s3)
        (s3) edge[loop above] node{a, b} (s3);
        \path (current bounding box.north) ++ (0,1cm);
        \end{tikzpicture}
        \caption{$\{w$: $w$ has at most one $b\}$}
        1.4 e
        \label{fig:my_label2}
    \end{figure}
    \begin{figure}[H]
    \centering

        \begin{tikzpicture}
        \node[state, initial] (s1q1) {$s_1, q_1$};
        \node[state, accepting, right of=s1q1] (s1q2) {$s_1, q_2$};
        \node[state, below of=s1q1] (s2q3) {$s_2, q_3$};
        \node[state, accepting,below of=s1q2] (s2q2) {$s_2, q_2$};
        \node[state, below of=s2q3] (s3q3) {$s_3, q_3$};
        \node[state, below of=s2q2] (s3q2) {$s_3, q_2$};

        \draw 
        (s1q1) edge[above] node{a} (s1q2)
        (s1q1) edge[right] node{b} (s2q3)
        (s1q2) edge[loop above] node{a} (s1q2)
        (s1q2) edge[right] node{b} (s2q2)
        (s2q3) edge[loop left] node{a} (s2q3)
        (s2q3) edge[left] node{b} (s3q3)
        (s3q3) edge[loop left] node{a, b} (s3q3)
        (s2q2) edge[loop left] node{a} (s2q2)
        (s2q2) edge[left] node{b} (s3q2)
        (s3q2) edge[loop left] node{a, b} (s3q2);
        \path (current bounding box.north) ++ (0,1cm);  
        \end{tikzpicture}
        \caption{$\{w$: $w$ starts with an $a$ and $w$ has at most one $b\}$}
        \label{fig:my_label23}
        where ($s_3$, $q_1$), ($s_2$, $q_1$), and ($s_1$, $q_3$) have been optimized out. \\
        1.4 e Final
    \end{figure}

    \begin{figure}[H] % ’ht’ tells LaTeX to place the figure ’here’ or at the top of the page
        \centering % centers the figure
        \begin{tikzpicture}
        \node[state, initial] (q1) {$q_{even}$};
        \node[state, accepting, right of=q1] (q2) {$q_{odd}$};
        \draw 
        (q1) edge[bend left, above] node{a} (q2)
        (q1) edge[loop above] node{b} (q1)
        (q2) edge[bend left, below] node{a} (q1)
        (q2) edge[loop above] node{b} (q2);
        \end{tikzpicture}
        \caption{$\{w$: $w$ has an odd number of $a$'s$\}$}
        1.4 f
        \label{fig:my_label5}   
    \end{figure}
\begin{figure}[H]
\centering  
        \begin{tikzpicture}
        \node[state, initial] (s1) {$s_1$};
        \node[state, accepting, right of=s1] (s2) {$s_2$};
        \draw 
        (s1) edge[loop above] node{$a$} (s1)
        (s1) edge[bend left, above] node{$b$} (s2)
        (s2) edge[bend left, below] node{$a$} (s1)
        (s2) edge[loop above] node{$b$} (s2);
        \path (current bounding box.north) ++ (0,1cm);
        \end{tikzpicture}
        \caption{$\{w$: $w$ ends with $b\}$}
        1.4 f
        \label{fig:my_label4}
        \end{figure}
    \begin{figure}[H]
        \centering  
        \begin{tikzpicture}
        \node[state, initial] (s1qe) {$s_1, q_{even}$};
        \node[state, right of=s1qe] (s2qe) {$s_2, q_{even}$};
        \node[state, below of=s1qe] (s1qo) {$s_1, q_{odd}$};
        \node[state, accepting, right of=s1qo] (s2qo) {$s_2, q_{odd}$};
        \draw 
        (s1qe) edge[bend left, left] node{$a$} (s1qo)
        (s1qe) edge[bend left, above] node{$b$} (s2qe)
        (s2qe) edge[bend left, below] node{$a$} (s1qo)
        (s2qe) edge[loop above] node{$b$} (s2qe)
        (s1qo) edge[bend left, left] node{$a$} (s1qe)
        (s1qo) edge[bend right, below] node{$b$} (s2qo)
        (s2qo) edge[bend right, right] node{$a$} (s1qe)
        (s2qo) edge[bend right, right] node{$b$} (s2qe);
        \path (current bounding box.north) ++ (0,1cm);
        \end{tikzpicture}
        \caption{$\{w$: $w$ has an odd number of $a$'s and ends with a $b\}$}
        1.4 f, Final.
        \label{fig:my_label7}   
    \end{figure}
    \begin{figure}[H] % ’ht’ tells LaTeX to place the figure ’here’ or at the top of the page
    \centering % centers the figure
    \begin{tikzpicture}
    \node[state, initial] (q1) {$q_{even}$};
    \node[state, accepting, right of=q1] (q2) {$q_{odd}$};
    \draw 
    (q1) edge[bend left, above] node{a} (q2)
    (q1) edge[loop above] node{b} (q1)
    (q2) edge[bend left, below] node{a} (q1)
    (q2) edge[loop above] node{b} (q2);
    \end{tikzpicture}
    \caption{$\{w$: $w$ has an odd number of $a$'s$\}$}
    1.4 g
    \label{fig:my_labela}
\end{figure}
\begin{figure}[H]
    \centering 
    \begin{tikzpicture}
    \node[state, initial, accepting] (se) {$s_{even}$};
    \node[state, right of=se] (so) {$s_{odd}$};
    \draw 
    (se) edge[bend left, above] node{$a, b$} (so)
    (so) edge[bend left, above] node{$a, b$} (se);
    \path (current bounding box.north) ++ (0,1cm);
    \end{tikzpicture}
    \caption{$\{w$: $w$ an even length $\}$}
    1.4 g
    \label{fig:my_label10}  
\end{figure}
\begin{figure}[H]
    \centering 

    \begin{tikzpicture}
    \node[state, initial] (seqe) {$s_{even}, q_{even}$};
    \node[state, right of=seqe] (soqo) {$s_{odd}, q_{odd}$};
    \node[state, below of=seqe] (soqe) {$s_{odd}, q_{even}$};
    \node[state, accepting, right of=soqe] (seqo) {$s_{even}, q_{odd}$};
    \draw 
    (seqe) edge[bend left, above] node{$a$} (soqo)
    (seqe) edge[bend left, left] node{$b$} (soqe)
    (soqe) edge[bend left, above] node{$a$} (seqo)
    (soqe) edge[bend left, left] node{$b$} (seqe)
    (soqo) edge[bend left, below] node{$a$} (seqe)
    (soqo) edge[bend left, left] node{$b$} (seqo)
    (seqo) edge[bend left, below] node{$a$} (soqe)
    (s2qo) edge[bend left, left] node{$b$} (soqo);
    \path (current bounding box.north) ++ (0,1cm);
    \end{tikzpicture}
    \caption{$\{w$: $w$ has an odd number of $a$'s and an even length $\}$}
    1.4 g, Final.
    \label{fig:my_labelo}   
 \end{figure}


    \begin{figure}[H] % ’ht’ tells LaTeX to place the figure ’here’ or at the top of the page
        \centering % centers the figure 
        \begin{tikzpicture}
        \node[state, initial] (q1) {$q_1$};
        \node[state, right of=q1] (q2) {$q_2$};
        \node[state, accepting, right of=q2] (q3) {$q_3$};
        \draw 
        (q1) edge[above] node{a} (q2)
        (q1) edge[loop above] node{b} (q1)
        (q2) edge[loop above] node{a} (q2)
        (q2) edge[above] node{b} (q3)
        (q3) edge[loop above] node{a, b} (q3);
        \end{tikzpicture}
        \caption{$\{w$: $w$ contains $ab\}$}
        1.5 c
        \label{fig:my_labeltable}
    \end{figure}
        \begin{figure}[H]
            \centering  

        \begin{tikzpicture}
        \node[state, initial] (s1) {$s_1$};
        \node[state, right of=s1] (s2) {$s_2$};
        \node[state, accepting, right of=s2] (s3) {$s_3$};
        \draw 
        (s1) edge[loop above] node{a} (s1)
        (s1) edge[above] node{b} (s2)
        (s2) edge[above] node{a} (s3)
        (s2) edge[loop above] node{b} (s2)
        (s3) edge[loop above] node{a, b} (s3);
        \path (current bounding box.north) ++ (0,1cm);
        \end{tikzpicture}
        \caption{$\{w$: $w$ contains $ba\}$}
        1.5 c
        \label{fig:my_labelol}
     \end{figure}
        \begin{figure}[H]
            \centering 

        \begin{tikzpicture}
        \node[state, initial] (q1s1) {$q_1, s_1$};
        \node[state, right of=q1s1] (q1s2) {$q_1, s_2$};
        \node[state, below of=s1q1] (q2s2) {$q_2, s_2$};
        \node[state, below of=q1s2] (q2s3) {$q_2, s_3$};
        \node[state, below of=q2s2] (q3s2) {$q_3, s_2$};
        \node[state, accepting, below of=q2s3] (q3s3) {$q_3, s_2$};

        \draw 
        (q1s1) edge[left] node{a} (q2s2)
        (q1s1) edge[above] node{b} (q1s2)
        (q1s2) edge[right] node{a} (q2s3)
        (q1s2) edge[right] node{b} (q2s2)
        (q2s2) edge[above] node{a} (q2s3)
        (q2s2) edge[right] node{b} (q3s2)
        (q2s3) edge[loop right] node{a} (q2s3)
        (q2s3) edge[right] node{b} (q3s3)
        (q3s2) edge[below] node{a} (q3s3)
        (q3s2) edge[loop below] node{b} (q3s2)
        (q3s3) edge[loop below] node{a, b} (q3s3);
        \path (current bounding box.north) ++ (0,1cm);  
        \end{tikzpicture}
        \caption{$\{w$: $w$ contains $ab$ and $ba\}$};
        \label{fig:my_labelp}
        where ($q_1$, $s_3$), ($q_2$, $s_1$), and ($q_3$, $s_1$) have been optimized out. \\
        1.5 c
    \end{figure}
    \begin{figure}[H]
        \centering

    \begin{tikzpicture}
    \node[state, accepting,initial] (q1s1) {$q_1, s_1$};
    \node[state, accepting,right of=q1s1] (q1s2) {$q_1, s_2$};
    \node[state, accepting,below of=s1q1] (q2s2) {$q_2, s_2$};
    \node[state, accepting,below of=q1s2] (q2s3) {$q_2, s_3$};
    \node[state, accepting,below of=q2s2] (q3s2) {$q_3, s_2$};
    \node[state,  below of=q2s3] (q3s3) {$q_3, s_2$};

    \draw 
    (q1s1) edge[left] node{a} (q2s2)
    (q1s1) edge[above] node{b} (q1s2)
    (q1s2) edge[right] node{a} (q2s3)
    (q1s2) edge[right] node{b} (q2s2)
    (q2s2) edge[above] node{a} (q2s3)
    (q2s2) edge[right] node{b} (q3s2)
    (q2s3) edge[loop right] node{a} (q2s3)
    (q2s3) edge[right] node{b} (q3s3)
    (q3s2) edge[below] node{a} (q3s3)
    (q3s2) edge[loop below] node{b} (q3s2)
    (q3s3) edge[loop below] node{a, b} (q3s3);
    \path (current bounding box.north) ++ (0,1cm);  
    \end{tikzpicture}
    \caption{$\{w$: $w$ does not contain $ab$ nor $ba\}$};
    \label{fig:my_labelhp}
    where ($q_1$, $s_3$), ($q_2$, $s_1$), and ($q_3$, $s_1$) have been optimized out. \\
    1.5 c, Final.
 \end{figure}
 \begin{figure}[H]

        \centering
    \begin{tikzpicture}
        \node[state, initial] (1) {$1$};
        \node[state, right of =1] (2) {$2$};
        \node[state, accepting, right of =2] (3) {$3$};
        \node[state, right of =3] (4) {$4$};
        \draw
        (1) edge[above] node{a} (2)
        (1) edge[loop above] node{b} (1)
        (2) edge[above] node{a} (3)
        (2) edge[loop above] node{b} (2)
        (3) edge[above] node{a} (4)
        (3) edge[loop above] node{b} (3)
        (4) edge[loop above] node{a, b} (4);
        \path (current bounding box.north) ++ (0,1cm);
    \end{tikzpicture}
    \caption{$\{w$: $w$ contains exactly two $a$'s$\}$}
    1.5 g
    \label{fig:my_label14}
\end{figure}
\begin{figure}[H]
    \centering

    \begin{tikzpicture}
    \node[state, accepting, initial] (1) {$1$};
    \node[state, accepting, right of =1] (2) {$2$};
    \node[state,  right of =2] (3) {$3$};
    \node[state, accepting, right of =3] (4) {$4$};
    \draw
    (1) edge[above] node{a} (2)
    (1) edge[loop above] node{b} (1)
    (2) edge[above] node{a} (3)
    (2) edge[loop above] node{b} (2)
    (3) edge[above] node{a} (4)
    (3) edge[loop above] node{b} (3)
    (4) edge[loop above] node{a, b} (4);
    \path (current bounding box.north) ++ (0,1cm);
    \end{tikzpicture}
    \caption{$\{w$: $w$ does not contain exactly two $a$'s$\}$}
    1.5 g, Final.
    \label{fig:my_label15}
\end{figure}
\begin{figure}[H]
    \centering

    \begin{tikzpicture}
        \node[state, initial](1) {$1$};
        \node[state,accepting,right of=1](2) {$2$};
        \node[state,accepting,below of=1](3) {$3$};
        \node[state,below of=2](4) {4};
        \draw
        (1) edge[above] node{a} (2)
        (1) edge[left] node{b} (3)
        (2) edge[right] node{a,b} (4)
        (3) edge[above] node{a,b} (4)
        (4) edge[loop below] node{a,b} (4);
        \path (current bounding box.north) ++ (0,1cm);
    \end{tikzpicture}
        \caption{$\{w$: $w$ is $a$ or $b\}$}
        1.5 h
    \label{fig:my_label16}
\end{figure}
\begin{figure}[H]
\centering

\begin{tikzpicture}
\node[state,accepting, initial](1) {$1$};
\node[state,right of=1](2) {$2$};
\node[state,below of=1](3) {$3$};
\node[state,accepting,below of=2](4) {4};
\draw
(1) edge[above] node{a} (2)
(1) edge[left] node{b} (3)
(2) edge[right] node{a,b} (4)
(3) edge[above] node{a,b} (4)
(4) edge[loop below] node{a,b} (4);
\path (current bounding box.north) ++ (0,1cm);
\end{tikzpicture}
\caption{$\{w$: $w$ is not $a$ or $b\}$}
1.5 h, Final.
\label{fig:my_label17}
\end{figure}
\begin{figure}[H]
    \centering

    \begin{tikzpicture}
    \node[state, initial, accepting](1){$1$};
    \node[state,accepting, right of=1](2){$2$};
    \node[state, below of=2](3){$3$};
    \draw
    (1) edge[above] node{0} (2)
    (1) edge[below] node{1} (3)
    (2) edge[right] node{0,1} (3)
    (3) edge[loop below] node{0,1} (3); 
    \path (current bounding box.north) ++ (0,1cm);  
    \end{tikzpicture}
        \caption{$\{w$: $w$ is $0$ or $\epsilon\}$}
        1.6 k
    \label{fig:my_label18}
\end{figure}

\begin{figure}[H]
    \centering

    \begin{tikzpicture}
        \node[state, initial, accepting](q1){$q_1$};
        \node[state, accepting,right of=q1](q2){$q_2$};
        \node[state, accepting, right of=q2](q3){$q_3$};
        \node[state, accepting,right of=q3](q4){$q_4$};
        \node[state, below of=q1](q5){$q_5$};
        \node[state,right of=q5](q6){$q_6$};
        \node[state, accepting, right of=q6](q7){$q_7$};
        \node[state,right of=q7](q8){$q_8$};
        \draw
        (q1) edge[bend left, left] node{0} (q5)
        (q1) edge[above] node{1} (q2)
        (q2) edge[bend left, left] node{0} (q6)
        (q2) edge[above] node{1} (q3)
        (q3) edge[bend left, left] node{0} (q7)
        (q3) edge[above] node{1} (q4)
        (q4) edge[bend left, left] node{0} (q8)
        (q4) edge[loop above] node{1} (q4)
        (q5) edge[bend left, left] node{0} (q1)
        (q5) edge[above] node{1} (q6)
        (q6) edge[bend left, left] node{0} (q2)
        (q6) edge[above] node{1} (q7)
        (q7) edge[bend left, left] node{0} (q3)
        (q7) edge[above] node{1} (q8)
        (q8) edge[bend left, left] node{0} (q4)
        (q8) edge[loop below] node{1} (q8);
        \path (current bounding box.north) ++ (0,1cm);
    \end{tikzpicture}
        \caption{$\{w$: $w$ contains an even number of $0$'s or exactly two $1$'s$\}$}
        1.6 l

    \label{fig:my_label19}
\end{figure}
\begin{figure}[H]
    \centering

    \begin{tikzpicture}
        \node[state, initial](q1){$q_1$};
        \path (current bounding box.north) ++ (0,1cm);
    \end{tikzpicture}
    \caption{The Empty Set}
    1.6 m
\end{figure}
\begin{figure}[H]
    \centering
    \begin{tikzpicture}
        \node[state, initial](q1) {$q_1$};
        \node[state, right of=q1](q2) {$q_2$};
        \node[state, right of=q2](q3) {$q_3$};
        \node[state,right of=q3](q4) {$q_4$};
        \node[state, accepting, right of=q4](q5){$q_5$};
        \draw
        (q1) edge[above] node{0} (q2)
        (q1) edge[loop above] node{0,1} (q1)
        (q2) edge[above] node{1} (q3)
        (q3) edge[above] node{0} (q4)
        (q4) edge[above] node{1} (q5)
        (q5) edge[loop above] node{0,1} (q5);
        \path (current bounding box.north) ++ (0,1cm);
    \end{tikzpicture}
    \caption{$\{w$: $w$ contains the sub-string $0101\}$}
    1.7 b
\end{figure}
\begin{figure}[H]
    \centering

    \begin{tikzpicture}
        \node[state, initial] (q2) {$q_1$};
        \node[state,accepting, below right of=q1](q2) {$q_2$};
        \node[state, right of=q2](q3) {$q_3$};
        \node[state, above right of=q1](q4) {$q_4$};
        \node[state, right of=q4](q5){$q_5$};
        \node[state, accepting, right of=q5](q6) {$q_6$};
        \draw
        (q1) edge[above] node{$\epsilon$} (q2)
        (q1) edge[above] node{$\epsilon$} (q4)
        (q2) edge[bend left, above] node{0} (q3)
        (q2) edge[loop below] node{1} (q2)
        (q3) edge[bend left, below] node{0} (q2)
        (q3) edge[loop below] node{1} (q3)
        (q4) edge[loop above] node{0} (q4)
        (q4) edge[above] node{1} (q5)
        (q5) edge[loop above] node{0} (q5)
        (q5) edge[above] node{1} (q6)
        (q6) edge[loop above] node{0} (q6);
    \end{tikzpicture}
    \caption{$\{w$: $w$ contains an even number of $0$'s or exactly two $1$'s$\}$}
    1.7 c
\end{figure}


    \begin{theorem}
        If $M$ = $(Q,\Sigma,\delta,q_0,F)$ is a $DFA$ that recognizes language $B$
        Then $M'$ = $(Q,\Sigma,\delta,q_0,\bar{F})$ recognizes language $\bar{B}$.
    \end{theorem}
    \begin{proof}
        \label{P}
        \begin{enumerate}
            \item
            $M$ = $(Q,\Sigma,\delta,q_0,F)$ is a $DFA$ that recognizes language $B$, so
            $B$ = $\{w$: $w$ is accepted by $M\}$.
            \item 
            Machine $M'$ = $(Q,\Sigma,\delta,q_0,\bar{F})$ is 
            identical to $M$ accept that it's set of acceptance states $\bar{F}$ are the complement of $F$. 
            \item 
            By the properties of $DFA$'s, $M'$ must accept only strings rejected by $M$ as well as all strings rejected by $M$. Thus, $M'$ recognizes $\bar{B}$.
        \end{enumerate}

    \end{proof}
\begin{corollary}
    By \ref{P}, if some language $B$ is regular, then $\bar{B}$ is also regular. Making the class of regular languages closed under complement.
\end{corollary}

\end{document}
2
  • 1
    saying [ht] is a "suggestion" is rather misleading, it is an instruction and latex will follow it exactly. In particular it does not include p or b so prevents these figures being placed on a page that only includes figures so they are held back waiting for a page with text where they would fit, and if this never happens they are dumped at the end of the document. Feb 1, 2020 at 8:11
  • This is true, in the sense of how latex will process it, however most people expect h to work as H and sometimes get really frustrated. Long time ago, in the 90s I learned this concept and it made me easier to deal with LaTeX float placement. (I must say that I used LaTeX in the 90s, but only returned to it recently, when ShareLaTeX and now Overleaf became available, so I am not a 30 years expert, my runtime is much smaller than my elapsed time)
    – Xexeo
    Feb 17, 2020 at 4:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .