hws/hw02.tex
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Fri, 02 Oct 2015 08:48:46 +0100
changeset 342 c235e0aeb8df
parent 294 c29853b672fb
child 347 22b5294daa2a
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}
22
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
\begin{document}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
\section*{Homework 2}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
\begin{enumerate}
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
     9
\item What is the language recognised by the regular expressions
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    10
  $(\varnothing^*)^*$.
258
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
    11
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    12
\item Review the first handout about sets of strings and read the
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    13
  second handout. Assuming the alphabet is the set $\{a, b\}$, decide
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    14
  which of the following equations are true in general for arbitrary
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    15
  languages $A$, $B$ and $C$:
115
86c1c049eb3e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 104
diff changeset
    16
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    17
  \begin{eqnarray}
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    18
    (A \cup B) @ C & =^? & A @ C \cup B @ C\nonumber\\
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    19
    A^* \cup B^*   & =^? & (A \cup B)^*\nonumber\\
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    20
    A^* @ A^*      & =^? & A^*\nonumber\\
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    21
    (A \cap B)@ C  & =^? & (A@C) \cap (B@C)\nonumber
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    22
  \end{eqnarray}
104
ffde837b1db1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 102
diff changeset
    23
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    24
  \noindent In case an equation is true, give an explanation; otherwise
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    25
  give a counter-example.
104
ffde837b1db1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 102
diff changeset
    26
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    27
\item Given the regular expressions $r_1 = \epsilon$ and $r_2 =
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    28
  \varnothing$ and $r_3 = a$. How many strings can the regular
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    29
  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
    30
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    31
\item Give regular expressions for (a) decimal numbers and for (b)
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    32
  binary numbers. (Hint: Observe that the empty string is not a
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    33
  number. Also observe that leading 0s are normally not written.)
22
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
258
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
    35
\item Decide whether the following two regular expressions are
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    36
  equivalent $(\epsilon + a)^* \equiv^? a^*$ and $(a \cdot b)^* \cdot
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    37
  a \equiv^? a \cdot (b \cdot a)^*$.
22
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    39
\item Given the regular expression $r = (a \cdot b + b)^*$.  Compute
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    40
  what the derivative of $r$ is with respect to $a$, $b$ and $c$. Is
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    41
  $r$ nullable?
22
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
\item Prove that for all regular expressions $r$ we have
258
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
    44
      
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
    45
\begin{center} 
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
    46
  $\textit{nullable}(r) \quad \text{if and only if} 
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
    47
  \quad [] \in L(r)$ 
22
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
\end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
258
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
    50
  Write down clearly in each case what you need to prove and
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
    51
  what are the assumptions. 
1e4da6d2490c updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 132
diff changeset
    52
  
292
7ed2a25dd115 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 267
diff changeset
    53
\item Define what is meant by the derivative of a regular expressions
267
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    54
  with respoect to a character. (Hint: The derivative is defined
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    55
  recursively.)
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    56
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    57
\item Assume the set $Der$ is defined as
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    58
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    59
  \begin{center}
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    60
    $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
    61
  \end{center}
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    62
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    63
  What is the relation between $Der$ and the notion of derivative of
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    64
  regular expressions?
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    65
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    66
\item Give a regular expression over the alphabet $\{a,b\}$
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    67
  recognising all strings that do not contain any substring $bb$ and
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    68
  end in $a$.
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    69
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    70
\item Do $(a + b)^* \cdot b^+$ and $(a^* \cdot b^+) + (b^*\cdot b^+)$ define 
a1544b804d1e updated homeworks
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    71
  the same language?
294
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    72
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    73
\item Define the function $zeroable$ by recursion over regular
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    74
  expressions. This function should satisfy the property
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    75
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    76
  \[
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    77
  zeroable(r) \;\;\text{if and only if}\;\;L(r) = \varnothing\qquad(*)
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    78
  \]
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    79
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    80
  The function $nullable$ for the not-regular expressions can be defined
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    81
  by 
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    82
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    83
  \[
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    84
  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
    85
  \]
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    86
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    87
  Unfortunately, a similar definition for $zeroable$ does not satisfy
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    88
  the property in $(*)$:
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    89
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    90
  \[
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    91
  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
    92
  \]
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    93
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    94
  Find out why?
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    95
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    96
\item Give a regular expressions that can recognise all strings from the 
c29853b672fb updated hws
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    97
  language $\{a^n\;|\;\exists k. n = 3 k + 1 \}$.
22
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    98
\end{enumerate}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
\end{document}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   102
%%% Local Variables: 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   103
%%% mode: latex
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   104
%%% TeX-master: t
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
%%% End: