videos/02-algo3.srt
changeset 774 42733adf2a48
parent 773 260e330f7466
equal deleted inserted replaced
773:260e330f7466 774:42733adf2a48
     1 1
     1 1
     2 00:00:06,350 --> 00:00:10,305
     2 00:00:06,350 --> 00:00:10,305
     3 They come back. I
     3 Welcome come back. I
     4 can hear you saying,
     4 can hear you saying,
     5 
     5 
     6 2
     6 2
     7 00:00:10,305 --> 00:00:12,000
     7 00:00:10,305 --> 00:00:12,000
     8 yes, you tried it out on
     8 yes, you tried it out on
    17 But how about on other examples?
    17 But how about on other examples?
    18 
    18 
    19 5
    19 5
    20 00:00:17,415 --> 00:00:21,265
    20 00:00:17,415 --> 00:00:21,265
    21 Specifically, we had two
    21 Specifically, we had two
    22 regular expressions.
    22 evil regular expressions.
    23 
    23 
    24 6
    24 6
    25 00:00:21,265 --> 00:00:23,480
    25 00:00:21,265 --> 00:00:23,480
    26 How about the other case?
    26 How about the other case?
    27 
    27 
    28 7
    28 7
    29 00:00:23,480 --> 00:00:27,480
    29 00:00:23,480 --> 00:00:27,480
    30 Where let's have a look at
    30 Well, let's have a look at
    31 that other case in this video.
    31 that other case in this video.
    32 
    32 
    33 8
    33 8
    34 00:00:29,140 --> 00:00:32,705
    34 00:00:29,140 --> 00:00:32,705
    35 So I'm back here
    35 So I'm back here
    36 in this Reto file.
    36 in this re2.sc file.
    37 
    37 
    38 9
    38 9
    39 00:00:32,705 --> 00:00:35,180
    39 00:00:32,705 --> 00:00:35,180
    40 And here's this test
    40 And here's this test
    41 case which run quite
    41 case which run quite
    42 
    42 
    43 10
    43 10
    44 00:00:35,180 --> 00:00:39,665
    44 00:00:35,180 --> 00:00:39,665
    45 nicely for strings between 01000.
    45 nicely for strings between 0 and 1000.
    46 
    46 
    47 11
    47 11
    48 00:00:39,665 --> 00:00:42,725
    48 00:00:39,665 --> 00:00:42,725
    49 Here is the other test case.
    49 Here is the other test case.
    50 
    50 
    53 I still run it only
    53 I still run it only
    54 
    54 
    55 13
    55 13
    56 00:00:44,090 --> 00:00:48,470
    56 00:00:44,090 --> 00:00:48,470
    57 for relatively small
    57 for relatively small
    58 strings between 020.
    58 strings between 0 and 20.
    59 
    59 
    60 14
    60 14
    61 00:00:48,470 --> 00:00:50,240
    61 00:00:48,470 --> 00:00:50,240
    62 And let's see what it say.
    62 And let's see what it says.
    63 
    63 
    64 15
    64 15
    65 00:00:50,240 --> 00:00:51,800
    65 00:00:50,240 --> 00:00:51,800
    66 So I'm running the test in
    66 So I'm running the test in
    67 
    67 
    68 16
    68 16
    69 00:00:51,800 --> 00:00:57,320
    69 00:00:51,800 --> 00:00:57,320
    70 the ammonoids repo and
    70 the Amoonite REPL and it 
    71 doesn't look too bad.
    71 doesn't look too bad.
    72 
    72 
    73 17
    73 17
    74 00:00:57,320 --> 00:01:01,160
    74 00:00:57,320 --> 00:01:01,160
    75 But this might be because
    75 But this might be because
    76 20 is not general enough.
    76 20 is not generous enough.
    77 
    77 
    78 18
    78 18
    79 00:01:01,160 --> 00:01:03,620
    79 00:01:01,160 --> 00:01:03,620
    80 So let's try it with 30.
    80 So let's try it with 30.
    81 
    81 
   118 00:01:31,399 --> 00:01:33,905
   118 00:01:31,399 --> 00:01:33,905
   119 So here is something going on,
   119 So here is something going on,
   120 
   120 
   121 28
   121 28
   122 00:01:33,905 --> 00:01:37,640
   122 00:01:33,905 --> 00:01:37,640
   123 which is Daphne bad and we
   123 which is definitely bad and we
   124 have to have a look at that.
   124 have to have a look at that.
   125 
   125 
   126 29
   126 29
   127 00:01:37,640 --> 00:01:40,640
   127 00:01:37,640 --> 00:01:40,640
   128 Okay? It's always
   128 It's always
   129 instructive with
   129 instructive with
   130 
   130 
   131 30
   131 30
   132 00:01:40,640 --> 00:01:43,460
   132 00:01:40,640 --> 00:01:43,460
   133 this algorithm to
   133 this algorithm to
   134 look at the sizes of
   134 look at the sizes of
   135 
   135 
   136 31
   136 31
   137 00:01:43,460 --> 00:01:45,695
   137 00:01:43,460 --> 00:01:45,695
   138 the record expressions
   138 the regular expressions
   139 we calculate
   139 we calculate.
   140 
   140 
   141 32
   141 32
   142 00:01:45,695 --> 00:01:49,625
   142 00:01:45,695 --> 00:01:49,625
   143 the evil to Is this
   143 The EVIL2 is this
   144 a star, star B.
   144 a star, star b.
   145 
   145 
   146 33
   146 33
   147 00:01:49,625 --> 00:01:51,800
   147 00:01:49,625 --> 00:01:51,800
   148 So there's nothing we
   148 So there's nothing we
   149 can compress there.
   149 can compress there.
   172 00:02:04,190 --> 00:02:05,600
   172 00:02:04,190 --> 00:02:05,600
   173 As you can see here.
   173 As you can see here.
   174 
   174 
   175 39
   175 39
   176 00:02:05,600 --> 00:02:08,420
   176 00:02:05,600 --> 00:02:08,420
   177 If I take this evil to wreck
   177 If I take this EVIL2 regular
   178 
   178 
   179 40
   179 40
   180 00:02:08,420 --> 00:02:09,935
   180 00:02:08,420 --> 00:02:09,935
   181 expression and they built
   181 expression and then build
   182 
   182 
   183 41
   183 41
   184 00:02:09,935 --> 00:02:12,470
   184 00:02:09,935 --> 00:02:12,470
   185 now longer and
   185 longer and
   186 longer derivatives,
   186 longer derivatives,
   187 
   187 
   188 42
   188 42
   189 00:02:12,470 --> 00:02:14,090
   189 00:02:12,470 --> 00:02:14,090
   190 you can see this grows.
   190 you can see this grows.
   207 it is quite quick.
   207 it is quite quick.
   208 
   208 
   209 47
   209 47
   210 00:02:21,680 --> 00:02:26,870
   210 00:02:21,680 --> 00:02:26,870
   211 But the size of the
   211 But the size of the
   212 reg expression,
   212 regular expression,
   213 
   213 
   214 48
   214 48
   215 00:02:26,870 --> 00:02:28,310
   215 00:02:26,870 --> 00:02:28,310
   216 the number of nodes,
   216 the number of nodes,
   217 
   217 
   233 00:02:37,865 --> 00:02:39,560
   233 00:02:37,865 --> 00:02:39,560
   234 it just runs out of memory.
   234 it just runs out of memory.
   235 
   235 
   236 53
   236 53
   237 00:02:39,560 --> 00:02:42,785
   237 00:02:39,560 --> 00:02:42,785
   238 This reg expression
   238 This regular expression
   239 just grew too much.
   239 just grew too much.
   240 
   240 
   241 54
   241 54
   242 00:02:42,785 --> 00:02:46,520
   242 00:02:42,785 --> 00:02:46,520
   243 So we somehow need
   243 So we somehow need
   244 to still compress
   244 to still compress
   245 
   245 
   246 55
   246 55
   247 00:02:46,520 --> 00:02:49,655
   247 00:02:46,520 --> 00:02:49,655
   248 this record expression
   248 this regular expression
   249 and make it not
   249 and make it not
   250 
   250 
   251 56
   251 56
   252 00:02:49,655 --> 00:02:52,700
   252 00:02:49,655 --> 00:02:52,700
   253 grow so much when we
   253 grow so much when we
   254 build derivative.
   254 build the derivative.
   255 
   255 
   256 57
   256 57
   257 00:02:52,700 --> 00:02:54,020
   257 00:02:52,700 --> 00:02:54,020
   258 So we have to look at
   258 So we have to look at
   259 
   259 
   277 it, we looked at
   277 it, we looked at
   278 
   278 
   279 62
   279 62
   280 00:03:03,740 --> 00:03:06,560
   280 00:03:03,740 --> 00:03:06,560
   281 this example of a
   281 this example of a
   282 wreck expression R,
   282 regulat expression r,
   283 
   283 
   284 63
   284 63
   285 00:03:06,560 --> 00:03:11,465
   285 00:03:06,560 --> 00:03:11,465
   286 which is a star of some
   286 which is a star of some
   287 alternative and some sequence.
   287 alternative and some sequence.
   310 0 and then followed by r,
   310 0 and then followed by r,
   311 
   311 
   312 69
   312 69
   313 00:03:26,570 --> 00:03:29,015
   313 00:03:26,570 --> 00:03:29,015
   314 which is this whole
   314 which is this whole
   315 wreck expression again.
   315 regular expression again.
   316 
   316 
   317 70
   317 70
   318 00:03:29,015 --> 00:03:30,935
   318 00:03:29,015 --> 00:03:30,935
   319 So you can also see.
   319 So you can also see
   320 
   320 
   321 71
   321 71
   322 00:03:30,935 --> 00:03:34,745
   322 00:03:30,935 --> 00:03:34,745
   323 Derivative operation
   323 the derivative operation
   324 introduces a lot of junk.
   324 introduces a lot of junk.
   325 
   325 
   326 72
   326 72
   327 00:03:34,745 --> 00:03:38,165
   327 00:03:34,745 --> 00:03:38,165
   328 This plus 0 isn't
   328 This plus 0 isn't
   329 really necessary.
   329 really necessary.
   330 
   330 
   331 73
   331 73
   332 00:03:38,165 --> 00:03:42,455
   332 00:03:38,165 --> 00:03:42,455
   333 And this times one could
   333 And this times 1 could
   334 be also thrown away.
   334 be also thrown away.
   335 
   335 
   336 74
   336 74
   337 00:03:42,455 --> 00:03:43,685
   337 00:03:42,455 --> 00:03:43,685
   338 So in the first case,
   338 So in the first case,
   342 actually we could just have
   342 actually we could just have
   343 one times b is b plus 0,
   343 one times b is b plus 0,
   344 
   344 
   345 76
   345 76
   346 00:03:48,110 --> 00:03:49,580
   346 00:03:48,110 --> 00:03:49,580
   347 it still be a,
   347 it still b,
   348 
   348 
   349 77
   349 77
   350 00:03:49,580 --> 00:03:54,905
   350 00:03:49,580 --> 00:03:54,905
   351 so it would be B followed by
   351 so it would be b followed by
   352 R. And in this second case,
   352 r. And in this second case,
   353 
   353 
   354 78
   354 78
   355 00:03:54,905 --> 00:03:57,515
   355 00:03:54,905 --> 00:03:57,515
   356 C0 times b, that will be just 0.
   356 0 times b, that will be just 0.
   357 
   357 
   358 79
   358 79
   359 00:03:57,515 --> 00:03:59,270
   359 00:03:57,515 --> 00:03:59,270
   360 Then 0 plus one is
   360 Then 0 plus one is
   361 
   361 
   362 80
   362 80
   363 00:03:59,270 --> 00:04:05,330
   363 00:03:59,270 --> 00:04:05,330
   364 11 times r would be just
   364 1 ... times r would be just
   365 r. And in the last case,
   365 r. And in the last case,
   366 
   366 
   367 81
   367 81
   368 00:04:05,330 --> 00:04:12,155
   368 00:04:05,330 --> 00:04:12,155
   369 C0 times B would be 00 plus
   369 0 times b would be 0. 0 plus
   370 0 is 00 times r would be 0.
   370 0 is 0. 0 times r would be 0.
   371 
   371 
   372 82
   372 82
   373 00:04:12,155 --> 00:04:17,540
   373 00:04:12,155 --> 00:04:17,540
   374 Okay? So we could throw out
   374 Okay? So we could throw out
   375 all these useless zeros and
   375 all these useless zeros and
   389 And then we build
   389 And then we build
   390 the next derivative.
   390 the next derivative.
   391 
   391 
   392 86
   392 86
   393 00:04:27,035 --> 00:04:31,130
   393 00:04:27,035 --> 00:04:31,130
   394 0 wouldn't go away by
   394 And the 0s wouldn't go away by
   395 building annuity where tests.
   395 building a new derivative.
   396 
   396 
   397 87
   397 87
   398 00:04:31,130 --> 00:04:34,310
   398 00:04:31,130 --> 00:04:34,310
   399 So we need to somehow
   399 So we need to somehow
   400 a mechanism to
   400 a mechanism to
   433 built the derivative,
   433 built the derivative,
   434 
   434 
   435 95
   435 95
   436 00:04:58,715 --> 00:05:01,415
   436 00:04:58,715 --> 00:05:01,415
   437 this might have
   437 this might have
   438 introduced some chunk.
   438 introduced some junk.
   439 
   439 
   440 96
   440 96
   441 00:05:01,415 --> 00:05:02,960
   441 00:05:01,415 --> 00:05:02,960
   442 And I now have to have
   442 And I now have to have
   443 
   443 
   444 97
   444 97
   445 00:05:02,960 --> 00:05:06,590
   445 00:05:02,960 --> 00:05:06,590
   446 essentially a additional function
   446 essentially an additional function
   447 
   447 
   448 98
   448 98
   449 00:05:06,590 --> 00:05:08,945
   449 00:05:06,590 --> 00:05:08,945
   450 which deletes this junk again.
   450 which deletes this junk again.
   451 
   451 
   453 00:05:08,945 --> 00:05:10,490
   453 00:05:08,945 --> 00:05:10,490
   454 And in doing so,
   454 And in doing so,
   455 
   455 
   456 100
   456 100
   457 00:05:10,490 --> 00:05:13,340
   457 00:05:10,490 --> 00:05:13,340
   458 keep steer, Rekha expression,
   458 keeps the regular expression,
   459 
   459 
   460 101
   460 101
   461 00:05:13,340 --> 00:05:16,730
   461 00:05:13,340 --> 00:05:16,730
   462 relatively small, pickers debts,
   462 relatively small, because that
   463 
   463 
   464 102
   464 102
   465 00:05:16,730 --> 00:05:19,535
   465 00:05:16,730 --> 00:05:19,535
   466 the Achilles heel
   466 is the Achilles' heel
   467 of this algorithm.
   467 of this algorithm.
   468 
   468 
   469 103
   469 103
   470 00:05:19,535 --> 00:05:22,565
   470 00:05:19,535 --> 00:05:22,565
   471 If this regular expression
   471 If this regular expression
   486 is to after the derivative,
   486 is to after the derivative,
   487 
   487 
   488 107
   488 107
   489 00:05:30,455 --> 00:05:33,080
   489 00:05:30,455 --> 00:05:33,080
   490 compress again this
   490 compress again this
   491 rec expression
   491 regular expression
   492 
   492 
   493 108
   493 108
   494 00:05:33,080 --> 00:05:35,570
   494 00:05:33,080 --> 00:05:35,570
   495 and then do the next derivative.
   495 and then do the next derivative.
   496 
   496 
   504 which essentially
   504 which essentially
   505 just goes through
   505 just goes through
   506 
   506 
   507 111
   507 111
   508 00:05:42,440 --> 00:05:46,040
   508 00:05:42,440 --> 00:05:46,040
   509 this reg expression and
   509 this regular expression and
   510 deletes all this junk,
   510 deletes all this junk,
   511 
   511 
   512 112
   512 112
   513 00:05:46,040 --> 00:05:50,045
   513 00:05:46,040 --> 00:05:50,045
   514 then we should be in a
   514 then we should be in a
   537 First of all, there
   537 First of all, there
   538 are only two cases.
   538 are only two cases.
   539 
   539 
   540 118
   540 118
   541 00:06:02,720 --> 00:06:05,060
   541 00:06:02,720 --> 00:06:05,060
   542 The only simplify when we have
   542 We only simplify when we have
   543 
   543 
   544 119
   544 119
   545 00:06:05,060 --> 00:06:08,255
   545 00:06:05,060 --> 00:06:08,255
   546 an alternative or a sequence.
   546 an alternative or a sequence.
   547 
   547 
   583 an alternative and the sequence.
   583 an alternative and the sequence.
   584 
   584 
   585 128
   585 128
   586 00:06:30,530 --> 00:06:34,880
   586 00:06:30,530 --> 00:06:34,880
   587 Now, however, there
   587 Now, however, there
   588 is one small point.
   588 is one small point
   589 
   589 
   590 129
   590 129
   591 00:06:34,880 --> 00:06:39,785
   591 00:06:34,880 --> 00:06:39,785
   592 You have to be aware of
   592 you have to be aware of.
   593 these simplification rules.
   593 These simplification rules
   594 
   594 
   595 130
   595 130
   596 00:06:39,785 --> 00:06:42,740
   596 00:06:39,785 --> 00:06:42,740
   597 They need to be essentially
   597 they need to be essentially
   598 applied backwards.
   598 applied backwards.
   599 
   599 
   600 131
   600 131
   601 00:06:42,740 --> 00:06:45,650
   601 00:06:42,740 --> 00:06:45,650
   602 So I have to first essentially
   602 So I have to first essentially
   603 go to the leaves of
   603 go to the leaves of
   604 
   604 
   605 132
   605 132
   606 00:06:45,650 --> 00:06:49,085
   606 00:06:45,650 --> 00:06:49,085
   607 this record expression and
   607 this regular expression and
   608 then have to find out,
   608 then have to find out,
   609 
   609 
   610 133
   610 133
   611 00:06:49,085 --> 00:06:51,170
   611 00:06:49,085 --> 00:06:51,170
   612 can I apply simplification?
   612 can I apply the simplification?
   613 
   613 
   614 134
   614 134
   615 00:06:51,170 --> 00:06:52,670
   615 00:06:51,170 --> 00:06:52,670
   616 And then if yes,
   616 And then if yes,
   617 
   617 
   653 And in this
   653 And in this
   654 simplification function,
   654 simplification function,
   655 
   655 
   656 143
   656 143
   657 00:07:16,850 --> 00:07:20,885
   657 00:07:16,850 --> 00:07:20,885
   658 what that means is the
   658 what that means we're
   659 matching this reg expression.
   659 matching this regular expression.
   660 
   660 
   661 144
   661 144
   662 00:07:20,885 --> 00:07:23,120
   662 00:07:20,885 --> 00:07:23,120
   663 Be test whether it's
   663 We test whether it's
   664 an alternative or
   664 an alternative or
   665 
   665 
   666 145
   666 145
   667 00:07:23,120 --> 00:07:26,345
   667 00:07:23,120 --> 00:07:26,345
   668 a sequence only then we
   668 a sequence. Only then we
   669 actually go into action.
   669 actually go into action.
   670 
   670 
   671 146
   671 146
   672 00:07:26,345 --> 00:07:28,385
   672 00:07:26,345 --> 00:07:28,385
   673 Once we know.
   673 Once we know
   674 
   674 
   675 147
   675 147
   676 00:07:28,385 --> 00:07:30,530
   676 00:07:28,385 --> 00:07:30,530
   677 In case of an alternative,
   677 in case of an alternative,
   678 
   678 
   679 148
   679 148
   680 00:07:30,530 --> 00:07:32,120
   680 00:07:30,530 --> 00:07:32,120
   681 what are the two components?
   681 what are the two components?
   682 
   682 
   683 149
   683 149
   684 00:07:32,120 --> 00:07:35,765
   684 00:07:32,120 --> 00:07:35,765
   685 P first, simplify each component,
   685 We first, simplify each component,
   686 
   686 
   687 150
   687 150
   688 00:07:35,765 --> 00:07:39,095
   688 00:07:35,765 --> 00:07:39,095
   689 okay, and then we
   689 okay, and then we
   690 get a result back.
   690 get a result back.
   694 And we check whether
   694 And we check whether
   695 
   695 
   696 152
   696 152
   697 00:07:41,180 --> 00:07:45,679
   697 00:07:41,180 --> 00:07:45,679
   698 this simplification of
   698 this simplification of
   699 R1 resulted into a 0.
   699 r1 resulted into a 0.
   700 
   700 
   701 153
   701 153
   702 00:07:45,679 --> 00:07:47,884
   702 00:07:45,679 --> 00:07:47,884
   703 Then because it's an alternative
   703 Then because it's an alternative
   704 
   704 
   705 154
   705 154
   706 00:07:47,884 --> 00:07:49,190
   706 00:07:47,884 --> 00:07:49,190
   707 than I can just replace it
   707 then I can just replace it
   708 
   708 
   709 155
   709 155
   710 00:07:49,190 --> 00:07:53,375
   710 00:07:49,190 --> 00:07:53,375
   711 by r is two a simplified
   711 by r2s, which a simplified
   712 version of R2.
   712 version of r2.
   713 
   713 
   714 156
   714 156
   715 00:07:53,375 --> 00:07:58,820
   715 00:07:53,375 --> 00:07:58,820
   716 If it came back r as
   716 If it came back r2s
   717 two is actually 0,
   717 is actually 0,
   718 
   718 
   719 157
   719 157
   720 00:07:58,820 --> 00:08:00,410
   720 00:07:58,820 --> 00:08:00,410
   721 then I can replace it by
   721 then I can replace it by
   722 
   722 
   723 158
   723 158
   724 00:08:00,410 --> 00:08:03,785
   724 00:08:00,410 --> 00:08:03,785
   725 the simplified version of a warm.
   725 the simplified version of a r1.
   726 
   726 
   727 159
   727 159
   728 00:08:03,785 --> 00:08:07,460
   728 00:08:03,785 --> 00:08:07,460
   729 If I simplify both
   729 If I simplify both
   730 alternatives and it
   730 alternatives and it
   734 happens that the simplified
   734 happens that the simplified
   735 versions are the same,
   735 versions are the same,
   736 
   736 
   737 161
   737 161
   738 00:08:11,180 --> 00:08:15,170
   738 00:08:11,180 --> 00:08:15,170
   739 next century I can throw away
   739 then  I can throw away
   740 one of the alternatives.
   740 one of the alternatives.
   741 
   741 
   742 162
   742 162
   743 00:08:15,170 --> 00:08:18,080
   743 00:08:15,170 --> 00:08:18,080
   744 Otherwise, I just have to
   744 Otherwise, I just have to
   745 keep the alternatives,
   745 keep the alternatives,
   746 
   746 
   747 163
   747 163
   748 00:08:18,080 --> 00:08:21,155
   748 00:08:18,080 --> 00:08:21,155
   749 but the simplified components
   749 but the simplified components.
   750 
   750 
   751 164
   751 164
   752 00:08:21,155 --> 00:08:23,915
   752 00:08:21,155 --> 00:08:23,915
   753 in the sequence is
   753 In the sequence case it is
   754 pretty much the same.
   754 pretty much the same.
   755 
   755 
   756 165
   756 165
   757 00:08:23,915 --> 00:08:27,950
   757 00:08:23,915 --> 00:08:27,950
   758 I first have to check what
   758 I first have to check what
   759 does it simplify underneath.
   759 does it simplify underneath.
   760 
   760 
   761 166
   761 166
   762 00:08:27,950 --> 00:08:31,385
   762 00:08:27,950 --> 00:08:31,385
   763 So I call first simplify
   763 So I call first simplify
   764 and then have a look.
   764 and then have a look...
   765 
   765 
   766 167
   766 167
   767 00:08:31,385 --> 00:08:33,020
   767 00:08:31,385 --> 00:08:33,020
   768 Does it matches C or one of
   768 Does it matches 0 one of 
   769 
   769 
   770 168
   770 168
   771 00:08:33,020 --> 00:08:36,035
   771 00:08:33,020 --> 00:08:36,035
   772 the simplification
   772 the simplifications,
   773 damage, just return 0.
   773 then I just return 0.
   774 
   774 
   775 169
   775 169
   776 00:08:36,035 --> 00:08:38,330
   776 00:08:36,035 --> 00:08:38,330
   777 Or if the other component is 0,
   777 Or if the other component is 0,
   778 
   778 
   785 If it's one, then I keep
   785 If it's one, then I keep
   786 the other component.
   786 the other component.
   787 
   787 
   788 172
   788 172
   789 00:08:43,310 --> 00:08:45,920
   789 00:08:43,310 --> 00:08:45,920
   790 And if this iss two is one,
   790 And if the rs2 is one,
   791 
   791 
   792 173
   792 173
   793 00:08:45,920 --> 00:08:47,615
   793 00:08:45,920 --> 00:08:47,615
   794 and I keep the first component,
   794 and I keep the first component.
   795 
   795 
   796 174
   796 174
   797 00:08:47,615 --> 00:08:50,359
   797 00:08:47,615 --> 00:08:50,359
   798 and otherwise it's
   798 And otherwise it's
   799 still the sequence.
   799 still the sequence.
   800 
   800 
   801 175
   801 175
   802 00:08:50,359 --> 00:08:53,540
   802 00:08:50,359 --> 00:08:53,540
   803 And in all the other cases I
   803 And in all the other cases I
   804 don't have to do anything.
   804 don't have to do anything.
   805 
   805 
   806 176
   806 176
   807 00:08:53,540 --> 00:08:55,700
   807 00:08:53,540 --> 00:08:55,700
   808 It's just a plain
   808 If it's just a plain
   809 0. I leave it in.
   809 0. I leave it in.
   810 
   810 
   811 177
   811 177
   812 00:08:55,700 --> 00:08:57,860
   812 00:08:55,700 --> 00:08:57,860
   813 If it's a plain
   813 If it's a plain
   814 warm, I leave it in.
   814 1, I leave it in.
   815 
   815 
   816 178
   816 178
   817 00:08:57,860 --> 00:09:00,170
   817 00:08:57,860 --> 00:09:00,170
   818 And if something is under a star,
   818 And if something is under a star,
   819 
   819 
   820 179
   820 179
   821 00:09:00,170 --> 00:09:02,840
   821 00:09:00,170 --> 00:09:02,840
   822 I don't open up this
   822 I don't open up this
   823 door and simplify it.
   823 star and simplify it.
   824 
   824 
   825 180
   825 180
   826 00:09:02,840 --> 00:09:06,680
   826 00:09:02,840 --> 00:09:06,680
   827 I just apply that to be
   827 I just apply that to be
   828 as quick as possible.
   828 as quick as possible.
   833 any effect on our code.
   833 any effect on our code.
   834 
   834 
   835 182
   835 182
   836 00:09:10,280 --> 00:09:12,980
   836 00:09:10,280 --> 00:09:12,980
   837 So I'm now in the
   837 So I'm now in the
   838 file read three,
   838 file re3.sc,
   839 
   839 
   840 183
   840 183
   841 00:09:12,980 --> 00:09:17,405
   841 00:09:12,980 --> 00:09:17,405
   842 and it's the same as Reto.
   842 and it's the same as re2.sc.
   843 
   843 
   844 184
   844 184
   845 00:09:17,405 --> 00:09:20,885
   845 00:09:17,405 --> 00:09:20,885
   846 It still has this
   846 It still has this
   847 explicit and Times case,
   847 explicit and n-times case,
   848 
   848 
   849 185
   849 185
   850 00:09:20,885 --> 00:09:24,665
   850 00:09:20,885 --> 00:09:24,665
   851 nullable and derivative
   851 nullable and derivative are
   852 still the same.
   852 still the same.
   853 
   853 
   854 186
   854 186
   855 00:09:24,665 --> 00:09:28,610
   855 00:09:24,665 --> 00:09:28,610
   856 Except now we have this
   856 Except now we have this
   860 00:09:28,610 --> 00:09:29,960
   860 00:09:28,610 --> 00:09:29,960
   861 And when we apply
   861 And when we apply
   862 
   862 
   863 188
   863 188
   864 00:09:29,960 --> 00:09:33,725
   864 00:09:29,960 --> 00:09:33,725
   865 the derivative after
   865 the derivative and after
   866 the apply deteriorated,
   866 we apply the derivative,
   867 
   867 
   868 189
   868 189
   869 00:09:33,725 --> 00:09:35,870
   869 00:09:33,725 --> 00:09:35,870
   870 simplify it to throw away
   870 we simplify it to throw away
   871 
   871 
   872 190
   872 190
   873 00:09:35,870 --> 00:09:39,050
   873 00:09:35,870 --> 00:09:39,050
   874 all the junk this
   874 all the junk this
   875 derivative introduced.
   875 derivative introduced.
   883 00:09:41,510 --> 00:09:43,580
   883 00:09:41,510 --> 00:09:43,580
   884 You still have this expansion
   884 You still have this expansion
   885 
   885 
   886 193
   886 193
   887 00:09:43,580 --> 00:09:45,515
   887 00:09:43,580 --> 00:09:45,515
   888 of the optional reg expression.
   888 of the optional regular expression.
   889 
   889 
   890 194
   890 194
   891 00:09:45,515 --> 00:09:49,670
   891 00:09:45,515 --> 00:09:49,670
   892 Here, our two evil wreck
   892 Here are our two EVIL regular
   893 expressions we use as a test.
   893 expressions we use as a test.
   894 
   894 
   895 195
   895 195
   896 00:09:49,670 --> 00:09:52,460
   896 00:09:49,670 --> 00:09:52,460
   897 And here's now this test case,
   897 And here's now this test case,
   898 
   898 
   899 196
   899 196
   900 00:09:52,460 --> 00:09:55,835
   900 00:09:52,460 --> 00:09:55,835
   901 the first one and the
   901 the first one and we're
   902 actually now trying it
   902 actually now trying it
   903 
   903 
   904 197
   904 197
   905 00:09:55,835 --> 00:10:00,515
   905 00:09:55,835 --> 00:10:00,515
   906 out for strings between
   906 out for strings between
   907 09 thousand a's.
   907 0 and 9000 a's.
   908 
   908 
   909 198
   909 198
   910 00:10:00,515 --> 00:10:08,285
   910 00:10:00,515 --> 00:10:08,285
   911 So C. So also gets
   911 So let's see. So also the 
   912 simplification makes a,
   912 simplification makes 
   913 
   913 
   914 199
   914 199
   915 00:10:08,285 --> 00:10:10,655
   915 00:10:08,285 --> 00:10:10,655
   916 actually this case fast on.
   916 actually this case faster.
   917 
   917 
   918 200
   918 200
   919 00:10:10,655 --> 00:10:16,260
   919 00:10:10,655 --> 00:10:16,260
   920 So we can now run strings
   920 So we can now run strings
   921 up to 9 thousand.
   921 up to 9000.
   922 
   922 
   923 201
   923 201
   924 00:10:16,260 --> 00:10:19,360
   924 00:10:16,260 --> 00:10:19,360
   925 And we don't actually
   925 And we don't actually
   926 sweat about this at all.
   926 sweat about this at all.
   927 
   927 
   928 202
   928 202
   929 00:10:19,360 --> 00:10:24,745
   929 00:10:19,360 --> 00:10:24,745
   930 For I have to say my laptop
   930 For I have to say my laptop
   931 is now starting its fan.
   931 is now starting to run its fan.
   932 
   932 
   933 203
   933 203
   934 00:10:24,745 --> 00:10:28,525
   934 00:10:24,745 --> 00:10:28,525
   935 And also, because the times
   935 And also, because the times
   936 are relatively small,
   936 are relatively small,
   949 which I didn't do before,
   949 which I didn't do before,
   950 
   950 
   951 207
   951 207
   952 00:10:34,720 --> 00:10:37,720
   952 00:10:34,720 --> 00:10:37,720
   953 just to be a tiny bit
   953 just to be a tiny bit
   954 more accurate map.
   954 more accurate.
   955 
   955 
   956 208
   956 208
   957 00:10:37,720 --> 00:10:42,025
   957 00:10:37,720 --> 00:10:42,025
   958 So three seconds for a
   958 So three seconds for a
   959 string of 9 thousand a's.
   959 string of 9000 a's.
   960 
   960 
   961 209
   961 209
   962 00:10:42,025 --> 00:10:44,980
   962 00:10:42,025 --> 00:10:44,980
   963 And now the more
   963 And now the more
   964 interesting question is,
   964 interesting question is,
   967 00:10:44,980 --> 00:10:46,240
   967 00:10:44,980 --> 00:10:46,240
   968 for the second case,
   968 for the second case,
   969 
   969 
   970 211
   970 211
   971 00:10:46,240 --> 00:10:48,625
   971 00:10:46,240 --> 00:10:48,625
   972 this E star, star b.
   972 this a star, star, b.
   973 
   973 
   974 212
   974 212
   975 00:10:48,625 --> 00:10:51,250
   975 00:10:48,625 --> 00:10:51,250
   976 And you can already see
   976 And you can already see
   977 on these numbers RB.
   977 on these numbers...
   978 
   978 
   979 213
   979 213
   980 00:10:51,250 --> 00:10:53,260
   980 00:10:51,250 --> 00:10:53,260
   981 And now you're really ambitious.
   981 we are really ambitious.
   982 
   982 
   983 214
   983 214
   984 00:10:53,260 --> 00:10:57,860
   984 00:10:53,260 --> 00:10:57,860
   985 And let's see how our
   985 And let's see how our
   986 program is coping with that.
   986 program is coping with that.
   990 Again. No sweat, at
   990 Again. No sweat, at
   991 least not on my part.
   991 least not on my part.
   992 
   992 
   993 216
   993 216
   994 00:11:07,780 --> 00:11:10,480
   994 00:11:07,780 --> 00:11:10,480
   995 The laptop thefts to
   995 The laptop has to
   996 calculate quite a bit.
   996 calculate quite a bit.
   997 
   997 
   998 217
   998 217
   999 00:11:10,480 --> 00:11:12,940
   999 00:11:10,480 --> 00:11:12,940
  1000 But this is now a string of
  1000 But this is now a string of
  1001 
  1001 
  1002 218
  1002 218
  1003 00:11:12,940 --> 00:11:16,539
  1003 00:11:12,940 --> 00:11:16,539
  1004 3 million A's and
  1004 3 million a's and
  1005 it needs a second.
  1005 it needs a second.
  1006 
  1006 
  1007 219
  1007 219
  1008 00:11:16,539 --> 00:11:20,680
  1008 00:11:16,539 --> 00:11:20,680
  1009 And let's see how far we get.
  1009 And let's see how far we get.
  1010 
  1010 
  1011 220
  1011 220
  1012 00:11:20,680 --> 00:11:25,280
  1012 00:11:20,680 --> 00:11:25,280
  1013 4 million a around two seconds.
  1013 4 million a's around two seconds.
  1014 
  1014 
  1015 221
  1015 221
  1016 00:11:27,030 --> 00:11:29,050
  1016 00:11:27,030 --> 00:11:29,050
  1017 So say it again,
  1017 So say it again,
  1018 
  1018 
  1019 222
  1019 222
  1020 00:11:29,050 --> 00:11:31,690
  1020 00:11:29,050 --> 00:11:31,690
  1021 I'm actually slowing it down.
  1021 I'm actually slowing it down
  1022 
  1022 
  1023 223
  1023 223
  1024 00:11:31,690 --> 00:11:34,150
  1024 00:11:31,690 --> 00:11:34,150
  1025 He artificially run the test
  1025 here artificially with running the test
  1026 
  1026 
  1027 224
  1027 224
  1028 00:11:34,150 --> 00:11:36,895
  1028 00:11:34,150 --> 00:11:36,895
  1029 three times and then
  1029 three times and then
  1030 take the average.
  1030 take the average.
  1035 less than five seconds.
  1035 less than five seconds.
  1036 
  1036 
  1037 226
  1037 226
  1038 00:11:42,749 --> 00:11:48,185
  1038 00:11:42,749 --> 00:11:48,185
  1039 And remember that is a
  1039 And remember that is a
  1040 string of 6 million A's.
  1040 string of 6 million a's.
  1041 
  1041 
  1042 227
  1042 227
  1043 00:11:48,185 --> 00:11:51,170
  1043 00:11:48,185 --> 00:11:51,170
  1044 Let's just have a
  1044 Let's just have a
  1045 look at the graphs.
  1045 look at the graphs.
  1046 
  1046 
  1047 228
  1047 228
  1048 00:11:51,170 --> 00:11:56,105
  1048 00:11:51,170 --> 00:11:56,105
  1049 So the simplification also
  1049 So the simplification also
  1050 made of first case faster.
  1050 made our first case faster.
  1051 
  1051 
  1052 229
  1052 229
  1053 00:11:56,105 --> 00:11:58,880
  1053 00:11:56,105 --> 00:11:58,880
  1054 So earlier without
  1054 So earlier without
  1055 simplification,
  1055 simplification,
  1056 
  1056 
  1057 230
  1057 230
  1058 00:11:58,880 --> 00:12:00,710
  1058 00:11:58,880 --> 00:12:00,710
  1059 where we just have
  1059 where we just have
  1060 this explicit and
  1060 this explicit 
  1061 
  1061 
  1062 231
  1062 231
  1063 00:12:00,710 --> 00:12:03,050
  1063 00:12:00,710 --> 00:12:03,050
  1064 times that at this graph.
  1064 n-times. That is this graph.
  1065 
  1065 
  1066 232
  1066 232
  1067 00:12:03,050 --> 00:12:05,210
  1067 00:12:03,050 --> 00:12:05,210
  1068 And now we can go up to
  1068 And now we can go up to
  1069 
  1069 
  1081 In the other example, remember,
  1081 In the other example, remember,
  1082 
  1082 
  1083 236
  1083 236
  1084 00:12:16,745 --> 00:12:19,220
  1084 00:12:16,745 --> 00:12:19,220
  1085 the existing regular
  1085 the existing regular
  1086 expression matches in
  1086 expression matchers in
  1087 
  1087 
  1088 237
  1088 237
  1089 00:12:19,220 --> 00:12:22,880
  1089 00:12:19,220 --> 00:12:22,880
  1090 Java eight, Python,
  1090 Java 8, Python,
  1091 and JavaScript.
  1091 and JavaScript.
  1092 
  1092 
  1093 238
  1093 238
  1094 00:12:22,880 --> 00:12:26,030
  1094 00:12:22,880 --> 00:12:26,030
  1095 And thanks to the
  1095 And thanks to the
  1096 student be Ozma,
  1096 student we also 
  1097 
  1097 
  1098 239
  1098 239
  1099 00:12:26,030 --> 00:12:27,935
  1099 00:12:26,030 --> 00:12:27,935
  1100 half a graph for Swift.
  1100 have a graph for Swift.
  1101 
  1101 
  1102 240
  1102 240
  1103 00:12:27,935 --> 00:12:29,750
  1103 00:12:27,935 --> 00:12:29,750
  1104 They're pretty atrocious.
  1104 They're pretty atrocious.
  1105 
  1105 
  1106 241
  1106 241
  1107 00:12:29,750 --> 00:12:33,320
  1107 00:12:29,750 --> 00:12:33,320
  1108 They need like for 30 Ace,
  1108 They need like for 30 a's,
  1109 
  1109 
  1110 242
  1110 242
  1111 00:12:33,320 --> 00:12:37,490
  1111 00:12:33,320 --> 00:12:37,490
  1112 something like on the
  1112 something like on the
  1113 magnitude of thirty-seconds.
  1113 magnitude of 30 seconds.
  1114 
  1114 
  1115 243
  1115 243
  1116 00:12:37,490 --> 00:12:39,740
  1116 00:12:37,490 --> 00:12:39,740
  1117 As I said already,
  1117 As I said already,
  1118 
  1118 
  1119 244
  1119 244
  1120 00:12:39,740 --> 00:12:42,665
  1120 00:12:39,740 --> 00:12:42,665
  1121 Java nine is slightly better.
  1121 Java 9 is slightly better.
  1122 
  1122 
  1123 245
  1123 245
  1124 00:12:42,665 --> 00:12:44,870
  1124 00:12:42,665 --> 00:12:44,870
  1125 Java nine and above this,
  1125 Java 9 and above, 
  1126 
  1126 
  1127 246
  1127 246
  1128 00:12:44,870 --> 00:12:46,220
  1128 00:12:44,870 --> 00:12:46,220
  1129 if you try that example,
  1129 if you try that example,
  1130 
  1130 
  1131 247
  1131 247
  1132 00:12:46,220 --> 00:12:48,665
  1132 00:12:46,220 --> 00:12:48,665
  1133 the same exponential and nine,
  1133 the same example in Java 9,
  1134 
  1134 
  1135 248
  1135 248
  1136 00:12:48,665 --> 00:12:51,230
  1136 00:12:48,665 --> 00:12:51,230
  1137 you would be able to
  1137 you would be able to
  1138 process something
  1138 process something
  1139 
  1139 
  1140 249
  1140 249
  1141 00:12:51,230 --> 00:12:54,215
  1141 00:12:51,230 --> 00:12:54,215
  1142 like 40 thousand A's
  1142 like 40 thousand a's
  1143 in half a minute.
  1143 in half a minute.
  1144 
  1144 
  1145 250
  1145 250
  1146 00:12:54,215 --> 00:12:57,740
  1146 00:12:54,215 --> 00:12:57,740
  1147 I have to admit I'm not
  1147 I have to admit I'm not
  1148 a 100% sure what they
  1148 100% sure what they
  1149 
  1149 
  1150 251
  1150 251
  1151 00:12:57,740 --> 00:13:03,575
  1151 00:12:57,740 --> 00:13:03,575
  1152 did to improve the
  1152 did to improve the
  1153 performance between Java 89.
  1153 performance between Java 8 and 9.
  1154 
  1154 
  1155 252
  1155 252
  1156 00:13:03,575 --> 00:13:05,510
  1156 00:13:03,575 --> 00:13:05,510
  1157 I know they did something on
  1157 I know they did something on
  1158 
  1158 
  1170 at what precisely they've done.
  1170 at what precisely they've done.
  1171 
  1171 
  1172 256
  1172 256
  1173 00:13:12,230 --> 00:13:17,945
  1173 00:13:12,230 --> 00:13:17,945
  1174 But that's still not
  1174 But that's still not
  1175 really competition fas.
  1175 really a competition for us.
  1176 
  1176 
  1177 257
  1177 257
  1178 00:13:17,945 --> 00:13:20,915
  1178 00:13:17,945 --> 00:13:20,915
  1179 So our third version,
  1179 So our third version,
  1180 
  1180 
  1182 00:13:20,915 --> 00:13:24,335
  1182 00:13:20,915 --> 00:13:24,335
  1183 in this example, a star, star b.
  1183 in this example, a star, star b.
  1184 
  1184 
  1185 259
  1185 259
  1186 00:13:24,335 --> 00:13:28,445
  1186 00:13:24,335 --> 00:13:28,445
  1187 We say it's something like
  1187 We said for something like
  1188 We need 6 million A's.
  1188 6 million a's we need 15 secs.
  1189 
  1189 
  1190 260
  1190 260
  1191 00:13:28,445 --> 00:13:31,760
  1191 00:13:28,445 --> 00:13:31,760
  1192 And again, I think these
  1192 And again, I think these
  1193 are slightly older times,
  1193 are slightly older times,
  1194 
  1194 
  1195 261
  1195 261
  1196 00:13:31,760 --> 00:13:33,770
  1196 00:13:31,760 --> 00:13:33,770
  1197 so he had needs 20 seconds.
  1197 so here it needs 20 seconds.
  1198 
  1198 
  1199 262
  1199 262
  1200 00:13:33,770 --> 00:13:37,250
  1200 00:13:33,770 --> 00:13:37,250
  1201 I think we had something
  1201 I think we had something
  1202 like below five seconds.
  1202 like below five seconds.
  1203 
  1203 
  1204 263
  1204 263
  1205 00:13:37,250 --> 00:13:40,865
  1205 00:13:37,250 --> 00:13:40,865
  1206 But again, you can see
  1206 But again, you can see
  1207 the trends. We rants.
  1207 the trends. We run.
  1208 
  1208 
  1209 264
  1209 264
  1210 00:13:40,865 --> 00:13:42,590
  1210 00:13:40,865 --> 00:13:42,590
  1211 Circles around them.
  1211 circles around them.
  1212 
  1212 
  1213 265
  1213 265
  1214 00:13:42,590 --> 00:13:46,530
  1214 00:13:42,590 --> 00:13:46,530
  1215 And that's quite nice.
  1215 And that's quite nice.
  1216 
  1216 
  1217 266
  1217 266
  1218 00:13:46,570 --> 00:13:49,774
  1218 00:13:46,570 --> 00:13:49,774
  1219 So what's good about
  1219 So what's good about
  1220 this algorithm?
  1220 this algorithm
  1221 
  1221 
  1222 267
  1222 267
  1223 00:13:49,774 --> 00:13:51,605
  1223 00:13:49,774 --> 00:13:51,605
  1224 By pressure of ski?
  1224 by Brzozowski?
  1225 
  1225 
  1226 268
  1226 268
  1227 00:13:51,605 --> 00:13:54,500
  1227 00:13:51,605 --> 00:13:54,500
  1228 Well, first, it extends
  1228 Well, first, it extends
  1229 
  1229 
  1236 00:13:57,800 --> 00:13:59,900
  1236 00:13:57,800 --> 00:13:59,900
  1237 So we saw in this example
  1237 So we saw in this example
  1238 
  1238 
  1239 271
  1239 271
  1240 00:13:59,900 --> 00:14:03,950
  1240 00:13:59,900 --> 00:14:03,950
  1241 the End Times regular expression
  1241 the n-times regular expression.
  1242 is a little bit of work.
  1242 Is a little bit of work, but
  1243 
  1243 
  1244 272
  1244 272
  1245 00:14:03,950 --> 00:14:05,405
  1245 00:14:03,950 --> 00:14:05,405
  1246 We could extend that.
  1246 we could extend that.
  1247 
  1247 
  1248 273
  1248 273
  1249 00:14:05,405 --> 00:14:08,480
  1249 00:14:05,405 --> 00:14:08,480
  1250 It also extends to the
  1250 It also extends to the
  1251 not reg expression,
  1251 not regular expression,
  1252 
  1252 
  1253 274
  1253 274
  1254 00:14:08,480 --> 00:14:10,820
  1254 00:14:08,480 --> 00:14:10,820
  1255 which I explain on
  1255 which I explain on
  1256 the next slide.
  1256 the next slide.
  1273 00:14:20,675 --> 00:14:22,955
  1273 00:14:20,675 --> 00:14:22,955
  1274 you still have to agree.
  1274 you still have to agree.
  1275 
  1275 
  1276 279
  1276 279
  1277 00:14:22,955 --> 00:14:25,715
  1277 00:14:22,955 --> 00:14:25,715
  1278 Quite beautiful in Scala.
  1278 It's quite beautiful in Scala.
  1279 
  1279 
  1280 280
  1280 280
  1281 00:14:25,715 --> 00:14:28,160
  1281 00:14:25,715 --> 00:14:28,160
  1282 And you could also
  1282 And you could also
  1283 easily implemented
  1283 easily implemented
  1284 
  1284 
  1285 281
  1285 281
  1286 00:14:28,160 --> 00:14:31,760
  1286 00:14:28,160 --> 00:14:31,760
  1287 in C language or in Python.
  1287 in the C language or in Python.
  1288 
  1288 
  1289 282
  1289 282
  1290 00:14:31,760 --> 00:14:34,250
  1290 00:14:31,760 --> 00:14:34,250
  1291 There's really no
  1291 There's really no
  1292 problem with that.
  1292 problem with that.
  1293 
  1293 
  1294 283
  1294 283
  1295 00:14:34,250 --> 00:14:38,390
  1295 00:14:34,250 --> 00:14:38,390
  1296 Say the algorithm's actually
  1296 The algorithm is actually
  1297 quite old already brush-off,
  1297 quite old already. 
  1298 
  1298 
  1299 284
  1299 284
  1300 00:14:38,390 --> 00:14:44,899
  1300 00:14:38,390 --> 00:14:44,899
  1301 ski wrote it down in
  1301 Brzozowski wrote it down in
  1302 1964 and his PhD thesis.
  1302 1964 and his PhD thesis.
  1303 
  1303 
  1304 285
  1304 285
  1305 00:14:44,899 --> 00:14:49,460
  1305 00:14:44,899 --> 00:14:49,460
  1306 Somehow it was forgotten during
  1306 Somehow it was forgotten during
  1311 recently has been rediscovered.
  1311 recently has been rediscovered.
  1312 
  1312 
  1313 287
  1313 287
  1314 00:14:54,095 --> 00:14:57,065
  1314 00:14:54,095 --> 00:14:57,065
  1315 At the moment, we are
  1315 At the moment, we are
  1316 only solve the problem
  1316 only solved the problem
  1317 
  1317 
  1318 288
  1318 288
  1319 00:14:57,065 --> 00:15:02,240
  1319 00:14:57,065 --> 00:15:02,240
  1320 of Gmail reg expression
  1320 of given a regular expression,
  1321 gamma string deaths,
  1321 givven a string, does
  1322 
  1322 
  1323 289
  1323 289
  1324 00:15:02,240 --> 00:15:05,550
  1324 00:15:02,240 --> 00:15:05,550
  1325 the regular expression
  1325 the regular expression
  1326 match the string yes or no.
  1326 match the string yes or no.
  1327 
  1327 
  1328 290
  1328 290
  1329 00:15:05,550 --> 00:15:08,740
  1329 00:15:05,550 --> 00:15:08,740
  1330 The want to of course, use
  1330 We want to of course, use
  1331 it as part of our lexicon.
  1331 it as part of our lexer.
  1332 
  1332 
  1333 291
  1333 291
  1334 00:15:08,740 --> 00:15:12,370
  1334 00:15:08,740 --> 00:15:12,370
  1335 And there we have to do
  1335 And there we have to do
  1336 something more complicated.
  1336 something more complicated.
  1350 And that's actually relatively
  1350 And that's actually relatively
  1351 recent work by somebody
  1351 recent work by somebody
  1352 
  1352 
  1353 295
  1353 295
  1354 00:15:22,045 --> 00:15:26,110
  1354 00:15:22,045 --> 00:15:26,110
  1355 called suits Month and
  1355 called Sulzmann and
  1356 the co-worker called Lou.
  1356 the co-worker called Lu.
  1357 
  1357 
  1358 296
  1358 296
  1359 00:15:26,110 --> 00:15:30,880
  1359 00:15:26,110 --> 00:15:30,880
  1360 And what I personally
  1360 And what I personally
  1361 also find very satisfying
  1361 also find very satisfying
  1401 Does it really satisfy
  1401 Does it really satisfy
  1402 the specification?
  1402 the specification?
  1403 
  1403 
  1404 306
  1404 306
  1405 00:15:56,645 --> 00:15:58,550
  1405 00:15:56,645 --> 00:15:58,550
  1406 Is really fs string
  1406 Is it really true that if a string
  1407 
  1407 
  1408 307
  1408 307
  1409 00:15:58,550 --> 00:16:00,440
  1409 00:15:58,550 --> 00:16:00,440
  1410 is in the language
  1410 is in the language
  1411 of a reg expression.
  1411 of a regular expression.
  1412 
  1412 
  1413 308
  1413 308
  1414 00:16:00,440 --> 00:16:03,050
  1414 00:16:00,440 --> 00:16:03,050
  1415 Does that matter? Vd say yes.
  1415 Does that matter? I would say yes.
  1416 
  1416 
  1417 309
  1417 309
  1418 00:16:03,050 --> 00:16:07,070
  1418 00:16:03,050 --> 00:16:07,070
  1419 However, I leave that
  1419 However, I leave that
  1420 for another video.
  1420 for another video.
  1425 this algorithm that can be
  1425 this algorithm that can be
  1426 
  1426 
  1427 311
  1427 311
  1428 00:16:10,580 --> 00:16:13,775
  1428 00:16:10,580 --> 00:16:13,775
  1429 actually extended to quite a
  1429 actually extended to quite a
  1430 number of rec expressions.
  1430 number of regular expressions.
  1431 
  1431 
  1432 312
  1432 312
  1433 00:16:13,775 --> 00:16:17,810
  1433 00:16:13,775 --> 00:16:17,810
  1434 So this is t not reg
  1434 So this is the NOT regular
  1435 expression that is
  1435 expression that is
  1436 
  1436 
  1437 313
  1437 313
  1438 00:16:17,810 --> 00:16:19,760
  1438 00:16:17,810 --> 00:16:19,760
  1439 opposed to match strings which
  1439 supposed to match strings which
  1440 
  1440 
  1441 314
  1441 314
  1442 00:16:19,760 --> 00:16:22,235
  1442 00:16:19,760 --> 00:16:22,235
  1443 this reg expression cannot match.
  1443 this regular expression cannot match.
  1444 
  1444 
  1445 315
  1445 315
  1446 00:16:22,235 --> 00:16:24,245
  1446 00:16:22,235 --> 00:16:24,245
  1447 So here's an example.
  1447 So here's an example.
  1448 
  1448 
  1449 316
  1449 316
  1450 00:16:24,245 --> 00:16:28,640
  1450 00:16:24,245 --> 00:16:28,640
  1451 You're in the business of
  1451 If you're in the business of
  1452 trying to find out what
  1452 trying to find out what
  1453 
  1453 
  1454 317
  1454 317
  1455 00:16:28,640 --> 00:16:33,530
  1455 00:16:28,640 --> 00:16:33,530
  1456 our comments in languages like
  1456 are comments in languages like
  1457 Java or C. Then you know,
  1457 Java or C. Then you know,
  1458 
  1458 
  1459 318
  1459 318
  1460 00:16:33,530 --> 00:16:35,060
  1460 00:16:33,530 --> 00:16:35,060
  1461 they always start with a slash,
  1461 they always start with a slash,
  1513 have such a string
  1513 have such a string
  1514 
  1514 
  1515 330
  1515 330
  1516 00:17:03,680 --> 00:17:06,410
  1516 00:17:03,680 --> 00:17:06,410
  1517 which doesn't
  1517 which doesn't
  1518 contain as standard,
  1518 contain a star and a slash,
  1519 
  1519 
  1520 331
  1520 331
  1521 00:17:06,410 --> 00:17:11,180
  1521 00:17:06,410 --> 00:17:11,180
  1522 then at the end you want to
  1522 then at the end you want to
  1523 match a star and a slash.
  1523 match a star and a slash.
  1526 00:17:11,180 --> 00:17:13,460
  1526 00:17:11,180 --> 00:17:13,460
  1527 So for these kind of comments,
  1527 So for these kind of comments,
  1528 
  1528 
  1529 333
  1529 333
  1530 00:17:13,460 --> 00:17:15,995
  1530 00:17:13,460 --> 00:17:15,995
  1531 this reg expression is
  1531 this regular expression is
  1532 actually quite useful.
  1532 actually quite useful.
  1533 
  1533 
  1534 334
  1534 334
  1535 00:17:15,995 --> 00:17:19,430
  1535 00:17:15,995 --> 00:17:19,430
  1536 And if you ever seen
  1536 And if you ever seen
  1537 how to do the negation,
  1537 how to do the negation,
  1538 
  1538 
  1539 335
  1539 335
  1540 00:17:19,430 --> 00:17:21,995
  1540 00:17:19,430 --> 00:17:21,995
  1541 this kinda break
  1541 for this kind of regular
  1542 expression with automata?
  1542 expression with automata,
  1543 
  1543 
  1544 336
  1544 336
  1545 00:17:21,995 --> 00:17:24,710
  1545 00:17:21,995 --> 00:17:24,710
  1546 You will know that's
  1546 you will know that's
  1547 a bit of a pain,
  1547 a bit of a pain.
  1548 
  1548 
  1549 337
  1549 337
  1550 00:17:24,710 --> 00:17:26,675
  1550 00:17:24,710 --> 00:17:26,675
  1551 but for the Borowski,
  1551 But for the Brzozowski,
  1552 
  1552 
  1553 338
  1553 338
  1554 00:17:26,675 --> 00:17:28,370
  1554 00:17:26,675 --> 00:17:28,370
  1555 it's no pain at all.
  1555 it's no pain at all.
  1556 
  1556 
  1557 339
  1557 339
  1558 00:17:28,370 --> 00:17:30,710
  1558 00:17:28,370 --> 00:17:30,710
  1559 The meaning of this
  1559 The meaning of this
  1560 reg expression
  1560 regular expression
  1561 
  1561 
  1562 340
  1562 340
  1563 00:17:30,710 --> 00:17:32,255
  1563 00:17:30,710 --> 00:17:32,255
  1564 would be something like that.
  1564 would be something like that.
  1565 
  1565 
  1572 00:17:35,540 --> 00:17:38,390
  1572 00:17:35,540 --> 00:17:38,390
  1573 and I take away all the strings,
  1573 and I take away all the strings,
  1574 
  1574 
  1575 343
  1575 343
  1576 00:17:38,390 --> 00:17:40,055
  1576 00:17:38,390 --> 00:17:40,055
  1577 this arc and match.
  1577 this r can match.
  1578 
  1578 
  1579 344
  1579 344
  1580 00:17:40,055 --> 00:17:42,080
  1580 00:17:40,055 --> 00:17:42,080
  1581 The remaining strings are
  1581 The remaining strings are
  1582 
  1582 
  1583 345
  1583 345
  1584 00:17:42,080 --> 00:17:44,630
  1584 00:17:42,080 --> 00:17:44,630
  1585 what this reg expression
  1585 what this regular expression
  1586 is supposed to match.
  1586 is supposed to match.
  1587 
  1587 
  1588 346
  1588 346
  1589 00:17:44,630 --> 00:17:47,165
  1589 00:17:44,630 --> 00:17:47,165
  1590 So I can specify
  1590 So I can specify
  1603 00:17:52,174 --> 00:17:54,140
  1603 00:17:52,174 --> 00:17:54,140
  1604 So for nullable, it would be
  1604 So for nullable, it would be
  1605 
  1605 
  1606 350
  1606 350
  1607 00:17:54,140 --> 00:17:56,570
  1607 00:17:54,140 --> 00:17:56,570
  1608 just a test where
  1608 just a test whether r
  1609 the eyes nullable.
  1609 is nullable.
  1610 
  1610 
  1611 351
  1611 351
  1612 00:17:56,570 --> 00:17:58,985
  1612 00:17:56,570 --> 00:17:58,985
  1613 And I just take the
  1613 And I just take the
  1614 negation of that.
  1614 negation of that.
  1615 
  1615 
  1616 352
  1616 352
  1617 00:17:58,985 --> 00:18:00,680
  1617 00:17:58,985 --> 00:18:00,680
  1618 And men I have to build
  1618 And then I have to build
  1619 
  1619 
  1620 353
  1620 353
  1621 00:18:00,680 --> 00:18:03,620
  1621 00:18:00,680 --> 00:18:03,620
  1622 the derivative of this
  1622 the derivative of this
  1623 not reg expression.
  1623 NOT regular expression.
  1624 
  1624 
  1625 354
  1625 354
  1626 00:18:03,620 --> 00:18:05,420
  1626 00:18:03,620 --> 00:18:05,420
  1627 Then I just have to move
  1627 Then I just have to move
  1628 
  1628 
  1629 355
  1629 355
  1630 00:18:05,420 --> 00:18:07,325
  1630 00:18:05,420 --> 00:18:07,325
  1631 this permutation does derivative,
  1631 this ....
  1632 
  1632 
  1633 356
  1633 356
  1634 00:18:07,325 --> 00:18:10,070
  1634 00:18:07,325 --> 00:18:10,070
  1635 derivative inside
  1635 derivative inside
  1636 the wreck expression
  1636 the regular expression
  1637 
  1637 
  1638 357
  1638 357
  1639 00:18:10,070 --> 00:18:12,575
  1639 00:18:10,070 --> 00:18:12,575
  1640 and keep the not on
  1640 and keep the NOT on
  1641 the outermost level.
  1641 the outermost level.
  1642 
  1642 
  1643 358
  1643 358
  1644 00:18:12,575 --> 00:18:15,515
  1644 00:18:12,575 --> 00:18:15,515
  1645 So there's again no
  1645 So there's again no
  1646 pain involved in
  1646 pain involved in
  1647 
  1647 
  1648 359
  1648 359
  1649 00:18:15,515 --> 00:18:19,130
  1649 00:18:15,515 --> 00:18:19,130
  1650 adding this reg expression
  1650 adding this regular expression
  1651 to the algorithm.
  1651 to the algorithm.
  1652 
  1652 
  1653 360
  1653 360
  1654 00:18:19,130 --> 00:18:22,100
  1654 00:18:19,130 --> 00:18:22,100
  1655 We made it to the end of
  1655 We made it to the end of
  1660 it also to the end
  1660 it also to the end
  1661 of this algorithm.
  1661 of this algorithm.
  1662 
  1662 
  1663 362
  1663 362
  1664 00:18:24,739 --> 00:18:27,620
  1664 00:18:24,739 --> 00:18:27,620
  1665 I can see to loose trends.
  1665 I can see to loose strands.
  1666 
  1666 
  1667 363
  1667 363
  1668 00:18:27,620 --> 00:18:29,420
  1668 00:18:27,620 --> 00:18:29,420
  1669 One is we implemented
  1669 One is we implemented
  1670 
  1670 
  1673 this algorithm for the
  1673 this algorithm for the
  1674 basic regular expressions.
  1674 basic regular expressions.
  1675 
  1675 
  1676 365
  1676 365
  1677 00:18:32,855 --> 00:18:38,705
  1677 00:18:32,855 --> 00:18:38,705
  1678 And we also added the end
  1678 And we also added the 
  1679 times out of necessity.
  1679 n-times out of necessity.
  1680 
  1680 
  1681 366
  1681 366
  1682 00:18:38,705 --> 00:18:41,120
  1682 00:18:38,705 --> 00:18:41,120
  1683 And I also showed
  1683 And I also showed
  1684 you how to implement
  1684 you how to implement
  1685 
  1685 
  1686 367
  1686 367
  1687 00:18:41,120 --> 00:18:44,840
  1687 00:18:41,120 --> 00:18:44,840
  1688 the not regular
  1688 the NOT regular
  1689 expression on a slide.
  1689 expression on a slide.
  1690 
  1690 
  1691 368
  1691 368
  1692 00:18:44,840 --> 00:18:48,995
  1692 00:18:44,840 --> 00:18:48,995
  1693 But your task in the
  1693 But your task in the
  1694 coursework actually is
  1694 coursework actually is
  1695 
  1695 
  1696 369
  1696 369
  1697 00:18:48,995 --> 00:18:52,970
  1697 00:18:48,995 --> 00:18:52,970
  1698 to extend that to some of
  1698 to extend that to some of
  1699 the extended reg expression.
  1699 the extended regular expressions.
  1700 
  1700 
  1701 370
  1701 370
  1702 00:18:52,970 --> 00:18:57,260
  1702 00:18:52,970 --> 00:18:57,260
  1703 So especially these bounded
  1703 So especially these bounded
  1704 repetitions like from 0 to
  1704 repetitions like from 0 to
  1705 
  1705 
  1706 371
  1706 371
  1707 00:18:57,260 --> 00:19:01,550
  1707 00:18:57,260 --> 00:19:01,550
  1708 n times or between n and m times.
  1708 n-times or between n and m times.
  1709 
  1709 
  1710 372
  1710 372
  1711 00:19:01,550 --> 00:19:04,325
  1711 00:19:01,550 --> 00:19:04,325
  1712 And I think also
  1712 And I think also
  1713 plus and D option.
  1713 plus and option.
  1714 
  1714 
  1715 373
  1715 373
  1716 00:19:04,325 --> 00:19:07,220
  1716 00:19:04,325 --> 00:19:07,220
  1717 The other loose trend is,
  1717 The other loose strand is,
  1718 
  1718 
  1719 374
  1719 374
  1720 00:19:07,220 --> 00:19:09,200
  1720 00:19:07,220 --> 00:19:09,200
  1721 remember I did this while
  1721 remember I did this wild
  1722 
  1722 
  1723 375
  1723 375
  1724 00:19:09,200 --> 00:19:11,645
  1724 00:19:09,200 --> 00:19:11,645
  1725 calculations with
  1725 calculations with
  1726 regular expressions.
  1726 regular expressions.
  1727 
  1727 
  1728 376
  1728 376
  1729 00:19:11,645 --> 00:19:13,205
  1729 00:19:11,645 --> 00:19:13,205
  1730 Why on earth?
  1730 Why on earth
  1731 
  1731 
  1732 377
  1732 377
  1733 00:19:13,205 --> 00:19:14,480
  1733 00:19:13,205 --> 00:19:14,480
  1734 Is that all correct?
  1734 is that all correct?
  1735 
  1735 
  1736 378
  1736 378
  1737 00:19:14,480 --> 00:19:16,355
  1737 00:19:14,480 --> 00:19:16,355
  1738 Why on earth should
  1738 Why on earth should
  1739 this algorithm
  1739 this algorithm