slides/slides07.tex
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Sat, 15 Jun 2013 09:23:18 -0400
changeset 93 4794759139ea
parent 64 slides07.tex@2d625418c011
child 173 7cfb7a6f7c99
permissions -rw-r--r--
better organised
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
\documentclass[dvipsnames,14pt,t]{beamer}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
\usepackage{beamerthemeplainculight}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
\usepackage[T1]{fontenc}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
\usepackage[latin1]{inputenc}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
\usepackage{mathpartir}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
\usepackage[absolute,overlay]{textpos}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
\usepackage{ifthen}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
\usepackage{tikz}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
\usepackage{pgf}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
\usepackage{calc} 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
\usepackage{ulem}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
\usepackage{courier}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
\usepackage{listings}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
\renewcommand{\uline}[1]{#1}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
\usetikzlibrary{arrows}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
\usetikzlibrary{automata}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
\usetikzlibrary{shapes}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
\usetikzlibrary{shadows}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
\usetikzlibrary{positioning}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
\usetikzlibrary{calc}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
\usetikzlibrary{plotmarks}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
\usepackage{graphicx} 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
\definecolor{javared}{rgb}{0.6,0,0} % for strings
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
\definecolor{javagreen}{rgb}{0.25,0.5,0.35} % comments
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
\definecolor{javapurple}{rgb}{0.5,0,0.35} % keywords
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
\definecolor{javadocblue}{rgb}{0.25,0.35,0.75} % javadoc
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
\lstset{language=Java,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
	basicstyle=\ttfamily,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
	keywordstyle=\color{javapurple}\bfseries,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
	stringstyle=\color{javagreen},
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
	commentstyle=\color{javagreen},
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
	morecomment=[s][\color{javadocblue}]{/**}{*/},
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
	numbers=left,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
	numberstyle=\tiny\color{black},
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
	stepnumber=1,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
	numbersep=10pt,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
	tabsize=2,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
	showspaces=false,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
	showstringspaces=false}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
\lstdefinelanguage{scala}{
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
  morekeywords={abstract,case,catch,class,def,%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
    do,else,extends,false,final,finally,%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
    for,if,implicit,import,match,mixin,%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
    new,null,object,override,package,%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
    private,protected,requires,return,sealed,%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
    super,this,throw,trait,true,try,%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
    type,val,var,while,with,yield},
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
  otherkeywords={=>,<-,<\%,<:,>:,\#,@},
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
  sensitive=true,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
  morecomment=[l]{//},
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
  morecomment=[n]{/*}{*/},
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
  morestring=[b]",
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
  morestring=[b]',
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
  morestring=[b]"""
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
\lstset{language=Scala,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
	basicstyle=\ttfamily,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
	keywordstyle=\color{javapurple}\bfseries,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
	stringstyle=\color{javagreen},
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
	commentstyle=\color{javagreen},
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
	morecomment=[s][\color{javadocblue}]{/**}{*/},
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
	numbers=left,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
	numberstyle=\tiny\color{black},
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
	stepnumber=1,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
	numbersep=10pt,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
	tabsize=2,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
	showspaces=false,
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
	showstringspaces=false}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
% beamer stuff 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
\renewcommand{\slidecaption}{AFL 07, King's College London, 14.~November 2012}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
\newcommand{\bl}[1]{\textcolor{blue}{#1}}       
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
\newcommand{\dn}{\stackrel{\mbox{\scriptsize def}}{=}}% for definitions
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
% The data files, written on the first run.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
\begin{filecontents}{re-python.data}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
1 0.029
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
5 0.029
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
10 0.029
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
15 0.032
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
16 0.042
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
17 0.042
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
18 0.055
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
19 0.084
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
20 0.136
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    91
21 0.248
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
22 0.464
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
23 0.899
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    94
24 1.773
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
25 3.505
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    96
26 6.993
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    97
27 14.503
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    98
28 29.307
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
#29 58.886
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
\end{filecontents}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   102
\begin{filecontents}{re-ruby.data}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   103
1 0.00006
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   104
2 0.00003
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
3 0.00001
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   106
4 0.00001
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107
5 0.00001
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   108
6 0.00002
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   109
7 0.00002
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   110
8 0.00004
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   111
9 0.00007
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   112
10 0.00013
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   113
11 0.00026
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   114
12 0.00055
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   115
13 0.00106
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   116
14 0.00196
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   117
15 0.00378
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   118
16 0.00764
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   119
17 0.01606
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   120
18 0.03094
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   121
19 0.06508
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   122
20 0.12420
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   123
21 0.25393
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   124
22 0.51449
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
23 1.02174
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   126
24 2.05998
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   127
25 4.22514
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   128
26 8.42479
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
27 16.88678
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   130
28 34.79653
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   131
\end{filecontents}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   132
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   133
\begin{filecontents}{re1.data}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   134
1 0.00179
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   135
2 0.00011
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   136
3 0.00014
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   137
4 0.00026
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   138
5 0.00050
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   139
6 0.00095
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   140
7 0.00190
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   141
8 0.00287
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   142
9 0.00779
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   143
10 0.01399
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   144
11 0.01894
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   145
12 0.03666
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   146
13 0.07994
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   147
14 0.08944
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
15 0.02377
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
16 0.07392
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
17 0.22798
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   151
18 0.65310
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   152
19 2.11360
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   153
20 6.31606
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   154
21 21.46013
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   155
\end{filecontents}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   156
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   157
\begin{filecontents}{re2.data}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   158
1  0.00240
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   159
2  0.00013
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   160
3  0.00020
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   161
4  0.00030
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   162
5  0.00049
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   163
6  0.00083
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   164
7  0.00146
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   165
8  0.00228
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   166
9  0.00351
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   167
10  0.00640
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   168
11  0.01217
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   169
12  0.02565
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   170
13  0.01382
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   171
14  0.02423
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   172
15  0.05065 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   173
16  0.06522
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   174
17  0.02140
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   175
18  0.05176
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   176
19  0.18254
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   177
20  0.51898
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   178
21  1.39631
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   179
22  2.69501
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   180
23  8.07952
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   181
\end{filecontents}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   182
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   183
\begin{filecontents}{re-internal.data}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   184
1 0.00069
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   185
301 0.00700
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   186
601 0.00297
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   187
901 0.00470
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   188
1201 0.01301
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   189
1501 0.01175
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   190
1801 0.01761
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   191
2101 0.01787
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   192
2401 0.02717
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   193
2701 0.03932
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   194
3001 0.03470
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   195
3301 0.04349
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   196
3601 0.05411
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   197
3901 0.06181
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   198
4201 0.07119
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   199
4501 0.08578
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   200
\end{filecontents}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   201
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   202
\begin{filecontents}{re3.data}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   203
1 0.001605
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   204
501 0.131066
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   205
1001 0.057885
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   206
1501 0.136875
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   207
2001 0.176238
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   208
2501 0.254363
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   209
3001 0.37262
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   210
3501 0.500946
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   211
4001 0.638384
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   212
4501 0.816605
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   213
5001 1.00491
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   214
5501 1.232505
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   215
6001 1.525672
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   216
6501 1.757502
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   217
7001 2.092784
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   218
7501 2.429224
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   219
8001 2.803037
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   220
8501 3.463045
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   221
9001 3.609
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   222
9501 4.081504
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   223
10001 4.54569
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   224
\end{filecontents}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   225
\begin{document}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   226
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   227
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   228
\mode<presentation>{
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   229
\begin{frame}<1>[t]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   230
\frametitle{%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   231
  \begin{tabular}{@ {}c@ {}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   232
  \\[-3mm]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   233
  \LARGE Automata and \\[-2mm] 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   234
  \LARGE Formal Languages (7)\\[3mm] 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   235
  \end{tabular}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   236
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   237
  \normalsize
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   238
  \begin{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   239
  \begin{tabular}{ll}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   240
  Email:  & christian.urban at kcl.ac.uk\\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   241
  Of$\!$fice: & S1.27 (1st floor Strand Building)\\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   242
  Slides: & KEATS (also home work is there)\\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   243
  \end{tabular}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   244
  \end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   245
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   246
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   247
\end{frame}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   248
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   249
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   250
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   251
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   252
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   253
\mode<presentation>{
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   254
\begin{frame}[t]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   255
\frametitle{\begin{tabular}{c}\bl{$(a?\{n\})a\{n\}$}\end{tabular}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   256
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   257
\mbox{}\\[-13mm]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   258
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   259
\begin{tikzpicture}[y=.2cm, x=.3cm]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   260
 	%axis
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   261
	\draw (0,0) -- coordinate (x axis mid) (30,0);
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   262
    	\draw (0,0) -- coordinate (y axis mid) (0,30);
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   263
    	%ticks
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   264
    	\foreach \x in {0,5,...,30}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   265
     		\draw (\x,1pt) -- (\x,-3pt)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   266
			node[anchor=north] {\x};
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   267
    	\foreach \y in {0,5,...,30}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   268
     		\draw (1pt,\y) -- (-3pt,\y) 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   269
     			node[anchor=east] {\y}; 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   270
	%labels      
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   271
	\node[below=0.6cm] at (x axis mid) {\bl{a}s};
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   272
	\node[rotate=90, left=1.2cm] at (y axis mid) {secs};
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   273
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   274
	%plots
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   275
	\draw[color=blue] plot[mark=*, mark options={fill=white}] 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   276
		file {re-python.data};
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   277
	\draw[color=red] plot[mark=triangle*, mark options={fill=white} ] 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   278
		file {re1.data};
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   279
         \draw[color=green] plot[mark=square*, mark options={fill=white} ] 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   280
		file {re2.data};
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   281
         \draw[color=brown] plot[mark=pentagon*, mark options={fill=white} ] 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   282
		file {re-ruby.data};
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   283
    
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   284
	%legend
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   285
	\begin{scope}[shift={(4,20)}] 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   286
	\draw[color=blue] (0,0) -- 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   287
		plot[mark=*, mark options={fill=white}] (0.25,0) -- (0.5,0) 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   288
		node[right]{\small Python};
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   289
	\draw[yshift=-\baselineskip, color=brown] (0,0) -- 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   290
		plot[mark=pentagon*, mark options={fill=white}] (0.25,0) -- (0.5,0)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   291
		node[right]{\small Ruby (Daniel Baldwin)};
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   292
         \draw[yshift=\baselineskip, color=red] (0,0) -- 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   293
		plot[mark=triangle*, mark options={fill=white}] (0.25,0) -- (0.5,0)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   294
		node[right]{\small Scala V1};	
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   295
	 \draw[yshift=2\baselineskip, color=green] (0,0) -- 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   296
		plot[mark=square*, mark options={fill=white}] (0.25,0) -- (0.5,0)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   297
		node[right]{\small Scala V2 with simplifications};
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   298
	\end{scope}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   299
\end{tikzpicture}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   300
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   301
\end{frame}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   302
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   303
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   304
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   305
\mode<presentation>{
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   306
\begin{frame}[t]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   307
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   308
\begin{tikzpicture}[y=.7cm, x=.0009cm]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   309
 	%axis
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   310
	\draw (0,0) -- coordinate (x axis mid) (10000,0);
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   311
    	\draw (0,0) -- coordinate (y axis mid) (0,6);
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   312
    	%ticks
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   313
    	\foreach \x in {0,2000,...,10000}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   314
     		\draw (\x,1pt) -- (\x,-3pt)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   315
			node[anchor=north] {\x};
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   316
    	\foreach \y in {0,1,...,6}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   317
     		\draw (1pt,\y) -- (-3pt,\y) 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   318
     			node[anchor=east] {\y}; 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   319
	%labels      
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   320
	\node[below=0.6cm] at (x axis mid) {\bl{a}s};
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   321
	\node[rotate=90, left=1.2cm] at (y axis mid) {secs};
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   322
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   323
	%plots
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   324
	\draw[color=blue] plot[mark=*, mark options={fill=white}] 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   325
		file {re-internal.data};
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   326
	\only<1->{	 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   327
         \draw[color=red] plot[mark=triangle*, mark options={fill=white} ] 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   328
		file {re3.data};}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   329
    
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   330
	%legend
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   331
	\begin{scope}[shift={(2000,4)}] 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   332
	\draw[color=blue] (0,0) -- 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   333
		plot[mark=*, mark options={fill=white}] (0.25,0) -- (0.5,0) 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   334
		node[right]{\small Scala Internal};
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   335
        \only<1->{
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   336
	\draw[yshift=\baselineskip, color=red] (0,0) -- 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   337
		plot[mark=triangle*, mark options={fill=white}] (0.25,0) -- (0.5,0)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   338
		node[right]{\small Scala V3 with explicit $\_\{\_\}$};}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   339
	\end{scope}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   340
\end{tikzpicture}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   341
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   342
\begin{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   343
\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {\hspace{-10mm}}l@ {}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   344
  \\[-8mm]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   345
  \bl{der c (r$_1$ $\cdot$ r$_2$)} & \bl{$\dn$}  & \bl{if nullable r$_1$}\\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   346
  & & \bl{then ((der c r$_1$) $\cdot$ r$_2$) + (der c r$_2$)}\\ 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   347
  & & \bl{else (der c r$_1$) $\cdot$ r$_2$}\\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   348
  \bl{der c (r$\{n\}$)} & \bl{$\dn$} & \bl{if $n = 0$ then $\varnothing$}\\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   349
  & & \bl{else (der c r) $\cdot$ r$\{n - 1\}$}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   350
  \end{tabular}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   351
\end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   352
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   353
\end{frame}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   354
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   355
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   356
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   357
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   358
\newcommand{\qq}{\mbox{\texttt{"}}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   359
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   360
\mode<presentation>{
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   361
\begin{frame}[c]
64
2d625418c011 added everything
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 63
diff changeset
   362
\frametitle{\begin{tabular}{c}CFGs\end{tabular}}
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   363
64
2d625418c011 added everything
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 63
diff changeset
   364
A \alert{context-free} grammar (CFG) \bl{$G$} consists of:
63
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   365
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   366
\begin{itemize}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   367
\item a finite set of nonterminal symbols (upper case)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   368
\item a finite terminal symbols or tokens (lower case)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   369
\item a start symbol (which must be a nonterminal)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   370
\item a set of rules
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   371
\begin{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   372
\bl{$A \rightarrow \text{rhs}$}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   373
\end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   374
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   375
where \bl{rhs} are sequences involving terminals and nonterminals (can also be empty).\medskip\pause
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   376
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   377
We can also allow rules
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   378
\begin{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   379
\bl{$A \rightarrow \text{rhs}_1 | \text{rhs}_2 | \ldots$}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   380
\end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   381
\end{itemize}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   382
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   383
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   384
\end{frame}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   385
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   386
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   387
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   388
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   389
\mode<presentation>{
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   390
\begin{frame}[c]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   391
\frametitle{\begin{tabular}{c}A CFG Derivation\end{tabular}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   392
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   393
\begin{enumerate}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   394
\item Begin with a string with only the start symbol \bl{$S$}\bigskip
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   395
\item Replace any non-terminal \bl{$X$} in the string by the
right-hand side of some production \bl{$X \rightarrow \text{rhs}$}\bigskip
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   396
\item Repeat 2 until there are no non-terminals
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   397
\end{enumerate}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   398
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   399
\begin{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   400
\bl{$S \rightarrow \ldots \rightarrow \ldots  \rightarrow \ldots  \rightarrow \ldots $}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   401
\end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   402
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   403
\end{frame}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   404
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   405
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   406
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   407
\mode<presentation>{
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   408
\begin{frame}[c]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   409
\frametitle{\begin{tabular}{c}Language of a CFG\end{tabular}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   410
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   411
Let \bl{$G$} be a context-free grammar with start symbol \bl{$S$}. 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   412
Then the language \bl{$L(G)$} is:
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   413
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   414
\begin{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   415
\bl{$\{c_1\ldots c_n \;|\; \forall i.\; c_i \in T \wedge S \rightarrow^* c_1\ldots c_n \}$}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   416
\end{center}\pause
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   417
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   418
\begin{itemize}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   419
\item Terminals are so-called because there are no rules for replacing them
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   420
\item Once generated, terminals are ``permanent''
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   421
\item Terminals ought to be tokens of the language (at least in this course)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   422
\end{itemize}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   423
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   424
\end{frame}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   425
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   426
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   427
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   428
\mode<presentation>{
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   429
\begin{frame}[c]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   430
\frametitle{\begin{tabular}{c}Arithmetic Expressions\end{tabular}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   431
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   432
\begin{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   433
\bl{\begin{tabular}{lcl}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   434
$E$ & $\rightarrow$ &  $num\_token$ \\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   435
$E$ & $\rightarrow$ &  $E \cdot + \cdot E$ \\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   436
$E$ & $\rightarrow$ &  $E \cdot - \cdot E$ \\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   437
$E$ & $\rightarrow$ &  $E \cdot * \cdot E$ \\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   438
$E$ & $\rightarrow$ &  $( \cdot E \cdot )$ 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   439
\end{tabular}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   440
\end{center}\pause\bigskip
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   441
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   442
A CFG is \alert{left-recursive} if it has a nonterminal \bl{$E$} such
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   443
that \bl{$E \rightarrow^+ E\cdot \ldots$}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   444
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   445
\end{frame}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   446
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   447
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   448
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   449
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   450
\mode<presentation>{
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   451
\begin{frame}[c]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   452
\frametitle{\begin{tabular}{c}Parse Trees\end{tabular}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   453
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   454
\begin{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   455
\bl{\begin{tabular}{lcl}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   456
$E$ & $\rightarrow$ &  $F \;|\; F \cdot * \cdot F$\\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   457
$F$ & $\rightarrow$ & $T \;|\; T \cdot + \cdot T \;|\; T \cdot - \cdot T$\\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   458
$T$ & $\rightarrow$ & $num\_token \;|\; ( \cdot E \cdot )$\\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   459
\end{tabular}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   460
\end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   461
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   462
\begin{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   463
\begin{tikzpicture}[level distance=8mm, blue]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   464
  \node {$E$}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   465
    child {node {$F$} 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   466
     child {node {$T$} 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   467
                 child {node {(\,$E$\,)}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   468
                            child {node{$F$ *{} $F$}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   469
                                  child {node {$T$} child {node {2}}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   470
                                  child {node {$T$} child {node {3}}} 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   471
                               }
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   472
                          }
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   473
              }
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   474
     child {node {+}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   475
     child {node {$T$}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   476
       child {node {(\,$E$\,)} 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   477
       child {node {$F$}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   478
       child {node {$T$ +{} $T$}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   479
                    child {node {3}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   480
                    child {node {4}} 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   481
                 }
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   482
                 }}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   483
    }};
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   484
\end{tikzpicture}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   485
\end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   486
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   487
\begin{textblock}{5}(1, 6.5)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   488
\bl{\texttt{(2*3)+(3+4)}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   489
\end{textblock}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   490
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   491
\end{frame}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   492
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   493
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   494
\mode<presentation>{
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   495
\begin{frame}[c]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   496
\frametitle{\begin{tabular}{c}Ambiguous Grammars\end{tabular}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   497
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   498
A CFG is \alert{ambiguous} if there is a string that has at least parse trees.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   499
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   500
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   501
\begin{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   502
\bl{\begin{tabular}{lcl}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   503
$E$ & $\rightarrow$ &  $num\_token$ \\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   504
$E$ & $\rightarrow$ &  $E \cdot + \cdot E$ \\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   505
$E$ & $\rightarrow$ &  $E \cdot - \cdot E$ \\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   506
$E$ & $\rightarrow$ &  $E \cdot * \cdot E$ \\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   507
$E$ & $\rightarrow$ &  $( \cdot E \cdot )$ 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   508
\end{tabular}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   509
\end{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   510
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   511
\bl{\texttt{1 + 2 * 3 + 4}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   512
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   513
\end{frame}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   514
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   515
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   516
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   517
\mode<presentation>{
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   518
\begin{frame}[c]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   519
\frametitle{\begin{tabular}{c}Dangling Else\end{tabular}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   520
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   521
Another ambiguous grammar:\bigskip
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   522
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   523
\begin{center}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   524
\bl{\begin{tabular}{lcl}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   525
$E$ & $\rightarrow$ &  if $E$ then $E$\\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   526
 & $|$ &  if $E$ then $E$ else $E$ \\
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   527
 & $|$ &  id 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   528
\end{tabular}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   529
\end{center}\bigskip
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   530
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   531
\bl{\texttt{if a then if x then y else c}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   532
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   533
\end{frame}}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   534
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   535
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   536
\end{document}
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   537
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   538
%%% Local Variables:  
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   539
%%% mode: latex
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   540
%%% TeX-master: t
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   541
%%% End: 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   542