hws/hw02.tex
author Christian Urban <christian.urban@kcl.ac.uk>
Fri, 25 Oct 2024 18:54:08 +0100
changeset 971 51e00f223792
parent 967 ce5de01b9632
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
\documentclass{article}
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
     2
\usepackage{../style}
889
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
     3
\usepackage{../graphicss}
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
     4
22
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
\begin{document}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
\section*{Homework 2}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
916
10f834eb0a9e texupdate
Christian Urban <christian.urban@kcl.ac.uk>
parents: 891
diff changeset
     9
%\HEADER
347
22b5294daa2a updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 294
diff changeset
    10
22
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
\begin{enumerate}
499
dfd0f41f8668 updated
Christian Urban <urbanc@in.tum.de>
parents: 471
diff changeset
    12
\item What is the difference between \emph{basic} regular expressions  
885
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
    13
  and \emph{extended} regular expressions?
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
    14
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
    15
  \solution{Basic regular expressions are $\ZERO$, $\ONE$, $c$, $r_1 + r_2$,
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
    16
    $r_1 \cdot r_2$, $r^*$. The extended ones are the bounded
967
ce5de01b9632 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 941
diff changeset
    17
    repetitions, not, etc.
ce5de01b9632 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 941
diff changeset
    18
ce5de01b9632 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 941
diff changeset
    19
ce5de01b9632 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 941
diff changeset
    20
    Maybe explain here how the extended regular expressions
ce5de01b9632 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 941
diff changeset
    21
    are defined in terms of the basic ones.
ce5de01b9632 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 941
diff changeset
    22
  }
499
dfd0f41f8668 updated
Christian Urban <urbanc@in.tum.de>
parents: 471
diff changeset
    23
  
401
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
    24
\item What is the language recognised by the regular
885
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
    25
  expressions $(\ZERO^*)^*$.
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
    26
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
    27
  \solution{$L(\ZERO^*{}^*) = \{[]\}$,
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
    28
    remember * always includes the empty string}
258
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
    29
401
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
    30
\item Review the first handout about sets of strings and read
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
    31
      the second handout. Assuming the alphabet is the set
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
    32
      $\{a, b\}$, decide which of the following equations are
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
    33
      true in general for arbitrary languages $A$, $B$ and
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
    34
      $C$:
115
86c1c049eb3e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
    35
401
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
    36
      \begin{eqnarray}
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
    37
      (A \cup B) @ C & =^? & A @ C \cup B @ C\nonumber\\
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
    38
      A^* \cup B^*   & =^? & (A \cup B)^*\nonumber\\
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
    39
      A^* @ A^*      & =^? & A^*\nonumber\\
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
    40
      (A \cap B)@ C  & =^? & (A@C) \cap (B@C)\nonumber
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
    41
      \end{eqnarray}
104
ffde837b1db1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 102
diff changeset
    42
401
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
    43
      \noindent In case an equation is true, give an
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
    44
      explanation; otherwise give a counter-example.
104
ffde837b1db1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 102
diff changeset
    45
885
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
    46
      \solution{1 + 3 are equal; 2 + 4 are not. Interesting is 4 where
928
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
    47
        $A = \{[a]\}$, $B = \{[]\}$ and $C = \{[a], []\}$ is an
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
    48
        counter-example.\medskip
889
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    49
928
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
    50
        For equations like 3 it is always a good idea to prove the
889
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    51
        two inclusions
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    52
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    53
        \[
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    54
          A^* \subseteq  A^* @ A^*   \qquad
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    55
          A^* @ A^* \subseteq A^*
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    56
        \]  
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    57
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    58
        This means for every string $s$ we have to show
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    59
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    60
        \[
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    61
          s \in A^*    \;\textit{implies}\;  s \in A^* @ A^* \qquad
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    62
          s \in A^* @ A^* \;\textit{implies}\;  s \in A^*
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    63
        \]
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    64
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    65
        The first one is easy because $[] \in A^*$ and therefore
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    66
        $s @ [] \in A^* @ A^*$.
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    67
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    68
        The second one says that $s$ must be of the form $s = s_1 @ s_2$ with
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    69
        $s_1 \in A^*$ and $s_2 \in A^*$. We have to show that
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    70
        $s_1 @ s_2 \in A^*$.
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    71
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    72
        If $s_1 \in A^*$ then there exists an $n$ such that $s_1 \in A^n$, and
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    73
        if $s_2 \in A^*$ then there exists an $m$ such that $s_2 \in A^m$.\bigskip
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    74
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    75
928
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
    76
        Aside: We are going to show the following power law
889
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    77
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    78
        \[
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    79
        A^n \,@\, A^m = A^{n+m}  
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    80
        \]  
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    81
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    82
        We prove that by induction on $n$.
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    83
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    84
        Case $n = 0$: $A^0 \,@\, A^m = A^{0+m}$ holds because $A^0 = \{[]\}$
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    85
        and $\{[]\} \,@\, A^m = A ^ m$ and $0 + m = m$.\medskip
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    86
        
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    87
        Case $n + 1$: The induction hypothesis is
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    88
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    89
        \[ A^n \,@\, A^m = A^{n+m}
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    90
        \]
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    91
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    92
        We need to prove
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    93
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    94
        \[
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    95
        A^{n+1} \,@\, A^m = A^{(n+1)+m}  
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    96
        \]
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    97
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    98
        The left-hand side is $(A \,@\, A^n) \,@\, A^m$ by the definition of
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
    99
        the power operation. We can rearrange that
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   100
        to $A \,@\, (A^n \,@\, A^m)$.   \footnote{Because for all languages $A$, $B$, $C$ we have $(A @ B) @ C = A @ (B @ C)$.}
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   101
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   102
        By the induction hypothesis we know that $A^n \,@\, A^m = A^{n+m}$.
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   103
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   104
        So we have $A \,@\, (A^{n+m})$. But this is $A^{(n+m)+1}$ again if we
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   105
        apply the definition of the power operator. If we
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   106
        rearrange that we get $A^{(n+1)+m}$ and are done with
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   107
        what we need to prove for the power law.\bigskip
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   108
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   109
        Picking up where we left, we know that $s_1 \in A^n$ and $s_2 \in A^m$. This now implies that $s_1 @ s_2\in A^n @ A^m$. By the power law this means
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   110
        $s_1 @ s_2\in A^{n+m}$. But this also means $s_1 @ s_2\in A^*$.
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   111
      }
885
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
   112
401
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   113
\item Given the regular expressions $r_1 = \ONE$ and $r_2 =
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   114
      \ZERO$ and $r_3 = a$. How many strings can the regular
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   115
      expressions $r_1^*$, $r_2^*$ and $r_3^*$ each match?
104
ffde837b1db1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 102
diff changeset
   116
885
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
   117
      \solution{$r_1$ and $r_2$ can match the empty string only, $r_3$ can
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
   118
        match $[]$, $a$, $aa$, ....}
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
   119
401
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   120
\item Give regular expressions for (a) decimal numbers and for
617
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 499
diff changeset
   121
      (b) binary numbers. Hint: Observe that the empty string
401
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   122
      is not a number. Also observe that leading 0s are
617
f7de0915fff2 updated
Christian Urban <urbanc@in.tum.de>
parents: 499
diff changeset
   123
      normally not written---for example the JSON format for numbers
891
00ffcd796ffb updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 889
diff changeset
   124
      explicitly forbids this. So 007 is not a number according to JSON.
22
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
941
66adcae6c762 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 931
diff changeset
   126
      \solution{Just numbers without leading 0s: $0 + (1..9)\cdot(0..9)^*$;
885
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
   127
        can be extended to decimal; similar for binary numbers
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
   128
      }
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
   129
258
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
   130
\item Decide whether the following two regular expressions are
401
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   131
      equivalent $(\ONE + a)^* \equiv^? a^*$ and $(a \cdot
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   132
      b)^* \cdot a \equiv^? a \cdot (b \cdot a)^*$.
22
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   133
885
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
   134
      \solution{Both are equivalent, but why the second? Essentially you have to show that each string in one set is in the other. For 2 this means you can do an induction proof that $(ab)^na$ is the same string as $a(ba)^n$, where the former is in the first set and the latter in the second.}
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
   135
22
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   136
881
3b2f76950473 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 880
diff changeset
   137
\item Give an argument for why the following holds:
885
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
   138
  if $r$ is nullable then $r^{\{n\}} \equiv r^{\{..n\}}$.
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
   139
928
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   140
  \solution{ This requires an inductive proof. There are a number of
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   141
    ways to prove this. It is clear that if $s \in L (r^{\{n\}})$ then
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   142
    also $s \in L (r^{\{..n\}})$.
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   143
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   144
    So one way to prove this is to show
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   145
    that if $s \in L (r^{\{..n\}})$ then also $s \in L (r^{\{n\}})$
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   146
    (under the assumption that $r$ is nullable, otherwise it would not
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   147
    be true).  The assumption $s \in L (r^{\{..n\}})$ means
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   148
    that $s \in L(r^{\{i\}})$ with $i \leq n$ holds
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   149
    and we have to show that $s \in L(r^{\{n\}})$ holds. 
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   150
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   151
    One can do this by induction for languages as follows:
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   152
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   153
    \[
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   154
      \textit{if}\; [] \in A \;\textit{and}\; s \in A^n
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   155
      \;\textit{then}\; s \in A^{n+m}
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   156
    \]  
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   157
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   158
    The proof is by induction on $m$. The base case $m=0$ is trivial.
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   159
    For the $m + 1$ case we have the induction hypothesis:
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   160
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   161
    \[
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   162
      \textit{if}\; [] \in A \;\textit{and}\; s \in A^n
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   163
      \;\textit{then}\; s \in A^{n+m}  
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   164
    \]  
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   165
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   166
    and we have to show
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   167
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   168
    \[
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   169
    s \in A^{n+m+1}   
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   170
    \]  
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   171
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   172
    under the assumption $[] \in A$ and $s \in A^n$. From the
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   173
    assumptions and the IH we can infer that $s\in A^{n + m}$.
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   174
    Then using the assumption $[] \in A$ we can infer that also
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   175
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   176
    \[
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   177
      s\in A \,@\, A^{n + m}
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   178
    \]
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   179
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   180
    which is equivalent to what we need to show $s \in A^{n+m+1}$.
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   181
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   182
    Now we know $s \in L(r^{\{i\}})$ with $i \leq n$. Since $i + m = n$
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   183
    for some $m$ we can conclude that $s \in L(r^{\{n\}})$. Done.
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   184
    
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   185
  }
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   186
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   187
\item Given the regular expression $r = (a \cdot b + b)^*$.
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   188
      Compute what the derivative of $r$ is with respect to
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   189
      $a$, $b$ and $c$. Is $r$ nullable?
258
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
   190
  
355
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 347
diff changeset
   191
\item Define what is meant by the derivative of a regular
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 347
diff changeset
   192
      expressions with respect to a character. (Hint: The
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 347
diff changeset
   193
      derivative is defined recursively.)
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   194
928
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   195
      \solution{The recursive function for $der$.}
885
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
   196
      
768
34f77b976b88 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 617
diff changeset
   197
\item  Assume the set $Der$ is defined as
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   198
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   199
  \begin{center}
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   200
    $Der\,c\,A \dn \{ s \;|\;  c\!::\!s \in A\}$
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   201
  \end{center}
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   202
401
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   203
      What is the relation between $Der$ and the notion of
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   204
      derivative of regular expressions?
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   205
885
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
   206
      \solution{Main property is $L(der\,c\,r) = Der\,c\,(L(r))$.}
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
   207
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   208
\item Give a regular expression over the alphabet $\{a,b\}$
401
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   209
      recognising all strings that do not contain any
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   210
      substring $bb$ and end in $a$.
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   211
931
14a6adca16b8 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 928
diff changeset
   212
      \solution{$((ba)^* \cdot (a)^*)^*\,\cdot\,a + ba$ \quad Not sure whether this can be simplified.}
885
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
   213
401
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   214
\item Do $(a + b)^* \cdot b^+$ and $(a^* \cdot b^+) +
885
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
   215
  (b^*\cdot b^+)$ define the same language?
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
   216
889
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   217
  \solution{No, the first one can match for example abababababbbbb
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   218
  while the second can only match for example aaaaaabbbbb or bbbbbbb}
294
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
   219
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
   220
\item Define the function $zeroable$ by recursion over regular
401
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   221
      expressions. This function should satisfy the property
294
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
   222
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
   223
  \[
401
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   224
  zeroable(r) \;\;\text{if and only if}\;\;L(r) = \{\}\qquad(*)
294
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
   225
  \]
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
   226
401
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   227
      The function $nullable$ for the not-regular expressions
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   228
      can be defined by 
294
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
   229
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
   230
  \[
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
   231
  nullable(\sim r) \dn \neg(nullable(r))
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
   232
  \]
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
   233
401
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   234
      Unfortunately, a similar definition for $zeroable$ does
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   235
      not satisfy the property in $(*)$:
294
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
   236
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
   237
  \[
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
   238
  zeroable(\sim r) \dn \neg(zeroable(r))
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
   239
  \]
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
   240
889
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   241
  Find a counter example?
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   242
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   243
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   244
  \solution{
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   245
    Here the idea is that nullable for NOT can be defined as
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   246
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   247
    \[nullable(\sim r) \dn \neg(nullable(r))\]
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   248
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   249
    This will satisfy the property
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   250
    $nullable(r) \;\;\text{if and only if}\;\;[] \in L(r)$. (Remember how
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   251
    $L(\sim r)$ is defined).\bigskip
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   252
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   253
    But you cannot define
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   254
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   255
    \[zeroable(\sim r) \dn \neg(zeroable(r))\]
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   256
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   257
    because if $r$ for example is $\ONE$ then $\sim \ONE$ can match
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   258
    some strings (all non-empty strings). So $zeroable$ should be false. But if we follow
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   259
    the above definition we would obtain $\neg(zeroable(\ONE))$. According
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   260
    to the definition of $zeroable$ for $\ONE$ this would be false,
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   261
    but if we now negate false, we get actually true. So the above
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   262
    definition would not satisfy the property
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   263
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   264
    \[
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   265
      zeroable(r) \;\;\text{if and only if}\;\;L(r) = \{\}
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   266
    \]  
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   267
    }
294
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
   268
401
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   269
\item Give a regular expressions that can recognise all
5d85dc9779b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   270
      strings from the language $\{a^n\;|\;\exists k.\; n = 3 k
885
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
   271
      + 1 \}$.
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
   272
526aaee62a3e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 881
diff changeset
   273
      \solution{$a(aaa)^*$}
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 401
diff changeset
   274
      
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 401
diff changeset
   275
\item Give a regular expression that can recognise an odd 
889
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   276
  number of $a$s or an even number of $b$s.
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   277
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   278
  \solution{
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   279
    If the a's and b's are meant to be separate, then this is easy 
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   280
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   281
    \[a(aa)^* + (bb)^*\]
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   282
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   283
    If the letters are mixed, then this is difficult
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   284
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   285
    \[(aa|bb|(ab|ba)\cdot (aa|bb)^* \cdot (ba|ab))^* \cdot (b|(ab|ba)(bb|aa)^* \cdot a)
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   286
    \]
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   287
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   288
    (copied from somewhere ;o)
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   289
928
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   290
    The idea behind this monstrous regex is essentially the DFA
889
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   291
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   292
\begin{center}    
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   293
\begin{tikzpicture}[scale=1,>=stealth',very thick,
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   294
                    every state/.style={minimum size=0pt,
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   295
                    draw=blue!50,very thick,fill=blue!20}]
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   296
  \node[state,initial]   (q0) at (0,2) {$q_0$};
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   297
  \node[state,accepting] (q1) at (2,2) {$q_1$};
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   298
  \node[state]           (q2) at (0,0) {$q_2$};
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   299
  \node[state]           (q3) at (2,0) {$q_3$};
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   300
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   301
 \path[->]  (q0) edge[bend left] node[above] {$a$} (q1)
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   302
            (q1) edge[bend left] node[above] {$a$} (q0)
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   303
            (q2) edge[bend left] node[above] {$a$} (q3)
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   304
            (q3) edge[bend left] node[above] {$a$} (q2)
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   305
            (q0) edge[bend left] node[right] {$b$} (q2)
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   306
            (q2) edge[bend left] node[left]  {$b$} (q0)
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   307
            (q1) edge[bend left] node[right] {$b$} (q3)
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   308
            (q3) edge[bend left] node[left]  {$b$} (q1);
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   309
\end{tikzpicture}
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   310
\end{center}
928
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   311
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   312
  Maybe a good idea to reconsider this example in Lecture 3
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   313
  where the Brzozowski algorithm for DFA $\rightarrow$ Regex
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 916
diff changeset
   314
  can be used.
889
00c1c3408c93 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 885
diff changeset
   315
}
444
3056a4c071b0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 404
diff changeset
   316
3056a4c071b0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 404
diff changeset
   317
\item \POSTSCRIPT  
404
245d302791c7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 401
diff changeset
   318
\end{enumerate}
22
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   319
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   320
\end{document}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   321
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   322
%%% Local Variables: 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   323
%%% mode: latex
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   324
%%% TeX-master: t
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   325
%%% End: