我在格式化家庭作业时遇到困难

我在格式化家庭作业时遇到困难

我认为 TexStudio 正在尝试优化空间,但我不知道如何阻止它。校样应该位于文档的末尾,但最终却被放置在靠近开头的位置。

\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}

答案1

浮动选项(如 [ht])只是建议。您的图片将被放置在 LaTeX“认为”更合适的位置。

如果你想要 tikzpicture 的固定位置,你可以:

  1. 不要将其作为图形放在浮点数中,只需将其直接插入文本中即可

  2. 保留图形和 \usepackage{float},并使用选项 [H],这对于图形来说是一个“难题”。

    我使用第二个选项尝试了你的代码并且效果很好:

\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}

相关内容