hws/hw03.tex
changeset 267 a1544b804d1e
parent 264 4deef8ac5d72
child 271 b9b54574ee41
equal deleted inserted replaced
266:ae039d6ae3f2 267:a1544b804d1e
     5 \begin{document}
     5 \begin{document}
     6 
     6 
     7 \section*{Homework 3}
     7 \section*{Homework 3}
     8 
     8 
     9 \begin{enumerate}
     9 \begin{enumerate}
    10 \item What is a regular language?
    10 \item What is a regular language? Are there alternative ways to define this
       
    11   notion? If yes, give an explanation why they define the same notion.
    11 
    12 
    12 \item Assume you have an alphabet consisting of the letters
    13 \item Why is every finite set of strings a regular language?
    13       $a$, $b$ and $c$ only. (1) Find a regular expression
    14 
    14       that recognises the two strings $ab$ and $ac$. (2) Find
    15 \item Assume you have an alphabet consisting of the letters $a$, $b$
    15       a regular expression that matches all strings
    16   and $c$ only. (1) Find a regular expression that recognises the two
    16       \emph{except} these two strings. Note, you can only use
    17   strings $ab$ and $ac$. (2) Find a regular expression that matches
    17       regular expressions of the form 
    18   all strings \emph{except} these two strings. Note, you can only use
       
    19   regular expressions of the form
    18       
    20       
    19       \begin{center} $r ::=
    21   \begin{center} $r ::=
    20       \varnothing \;|\; \epsilon \;|\; c \;|\; r_1 + r_2 \;|\;
    22     \varnothing \;|\; \epsilon \;|\; c \;|\; r_1 + r_2 \;|\;
    21       r_1 \cdot r_2 \;|\; r^*$ 
    23     r_1 \cdot r_2 \;|\; r^*$ 
    22       \end{center}
    24   \end{center}
    23 
    25 
    24 \item Define the function \textit{zeroable} which takes a
    26 \item Define the function \textit{zeroable} which takes a regular
    25       regular expression as argument and returns a boolean.
    27   expression as argument and returns a boolean.  The function should
    26       The function should satisfy the following property:
    28   satisfy the following property:
    27 
    29 
    28 \begin{center}
    30   \begin{center}
    29 $\textit{zeroable(r)} \;\text{if and only if}\; L(r) = \varnothing$
    31     $\textit{zeroable(r)} \;\text{if and only if}\; L(r) = \varnothing$
    30 \end{center}
    32   \end{center}
    31 
    33 
    32 \item Given the alphabet $\{a,b\}$. Draw the automaton that has two states, say  $q_0$ and $q_1$.
    34 \item Given the alphabet $\{a,b\}$. Draw the automaton that has two
    33 The starting state is $q_0$ and the final state is $q_1$. The transition
    35   states, say $q_0$ and $q_1$.  The starting state is $q_0$ and the
    34 function is given by
    36   final state is $q_1$. The transition function is given by
    35 
    37 
    36 \begin{center}
    38   \begin{center}
    37 \begin{tabular}{l}
    39     \begin{tabular}{l}
    38 $(q_0, a) \rightarrow q_0$\\
    40       $(q_0, a) \rightarrow q_0$\\
    39 $(q_0, b) \rightarrow q_1$\\
    41       $(q_0, b) \rightarrow q_1$\\
    40 $(q_1, b) \rightarrow q_1$
    42       $(q_1, b) \rightarrow q_1$
    41 \end{tabular}
    43     \end{tabular}
    42 \end{center}
    44   \end{center}
    43 
    45 
    44 What is the languages recognised by this automaton?
    46   What is the language recognised by this automaton?
    45 
    47 
    46 \item Give a non-deterministic finite automaton that can recognise 
    48 \item Give a non-deterministic finite automaton that can recognise the
    47 the language $L(a\cdot (a + b)^* \cdot c)$. 
    49   language $L(a\cdot (a + b)^* \cdot c)$.
    48 
    50 
       
    51 \item Given a deterministic finite automata $A(Q, q_0, F, \delta)$,
       
    52   define which language is recognised by this automaton. Can you 
       
    53   define also the language defined by a non-deterministic automaton?
    49 
    54 
    50 \item Given the following deterministic finite automaton over the alphabet $\{0, 1\}$,
    55 \item Given the following deterministic finite automata over the
    51 find the corresponding minimal automaton. In case states can be merged,
    56   alphabet $\{a, b\}$, find an automaton that recognises the
    52 state clearly which states can
    57   complement language.  (Hint: Recall that for the algorithm from the
    53 be merged.
    58   lectures, the automaton needs to be in completed form, that is have
       
    59   a transition for every letter from the alphabet.)
    54 
    60 
    55 \begin{center}
    61   \begin{center}
    56 \begin{tikzpicture}[scale=3, line width=0.7mm]
    62     \begin{tikzpicture}[scale=2, line width=0.7mm]
    57   \node[state, initial]        (q0) at ( 0,1) {$q_0$};
    63       \node[state, initial]        (q0) at ( 0,1) {$q_0$};
    58   \node[state]                    (q1) at ( 1,1) {$q_1$};
    64       \node[state, accepting]  (q1) at ( 1,1) {$q_1$};
    59   \node[state, accepting] (q4) at ( 2,1) {$q_4$};
    65       \path[->] (q0) edge node[above] {$a$} (q1)
    60   \node[state]                    (q2) at (0.5,0) {$q_2$};
    66                 (q1) edge [loop right] node {$b$} ();
    61   \node[state]                    (q3) at (1.5,0) {$q_3$};
    67     \end{tikzpicture}
    62   \path[->] (q0) edge node[above] {$0$} (q1)
    68   \end{center}
    63                   (q0) edge node[right] {$1$} (q2)
       
    64                   (q1) edge node[above] {$0$} (q4)
       
    65                   (q1) edge node[right] {$1$} (q2)
       
    66                   (q2) edge node[above] {$0$} (q3)
       
    67                   (q2) edge [loop below] node {$1$} ()
       
    68                   (q3) edge node[left] {$0$} (q4)
       
    69                   (q3) edge [bend left=95, looseness = 2.2] node [left=2mm] {$1$} (q0)
       
    70                   (q4) edge [loop right] node {$0, 1$} ()
       
    71                   ;
       
    72 \end{tikzpicture}
       
    73 \end{center}
       
    74 
    69 
    75 \item Define the language $L(M)$ accepted by a deterministic finite automaton $M$.
    70 \item Given the following deterministic finite automaton over the
       
    71   alphabet $\{0, 1\}$, find the corresponding minimal automaton. In
       
    72   case states can be merged, state clearly which states can be merged.
    76 
    73 
       
    74   \begin{center}
       
    75     \begin{tikzpicture}[scale=2, line width=0.7mm]
       
    76       \node[state, initial]        (q0) at ( 0,1) {$q_0$};
       
    77       \node[state]                    (q1) at ( 1,1) {$q_1$};
       
    78       \node[state, accepting] (q4) at ( 2,1) {$q_4$};
       
    79       \node[state]                    (q2) at (0.5,0) {$q_2$};
       
    80       \node[state]                    (q3) at (1.5,0) {$q_3$};
       
    81       \path[->] (q0) edge node[above] {$0$} (q1)
       
    82                 (q0) edge node[right] {$1$} (q2)
       
    83                 (q1) edge node[above] {$0$} (q4)
       
    84                 (q1) edge node[right] {$1$} (q2)
       
    85                 (q2) edge node[above] {$0$} (q3)
       
    86                 (q2) edge [loop below] node {$1$} ()
       
    87                 (q3) edge node[left] {$0$} (q4)
       
    88                 (q3) edge [bend left=95, looseness = 2.2] node [left=2mm] {$1$} (q0)
       
    89                 (q4) edge [loop right] node {$0, 1$} ();
       
    90     \end{tikzpicture}
       
    91   \end{center}
       
    92 
       
    93 %\item Given the following deterministic finite automaton
       
    94 %
       
    95 %\begin{center}
       
    96 %\begin{tikzpicture}[scale=3, line width=0.7mm]
       
    97 %  \node[state, initial]        (q0) at ( 0,1) {$q_0$};
       
    98 %  \node[state,accepting]  (q1) at ( 1,1) {$q_1$};
       
    99 %  \node[state, accepting] (q2) at ( 2,1) {$q_2$};
       
   100 %  \path[->] (q0) edge node[above] {$b$} (q1)
       
   101 %                  (q1) edge [loop above] node[above] {$a$} ()
       
   102 %                  (q2) edge [loop above] node[above] {$a, b$} ()
       
   103 %                  (q1) edge node[above] {$b$} (q2)
       
   104 %                  (q0) edge[bend right] node[below] {$a$} (q2)
       
   105 %                  ;
       
   106 %\end{tikzpicture}
       
   107 %\end{center}
       
   108 %find the corresponding minimal automaton. State clearly which nodes
       
   109 %can be merged.
       
   110 
       
   111 \item Given the following non-deterministic finite automaton over the
       
   112   alphabet $\{a, b\}$, find a deterministic finite automaton that
       
   113   recognises the same language:
       
   114 
       
   115   \begin{center}
       
   116     \begin{tikzpicture}[scale=3, line width=0.7mm]
       
   117       \node[state, initial]        (q0) at ( 0,1) {$q_0$};
       
   118       \node[state]                    (q1) at ( 1,1) {$q_1$};
       
   119       \node[state, accepting] (q2) at ( 2,1) {$q_2$};
       
   120       \path[->] (q0) edge node[above] {$a$} (q1)
       
   121                 (q0) edge [loop above] node[above] {$b$} ()
       
   122                 (q0) edge [loop below] node[below] {$a$} ()
       
   123                 (q1) edge node[above] {$a$} (q2);
       
   124     \end{tikzpicture}
       
   125   \end{center}
       
   126 
       
   127 \item Given the following finite deterministic automaton over the alphabet $\{a, b\}$:
       
   128 
       
   129   \begin{center}
       
   130     \begin{tikzpicture}[scale=2, line width=0.5mm]
       
   131       \node[state, initial, accepting]        (q0) at ( 0,1) {$q_0$};
       
   132       \node[state, accepting]                    (q1) at ( 1,1) {$q_1$};
       
   133       \node[state] (q2) at ( 2,1) {$q_2$};
       
   134       \path[->] (q0) edge[bend left] node[above] {$a$} (q1)
       
   135                 (q1) edge[bend left] node[above] {$b$} (q0)
       
   136                 (q2) edge[bend left=50] node[below] {$b$} (q0)
       
   137                 (q1) edge node[above] {$a$} (q2)
       
   138                 (q2) edge [loop right] node {$a$} ()
       
   139                 (q0) edge [loop below] node {$b$} ()
       
   140             ;
       
   141     \end{tikzpicture}
       
   142   \end{center}
       
   143 
       
   144   Give a regular expression that can recognise the same language as
       
   145   this automaton. (Hint: If you use Brzozwski's method, you can assume
       
   146   Arden's lemma which states that an equation of the form $q = q\cdot r + s$
       
   147   has the unique solution $q = s \cdot r^*$.)
    77 \end{enumerate}
   148 \end{enumerate}
    78 
       
    79 
       
    80 
   149 
    81 \end{document}
   150 \end{document}
    82 
   151 
    83 %%% Local Variables: 
   152 %%% Local Variables: 
    84 %%% mode: latex
   153 %%% mode: latex