videos/02-algo2.srt
author Christian Urban <christian.urban@kcl.ac.uk>
Fri, 03 Dec 2021 22:07:11 +0000
changeset 857 2b11eb06af76
parent 773 260e330f7466
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     1
1
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     2
00:00:06,020 --> 00:00:09,945
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
     3
Welcome back. After
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     4
this disappointment
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     5
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     6
2
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     7
00:00:09,945 --> 00:00:14,115
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
     8
and case of over-promising
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
     9
and under-achieving,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    10
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    11
3
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    12
00:00:14,115 --> 00:00:17,295
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
    13
let's have a look whether
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    14
we can recover from that.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    15
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    16
4
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    17
00:00:17,295 --> 00:00:20,535
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    18
So here's one problem.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    19
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    20
5
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    21
00:00:20,535 --> 00:00:23,790
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
    22
When we looked at this 
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
    23
n-times regular expression, we
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    24
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    25
6
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    26
00:00:23,790 --> 00:00:27,330
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
    27
were not able to represent
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    28
that directly.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    29
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    30
7
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    31
00:00:27,330 --> 00:00:31,275
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
    32
We had to represent it as a
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
    33
sequence regular expression.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    34
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    35
8
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    36
00:00:31,275 --> 00:00:32,850
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    37
So we expanded it.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    38
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    39
9
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    40
00:00:32,850 --> 00:00:36,510
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
    41
So times-one would be just a,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    42
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    43
10
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    44
00:00:36,510 --> 00:00:40,595
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
    45
times-two would
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
    46
be a o a, and so on.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    47
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    48
11
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    49
00:00:40,595 --> 00:00:43,535
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    50
And so you can see if
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    51
you go already to 13,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    52
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    53
12
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    54
00:00:43,535 --> 00:00:47,960
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
    55
n equals 13, the regular
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    56
expression becomes quite large.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    57
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    58
13
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    59
00:00:47,960 --> 00:00:52,865
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    60
And now the functions
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
    61
nullable and also derivative,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    62
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    63
14
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    64
00:00:52,865 --> 00:00:56,360
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
    65
they need to traverse
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
    66
this regular expression.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    67
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    68
15
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    69
00:00:56,360 --> 00:00:59,060
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
    70
Remember this tree, sometimes,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    71
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    72
16
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    73
00:00:59,060 --> 00:01:01,820
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    74
they have to traverse
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    75
that even several times.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    76
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    77
17
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    78
00:01:01,820 --> 00:01:04,535
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    79
So that will slow
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    80
down the algorithm.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    81
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    82
18
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    83
00:01:04,535 --> 00:01:08,150
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    84
And in particular, because
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
    85
our first regular expression was
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    86
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    87
19
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    88
00:01:08,150 --> 00:01:11,840
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
    89
actually not just a, but
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
    90
a + 1. So we had
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    91
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    92
20
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    93
00:01:11,840 --> 00:01:14,330
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
    94
in the case of 13,
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
    95
we had a + 1, a + 1,...
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    96
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    97
21
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    98
00:01:14,330 --> 00:01:17,330
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
    99
a + 1... 13 times.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   100
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   101
22
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   102
00:01:17,330 --> 00:01:20,150
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   103
And this regular
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   104
expression just grows
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   105
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   106
23
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   107
00:01:20,150 --> 00:01:25,475
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   108
with the number n. Just to
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   109
show you this also in code,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   110
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   111
24
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   112
00:01:25,475 --> 00:01:28,115
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   113
I'm in the file re1.sc,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   114
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   115
25
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   116
00:01:28,115 --> 00:01:30,920
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   117
and in the end I have a size function.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   118
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   119
26
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   120
00:01:30,920 --> 00:01:33,140
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   121
The size function takes
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   122
a regular expression as
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   123
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   124
27
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   125
00:01:33,140 --> 00:01:36,215
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   126
argument and produces an integer.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   127
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   128
28
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   129
00:01:36,215 --> 00:01:39,980
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   130
And essentially it takes
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   131
this regular expression, seen as
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   132
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   133
29
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   134
00:01:39,980 --> 00:01:44,045
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   135
a tree and counts how many
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   136
nodes there are in this tree.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   137
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   138
30
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   139
00:01:44,045 --> 00:01:49,490
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   140
And so if I take this EVIL1
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   141
regular expression, this one,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   142
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   143
31
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   144
00:01:49,490 --> 00:01:52,160
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   145
and increase now this n. So you
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   146
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   147
32
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   148
00:01:52,160 --> 00:01:54,680
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   149
can already see
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   150
for n = 1,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   151
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   152
33
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   153
00:01:54,680 --> 00:01:56,540
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   154
the size of this
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   155
record expression is 5
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   156
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   157
34
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   158
00:01:56,540 --> 00:01:59,615
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   159
and you see it
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   160
slowly increases.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   161
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   162
35
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   163
00:01:59,615 --> 00:02:02,150
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   164
And this 20, i.e. n = 20,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   165
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   166
36
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   167
00:02:02,150 --> 00:02:07,100
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   168
the size of this regular
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   169
expression is now already 119.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   170
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   171
37
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   172
00:02:07,100 --> 00:02:10,145
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   173
The interesting
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   174
line is this one.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   175
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   176
38
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   177
00:02:10,145 --> 00:02:13,295
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   178
Remember, when we
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   179
built the derivative,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   180
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   181
39
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   182
00:02:13,295 --> 00:02:17,150
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   183
very often parts of a regular
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   184
expression gets copied.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   185
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   186
40
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   187
00:02:17,150 --> 00:02:19,280
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   188
So if you have like EVIL1
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   189
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   190
41
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   191
00:02:19,280 --> 00:02:22,325
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   192
of 20, and you have 119 nodes,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   193
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   194
42
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   195
00:02:22,325 --> 00:02:25,475
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   196
now this will be often copied.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   197
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   198
43
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   199
00:02:25,475 --> 00:02:31,475
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   200
And we want to see what's the
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   201
resulting tree look like, i.e.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   202
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   203
44
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   204
00:02:31,475 --> 00:02:32,780
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   205
how many nodes does it have.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   206
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   207
45
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   208
00:02:32,780 --> 00:02:34,985
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   209
So I take here EVIL1 of 20
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   210
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   211
46
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   212
00:02:34,985 --> 00:02:38,405
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   213
and the derivative
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   214
according to 20 a's.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   215
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   216
47
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   217
00:02:38,405 --> 00:02:41,820
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   218
And just have a look
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   219
what the size is.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   220
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   221
48
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   222
00:02:43,210 --> 00:02:45,680
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   223
Okay, that takes a while.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   224
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   225
49
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   226
00:02:45,680 --> 00:02:48,410
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   227
You see now this recular expression,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   228
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   229
50
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   230
00:02:48,410 --> 00:02:52,280
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   231
the derivative has already
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   232
8 million plus nodes.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   233
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   234
51
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   235
00:02:52,280 --> 00:02:55,400
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   236
And now nullable and
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   237
derivative have to
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   238
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   239
52
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   240
00:02:55,400 --> 00:02:58,430
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   241
traverse these trees with
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   242
8 million plus nodes.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   243
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   244
53
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   245
00:02:58,430 --> 00:03:01,400
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   246
So it's no wonder
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   247
that this is slow.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   248
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   249
54
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   250
00:03:01,400 --> 00:03:03,860
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   251
The first thing we
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   252
can try to mitigate
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   253
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   254
55
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   255
00:03:03,860 --> 00:03:06,350
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   256
this explosion problem is to
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   257
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   258
56
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   259
00:03:06,350 --> 00:03:09,050
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   260
have an explicit 
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   261
n-times regular expression.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   262
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   263
57
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   264
00:03:09,050 --> 00:03:11,600
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   265
So instead of expanding
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   266
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   267
58
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   268
00:03:11,600 --> 00:03:13,415
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   269
it to the sequence
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   270
regular expression,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   271
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   272
59
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   273
00:03:13,415 --> 00:03:17,510
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   274
let's just have a single
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   275
regular expression n-times,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   276
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   277
60
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   278
00:03:17,510 --> 00:03:20,540
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   279
which takes an expression and
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   280
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   281
61
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   282
00:03:20,540 --> 00:03:24,470
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   283
a number, and keeps that
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   284
regular expression small.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   285
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   286
62
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   287
00:03:24,470 --> 00:03:27,095
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   288
I'm here in the file re2.sc,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   289
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   290
63
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   291
00:03:27,095 --> 00:03:29,090
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   292
which is also on KEATS.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   293
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   294
64
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   295
00:03:29,090 --> 00:03:32,570
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   296
And the only change I made
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   297
is I added explicitly
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   298
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   299
65
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   300
00:03:32,570 --> 00:03:33,860
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   301
a regular expression for
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   302
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   303
66
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   304
00:03:33,860 --> 00:03:36,770
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   305
n-times. The optional
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   306
regular expression
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   307
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   308
67
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   309
00:03:36,770 --> 00:03:39,920
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   310
we leave out at the
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   311
moment because this a?
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   312
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   313
68
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   314
00:03:39,920 --> 00:03:41,975
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   315
is represented as
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   316
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   317
69
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   318
00:03:41,975 --> 00:03:44,645
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   319
a + 1 and doesn't
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   320
expand too much.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   321
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   322
70
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   323
00:03:44,645 --> 00:03:47,375
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   324
The real culprit
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   325
is this n-times.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   326
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   327
71
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   328
00:03:47,375 --> 00:03:51,095
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   329
And instead of expanding
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   330
it n-times, we just
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   331
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   332
72
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   333
00:03:51,095 --> 00:03:54,275
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   334
take here a regular expression
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   335
and a natural number,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   336
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   337
73
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   338
00:03:54,275 --> 00:03:56,960
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   339
which says how many times
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   340
it should be repeated.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   341
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   342
74
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   343
00:03:56,960 --> 00:03:59,165
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   344
And in this week we
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   345
can keep it small.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   346
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   347
75
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   348
00:03:59,165 --> 00:04:01,370
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   349
But by adding that
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   350
regular expression,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   351
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   352
76
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   353
00:04:01,370 --> 00:04:05,150
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   354
we now have to think about
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   355
cases for nullable and
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   356
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   357
77
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   358
00:04:05,150 --> 00:04:07,340
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   359
derivative. So that we have
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   360
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   361
78
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   362
00:04:07,340 --> 00:04:10,205
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   363
to calculate next
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   364
what they look like.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   365
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   366
79
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   367
00:04:10,205 --> 00:04:14,060
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   368
We can actually
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   369
calculate what the rule
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   370
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   371
80
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   372
00:04:14,060 --> 00:04:17,525
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   373
for nullable should be from
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   374
how we defined it earlier.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   375
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   376
81
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   377
00:04:17,525 --> 00:04:19,580
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   378
Remember, if you have
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   379
a regular expression,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   380
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   381
82
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   382
00:04:19,580 --> 00:04:21,980
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   383
r and we take it
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   384
n-times of this r,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   385
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   386
83
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   387
00:04:21,980 --> 00:04:25,220
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   388
then in case if n = 0,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   389
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   390
84
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   391
00:04:25,220 --> 00:04:28,130
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   392
we definded that as the
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   393
1 regular expression.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   394
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   395
85
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   396
00:04:28,130 --> 00:04:30,380
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   397
If n = 1,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   398
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   399
86
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   400
00:04:30,380 --> 00:04:32,495
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   401
it will be just a
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   402
single copy of r.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   403
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   404
87
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   405
00:04:32,495 --> 00:04:33,725
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   406
If n = 2,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   407
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   408
88
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   409
00:04:33,725 --> 00:04:35,270
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   410
it will be two copies in sequence.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   411
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   412
89
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   413
00:04:35,270 --> 00:04:39,260
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   414
If three, we have
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   415
three copies and so on.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   416
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   417
90
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   418
00:04:39,260 --> 00:04:41,390
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   419
Now we have to
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   420
somehow characterize
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   421
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   422
91
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   423
00:04:41,390 --> 00:04:44,285
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   424
when are these cases all nullable.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   425
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   426
92
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   427
00:04:44,285 --> 00:04:47,810
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   428
Well, if n equals 0,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   429
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   430
93
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   431
00:04:47,810 --> 00:04:49,850
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   432
then this will be defined as 1.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   433
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   434
94
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   435
00:04:49,850 --> 00:04:52,100
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   436
So 1 can match
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   437
the empty string.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   438
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   439
95
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   440
00:04:52,100 --> 00:04:54,785
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   441
So that should be
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   442
definitely true.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   443
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   444
96
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   445
00:04:54,785 --> 00:04:57,725
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   446
Okay, if n = 1,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   447
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   448
97
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   449
00:04:57,725 --> 00:05:00,470
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   450
when can this regular expression
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   451
match the empty string?
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   452
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   453
98
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   454
00:05:00,470 --> 00:05:02,000
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   455
So when should this be nullable?
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   456
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   457
99
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   458
00:05:02,000 --> 00:05:07,535
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   459
Well, if nullable of r holds,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   460
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   461
100
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   462
00:05:07,535 --> 00:05:09,860
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   463
If it can match
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   464
the empty string,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   465
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   466
101
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   467
00:05:09,860 --> 00:05:12,110
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   468
then we can match
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   469
the empty string.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   470
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   471
102
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   472
00:05:12,110 --> 00:05:14,870
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   473
When can this regular expression
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   474
match the empty string?
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   475
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   476
103
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   477
00:05:14,870 --> 00:05:16,265
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   478
So these are now two copies of r.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   479
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   480
104
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   481
00:05:16,265 --> 00:05:20,690
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   482
Well, both copies need
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   483
to match the empty string.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   484
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   485
105
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   486
00:05:20,690 --> 00:05:22,820
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   487
So again, we have to ask
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   488
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   489
106
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   490
00:05:22,820 --> 00:05:25,774
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   491
both of them need to be nullable.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   492
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   493
107
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   494
00:05:25,774 --> 00:05:28,520
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   495
Similarly, in the third case,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   496
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   497
108
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   498
00:05:28,520 --> 00:05:30,710
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   499
all three copies need to be
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   500
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   501
109
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   502
00:05:30,710 --> 00:05:33,230
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   503
able to match the empty
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   504
string. When is that the case?
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   505
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   506
110
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   507
00:05:33,230 --> 00:05:38,360
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   508
Well, if nullable of
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   509
r holds and so on.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   510
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   511
111
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   512
00:05:38,360 --> 00:05:48,754
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   513
So we can actually define that
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   514
if n = 0, then true,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   515
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   516
112
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   517
00:05:48,754 --> 00:05:56,045
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   518
else we have to ask whether
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   519
nullable of r holds.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   520
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   521
113
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   522
00:05:56,045 --> 00:05:58,550
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   523
So that will be the clause we
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   524
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   525
114
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   526
00:05:58,550 --> 00:06:01,625
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   527
have to implement for
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   528
n-times and nullable.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   529
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   530
115
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   531
00:06:01,625 --> 00:06:04,280
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   532
Deriving the definition for
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   533
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   534
116
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   535
00:06:04,280 --> 00:06:06,920
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   536
the derivative of the n-times
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   537
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   538
117
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   539
00:06:06,920 --> 00:06:10,175
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   540
regular expression
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   541
is not that easy.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   542
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   543
118
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   544
00:06:10,175 --> 00:06:12,755
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   545
We have to look again
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   546
how it was defined
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   547
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   548
119
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   549
00:06:12,755 --> 00:06:16,010
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   550
earlier and we somehow
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   551
have to spot a pattern.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   552
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   553
120
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   554
00:06:16,010 --> 00:06:18,380
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   555
Otherwise, our
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   556
algorithm will be again
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   557
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   558
121
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   559
00:06:18,380 --> 00:06:20,975
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   560
quite slow if we don't
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   561
spot that pattern.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   562
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   563
122
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   564
00:06:20,975 --> 00:06:22,550
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   565
So let's have a look.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   566
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   567
123
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   568
00:06:22,550 --> 00:06:26,240
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   569
So in the case that
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   570
n is equal to 0,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   571
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   572
124
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   573
00:06:26,240 --> 00:06:29,885
772
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   574
then r n-times was
Christian Urban <christian.urban@kcl.ac.uk>
parents: 769
diff changeset
   575
defined as just 1.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   576
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   577
125
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   578
00:06:29,885 --> 00:06:32,030
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   579
What would be the
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   580
derivative of one?
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   581
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   582
126
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   583
00:06:32,030 --> 00:06:36,140
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   584
So the derivative of c of 1
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   585
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   586
127
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   587
00:06:36,140 --> 00:06:38,990
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   588
would be defined as 0.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   589
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   590
128
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   591
00:06:38,990 --> 00:06:41,465
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   592
Okay, fair enough.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   593
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   594
129
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   595
00:06:41,465 --> 00:06:44,960
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   596
If he have n = 1,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   597
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   598
130
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   599
00:06:44,960 --> 00:06:48,125
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   600
then we just have one copy
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   601
of this regular expression.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   602
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   603
131
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   604
00:06:48,125 --> 00:06:50,120
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   605
So there's not much else we can do.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   606
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   607
132
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   608
00:06:50,120 --> 00:06:53,735
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   609
We would have to calculate
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   610
the derivative of r.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   611
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   612
133
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   613
00:06:53,735 --> 00:06:57,395
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   614
Now in the n = 2 case,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   615
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   616
134
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   617
00:06:57,395 --> 00:07:00,245
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   618
that would mean we
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   619
have two copies of r.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   620
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   621
135
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   622
00:07:00,245 --> 00:07:03,425
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   623
And they would be a sequence.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   624
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   625
136
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   626
00:07:03,425 --> 00:07:07,775
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   627
How would be the derivative c of
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   628
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   629
137
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   630
00:07:07,775 --> 00:07:10,340
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   631
r followed by r be
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   632
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   633
138
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   634
00:07:10,340 --> 00:07:13,265
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   635
defined? Well we would
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   636
look up the definition.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   637
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   638
139
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   639
00:07:13,265 --> 00:07:15,470
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   640
And it would say that's
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   641
the complicated case,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   642
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   643
140
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   644
00:07:15,470 --> 00:07:16,760
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   645
the sequence.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   646
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   647
141
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   648
00:07:16,760 --> 00:07:21,875
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   649
If nullable of r,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   650
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   651
142
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   652
00:07:21,875 --> 00:07:25,250
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   653
then the more complicated case,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   654
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   655
143
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   656
00:07:25,250 --> 00:07:28,225
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   657
else, that's the easy
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   658
case, that would be
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   659
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   660
144
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   661
00:07:28,225 --> 00:07:32,660
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   662
derivative of c of r, followed
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   663
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   664
145
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   665
00:07:32,660 --> 00:07:35,540
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   666
by r. And then I just have to copy
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   667
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   668
146
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   669
00:07:35,540 --> 00:07:40,775
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   670
that derivative of c
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   671
of r followed by r here.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   672
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   673
147
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   674
00:07:40,775 --> 00:07:43,130
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   675
But in this case I have also
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   676
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   677
148
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   678
00:07:43,130 --> 00:07:51,145
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   679
the alternative derivative
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   680
of c of r. And from that,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   681
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   682
149
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   683
00:07:51,145 --> 00:07:55,030
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   684
it looks like we can't
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   685
do much better than
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   686
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   687
150
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   688
00:07:55,030 --> 00:07:58,390
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   689
that, unless we do
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   690
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   691
151
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   692
00:07:58,390 --> 00:08:02,560
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   693
a little bit of magic and the
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   694
magic has to do with this case.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   695
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   696
152
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   697
00:08:02,560 --> 00:08:07,420
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   698
So let me look at this
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   699
case a bit more closely.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   700
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   701
153
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   702
00:08:07,420 --> 00:08:09,819
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   703
Let me go back to slides
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   704
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   705
154
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   706
00:08:09,819 --> 00:08:12,940
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   707
because actually the calculation
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   708
might be a bit hairy.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   709
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   710
155
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   711
00:08:12,940 --> 00:08:16,945
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   712
So remember we are in this
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   713
case where n equals two.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   714
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   715
156
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   716
00:08:16,945 --> 00:08:18,550
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   717
And this was defined as
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   718
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   719
157
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   720
00:08:18,550 --> 00:08:20,680
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   721
this sequence regular
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   722
expression r followed by r.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   723
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   724
158
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   725
00:08:20,680 --> 00:08:23,080
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   726
And the question was,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   727
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   728
159
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   729
00:08:23,080 --> 00:08:26,365
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   730
can we somehow make sense
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   731
out of this derivative
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   732
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   733
160
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   734
00:08:26,365 --> 00:08:30,370
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   735
where we have to build the
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   736
derivative of a sequence.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   737
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   738
161
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   739
00:08:30,370 --> 00:08:33,020
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   740
So if we just unfold the definition,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   741
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   742
162
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   743
00:08:33,020 --> 00:08:36,050
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   744
we would ask if
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   745
the r is nullable,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   746
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   747
163
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   748
00:08:36,050 --> 00:08:39,095
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   749
In this case, we return
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   750
this alternative.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   751
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   752
164
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   753
00:08:39,095 --> 00:08:40,640
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   754
And if it's not nullable,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   755
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   756
165
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   757
00:08:40,640 --> 00:08:44,135
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   758
it is just this
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   759
regular expression.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   760
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   761
166
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   762
00:08:44,135 --> 00:08:49,550
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   763
Now my claim is that
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   764
this whole if condition
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   765
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   766
167
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   767
00:08:49,550 --> 00:08:55,895
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   768
can be replaced by just this
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   769
simple derivative here.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   770
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   771
168
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   772
00:08:55,895 --> 00:08:58,775
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   773
And if that claim is correct,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   774
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   775
169
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   776
00:08:58,775 --> 00:09:01,520
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   777
there would be very nice
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   778
because in contrast to
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   779
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   780
170
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   781
00:09:01,520 --> 00:09:04,130
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   782
this if condition where
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   783
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   784
171
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   785
00:09:04,130 --> 00:09:06,280
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   786
we have to calculate
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   787
like nullable,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   788
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   789
172
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   790
00:09:06,280 --> 00:09:08,330
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   791
decide in which branch we are.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   792
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   793
173
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   794
00:09:08,330 --> 00:09:10,580
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   795
We don't have to
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   796
calculate nullable,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   797
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   798
174
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   799
00:09:10,580 --> 00:09:13,880
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   800
we can just replace
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   801
it by this expression.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   802
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   803
175
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   804
00:09:13,880 --> 00:09:16,670
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   805
So if we can
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   806
substantiate that claim,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   807
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   808
176
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   809
00:09:16,670 --> 00:09:19,860
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   810
that will be definitely
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   811
good our algorithm.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   812
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   813
177
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   814
00:09:20,140 --> 00:09:22,775
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   815
And to substantiate that,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   816
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   817
178
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   818
00:09:22,775 --> 00:09:26,795
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   819
I will focus on this
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   820
record expression here.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   821
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   822
179
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   823
00:09:26,795 --> 00:09:31,100
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   824
And notice that this record
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   825
expression will only be
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   826
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   827
180
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   828
00:09:31,100 --> 00:09:35,780
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   829
called or only be generated
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   830
if r is nullable.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   831
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   832
181
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   833
00:09:35,780 --> 00:09:38,075
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   834
So in any other case,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   835
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   836
182
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   837
00:09:38,075 --> 00:09:40,060
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   838
I will actually not go into 
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   839
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   840
183
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   841
00:09:40,060 --> 00:09:43,850
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   842
that if branch and would
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   843
be in the other one.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   844
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   845
184
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   846
00:09:43,850 --> 00:09:45,260
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   847
So if we are in this if branch,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   848
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   849
185
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   850
00:09:45,260 --> 00:09:47,705
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   851
we definitely know
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   852
that r is nullable.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   853
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   854
186
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   855
00:09:47,705 --> 00:09:52,955
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   856
Okay, so here's
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   857
our regular expression.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   858
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   859
187
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   860
00:09:52,955 --> 00:09:55,940
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   861
And we know it's nullable.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   862
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   863
188
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   864
00:09:55,940 --> 00:09:57,920
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   865
So we have to somehow find
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   866
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   867
189
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   868
00:09:57,920 --> 00:10:00,380
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   869
an equivalent expression that
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   870
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   871
190
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   872
00:10:00,380 --> 00:10:04,100
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   873
is smaller or simpler
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   874
than that one.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   875
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   876
191
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   877
00:10:04,100 --> 00:10:05,945
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   878
Let's see what we can do.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   879
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   880
192
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   881
00:10:05,945 --> 00:10:10,160
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   882
So the first thing
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   883
actually is we're multiplying
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   884
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   885
193
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   886
00:10:10,160 --> 00:10:16,595
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   887
this right hand side of the
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   888
alternative with times 1.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   889
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   890
194
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   891
00:10:16,595 --> 00:10:19,700
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   892
We can do that
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   893
because this does not
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   894
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   895
195
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   896
00:10:19,700 --> 00:10:23,090
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   897
change which strings this
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   898
regular expression can match.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   899
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   900
196
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   901
00:10:23,090 --> 00:10:25,685
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   902
Remember we even had it
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   903
as a simplification rule,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   904
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   905
197
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   906
00:10:25,685 --> 00:10:27,425
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   907
just in this case we
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   908
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   909
198
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   910
00:10:27,425 --> 00:10:29,705
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   911
don't apply it as a
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   912
simplification rule,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   913
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   914
199
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   915
00:10:29,705 --> 00:10:31,310
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   916
actually make this
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   917
regular expression
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   918
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   919
200
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   920
00:10:31,310 --> 00:10:32,720
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   921
a bit more complicated.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   922
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   923
201
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   924
00:10:32,720 --> 00:10:34,910
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   925
But times 1 doesn't make
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   926
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   927
202
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   928
00:10:34,910 --> 00:10:37,820
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   929
a difference because it
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   930
means at the end of a string,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   931
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   932
203
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   933
00:10:37,820 --> 00:10:40,070
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   934
we still want to match
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   935
the empty string.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   936
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   937
204
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   938
00:10:40,070 --> 00:10:42,155
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   939
Okay, so that is possible.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   940
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   941
205
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   942
00:10:42,155 --> 00:10:45,740
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   943
I can do that. Once
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   944
we have done that,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   945
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   946
206
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   947
00:10:45,740 --> 00:10:48,410
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   948
you will notice that this
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   949
factor derivative of
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   950
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   951
207
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   952
00:10:48,410 --> 00:10:51,860
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   953
r are exactly the
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   954
same as that one.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   955
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   956
208
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   957
00:10:51,860 --> 00:10:54,650
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   958
And in between is a plus.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   959
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   960
209
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   961
00:10:54,650 --> 00:10:57,440
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   962
So you probably remember the law
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   963
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   964
210
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   965
00:10:57,440 --> 00:11:00,170
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   966
from school math
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   967
that I can pull out
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   968
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   969
211
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   970
00:11:00,170 --> 00:11:02,735
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   971
this factor derivative of c of r.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   972
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   973
212
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   974
00:11:02,735 --> 00:11:06,320
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   975
And I'm inside the parentheses
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   976
is left with that.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   977
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   978
213
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   979
00:11:06,320 --> 00:11:09,245
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   980
So now I have r + 1.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   981
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   982
214
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   983
00:11:09,245 --> 00:11:13,055
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   984
Usually we cannot
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   985
simplify r + 1.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   986
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   987
215
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   988
00:11:13,055 --> 00:11:15,530
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   989
If it had been r + 0, then yes,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   990
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   991
216
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   992
00:11:15,530 --> 00:11:18,665
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   993
we could have got rid of the 0.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   994
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   995
217
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   996
00:11:18,665 --> 00:11:21,590
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
   997
But this + 1 often
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   998
makes a difference,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   999
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1000
218
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1001
00:11:21,590 --> 00:11:22,970
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1002
but not in our case.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1003
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1004
219
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1005
00:11:22,970 --> 00:11:25,940
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1006
Remember, we know that
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1007
this r is nullable,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1008
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1009
220
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1010
00:11:25,940 --> 00:11:29,840
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1011
so on its own can already
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1012
match the empty string.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1013
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1014
221
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1015
00:11:29,840 --> 00:11:33,305
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1016
So we don't really need this
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1017
alternative plus one there,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1018
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1019
222
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1020
00:11:33,305 --> 00:11:35,300
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1021
so we can just get rid of that.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1022
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1023
223
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1024
00:11:35,300 --> 00:11:37,070
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1025
Okay, and so now we have
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1026
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1027
224
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1028
00:11:37,070 --> 00:11:40,535
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1029
a much simpler equivalent
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1030
regular expression.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1031
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1032
225
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1033
00:11:40,535 --> 00:11:44,285
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1034
And this actually helps a
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1035
lot for our if-condition.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1036
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1037
226
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1038
00:11:44,285 --> 00:11:46,925
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1039
Look, this was the
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1040
original if-condition
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1041
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1042
227
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1043
00:11:46,925 --> 00:11:50,270
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1044
and this is the regular expression
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1045
we just simplified.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1046
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1047
228
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1048
00:11:50,270 --> 00:11:53,105
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1049
If we replace it with this one,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1050
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1051
229
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1052
00:11:53,105 --> 00:11:56,090
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1053
then we just end up with this.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1054
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1055
230
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1056
00:11:56,090 --> 00:11:59,510
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1057
And now you will see that
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1058
the if condition is actually
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1059
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1060
231
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1061
00:11:59,510 --> 00:12:02,750
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1062
pointless because you
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1063
check if it's nullable,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1064
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1065
232
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1066
00:12:02,750 --> 00:12:05,060
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1067
we return this regular
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1068
expression or it's
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1069
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1070
233
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1071
00:12:05,060 --> 00:12:08,210
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1072
not nullable and we
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1073
return exactly the same.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1074
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1075
234
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1076
00:12:08,210 --> 00:12:10,025
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1077
That doesn't make any difference.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1078
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1079
235
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1080
00:12:10,025 --> 00:12:11,750
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1081
So we can just get rid of
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1082
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1083
236
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1084
00:12:11,750 --> 00:12:14,645
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1085
that one and can
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1086
replace it by that.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1087
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1088
237
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1089
00:12:14,645 --> 00:12:16,865
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1090
And you see, this is now
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1091
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1092
238
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1093
00:12:16,865 --> 00:12:20,720
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1094
a much simpler case than
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1095
what we had before.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1096
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1097
239
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1098
00:12:20,720 --> 00:12:24,170
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1099
So let's take stock
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1100
what we have so far.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1101
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1102
240
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1103
00:12:24,170 --> 00:12:26,915
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1104
So we know in the 0-case,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1105
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1106
241
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1107
00:12:26,915 --> 00:12:30,920
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1108
the derivative needs
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1109
to be defined as 0.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1110
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1111
242
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1112
00:12:30,920 --> 00:12:33,095
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1113
Because we define this
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1114
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1115
243
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1116
00:12:33,095 --> 00:12:36,785
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1117
n-times as one,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1118
the derivative is 0.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1119
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1120
244
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1121
00:12:36,785 --> 00:12:39,889
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1122
For just r, this will
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1123
be the derivative.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1124
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1125
245
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1126
00:12:39,889 --> 00:12:42,170
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1127
And we can't do any
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1128
better than that.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1129
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1130
246
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1131
00:12:42,170 --> 00:12:45,620
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1132
For r followed by r, as we
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1133
just found out
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1134
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1135
247
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1136
00:12:45,620 --> 00:12:47,270
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1137
actually it is quite simple
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1138
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1139
248
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1140
00:12:47,270 --> 00:12:51,410
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1141
regular expression is equivalent
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1142
to the derivative.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1143
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1144
249
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1145
00:12:51,410 --> 00:12:53,870
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1146
Now, we have to continue with
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1147
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1148
250
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1149
00:12:53,870 --> 00:12:56,090
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1150
that case where n is
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1151
equal to three and we
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1152
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1153
251
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1154
00:12:56,090 --> 00:12:58,099
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1155
now have three copies
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1156
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1157
252
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1158
00:12:58,099 --> 00:13:02,390
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1159
of this r. What should
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1160
be the derivative?
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1161
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1162
253
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1163
00:13:02,390 --> 00:13:05,330
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1164
Well, if you look very carefully
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1165
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1166
254
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1167
00:13:05,330 --> 00:13:08,465
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1168
at this emerging pattern,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1169
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1170
255
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1171
00:13:08,465 --> 00:13:12,410
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1172
I have to say then
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1173
what would be nice if,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1174
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1175
256
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1176
00:13:12,410 --> 00:13:16,400
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1177
if he could show that in
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1178
the n equals three case,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1179
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1180
257
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1181
00:13:16,400 --> 00:13:18,275
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1182
we end up with this.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1183
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1184
258
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1185
00:13:18,275 --> 00:13:21,290
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1186
Because then what we have is this.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1187
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1188
259
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1189
00:13:21,290 --> 00:13:25,370
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1190
We can define our
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1191
nullable for n-times
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1192
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1193
260
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1194
00:13:25,370 --> 00:13:31,025
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1195
as if n = 0 then
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1196
true, else nullable r.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1197
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1198
261
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1199
00:13:31,025 --> 00:13:33,875
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1200
And for the derivative,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1201
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1202
262
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1203
00:13:33,875 --> 00:13:37,190
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1204
we can save if n is equal to 0,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1205
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1206
263
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1207
00:13:37,190 --> 00:13:40,235
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1208
then we return the
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1209
0 regular expression.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1210
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1211
264
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1212
00:13:40,235 --> 00:13:43,295
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1213
Otherwise, as you can see
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1214
from this pattern here,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1215
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1216
265
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1217
00:13:43,295 --> 00:13:50,735
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1218
it would be derivative of
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1219
c r followed by r{n-1}.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1220
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1221
266
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1222
00:13:50,735 --> 00:13:54,770
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1223
Okay? And the only
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1224
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1225
267
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1226
00:13:54,770 --> 00:13:56,330
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1227
thing we have to make csure is that
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1228
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1229
268
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1230
00:13:56,330 --> 00:13:58,175
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1231
this pattern actually holds.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1232
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1233
269
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1234
00:13:58,175 --> 00:14:00,470
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1235
So that's, I will
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1236
show you next in
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1237
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1238
270
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1239
00:14:00,470 --> 00:14:03,735
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1240
the case for n equals three.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1241
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1242
271
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1243
00:14:03,735 --> 00:14:07,810
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1244
If we have a regular expression r
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1245
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1246
272
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1247
00:14:07,810 --> 00:14:09,820
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1248
and it's followed
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1249
by r and another r,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1250
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1251
273
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1252
00:14:09,820 --> 00:14:11,275
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1253
three copies of it.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1254
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1255
274
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1256
00:14:11,275 --> 00:14:14,245
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1257
We can just unfold
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1258
again the definition.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1259
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1260
275
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1261
00:14:14,245 --> 00:14:16,930
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1262
So we would ask if r is nullable,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1263
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1264
276
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1265
00:14:16,930 --> 00:14:19,765
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1266
then we have this if branch.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1267
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1268
277
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1269
00:14:19,765 --> 00:14:23,905
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1270
And if r is not nullable,
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1271
we have this else branch.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1272
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1273
278
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1274
00:14:23,905 --> 00:14:27,010
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1275
Okay? What can we do here?
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1276
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1277
279
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1278
00:14:27,010 --> 00:14:30,310
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1279
Well, we notice that
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1280
this one is just now
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1281
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1282
280
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1283
00:14:30,310 --> 00:14:34,510
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1284
the derivative of two
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1285
r's, one after another.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1286
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1287
281
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1288
00:14:34,510 --> 00:14:37,330
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1289
But this we just
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1290
calculated a moment ago,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1291
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1292
282
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1293
00:14:37,330 --> 00:14:40,120
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1294
so we can just
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1295
replace it by this.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1296
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1297
283
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1298
00:14:40,120 --> 00:14:43,255
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1299
Ok. That's what we
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1300
calculated earlier.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1301
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1302
284
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1303
00:14:43,255 --> 00:14:46,665
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1304
But now you will see
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1305
again this factor,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1306
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1307
285
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1308
00:14:46,665 --> 00:14:48,695
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1309
and this factor is the same.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1310
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1311
286
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1312
00:14:48,695 --> 00:14:52,700
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1313
So I can pull that
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1314
out to be like that.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1315
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1316
287
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1317
00:14:52,700 --> 00:14:57,380
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1318
And I have now r followed
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1319
by r plus r. 
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1320
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1321
288
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1322
00:14:57,380 --> 00:14:59,030
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1323
But now you probably
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1324
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1325
289
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1326
00:14:59,030 --> 00:15:00,680
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1327
remember how we did it earlier.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1328
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1329
290
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1330
00:15:00,680 --> 00:15:03,080
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1331
We can now pull out one copy of
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1332
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1333
291
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1334
00:15:03,080 --> 00:15:06,020
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1335
this are to just get
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1336
something like this.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1337
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1338
292
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1339
00:15:06,020 --> 00:15:08,765
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1340
We have to add one essentially,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1341
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1342
293
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1343
00:15:08,765 --> 00:15:11,615
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1344
but we now get r plus one.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1345
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1346
294
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1347
00:15:11,615 --> 00:15:15,065
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1348
And this r here is
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1349
now just pulled out.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1350
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1351
295
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1352
00:15:15,065 --> 00:15:18,995
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1353
Well, here again kicks
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1354
in this reasoning.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1355
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1356
296
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1357
00:15:18,995 --> 00:15:22,700
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1358
We go in this if branch
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1359
only if r is nullable.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1360
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1361
297
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1362
00:15:22,700 --> 00:15:26,150
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1363
So r on its own can already
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1364
match the empty string.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1365
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1366
298
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1367
00:15:26,150 --> 00:15:28,895
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1368
So I don't need
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1369
really this plus one.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1370
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1371
299
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1372
00:15:28,895 --> 00:15:30,695
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1373
I can just get rid of it.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1374
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1375
300
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1376
00:15:30,695 --> 00:15:33,140
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1377
And so I now just have
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1378
to rearrange the parentheses
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1379
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1380
301
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1381
00:15:33,140 --> 00:15:35,450
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1382
which we said we can also do.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1383
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1384
302
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1385
00:15:35,450 --> 00:15:37,595
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1386
So we have something like that.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1387
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1388
303
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1389
00:15:37,595 --> 00:15:39,740
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1390
And here again, the
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1391
same reasoning,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1392
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1393
304
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1394
00:15:39,740 --> 00:15:41,975
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1395
we have an if condition
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1396
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1397
305
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1398
00:15:41,975 --> 00:15:43,310
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1399
where it doesn't
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1400
really matter what
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1401
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1402
306
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1403
00:15:43,310 --> 00:15:44,405
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1404
we're going to return,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1405
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1406
307
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1407
00:15:44,405 --> 00:15:46,205
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1408
it's in both branches the same.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1409
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1410
308
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1411
00:15:46,205 --> 00:15:48,470
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1412
So we can just
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1413
replace it by that.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1414
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1415
309
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1416
00:15:48,470 --> 00:15:51,920
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1417
And yes, now we can be
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1418
pretty sure they'll
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1419
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1420
310
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1421
00:15:51,920 --> 00:15:55,310
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1422
work for all the n-times
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1423
regular expressions.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1424
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1425
311
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1426
00:15:55,310 --> 00:15:57,860
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1427
And I leave 
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1428
the calculation for
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1429
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1430
312
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1431
00:15:57,860 --> 00:16:02,570
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1432
maybe r to the four to you.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1433
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1434
313
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1435
00:16:02,570 --> 00:16:04,490
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1436
And the reason why I do it
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1437
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1438
314
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1439
00:16:04,490 --> 00:16:06,605
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1440
in such a detail,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1441
this calculation,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1442
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1443
315
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1444
00:16:06,605 --> 00:16:08,960
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1445
this is really meant
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1446
to help you with
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1447
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1448
316
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1449
00:16:08,960 --> 00:16:13,200
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1450
the coursework which is
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1451
coming up this week.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1452
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1453
317
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1454
00:16:13,210 --> 00:16:16,250
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1455
I'm now back in our
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1456
implementation.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1457
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1458
318
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1459
00:16:16,250 --> 00:16:20,660
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1460
In this re2.sc, we said we have
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1461
this explicit constructor 
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1462
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1463
319
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1464
00:16:20,660 --> 00:16:25,535
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1465
for n-times. We can now fill
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1466
in the cases for nullable.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1467
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1468
320
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1469
00:16:25,535 --> 00:16:27,635
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1470
So if we have r n-times,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1471
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1472
321
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1473
00:16:27,635 --> 00:16:30,995
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1474
if this n is equal to
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1475
0, we return true.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1476
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1477
322
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1478
00:16:30,995 --> 00:16:34,190
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1479
Otherwise we have to test
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1480
whether r is nullable.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1481
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1482
323
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1483
00:16:34,190 --> 00:16:37,565
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1484
And in the derivative case, 
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1485
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1486
324
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1487
00:16:37,565 --> 00:16:40,339
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1488
if this n is equal to 0,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1489
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1490
325
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1491
00:16:40,339 --> 00:16:43,564
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1492
the return this 0
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1493
regular expression.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1494
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1495
326
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1496
00:16:43,564 --> 00:16:46,700
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1497
Otherwise we return the
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1498
sequence of the derivative
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1499
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1500
327
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1501
00:16:46,700 --> 00:16:50,270
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1502
of c of r followed by n times of r,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1503
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1504
328
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1505
00:16:50,270 --> 00:16:54,545
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1506
but n minus one times, and
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1507
everything else stays the same.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1508
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1509
329
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1510
00:16:54,545 --> 00:16:56,510
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1511
Here's the function for strings,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1512
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1513
330
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1514
00:16:56,510 --> 00:16:58,430
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1515
derivative function for strings.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1516
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1517
331
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1518
00:16:58,430 --> 00:17:01,595
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1519
In the main matcher
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1520
function is all the same.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1521
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1522
332
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1523
00:17:01,595 --> 00:17:04,820
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1524
We still require this
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1525
definition because
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1526
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1527
333
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1528
00:17:04,820 --> 00:17:06,050
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1529
we haven't done anything about
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1530
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1531
334
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1532
00:17:06,050 --> 00:17:08,090
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1533
the optional regular
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1534
expression yet.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1535
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1536
335
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1537
00:17:08,090 --> 00:17:10,670
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1538
And we have now this
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1539
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1540
336
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1541
00:17:10,670 --> 00:17:13,250
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1542
EVIL1 and EVIL2
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1543
regular expression.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1544
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1545
337
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1546
00:17:13,250 --> 00:17:15,290
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1547
And let's test it. And let's be
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1548
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1549
338
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1550
00:17:15,290 --> 00:17:17,000
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1551
a bit more ambitious.
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1552
We're testing it with
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1553
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1554
339
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1555
00:17:17,000 --> 00:17:20,315
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1556
strings between 0 and 1000
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1557
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1558
340
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1559
00:17:20,315 --> 00:17:22,580
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1560
and let's see what the time say.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1561
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1562
341
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1563
00:17:22,580 --> 00:17:26,210
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1564
I'm testing this again
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1565
inside the Ammonite REPL.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1566
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1567
342
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1568
00:17:26,210 --> 00:17:30,180
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1569
And you'll see it should
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1570
be now much quicker.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1571
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1572
343
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1573
00:17:30,610 --> 00:17:34,640
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1574
Okay, it might slow
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1575
down also around 600.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1576
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1577
344
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1578
00:17:34,640 --> 00:17:40,490
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1579
700 needs two seconds,
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1580
three seconds for 800.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1581
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1582
345
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1583
00:17:40,490 --> 00:17:43,940
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1584
Let's see what it
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1585
needs for one thousand?
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1586
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1587
346
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1588
00:17:43,940 --> 00:17:47,435
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1589
But you have to remember
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1590
Ruby and Python
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1591
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1592
347
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1593
00:17:47,435 --> 00:17:51,530
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1594
needed half a
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1595
minute for just 30 a's.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1596
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1597
348
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1598
00:17:51,530 --> 00:17:54,485
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1599
We need a little bit
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1600
more than six seconds,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1601
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1602
349
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1603
00:17:54,485 --> 00:17:57,110
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1604
but we are processing a string of
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1605
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1606
350
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1607
00:17:57,110 --> 00:18:00,575
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1608
1000 a's. So that success.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1609
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1610
351
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1611
00:18:00,575 --> 00:18:04,775
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1612
This speed is also explained
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1613
if you look at the sizes.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1614
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1615
352
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1616
00:18:04,775 --> 00:18:08,975
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1617
Since we now have this explicit
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1618
n-times constructor,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1619
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1620
353
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1621
00:18:08,975 --> 00:18:11,930
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1622
it doesn't really matter
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1623
how big this n is.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1624
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1625
354
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1626
00:18:11,930 --> 00:18:14,540
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1627
This EVIL1 regular
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1628
expression will always be
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1629
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1630
355
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1631
00:18:14,540 --> 00:18:17,195
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1632
of this size seven, at
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1633
the beginning.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1634
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1635
356
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1636
00:18:17,195 --> 00:18:20,315
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1637
And you can also see if you
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1638
now build the derivatives,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1639
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1640
357
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1641
00:18:20,315 --> 00:18:22,550
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1642
they still grow in size,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1643
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1644
358
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1645
00:18:22,550 --> 00:18:24,740
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1646
but much more moderately.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1647
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1648
359
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1649
00:18:24,740 --> 00:18:28,100
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1650
And let's try out this
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1651
example with 20 a's.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1652
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1653
360
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1654
00:18:28,100 --> 00:18:31,685
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1655
So we build the derivative
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1656
according to 20 character a's.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1657
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1658
361
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1659
00:18:31,685 --> 00:18:33,890
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1660
In the earlier example,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1661
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1662
362
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1663
00:18:33,890 --> 00:18:35,780
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1664
we ended up with a
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1665
regular expression that
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1666
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1667
363
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1668
00:18:35,780 --> 00:18:37,895
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1669
had like 8 million plus nodes.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1670
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1671
364
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1672
00:18:37,895 --> 00:18:39,830
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1673
And if we do this now,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1674
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1675
365
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1676
00:18:39,830 --> 00:18:43,205
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1677
then we just have a regular
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1678
expression with 211 nodes.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1679
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1680
366
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1681
00:18:43,205 --> 00:18:44,750
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1682
And that is much smaller and
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1683
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1684
367
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1685
00:18:44,750 --> 00:18:47,165
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1686
all the calculations
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1687
would be much quicker.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1688
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1689
368
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1690
00:18:47,165 --> 00:18:49,550
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1691
So yeah, the Brzozowski
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1692
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1693
369
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1694
00:18:49,550 --> 00:18:52,205
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1695
algorithm
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1696
and with this improvement,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1697
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1698
370
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1699
00:18:52,205 --> 00:18:54,890
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1700
we're now running
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1701
circles around Ruby and
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1702
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1703
371
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1704
00:18:54,890 --> 00:18:58,445
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1705
Python because they're just
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1706
stuck here at the beginning.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1707
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1708
372
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1709
00:18:58,445 --> 00:19:00,230
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1710
Because they need already
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1711
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1712
373
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1713
00:19:00,230 --> 00:19:02,975
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1714
like half a minute
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1715
for just 30 a's.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1716
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1717
374
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1718
00:19:02,975 --> 00:19:05,930
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1719
We now can do something
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1720
like thousand a's
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1721
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1722
375
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1723
00:19:05,930 --> 00:19:07,580
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1724
in a reasonable time.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1725
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1726
376
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1727
00:19:07,580 --> 00:19:09,740
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1728
I think this must be
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1729
timing I obtained with
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1730
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1731
377
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1732
00:19:09,740 --> 00:19:12,635
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1733
my older laptop some time ago.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1734
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1735
378
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1736
00:19:12,635 --> 00:19:14,210
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1737
Because remember we
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1738
had something like
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1739
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1740
379
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1741
00:19:14,210 --> 00:19:16,670
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1742
six seconds. Here it says 15.
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1743
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1744
380
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1745
00:19:16,670 --> 00:19:18,080
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1746
You always have to take
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1747
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1748
381
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1749
00:19:18,080 --> 00:19:20,885
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1750
these times with
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1751
the pinch of salt.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1752
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1753
382
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1754
00:19:20,885 --> 00:19:22,670
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1755
It's essentially only the trend,
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1756
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1757
383
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1758
00:19:22,670 --> 00:19:25,100
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1759
but it's clear we are
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1760
much, much better.
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1761
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1762
384
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1763
00:19:25,100 --> 00:19:27,065
773
260e330f7466 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 772
diff changeset
  1764
We have worked a lot,
769
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1765
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1766
385
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1767
00:19:27,065 --> 00:19:30,720
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1768
but we also got something
f9686b22db7e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1769
for it in return.