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