766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1 |
1
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2 |
00:00:05,880 --> 00:00:09,700
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
3 |
Welcome back.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
4 |
Remember this slide.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
5 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
6 |
2
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
7 |
00:00:09,700 --> 00:00:11,500
|
769
|
8 |
This slide said what is
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
9 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
10 |
3
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
11 |
00:00:11,500 --> 00:00:14,500
|
769
|
12 |
our regular expression matcher
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
13 |
actually supposed to do?
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
14 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
15 |
4
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
16 |
00:00:14,500 --> 00:00:16,570
|
769
|
17 |
It will take two arguments,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
18 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
19 |
5
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
20 |
00:00:16,570 --> 00:00:18,670
|
769
|
21 |
a regular expression r and a string s.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
22 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
23 |
6
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
24 |
00:00:18,670 --> 00:00:21,580
|
769
|
25 |
And it's supposed to say yes,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
26 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
27 |
7
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
28 |
00:00:21,580 --> 00:00:23,440
|
769
|
29 |
the regular expression matches
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
30 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
31 |
8
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
32 |
00:00:23,440 --> 00:00:26,920
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
33 |
the string if and only
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
34 |
if the string is in
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
35 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
36 |
9
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
37 |
00:00:26,920 --> 00:00:28,855
|
769
|
38 |
the language of r.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
39 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
40 |
10
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
41 |
00:00:28,855 --> 00:00:32,410
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
42 |
And if the string is not
|
769
|
43 |
in the language of r,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
44 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
45 |
11
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
46 |
00:00:32,410 --> 00:00:35,515
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
47 |
then our algorithm has to say no.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
48 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
49 |
12
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
50 |
00:00:35,515 --> 00:00:37,210
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
51 |
And we can't use
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
52 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
53 |
13
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
54 |
00:00:37,210 --> 00:00:39,565
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
55 |
this specification
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
56 |
directly because remember,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
57 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
58 |
14
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
59 |
00:00:39,565 --> 00:00:43,305
|
769
|
60 |
this L sometimes
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
61 |
produces infinite sets.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
62 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
63 |
15
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
64 |
00:00:43,305 --> 00:00:47,585
|
769
|
65 |
And we can't test whether a
|
|
66 |
string is in infinite set,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
67 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
68 |
16
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
69 |
00:00:47,585 --> 00:00:50,090
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
70 |
at least not easily.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
71 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
72 |
17
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
73 |
00:00:50,090 --> 00:00:52,340
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
74 |
And so what we have to do
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
75 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
76 |
18
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
77 |
00:00:52,340 --> 00:00:54,260
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
78 |
instead is we have
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
79 |
to be a bit more
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
80 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
81 |
19
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
82 |
00:00:54,260 --> 00:00:57,050
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
83 |
clever and implement
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
84 |
some operations
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
85 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
86 |
20
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
87 |
00:00:57,050 --> 00:00:59,284
|
769
|
88 |
on regular expressions instead,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
89 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
90 |
21
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
91 |
00:00:59,284 --> 00:01:03,275
|
769
|
92 |
because regular expressions
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
93 |
are always finite trees.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
94 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
95 |
22
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
96 |
00:01:03,275 --> 00:01:05,870
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
97 |
I should say the
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
98 |
person who has been
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
99 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
100 |
23
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
101 |
00:01:05,870 --> 00:01:08,150
|
769
|
102 |
clever is called Brzozowski.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
103 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
104 |
24
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
105 |
00:01:08,150 --> 00:01:11,435
|
769
|
106 |
It's his algorithm
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
107 |
I'm introducing here.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
108 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
109 |
25
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
110 |
00:01:11,435 --> 00:01:15,515
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
111 |
And his algorithm consists
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
112 |
of two functions.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
113 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
114 |
26
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
115 |
00:01:15,515 --> 00:01:17,840
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
116 |
One is called
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
117 |
nullable and it takes
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
118 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
119 |
27
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
120 |
00:01:17,840 --> 00:01:20,104
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
121 |
a regular expression as argument.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
122 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
123 |
28
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
124 |
00:01:20,104 --> 00:01:24,155
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
125 |
And the idea is that
|
769
|
126 |
this function nullable is
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
127 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
128 |
29
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
129 |
00:01:24,155 --> 00:01:26,450
|
769
|
130 |
testing whether
|
|
131 |
the regular expression
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
132 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
133 |
30
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
134 |
00:01:26,450 --> 00:01:27,950
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
135 |
can match the empty string.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
136 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
137 |
31
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
138 |
00:01:27,950 --> 00:01:30,305
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
139 |
So 0 cannot match any string.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
140 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
141 |
32
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
142 |
00:01:30,305 --> 00:01:33,275
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
143 |
So it cannot match the
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
144 |
empty string either.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
145 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
146 |
33
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
147 |
00:01:33,275 --> 00:01:35,465
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
148 |
So that's defined as false.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
149 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
150 |
34
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
151 |
00:01:35,465 --> 00:01:37,775
|
769
|
152 |
This regular expression,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
153 |
the whole purpose
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
154 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
155 |
35
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
156 |
00:01:37,775 --> 00:01:39,680
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
157 |
is that it can match
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
158 |
the empty string.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
159 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
160 |
36
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
161 |
00:01:39,680 --> 00:01:41,645
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
162 |
So it's defined as true.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
163 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
164 |
37
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
165 |
00:01:41,645 --> 00:01:44,599
|
769
|
166 |
If a regular expression
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
167 |
can match a character,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
168 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
169 |
38
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
170 |
00:01:44,599 --> 00:01:47,045
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
171 |
then it cannot match
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
172 |
the empty string.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
173 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
174 |
39
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
175 |
00:01:47,045 --> 00:01:49,445
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
176 |
So that is defined as false.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
177 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
178 |
40
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
179 |
00:01:49,445 --> 00:01:53,180
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
180 |
If an alternative can
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
181 |
match the empty string,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
182 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
183 |
41
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
184 |
00:01:53,180 --> 00:01:56,960
|
769
|
185 |
then either r1 can
|
|
186 |
match the empty string,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
187 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
188 |
42
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
189 |
00:01:56,960 --> 00:01:59,720
|
769
|
190 |
or r2 can match the empty string.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
191 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
192 |
43
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
193 |
00:01:59,720 --> 00:02:03,110
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
194 |
So either nullable
|
769
|
195 |
of r1 has to hold,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
196 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
197 |
44
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
198 |
00:02:03,110 --> 00:02:06,945
|
769
|
199 |
or nullable of r2 has to hold.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
200 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
201 |
45
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
202 |
00:02:06,945 --> 00:02:09,925
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
203 |
In this sequence, it's
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
204 |
the other way around.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
205 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
206 |
46
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
207 |
00:02:09,925 --> 00:02:12,790
|
769
|
208 |
If this regular expression can
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
209 |
match the empty string,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
210 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
211 |
47
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
212 |
00:02:12,790 --> 00:02:16,615
|
769
|
213 |
then r1 has to be able to
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
214 |
match the empty string,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
215 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
216 |
48
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
217 |
00:02:16,615 --> 00:02:20,290
|
769
|
218 |
and r2 has to be able to
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
219 |
match the empty string.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
220 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
221 |
49
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
222 |
00:02:20,290 --> 00:02:22,555
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
223 |
So here it's just the opposite.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
224 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
225 |
50
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
226 |
00:02:22,555 --> 00:02:25,660
|
769
|
227 |
In one case it is or and
|
|
228 |
the other case it is and.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
229 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
230 |
51
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
231 |
00:02:25,660 --> 00:02:27,970
|
769
|
232 |
The star regular
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
233 |
expression can match
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
234 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
235 |
52
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
236 |
00:02:27,970 --> 00:02:30,445
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
237 |
always the empty string.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
238 |
So that is true.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
239 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
240 |
53
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
241 |
00:02:30,445 --> 00:02:33,340
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
242 |
So this is a simple
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
243 |
recursive function
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
244 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
245 |
54
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
246 |
00:02:33,340 --> 00:02:37,179
|
769
|
247 |
and it should not be too
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
248 |
difficult to implement.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
249 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
250 |
55
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
251 |
00:02:37,179 --> 00:02:42,025
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
252 |
Okay, this nullable function
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
253 |
that is easy-peasy.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
254 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
255 |
56
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
256 |
00:02:42,025 --> 00:02:44,604
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
257 |
The second function, however,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
258 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
259 |
57
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
260 |
00:02:44,604 --> 00:02:49,155
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
261 |
is a bit more involved and
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
262 |
that's just to be expected.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
263 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
264 |
58
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
265 |
00:02:49,155 --> 00:02:53,075
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
266 |
Remember people working in
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
267 |
this area already for decades.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
268 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
269 |
59
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
270 |
00:02:53,075 --> 00:02:57,305
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
271 |
If they have some problems
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
272 |
with runtime, for example,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
273 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
274 |
60
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
275 |
00:02:57,305 --> 00:02:58,940
|
769
|
276 |
we can't expect that
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
277 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
278 |
61
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
279 |
00:02:58,940 --> 00:03:03,260
|
769
|
280 |
a simple fix will solve all
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
281 |
the problems in the world.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
282 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
283 |
62
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
284 |
00:03:03,260 --> 00:03:06,530
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
285 |
So I admit the second
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
286 |
function is a bit more
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
287 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
288 |
63
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
289 |
00:03:06,530 --> 00:03:10,085
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
290 |
complicated and make sure
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
291 |
that you understand it.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
292 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
293 |
64
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
294 |
00:03:10,085 --> 00:03:12,140
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
295 |
And it also just
|
769
|
296 |
shows this Brzozowski
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
297 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
298 |
65
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
299 |
00:03:12,140 --> 00:03:14,345
|
769
|
300 |
is a very clever guy.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
301 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
302 |
66
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
303 |
00:03:14,345 --> 00:03:15,800
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
304 |
Actually, I have to say he was
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
305 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
306 |
67
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
307 |
00:03:15,800 --> 00:03:17,720
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
308 |
a clever guy because
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
309 |
I think he either
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
310 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
311 |
68
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
312 |
00:03:17,720 --> 00:03:21,650
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
313 |
died last year or
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
314 |
the year before.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
315 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
316 |
69
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
317 |
00:03:21,650 --> 00:03:25,505
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
318 |
And he came up with this
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
319 |
algorithm already in 1964.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
320 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
321 |
70
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
322 |
00:03:25,505 --> 00:03:27,260
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
323 |
It somehow got lost,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
324 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
325 |
71
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
326 |
00:03:27,260 --> 00:03:30,305
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
327 |
but has been rediscovered
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
328 |
in the last ten years.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
329 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
330 |
72
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
331 |
00:03:30,305 --> 00:03:34,685
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
332 |
So the idea of the second
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
333 |
function is the following.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
334 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
335 |
73
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
336 |
00:03:34,685 --> 00:03:38,120
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
337 |
Imagine you have a
|
769
|
338 |
regular expression and it can
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
339 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
340 |
74
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
341 |
00:03:38,120 --> 00:03:41,930
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
342 |
match a string of the
|
769
|
343 |
form c followed by s.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
344 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
345 |
75
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
346 |
00:03:41,930 --> 00:03:44,810
|
769
|
347 |
So the c is the first
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
348 |
character of that string.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
349 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
350 |
76
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
351 |
00:03:44,810 --> 00:03:48,605
|
769
|
352 |
So I imagine that r can
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
353 |
match this kind of string.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
354 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
355 |
77
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
356 |
00:03:48,605 --> 00:03:50,330
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
357 |
The question is now,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
358 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
359 |
78
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
360 |
00:03:50,330 --> 00:03:52,400
|
769
|
361 |
what would a regular
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
362 |
expression look
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
363 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
364 |
79
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
365 |
00:03:52,400 --> 00:03:54,695
|
769
|
366 |
like that can match just
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
367 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
368 |
80
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
369 |
00:03:54,695 --> 00:03:57,140
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
370 |
s. You probably remember
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
371 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
372 |
81
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
373 |
00:03:57,140 --> 00:03:59,300
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
374 |
that from the semantic
|
769
|
375 |
derivative,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
376 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
377 |
82
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
378 |
00:03:59,300 --> 00:04:00,860
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
379 |
there was also
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
380 |
something of chopping
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
381 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
382 |
83
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
383 |
00:04:00,860 --> 00:04:02,210
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
384 |
off the first character.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
385 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
386 |
84
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
387 |
00:04:02,210 --> 00:04:04,940
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
388 |
Here it's the same.
|
769
|
389 |
If a regular expression
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
390 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
391 |
85
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
392 |
00:04:04,940 --> 00:04:07,835
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
393 |
can match a string
|
769
|
394 |
starting with a c,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
395 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
396 |
86
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
397 |
00:04:07,835 --> 00:04:11,090
|
769
|
398 |
we're looking for a regular
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
399 |
expression which can match
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
400 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
401 |
87
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
402 |
00:04:11,090 --> 00:04:15,215
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
403 |
the rest of the string where
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
404 |
the c has been chopped off.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
405 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
406 |
88
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
407 |
00:04:15,215 --> 00:04:17,690
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
408 |
And this operation will be called
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
409 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
410 |
89
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
411 |
00:04:17,690 --> 00:04:21,049
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
412 |
the derivative of a
|
769
|
413 |
regular expression.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
414 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
415 |
90
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
416 |
00:04:21,049 --> 00:04:22,205
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
417 |
And it will also take
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
418 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
419 |
91
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
420 |
00:04:22,205 --> 00:04:25,460
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
421 |
a character as argument
|
769
|
422 |
and a regular expression.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
423 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
424 |
92
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
425 |
00:04:25,460 --> 00:04:28,730
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
426 |
And in contrast to
|
769
|
427 |
the semantic
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
428 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
429 |
93
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
430 |
00:04:28,730 --> 00:04:31,310
|
769
|
431 |
derivative, which works
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
432 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
433 |
94
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
434 |
00:04:31,310 --> 00:04:34,430
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
435 |
over languages or
|
769
|
436 |
sets of strings,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
437 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
438 |
95
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
439 |
00:04:34,430 --> 00:04:39,620
|
769
|
440 |
this derivative works
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
441 |
over regular expressions.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
442 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
443 |
96
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
444 |
00:04:39,620 --> 00:04:41,330
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
445 |
Okay, here's this function.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
446 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
447 |
97
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
448 |
00:04:41,330 --> 00:04:43,970
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
449 |
It's defined recursively over
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
450 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
451 |
98
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
452 |
00:04:43,970 --> 00:04:46,370
|
769
|
453 |
the structure of regular expressions.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
454 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
455 |
99
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
456 |
00:04:46,370 --> 00:04:48,814
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
457 |
The first argument
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
458 |
is the character,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
459 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
460 |
100
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
461 |
00:04:48,814 --> 00:04:52,700
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
462 |
and the second one is
|
769
|
463 |
a regular expression.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
464 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
465 |
101
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
466 |
00:04:52,700 --> 00:04:56,510
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
467 |
And remember the idea
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
468 |
is we're looking for
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
469 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
470 |
102
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
471 |
00:04:56,510 --> 00:05:00,680
|
769
|
472 |
a regular expression that
|
|
473 |
can match everything
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
474 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
475 |
103
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
476 |
00:05:00,680 --> 00:05:03,125
|
769
|
477 |
this regular expression
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
478 |
as argument can match
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
479 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
480 |
104
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
481 |
00:05:03,125 --> 00:05:07,040
|
769
|
482 |
except for the c. So now let's
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
483 |
look at this first case.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
484 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
485 |
105
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
486 |
00:05:07,040 --> 00:05:10,550
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
487 |
So this reg expression
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
488 |
cannot match any string.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
489 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
490 |
106
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
491 |
00:05:10,550 --> 00:05:14,270
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
492 |
So it certainly cannot
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
493 |
match any string starting
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
494 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
495 |
107
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
496 |
00:05:14,270 --> 00:05:16,910
|
769
|
497 |
a c. So we have to look
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
498 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
499 |
108
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
500 |
00:05:16,910 --> 00:05:20,090
|
769
|
501 |
for a regular expression which
|
|
502 |
can not match anything.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
503 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
504 |
109
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
505 |
00:05:20,090 --> 00:05:22,700
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
506 |
Well, that's the purpose
|
769
|
507 |
of this regular expression,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
508 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
509 |
110
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
510 |
00:05:22,700 --> 00:05:24,815
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
511 |
so we define it as 0.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
512 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
513 |
111
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
514 |
00:05:24,815 --> 00:05:28,130
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
515 |
In the next case,
|
769
|
516 |
this regular expression
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
517 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
518 |
112
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
519 |
00:05:28,130 --> 00:05:30,440
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
520 |
can match the empty string,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
521 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
522 |
113
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
523 |
00:05:30,440 --> 00:05:33,440
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
524 |
but it cannot match
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
525 |
any string that starts
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
526 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
527 |
114
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
528 |
00:05:33,440 --> 00:05:36,350
|
769
|
529 |
with c. So also in this case,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
530 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
531 |
115
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
532 |
00:05:36,350 --> 00:05:39,560
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
533 |
we just define it as
|
769
|
534 |
the regular expression,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
535 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
536 |
116
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
537 |
00:05:39,560 --> 00:05:41,615
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
538 |
which cannot match anything.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
539 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
540 |
117
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
541 |
00:05:41,615 --> 00:05:45,170
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
542 |
In the next case, this
|
769
|
543 |
c is the argument to
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
544 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
545 |
118
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
546 |
00:05:45,170 --> 00:05:48,335
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
547 |
the derivative and this d
|
769
|
548 |
is the regular expression.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
549 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
550 |
119
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
551 |
00:05:48,335 --> 00:05:50,225
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
552 |
So now there are two cases.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
553 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
554 |
120
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
555 |
00:05:50,225 --> 00:05:53,525
|
769
|
556 |
If this c and this d
|
|
557 |
is actually equal,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
558 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
559 |
121
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
560 |
00:05:53,525 --> 00:05:55,970
|
769
|
561 |
Thaat means this regular
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
562 |
expression can match
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
563 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
564 |
122
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
565 |
00:05:55,970 --> 00:05:59,240
|
769
|
566 |
a string which just contains c.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
567 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
568 |
123
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
569 |
00:05:59,240 --> 00:06:01,505
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
570 |
So if we strip that off,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
571 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
572 |
124
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
573 |
00:06:01,505 --> 00:06:04,790
|
769
|
574 |
what remains is
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
575 |
the empty string.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
576 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
577 |
125
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
578 |
00:06:04,790 --> 00:06:06,890
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
579 |
What is a regular expression
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
580 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
581 |
126
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
582 |
00:06:06,890 --> 00:06:09,170
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
583 |
look like that can
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
584 |
match the empty string.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
585 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
586 |
127
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
587 |
00:06:09,170 --> 00:06:11,915
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
588 |
Well, that's the
|
769
|
589 |
purpose of the 1.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
590 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
591 |
128
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
592 |
00:06:11,915 --> 00:06:15,440
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
593 |
And if c is not equal to d,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
594 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
595 |
129
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
596 |
00:06:15,440 --> 00:06:17,630
|
769
|
597 |
then this regular expression
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
598 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
599 |
130
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
600 |
00:06:17,630 --> 00:06:19,220
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
601 |
cannot match anything
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
602 |
which starts with
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
603 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
604 |
131
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
605 |
00:06:19,220 --> 00:06:23,780
|
769
|
606 |
a c. So again it will
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
607 |
be defined as just 0.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
608 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
609 |
132
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
610 |
00:06:23,780 --> 00:06:29,390
|
769
|
611 |
Now, the alternative case,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
612 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
613 |
133
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
614 |
00:06:29,390 --> 00:06:31,970
|
769
|
615 |
if this regular expression can
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
616 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
617 |
134
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
618 |
00:06:31,970 --> 00:06:36,050
|
769
|
619 |
match strings
|
|
620 |
starting with c,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
621 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
622 |
135
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
623 |
00:06:36,050 --> 00:06:40,820
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
624 |
then it can either be
|
769
|
625 |
matched by the r1
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
626 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
627 |
136
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
628 |
00:06:40,820 --> 00:06:44,495
|
769
|
629 |
or it can be matched by the r2.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
630 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
631 |
137
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
632 |
00:06:44,495 --> 00:06:50,090
|
769
|
633 |
If the r1 can match c
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
634 |
and then following a string,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
635 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
636 |
138
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
637 |
00:06:50,090 --> 00:06:53,975
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
638 |
then we just have to recursively
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
639 |
call the derivative for
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
640 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
641 |
139
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
642 |
00:06:53,975 --> 00:06:56,570
|
769
|
643 |
r1 to get a regular expression
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
644 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
645 |
140
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
646 |
00:06:56,570 --> 00:06:59,135
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
647 |
that can match the
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
648 |
rest of the string.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
649 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
650 |
141
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
651 |
00:06:59,135 --> 00:07:02,690
|
769
|
652 |
And the same we can do with r2.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
653 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
654 |
142
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
655 |
00:07:02,690 --> 00:07:06,110
|
769
|
656 |
You can find a regular expression
|
|
657 |
which can match everything
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
658 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
659 |
143
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
660 |
00:07:06,110 --> 00:07:07,850
|
769
|
661 |
this r2 can match,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
662 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
663 |
144
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
664 |
00:07:07,850 --> 00:07:09,710
|
769
|
665 |
starting with c, but
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
666 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
667 |
145
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
668 |
00:07:09,710 --> 00:07:12,590
|
769
|
669 |
we are chopping off this c.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
670 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
671 |
146
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
672 |
00:07:12,590 --> 00:07:16,370
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
673 |
So now if you have to find
|
769
|
674 |
the regular expression,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
675 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
676 |
147
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
677 |
00:07:16,370 --> 00:07:20,030
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
678 |
which can match all the strings
|
769
|
679 |
where c is chopped off,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
680 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
681 |
148
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
682 |
00:07:20,030 --> 00:07:22,295
|
769
|
683 |
then we just have to
|
|
684 |
take the alternative
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
685 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
686 |
149
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
687 |
00:07:22,295 --> 00:07:24,965
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
688 |
of these two derivatives.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
689 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
690 |
150
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
691 |
00:07:24,965 --> 00:07:29,390
|
769
|
692 |
Now to sequence case.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
693 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
694 |
151
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
695 |
00:07:29,390 --> 00:07:33,005
|
769
|
696 |
This sequence case is the
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
697 |
most complicated one.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
698 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
699 |
152
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
700 |
00:07:33,005 --> 00:07:35,180
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
701 |
And let's look first at
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
702 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
703 |
153
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
704 |
00:07:35,180 --> 00:07:39,335
|
769
|
705 |
the second case, in the
|
|
706 |
else branch.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
707 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
708 |
154
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
709 |
00:07:39,335 --> 00:07:42,830
|
769
|
710 |
So if this
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
711 |
regular expression
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
712 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
713 |
155
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
714 |
00:07:42,830 --> 00:07:46,145
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
715 |
can match a string
|
769
|
716 |
starting with c,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
717 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
718 |
156
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
719 |
00:07:46,145 --> 00:07:48,155
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
720 |
then the following
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
721 |
must have happened.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
722 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
723 |
157
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
724 |
00:07:48,155 --> 00:07:51,905
|
769
|
725 |
First, the r1 must have matched
|
|
726 |
a string starting with c
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
727 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
728 |
158
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
729 |
00:07:51,905 --> 00:07:56,420
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
730 |
and then anything coming
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
731 |
afterwards with r2.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
732 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
733 |
159
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
734 |
00:07:56,420 --> 00:07:59,660
|
769
|
735 |
So in this case I only
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
736 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
737 |
160
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
738 |
00:07:59,660 --> 00:08:03,260
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
739 |
have to call this
|
769
|
740 |
derivative for this r1,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
741 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
742 |
161
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
743 |
00:08:03,260 --> 00:08:06,830
|
769
|
744 |
and find the regular expression
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
745 |
which can match everything
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
746 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
747 |
162
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
748 |
00:08:06,830 --> 00:08:11,555
|
769
|
749 |
this r1 can match except
|
|
750 |
for this c chopped off.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
751 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
752 |
163
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
753 |
00:08:11,555 --> 00:08:15,830
|
769
|
754 |
And I have to build the
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
755 |
sequence derivative of that.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
756 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
757 |
164
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
758 |
00:08:15,830 --> 00:08:18,260
|
769
|
759 |
So that's what the else branch says:
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
760 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
761 |
165
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
762 |
00:08:18,260 --> 00:08:21,860
|
769
|
763 |
I take the
|
|
764 |
derivative of r1 and I
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
765 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
766 |
166
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
767 |
00:08:21,860 --> 00:08:23,480
|
769
|
768 |
put the r2 on
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
769 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
770 |
167
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
771 |
00:08:23,480 --> 00:08:25,865
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
772 |
the back because that's
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
773 |
the rest of the string.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
774 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
775 |
168
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
776 |
00:08:25,865 --> 00:08:29,240
|
769
|
777 |
So that's the only
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
778 |
case we have to consider
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
779 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
780 |
169
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
781 |
00:08:29,240 --> 00:08:32,750
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
782 |
this sequence case
|
769
|
783 |
except if not the
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
784 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
785 |
170
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
786 |
00:08:32,750 --> 00:08:37,895
|
769
|
787 |
r1 can match the
|
|
788 |
c and something else.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
789 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
790 |
171
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
791 |
00:08:37,895 --> 00:08:42,965
|
769
|
792 |
But if r1 is matching
|
|
793 |
actually the empty string.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
794 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
795 |
172
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
796 |
00:08:42,965 --> 00:08:48,890
|
769
|
797 |
In this case actually the r2
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
798 |
is in charge of matching
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
799 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
800 |
173
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
801 |
00:08:48,890 --> 00:08:51,590
|
769
|
802 |
the string starting with c. So in
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
803 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
804 |
174
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
805 |
00:08:51,590 --> 00:08:55,490
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
806 |
this case we have to call
|
769
|
807 |
the derivative for r2.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
808 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
809 |
175
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
810 |
00:08:55,490 --> 00:08:57,875
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
811 |
So that's why we have
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
812 |
these two cases.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
813 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
814 |
176
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
815 |
00:08:57,875 --> 00:09:00,455
|
769
|
816 |
So if r1 is nullable,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
817 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
818 |
177
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
819 |
00:09:00,455 --> 00:09:03,245
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
820 |
then it can match
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
821 |
the empty string.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
822 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
823 |
178
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
824 |
00:09:03,245 --> 00:09:05,330
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
825 |
And we have to
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
826 |
consider the case that
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
827 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
828 |
179
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
829 |
00:09:05,330 --> 00:09:08,045
|
769
|
830 |
this r2 is matching a string
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
831 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
832 |
180
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
833 |
00:09:08,045 --> 00:09:10,700
|
769
|
834 |
starting with c. And so we have
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
835 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
836 |
181
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
837 |
00:09:10,700 --> 00:09:14,210
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
838 |
to call the derivative
|
769
|
839 |
for this r2 in this case.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
840 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
841 |
182
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
842 |
00:09:14,210 --> 00:09:18,680
|
769
|
843 |
Otherwise, the r1 will
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
844 |
be in charge of matching
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
845 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
846 |
183
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
847 |
00:09:18,680 --> 00:09:20,840
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
848 |
a part of that
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
849 |
string starting with
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
850 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
851 |
184
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
852 |
00:09:20,840 --> 00:09:24,695
|
769
|
853 |
c. And I have to call the
|
|
854 |
derivative on this r1.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
855 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
856 |
185
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
857 |
00:09:24,695 --> 00:09:30,670
|
769
|
858 |
I hope this makes sense.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
859 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
860 |
186
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
861 |
00:09:30,670 --> 00:09:34,150
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
862 |
Go over that and
|
769
|
863 |
also the handouts
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
864 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
865 |
187
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
866 |
00:09:34,150 --> 00:09:37,465
|
769
|
867 |
again. That case
|
|
868 |
is really subtle.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
869 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
870 |
188
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
871 |
00:09:37,465 --> 00:09:40,945
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
872 |
And how do I remember this case?
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
873 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
874 |
189
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
875 |
00:09:40,945 --> 00:09:42,430
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
876 |
Well, I know it's
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
877 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
878 |
190
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
879 |
00:09:42,430 --> 00:09:45,310
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
880 |
an if condition and the
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
881 |
condition is nullable,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
882 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
883 |
191
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
884 |
00:09:45,310 --> 00:09:48,160
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
885 |
then I will always remember
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
886 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
887 |
192
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
888 |
00:09:48,160 --> 00:09:53,275
|
769
|
889 |
the else branch where it pushes
|
|
890 |
the derivative over the r1.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
891 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
892 |
193
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
893 |
00:09:53,275 --> 00:09:55,780
|
769
|
894 |
So I usually write
|
|
895 |
down the else branch first,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
896 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
897 |
194
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
898 |
00:09:55,780 --> 00:09:59,650
|
769
|
899 |
and then construct
|
|
900 |
the then branch by saying,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
901 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
902 |
195
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
903 |
00:09:59,650 --> 00:10:01,525
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
904 |
well, I just repeat this.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
905 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
906 |
196
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
907 |
00:10:01,525 --> 00:10:03,760
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
908 |
And I have to remember
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
909 |
in that case I
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
910 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
911 |
197
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
912 |
00:10:03,760 --> 00:10:06,580
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
913 |
have to build also
|
769
|
914 |
derivative of r2.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
915 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
916 |
198
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
917 |
00:10:06,580 --> 00:10:12,695
|
769
|
918 |
Finally, the star case.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
919 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
920 |
199
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
921 |
00:10:12,695 --> 00:10:15,665
|
769
|
922 |
So here again
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
923 |
we're looking for
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
924 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
925 |
200
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
926 |
00:10:15,665 --> 00:10:17,300
|
769
|
927 |
a regular expression which
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
928 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
929 |
201
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
930 |
00:10:17,300 --> 00:10:19,745
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
931 |
can match the string
|
769
|
932 |
starting with c,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
933 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
934 |
202
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
935 |
00:10:19,745 --> 00:10:22,355
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
936 |
except that the c has
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
937 |
been chopped off.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
938 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
939 |
203
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
940 |
00:10:22,355 --> 00:10:28,640
|
769
|
941 |
So if r* has to match
|
|
942 |
a string starting with c,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
943 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
944 |
204
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
945 |
00:10:28,640 --> 00:10:32,735
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
946 |
then at least we need one
|
769
|
947 |
copy of this r.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
948 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
949 |
205
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
950 |
00:10:32,735 --> 00:10:34,310
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
951 |
So at least one copy of
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
952 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
953 |
206
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
954 |
00:10:34,310 --> 00:10:37,010
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
955 |
this r has matched
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
956 |
something which starts with
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
957 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
958 |
207
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
959 |
00:10:37,010 --> 00:10:38,870
|
769
|
960 |
a c and then afterwards
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
961 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
962 |
208
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
963 |
00:10:38,870 --> 00:10:41,570
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
964 |
come 0 more copies
|
769
|
965 |
of this r*.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
966 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
967 |
209
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
968 |
00:10:41,570 --> 00:10:45,530
|
769
|
969 |
What we do there
|
|
970 |
is we are trying to find
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
971 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
972 |
210
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
973 |
00:10:45,530 --> 00:10:47,960
|
769
|
974 |
the regular expression
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
975 |
which can match
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
976 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
977 |
211
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
978 |
00:10:47,960 --> 00:10:50,915
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
979 |
this first part of the string.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
980 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
981 |
212
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
982 |
00:10:50,915 --> 00:10:53,255
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
983 |
However, where the
|
769
|
984 |
c is chopped off.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
985 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
986 |
213
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
987 |
00:10:53,255 --> 00:10:55,130
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
988 |
And then we just say, well,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
989 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
990 |
214
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
991 |
00:10:55,130 --> 00:10:57,050
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
992 |
the rest has to be
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
993 |
matched again with
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
994 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
995 |
215
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
996 |
00:10:57,050 --> 00:10:59,030
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
997 |
0 or more copies of
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
998 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
999 |
216
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1000 |
00:10:59,030 --> 00:11:02,600
|
769
|
1001 |
this r. So that's why
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1002 |
it's defined like this.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1003 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1004 |
217
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1005 |
00:11:02,600 --> 00:11:09,050
|
769
|
1006 |
Okay? ...As said, please take care
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1007 |
with this definition.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1008 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1009 |
218
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1010 |
00:11:09,050 --> 00:11:11,435
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1011 |
That's not so simple.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1012 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1013 |
219
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1014 |
00:11:11,435 --> 00:11:13,250
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1015 |
Once you get a hang of it,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1016 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1017 |
220
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1018 |
00:11:13,250 --> 00:11:15,170
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1019 |
however, it makes perfect sense.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1020 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1021 |
221
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1022 |
00:11:15,170 --> 00:11:17,210
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1023 |
So let me explain it in
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1024 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1025 |
222
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1026 |
00:11:17,210 --> 00:11:20,825
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1027 |
different ways in
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1028 |
the next slides.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1029 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1030 |
223
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1031 |
00:11:20,825 --> 00:11:24,695
|
769
|
1032 |
Let's look
|
|
1033 |
first at some examples.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1034 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1035 |
224
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1036 |
00:11:24,695 --> 00:11:27,140
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1037 |
So here is a regular expression,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1038 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1039 |
225
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1040 |
00:11:27,140 --> 00:11:29,390
|
769
|
1041 |
r. And let's have
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1042 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1043 |
226
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1044 |
00:11:29,390 --> 00:11:32,450
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1045 |
a look at these three
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1046 |
derivatives according to a,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1047 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1048 |
227
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1049 |
00:11:32,450 --> 00:11:38,405
|
769
|
1050 |
b, and c. And we shall do
|
|
1051 |
the one for a.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1052 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1053 |
228
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1054 |
00:11:38,405 --> 00:11:42,379
|
769
|
1055 |
So here is our regular expression
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1056 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1057 |
229
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1058 |
00:11:42,379 --> 00:11:45,334
|
769
|
1059 |
and I was very generous
|
|
1060 |
with parentheses.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1061 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1062 |
230
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1063 |
00:11:45,334 --> 00:11:48,140
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1064 |
And the outermost is a star.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1065 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1066 |
231
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1067 |
00:11:48,140 --> 00:11:52,550
|
769
|
1068 |
So we now build the
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1069 |
derivative according to a,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1070 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1071 |
232
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1072 |
00:11:52,550 --> 00:11:55,474
|
769
|
1073 |
the character a, of
|
|
1074 |
that regular expression.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1075 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1076 |
233
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1077 |
00:11:55,474 --> 00:11:57,380
|
769
|
1078 |
So the first thing we
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1079 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1080 |
234
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1081 |
00:11:57,380 --> 00:11:59,555
|
769
|
1082 |
have to analyse is the case star.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1083 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1084 |
235
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1085 |
00:11:59,555 --> 00:12:04,370
|
769
|
1086 |
So here's the regular expression,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1087 |
which we are looking at.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1088 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1089 |
236
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1090 |
00:12:04,370 --> 00:12:09,170
|
769
|
1091 |
This r and the outermost
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1092 |
constructor is this star.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1093 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1094 |
237
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1095 |
00:12:09,170 --> 00:12:11,510
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1096 |
If you go back to the definition,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1097 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1098 |
238
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1099 |
00:12:11,510 --> 00:12:13,625
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1100 |
I hope you have it next to you,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1101 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1102 |
239
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1103 |
00:12:13,625 --> 00:12:16,340
|
769
|
1104 |
then this star-case is defined
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1105 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1106 |
240
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1107 |
00:12:16,340 --> 00:12:20,000
|
769
|
1108 |
as you're taking just the
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1109 |
inside of the star
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1110 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1111 |
241
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1112 |
00:12:20,000 --> 00:12:23,030
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1113 |
and apply this derivative and
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1114 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1115 |
242
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1116 |
00:12:23,030 --> 00:12:26,765
|
769
|
1117 |
leave the r on the
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1118 |
outside at the end.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1119 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1120 |
243
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1121 |
00:12:26,765 --> 00:12:29,990
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1122 |
Ok. So that's the first step.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1123 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1124 |
244
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1125 |
00:12:29,990 --> 00:12:32,030
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1126 |
Now we have to analyze
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1127 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1128 |
245
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1129 |
00:12:32,030 --> 00:12:36,035
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1130 |
the derivative according to
|
769
|
1131 |
a of this regular expression,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1132 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1133 |
246
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1134 |
00:12:36,035 --> 00:12:38,000
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1135 |
which is an alternative.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1136 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1137 |
247
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1138 |
00:12:38,000 --> 00:12:39,665
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1139 |
So the outermost is a plus.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1140 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1141 |
248
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1142 |
00:12:39,665 --> 00:12:41,375
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1143 |
Ok, that's very easy again,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1144 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1145 |
249
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1146 |
00:12:41,375 --> 00:12:45,185
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1147 |
we just have to push the
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1148 |
derivative into each component,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1149 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1150 |
250
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1151 |
00:12:45,185 --> 00:12:47,705
|
769
|
1152 |
into the a followed by b.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1153 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1154 |
251
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1155 |
00:12:47,705 --> 00:12:49,145
|
769
|
1156 |
And into the second
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1157 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1158 |
252
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1159 |
00:12:49,145 --> 00:12:51,185
|
769
|
1160 |
alternative, into b.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1161 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1162 |
253
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1163 |
00:12:51,185 --> 00:12:56,030
|
769
|
1164 |
We take the derivative
|
|
1165 |
of each according to a.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1166 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1167 |
254
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1168 |
00:12:56,030 --> 00:13:00,635
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1169 |
Now this one is a sequence
|
769
|
1170 |
regular expression.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1171 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1172 |
255
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1173 |
00:13:00,635 --> 00:13:02,210
|
769
|
1174 |
This was the complicated case.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1175 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1176 |
256
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1177 |
00:13:02,210 --> 00:13:04,160
|
769
|
1178 |
First of all
|
|
1179 |
we have to test is
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1180 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1181 |
257
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1182 |
00:13:04,160 --> 00:13:07,910
|
769
|
1183 |
the first component
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1184 |
nullable of this sequence?
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1185 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1186 |
258
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1187 |
00:13:07,910 --> 00:13:09,200
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1188 |
Well, that is a,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1189 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1190 |
259
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1191 |
00:13:09,200 --> 00:13:12,740
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1192 |
in this case, a on its
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1193 |
own is not nullable.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1194 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1195 |
260
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1196 |
00:13:12,740 --> 00:13:14,210
|
769
|
1197 |
So we are the easy case,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1198 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1199 |
261
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1200 |
00:13:14,210 --> 00:13:17,000
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1201 |
we only have a single derivative
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1202 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1203 |
262
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1204 |
00:13:17,000 --> 00:13:19,370
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1205 |
pushed in the first component.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1206 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1207 |
263
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1208 |
00:13:19,370 --> 00:13:25,160
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1209 |
So we have the derivative
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1210 |
of a with the character a.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1211 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1212 |
264
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1213 |
00:13:25,160 --> 00:13:27,920
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1214 |
Okay, that's now
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1215 |
the character case.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1216 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1217 |
265
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1218 |
00:13:27,920 --> 00:13:29,720
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1219 |
And in this case the character
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1220 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1221 |
266
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1222 |
00:13:29,720 --> 00:13:31,715
|
769
|
1223 |
and the regular expression agree.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1224 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1225 |
267
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1226 |
00:13:31,715 --> 00:13:33,890
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1227 |
So it's defined as one.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1228 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1229 |
268
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1230 |
00:13:33,890 --> 00:13:37,550
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1231 |
Ok? In the other case,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1232 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1233 |
269
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1234 |
00:13:37,550 --> 00:13:39,710
|
769
|
1235 |
the regular expression is b,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1236 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1237 |
270
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1238 |
00:13:39,710 --> 00:13:41,675
|
769
|
1239 |
but the characters a.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1240 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1241 |
271
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1242 |
00:13:41,675 --> 00:13:46,385
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1243 |
So in this case
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1244 |
it's defined as 0.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1245 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1246 |
272
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1247 |
00:13:46,385 --> 00:13:50,630
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1248 |
Okay? So that's what the
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1249 |
derivative would be.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1250 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1251 |
273
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1252 |
00:13:50,630 --> 00:13:52,160
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1253 |
This r is there
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1254 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1255 |
274
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1256 |
00:13:52,160 --> 00:13:55,280
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1257 |
because originally we
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1258 |
started with a star.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1259 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1260 |
275
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1261 |
00:13:55,280 --> 00:13:58,295
|
769
|
1262 |
This regular expression is that star.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1263 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1264 |
276
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1265 |
00:13:58,295 --> 00:14:02,780
|
769
|
1266 |
So the derivative
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1267 |
according to a
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1268 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1269 |
277
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1270 |
00:14:02,780 --> 00:14:07,610
|
769
|
1271 |
of that regular expression
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1272 |
is this expression.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1273 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1274 |
278
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1275 |
00:14:07,610 --> 00:14:10,970
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1276 |
We just have to
|
769
|
1277 |
substitute this r back in.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1278 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1279 |
279
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1280 |
00:14:10,970 --> 00:14:13,745
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1281 |
Just coming back to this slide.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1282 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1283 |
280
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1284 |
00:14:13,745 --> 00:14:16,160
|
769
|
1285 |
So far, we only analyzes
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1286 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1287 |
281
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1288 |
00:14:16,160 --> 00:14:19,505
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1289 |
the derivative according
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1290 |
to a single character.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1291 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1292 |
282
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1293 |
00:14:19,505 --> 00:14:23,960
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1294 |
But we can also very easily
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1295 |
extend that to whole strings.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1296 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1297 |
283
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1298 |
00:14:23,960 --> 00:14:26,360
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1299 |
So if you build the
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1300 |
derivative according
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1301 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1302 |
284
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1303 |
00:14:26,360 --> 00:14:27,905
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1304 |
to the empty string,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1305 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1306 |
285
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1307 |
00:14:27,905 --> 00:14:30,875
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1308 |
we just return the
|
769
|
1309 |
regular expression.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1310 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1311 |
286
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1312 |
00:14:30,875 --> 00:14:35,585
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1313 |
If we have a string
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1314 |
starting with character c,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1315 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1316 |
287
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1317 |
00:14:35,585 --> 00:14:37,850
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1318 |
remember that can
|
769
|
1319 |
be any character,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1320 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1321 |
288
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1322 |
00:14:37,850 --> 00:14:42,170
|
769
|
1323 |
then we build first the simple
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1324 |
derivative according to
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1325 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1326 |
289
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1327 |
00:14:42,170 --> 00:14:44,360
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1328 |
that first character and
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1329 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1330 |
290
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1331 |
00:14:44,360 --> 00:14:46,925
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1332 |
continue with the
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1333 |
rest of the string.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1334 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1335 |
291
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1336 |
00:14:46,925 --> 00:14:50,615
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1337 |
So here you see again,
|
769
|
1338 |
my personal convention:
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1339 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1340 |
292
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1341 |
00:14:50,615 --> 00:14:54,365
|
769
|
1342 |
everything which works on
|
|
1343 |
lists has this s at the end.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1344 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1345 |
293
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1346 |
00:14:54,365 --> 00:14:57,125
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1347 |
So this function is
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1348 |
for single characters.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1349 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1350 |
294
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1351 |
00:14:57,125 --> 00:14:59,179
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1352 |
This one is for strings,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1353 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1354 |
295
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1355 |
00:14:59,179 --> 00:15:02,450
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1356 |
but it uses the one
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1357 |
for the character.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1358 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1359 |
296
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1360 |
00:15:02,450 --> 00:15:04,025
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1361 |
Essentially what it does is
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1362 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1363 |
297
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1364 |
00:15:04,025 --> 00:15:06,185
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1365 |
it chops off the first character,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1366 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1367 |
298
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1368 |
00:15:06,185 --> 00:15:09,800
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1369 |
builds the derivative, then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1370 |
chops off the next character,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1371 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1372 |
299
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1373 |
00:15:09,800 --> 00:15:13,760
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1374 |
builds the derivative of
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1375 |
the result, and so on.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1376 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1377 |
300
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1378 |
00:15:13,760 --> 00:15:17,000
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1379 |
Having this function,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1380 |
we can actually now
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1381 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1382 |
301
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1383 |
00:15:17,000 --> 00:15:20,600
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1384 |
state what the algorithm
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1385 |
is, the complete algorithm.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1386 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1387 |
302
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1388 |
00:15:20,600 --> 00:15:23,465
|
769
|
1389 |
So the Brzozowski matcher
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1390 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1391 |
303
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1392 |
00:15:23,465 --> 00:15:24,860
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1393 |
takes a regular expression as
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1394 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1395 |
304
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1396 |
00:15:24,860 --> 00:15:26,915
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1397 |
argument and a
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1398 |
string as argument.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1399 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1400 |
305
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1401 |
00:15:26,915 --> 00:15:30,920
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1402 |
And is supposed to say yes if
|
769
|
1403 |
the regular expression matches
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1404 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1405 |
306
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1406 |
00:15:30,920 --> 00:15:33,560
|
769
|
1407 |
the string or no
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1408 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1409 |
307
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1410 |
00:15:33,560 --> 00:15:36,065
|
769
|
1411 |
if the regular expression does
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1412 |
not match the string.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1413 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1414 |
308
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1415 |
00:15:36,065 --> 00:15:37,715
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1416 |
And how does it do that?
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1417 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1418 |
309
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1419 |
00:15:37,715 --> 00:15:42,560
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1420 |
Well, it takes this string
|
769
|
1421 |
s and this regular expression,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1422 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1423 |
310
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1424 |
00:15:42,560 --> 00:15:43,925
|
769
|
1425 |
and it first builds
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1426 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1427 |
311
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1428 |
00:15:43,925 --> 00:15:48,845
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1429 |
successive derivatives until
|
769
|
1430 |
that string is exhausted.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1431 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1432 |
312
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1433 |
00:15:48,845 --> 00:15:52,115
|
769
|
1434 |
Then you have
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1435 |
a final derivative,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1436 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1437 |
313
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1438 |
00:15:52,115 --> 00:15:53,839
|
769
|
1439 |
a final regular expression
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1440 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1441 |
314
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1442 |
00:15:53,839 --> 00:15:55,370
|
769
|
1443 |
and you test whether
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1444 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1445 |
315
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1446 |
00:15:55,370 --> 00:15:57,920
|
769
|
1447 |
this regular expression can
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1448 |
match the empty string.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1449 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1450 |
316
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1451 |
00:15:57,920 --> 00:16:01,370
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1452 |
If yes, then the
|
769
|
1453 |
original regular expression,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1454 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1455 |
317
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1456 |
00:16:01,370 --> 00:16:03,245
|
769
|
1457 |
this r, can match the string.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1458 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1459 |
318
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1460 |
00:16:03,245 --> 00:16:05,210
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1461 |
If no, if it cannot match
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1462 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1463 |
319
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1464 |
00:16:05,210 --> 00:16:08,030
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1465 |
the final derivative
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1466 |
with the empty string,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1467 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1468 |
320
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1469 |
00:16:08,030 --> 00:16:10,280
|
769
|
1470 |
then no this
|
|
1471 |
regular expression r
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1472 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1473 |
321
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1474 |
00:16:10,280 --> 00:16:12,905
|
769
|
1475 |
cannot match that string.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1476 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1477 |
322
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1478 |
00:16:12,905 --> 00:16:16,010
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1479 |
I know it looks
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1480 |
very anticlimactic,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1481 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1482 |
323
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1483 |
00:16:16,010 --> 00:16:19,625
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1484 |
but that's actually the
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1485 |
beauty of this algorithm,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1486 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1487 |
324
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1488 |
00:16:19,625 --> 00:16:22,760
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1489 |
that it's not that complicated.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1490 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1491 |
325
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1492 |
00:16:22,760 --> 00:16:25,340
|
769
|
1493 |
So how does the algorithm work
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1494 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1495 |
326
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1496 |
00:16:25,340 --> 00:16:27,634
|
769
|
1497 |
in a concrete example?
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1498 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1499 |
327
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1500 |
00:16:27,634 --> 00:16:31,580
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1501 |
Imagine you have a string, abc
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1502 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1503 |
328
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1504 |
00:16:31,580 --> 00:16:34,370
|
769
|
1505 |
and you have a regular
|
|
1506 |
expression, say r1.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1507 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1508 |
329
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1509 |
00:16:34,370 --> 00:16:37,520
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1510 |
And you want to find out
|
769
|
1511 |
whether this r1 can match
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1512 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1513 |
330
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1514 |
00:16:37,520 --> 00:16:41,300
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1515 |
that string abc or not.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1516 |
How do you do that?
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1517 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1518 |
331
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1519 |
00:16:41,300 --> 00:16:45,140
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1520 |
Well, you would first
|
769
|
1521 |
take this r1 and you
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1522 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1523 |
332
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1524 |
00:16:45,140 --> 00:16:47,150
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1525 |
build the derivative according
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1526 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1527 |
333
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1528 |
00:16:47,150 --> 00:16:49,880
|
769
|
1529 |
to the first character, the a.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1530 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1531 |
334
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1532 |
00:16:49,880 --> 00:16:53,015
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1533 |
Okay? You get the derivative,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1534 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1535 |
335
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1536 |
00:16:53,015 --> 00:16:55,294
|
769
|
1537 |
which I call here r2.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1538 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1539 |
336
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1540 |
00:16:55,294 --> 00:16:58,640
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1541 |
Then you take the next
|
769
|
1542 |
character, the b.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1543 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1544 |
337
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1545 |
00:16:58,640 --> 00:17:04,535
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1546 |
You now build the derivative
|
769
|
1547 |
according to b of this r2.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1548 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1549 |
338
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1550 |
00:17:04,535 --> 00:17:07,460
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1551 |
Okay? So you take the
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1552 |
result of the first step,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1553 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1554 |
339
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1555 |
00:17:07,460 --> 00:17:09,530
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1556 |
you feed it into the second step,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1557 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1558 |
340
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1559 |
00:17:09,530 --> 00:17:11,810
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1560 |
and you take the
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1561 |
second character.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1562 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1563 |
341
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1564 |
00:17:11,810 --> 00:17:17,075
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1565 |
Then you do this also with c.
|
769
|
1566 |
So you get a derivative r3,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1567 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1568 |
342
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1569 |
00:17:17,075 --> 00:17:22,460
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1570 |
and you build the derivative
|
769
|
1571 |
of r3 according to c,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1572 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1573 |
343
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1574 |
00:17:22,460 --> 00:17:24,185
|
769
|
1575 |
you get an r4.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1576 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1577 |
344
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1578 |
00:17:24,185 --> 00:17:26,300
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1579 |
Okay, so that's the
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1580 |
final derivative.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1581 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1582 |
345
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1583 |
00:17:26,300 --> 00:17:27,530
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1584 |
The string is exhausted.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1585 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1586 |
346
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1587 |
00:17:27,530 --> 00:17:29,570
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1588 |
We build derivatives
|
769
|
1589 |
according to a, b,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1590 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1591 |
347
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1592 |
00:17:29,570 --> 00:17:34,610
|
769
|
1593 |
and c. Now we just test whether
|
|
1594 |
this r4 is nullable.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1595 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1596 |
348
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1597 |
00:17:34,610 --> 00:17:37,175
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1598 |
If it says yes,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1599 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1600 |
349
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1601 |
00:17:37,175 --> 00:17:41,510
|
769
|
1602 |
then the regular expression matcher
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1603 |
will just say true, yes,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1604 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1605 |
350
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1606 |
00:17:41,510 --> 00:17:43,340
|
769
|
1607 |
this original regular expression,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1608 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1609 |
351
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1610 |
00:17:43,340 --> 00:17:47,270
|
769
|
1611 |
the r1, will be able to
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1612 |
match that string abc.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1613 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1614 |
352
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1615 |
00:17:47,270 --> 00:17:50,585
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1616 |
And if this test returns false,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1617 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1618 |
353
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1619 |
00:17:50,585 --> 00:17:53,015
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1620 |
then the algorithm says false.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1621 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1622 |
354
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1623 |
00:17:53,015 --> 00:17:56,975
|
769
|
1624 |
This regular expression will
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1625 |
not match the string.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1626 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1627 |
355
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1628 |
00:17:56,975 --> 00:18:00,260
|
769
|
1629 |
Ok, you might ask:
|
|
1630 |
Why on earth does
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1631 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1632 |
356
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1633 |
00:18:00,260 --> 00:18:02,960
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1634 |
that algorithm
|
769
|
1635 |
actually work?
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1636 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1637 |
357
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1638 |
00:18:02,960 --> 00:18:06,515
|
769
|
1639 |
Here's anather explanation
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1640 |
for why it works.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1641 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1642 |
358
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1643 |
00:18:06,515 --> 00:18:10,190
|
769
|
1644 |
Imagine you have a regular
|
|
1645 |
expression r1, okay?
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1646 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1647 |
359
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1648 |
00:18:10,190 --> 00:18:13,220
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1649 |
And you have a string abc,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1650 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1651 |
360
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1652 |
00:18:13,220 --> 00:18:14,270
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1653 |
and you want to find out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1654 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1655 |
361
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1656 |
00:18:14,270 --> 00:18:17,180
|
769
|
1657 |
whether r1 can
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1658 |
match that string.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1659 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1660 |
362
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1661 |
00:18:17,180 --> 00:18:18,799
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1662 |
And for the moment,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1663 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1664 |
363
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1665 |
00:18:18,799 --> 00:18:22,610
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1666 |
let's assume that it
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1667 |
can match that string.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1668 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1669 |
364
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1670 |
00:18:22,610 --> 00:18:26,315
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1671 |
Ok? So the language L of
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1672 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1673 |
365
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1674 |
00:18:26,315 --> 00:18:30,185
|
769
|
1675 |
r1 will actually
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1676 |
contain that string,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1677 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1678 |
366
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1679 |
00:18:30,185 --> 00:18:31,805
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1680 |
otherwise it wouldn't match that.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1681 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1682 |
367
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1683 |
00:18:31,805 --> 00:18:36,710
|
769
|
1684 |
Okay? So abc is in
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1685 |
this language, okay?
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1686 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1687 |
368
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1688 |
00:18:36,710 --> 00:18:39,785
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1689 |
If I now take the
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1690 |
semantic derivative,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1691 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1692 |
369
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1693 |
00:18:39,785 --> 00:18:43,145
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1694 |
that means I look at all
|
769
|
1695 |
the strings in this L(r1)
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1696 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1697 |
370
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1698 |
00:18:43,145 --> 00:18:46,820
|
769
|
1699 |
and filter out
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1700 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1701 |
371
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1702 |
00:18:46,820 --> 00:18:48,740
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1703 |
all the ones which
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1704 |
do not start with
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1705 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1706 |
372
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1707 |
00:18:48,740 --> 00:18:51,260
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1708 |
an a, I discharge them.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1709 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1710 |
373
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1711 |
00:18:51,260 --> 00:18:54,545
|
769
|
1712 |
And I only look at the ones
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1713 |
which start with an a.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1714 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1715 |
374
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1716 |
00:18:54,545 --> 00:18:56,465
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1717 |
And of those strings,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1718 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1719 |
375
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1720 |
00:18:56,465 --> 00:18:58,475
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1721 |
I chop off this a.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1722 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1723 |
376
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1724 |
00:18:58,475 --> 00:19:01,025
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1725 |
So after this
|
769
|
1726 |
semantic derivative,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1727 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1728 |
377
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1729 |
00:19:01,025 --> 00:19:05,735
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1730 |
this set of strings will
|
769
|
1731 |
contain just bc.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1732 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1733 |
378
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1734 |
00:19:05,735 --> 00:19:12,830
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1735 |
Ok. Now if I build the next
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1736 |
semantic derivative of that,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1737 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1738 |
379
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1739 |
00:19:12,830 --> 00:19:14,345
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1740 |
then I would look at
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1741 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1742 |
380
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1743 |
00:19:14,345 --> 00:19:16,850
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1744 |
all the strings which
|
769
|
1745 |
start with a b,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1746 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1747 |
381
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1748 |
00:19:16,850 --> 00:19:21,350
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1749 |
and forget about everything
|
769
|
1750 |
else. Of the remaining ones
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1751 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1752 |
382
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1753 |
00:19:21,350 --> 00:19:27,905
|
769
|
1754 |
I know they start with b.
|
|
1755 |
I just chop of the b. Ok.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1756 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1757 |
383
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1758 |
00:19:27,905 --> 00:19:31,655
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1759 |
So in this whole set here,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1760 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1761 |
384
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1762 |
00:19:31,655 --> 00:19:33,785
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1763 |
in this whole set here,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1764 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1765 |
385
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1766 |
00:19:33,785 --> 00:19:39,030
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1767 |
there will be now a string
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1768 |
which is just c. Okay?
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1769 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1770 |
386
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1771 |
00:19:39,190 --> 00:19:44,420
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1772 |
Then I built the third
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1773 |
semantic derivative
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1774 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1775 |
387
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1776 |
00:19:44,420 --> 00:19:47,300
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1777 |
because I want to find out
|
769
|
1778 |
whether abc is matched.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1779 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1780 |
388
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1781 |
00:19:47,300 --> 00:19:50,540
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1782 |
Okay? So now I look
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1783 |
at all the strings in
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1784 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1785 |
389
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1786 |
00:19:50,540 --> 00:19:52,820
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1787 |
here and look at
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1788 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1789 |
390
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1790 |
00:19:52,820 --> 00:19:55,340
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1791 |
them whether they start
|
769
|
1792 |
with a c. If yes,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1793 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1794 |
391
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1795 |
00:19:55,340 --> 00:19:56,885
|
769
|
1796 |
I chop off the c.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1797 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1798 |
392
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1799 |
00:19:56,885 --> 00:19:59,120
|
769
|
1800 |
And put in what is remaining.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1801 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1802 |
393
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1803 |
00:19:59,120 --> 00:20:00,425
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1804 |
So in this case,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1805 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1806 |
394
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1807 |
00:20:00,425 --> 00:20:02,510
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1808 |
if I have the string c
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1809 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1810 |
395
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1811 |
00:20:02,510 --> 00:20:04,550
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1812 |
in this language and
|
769
|
1813 |
I chop off this c,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1814 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1815 |
396
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1816 |
00:20:04,550 --> 00:20:07,700
|
769
|
1817 |
what is remaining
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1818 |
is the empty string.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1819 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1820 |
397
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1821 |
00:20:07,700 --> 00:20:09,695
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1822 |
So we have to check of
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1823 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1824 |
398
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1825 |
00:20:09,695 --> 00:20:14,510
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1826 |
that language whether it
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1827 |
contains the empty string.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1828 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1829 |
399
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1830 |
00:20:14,510 --> 00:20:18,800
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1831 |
If yes, then the
|
769
|
1832 |
original r1 can match
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1833 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1834 |
400
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1835 |
00:20:18,800 --> 00:20:21,050
|
769
|
1836 |
this abc because this abc
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1837 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1838 |
401
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1839 |
00:20:21,050 --> 00:20:24,119
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1840 |
must have been in this language.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1841 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1842 |
402
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1843 |
00:20:24,130 --> 00:20:28,565
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1844 |
And if in the end there wasn't
|
769
|
1845 |
the empty string, then
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1846 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1847 |
403
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1848 |
00:20:28,565 --> 00:20:33,575
|
769
|
1849 |
this abs was not in
|
|
1850 |
this language of r1.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1851 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1852 |
404
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1853 |
00:20:33,575 --> 00:20:36,260
|
769
|
1854 |
And so the lexer must have,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1855 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1856 |
405
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1857 |
00:20:36,260 --> 00:20:38,880
|
769
|
1858 |
or the matcher must have failed.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1859 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1860 |
406
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1861 |
00:20:39,040 --> 00:20:42,530
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1862 |
The clever bit is that here
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1863 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1864 |
407
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1865 |
00:20:42,530 --> 00:20:45,530
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1866 |
the explanation is for languages.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1867 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1868 |
408
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1869 |
00:20:45,530 --> 00:20:49,835
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1870 |
Remember, this
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1871 |
semantic derivative
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1872 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1873 |
409
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1874 |
00:20:49,835 --> 00:20:53,450
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1875 |
works over languages and they
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1876 |
sometimes can be in finite.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1877 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1878 |
410
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1879 |
00:20:53,450 --> 00:20:55,730
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1880 |
So that's not really
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1881 |
an algorithm.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1882 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1883 |
411
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1884 |
00:20:55,730 --> 00:20:58,880
|
769
|
1885 |
That's just
|
|
1886 |
explaining the idea.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1887 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1888 |
412
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1889 |
00:20:58,880 --> 00:21:02,525
|
769
|
1890 |
What Brzozowski
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1891 |
achieved was that he
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1892 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1893 |
413
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1894 |
00:21:02,525 --> 00:21:06,440
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1895 |
now works with this derivative
|
769
|
1896 |
regular expressions and
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1897 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1898 |
414
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1899 |
00:21:06,440 --> 00:21:10,715
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1900 |
somehow imitates what
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1901 |
happens on these languages.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1902 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1903 |
415
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1904 |
00:21:10,715 --> 00:21:14,135
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1905 |
Because remember if you
|
769
|
1906 |
have a regular expression,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1907 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1908 |
416
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1909 |
00:21:14,135 --> 00:21:17,405
|
769
|
1910 |
and you want to test
|
|
1911 |
whether it can match abc,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1912 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1913 |
417
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1914 |
00:21:17,405 --> 00:21:22,550
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1915 |
then you take first
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1916 |
derivative according to a.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1917 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1918 |
418
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1919 |
00:21:22,550 --> 00:21:25,760
|
769
|
1920 |
So you will get a regular
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1921 |
expression which can match b
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1922 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1923 |
419
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1924 |
00:21:25,760 --> 00:21:29,464
|
769
|
1925 |
and c, if r could match abc.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1926 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1927 |
420
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1928 |
00:21:29,464 --> 00:21:31,430
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1929 |
So after the first derivative,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1930 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1931 |
421
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1932 |
00:21:31,430 --> 00:21:33,620
|
769
|
1933 |
you will get a regular expression
|
|
1934 |
which can match b and
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1935 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1936 |
422
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1937 |
00:21:33,620 --> 00:21:37,070
|
769
|
1938 |
c. If you take the
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1939 |
second derivative,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1940 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1941 |
423
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1942 |
00:21:37,070 --> 00:21:41,225
|
769
|
1943 |
you will get a regular expression
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1944 |
which can match c alone.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1945 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1946 |
424
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1947 |
00:21:41,225 --> 00:21:44,180
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1948 |
And if you take the
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1949 |
final derivative,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1950 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1951 |
425
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1952 |
00:21:44,180 --> 00:21:46,070
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1953 |
then you will get
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1954 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1955 |
426
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1956 |
00:21:46,070 --> 00:21:48,260
|
769
|
1957 |
a regular expression which hopefully
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1958 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1959 |
427
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1960 |
00:21:48,260 --> 00:21:49,715
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1961 |
can match the empty string.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1962 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1963 |
428
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1964 |
00:21:49,715 --> 00:21:53,780
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1965 |
If it does, then this
|
769
|
1966 |
r can match the abc.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1967 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1968 |
429
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1969 |
00:21:53,780 --> 00:21:55,655
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1970 |
And if it doesn't, then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1971 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1972 |
430
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1973 |
00:21:55,655 --> 00:21:58,680
|
769
|
1974 |
abc couldn't be
|
|
1975 |
matched by this r.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1976 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1977 |
431
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1978 |
00:21:58,900 --> 00:22:02,990
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1979 |
Okay, let's have a look
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1980 |
how this pans out in code.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1981 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1982 |
432
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1983 |
00:22:02,990 --> 00:22:06,050
|
769
|
1984 |
Here's the file re1.sc.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1985 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1986 |
433
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1987 |
00:22:06,050 --> 00:22:07,940
|
769
|
1988 |
It's also uploaded on KEATS,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1989 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1990 |
434
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1991 |
00:22:07,940 --> 00:22:10,625
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1992 |
so you can see exactly
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1993 |
what I'm doing.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1994 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1995 |
435
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1996 |
00:22:10,625 --> 00:22:13,970
|
769
|
1997 |
And actually you already saw
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1998 |
that file because I showed you
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1999 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2000 |
436
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2001 |
00:22:13,970 --> 00:22:15,710
|
769
|
2002 |
how my regular expressions are
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2003 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2004 |
437
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2005 |
00:22:15,710 --> 00:22:17,960
|
769
|
2006 |
defined, with the
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2007 |
abstract classes here.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2008 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2009 |
438
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2010 |
00:22:17,960 --> 00:22:21,155
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2011 |
And here, the six cases
|
769
|
2012 |
for 0, 1, character,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2013 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2014 |
439
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2015 |
00:22:21,155 --> 00:22:23,540
|
769
|
2016 |
alternative,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2017 |
sequence and star.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2018 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2019 |
440
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2020 |
00:22:23,540 --> 00:22:26,705
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2021 |
Ok. So the first
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2022 |
function nullable,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2023 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2024 |
441
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2025 |
00:22:26,705 --> 00:22:28,760
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2026 |
the simple one, takes
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2027 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2028 |
442
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2029 |
00:22:28,760 --> 00:22:32,120
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2030 |
a regular expression as
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2031 |
argument and returns a boolean.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2032 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2033 |
443
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2034 |
00:22:32,120 --> 00:22:34,280
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2035 |
And then with this
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2036 |
pattern matching,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2037 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2038 |
444
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2039 |
00:22:34,280 --> 00:22:37,040
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2040 |
we just go through
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2041 |
all these six cases
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2042 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2043 |
445
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2044 |
00:22:37,040 --> 00:22:38,900
|
769
|
2045 |
0 is defined as false.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2046 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2047 |
446
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2048 |
00:22:38,900 --> 00:22:43,234
|
769
|
2049 |
One is defined as true.
|
|
2050 |
Character, for any character,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2051 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2052 |
447
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2053 |
00:22:43,234 --> 00:22:45,455
|
769
|
2054 |
this nullable will return false.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2055 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2056 |
448
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2057 |
00:22:45,455 --> 00:22:47,540
|
769
|
2058 |
The alternative is defined here,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2059 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2060 |
449
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2061 |
00:22:47,540 --> 00:22:50,000
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2062 |
so that's the or in Scala.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2063 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2064 |
450
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2065 |
00:22:50,000 --> 00:22:52,700
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2066 |
And for the sequence,
|
769
|
2067 |
that's the and.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2068 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2069 |
451
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2070 |
00:22:52,700 --> 00:22:56,180
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2071 |
And this star, no matter
|
769
|
2072 |
what the regular expression is,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2073 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2074 |
452
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2075 |
00:22:56,180 --> 00:22:59,540
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2076 |
it will always match the
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2077 |
empty string, so true.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2078 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2079 |
453
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2080 |
00:22:59,540 --> 00:23:02,225
|
769
|
2081 |
So nullable is very easy.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2082 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2083 |
454
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2084 |
00:23:02,225 --> 00:23:07,430
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2085 |
The derivative is also not
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2086 |
so much more complicated.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2087 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2088 |
455
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2089 |
00:23:07,430 --> 00:23:08,974
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2090 |
It takes two arguments,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2091 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2092 |
456
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2093 |
00:23:08,974 --> 00:23:11,810
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2094 |
a character and the
|
769
|
2095 |
regular expression,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2096 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2097 |
457
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2098 |
00:23:11,810 --> 00:23:14,405
|
769
|
2099 |
and returns a regular expression.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2100 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2101 |
458
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2102 |
00:23:14,405 --> 00:23:16,340
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2103 |
So now we just have to analyze
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2104 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2105 |
459
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2106 |
00:23:16,340 --> 00:23:18,890
|
769
|
2107 |
what's that regular
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2108 |
expression looks like.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2109 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2110 |
460
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2111 |
00:23:18,890 --> 00:23:23,870
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2112 |
If it's 0, we return
|
769
|
2113 |
0; if it's 1 we return 0.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2114 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2115 |
461
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2116 |
00:23:23,870 --> 00:23:26,990
|
769
|
2117 |
If the character... If the
|
|
2118 |
regular expressions character
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2119 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2120 |
462
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2121 |
00:23:26,990 --> 00:23:30,260
|
769
|
2122 |
d, we test whether it's
|
|
2123 |
equal to this character
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2124 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2125 |
463
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2126 |
00:23:30,260 --> 00:23:32,225
|
769
|
2127 |
we want to take the
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2128 |
derivative off.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2129 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2130 |
464
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2131 |
00:23:32,225 --> 00:23:36,185
|
769
|
2132 |
If yes, return 1, otherwise 0.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2133 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2134 |
465
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2135 |
00:23:36,185 --> 00:23:38,600
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2136 |
The alternative which has pushed
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2137 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2138 |
466
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2139 |
00:23:38,600 --> 00:23:39,860
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2140 |
the derivative under
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2141 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2142 |
467
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2143 |
00:23:39,860 --> 00:23:42,710
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2144 |
this alternative,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2145 |
that's the easy one.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2146 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2147 |
468
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2148 |
00:23:42,710 --> 00:23:44,690
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2149 |
Here's the sequence case where we
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2150 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2151 |
469
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2152 |
00:23:44,690 --> 00:23:47,015
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2153 |
first have to test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2154 |
if it's nullable,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2155 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2156 |
470
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2157 |
00:23:47,015 --> 00:23:49,040
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2158 |
If it's not the have to push
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2159 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2160 |
471
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2161 |
00:23:49,040 --> 00:23:52,160
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2162 |
the derivative over
|
769
|
2163 |
the first, the r1.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2164 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2165 |
472
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2166 |
00:23:52,160 --> 00:23:56,135
|
769
|
2167 |
And otherwise if it is nullable,
|
|
2168 |
we have two cases.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2169 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2170 |
473
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2171 |
00:23:56,135 --> 00:24:00,605
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2172 |
Either you have to push
|
769
|
2173 |
it over the r1 or r2.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2174 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2175 |
474
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2176 |
00:24:00,605 --> 00:24:03,860
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2177 |
And a star case, this one.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2178 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2179 |
475
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2180 |
00:24:03,860 --> 00:24:07,160
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2181 |
We just build the sequence
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2182 |
of the derivative of
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2183 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2184 |
476
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2185 |
00:24:07,160 --> 00:24:11,600
|
769
|
2186 |
r1 and append the
|
|
2187 |
r1 as a sequence,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2188 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2189 |
477
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2190 |
00:24:11,600 --> 00:24:14,195
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2191 |
put the star at the end.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2192 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2193 |
478
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2194 |
00:24:14,195 --> 00:24:19,430
|
769
|
2195 |
Okay, so here's the
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2196 |
function for strings.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2197 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2198 |
479
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2199 |
00:24:19,430 --> 00:24:21,740
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2200 |
So a list of characters.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2201 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2202 |
480
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2203 |
00:24:21,740 --> 00:24:23,870
|
769
|
2204 |
This function takes an s,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2205 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2206 |
481
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2207 |
00:24:23,870 --> 00:24:26,480
|
769
|
2208 |
a list of characters as argument
|
|
2209 |
and a regular expression
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2210 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2211 |
482
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2212 |
00:24:26,480 --> 00:24:29,360
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2213 |
as argument and returns
|
769
|
2214 |
a regular expression.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2215 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2216 |
483
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2217 |
00:24:29,360 --> 00:24:31,460
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2218 |
And we just have to
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2219 |
pattern match what
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2220 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2221 |
484
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2222 |
00:24:31,460 --> 00:24:34,055
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2223 |
that string looks like
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2224 |
or this list looks like.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2225 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2226 |
485
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2227 |
00:24:34,055 --> 00:24:35,360
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2228 |
If it's the empty list,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2229 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2230 |
486
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2231 |
00:24:35,360 --> 00:24:38,030
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2232 |
it just immediately
|
769
|
2233 |
return the r. If
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2234 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2235 |
487
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2236 |
00:24:38,030 --> 00:24:42,020
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2237 |
it's something of the
|
769
|
2238 |
form c followed by s,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2239 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2240 |
488
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2241 |
00:24:42,020 --> 00:24:45,050
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2242 |
then we build first the
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2243 |
derivative according
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2244 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2245 |
489
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2246 |
00:24:45,050 --> 00:24:48,345
|
769
|
2247 |
to c. And then
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2248 |
the result of that,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2249 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2250 |
490
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2251 |
00:24:48,345 --> 00:24:50,090
|
769
|
2252 |
we recursively call
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2253 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2254 |
491
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2255 |
00:24:50,090 --> 00:24:53,675
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2256 |
the derivative
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2257 |
according to s. Okay?
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2258 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2259 |
492
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2260 |
00:24:53,675 --> 00:24:56,060
|
769
|
2261 |
And now the main matcher,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2262 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2263 |
493
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2264 |
00:24:56,060 --> 00:24:59,360
|
769
|
2265 |
it takes a regular
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2266 |
expression and takes
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2267 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2268 |
494
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2269 |
00:24:59,360 --> 00:25:02,870
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2270 |
a string and returns a
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2271 |
boolean, true or false.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2272 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2273 |
495
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2274 |
00:25:02,870 --> 00:25:05,705
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2275 |
And it first builds
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2276 |
the derivative.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2277 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2278 |
496
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2279 |
00:25:05,705 --> 00:25:07,430
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2280 |
The only thing I have to do here
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2281 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2282 |
497
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2283 |
00:25:07,430 --> 00:25:09,410
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2284 |
because I'm implementing
|
769
|
2285 |
it in Scala,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2286 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2287 |
498
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2288 |
00:25:09,410 --> 00:25:15,064
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2289 |
I have to coerce between strings
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2290 |
and lists of characters.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2291 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2292 |
499
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2293 |
00:25:15,064 --> 00:25:16,580
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2294 |
So he, I take first
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2295 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2296 |
500
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2297 |
00:25:16,580 --> 00:25:20,810
|
769
|
2298 |
the toList of the s. That
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2299 |
gives me a list of characters.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2300 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2301 |
501
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2302 |
00:25:20,810 --> 00:25:23,135
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2303 |
Then I build this derivative
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2304 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2305 |
502
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2306 |
00:25:23,135 --> 00:25:26,045
|
769
|
2307 |
with the s, because I'm
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2308 |
looking at strings.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2309 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2310 |
503
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2311 |
00:25:26,045 --> 00:25:28,160
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2312 |
And then at the end,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2313 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2314 |
504
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2315 |
00:25:28,160 --> 00:25:33,050
|
769
|
2316 |
built the nullable of
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2317 |
the final derivative.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2318 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2319 |
505
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2320 |
00:25:33,050 --> 00:25:37,310
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2321 |
The beauty of all this
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2322 |
is that in Scala,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2323 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2324 |
506
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2325 |
00:25:37,310 --> 00:25:40,085
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2326 |
these definition which
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2327 |
I had on the slides
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2328 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2329 |
507
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2330 |
00:25:40,085 --> 00:25:43,835
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2331 |
go almost one-to-one into code.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2332 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2333 |
508
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2334 |
00:25:43,835 --> 00:25:45,605
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2335 |
And that's of course,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2336 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2337 |
509
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2338 |
00:25:45,605 --> 00:25:47,480
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2339 |
makes it very easy
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2340 |
to implement in
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2341 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2342 |
510
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2343 |
00:25:47,480 --> 00:25:49,730
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2344 |
a functional language like Scala.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2345 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2346 |
511
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2347 |
00:25:49,730 --> 00:25:52,865
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2348 |
We can also now try
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2349 |
out some examples.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2350 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2351 |
512
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2352 |
00:25:52,865 --> 00:25:56,960
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2353 |
This was the example
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2354 |
I had on the slide.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2355 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2356 |
513
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2357 |
00:25:56,960 --> 00:25:58,370
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2358 |
And we could now calculate
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2359 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2360 |
514
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2361 |
00:25:58,370 --> 00:26:00,305
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2362 |
what's the derivative
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2363 |
according to a,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2364 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2365 |
515
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2366 |
00:26:00,305 --> 00:26:02,720
|
769
|
2367 |
b, and c of this
|
|
2368 |
regular expression.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2369 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2370 |
516
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2371 |
00:26:02,720 --> 00:26:07,040
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2372 |
And I hope you didn't
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2373 |
make any mistake.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2374 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2375 |
517
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2376 |
00:26:07,040 --> 00:26:09,260
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2377 |
Now of course we want
|
769
|
2378 |
to see whether we
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2379 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2380 |
518
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2381 |
00:26:09,260 --> 00:26:11,390
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2382 |
do any better with
|
769
|
2383 |
this algorithm...
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2384 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2385 |
519
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2386 |
00:26:11,390 --> 00:26:13,715
|
769
|
2387 |
than Python and Ruby.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2388 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2389 |
520
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2390 |
00:26:13,715 --> 00:26:16,070
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2391 |
And let's first have a
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2392 |
look at this example.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2393 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2394 |
521
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2395 |
00:26:16,070 --> 00:26:18,079
|
769
|
2396 |
So this regular expression.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2397 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2398 |
522
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2399 |
00:26:18,079 --> 00:26:19,880
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2400 |
The problem is that in
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2401 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2402 |
523
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2403 |
00:26:19,880 --> 00:26:22,070
|
769
|
2404 |
our regular expression
|
|
2405 |
matcher so far we have
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2406 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2407 |
524
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2408 |
00:26:22,070 --> 00:26:24,530
|
769
|
2409 |
the sequence rregular
|
|
2410 |
expression, but we
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2411 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2412 |
525
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2413 |
00:26:24,530 --> 00:26:27,200
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2414 |
don't have this optional
|
769
|
2415 |
regular expression.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2416 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2417 |
526
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2418 |
00:26:27,200 --> 00:26:30,800
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2419 |
And we don't have this n
|
769
|
2420 |
times regular expression,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2421 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2422 |
527
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2423 |
00:26:30,800 --> 00:26:36,605
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2424 |
but we can quickly implement
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2425 |
that in our implementation.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2426 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2427 |
528
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2428 |
00:26:36,605 --> 00:26:40,549
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2429 |
So if you want to build the
|
769
|
2430 |
optional regular expression,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2431 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2432 |
529
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2433 |
00:26:40,549 --> 00:26:41,870
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2434 |
which is defined here,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2435 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2436 |
530
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2437 |
00:26:41,870 --> 00:26:44,570
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2438 |
a little function which
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2439 |
takes a reg expression and
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2440 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2441 |
531
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2442 |
00:26:44,570 --> 00:26:47,360
|
769
|
2443 |
returns the alternative of r and 1.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2444 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2445 |
532
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2446 |
00:26:47,360 --> 00:26:49,624
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2447 |
So it essentially
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2448 |
takes the definition
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2449 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2450 |
533
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2451 |
00:26:49,624 --> 00:26:53,240
|
769
|
2452 |
of optional r and
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2453 |
replaces it by that.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2454 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2455 |
534
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2456 |
00:26:53,240 --> 00:26:56,150
|
769
|
2457 |
The n-times what we
|
|
2458 |
essentially do there is
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2459 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2460 |
535
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2461 |
00:26:56,150 --> 00:27:01,535
|
769
|
2462 |
we built n copies of this r. Ok?
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2463 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2464 |
536
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2465 |
00:27:01,535 --> 00:27:04,745
|
769
|
2466 |
So if this n-times was 0,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2467 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2468 |
537
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2469 |
00:27:04,745 --> 00:27:06,245
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2470 |
we just return one.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2471 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2472 |
538
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2473 |
00:27:06,245 --> 00:27:11,570
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2474 |
If it's one, then we return
|
769
|
2475 |
just the regular expression.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2476 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2477 |
539
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2478 |
00:27:11,570 --> 00:27:15,575
|
769
|
2479 |
And if it's something
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2480 |
bigger than one,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2481 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2482 |
540
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2483 |
00:27:15,575 --> 00:27:18,560
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2484 |
then we just built the
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2485 |
sequence of one of
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2486 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2487 |
541
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2488 |
00:27:18,560 --> 00:27:20,270
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2489 |
these copies and call
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2490 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2491 |
542
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2492 |
00:27:20,270 --> 00:27:22,925
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2493 |
this function again
|
769
|
2494 |
with n - 1.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2495 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2496 |
543
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2497 |
00:27:22,925 --> 00:27:26,330
|
769
|
2498 |
So we just build now n-copies of that.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2499 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2500 |
544
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2501 |
00:27:26,330 --> 00:27:30,710
|
769
|
2502 |
Okay, so we can look
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2503 |
at our first example.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2504 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2505 |
545
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2506 |
00:27:30,710 --> 00:27:32,629
|
769
|
2507 |
This is the regular expression,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2508 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2509 |
546
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2510 |
00:27:32,629 --> 00:27:36,035
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2511 |
and I call that here
|
769
|
2512 |
evil regular expression1.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2513 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2514 |
547
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2515 |
00:27:36,035 --> 00:27:37,670
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2516 |
It doesn't look as beautiful
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2517 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2518 |
548
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2519 |
00:27:37,670 --> 00:27:39,140
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2520 |
as what we write down on paper.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2521 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2522 |
549
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2523 |
00:27:39,140 --> 00:27:41,240
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2524 |
We will actually look
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2525 |
at this later on
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2526 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2527 |
550
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2528 |
00:27:41,240 --> 00:27:43,640
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2529 |
if this can be improved.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2530 |
But here it is.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2531 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2532 |
551
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2533 |
00:27:43,640 --> 00:27:45,724
|
769
|
2534 |
Here's the regular expression,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2535 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2536 |
552
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2537 |
00:27:45,724 --> 00:27:49,520
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2538 |
and here's a little function
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2539 |
which measures the time.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2540 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2541 |
553
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2542 |
00:27:49,520 --> 00:27:53,180
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2543 |
And we can now start testing
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2544 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2545 |
554
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2546 |
00:27:53,180 --> 00:27:57,845
|
769
|
2547 |
this regular expression with
|
|
2548 |
strings just containing a's.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2549 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2550 |
555
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2551 |
00:27:57,845 --> 00:28:00,020
|
769
|
2552 |
And we are first a bit cautious,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2553 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2554 |
556
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2555 |
00:28:00,020 --> 00:28:04,985
|
769
|
2556 |
we test it between 0 and 20,
|
|
2557 |
and we count by two.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2558 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2559 |
557
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2560 |
00:28:04,985 --> 00:28:08,330
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2561 |
And I actually will not
|
769
|
2562 |
start that within Scala,
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2563 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2564 |
558
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2565 |
00:28:08,330 --> 00:28:12,965
|
769
|
2566 |
but actually use Ammonite.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2567 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2568 |
559
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2569 |
00:28:12,965 --> 00:28:15,305
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2570 |
And that's out.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2571 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2572 |
560
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2573 |
00:28:15,305 --> 00:28:17,269
|
769
|
2574 |
And that calculates
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2575 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2576 |
561
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2577 |
00:28:17,269 --> 00:28:20,675
|
769
|
2578 |
for 18 a's. It's pretty fast.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2579 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2580 |
562
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2581 |
00:28:20,675 --> 00:28:24,815
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2582 |
But for 20 it already
|
769
|
2583 |
needs 2 seconds.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2584 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2585 |
563
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2586 |
00:28:24,815 --> 00:28:28,265
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2587 |
And you can see
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2588 |
actually this jump from
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2589 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2590 |
564
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2591 |
00:28:28,265 --> 00:28:32,825
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2592 |
18 to 20 in the runtime
|
769
|
2593 |
is pretty bad too.
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2594 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2595 |
565
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2596 |
00:28:32,825 --> 00:28:37,460
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2597 |
And if we actually measure
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2598 |
it more accurately,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2599 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2600 |
566
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2601 |
00:28:37,460 --> 00:28:39,770
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2602 |
then we get this picture.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2603 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2604 |
567
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2605 |
00:28:39,770 --> 00:28:41,255
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2606 |
And what turns out,
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2607 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2608 |
568
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2609 |
00:28:41,255 --> 00:28:45,830
|
769
|
2610 |
we are actually worse than Python
|
766
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2611 |
and Ruby in this example.
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2612 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2613 |
569
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2614 |
00:28:45,830 --> 00:28:49,230
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2615 |
So I guess that's a fail.
|