hws/hw09.tex
author Christian Urban <urbanc@in.tum.de>
Tue, 23 Aug 2016 15:38:20 +0200
changeset 416 357c395ae838
parent 359 db106e5b7c4d
child 459 780486571e38
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
208
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
\documentclass{article}
292
7ed2a25dd115 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 208
diff changeset
     2
\usepackage{../style}
7ed2a25dd115 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 208
diff changeset
     3
\usepackage{../graphics}
208
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
\begin{document}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     6
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     7
\section*{Homework 9}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
359
db106e5b7c4d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 314
diff changeset
     9
\HEADER
db106e5b7c4d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 314
diff changeset
    10
208
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    11
\begin{enumerate}
292
7ed2a25dd115 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 208
diff changeset
    12
\item Describe what is meant by \emph{eliminating tail
7ed2a25dd115 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 208
diff changeset
    13
      recursion}, when such an optimization can be applied and
7ed2a25dd115 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 208
diff changeset
    14
      why it is a benefit?
208
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    15
314
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    16
%  \item It is true (I confirmed it) that
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    17
%  
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    18
%  \begin{center} if $\varnothing$ does not occur in $r$
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    19
%  \;\;then\;\;$L(r) \not= \{\}$ 
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    20
%  \end{center}
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    21
%  
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    22
%  \noindent
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    23
%  holds, or equivalently
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    24
%  
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    25
%  \begin{center}
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    26
%  $L(r) = \{\}$ \;\;implies\;\; $\varnothing$ occurs in $r$.
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    27
%  \end{center}
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    28
%  
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    29
%  \noindent
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    30
%  You can prove either version by induction on $r$. The best way to
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    31
%  make more formal what is meant by `$\varnothing$ occurs in $r$', you can define
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    32
%  the following function:
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    33
%  
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    34
%  \begin{center}
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    35
%  \begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}}
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    36
%  $occurs(\varnothing)$      & $\dn$ & $true$\\
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    37
%  $occurs(\epsilon)$           & $\dn$ &  $f\!alse$\\
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    38
%  $occurs (c)$                    & $\dn$ &  $f\!alse$\\
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    39
%  $occurs (r_1 + r_2)$       & $\dn$ &  $occurs(r_1) \vee occurs(r_2)$\\ 
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    40
%  $occurs (r_1 \cdot r_2)$ & $\dn$ &  $occurs(r_1) \vee occurs(r_2)$\\
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    41
%  $occurs (r^*)$                & $\dn$ & $occurs(r)$ \\
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    42
%  \end{tabular}
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    43
%  \end{center}
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    44
%  
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    45
%  \noindent
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    46
%  Now you can prove 
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    47
%  
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    48
%  \begin{center}
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    49
%  $L(r) = \{\}$ \;\;implies\;\; $occurs(r)$.
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    50
%  \end{center}
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    51
%  
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    52
%  \noindent
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    53
%  The interesting cases are $r_1 + r_2$ and $r^*$.
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    54
%  The other direction is not true, that is if $occurs(r)$ then $L(r) = \{\}$. A counter example
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    55
%  is $\varnothing + a$: although $\varnothing$ occurs in this regular expression, the corresponding
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    56
%  language is not empty. The obvious extension to include the not-regular expression, $\sim r$,
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    57
%  also leads to an incorrect statement. Suppose we add the clause
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    58
%    
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    59
%  \begin{center}
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    60
%  \begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}}
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    61
%  $occurs(\sim r)$      & $\dn$ & $occurs(r)$
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    62
%  \end{tabular}
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    63
%  \end{center}  
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    64
%  
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    65
%  \noindent
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    66
%  to the definition above, then it will not be true that
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    67
%  
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    68
%  \begin{center}
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    69
%  $L(r) = \{\}$ \;\;implies\;\; $occurs(r)$.
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    70
%  \end{center}
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    71
%  
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    72
%  \noindent
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    73
%  Assume the alphabet contains just $a$ and $b$, find a counter example to this
7dd5797a5ffa updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 292
diff changeset
    74
%  property.
208
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    75
  
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    76
\end{enumerate}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    77
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    78
\end{document}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    79
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    80
%%% Local Variables: 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    81
%%% mode: latex
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    82
%%% TeX-master: t
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    83
%%% End: