44
|
1 |
\documentclass[dvipsnames,14pt,t]{beamer}
|
270
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
2 |
\usepackage{../slides}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
3 |
\usepackage{../graphics}
|
215
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
4 |
\usepackage{../langs}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
5 |
\usepackage{../data}
|
44
|
6 |
|
270
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
7 |
\hfuzz=220pt
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
8 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
9 |
\pgfplotsset{compat=1.11}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
10 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
11 |
\newcommand{\bl}[1]{\textcolor{blue}{#1}}
|
44
|
12 |
|
|
13 |
% beamer stuff
|
270
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
14 |
\renewcommand{\slidecaption}{AFL 05, King's College London}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
15 |
|
44
|
16 |
|
|
17 |
\begin{document}
|
|
18 |
|
|
19 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
270
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
20 |
\begin{frame}[t]
|
44
|
21 |
\frametitle{%
|
|
22 |
\begin{tabular}{@ {}c@ {}}
|
|
23 |
\\[-3mm]
|
|
24 |
\LARGE Automata and \\[-2mm]
|
|
25 |
\LARGE Formal Languages (5)\\[3mm]
|
|
26 |
\end{tabular}}
|
|
27 |
|
|
28 |
\normalsize
|
|
29 |
\begin{center}
|
|
30 |
\begin{tabular}{ll}
|
|
31 |
Email: & christian.urban at kcl.ac.uk\\
|
147
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
32 |
Office: & S1.27 (1st floor Strand Building)\\
|
44
|
33 |
Slides: & KEATS (also home work is there)\\
|
|
34 |
\end{tabular}
|
|
35 |
\end{center}
|
270
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
36 |
\end{frame}
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
37 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
44
|
38 |
|
|
39 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
147
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
40 |
\begin{frame}[c]
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
41 |
\frametitle{\begin{tabular}{c}Last Week\\ Regexes and Values\end{tabular}}
|
44
|
42 |
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
43 |
Regular expressions and their corresponding values:
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
44 |
|
147
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
45 |
\begin{center}
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
46 |
\begin{columns}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
47 |
\begin{column}{3cm}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
48 |
\begin{tabular}{@{}rrl@{}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
49 |
\bl{$r$} & \bl{$::=$} & \bl{$\varnothing$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
50 |
& \bl{$\mid$} & \bl{$\epsilon$} \\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
51 |
& \bl{$\mid$} & \bl{$c$} \\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
52 |
& \bl{$\mid$} & \bl{$r_1 \cdot r_2$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
53 |
& \bl{$\mid$} & \bl{$r_1 + r_2$} \\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
54 |
\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
55 |
& \bl{$\mid$} & \bl{$r^*$} \\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
56 |
\end{tabular}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
57 |
\end{column}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
58 |
\begin{column}{3cm}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
59 |
\begin{tabular}{@{\hspace{-7mm}}rrl@{}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
60 |
\bl{$v$} & \bl{$::=$} & \\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
61 |
& & \bl{$Empty$} \\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
62 |
& \bl{$\mid$} & \bl{$Char(c)$} \\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
63 |
& \bl{$\mid$} & \bl{$Seq(v_1,v_2)$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
64 |
& \bl{$\mid$} & \bl{$Left(v)$} \\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
65 |
& \bl{$\mid$} & \bl{$Right(v)$} \\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
66 |
& \bl{$\mid$} & \bl{$[v_1,\ldots\,v_n]$} \\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
67 |
\end{tabular}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
68 |
\end{column}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
69 |
\end{columns}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
70 |
\end{center}
|
44
|
71 |
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
72 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
73 |
\end{frame}
|
147
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
74 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
75 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
76 |
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
77 |
|
147
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
78 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
272
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
79 |
\begin{frame}[c]
|
44
|
80 |
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
81 |
\begin{textblock}{10}(3,5)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
82 |
\begin{tikzpicture}[scale=2,node distance=1.3cm,every node/.style={minimum size=8mm}]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
83 |
\node (r1) {\bl{$r_1$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
84 |
\node (r2) [right=of r1] {\bl{$r_2$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
85 |
\draw[->,line width=1mm] (r1) -- (r2) node[above,midway] {\bl{$der\,a$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
86 |
\node (r3) [right=of r2] {\bl{$r_3$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
87 |
\draw[->,line width=1mm] (r2) -- (r3) node[above,midway] {\bl{$der\,b$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
88 |
\node (r4) [right=of r3] {\bl{$r_4$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
89 |
\draw[->,line width=1mm] (r3) -- (r4) node[above,midway] {\bl{$der\,c$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
90 |
\draw (r4) node[anchor=west] {\;\raisebox{3mm}{\bl{$nullable$}}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
91 |
\node (v4) [below=of r4] {\bl{$v_4$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
92 |
\draw[->,line width=1mm] (r4) -- (v4);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
93 |
\node (v3) [left=of v4] {\bl{$v_3$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
94 |
\draw[->,line width=1mm] (v4) -- (v3) node[below,midway] {\bl{$inj\,c$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
95 |
\node (v2) [left=of v3] {\bl{$v_2$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
96 |
\draw[->,line width=1mm] (v3) -- (v2) node[below,midway] {\bl{$inj\,b$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
97 |
\node (v1) [left=of v2] {\bl{$v_1$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
98 |
\draw[->,line width=1mm] (v2) -- (v1) node[below,midway] {\bl{$inj\,a$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
99 |
\draw[->,line width=0.5mm] (r3) -- (v3);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
100 |
\draw[->,line width=0.5mm] (r2) -- (v2);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
101 |
\draw[->,line width=0.5mm] (r1) -- (v1);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
102 |
\draw (r4) node[anchor=north west] {\;\raisebox{-8mm}{\bl{$mkeps$}}};
|
147
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
103 |
\end{tikzpicture}
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
104 |
\end{textblock}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
105 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
106 |
\only<2->{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
107 |
\begin{textblock}{6}(1,0.8)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
108 |
\begin{bubble}[6cm]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
109 |
\small
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
110 |
\begin{tabular}{ll}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
111 |
\bl{$r_1$}: & \bl{$a \cdot (b \cdot c)$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
112 |
\bl{$r_2$}: & \bl{$\epsilon \cdot (b \cdot c)$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
113 |
\bl{$r_3$}: & \bl{$(\varnothing \cdot (b \cdot c)) + (\epsilon \cdot c)$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
114 |
\bl{$r_4$}: & \bl{$(\varnothing \cdot (b \cdot c)) + ((\varnothing \cdot c) + \epsilon)$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
115 |
\end{tabular}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
116 |
\end{bubble}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
117 |
\end{textblock}}
|
147
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
118 |
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
119 |
\only<2->{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
120 |
\begin{textblock}{6}(5,11.4)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
121 |
\begin{bubble}[7.6cm]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
122 |
\small
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
123 |
\begin{tabular}{ll}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
124 |
\bl{$v_1$}: & \bl{$Seq(Char(a), Seq(Char(b), Char(c)))$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
125 |
\bl{$v_2$}: & \bl{$Seq(Empty, Seq(Char(b), Char(c)))$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
126 |
\bl{$v_3$}: & \bl{$Right(Seq(Empty, Char(c)))$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
127 |
\bl{$v_4$}: & \bl{$Right(Right(Empty))$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
128 |
\end{tabular}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
129 |
\end{bubble}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
130 |
\end{textblock}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
131 |
\end{frame}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
132 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
133 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
134 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
135 |
\begin{frame}[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
136 |
\frametitle{Mkeps}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
137 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
138 |
Finding a (posix) value for recognising the empty string:
|
147
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
139 |
|
44
|
140 |
\begin{center}
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
141 |
\begin{tabular}{lcl}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
142 |
\bl{$mkeps\,\epsilon$} & \bl{$\dn$} & \bl{$Empty$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
143 |
\bl{$mkeps\,r_1 + r_2$} & \bl{$\dn$} & \bl{if $nullable(r_1)$} \\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
144 |
& & \bl{then $Left(mkeps(r_1))$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
145 |
& & \bl{else $Right(mkeps(r_2))$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
146 |
\bl{$mkeps\,r_1 \cdot r_2$} & \bl{$\dn$} & \bl{$Seq(mkeps(r_1),mkeps(r_2))$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
147 |
\bl{$mkeps\,r^*$} & \bl{$\dn$} & \bl{$[]$} \\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
148 |
\end{tabular}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
149 |
\end{center}
|
147
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
150 |
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
151 |
\end{frame}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
152 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
153 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
154 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
155 |
\begin{frame}[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
156 |
\frametitle{Inject}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
157 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
158 |
Injecting (``Adding'') a character to a value\\
|
147
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
159 |
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
160 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
161 |
\begin{tabular}{l@{\hspace{1mm}}c@{\hspace{1mm}}l}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
162 |
\bl{$inj\,(c)\,c\,Empty$} & \bl{$\dn$} & \bl{$Char\,c$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
163 |
\bl{$inj\,(r_1 + r_2)\,c\,Left(v)$} & \bl{$\dn$} & \bl{$Left(inj\,r_1\,c\,v)$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
164 |
\bl{$inj\,(r_1 + r_2)\,c\,Right(v)$} & \bl{$\dn$} & \bl{$Right(inj\,r_2\,c\,v)$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
165 |
\bl{$inj\,(r_1 \cdot r_2)\,c\,Seq(v_1,v_2)$} & \bl{$\dn$} & \bl{$Seq(inj\,r_1\,c\,v_1,v_2)$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
166 |
\bl{$inj\,(r_1 \cdot r_2)\,c\,Left(Seq(v_1,v_2))$} & \bl{$\dn$} & \bl{$Seq(inj\,r_1\,c\,v_1,v_2)$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
167 |
\bl{$inj\,(r_1 \cdot r_2)\,c\,Right(v)$} & \bl{$\dn$} & \bl{$Seq(mkeps(r_1),inj\,r_2\,c\,v)$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
168 |
\bl{$inj\,(r^*)\,c\,Seq(v,vs)$} & \bl{$\dn$} & \bl{$inj\,r\,c\,v\,::\,vs$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
169 |
\end{tabular}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
170 |
\end{center}\bigskip
|
147
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
171 |
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
172 |
\footnotesize
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
173 |
\bl{$inj$}: 1st arg $\mapsto$ a rexp; 2nd arg $\mapsto$ a character; 3rd arg $\mapsto$ a value
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
174 |
\end{frame}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
175 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
176 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
177 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
178 |
\begin{frame}[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
179 |
\frametitle{Flatten}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
180 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
181 |
Obtaining the string underlying a value:
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
182 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
183 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
184 |
\begin{tabular}{lcl}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
185 |
\bl{$|Empty|$} & \bl{$\dn$} & \bl{$[]$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
186 |
\bl{$|Char(c)|$} & \bl{$\dn$} & \bl{$[c]$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
187 |
\bl{$|Left(v)|$} & \bl{$\dn$} & \bl{$|v|$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
188 |
\bl{$|Right(v)|$} & \bl{$\dn$} & \bl{$|v|$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
189 |
\bl{$|Seq(v_1,v_2)|$}& \bl{$\dn$} & \bl{$|v_1| \,@\, |v_2|$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
190 |
\bl{$|[v_1,\ldots ,v_n]|$} & \bl{$\dn$} & \bl{$|v_1| \,@\ldots @\, |v_n|$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
191 |
\end{tabular}
|
147
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
192 |
\end{center}
|
44
|
193 |
|
272
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
194 |
\end{frame}
|
44
|
195 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
196 |
|
|
197 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
272
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
198 |
\begin{frame}[c]
|
44
|
199 |
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
200 |
\begin{textblock}{10}(3,5)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
201 |
\begin{tikzpicture}[scale=2,node distance=1.3cm,every node/.style={minimum size=8mm}]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
202 |
\node (r1) {\bl{$r_1$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
203 |
\node (r2) [right=of r1] {\bl{$r_2$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
204 |
\draw[->,line width=1mm] (r1) -- (r2) node[above,midway] {\bl{$der\,a$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
205 |
\node (r3) [right=of r2] {\bl{$r_3$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
206 |
\draw[->,line width=1mm] (r2) -- (r3) node[above,midway] {\bl{$der\,b$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
207 |
\node (r4) [right=of r3] {\bl{$r_4$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
208 |
\draw[->,line width=1mm] (r3) -- (r4) node[above,midway] {\bl{$der\,c$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
209 |
\draw (r4) node[anchor=west] {\;\raisebox{3mm}{\bl{$nullable$}}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
210 |
\node (v4) [below=of r4] {\bl{$v_4$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
211 |
\draw[->,line width=1mm] (r4) -- (v4);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
212 |
\node (v3) [left=of v4] {\bl{$v_3$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
213 |
\draw[->,line width=1mm] (v4) -- (v3) node[below,midway] {\bl{$inj\,c$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
214 |
\node (v2) [left=of v3] {\bl{$v_2$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
215 |
\draw[->,line width=1mm] (v3) -- (v2) node[below,midway] {\bl{$inj\,b$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
216 |
\node (v1) [left=of v2] {\bl{$v_1$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
217 |
\draw[->,line width=1mm] (v2) -- (v1) node[below,midway] {\bl{$inj\,a$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
218 |
\draw[->,line width=0.5mm] (r3) -- (v3);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
219 |
\draw[->,line width=0.5mm] (r2) -- (v2);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
220 |
\draw[->,line width=0.5mm] (r1) -- (v1);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
221 |
\draw (r4) node[anchor=north west] {\;\raisebox{-8mm}{\bl{$mkeps$}}};
|
147
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
222 |
\end{tikzpicture}
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
223 |
\end{textblock}
|
147
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
224 |
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
225 |
\begin{textblock}{6}(1,0.8)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
226 |
\begin{bubble}[6cm]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
227 |
\small
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
228 |
\begin{tabular}{ll}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
229 |
\bl{$r_1$}: & \bl{$a \cdot (b \cdot c)$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
230 |
\bl{$r_2$}: & \bl{$\epsilon \cdot (b \cdot c)$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
231 |
\bl{$r_3$}: & \bl{$(\varnothing \cdot (b \cdot c)) + (\epsilon \cdot c)$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
232 |
\bl{$r_4$}: & \bl{$(\varnothing \cdot (b \cdot c)) + ((\varnothing \cdot c) + \epsilon)$}\\
|
147
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
233 |
\end{tabular}
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
234 |
\end{bubble}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
235 |
\end{textblock}
|
147
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
236 |
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
237 |
\begin{textblock}{6}(1,11.4)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
238 |
\begin{bubble}[7.6cm]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
239 |
\small
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
240 |
\begin{tabular}{ll}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
241 |
\bl{$v_1$}: & \bl{$Seq(Char(a), Seq(Char(b), Char(c)))$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
242 |
\bl{$v_2$}: & \bl{$Seq(Empty, Seq(Char(b), Char(c)))$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
243 |
\bl{$v_3$}: & \bl{$Right(Seq(Empty, Char(c)))$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
244 |
\bl{$v_4$}: & \bl{$Right(Right(Empty))$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
245 |
\end{tabular}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
246 |
\end{bubble}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
247 |
\end{textblock}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
248 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
249 |
\begin{textblock}{6}(12,11.4)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
250 |
\begin{bubble}[2cm]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
251 |
\small
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
252 |
\begin{tabular}{ll}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
253 |
\bl{$|v_1|$}: & \bl{$abc$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
254 |
\bl{$|v_2|$}: & \bl{$bc$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
255 |
\bl{$|v_3|$}: & \bl{$c$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
256 |
\bl{$|v_4|$}: & \bl{$[]$}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
257 |
\end{tabular}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
258 |
\end{bubble}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
259 |
\end{textblock}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
260 |
|
44
|
261 |
|
272
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
262 |
\end{frame}
|
44
|
263 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
264 |
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
265 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
266 |
\begin{frame}[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
267 |
\frametitle{Simplification}
|
147
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
268 |
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
269 |
\begin{itemize}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
270 |
\item If we simplify after the derivative, then we are builing the
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
271 |
value for the simplified regular expression, but \emph{not} for the original
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
272 |
regular expression.
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
273 |
\end{itemize}
|
44
|
274 |
|
147
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
275 |
\begin{center}
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
276 |
\begin{tikzpicture}[scale=2,node distance=1.3cm,every node/.style={minimum size=8mm}]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
277 |
\node (r1) {\bl{$r_1$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
278 |
\node (r2) [right=of r1] {\bl{$r_2$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
279 |
\draw[->,line width=1mm] (r1) -- (r2) node[above,midway] {\bl{$der\,a$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
280 |
\node (r3) [right=of r2] {\bl{$r_3$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
281 |
\draw[->,line width=1mm] (r2) -- (r3) node[above,midway] {\bl{$der\,b$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
282 |
\node (r4) [right=of r3] {\bl{$r_4$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
283 |
\draw[->,line width=1mm] (r3) -- (r4) node[above,midway] {\bl{$der\,c$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
284 |
\draw (r4) node[anchor=west] {\;\raisebox{3mm}{\bl{$nullable$}}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
285 |
\node (v4) [below=of r4] {\bl{$v_4$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
286 |
\draw[->,line width=1mm] (r4) -- (v4);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
287 |
\node (v3) [left=of v4] {\bl{$v_3$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
288 |
\draw[->,line width=1mm] (v4) -- (v3) node[below,midway] {\bl{$inj\,c$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
289 |
\node (v2) [left=of v3] {\bl{$v_2$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
290 |
\draw[->,line width=1mm] (v3) -- (v2) node[below,midway] {\bl{$inj\,b$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
291 |
\node (v1) [left=of v2] {\bl{$v_1$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
292 |
\draw[->,line width=1mm] (v2) -- (v1) node[below,midway] {\bl{$inj\,a$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
293 |
\draw[->,line width=0.5mm] (r3) -- (v3);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
294 |
\draw[->,line width=0.5mm] (r2) -- (v2);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
295 |
\draw[->,line width=0.5mm] (r1) -- (v1);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
296 |
\draw (r4) node[anchor=north west] {\;\raisebox{-8mm}{\bl{$mkeps$}}};
|
147
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
297 |
\end{tikzpicture}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
298 |
\end{center}
|
44
|
299 |
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
300 |
\small
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
301 |
\hspace{4.5cm}\bl{$(\varnothing \cdot (b \cdot c)) + ((\varnothing \cdot c) + \epsilon)$}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
302 |
$\mapsto$
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
303 |
\bl{$\epsilon$}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
304 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
305 |
\end{frame}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
306 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
307 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
308 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
309 |
\begin{frame}[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
310 |
\frametitle{Rectification}
|
44
|
311 |
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
312 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
313 |
\begin{tabular}{l}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
314 |
\bl{$simp(r)$}:\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
315 |
\quad case \bl{$r = r_1 + r_2$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
316 |
\qquad let \bl{$(r_{1s}, f_{1s}) = simp(r_1)$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
317 |
\qquad \phantom{let} \bl{$(r_{2s}, f_{2s}) = simp(r_2)$}\smallskip\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
318 |
\qquad case \bl{$r_{1s} = \varnothing$}:
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
319 |
return \bl{$(r_{2s}, \lambda v. \,Right(f_{2s}(v)))$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
320 |
\qquad case \bl{$r_{2s} = \varnothing$}:
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
321 |
return \bl{$(r_{1s}, \lambda v. \,Left(f_{1s}(v)))$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
322 |
\qquad case \bl{$r_{1s} = r_{2s}$}:
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
323 |
return \bl{$(r_{1s}, \lambda v. \,Left(f_{1s}(v)))$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
324 |
\qquad otherwise:
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
325 |
return \bl{$(r_{1s} + r_{2s}, f_{alt}(f_{1s}, f_{2s}))$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
326 |
\end{tabular}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
327 |
\end{center}
|
44
|
328 |
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
329 |
\small
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
330 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
331 |
\begin{tabular}{l@{\hspace{1mm}}l}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
332 |
\bl{$f_{alt}(f_1, f_2) \dn$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
333 |
\qquad \bl{$\lambda v.\,$} case \bl{$v = Left(v')$}:
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
334 |
& return \bl{$Left(f_1(v'))$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
335 |
\qquad \phantom{$\lambda v.\,$} case \bl{$v = Right(v')$}:
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
336 |
& return \bl{$Right(f_2(v'))$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
337 |
\end{tabular}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
338 |
\end{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
339 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
340 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
341 |
\end{frame}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
342 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
44
|
343 |
|
|
344 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
345 |
\begin{frame}[c]
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
346 |
\frametitle{Rectification}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
347 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
348 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
349 |
\begin{tabular}{@{\hspace{-3mm}}l}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
350 |
\bl{$simp(r)$}:\ldots\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
351 |
\quad case \bl{$r = r_1 \cdot r_2$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
352 |
\qquad let \bl{$(r_{1s}, f_{1s}) = simp(r_1)$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
353 |
\qquad \phantom{let} \bl{$(r_{2s}, f_{2s}) = simp(r_2)$}\smallskip\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
354 |
\qquad case \bl{$r_{1s} = \varnothing$}:
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
355 |
return \bl{$(\varnothing, f_{error})$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
356 |
\qquad case \bl{$r_{2s} = \varnothing$}:
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
357 |
return \bl{$(\varnothing, f_{error})$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
358 |
\qquad case \bl{$r_{1s} = \epsilon$}:
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
359 |
return \bl{$(r_{2s}, \lambda v. \,Seq(f_{1s}(Empty), f_{2s}(v)))$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
360 |
\qquad case \bl{$r_{2s} = \epsilon$}:
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
361 |
return \bl{$(r_{1s}, \lambda v. \,Seq(f_{1s}(v), f_{2s}(Empty)))$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
362 |
\qquad otherwise:
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
363 |
return \bl{$(r_{1s} \cdot r_{2s}, f_{seq}(f_{1s}, f_{2s}))$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
364 |
\end{tabular}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
365 |
\end{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
366 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
367 |
\small
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
368 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
369 |
\begin{tabular}{l@{\hspace{1mm}}l}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
370 |
\bl{$f_{seq}(f_1, f_2) \dn$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
371 |
\qquad \bl{$\lambda v.\,$ case $v = Seq(v_1, v_2)$}:
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
372 |
& return \bl{$Seq(f_1(v_1), f_2(v_2))$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
373 |
\end{tabular}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
374 |
\end{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
375 |
\end{frame}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
376 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
44
|
377 |
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
378 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
379 |
\begin{frame}[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
380 |
\frametitle{Lexing with Simplification}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
381 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
382 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
383 |
\begin{tabular}{l@{\hspace{1mm}}c@{\hspace{1mm}}l}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
384 |
\bl{$lex\,r\,[]$} & \bl{$\dn$} & \bl{if $nullable(r)$ then $mkeps(r)$ else $error$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
385 |
\bl{$lex\,r\,c::s$} & \bl{$\dn$} & \bl{let $(r', frect) = simp(der(c, r))$}\smallskip\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
386 |
& & \bl{$inj\,r\,c\,(frect(lex(r', s)))$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
387 |
\end{tabular}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
388 |
\end{center}\bigskip
|
44
|
389 |
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
390 |
\begin{center}\small
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
391 |
\begin{tikzpicture}[node distance=1.1cm,every node/.style={minimum size=7mm}]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
392 |
\node (r1) {\bl{$r_1$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
393 |
\node (r2) [right=of r1] {\bl{$r_2$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
394 |
\draw[->,line width=1mm] (r1) -- (r2) node[above,midway] {\bl{$der\,a$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
395 |
\node (r3) [right=of r2] {\bl{$r_3$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
396 |
\draw[->,line width=1mm] (r2) -- (r3) node[above,midway] {\bl{$der\,b$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
397 |
\node (r4) [right=of r3] {\bl{$r_4$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
398 |
\draw[->,line width=1mm] (r3) -- (r4) node[above,midway] {\bl{$der\,c$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
399 |
\draw (r4) node[anchor=west] {\;\raisebox{3mm}{\bl{$nullable$}}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
400 |
\node (v4) [below=of r4] {\bl{$v_4$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
401 |
\draw[->,line width=1mm] (r4) -- (v4);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
402 |
\node (v3) [left=of v4] {\bl{$v_3$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
403 |
\draw[->,line width=1mm] (v4) -- (v3) node[below,midway] {\bl{$inj\,c$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
404 |
\node (v2) [left=of v3] {\bl{$v_2$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
405 |
\draw[->,line width=1mm] (v3) -- (v2) node[below,midway] {\bl{$inj\,b$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
406 |
\node (v1) [left=of v2] {\bl{$v_1$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
407 |
\draw[->,line width=1mm] (v2) -- (v1) node[below,midway] {\bl{$inj\,a$}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
408 |
\draw[->,line width=0.5mm] (r3) -- (v3);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
409 |
\draw[->,line width=0.5mm] (r2) -- (v2);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
410 |
\draw[->,line width=0.5mm] (r1) -- (v1);
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
411 |
\draw (r4) node[anchor=north west] {\;\raisebox{-8mm}{\bl{$mkeps$}}};
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
412 |
\end{tikzpicture}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
413 |
\end{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
414 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
415 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
416 |
\end{frame}
|
44
|
417 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
418 |
|
|
419 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
420 |
\begin{frame}[c]
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
421 |
\frametitle{Records}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
422 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
423 |
\begin{itemize}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
424 |
\item new regex: \bl{$(x:r)$}\hspace{7mm}new value: \bl{$Rec(x,v)$}\medskip\pause
|
44
|
425 |
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
426 |
\item \bl{$nullable(x:r) \dn nullable(r)$}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
427 |
\item \bl{$der\,c\,(x:r) \dn (x:der\,c\,r)$}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
428 |
\item \bl{$mkeps(x:r) \dn Rec(x, mkeps(r))$}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
429 |
\item \bl{$inj\,(x:r)\,c\,v \dn Rec(x, inj\,r\,c\,v)$}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
430 |
\end{itemize}\bigskip\bigskip\pause
|
44
|
431 |
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
432 |
\small
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
433 |
for extracting subpatterns \bl{$(z: ((x:ab) + (y:ba))$}
|
44
|
434 |
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
435 |
\end{frame}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
436 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
46
|
437 |
|
148
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
438 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
439 |
\begin{frame}[c]
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
440 |
\frametitle{While Tokens}
|
150
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
441 |
|
148
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
442 |
\begin{center}
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
443 |
\begin{tabular}{@{}r@{\hspace{2mm}}c@{\hspace{2mm}}l@{}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
444 |
\pcode{WHILE\_REGS} & $\dn$ & \raisebox{-1mm}{\large(}\pcode{("k" : KEYWORD)} +\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
445 |
& & \phantom{(}\pcode{("i" : ID)} +\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
446 |
& & \phantom{(}\pcode{("o" : OP)} + \\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
447 |
& & \phantom{(}\pcode{("n" : NUM)} + \\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
448 |
& & \phantom{(}\pcode{("s" : SEMI)} +\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
449 |
& & \phantom{(}\pcode{("p" : (LPAREN + RPAREN))} +\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
450 |
& & \phantom{(}\pcode{("b" : (BEGIN + END))} +\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
451 |
& & \phantom{(}\pcode{("w" : WHITESPACE)}\raisebox{-1mm}{\large)$^*$}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
452 |
\end{tabular}
|
148
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
453 |
\end{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
454 |
|
289
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
455 |
\end{frame}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
456 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
148
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
457 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
458 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
459 |
\mode<presentation>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
460 |
\begin{frame}[t]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
461 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
462 |
\consolas
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
463 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
464 |
"if true then then 42 else +"
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
465 |
\end{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
466 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
467 |
\only<1>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
468 |
\small\begin{tabular}{l}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
469 |
KEYWORD(if),\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
470 |
WHITESPACE,\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
471 |
IDENT(true),\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
472 |
WHITESPACE,\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
473 |
KEYWORD(then),\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
474 |
WHITESPACE,\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
475 |
KEYWORD(then),\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
476 |
WHITESPACE,\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
477 |
NUM(42),\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
478 |
WHITESPACE,\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
479 |
KEYWORD(else),\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
480 |
WHITESPACE,\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
481 |
OP(+)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
482 |
\end{tabular}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
483 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
484 |
\only<2>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
485 |
\small\begin{tabular}{l}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
486 |
KEYWORD(if),\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
487 |
IDENT(true),\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
488 |
KEYWORD(then),\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
489 |
KEYWORD(then),\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
490 |
NUM(42),\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
491 |
KEYWORD(else),\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
492 |
OP(+)
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
493 |
\end{tabular}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
494 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
495 |
\end{frame}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
496 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
497 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
498 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
499 |
\mode<presentation>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
500 |
\begin{frame}[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
501 |
|
150
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
502 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
503 |
There is one small problem with the tokenizer. How should we
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
504 |
tokenize:
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
505 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
506 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
507 |
{\consolas "x - 3"}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
508 |
\end{center}
|
149
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
509 |
|
150
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
510 |
\consolas
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
511 |
\begin{tabular}{@{}l}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
512 |
OP:\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
513 |
\hspace{5mm}\texttt{"+"}, \texttt{"-"}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
514 |
NUM:\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
515 |
\hspace{5mm}(NONZERODIGIT $\cdot$ DIGIT$^*$) + {''0''}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
516 |
NUMBER:\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
517 |
\hspace{5mm}NUM + (\texttt{"-"} $\cdot$ NUM)\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
518 |
\end{tabular}
|
149
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
519 |
|
148
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
520 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
521 |
\end{frame}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
522 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
523 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
524 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
525 |
\mode<presentation>{
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
526 |
\begin{frame}[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
527 |
\frametitle{\begin{tabular}{c}Two Rules\end{tabular}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
528 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
529 |
\begin{itemize}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
530 |
\item Longest match rule (``maximal munch rule''): The
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
531 |
longest initial substring matched by any regular expression is taken
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
532 |
as next token.\bigskip
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
533 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
534 |
\item Rule priority:
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
535 |
For a particular longest initial substring, the first regular
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
536 |
expression that can match determines the token.
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
537 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
538 |
\end{itemize}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
539 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
540 |
%\url{http://www.technologyreview.com/tr10/?year=2011}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
541 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
542 |
%finite deterministic automata/ nondeterministic automaton
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
543 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
544 |
%\item problem with infix operations, for example i-12
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
545 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
546 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
547 |
\end{frame}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
548 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
150
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
549 |
|
290
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
550 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
551 |
\begin{frame}[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
552 |
\frametitle{Environment}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
553 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
554 |
Obtaining the ``recorded'' parts of a regular expression:
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
555 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
556 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
557 |
\begin{tabular}{lcl}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
558 |
\bl{$env(Empty)$} & \bl{$\dn$} & \bl{$[]$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
559 |
\bl{$env(Char(c))$} & \bl{$\dn$} & \bl{$[]$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
560 |
\bl{$env(Left(v))$} & \bl{$\dn$} & \bl{$env(v)$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
561 |
\bl{$env(Right(v))$} & \bl{$\dn$} & \bl{$env(v)$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
562 |
\bl{$env(Seq(v_1,v_2))$}& \bl{$\dn$} & \bl{$env(v_1) \,@\, env(v_2)$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
563 |
\bl{$env([v_1,\ldots ,v_n])$} & \bl{$\dn$} &
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
564 |
\bl{$env(v_1) \,@\ldots @\, env(v_n)$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
565 |
\bl{$env(Rec(x:v))$} & \bl{$\dn$} & \bl{$(x:|v|) :: env(v)$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
566 |
\end{tabular}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
567 |
\end{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
568 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
569 |
\end{frame}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
570 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
571 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
572 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
573 |
\begin{frame}[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
574 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
575 |
\begin{itemize}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
576 |
\item Regular expression for email addresses
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
577 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
578 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
579 |
\begin{tabular}{l}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
580 |
(name: \bl{$[a\mbox{-}z0\mbox{-}9\_\!\_\,.-]^+$})\bl{$\cdot @\cdot$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
581 |
\qquad(domain: \bl{$[a\mbox{-}z0\mbox{-}9\,.-]^+$}) \bl{$\cdot .\cdot$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
582 |
\qquad\qquad(top\_level: \bl{$[a\mbox{-}z\,.]^{\{2,6\}}$})
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
583 |
\end{tabular}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
584 |
\end{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
585 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
586 |
\bl{\[
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
587 |
\texttt{christian.urban@kcl.ac.uk}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
588 |
\]}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
589 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
590 |
\item result environment:
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
591 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
592 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
593 |
\begin{tabular}{l}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
594 |
\bl{$[(name:\texttt{christian.urban}),$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
595 |
\bl{$\phantom{[}(domain:\texttt{kcl}),$}\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
596 |
\bl{$\phantom{[}(top\_level:\texttt{ac.uk})]$}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
597 |
\end{tabular}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
598 |
\end{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
599 |
\end{itemize}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
600 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
601 |
\end{frame}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
602 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
603 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
604 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
605 |
\begin{frame}[c]
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
606 |
\frametitle{Coursework}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
607 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
608 |
\begin{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
609 |
\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
610 |
\bl{$nullable([c_1 c_2 \ldots c_n])$} & \bl{$\dn$} & $?$\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
611 |
\bl{$nullable(r^+)$} & \bl{$\dn$} & $?$\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
612 |
\bl{$nullable(r^?)$} & \bl{$\dn$} & $?$\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
613 |
\bl{$nullable(r^{\{n,m\}})$} & \bl{$\dn$} & $?$\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
614 |
\bl{$nullable(\sim{}r)$} & \bl{$\dn$} & $?$\medskip\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
615 |
\bl{$der\, c\, ([c_1 c_2 \ldots c_n])$} & \bl{$\dn$} & $?$\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
616 |
\bl{$der\, c\, (r^+)$} & \bl{$\dn$} & $?$\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
617 |
\bl{$der\, c\, (r^?)$} & \bl{$\dn$} & $?$\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
618 |
\bl{$der\, c\, (r^{\{n,m\}})$} & \bl{$\dn$} & $?$\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
619 |
\bl{$der\, c\, (\sim{}r)$} & \bl{$\dn$} & $?$\\
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
620 |
\end{tabular}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
621 |
\end{center}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
622 |
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
623 |
\end{frame}
|
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
624 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
150
Christian Urban <christian dot urban at kcl dot ac dot uk>
diff
changeset
|
625 |
|
44
|
626 |
\end{document}
|
|
627 |
|
|
628 |
%%% Local Variables:
|
|
629 |
%%% mode: latex
|
|
630 |
%%% TeX-master: t
|
|
631 |
%%% End:
|
|
632 |
|