forked from DeathKing/Learning-SICP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlec1a.eng.ass
1059 lines (1057 loc) · 102 KB
/
lec1a.eng.ass
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
[Script Info]
; Script generated by Aegisub 3.0.2
; http://www.aegisub.org/
Title: Default Aegisub file
ScriptType: v4.00+
WrapStyle: 0
ScaledBorderAndShadow: yes
Collisions: Normal
PlayResX: 640
PlayResY: 480
Audio URI: lec1a_Rerip_remux.mp4
Scroll Position: 752
Active Line: 753
Video Zoom Percent: 0.875
Video File: lec1a_Rerip_remux.mp4
Video Aspect Ratio: c1.33333
Video Position: 95862
Last Style Storage: Default
YCbCr Matrix: TV.601
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Calisto MT,23,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,1,0,2,10,10,30,1
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:14.71,0:00:17.89,Default,,0,0,0,,I'd like to welcome you to this course on computer science.
Dialogue: 0,0:00:28.40,0:00:29.85,Default,,0,0,0,,Actually, that's a terrible way to start.
Dialogue: 0,0:00:29.85,0:00:32.34,Default,,0,0,0,,Computer science is a terrible name for this business.
Dialogue: 0,0:00:32.83,0:00:34.30,Default,,0,0,0,,First of all, it's not a science.
Dialogue: 0,0:00:35.92,0:00:39.81,Default,,0,0,0,,It might be engineering or it might be art,
Dialogue: 0,0:00:40.09,0:00:42.91,Default,,0,0,0,,but we'll actually see that computer so-called science
Dialogue: 0,0:00:42.93,0:00:44.97,Default,,0,0,0,,actually has a lot in common with magic,
Dialogue: 0,0:00:45.01,0:00:46.35,Default,,0,0,0,,and we'll see that in this course.
Dialogue: 0,0:00:47.28,0:00:48.22,Default,,0,0,0,,So it's not a science.
Dialogue: 0,0:00:48.23,0:00:52.30,Default,,0,0,0,,It's also not really very much about computers.
Dialogue: 0,0:00:53.39,0:00:55.47,Default,,0,0,0,,And it's not about computers in the same sense
Dialogue: 0,0:00:55.47,0:01:00.05,Default,,0,0,0,,that physics is not really about particle accelerators,
Dialogue: 0,0:01:00.80,0:01:05.58,Default,,0,0,0,,and biology is not really about microscopes and petri dishes.
Dialogue: 0,0:01:06.46,0:01:10.25,Default,,0,0,0,,And it's not about computers in the same sense
Dialogue: 0,0:01:10.31,0:01:14.88,Default,,0,0,0,,that geometry is not really about using surveying instruments.
Dialogue: 0,0:01:16.48,0:01:19.01,Default,,0,0,0,,In fact, there's a lot of commonality
Dialogue: 0,0:01:19.33,0:01:21.45,Default,,0,0,0,,between computer science and geometry.
Dialogue: 0,0:01:21.45,0:01:22.66,Default,,0,0,0,,Geometry, first of all,
Dialogue: 0,0:01:23.02,0:01:24.98,Default,,0,0,0,,is another subject with a lousy name.
Dialogue: 0,0:01:25.58,0:01:27.85,Default,,0,0,0,,The name comes from Gaia, meaning the Earth,
Dialogue: 0,0:01:27.90,0:01:29.09,Default,,0,0,0,,and metron, meaning to measure.
Dialogue: 0,0:01:29.82,0:01:33.39,Default,,0,0,0,,Geometry originally meant measuring the Earth or surveying.
Dialogue: 0,0:01:34.37,0:01:36.89,Default,,0,0,0,,And the reason for that was that, thousands of years ago,
Dialogue: 0,0:01:37.69,0:01:41.69,Default,,0,0,0,,the Egyptian priesthood developed the rudiments of geometry
Dialogue: 0,0:01:42.59,0:01:46.33,Default,,0,0,0,,in order to figure out how to restore the boundaries of fields
Dialogue: 0,0:01:46.35,0:01:48.69,Default,,0,0,0,,that were destroyed in the annual flooding of the Nile.
Dialogue: 0,0:01:49.47,0:01:50.65,Default,,0,0,0,,And to the Egyptians who did that,
Dialogue: 0,0:01:50.65,0:01:53.93,Default,,0,0,0,,geometry really was the use of surveying instruments.
Dialogue: 0,0:01:55.63,0:01:58.55,Default,,0,0,0,,Now, the reason that we think computer science is about computers
Dialogue: 0,0:01:58.57,0:02:02.49,Default,,0,0,0,,is pretty much the same reason that the Egyptians thought geometry
Dialogue: 0,0:02:02.51,0:02:04.10,Default,,0,0,0,,was about surveying instruments.
Dialogue: 0,0:02:04.59,0:02:07.37,Default,,0,0,0,,And that is, when some field is just getting started
Dialogue: 0,0:02:07.39,0:02:09.86,Default,,0,0,0,,and you don't really understand it very well,
Dialogue: 0,0:02:11.10,0:02:16.64,Default,,0,0,0,,it's very easy to confuse the essence of what you're doing with the tools that you use.
Dialogue: 0,0:02:17.65,0:02:20.30,Default,,0,0,0,,And indeed, on some absolute scale of things,
Dialogue: 0,0:02:20.30,0:02:24.82,Default,,0,0,0,,we probably know less about the essence of computer science
Dialogue: 0,0:02:24.83,0:02:27.49,Default,,0,0,0,,than the ancient Egyptians really knew about geometry.
Dialogue: 0,0:02:30.25,0:02:32.64,Default,,0,0,0,,Well, what do I mean by the essence of computer science?
Dialogue: 0,0:02:32.65,0:02:34.41,Default,,0,0,0,,What do I mean by the essence of geometry?
Dialogue: 0,0:02:34.41,0:02:36.45,Default,,0,0,0,,See, it's certainly true that these Egyptians went off
Dialogue: 0,0:02:36.46,0:02:37.67,Default,,0,0,0,,and used surveying instruments,
Dialogue: 0,0:02:37.69,0:02:41.55,Default,,0,0,0,,but when we look back on them after a couple of thousand years,
Dialogue: 0,0:02:41.57,0:02:41.85,Default,,0,0,0,,we say,
Dialogue: 0,0:02:41.87,0:02:43.64,Default,,0,0,0,,gee, what they were doing,
Dialogue: 0,0:02:43.71,0:02:45.48,Default,,0,0,0,,the important stuff they were doing,
Dialogue: 0,0:02:45.62,0:02:50.45,Default,,0,0,0,,was to begin to formalize notions about space and time,
Dialogue: 0,0:02:51.58,0:02:57.53,Default,,0,0,0,,to start a way of talking about mathematical truths formally.
Dialogue: 0,0:02:58.01,0:02:59.61,Default,,0,0,0,,That led to the axiomatic method.
Dialogue: 0,0:02:59.61,0:03:02.53,Default,,0,0,0,,That led to sort of all of modern mathematics,
Dialogue: 0,0:03:04.16,0:03:06.90,Default,,0,0,0,,figuring out a way to talk precisely about
Dialogue: 0,0:03:07.25,0:03:10.19,Default,,0,0,0,,so-called declarative knowledge, what is true.
Dialogue: 0,0:03:12.45,0:03:16.25,Default,,0,0,0,,Well, similarly, I think in the future people will look back and say,
Dialogue: 0,0:03:16.27,0:03:19.36,Default,,0,0,0,,yes, those primitives in the 20th century were fiddling around
Dialogue: 0,0:03:19.36,0:03:21.20,Default,,0,0,0,,with these gadgets called computers,
Dialogue: 0,0:03:21.77,0:03:26.25,Default,,0,0,0,,but really what they were doing is starting to learn
Dialogue: 0,0:03:26.25,0:03:32.55,Default,,0,0,0,,how to formalize intuitions about process,
Dialogue: 0,0:03:32.64,0:03:34.13,Default,,0,0,0,,how to do things,
Dialogue: 0,0:03:39.02,0:03:51.25,Default,,0,0,0,,starting to develop a way to talk precisely about how-to knowledge,
Dialogue: 0,0:03:51.76,0:03:56.03,Default,,0,0,0,,as opposed to geometry that talks about what is true.
Dialogue: 0,0:03:56.53,0:03:58.57,Default,,0,0,0,,Let me give you an example of that.
Dialogue: 0,0:04:02.30,0:04:02.69,Default,,0,0,0,,Let's take a look
Dialogue: 0,0:04:02.70,0:04:09.82,Default,,0,0,0,,Here is a piece of mathematics that says what a square root is.
Dialogue: 0,0:04:10.09,0:04:14.35,Default,,0,0,0,,The square root of X is the number Y,
Dialogue: 0,0:04:15.98,0:04:20.38,Default,,0,0,0,,such that Y squared is equal to X and Y is greater than 0.
Dialogue: 0,0:04:20.43,0:04:22.50,Default,,0,0,0,,Now, that's a fine piece of mathematics,
Dialogue: 0,0:04:22.88,0:04:25.25,Default,,0,0,0,,but just telling you what a square root is
Dialogue: 0,0:04:25.63,0:04:30.29,Default,,0,0,0,,doesn't really say anything about how you might go out and find one.
Dialogue: 0,0:04:31.42,0:04:35.90,Default,,0,0,0,,So let's contrast that with a piece of imperative knowledge,
Dialogue: 0,0:04:37.13,0:04:39.92,Default,,0,0,0,,how you might go out and find a square root.
Dialogue: 0,0:04:39.95,0:04:45.74,Default,,0,0,0,,This, in fact, also comes from Egypt, not ancient, ancient Egypt.
Dialogue: 0,0:04:45.76,0:04:48.88,Default,,0,0,0,,This is an algorithm due to Heron of Alexandria,
Dialogue: 0,0:04:49.90,0:04:52.77,Default,,0,0,0,,called how to find a square root by successive averaging.
Dialogue: 0,0:04:52.89,0:04:55.13,Default,,0,0,0,,And what it says is that,
Dialogue: 0,0:04:55.15,0:04:58.06,Default,,0,0,0,,in order to find a square root,
Dialogue: 0,0:05:03.34,0:05:08.33,Default,,0,0,0,,you make a guess, you improve that guess --
Dialogue: 0,0:05:10.19,0:05:11.44,Default,,0,0,0,,and the way you improve the guess
Dialogue: 0,0:05:11.45,0:05:13.95,Default,,0,0,0,,is to average the guess and X over the guess,
Dialogue: 0,0:05:14.41,0:05:15.60,Default,,0,0,0,,and we'll talk a little bit later about
Dialogue: 0,0:05:15.61,0:05:17.12,Default,,0,0,0,,why that's a reasonable thing--
Dialogue: 0,0:05:17.14,0:05:19.37,Default,,0,0,0,,and you keep improving the guess until it's good enough.
Dialogue: 0,0:05:19.73,0:05:20.85,Default,,0,0,0,,That's a method.
Dialogue: 0,0:05:20.99,0:05:24.65,Default,,0,0,0,,That's how to do something as opposed to
Dialogue: 0,0:05:24.72,0:05:27.33,Default,,0,0,0,,declarative knowledge that says what you're looking for.
Dialogue: 0,0:05:28.05,0:05:29.76,Default,,0,0,0,,That's a process.
Dialogue: 0,0:05:34.40,0:05:38.25,Default,,0,0,0,,Well, what's a process in general?
Dialogue: 0,0:05:39.01,0:05:40.14,Default,,0,0,0,,It's kind of hard to say.
Dialogue: 0,0:05:40.16,0:05:43.72,Default,,0,0,0,,You can think of it as like a magical spirit
Dialogue: 0,0:05:44.77,0:05:47.33,Default,,0,0,0,,that sort of lives in the computer and does something.
Dialogue: 0,0:05:48.01,0:05:54.11,Default,,0,0,0,,And the thing that directs a process is
Dialogue: 0,0:05:54.13,0:05:57.98,Default,,0,0,0,,a pattern of rules called a procedure.
Dialogue: 0,0:06:01.98,0:06:04.73,Default,,0,0,0,,So procedures are the spells, if you like,
Dialogue: 0,0:06:05.23,0:06:09.40,Default,,0,0,0,,that control these magical spirits that are the processes.
Dialogue: 0,0:06:10.75,0:06:12.75,Default,,0,0,0,,I guess you know everyone needs a magical language,
Dialogue: 0,0:06:12.77,0:06:14.55,Default,,0,0,0,,and sorcerers, real sorcerers,
Dialogue: 0,0:06:14.57,0:06:18.59,Default,,0,0,0,,use ancient Arcadian or Sumerian or Babylonian or whatever.
Dialogue: 0,0:06:18.62,0:06:20.09,Default,,0,0,0,,We're going to conjure our spirits
Dialogue: 0,0:06:20.13,0:06:22.71,Default,,0,0,0,,in a magical language called Lisp,
Dialogue: 0,0:06:24.37,0:06:28.01,Default,,0,0,0,,which is a language designed for talking about,
Dialogue: 0,0:06:28.57,0:06:31.84,Default,,0,0,0,,for casting the spells that are procedures to direct the processes.
Dialogue: 0,0:06:31.87,0:06:33.91,Default,,0,0,0,,Now, it's very easy to learn Lisp.
Dialogue: 0,0:06:33.97,0:06:35.98,Default,,0,0,0,,In fact, in a few minutes, I'm going to teach you,
Dialogue: 0,0:06:36.00,0:06:37.16,Default,,0,0,0,,essentially, all of Lisp.
Dialogue: 0,0:06:37.37,0:06:38.96,Default,,0,0,0,,I'm going to teach you, essentially, all of the rules.
Dialogue: 0,0:06:40.77,0:06:43.65,Default,,0,0,0,,And you shouldn't find that particularly surprising.
Dialogue: 0,0:06:43.69,0:06:45.87,Default,,0,0,0,,That's sort of like saying it's very easy
Dialogue: 0,0:06:45.90,0:06:47.01,Default,,0,0,0,,to learn the rules of chess.
Dialogue: 0,0:06:47.04,0:06:48.13,Default,,0,0,0,,And indeed, in a few minutes,
Dialogue: 0,0:06:48.17,0:06:49.70,Default,,0,0,0,,you can tell somebody the rules of chess.
Dialogue: 0,0:06:50.81,0:06:52.24,Default,,0,0,0,,But of course, that's very different from
Dialogue: 0,0:06:52.25,0:06:55.37,Default,,0,0,0,,saying you understand the implications of those rules
Dialogue: 0,0:06:55.42,0:06:58.05,Default,,0,0,0,,and how to use those rules to become a masterful chess player.
Dialogue: 0,0:06:58.49,0:06:59.82,Default,,0,0,0,,Well, Lisp is the same way.
Dialogue: 0,0:07:00.41,0:07:02.18,Default,,0,0,0,,We're going to state the rules in a few minutes,
Dialogue: 0,0:07:02.36,0:07:03.55,Default,,0,0,0,,and it'll be very easy to see.
Dialogue: 0,0:07:03.62,0:07:07.09,Default,,0,0,0,,But what's really hard is going to be the implications of those rules,
Dialogue: 0,0:07:07.32,0:07:10.46,Default,,0,0,0,,how you exploit those rules to be a master programmer.
Dialogue: 0,0:07:12.06,0:07:15.29,Default,,0,0,0,,And the implications of those rules are going to take us the,
Dialogue: 0,0:07:15.31,0:07:18.56,Default,,0,0,0,,well, the whole rest of the subject and, of course, way beyond.
Dialogue: 0,0:07:21.45,0:07:23.11,Default,,0,0,0,,OK, so in computer science,
Dialogue: 0,0:07:24.49,0:07:26.19,Default,,0,0,0,,we're in the business of
Dialogue: 0,0:07:26.21,0:07:30.58,Default,,0,0,0,,formalizing this sort of how-to imperative knowledge,
Dialogue: 0,0:07:30.62,0:07:32.10,Default,,0,0,0,,how to do stuff.
Dialogue: 0,0:07:33.37,0:07:35.39,Default,,0,0,0,,And the real issues of computer science are, of course,
Dialogue: 0,0:07:35.41,0:07:38.36,Default,,0,0,0,,not telling people how to do square roots.
Dialogue: 0,0:07:39.09,0:07:40.06,Default,,0,0,0,,Because if that was all it was,
Dialogue: 0,0:07:40.09,0:07:41.34,Default,,0,0,0,,there wouldn't be no big deal.
Dialogue: 0,0:07:41.57,0:07:44.05,Default,,0,0,0,,The real problems come when we try to
Dialogue: 0,0:07:44.08,0:07:46.16,Default,,0,0,0,,build very, very large systems,
Dialogue: 0,0:07:46.61,0:07:49.53,Default,,0,0,0,,computer programs that are thousands of pages long,
Dialogue: 0,0:07:49.58,0:07:53.98,Default,,0,0,0,,so long that nobody can really hold them in their heads all at once.
Dialogue: 0,0:07:54.73,0:07:58.81,Default,,0,0,0,,And the only reason that that's possible is because
Dialogue: 0,0:07:58.86,0:08:18.97,Default,,0,0,0,,there are techniques for controlling the complexity of these large systems.
Dialogue: 0,0:08:20.30,0:08:22.69,Default,,0,0,0,,And these techniques that are controlling complexity
Dialogue: 0,0:08:22.72,0:08:24.17,Default,,0,0,0,,are what this course is really about.
Dialogue: 0,0:08:24.65,0:08:25.47,Default,,0,0,0,,And in some sense,
Dialogue: 0,0:08:25.50,0:08:27.47,Default,,0,0,0,,that's really what computer science is about.
Dialogue: 0,0:08:29.63,0:08:31.89,Default,,0,0,0,,Now, that may seem like a very strange thing to say.
Dialogue: 0,0:08:31.92,0:08:35.61,Default,,0,0,0,,Because after all, a lot of people besides computer scientists
Dialogue: 0,0:08:35.65,0:08:37.82,Default,,0,0,0,,deal with controlling complexity.
Dialogue: 0,0:08:37.84,0:08:41.02,Default,,0,0,0,,A large airliner is an extremely complex system,
Dialogue: 0,0:08:41.82,0:08:43.79,Default,,0,0,0,,and the aeronautical engineers who design that
Dialogue: 0,0:08:44.05,0:08:46.13,Default,,0,0,0,,are dealing with immense complexity.
Dialogue: 0,0:08:47.09,0:08:50.19,Default,,0,0,0,,But there's a difference between that kind of complexity
Dialogue: 0,0:08:50.75,0:08:52.60,Default,,0,0,0,,and what we deal with in computer science.
Dialogue: 0,0:08:55.18,0:08:57.73,Default,,0,0,0,,And that is that computer science,
Dialogue: 0,0:08:57.79,0:09:00.09,Default,,0,0,0,,in some sense, isn't real.
Dialogue: 0,0:09:02.69,0:09:06.62,Default,,0,0,0,,You see, when an engineer is designing a physical system,
Dialogue: 0,0:09:07.14,0:09:08.49,Default,,0,0,0,,that's made out of real parts.
Dialogue: 0,0:09:09.40,0:09:11.18,Default,,0,0,0,,The engineers who worry about that
Dialogue: 0,0:09:11.85,0:09:16.65,Default,,0,0,0,,have to address problems of tolerance and approximation and noise in the system.
Dialogue: 0,0:09:16.67,0:09:19.02,Default,,0,0,0,,So for example, as an electrical engineer,
Dialogue: 0,0:09:19.09,0:09:21.71,Default,,0,0,0,,I can go off and easily build a one-stage amplifier
Dialogue: 0,0:09:21.73,0:09:23.03,Default,,0,0,0,,or a two-stage amplifier,
Dialogue: 0,0:09:23.41,0:09:25.39,Default,,0,0,0,,and I can imagine cascading a lot of them
Dialogue: 0,0:09:25.45,0:09:26.91,Default,,0,0,0,,to build a million-stage amplifier.
Dialogue: 0,0:09:26.99,0:09:28.75,Default,,0,0,0,,But it's ridiculous to build such a thing,
Dialogue: 0,0:09:28.98,0:09:32.15,Default,,0,0,0,,because long before the millionth stage,
Dialogue: 0,0:09:32.16,0:09:34.56,Default,,0,0,0,,the thermal noise in those components way at the beginning
Dialogue: 0,0:09:34.57,0:09:36.80,Default,,0,0,0,,is going to get amplified and make the whole thing meaningless.
Dialogue: 0,0:09:39.10,0:09:43.12,Default,,0,0,0,,Computer science deals with idealized components.
Dialogue: 0,0:09:44.12,0:09:47.63,Default,,0,0,0,,We know as much as we want about these little program
Dialogue: 0,0:09:47.65,0:09:49.56,Default,,0,0,0,,and data pieces that we're fitting things together.
Dialogue: 0,0:09:51.90,0:09:53.20,Default,,0,0,0,,We don't have to worry about tolerance.
Dialogue: 0,0:09:53.21,0:09:56.99,Default,,0,0,0,,And that means that, in building a large program,
Dialogue: 0,0:09:58.13,0:10:00.03,Default,,0,0,0,,there's not all that much difference
Dialogue: 0,0:10:00.35,0:10:04.18,Default,,0,0,0,,between what I can build and what I can imagine,
Dialogue: 0,0:10:05.53,0:10:07.60,Default,,0,0,0,,because the parts are these abstract entities
Dialogue: 0,0:10:07.63,0:10:10.32,Default,,0,0,0,,that I know as much as I want.
Dialogue: 0,0:10:10.33,0:10:12.39,Default,,0,0,0,,I know about them as precisely as I'd like.
Dialogue: 0,0:10:13.45,0:10:15.50,Default,,0,0,0,,So as opposed to other kinds of engineering,
Dialogue: 0,0:10:15.66,0:10:17.42,Default,,0,0,0,,where the constraints on what you can build
Dialogue: 0,0:10:17.44,0:10:18.90,Default,,0,0,0,,are the constraints of physical systems,
Dialogue: 0,0:10:18.94,0:10:21.02,Default,,0,0,0,,the constraints of physics and noise and approximation,
Dialogue: 0,0:10:21.21,0:10:25.60,Default,,0,0,0,,the constraints imposed in building large software systems
Dialogue: 0,0:10:25.64,0:10:27.58,Default,,0,0,0,,are the limitations of our own minds.
Dialogue: 0,0:10:29.12,0:10:29.98,Default,,0,0,0,,So in that sense,
Dialogue: 0,0:10:30.00,0:10:33.67,Default,,0,0,0,,computer science is like an abstract form of engineering.
Dialogue: 0,0:10:33.80,0:10:35.73,Default,,0,0,0,,It's the kind of engineering where you ignore
Dialogue: 0,0:10:35.76,0:10:38.02,Default,,0,0,0,,the constraints that are imposed by reality.
Dialogue: 0,0:10:41.97,0:10:46.15,Default,,0,0,0,,Well, what are some of these techniques?
Dialogue: 0,0:10:46.28,0:10:48.39,Default,,0,0,0,,They're not special to computer science.
Dialogue: 0,0:10:50.39,0:10:52.55,Default,,0,0,0,,First technique, which is used in all of engineering,
Dialogue: 0,0:10:53.36,0:10:58.91,Default,,0,0,0,,is a kind of abstraction called black-box abstraction.
Dialogue: 0,0:11:07.71,0:11:12.58,Default,,0,0,0,,Take something and build a box about it.
Dialogue: 0,0:11:14.37,0:11:20.09,Default,,0,0,0,,Let's see, for example, if we looked at that square root method,
Dialogue: 0,0:11:22.64,0:11:28.53,Default,,0,0,0,,I might want to take that and build a box.
Dialogue: 0,0:11:29.89,0:11:37.52,Default,,0,0,0,,That sort of says, to find the square root of X.
Dialogue: 0,0:11:38.86,0:11:41.27,Default,,0,0,0,,And that might be a whole complicated set of rules.
Dialogue: 0,0:11:42.64,0:11:46.69,Default,,0,0,0,,And that might end up being a kind of thing where I can put in,
Dialogue: 0,0:11:46.81,0:11:50.06,Default,,0,0,0,,say, 36 and say, what's the square root of 36?
Dialogue: 0,0:11:50.25,0:11:51.46,Default,,0,0,0,,And out comes 6.
Dialogue: 0,0:11:53.89,0:11:56.22,Default,,0,0,0,,And the important thing is that
Dialogue: 0,0:11:56.24,0:12:00.03,Default,,0,0,0,,I'd like to design that so that
Dialogue: 0,0:12:00.06,0:12:04.08,Default,,0,0,0,,if George comes along and would like to compute,
Dialogue: 0,0:12:05.10,0:12:09.37,Default,,0,0,0,,say, the square root of A plus the square root of B,
Dialogue: 0,0:12:11.34,0:12:14.38,Default,,0,0,0,,he can take this thing and use it as a module
Dialogue: 0,0:12:14.43,0:12:15.74,Default,,0,0,0,,without having to look inside
Dialogue: 0,0:12:15.77,0:12:17.31,Default,,0,0,0,,and build something that looks like this,
Dialogue: 0,0:12:18.45,0:12:24.20,Default,,0,0,0,,like an A and a B and a square root box and another square root box
Dialogue: 0,0:12:24.53,0:12:33.87,Default,,0,0,0,,and then something that adds that would put out the answer.
Dialogue: 0,0:12:33.96,0:12:38.15,Default,,0,0,0,,And you can see, just from the fact that I want to do that,
Dialogue: 0,0:12:38.92,0:12:40.42,Default,,0,0,0,,is from George's point of view,
Dialogue: 0,0:12:40.51,0:12:43.10,Default,,0,0,0,,the internals of what's in here should not be important.
Dialogue: 0,0:12:44.19,0:12:47.25,Default,,0,0,0,,So for instance, it shouldn't matter that, when I wrote this,
Dialogue: 0,0:12:47.27,0:12:50.43,Default,,0,0,0,,I said I want to find the square root of X.
Dialogue: 0,0:12:50.61,0:12:52.27,Default,,0,0,0,,I could have said the square root of Y,
Dialogue: 0,0:12:52.72,0:12:55.62,Default,,0,0,0,,or the square root of A, or anything at all
Dialogue: 0,0:12:56.70,0:13:02.35,Default,,0,0,0,,That's the fundamental notion of putting something in a box
Dialogue: 0,0:13:03.53,0:13:06.44,Default,,0,0,0,,using black-box abstraction to suppress detail.
Dialogue: 0,0:13:07.60,0:13:10.99,Default,,0,0,0,,And the reason for that is you want to go off and build bigger boxes.
Dialogue: 0,0:13:12.05,0:13:14.57,Default,,0,0,0,,Now, there's another reason for doing black-box abstraction
Dialogue: 0,0:13:14.59,0:13:18.41,Default,,0,0,0,,other than you want to suppress detail for building bigger boxes.
Dialogue: 0,0:13:18.48,0:13:25.02,Default,,0,0,0,,Sometimes you want to say that your way of doing something,
Dialogue: 0,0:13:25.04,0:13:26.88,Default,,0,0,0,,your how-to method,
Dialogue: 0,0:13:28.44,0:13:30.79,Default,,0,0,0,,is an instance of a more general thing,
Dialogue: 0,0:13:31.16,0:13:34.57,Default,,0,0,0,,and you'd like your language to be able to express that generality.
Dialogue: 0,0:13:35.57,0:13:37.93,Default,,0,0,0,,Let me show you another example
Dialogue: 0,0:13:37.97,0:13:38.86,Default,,0,0,0,,sticking with square roots.
Dialogue: 0,0:13:38.89,0:13:42.16,Default,,0,0,0,,Let's go back and take another look at that slide
Dialogue: 0,0:13:42.19,0:13:43.75,Default,,0,0,0,,with the square root algorithm on it.
Dialogue: 0,0:13:44.16,0:13:45.62,Default,,0,0,0,,Remember what that says.
Dialogue: 0,0:13:45.79,0:13:49.82,Default,,0,0,0,,That says, in order to do something, I make a guess,
Dialogue: 0,0:13:50.62,0:13:54.84,Default,,0,0,0,,and I improve that guess, and I sort of keep improving that guess.
Dialogue: 0,0:13:55.66,0:14:00.14,Default,,0,0,0,,So there's the general strategy of, I'm looking for something,
Dialogue: 0,0:14:01.15,0:14:04.00,Default,,0,0,0,,and the way I find it is that I keep improving it.
Dialogue: 0,0:14:04.16,0:14:10.25,Default,,0,0,0,,Now, that's a particular case of another kind of strategy
Dialogue: 0,0:14:10.97,0:14:13.23,Default,,0,0,0,,for finding a fixed point of something.
Dialogue: 0,0:14:14.57,0:14:16.59,Default,,0,0,0,,So you have a fixed point of a function.
Dialogue: 0,0:14:17.13,0:14:26.03,Default,,0,0,0,,A fixed point of a function is something, is a value.
Dialogue: 0,0:14:26.13,0:14:31.79,Default,,0,0,0,,A fixed point of a function F is a value Y, such that F of Y equals Y.
Dialogue: 0,0:14:32.97,0:14:40.89,Default,,0,0,0,,And the way I might do that is start with a guess.
Dialogue: 0,0:14:42.00,0:14:45.85,Default,,0,0,0,,And then if I want something that doesn't change when I keep applying F,
Dialogue: 0,0:14:45.96,0:14:49.45,Default,,0,0,0,,is I'll keep applying F over and over until that result doesn't change very much.
Dialogue: 0,0:14:50.05,0:14:51.93,Default,,0,0,0,,So there's a general strategy.
Dialogue: 0,0:14:52.24,0:14:56.17,Default,,0,0,0,,And then, for example, to compute the square root of X,
Dialogue: 0,0:14:56.24,0:15:03.45,Default,,0,0,0,,I can try and find a fixed point of the function which takes Y to the average of X/Y.
Dialogue: 0,0:15:03.55,0:15:07.52,Default,,0,0,0,,And the idea that is that if I really had Y equal to the square root of X,
Dialogue: 0,0:15:08.01,0:15:11.80,Default,,0,0,0,,then Y and X/Y would be the same value.
Dialogue: 0,0:15:12.00,0:15:13.90,Default,,0,0,0,,They'd both be the square root of X,
Dialogue: 0,0:15:14.86,0:15:18.85,Default,,0,0,0,,because X over the square root of X is the square root of X.
Dialogue: 0,0:15:19.09,0:15:21.84,Default,,0,0,0,,And so the average if Y were equal to the square of X,
Dialogue: 0,0:15:22.25,0:15:25.21,Default,,0,0,0,,then the average wouldn't change.
Dialogue: 0,0:15:25.98,0:15:28.93,Default,,0,0,0,,So the square root of X is a fixed point of that particular function.
Dialogue: 0,0:15:30.09,0:15:33.85,Default,,0,0,0,,Now, what I'd like to have, I'd like to express
Dialogue: 0,0:15:33.98,0:15:36.42,Default,,0,0,0,,the general strategy for finding fixed points.
Dialogue: 0,0:15:36.57,0:15:40.13,Default,,0,0,0,,So what I might imagine doing, is to find,
Dialogue: 0,0:15:41.02,0:15:46.45,Default,,0,0,0,,is to be able to use my language to define a box that says "fixed point,"
Dialogue: 0,0:15:49.58,0:15:52.19,Default,,0,0,0,,just like I could make a box that says "square root."
Dialogue: 0,0:15:52.21,0:15:55.18,Default,,0,0,0,,And I'd like to be able to express this in my language.
Dialogue: 0,0:15:56.08,0:16:01.37,Default,,0,0,0,,So I'd like to express not only the imperative how-to knowledge
Dialogue: 0,0:16:01.42,0:16:03.21,Default,,0,0,0,,of a particular thing like square root,
Dialogue: 0,0:16:03.58,0:16:05.60,Default,,0,0,0,,but I'd like to be able to express the imperative knowledge
Dialogue: 0,0:16:05.66,0:16:08.27,Default,,0,0,0,,of how to do a general thing like how to find fixed point.
Dialogue: 0,0:16:09.82,0:16:12.25,Default,,0,0,0,,And in fact, let's go back and look at that slide again.
Dialogue: 0,0:16:15.02,0:16:23.28,Default,,0,0,0,,See, not only is this a piece of imperative knowledge,
Dialogue: 0,0:16:23.33,0:16:25.32,Default,,0,0,0,,how to find a fixed point,
Dialogue: 0,0:16:26.25,0:16:27.39,Default,,0,0,0,,but over here on the bottom,
Dialogue: 0,0:16:27.42,0:16:30.32,Default,,0,0,0,,there's another piece of imperative knowledge which says,
Dialogue: 0,0:16:30.41,0:16:35.85,Default,,0,0,0,,one way to compute square root is to apply this general fixed point method.
Dialogue: 0,0:16:36.17,0:16:38.89,Default,,0,0,0,,So I'd like to also be able to express that imperative knowledge.
Dialogue: 0,0:16:39.74,0:16:40.70,Default,,0,0,0,,What would that look like?
Dialogue: 0,0:16:40.73,0:16:44.90,Default,,0,0,0,,That would say, this fixed point box is such that
Dialogue: 0,0:16:45.76,0:16:58.21,Default,,0,0,0,,if I input to it the function that takes Y to the average of Y and X/Y,
Dialogue: 0,0:16:59.77,0:17:06.23,Default,,0,0,0,,then what should come out of that fixed point box is a method for finding square roots.
Dialogue: 0,0:17:08.91,0:17:10.24,Default,,0,0,0,,So in these boxes we're building,
Dialogue: 0,0:17:10.27,0:17:15.07,Default,,0,0,0,,we're not only building boxes that you input numbers and output numbers,
Dialogue: 0,0:17:16.40,0:17:18.54,Default,,0,0,0,,we're going to be building in boxes that,
Dialogue: 0,0:17:18.67,0:17:21.34,Default,,0,0,0,,in effect, compute methods like finding square root.
Dialogue: 0,0:17:22.22,0:17:25.85,Default,,0,0,0,,And my take is their inputs functions,
Dialogue: 0,0:17:26.49,0:17:29.29,Default,,0,0,0,,like Y goes to the average of Y and X/Y.
Dialogue: 0,0:17:29.71,0:17:31.49,Default,,0,0,0,,The reason we want to do that,
Dialogue: 0,0:17:32.21,0:17:35.60,Default,,0,0,0,,the reason this is a procedure, will end up being a procedure,
Dialogue: 0,0:17:35.63,0:17:38.61,Default,,0,0,0,,as we'll see, whose value is another procedure,
Dialogue: 0,0:17:39.31,0:17:41.10,Default,,0,0,0,,the reason we want to do that is because
Dialogue: 0,0:17:41.52,0:17:46.27,Default,,0,0,0,,procedures are going to be our ways of talking about imperative knowledge.
Dialogue: 0,0:17:48.00,0:17:49.93,Default,,0,0,0,,And the way to make that very powerful is
Dialogue: 0,0:17:49.93,0:17:52.13,Default,,0,0,0,,to be able to talk about other kinds of knowledge.
Dialogue: 0,0:17:53.42,0:17:56.52,Default,,0,0,0,,So here is a procedure that, in effect, talks about another procedure,
Dialogue: 0,0:17:57.10,0:18:00.34,Default,,0,0,0,,a general strategy that itself talks about general strategies.
Dialogue: 0,0:18:03.57,0:18:08.24,Default,,0,0,0,,Well, our first topic in this course--
Dialogue: 0,0:18:08.25,0:18:09.69,Default,,0,0,0,,there'll be three major topics--
Dialogue: 0,0:18:09.74,0:18:10.94,Default,,0,0,0,,will be black-box abstraction.
Dialogue: 0,0:18:10.97,0:18:13.31,Default,,0,0,0,,Let's look at that in a little bit more detail.
Dialogue: 0,0:18:15.12,0:18:24.04,Default,,0,0,0,,What we're going to do is we will start out talking about
Dialogue: 0,0:18:24.08,0:18:26.72,Default,,0,0,0,,how Lisp is built up out of primitive objects.
Dialogue: 0,0:18:27.36,0:18:29.20,Default,,0,0,0,,What does the language supply with us?
Dialogue: 0,0:18:29.49,0:18:33.58,Default,,0,0,0,,And we'll see that there are primitive procedures and primitive data.
Dialogue: 0,0:18:36.16,0:18:37.04,Default,,0,0,0,,Then we're going to see,
Dialogue: 0,0:18:37.05,0:18:38.77,Default,,0,0,0,,how do you take those primitives and
Dialogue: 0,0:18:38.81,0:18:40.76,Default,,0,0,0,,combine them to make more complicated things,
Dialogue: 0,0:18:41.45,0:18:42.92,Default,,0,0,0,,means of combination?
Dialogue: 0,0:18:43.20,0:18:46.30,Default,,0,0,0,,And what we'll see is that there are ways of putting things together,
Dialogue: 0,0:18:46.45,0:18:50.48,Default,,0,0,0,,putting primitive procedures together to make more complicated procedures.
Dialogue: 0,0:18:50.96,0:18:54.43,Default,,0,0,0,,And we'll see how to put primitive data together to make compound data.
Dialogue: 0,0:18:56.21,0:18:59.34,Default,,0,0,0,,Then we'll say, well, having made those compounds things,
Dialogue: 0,0:18:59.79,0:19:01.29,Default,,0,0,0,,how do you abstract them?
Dialogue: 0,0:19:02.91,0:19:04.97,Default,,0,0,0,,How do you put those black boxes around them
Dialogue: 0,0:19:05.04,0:19:07.73,Default,,0,0,0,,so you can use them as components in more complex things?
Dialogue: 0,0:19:08.16,0:19:10.93,Default,,0,0,0,,And we'll see that's done by defining procedures and
Dialogue: 0,0:19:11.52,0:19:14.79,Default,,0,0,0,,a technique for dealing with compound data called data abstraction.
Dialogue: 0,0:19:15.61,0:19:17.36,Default,,0,0,0,,And then, what's maybe the most important thing,
Dialogue: 0,0:19:17.92,0:19:21.49,Default,,0,0,0,,is going from just the rules to how does an expert work?
Dialogue: 0,0:19:21.61,0:19:27.12,Default,,0,0,0,,How do you express common patterns of doing things, like saying, well,
Dialogue: 0,0:19:27.15,0:19:28.64,Default,,0,0,0,,there's a general method of fixed point and
Dialogue: 0,0:19:28.69,0:19:30.87,Default,,0,0,0,,square root is a particular case of that?
Dialogue: 0,0:19:31.90,0:19:34.41,Default,,0,0,0,,And we're going to use--
Dialogue: 0,0:19:34.59,0:19:35.63,Default,,0,0,0,,I've already hinted at it--
Dialogue: 0,0:19:35.66,0:19:37.30,Default,,0,0,0,,something called higher-order procedures,
Dialogue: 0,0:19:37.34,0:19:42.05,Default,,0,0,0,,namely procedures whose inputs and outputs are themselves procedures.
Dialogue: 0,0:19:42.96,0:19:44.86,Default,,0,0,0,,And then we'll also see something very interesting.
Dialogue: 0,0:19:44.86,0:19:48.49,Default,,0,0,0,,We'll see, as we go further and further on and become more abstract,
Dialogue: 0,0:19:48.80,0:19:50.31,Default,,0,0,0,,there'll be very--
Dialogue: 0,0:19:50.43,0:19:53.61,Default,,0,0,0,,well, the line between what we consider to be data and
Dialogue: 0,0:19:53.63,0:19:57.80,Default,,0,0,0,,what we consider to be procedures is going to blur at an incredible rate.
Dialogue: 0,0:20:02.89,0:20:07.12,Default,,0,0,0,,Well, that's our first subject, black-box abstraction.
Dialogue: 0,0:20:07.12,0:20:08.62,Default,,0,0,0,,Let's look at the second topic.
Dialogue: 0,0:20:11.10,0:20:13.88,Default,,0,0,0,,I can introduce it like this.
Dialogue: 0,0:20:13.89,0:20:18.09,Default,,0,0,0,,See, suppose I want to express the idea--
Dialogue: 0,0:20:19.42,0:20:22.51,Default,,0,0,0,,remember, we're talking about ideas--
Dialogue: 0,0:20:22.91,0:20:25.53,Default,,0,0,0,,suppose I want to express the idea that
Dialogue: 0,0:20:26.41,0:20:35.12,Default,,0,0,0,,I can take something and multiply it by the sum of two other things.
Dialogue: 0,0:20:36.09,0:20:37.93,Default,,0,0,0,,So for example, I might say,
Dialogue: 0,0:20:38.11,0:20:41.52,Default,,0,0,0,,if I had 1 and 3 and multiply that by 2, I get 8.
Dialogue: 0,0:20:42.03,0:20:45.11,Default,,0,0,0,,But I'm talking about the general idea of what's called linear combination,
Dialogue: 0,0:20:45.44,0:20:47.98,Default,,0,0,0,,that you can add two things and multiply them by something else.
Dialogue: 0,0:20:49.28,0:20:51.01,Default,,0,0,0,,It's very easy when I think about it for numbers,
Dialogue: 0,0:20:51.05,0:20:55.41,Default,,0,0,0,,but suppose I also want to use that same idea to think about,
Dialogue: 0,0:20:56.08,0:20:58.58,Default,,0,0,0,,I could add two vectors, a1 and a2,
Dialogue: 0,0:20:59.89,0:21:03.26,Default,,0,0,0,,and then scale them by some factor x and get another vector.
Dialogue: 0,0:21:03.33,0:21:09.75,Default,,0,0,0,,Or I might say, I want to think about a1 and a2 as being polynomials,
Dialogue: 0,0:21:11.07,0:21:13.90,Default,,0,0,0,,and I might want to add those two polynomials and
Dialogue: 0,0:21:13.92,0:21:16.86,Default,,0,0,0,,then multiply them by 2 to get a more complicated one.
Dialogue: 0,0:21:20.16,0:21:23.83,Default,,0,0,0,,Or a1 and a2 might be electrical signals,
Dialogue: 0,0:21:24.56,0:21:27.77,Default,,0,0,0,,and I might want to think about summing those two electrical signals and
Dialogue: 0,0:21:27.81,0:21:30.27,Default,,0,0,0,,then putting the whole thing through an amplifier,
Dialogue: 0,0:21:30.28,0:21:33.03,Default,,0,0,0,,multiplying it by some factor of 2 or something.
Dialogue: 0,0:21:33.82,0:21:36.93,Default,,0,0,0,,The idea is I want to think about the general notion of that.
Dialogue: 0,0:21:38.32,0:21:45.42,Default,,0,0,0,,Now, if our language is going to be good language for expressing those kind of general ideas,
Dialogue: 0,0:21:47.07,0:21:49.31,Default,,0,0,0,,if I really, really can do that,
Dialogue: 0,0:21:50.65,0:21:52.09,Default,,0,0,0,,I'd like to be able to say
Dialogue: 0,0:21:54.99,0:22:00.41,Default,,0,0,0,,I'm going to multiply by x the sum of a1 and a2,
Dialogue: 0,0:22:02.80,0:22:05.07,Default,,0,0,0,,and I'd like that to express the general idea of
Dialogue: 0,0:22:06.03,0:22:09.23,Default,,0,0,0,,all different kinds of things that a1 and a2 could be.
Dialogue: 0,0:22:10.03,0:22:11.58,Default,,0,0,0,,Now, if you think about that, there's a problem,
Dialogue: 0,0:22:11.58,0:22:16.17,Default,,0,0,0,,because after all, the actual primitive operations
Dialogue: 0,0:22:16.21,0:22:18.33,Default,,0,0,0,,that go on in the machine are obviously going to be different
Dialogue: 0,0:22:18.38,0:22:22.98,Default,,0,0,0,,if I'm adding two numbers than if I'm adding two polynomials,
Dialogue: 0,0:22:23.29,0:22:27.49,Default,,0,0,0,,or if I'm adding the representation of two electrical signals or wave forms.
Dialogue: 0,0:22:27.89,0:22:32.53,Default,,0,0,0,,Somewhere, there has to be the knowledge of the kinds of various things
Dialogue: 0,0:22:32.87,0:22:34.25,Default,,0,0,0,,that you can add and the ways of adding them.
Dialogue: 0,0:22:37.09,0:22:38.64,Default,,0,0,0,,Now, to construct such a system,
Dialogue: 0,0:22:38.78,0:22:40.67,Default,,0,0,0,,the question is, where do I put that knowledge?
Dialogue: 0,0:22:41.20,0:22:44.41,Default,,0,0,0,,How do I think about the different kinds of choices I have?
Dialogue: 0,0:22:44.56,0:22:48.42,Default,,0,0,0,,And if tomorrow George comes up with a new kind of object
Dialogue: 0,0:22:48.45,0:22:50.32,Default,,0,0,0,,that might be added and multiplied,
Dialogue: 0,0:22:51.01,0:22:53.32,Default,,0,0,0,,how do I add George's new object to the system
Dialogue: 0,0:22:53.52,0:22:55.68,Default,,0,0,0,,without screwing up everything that was already there?
Dialogue: 0,0:22:57.81,0:23:00.54,Default,,0,0,0,,Well, that's going to be the second big topic,
Dialogue: 0,0:23:00.57,0:23:03.16,Default,,0,0,0,,the way of controlling that kind of complexity.
Dialogue: 0,0:23:03.84,0:23:08.43,Default,,0,0,0,,And the way you do that is by establishing conventional interfaces,
Dialogue: 0,0:23:17.44,0:23:20.21,Default,,0,0,0,,agreed upon ways of plugging things together.
Dialogue: 0,0:23:20.25,0:23:22.04,Default,,0,0,0,,Just like in electrical engineering,
Dialogue: 0,0:23:22.94,0:23:25.39,Default,,0,0,0,,people have standard impedances for connectors,
Dialogue: 0,0:23:26.16,0:23:28.62,Default,,0,0,0,,and then you know if you build something with one of those standard impedances,
Dialogue: 0,0:23:28.67,0:23:30.40,Default,,0,0,0,,you can plug it together with something else.
Dialogue: 0,0:23:32.78,0:23:35.68,Default,,0,0,0,,So that's going to be our second large topic, conventional interfaces.
Dialogue: 0,0:23:35.73,0:23:40.94,Default,,0,0,0,,What we're going to see is, first, we're going to talk about the problem of generic operations,
Dialogue: 0,0:23:40.97,0:23:42.22,Default,,0,0,0,,which is the one I alluded to,
Dialogue: 0,0:23:42.59,0:23:47.28,Default,,0,0,0,,things like "plus" that have to work with all different kinds of data.
Dialogue: 0,0:23:52.61,0:23:54.57,Default,,0,0,0,,So we talk about generic operations.
Dialogue: 0,0:23:54.61,0:23:56.99,Default,,0,0,0,,Then we're going to talk about really large-scale structures.
Dialogue: 0,0:23:58.32,0:24:00.83,Default,,0,0,0,,How do you put together very large programs
Dialogue: 0,0:24:01.02,0:24:04.89,Default,,0,0,0,,that model the kinds of complex systems in the real world that you'd like to model?
Dialogue: 0,0:24:05.53,0:24:06.53,Default,,0,0,0,,And what we're going to see is that
Dialogue: 0,0:24:06.57,0:24:11.81,Default,,0,0,0,,there are two very important metaphors for putting together such systems.
Dialogue: 0,0:24:11.85,0:24:13.90,Default,,0,0,0,,One is called object-oriented programming,
Dialogue: 0,0:24:14.09,0:24:18.94,Default,,0,0,0,,where you sort of think of your system as a kind of society
Dialogue: 0,0:24:19.37,0:24:22.36,Default,,0,0,0,,full of little things that interact by sending information between them.
Dialogue: 0,0:24:23.44,0:24:27.81,Default,,0,0,0,,And then the second one is operations on aggregates, called streams,
Dialogue: 0,0:24:27.98,0:24:31.50,Default,,0,0,0,,where you think of a large system put together kind of
Dialogue: 0,0:24:31.50,0:24:35.29,Default,,0,0,0,,like a signal processing engineer puts together a large electrical system.
Dialogue: 0,0:24:38.93,0:24:40.49,Default,,0,0,0,,That's going to be our second topic.
Dialogue: 0,0:24:43.37,0:24:45.93,Default,,0,0,0,,Now, the third thing we're going to come to,
Dialogue: 0,0:24:45.95,0:24:49.70,Default,,0,0,0,,the third basic technique for controlling complexity,
Dialogue: 0,0:24:49.74,0:24:50.94,Default,,0,0,0,,is making new languages.
Dialogue: 0,0:24:51.69,0:24:55.42,Default,,0,0,0,,Because sometimes, when you're sort of overwhelmed by the complexity of a design,
Dialogue: 0,0:24:55.47,0:24:59.69,Default,,0,0,0,,the way that you control that complexity is to pick a new design language.
Dialogue: 0,0:25:01.41,0:25:05.60,Default,,0,0,0,,And the purpose of the new design language will be to highlight different aspects of the system.
Dialogue: 0,0:25:05.79,0:25:09.36,Default,,0,0,0,,It will suppress some kinds of details and emphasize other kinds of details.
Dialogue: 0,0:25:12.99,0:25:15.93,Default,,0,0,0,,This is going to be the most magical part of the course.
Dialogue: 0,0:25:16.03,0:25:21.20,Default,,0,0,0,,We're going to start out by actually looking at the technology for building new computer languages.
Dialogue: 0,0:25:21.82,0:25:26.30,Default,,0,0,0,,The first thing we're going to do is actually build in Lisp.
Dialogue: 0,0:25:29.23,0:25:34.02,Default,,0,0,0,,We're going to express in Lisp the process of interpreting Lisp itself.
Dialogue: 0,0:25:34.29,0:25:36.94,Default,,0,0,0,,And that's going to be a very sort of self-circular thing.
Dialogue: 0,0:25:36.96,0:25:39.92,Default,,0,0,0,,There's a little mystical symbol that has to do with that.
Dialogue: 0,0:25:40.97,0:25:46.38,Default,,0,0,0,,The process of interpreting Lisp is sort of a giant wheel of two processes,
Dialogue: 0,0:25:46.57,0:25:47.71,Default,,0,0,0,,apply and eval,
Dialogue: 0,0:25:47.89,0:25:50.87,Default,,0,0,0,,which sort of constantly reduce expressions to each other.
Dialogue: 0,0:25:52.54,0:25:54.24,Default,,0,0,0,,Then we're going to see all sorts of other magical things.
Dialogue: 0,0:25:54.25,0:25:56.85,Default,,0,0,0,,Here's another magical symbol.
Dialogue: 0,0:25:57.12,0:26:01.52,Default,,0,0,0,,This is sort of the Y operator,
Dialogue: 0,0:26:01.55,0:26:06.45,Default,,0,0,0,,which is, in some sense, the expression of infinity inside our procedural language.
Dialogue: 0,0:26:06.51,0:26:07.44,Default,,0,0,0,,We'll take a look at that.
Dialogue: 0,0:26:08.40,0:26:13.73,Default,,0,0,0,,In any case, this section of the course is called Metalinguistic Abstraction,
Dialogue: 0,0:26:16.17,0:26:26.23,Default,,0,0,0,,abstracting by talking about how you construct new languages.
Dialogue: 0,0:26:30.22,0:26:35.71,Default,,0,0,0,,As I said, we're going to start out by looking at the process of interpretation.
Dialogue: 0,0:26:35.74,0:26:42.12,Default,,0,0,0,,We're going to look at this apply-eval loop, and build Lisp.
Dialogue: 0,0:26:42.16,0:26:44.17,Default,,0,0,0,,Then, just to show you that this is very general,
Dialogue: 0,0:26:44.37,0:26:48.26,Default,,0,0,0,,we're going to use exactly the same technology to build a very different kind of language,
Dialogue: 0,0:26:48.53,0:26:50.31,Default,,0,0,0,,a so-called logic programming language,
Dialogue: 0,0:26:50.53,0:26:54.83,Default,,0,0,0,,where you don't really talk about procedures at all that have inputs and outputs.
Dialogue: 0,0:26:54.86,0:26:57.25,Default,,0,0,0,,What you do is talk about relations between things.
Dialogue: 0,0:26:57.31,0:27:03.92,Default,,0,0,0,,And then finally, we're going to talk about how you implement these things very concretely
Dialogue: 0,0:27:03.95,0:27:05.60,Default,,0,0,0,,on the very simplest kind of machines.
Dialogue: 0,0:27:05.65,0:27:08.39,Default,,0,0,0,,We'll see something like this.
Dialogue: 0,0:27:09.13,0:27:12.14,Default,,0,0,0,,This is a picture of a chip,
Dialogue: 0,0:27:12.16,0:27:17.47,Default,,0,0,0,,which is the Lisp interpreter that we will be talking about then in hardware.
Dialogue: 0,0:27:20.88,0:27:23.79,Default,,0,0,0,,Well, there's an outline of the course, three big topics.
Dialogue: 0,0:27:24.88,0:27:29.41,Default,,0,0,0,,Black-box abstraction, conventional interfaces, metalinguistic abstraction.
Dialogue: 0,0:27:31.58,0:27:33.57,Default,,0,0,0,,Now, let's take a break now and then we'll get started.
Dialogue: 0,0:27:52.19,0:28:03.42,Default,,0,0,0,,[JESU, JOY OF MAN'S DESIRING]
Dialogue: 0,0:28:03.92,0:28:06.84,Default,,0,0,0,,Let's actually start in learning Lisp now.
Dialogue: 0,0:28:08.06,0:28:10.75,Default,,0,0,0,,Actually, we'll start out by learning something much more important,
Dialogue: 0,0:28:10.80,0:28:14.33,Default,,0,0,0,,maybe the very most important thing in this course, which is not Lisp,
Dialogue: 0,0:28:14.38,0:28:18.41,Default,,0,0,0,,in particular, of course, but rather a general framework
Dialogue: 0,0:28:18.62,0:28:21.89,Default,,0,0,0,,for thinking about languages that I already alluded to.
Dialogue: 0,0:28:22.12,0:28:25.10,Default,,0,0,0,,When somebody tells you they're going to show you a language,
Dialogue: 0,0:28:25.13,0:28:26.16,Default,,0,0,0,,what you should say is,
Dialogue: 0,0:28:26.19,0:28:32.87,Default,,0,0,0,,what I'd like you to tell me is what are the primitive elements?
Dialogue: 0,0:28:37.50,0:28:38.78,Default,,0,0,0,,What does the language come with?
Dialogue: 0,0:28:38.96,0:28:43.53,Default,,0,0,0,,Then, what are the ways you put those together?
Dialogue: 0,0:28:43.68,0:28:47.42,Default,,0,0,0,,What are the means of combination?
Dialogue: 0,0:28:50.17,0:28:54.18,Default,,0,0,0,,What are the things that allow you to take these primitive elements
Dialogue: 0,0:28:54.37,0:28:56.51,Default,,0,0,0,,and build bigger things out of them?
Dialogue: 0,0:28:58.01,0:28:59.61,Default,,0,0,0,,What are the ways of putting things together?
Dialogue: 0,0:29:01.39,0:29:05.69,Default,,0,0,0,,And then, what are the means of abstraction?
Dialogue: 0,0:29:08.35,0:29:16.85,Default,,0,0,0,,How do we take those complicated things and draw those boxes around them?
Dialogue: 0,0:29:16.88,0:29:19.66,Default,,0,0,0,,How do we name them so that we can now use them
Dialogue: 0,0:29:19.68,0:29:23.85,Default,,0,0,0,,as if they were primitive elements in making still more complex things?
Dialogue: 0,0:29:23.89,0:29:25.66,Default,,0,0,0,,And so on, and so on, and so on.
Dialogue: 0,0:29:26.89,0:29:28.08,Default,,0,0,0,,So when someone says to you, gee,
Dialogue: 0,0:29:28.09,0:29:29.55,Default,,0,0,0,,I have a great new computer language,
Dialogue: 0,0:29:30.86,0:29:34.70,Default,,0,0,0,,you don't say, how many characters does it take to invert a matrix?
Dialogue: 0,0:29:35.73,0:29:36.88,Default,,0,0,0,,It's irrelevant.
Dialogue: 0,0:29:37.39,0:29:42.30,Default,,0,0,0,,What you say is, if the language did not come with matrices built in
Dialogue: 0,0:29:42.33,0:29:43.37,Default,,0,0,0,,or with something else built in,
Dialogue: 0,0:29:43.37,0:29:46.03,Default,,0,0,0,,how could I then build that thing?
Dialogue: 0,0:29:46.05,0:29:48.47,Default,,0,0,0,,What are the means of combination which would allow me to do that?
Dialogue: 0,0:29:48.62,0:29:50.71,Default,,0,0,0,,And then, what are the means of abstraction
Dialogue: 0,0:29:51.68,0:29:54.21,Default,,0,0,0,,which allow me then to use those as elements
Dialogue: 0,0:29:54.22,0:29:56.52,Default,,0,0,0,,in making more complicated things yet?
Dialogue: 0,0:29:58.75,0:30:04.61,Default,,0,0,0,,Well, we're going to see that Lisp has some primitive data and some primitive procedures.
Dialogue: 0,0:30:05.25,0:30:07.50,Default,,0,0,0,,In fact, let's really start.
Dialogue: 0,0:30:07.55,0:30:14.89,Default,,0,0,0,,And here's a piece of primitive data in Lisp, number 3.
Dialogue: 0,0:30:16.27,0:30:19.87,Default,,0,0,0,,Actually, if I'm being very pedantic, that's not the number 3.
Dialogue: 0,0:30:19.93,0:30:25.57,Default,,0,0,0,,That's some symbol that represents Plato's concept of the number 3.
Dialogue: 0,0:30:26.67,0:30:28.93,Default,,0,0,0,,And here's another.
Dialogue: 0,0:30:30.48,0:30:36.06,Default,,0,0,0,,Here's some more primitive data in Lisp, 17.4.
Dialogue: 0,0:30:36.08,0:30:39.42,Default,,0,0,0,,Or actually, some representation of 17.4.
Dialogue: 0,0:30:40.99,0:30:44.48,Default,,0,0,0,,And here's another one, 5.
Dialogue: 0,0:30:46.86,0:30:52.21,Default,,0,0,0,,Here's another primitive object that's built in Lisp, addition.
Dialogue: 0,0:30:52.25,0:30:55.68,Default,,0,0,0,,Actually, to use the same kind of pedantic--
Dialogue: 0,0:30:55.71,0:31:00.47,Default,,0,0,0,,this is a name for the primitive method of adding things.
Dialogue: 0,0:31:00.53,0:31:02.53,Default,,0,0,0,,Just like this is a name for Plato's number 3,
Dialogue: 0,0:31:02.61,0:31:09.32,Default,,0,0,0,,this is a name for Plato's concept of how you add things.
Dialogue: 0,0:31:10.32,0:31:11.98,Default,,0,0,0,,So those are some primitive elements.
Dialogue: 0,0:31:12.14,0:31:13.76,Default,,0,0,0,,I can put them together.
Dialogue: 0,0:31:14.14,0:31:18.29,Default,,0,0,0,,I can say, gee, what's the sum of 3 and 17.4 and 5?
Dialogue: 0,0:31:18.69,0:31:21.31,Default,,0,0,0,,And the way I do that is to say,
Dialogue: 0,0:31:21.33,0:31:27.71,Default,,0,0,0,,let's apply the sum operator to these three numbers.
Dialogue: 0,0:31:27.74,0:31:31.15,Default,,0,0,0,,And I should get, what? 8, 17. 25.4.
Dialogue: 0,0:31:34.43,0:31:38.05,Default,,0,0,0,,So I should be able to ask Lisp what the value of this is,
Dialogue: 0,0:31:38.94,0:31:40.77,Default,,0,0,0,,and it will return 25.4.
Dialogue: 0,0:31:43.58,0:31:44.83,Default,,0,0,0,,Let's introduce some names.
Dialogue: 0,0:31:44.88,0:31:51.47,Default,,0,0,0,,This thing that I typed is called a combination.
Dialogue: 0,0:31:56.88,0:32:01.94,Default,,0,0,0,,And a combination consists, in general, of applying an operator--
Dialogue: 0,0:32:03.39,0:32:04.72,Default,,0,0,0,,so this is an operator--
Dialogue: 0,0:32:09.71,0:32:12.05,Default,,0,0,0,,to some operands.
Dialogue: 0,0:32:13.25,0:32:14.54,Default,,0,0,0,,These are the operands.
Dialogue: 0,0:32:21.89,0:32:23.79,Default,,0,0,0,,And of course, I can make more complex things.
Dialogue: 0,0:32:23.82,0:32:28.56,Default,,0,0,0,,The reason I can get complexity out of this is because the operands themselves,
Dialogue: 0,0:32:29.52,0:32:31.09,Default,,0,0,0,,in general, can be combinations.
Dialogue: 0,0:32:31.15,0:32:44.47,Default,,0,0,0,,So for instance, I could say, what is the sum of 3 and the product of 5 and 6 and 8 and 2?
Dialogue: 0,0:32:45.66,0:32:52.16,Default,,0,0,0,,And I should get-- let's see-- 30, 40, 43.
Dialogue: 0,0:32:52.73,0:32:54.81,Default,,0,0,0,,So Lisp should tell me that that's 43.
Dialogue: 0,0:32:56.56,0:33:02.80,Default,,0,0,0,,Forming combinations is the basic needs of combination that we'll be looking at.
Dialogue: 0,0:33:04.65,0:33:09.22,Default,,0,0,0,,And then, well, you see some syntax here.
Dialogue: 0,0:33:10.56,0:33:13.04,Default,,0,0,0,,Lisp uses what's called prefix notation,
Dialogue: 0,0:33:16.22,0:33:25.21,Default,,0,0,0,,which means that the operator is written to the left of the operands.
Dialogue: 0,0:33:25.47,0:33:26.48,Default,,0,0,0,,It's just a convention.
Dialogue: 0,0:33:27.66,0:33:29.77,Default,,0,0,0,,And notice, it's fully parenthesized.
Dialogue: 0,0:33:30.08,0:33:32.32,Default,,0,0,0,,And the parentheses make it completely unambiguous.
Dialogue: 0,0:33:32.32,0:33:36.99,Default,,0,0,0,,So by looking at this, I can see that there's the operator,
Dialogue: 0,0:33:37.01,0:33:40.99,Default,,0,0,0,,and there are 1, 2, 3, 4 operands.
Dialogue: 0,0:33:42.38,0:33:47.97,Default,,0,0,0,,And I can see that the second operand here is itself some combination
Dialogue: 0,0:33:48.88,0:33:51.55,Default,,0,0,0,,that has one operator and two operands.
Dialogue: 0,0:33:52.43,0:33:54.27,Default,,0,0,0,,Parentheses in Lisp are a little bit,
Dialogue: 0,0:33:54.61,0:33:57.71,Default,,0,0,0,,or are very unlike parentheses in conventional mathematics.
Dialogue: 0,0:33:57.77,0:34:00.11,Default,,0,0,0,,In mathematics, we sort of use them to mean grouping,
Dialogue: 0,0:34:01.21,0:34:03.75,Default,,0,0,0,,and it sort of doesn't hurt if sometimes you leave out parentheses
Dialogue: 0,0:34:03.77,0:34:05.56,Default,,0,0,0,,if people understand that that's a group.
Dialogue: 0,0:34:05.76,0:34:08.51,Default,,0,0,0,,And in general, it doesn't hurt if you put in extra parentheses,
Dialogue: 0,0:34:08.86,0:34:10.94,Default,,0,0,0,,because that maybe makes the grouping more distinct.
Dialogue: 0,0:34:10.96,0:34:11.77,Default,,0,0,0,,Lisp is not like that.
Dialogue: 0,0:34:13.12,0:34:15.37,Default,,0,0,0,,In Lisp, you cannot leave out parentheses,
Dialogue: 0,0:34:16.38,0:34:18.56,Default,,0,0,0,,and you cannot put in extra parentheses,
Dialogue: 0,0:34:19.33,0:34:21.28,Default,,0,0,0,,because putting in parentheses always means,
Dialogue: 0,0:34:21.37,0:34:27.05,Default,,0,0,0,,exactly and precisely, this is a combination which has meaning,
Dialogue: 0,0:34:27.09,0:34:28.81,Default,,0,0,0,,applying operators to operands.
Dialogue: 0,0:34:29.04,0:34:32.62,Default,,0,0,0,,And if I left this out, if I left those parentheses out,
Dialogue: 0,0:34:32.65,0:34:33.96,Default,,0,0,0,,it would mean something else.
Dialogue: 0,0:34:35.41,0:34:37.25,Default,,0,0,0,,In fact, the way to think about this,
Dialogue: 0,0:34:37.41,0:34:41.65,Default,,0,0,0,,is really what I'm doing when I write something like this is writing a tree.
Dialogue: 0,0:34:42.37,0:34:47.30,Default,,0,0,0,,So this combination is a tree that has a plus and
Dialogue: 0,0:34:47.37,0:34:54.46,Default,,0,0,0,,then a 3 and then a something else and an 8 and a 2.
Dialogue: 0,0:34:54.48,0:34:56.35,Default,,0,0,0,,And then this something else here is
Dialogue: 0,0:34:56.35,0:35:03.22,Default,,0,0,0,,itself a little subtree that has a star and a 5 and a 6.
Dialogue: 0,0:35:03.95,0:35:05.53,Default,,0,0,0,,And the way to think of that is, really,
Dialogue: 0,0:35:05.55,0:35:09.00,Default,,0,0,0,,what's going on are we're writing these trees,
Dialogue: 0,0:35:09.21,0:35:15.10,Default,,0,0,0,,and parentheses are just a way to write this two-dimensional structure
Dialogue: 0,0:35:15.79,0:35:17.34,Default,,0,0,0,,as a linear character string.
Dialogue: 0,0:35:19.23,0:35:23.81,Default,,0,0,0,,Because at least when Lisp first started and people had teletypes or punch cards or whatever,
Dialogue: 0,0:35:24.17,0:35:25.60,Default,,0,0,0,,this was more convenient.
Dialogue: 0,0:35:25.97,0:35:30.52,Default,,0,0,0,,Maybe if Lisp started today, the syntax of Lisp would look like that.
Dialogue: 0,0:35:31.76,0:35:35.07,Default,,0,0,0,,Well, let's look at what that actually looks like on the computer.
Dialogue: 0,0:35:36.29,0:35:39.37,Default,,0,0,0,,Here I have a Lisp interaction set up.
Dialogue: 0,0:35:39.41,0:35:40.43,Default,,0,0,0,,There's a editor.
Dialogue: 0,0:35:41.13,0:35:44.86,Default,,0,0,0,,And on the top, I'm going to type some values and ask Lisp what they are.
Dialogue: 0,0:35:45.12,0:35:46.75,Default,,0,0,0,,So for instance, I can say to Lisp,
Dialogue: 0,0:35:46.83,0:35:48.53,Default,,0,0,0,,what's the value of that symbol?
Dialogue: 0,0:35:49.44,0:35:50.50,Default,,0,0,0,,That's 3.
Dialogue: 0,0:35:50.57,0:35:52.20,Default,,0,0,0,,And I ask Lisp to evaluate it.
Dialogue: 0,0:35:52.32,0:35:54.77,Default,,0,0,0,,And there you see Lisp has returned on the bottom,
Dialogue: 0,0:35:55.39,0:35:56.84,Default,,0,0,0,,and said, oh yeah, that's 3.
Dialogue: 0,0:35:57.58,0:36:04.96,Default,,0,0,0,,Or I can say, what's the sum of 3 and 4 and 8?
Dialogue: 0,0:36:06.45,0:36:08.05,Default,,0,0,0,,What's that combination?
Dialogue: 0,0:36:08.93,0:36:10.66,Default,,0,0,0,,And ask Lisp to evaluate it.
Dialogue: 0,0:36:14.49,0:36:15.68,Default,,0,0,0,,That's 15.
Dialogue: 0,0:36:16.57,0:36:18.80,Default,,0,0,0,,Or I can type in something more complicated.
Dialogue: 0,0:36:19.25,0:36:34.14,Default,,0,0,0,,I can say, what's the sum of the product of 3 and the sum of 7 and 19.5?
Dialogue: 0,0:36:35.21,0:36:38.00,Default,,0,0,0,,And you'll notice here that Lisp has something built in
Dialogue: 0,0:36:38.01,0:36:39.76,Default,,0,0,0,,that helps me keep track of all these parentheses.
Dialogue: 0,0:36:39.77,0:36:42.13,Default,,0,0,0,,Watch as I type the next closed parentheses,
Dialogue: 0,0:36:42.21,0:36:45.01,Default,,0,0,0,,which is going to close the combination starting with the star.
Dialogue: 0,0:36:45.52,0:36:47.30,Default,,0,0,0,,The opening one will flash.
Dialogue: 0,0:36:47.76,0:36:49.69,Default,,0,0,0,,Here, I'll rub those out and do it again.
Dialogue: 0,0:36:50.14,0:36:52.70,Default,,0,0,0,,Type close, and you see that closes the plus.
Dialogue: 0,0:36:53.58,0:36:56.41,Default,,0,0,0,,Close again, that closes the star.
Dialogue: 0,0:36:57.90,0:37:00.76,Default,,0,0,0,,Now I'm back to the sum, and maybe I'm going to add that all to 4.
Dialogue: 0,0:37:01.66,0:37:02.69,Default,,0,0,0,,That closes the plus.
Dialogue: 0,0:37:02.73,0:37:07.07,Default,,0,0,0,,Now I have a complete combination, and I can ask Lisp for the value of that.
Dialogue: 0,0:37:07.26,0:37:11.66,Default,,0,0,0,,That kind of paren balancing is something that's built into
Dialogue: 0,0:37:11.76,0:37:13.29,Default,,0,0,0,,a lot of Lisp systems to help you keep track,
Dialogue: 0,0:37:13.36,0:37:16.55,Default,,0,0,0,,because it is kind of hard just by hand doing all these parentheses.
Dialogue: 0,0:37:16.81,0:37:21.20,Default,,0,0,0,,There's another kind of convention for keeping track of parentheses.
Dialogue: 0,0:37:21.25,0:37:23.68,Default,,0,0,0,,Let me write another complicated combination.
Dialogue: 0,0:37:24.77,0:37:34.00,Default,,0,0,0,,Let's take the sum of the product of 3 and 5 and add that to something.
Dialogue: 0,0:37:34.03,0:37:35.23,Default,,0,0,0,,And now what I'm going to do is
Dialogue: 0,0:37:35.28,0:37:39.85,Default,,0,0,0,,I'm going to indent so that the operands are written vertically.
Dialogue: 0,0:37:40.30,0:37:45.65,Default,,0,0,0,,Which the sum of that and the product of 47 and--
Dialogue: 0,0:37:47.02,0:37:54.59,Default,,0,0,0,,let's say the product of 47 with a difference of 20 and 6.8.
Dialogue: 0,0:37:54.62,0:37:57.09,Default,,0,0,0,,That means subtract 6.8 from 20.
Dialogue: 0,0:37:58.97,0:38:00.19,Default,,0,0,0,,And then you see the parentheses close.
Dialogue: 0,0:38:00.22,0:38:03.47,Default,,0,0,0,,Close the minus. Close the star.
Dialogue: 0,0:38:03.76,0:38:05.42,Default,,0,0,0,,And now let's get another operator.
Dialogue: 0,0:38:05.44,0:38:09.49,Default,,0,0,0,,You see the Lisp editor here is indenting to the right position automatically
Dialogue: 0,0:38:10.40,0:38:11.50,Default,,0,0,0,,to help me keep track.
Dialogue: 0,0:38:12.61,0:38:14.09,Default,,0,0,0,,I'll do that again.
Dialogue: 0,0:38:14.13,0:38:15.89,Default,,0,0,0,,I'll close that last parentheses again.
Dialogue: 0,0:38:16.25,0:38:17.71,Default,,0,0,0,,You see it balances the plus.
Dialogue: 0,0:38:20.40,0:38:22.64,Default,,0,0,0,,Now I can say, what's the value of that?
Dialogue: 0,0:38:23.87,0:38:29.28,Default,,0,0,0,,So those two things, indenting to the right level,
Dialogue: 0,0:38:29.31,0:38:30.86,Default,,0,0,0,,which is called pretty printing,
Dialogue: 0,0:38:31.55,0:38:33.58,Default,,0,0,0,,and flashing parentheses,
Dialogue: 0,0:38:33.89,0:38:37.73,Default,,0,0,0,,are two things that a lot of Lisp systems have built in to help you keep track.
Dialogue: 0,0:38:37.76,0:38:39.01,Default,,0,0,0,,And you should learn how to use them.
Dialogue: 0,0:38:41.52,0:38:43.17,Default,,0,0,0,,Ok, those are the primitives.
Dialogue: 0,0:38:44.73,0:38:46.31,Default,,0,0,0,,There's a means of combination.
Dialogue: 0,0:38:46.33,0:38:47.93,Default,,0,0,0,,Now let's go up to the means of abstraction.
Dialogue: 0,0:38:49.44,0:38:53.84,Default,,0,0,0,,I'd like to be able to take the idea that I do some combination like this,
Dialogue: 0,0:38:53.85,0:38:55.77,Default,,0,0,0,,and abstract it and give it a simple name,
Dialogue: 0,0:38:55.81,0:38:57.26,Default,,0,0,0,,so I can use that as an element.
Dialogue: 0,0:38:57.31,0:38:59.92,Default,,0,0,0,,And I do that in Lisp with "define."
Dialogue: 0,0:39:01.17,0:39:02.43,Default,,0,0,0,,So I can say, for example,
Dialogue: 0,0:39:02.73,0:39:15.05,Default,,0,0,0,,define A to be the product of 5 and 5.
Dialogue: 0,0:39:18.40,0:39:22.35,Default,,0,0,0,,And now I could say, for example, to Lisp,
Dialogue: 0,0:39:22.38,0:39:26.01,Default,,0,0,0,,what is the product of A and A?
Dialogue: 0,0:39:27.18,0:39:29.81,Default,,0,0,0,,And this should be 25, and this should be 625.
Dialogue: 0,0:39:31.97,0:39:36.01,Default,,0,0,0,,And then, crucial thing, I can now use A--
Dialogue: 0,0:39:36.21,0:39:37.92,Default,,0,0,0,,here I've used it in a combination--
Dialogue: 0,0:39:38.41,0:39:43.55,Default,,0,0,0,,but I could use that in other more complicated things that I name in turn.
Dialogue: 0,0:39:43.58,0:39:50.93,Default,,0,0,0,,So I could say, define B to be the sum of,
Dialogue: 0,0:39:50.97,0:39:57.45,Default,,0,0,0,,we'll say, A and the product of 5 and A.
Dialogue: 0,0:39:59.44,0:40:00.72,Default,,0,0,0,,And then close the plus.
Dialogue: 0,0:40:03.45,0:40:05.85,Default,,0,0,0,,Let's take a look at that on the computer and see how that looks.
Dialogue: 0,0:40:07.28,0:40:10.68,Default,,0,0,0,,So I'll just type what I wrote on the board.
Dialogue: 0,0:40:10.83,0:40:21.73,Default,,0,0,0,,I could say, define A to be the product of 5 and 5.
Dialogue: 0,0:40:23.74,0:40:25.38,Default,,0,0,0,,And I'll tell that to Lisp.
Dialogue: 0,0:40:25.52,0:40:28.94,Default,,0,0,0,,And notice what Lisp responded there with was an A in the bottom.
Dialogue: 0,0:40:29.09,0:40:31.38,Default,,0,0,0,,In general, when you type in a definition in Lisp,
Dialogue: 0,0:40:31.50,0:40:35.02,Default,,0,0,0,,it responds with the symbol being defined.
Dialogue: 0,0:40:35.63,0:40:39.66,Default,,0,0,0,,Now I could say to Lisp, what is the product of A and A?
Dialogue: 0,0:40:42.81,0:40:44.33,Default,,0,0,0,,And it says that's 625.
Dialogue: 0,0:40:46.05,0:41:00.34,Default,,0,0,0,,I can define B to be the sum of A and the product of 5 and A.
Dialogue: 0,0:41:00.48,0:41:05.70,Default,,0,0,0,,Close a paren closes the star. Close the plus. Close the "define."
Dialogue: 0,0:41:07.63,0:41:10.37,Default,,0,0,0,,Lisp says, OK, B, there on the bottom.
Dialogue: 0,0:41:11.04,0:41:13.24,Default,,0,0,0,,And now I can say to Lisp, what's the value of B?
Dialogue: 0,0:41:17.18,0:41:18.88,Default,,0,0,0,,And I can say something more complicated,
Dialogue: 0,0:41:18.93,0:41:26.69,Default,,0,0,0,,like what's the sum of A and the quotient of B and 5?
Dialogue: 0,0:41:26.73,0:41:30.25,Default,,0,0,0,,That slash is divide, another primitive operator.
Dialogue: 0,0:41:30.38,0:41:32.78,Default,,0,0,0,,I've divided B by 5, added it to A.
Dialogue: 0,0:41:33.65,0:41:35.23,Default,,0,0,0,,Lisp says, OK, that's 55.
Dialogue: 0,0:41:36.57,0:41:37.92,Default,,0,0,0,,So there's what it looks like.
Dialogue: 0,0:41:39.82,0:41:43.40,Default,,0,0,0,,There's the basic means of defining something.
Dialogue: 0,0:41:43.44,0:41:49.02,Default,,0,0,0,,It's the simplest kind of naming, but it's not really very powerful.
Dialogue: 0,0:41:50.06,0:41:51.60,Default,,0,0,0,,See, what I'd really like to name--
Dialogue: 0,0:41:51.84,0:41:53.37,Default,,0,0,0,,remember, we're talking about general methods--
Dialogue: 0,0:41:53.57,0:41:57.68,Default,,0,0,0,,I'd like to name, oh, the general idea that, for example,
Dialogue: 0,0:41:58.11,0:42:17.53,Default,,0,0,0,,I could multiply 5 by 5, or 6 by 6, or 1,001 by 1,001, 1,001.7 by 1,001.7.
Dialogue: 0,0:42:17.76,0:42:24.16,Default,,0,0,0,,I'd like to be able to name the general idea of multiplying something by itself.
Dialogue: 0,0:42:28.48,0:42:30.11,Default,,0,0,0,,Well, you know what that is. That's called squaring.
Dialogue: 0,0:42:31.69,0:42:35.63,Default,,0,0,0,,And the way I can do that in Lisp is I can say,
Dialogue: 0,0:42:37.97,0:42:56.25,Default,,0,0,0,,define to square something x, multiply x by itself.
Dialogue: 0,0:42:57.87,0:43:01.12,Default,,0,0,0,,And then having done that, I could say to Lisp,
Dialogue: 0,0:43:01.12,0:43:05.49,Default,,0,0,0,,for example, what's the square of 10?
Dialogue: 0,0:43:06.67,0:43:07.87,Default,,0,0,0,,And Lisp will say 100.
Dialogue: 0,0:43:10.70,0:43:14.24,Default,,0,0,0,,So now let's actually look at that a little more closely.
Dialogue: 0,0:43:15.29,0:43:16.88,Default,,0,0,0,,Right, there's the definition of square.
Dialogue: 0,0:43:17.50,0:43:22.55,Default,,0,0,0,,To square something, multiply it by itself.
Dialogue: 0,0:43:23.69,0:43:25.34,Default,,0,0,0,,You see this x here.
Dialogue: 0,0:43:26.29,0:43:27.81,Default,,0,0,0,,That x is kind of a pronoun,
Dialogue: 0,0:43:27.87,0:43:29.53,Default,,0,0,0,,which is the something that I'm going to square.
Dialogue: 0,0:43:31.49,0:43:37.41,Default,,0,0,0,,And what I do with it is I multiply x, I multiply it by itself.
Dialogue: 0,0:43:42.22,0:43:48.27,Default,,0,0,0,,OK. So there's the notation for defining a procedure.
Dialogue: 0,0:43:48.29,0:43:50.29,Default,,0,0,0,,Actually, this is a little bit confusing,
Dialogue: 0,0:43:50.81,0:43:53.97,Default,,0,0,0,,because this is sort of how I might use square.
Dialogue: 0,0:43:54.00,0:43:56.80,Default,,0,0,0,,And I say square root of x or square root of 10,
Dialogue: 0,0:43:57.55,0:44:00.81,Default,,0,0,0,,but it's not making it very clear that I'm actually naming something.
Dialogue: 0,0:44:03.10,0:44:04.91,Default,,0,0,0,,So let me write this definition in another way
Dialogue: 0,0:44:05.74,0:44:08.21,Default,,0,0,0,,that makes it a little bit more clear that I'm naming something.
Dialogue: 0,0:44:08.54,0:44:29.39,Default,,0,0,0,,I'll say, "define" square to be lambda of x times xx.
Dialogue: 0,0:44:36.56,0:44:42.05,Default,,0,0,0,,Here, I'm naming something square, just like over here, I'm naming something A.
Dialogue: 0,0:44:43.23,0:44:44.72,Default,,0,0,0,,The thing that I'm naming square--
Dialogue: 0,0:44:44.75,0:44:48.39,Default,,0,0,0,,here, the thing I named A was the value of this combination.
Dialogue: 0,0:44:49.29,0:44:52.41,Default,,0,0,0,,Here, the thing that I'm naming square is this thing
Dialogue: 0,0:44:52.43,0:44:53.44,Default,,0,0,0,,that begins with lambda,
Dialogue: 0,0:44:53.45,0:44:56.77,Default,,0,0,0,,and lambda is Lisp's way of saying make a procedure.
Dialogue: 0,0:45:00.24,0:45:02.91,Default,,0,0,0,,Let's look at that more closely on the slide.
Dialogue: 0,0:45:04.27,0:45:05.81,Default,,0,0,0,,The way I read that definition is to say,
Dialogue: 0,0:45:05.85,0:45:10.33,Default,,0,0,0,,I define square to be make a procedure--
Dialogue: 0,0:45:12.78,0:45:13.97,Default,,0,0,0,,that's what the lambda is--
Dialogue: 0,0:45:14.06,0:45:17.49,Default,,0,0,0,,make a procedure with an argument named x.
Dialogue: 0,0:45:19.26,0:45:24.09,Default,,0,0,0,,And what it does is return the results of multiplying x by itself.
Dialogue: 0,0:45:24.97,0:45:33.12,Default,,0,0,0,,Now, in general, we're going to be using this top form of defining,
Dialogue: 0,0:45:33.41,0:45:35.20,Default,,0,0,0,,just because it's a little bit more convenient.
Dialogue: 0,0:45:35.21,0:45:38.67,Default,,0,0,0,,But don't lose sight of the fact that it's really this.
Dialogue: 0,0:45:38.86,0:45:41.41,Default,,0,0,0,,In fact, as far as the Lisp interpreter's concerned,
Dialogue: 0,0:45:41.61,0:45:45.55,Default,,0,0,0,,there's no difference between typing this to it and typing this to it.
Dialogue: 0,0:45:46.51,0:45:53.29,Default,,0,0,0,,And there's a word for that, sort of syntactic sugar.
Dialogue: 0,0:45:54.41,0:45:55.80,Default,,0,0,0,,What syntactic sugar means,
Dialogue: 0,0:45:56.35,0:46:00.83,Default,,0,0,0,,it's having somewhat more convenient surface forms for typing something.
Dialogue: 0,0:46:01.12,0:46:06.11,Default,,0,0,0,,So this is just really syntactic sugar for this underlying Greek thing with the lambda.
Dialogue: 0,0:46:07.31,0:46:10.62,Default,,0,0,0,,And the reason you should remember that is don't forget that,
Dialogue: 0,0:46:10.80,0:46:13.87,Default,,0,0,0,,when I write something like this, I'm really naming something.
Dialogue: 0,0:46:14.46,0:46:16.22,Default,,0,0,0,,I'm naming something square,
Dialogue: 0,0:46:16.24,0:46:19.90,Default,,0,0,0,,and the something that I'm naming square is a procedure that's getting constructed.
Dialogue: 0,0:46:21.20,0:46:23.90,Default,,0,0,0,,Well, let's look at that on the computer, too.
Dialogue: 0,0:46:24.78,0:46:35.95,Default,,0,0,0,,So I'll come and I'll say, define square of x to be times xx.
Dialogue: 0,0:46:49.65,0:46:52.32,Default,,0,0,0,,Now I'll tell Lisp that.
Dialogue: 0,0:46:53.49,0:46:53.92,Default,,0,0,0,,It says "square."
Dialogue: 0,0:46:53.93,0:46:56.29,Default,,0,0,0,,See, I've named something "square."
Dialogue: 0,0:46:56.45,0:47:02.88,Default,,0,0,0,,Now, having done that, I can ask Lisp for, what's the square of 1,001?
Dialogue: 0,0:47:05.26,0:47:17.69,Default,,0,0,0,,Or in general, I could say, what's the square of the sum of 5 and 7?
Dialogue: 0,0:47:22.81,0:47:24.95,Default,,0,0,0,,The square of 12's 144.
Dialogue: 0,0:47:25.07,0:47:28.86,Default,,0,0,0,,Or I can use square itself as an element in some combination.
Dialogue: 0,0:47:28.88,0:47:37.50,Default,,0,0,0,,I can say, what's the sum of the square of 3 and the square of 4?
Dialogue: 0,0:47:42.53,0:47:44.09,Default,,0,0,0,,9 and 16 is 25.
Dialogue: 0,0:47:44.91,0:47:50.54,Default,,0,0,0,,Or I can use square as an element in some much more complicated thing.
Dialogue: 0,0:47:50.59,0:48:00.51,Default,,0,0,0,,I can say, what's the square of, the sqare of, the square of 1,001?
Dialogue: 0,0:48:07.89,0:48:10.63,Default,,0,0,0,,And there's the square of the square of the square of 1,001.
Dialogue: 0,0:48:11.20,0:48:15.45,Default,,0,0,0,,Or I can say to Lisp, what is square itself?
Dialogue: 0,0:48:15.68,0:48:17.16,Default,,0,0,0,,What's the value of that?
Dialogue: 0,0:48:17.44,0:48:22.14,Default,,0,0,0,,And Lisp returns some conventional way of telling me that that's a procedure.
Dialogue: 0,0:48:22.27,0:48:23.98,Default,,0,0,0,,It says, "compound procedure square."
Dialogue: 0,0:48:24.25,0:48:27.92,Default,,0,0,0,,Remember, the value of square is this procedure,
Dialogue: 0,0:48:29.15,0:48:30.89,Default,,0,0,0,,and the thing with the stars and the brackets
Dialogue: 0,0:48:31.10,0:48:34.78,Default,,0,0,0,,are just Lisp's conventional way of describing that.
Dialogue: 0,0:48:36.11,0:48:41.33,Default,,0,0,0,,Let's look at two more examples of defining.
Dialogue: 0,0:48:44.91,0:48:46.91,Default,,0,0,0,,Here are two more procedures.
Dialogue: 0,0:48:47.36,0:48:52.84,Default,,0,0,0,,I can define the average of x and y to be the sum of x and y divided by 2.
Dialogue: 0,0:48:54.67,0:49:01.49,Default,,0,0,0,,Or having had average and mean square, having had average and square,
Dialogue: 0,0:49:01.65,0:49:04.71,Default,,0,0,0,,I can use that to talk about the mean square of something,
Dialogue: 0,0:49:04.91,0:49:09.26,Default,,0,0,0,,which is the average of the square of x and the square of y.
Dialogue: 0,0:49:10.97,0:49:13.63,Default,,0,0,0,,So for example, having done that, I could say,
Dialogue: 0,0:49:13.66,0:49:24.88,Default,,0,0,0,,what's the mean square of 2 and 3?
Dialogue: 0,0:49:25.23,0:49:30.24,Default,,0,0,0,,And I should get the average of 4 and 9, which is 6.5.
Dialogue: 0,0:49:32.85,0:49:36.64,Default,,0,0,0,,The key thing here is that, having defined square,
Dialogue: 0,0:49:36.64,0:49:38.67,Default,,0,0,0,,I can use it as if it were primitive.
Dialogue: 0,0:49:41.41,0:49:43.07,Default,,0,0,0,,So if we look here on the slide,
Dialogue: 0,0:49:44.65,0:49:45.74,Default,,0,0,0,,if I look at mean square,
Dialogue: 0,0:49:47.29,0:49:52.56,Default,,0,0,0,,the person defining mean square doesn't have to know, at this point,
Dialogue: 0,0:49:52.61,0:49:55.76,Default,,0,0,0,,whether square was something built into the language
Dialogue: 0,0:49:56.94,0:49:58.93,Default,,0,0,0,,or whether it was a procedure that was defined.
Dialogue: 0,0:49:59.73,0:50:01.28,Default,,0,0,0,,And that's a key thing in Lisp,
Dialogue: 0,0:50:02.30,0:50:07.52,Default,,0,0,0,,that you do not make arbitrary distinctions between things
Dialogue: 0,0:50:07.53,0:50:11.82,Default,,0,0,0,,that happen to be primitive in the language and things that happen to be built in.
Dialogue: 0,0:50:12.83,0:50:14.73,Default,,0,0,0,,A person using that shouldn't even have to know.
Dialogue: 0,0:50:14.93,0:50:18.51,Default,,0,0,0,,So the things you construct get used with all the power and flexibility
Dialogue: 0,0:50:18.51,0:50:19.53,Default,,0,0,0,,as if they were primitives.
Dialogue: 0,0:50:19.57,0:50:22.57,Default,,0,0,0,,In fact, you can drive that home by looking on the computer one more time.
Dialogue: 0,0:50:24.75,0:50:26.30,Default,,0,0,0,,We talked about plus.
Dialogue: 0,0:50:26.72,0:50:30.09,Default,,0,0,0,,And in fact, if I come here on the computer screen and say,
Dialogue: 0,0:50:30.11,0:50:32.33,Default,,0,0,0,,what is the value of plus?
Dialogue: 0,0:50:34.40,0:50:37.20,Default,,0,0,0,,Notice what Lisp types out. On the bottom there, it typed out,
Dialogue: 0,0:50:37.25,0:50:38.81,Default,,0,0,0,,"compound procedure plus."
Dialogue: 0,0:50:39.89,0:50:42.29,Default,,0,0,0,,Because, in this system,
Dialogue: 0,0:50:42.33,0:50:45.49,Default,,0,0,0,,it turns out that the addition operator is itself a compound procedure.
Dialogue: 0,0:50:45.97,0:50:47.97,Default,,0,0,0,,And if I didn't just type that in, you'd never know that,
Dialogue: 0,0:50:48.06,0:50:49.68,Default,,0,0,0,,and it wouldn't make any difference anyway.
Dialogue: 0,0:50:49.84,0:50:50.51,Default,,0,0,0,,We don't care.
Dialogue: 0,0:50:50.56,0:50:53.39,Default,,0,0,0,,It's below the level of the abstraction that we're dealing with.
Dialogue: 0,0:50:54.17,0:50:59.11,Default,,0,0,0,,So the key thing is you cannot tell, should not be able to tell, in general,
Dialogue: 0,0:50:59.17,0:51:03.82,Default,,0,0,0,,the difference between things that are built in and things that are compound.
Dialogue: 0,0:51:03.84,0:51:04.38,Default,,0,0,0,,Why is that?
Dialogue: 0,0:51:04.38,0:51:08.07,Default,,0,0,0,,Because the things that are compound have an abstraction wrapper wrapped around them.
Dialogue: 0,0:51:09.05,0:51:11.61,Default,,0,0,0,,We've seen almost all the elements of Lisp now.
Dialogue: 0,0:51:12.67,0:51:14.53,Default,,0,0,0,,There's only one more we have to look at,
Dialogue: 0,0:51:14.57,0:51:16.53,Default,,0,0,0,,and that is how to make a case analysis.
Dialogue: 0,0:51:16.59,0:51:17.70,Default,,0,0,0,,Let me show you what I mean.
Dialogue: 0,0:51:18.96,0:51:24.08,Default,,0,0,0,,We might want to think about the mathematical definition of the absolute value functions.
Dialogue: 0,0:51:24.11,0:51:30.03,Default,,0,0,0,,I might say the absolute value of x is the function
Dialogue: 0,0:51:30.16,0:51:37.24,Default,,0,0,0,,which has the property that it's negative of x. For x less than 0,
Dialogue: 0,0:51:37.92,0:51:41.13,Default,,0,0,0,,it's 0 for x equal to 0.
Dialogue: 0,0:51:42.64,0:51:46.62,Default,,0,0,0,,And it's x for x greater than 0.
Dialogue: 0,0:51:49.15,0:51:51.90,Default,,0,0,0,,And Lisp has a way of making case analyses.
Dialogue: 0,0:51:52.11,0:51:53.85,Default,,0,0,0,,Let me define for you absolute value.
Dialogue: 0,0:51:55.55,0:52:02.41,Default,,0,0,0,,Say define the absolute value of x is conditional.
Dialogue: 0,0:52:03.02,0:52:05.67,Default,,0,0,0,,This means case analysis, COND.
Dialogue: 0,0:52:09.23,0:52:19.09,Default,,0,0,0,,If x is less than 0, the answer is negate x.
Dialogue: 0,0:52:22.99,0:52:24.88,Default,,0,0,0,,What I've written here is a clause.
Dialogue: 0,0:52:24.99,0:52:35.54,Default,,0,0,0,,This whole thing is a conditional clause, and it has two parts.
Dialogue: 0,0:52:36.35,0:52:44.70,Default,,0,0,0,,This part here is a predicate or a condition.
Dialogue: 0,0:52:44.83,0:52:45.90,Default,,0,0,0,,That's a condition.
Dialogue: 0,0:52:46.11,0:52:48.29,Default,,0,0,0,,And the condition is expressed by something called a predicate,
Dialogue: 0,0:52:48.33,0:52:51.05,Default,,0,0,0,,and a predicate in Lisp is some sort of thing
Dialogue: 0,0:52:51.37,0:52:52.87,Default,,0,0,0,,that returns either true or false.
Dialogue: 0,0:52:53.53,0:52:56.13,Default,,0,0,0,,And you see Lisp has a primitive procedure, less-than,
Dialogue: 0,0:52:57.29,0:52:59.08,Default,,0,0,0,,that tests whether something is true or false.
Dialogue: 0,0:53:00.54,0:53:06.32,Default,,0,0,0,,And the other part of a clause is an action or a thing to do,
Dialogue: 0,0:53:06.93,0:53:08.14,Default,,0,0,0,,in the case where that's true.
Dialogue: 0,0:53:08.17,0:53:09.81,Default,,0,0,0,,And here, what I'm doing is negating x.
Dialogue: 0,0:53:10.08,0:53:14.41,Default,,0,0,0,,The negation operator, the minus sign in Lisp is a little bit funny.
Dialogue: 0,0:53:14.56,0:53:18.43,Default,,0,0,0,,If there's two or more arguments,
Dialogue: 0,0:53:18.58,0:53:22.49,Default,,0,0,0,,if there's two arguments it subtracts the second one from the first, and we saw that.
Dialogue: 0,0:53:22.53,0:53:24.13,Default,,0,0,0,,And if there's one argument, it negates it.
Dialogue: 0,0:53:25.13,0:53:27.87,Default,,0,0,0,,So this corresponds to that.
Dialogue: 0,0:53:27.87,0:53:29.69,Default,,0,0,0,,And then there's another COND clause.
Dialogue: 0,0:53:30.64,0:53:35.87,Default,,0,0,0,,It says, in the case where x is equal to 0, the answer is 0.
Dialogue: 0,0:53:37.95,0:53:44.75,Default,,0,0,0,,And in the case where x is greater than 0, the answer is x.
Dialogue: 0,0:53:45.33,0:53:49.38,Default,,0,0,0,,Close that clause. Close the COND. Close the definition.
Dialogue: 0,0:53:49.57,0:53:51.29,Default,,0,0,0,,And there's the definition of absolute value.
Dialogue: 0,0:53:51.31,0:53:53.66,Default,,0,0,0,,And you see it's the case analysis that looks very much
Dialogue: 0,0:53:53.66,0:53:56.04,Default,,0,0,0,,like the case analysis you use in mathematics.
Dialogue: 0,0:53:58.14,0:54:03.07,Default,,0,0,0,,There's a somewhat different way of writing a restricted case analysis.
Dialogue: 0,0:54:03.07,0:54:06.24,Default,,0,0,0,,Often, you have a case analysis where you only have one case,
Dialogue: 0,0:54:06.93,0:54:08.07,Default,,0,0,0,,where you test something,
Dialogue: 0,0:54:08.33,0:54:10.75,Default,,0,0,0,,and then depending on whether it's true or false, you do something.
Dialogue: 0,0:54:11.01,0:54:15.90,Default,,0,0,0,,And here's another definition of absolute value
Dialogue: 0,0:54:16.00,0:54:17.19,Default,,0,0,0,,which looks almost the same,
Dialogue: 0,0:54:17.66,0:54:22.56,Default,,0,0,0,,which says, if x is less than 0, the result is negate x.
Dialogue: 0,0:54:24.41,0:54:25.97,Default,,0,0,0,,Otherwise, the answer is x.
Dialogue: 0,0:54:26.05,0:54:27.25,Default,,0,0,0,,And we'll be using "if" a lot.
Dialogue: 0,0:54:27.29,0:54:29.13,Default,,0,0,0,,But again, the thing to remember is that
Dialogue: 0,0:54:29.13,0:54:32.70,Default,,0,0,0,,this form of absolute value that you're looking at here,
Dialogue: 0,0:54:34.30,0:54:36.98,Default,,0,0,0,,and then this one over here that I wrote on the board,
Dialogue: 0,0:54:37.52,0:54:38.80,Default,,0,0,0,,are essentially the same.
Dialogue: 0,0:54:39.09,0:54:42.26,Default,,0,0,0,,And "if" and COND are-- well, whichever way you like it.
Dialogue: 0,0:54:42.30,0:54:44.45,Default,,0,0,0,,You can think of COND as syntactic sugar for "if",
Dialogue: 0,0:54:44.99,0:54:47.36,Default,,0,0,0,,or you can think of "if" as syntactic sugar for COND,
Dialogue: 0,0:54:47.39,0:54:48.65,Default,,0,0,0,,and it doesn't make any difference.
Dialogue: 0,0:54:49.21,0:54:51.35,Default,,0,0,0,,The person implementing a Lisp system will pick one
Dialogue: 0,0:54:51.39,0:54:52.97,Default,,0,0,0,,and implement the other in terms of that.
Dialogue: 0,0:54:53.15,0:54:54.67,Default,,0,0,0,,And it doesn't matter which one you pick.
Dialogue: 0,0:55:02.27,0:55:05.36,Default,,0,0,0,,Why don't we break now, and then take some questions.
Dialogue: 0,0:55:05.69,0:55:10.08,Default,,0,0,0,,How come sometimes when I write define,
Dialogue: 0,0:55:11.09,0:55:14.75,Default,,0,0,0,,I put an open paren here and say,
Dialogue: 0,0:55:14.81,0:55:16.45,Default,,0,0,0,,define open paren something or other,
Dialogue: 0,0:55:16.86,0:55:20.81,Default,,0,0,0,,and sometimes when I write this, I don't put an open paren?
Dialogue: 0,0:55:22.06,0:55:27.23,Default,,0,0,0,,The answer is, this particular form of "define",
Dialogue: 0,0:55:27.26,0:55:29.41,Default,,0,0,0,,where you say define some expression,
Dialogue: 0,0:55:29.47,0:55:32.13,Default,,0,0,0,,is this very special thing for defining procedures.
Dialogue: 0,0:55:33.61,0:55:40.21,Default,,0,0,0,,But again, what it really means is I'm defining this symbol, square, to be that.
Dialogue: 0,0:55:41.45,0:55:45.98,Default,,0,0,0,,So the way you should think about it is what "define" does is you write "define",
Dialogue: 0,0:55:47.15,0:55:50.06,Default,,0,0,0,,and the second thing you write is the symbol here-- no open paren--
Dialogue: 0,0:55:50.17,0:55:51.49,Default,,0,0,0,,the symbol you're defining
Dialogue: 0,0:55:52.08,0:55:53.70,Default,,0,0,0,,and what you're defining it to be.
Dialogue: 0,0:55:54.65,0:55:57.55,Default,,0,0,0,,That's like here and like here.
Dialogue: 0,0:55:57.61,0:56:00.29,Default,,0,0,0,,That's sort of the basic way you use "define."
Dialogue: 0,0:56:01.12,0:56:03.65,Default,,0,0,0,,And then, there's this special syntactic trick
Dialogue: 0,0:56:04.29,0:56:07.04,Default,,0,0,0,,which allows you to define procedures that look like this.
Dialogue: 0,0:56:08.17,0:56:11.49,Default,,0,0,0,,So the difference is, it's whether or not you're defining a procedure.
Dialogue: 0,0:56:12.91,0:56:37.60,Default,,0,0,0,,[JESU, JOY OF MAN'S DESIRING]
Dialogue: 0,0:56:38.05,0:56:41.98,Default,,0,0,0,,Well, believe it or not, you actually now know enough Lisp
Dialogue: 0,0:56:42.78,0:56:45.42,Default,,0,0,0,,to write essentially any numerical procedure
Dialogue: 0,0:56:46.25,0:56:49.63,Default,,0,0,0,,that you'd write in a language like FORTRAN or Basic or whatever,
Dialogue: 0,0:56:49.66,0:56:51.01,Default,,0,0,0,,or, essentially, any other language.
Dialogue: 0,0:56:52.05,0:56:54.76,Default,,0,0,0,,And you're probably saying, that's not believable,
Dialogue: 0,0:56:54.81,0:56:56.65,Default,,0,0,0,,because you know that these languages have things
Dialogue: 0,0:56:56.65,0:57:00.22,Default,,0,0,0,,like "for statements", and "do until while" or something.
Dialogue: 0,0:57:00.99,0:57:04.59,Default,,0,0,0,,But we don't really need any of that.
Dialogue: 0,0:57:05.05,0:57:07.13,Default,,0,0,0,,In fact, we're not going to use any of that in this course.
Dialogue: 0,0:57:08.25,0:57:10.16,Default,,0,0,0,,Let me show you.
Dialogue: 0,0:57:10.25,0:57:13.61,Default,,0,0,0,,Again, looking back at square root,
Dialogue: 0,0:57:13.65,0:57:19.03,Default,,0,0,0,,let's go back to this square root algorithm of Heron of Alexandria.
Dialogue: 0,0:57:19.09,0:57:19.97,Default,,0,0,0,,Remember what that said.
Dialogue: 0,0:57:20.06,0:57:23.67,Default,,0,0,0,,It said, to find an approximation to the square root of X,
Dialogue: 0,0:57:25.07,0:57:26.16,Default,,0,0,0,,you make a guess,
Dialogue: 0,0:57:27.45,0:57:31.88,Default,,0,0,0,,you improve that guess by averaging the guess and X over the guess.
Dialogue: 0,0:57:32.94,0:57:36.06,Default,,0,0,0,,You keep improving that until the guess is good enough.
Dialogue: 0,0:57:36.72,0:57:38.43,Default,,0,0,0,,I already alluded to the idea.
Dialogue: 0,0:57:38.56,0:57:42.24,Default,,0,0,0,,The idea is that, if the initial guess that you took
Dialogue: 0,0:57:43.04,0:57:46.91,Default,,0,0,0,,was actually equal to the square root of X,
Dialogue: 0,0:57:47.15,0:57:50.06,Default,,0,0,0,,then G here would be equal to X/G.
Dialogue: 0,0:57:52.89,0:57:55.33,Default,,0,0,0,,So if you hit the square root, averaging them wouldn't change it.
Dialogue: 0,0:57:55.69,0:57:59.62,Default,,0,0,0,,If the G that you picked was larger than the square root of X,
Dialogue: 0,0:58:00.38,0:58:02.94,Default,,0,0,0,,then X/G will be smaller than the square root of X,
Dialogue: 0,0:58:03.21,0:58:05.37,Default,,0,0,0,,so that when you average G and X/G,
Dialogue: 0,0:58:05.63,0:58:07.57,Default,,0,0,0,,you get something in between.
Dialogue: 0,0:58:08.96,0:58:12.95,Default,,0,0,0,,So if you pick a G that's too small, your answer will be too large.
Dialogue: 0,0:58:13.12,0:58:14.81,Default,,0,0,0,,If you pick a G that's too large,
Dialogue: 0,0:58:16.32,0:58:18.06,Default,,0,0,0,,if your G is larger than the square root of X
Dialogue: 0,0:58:18.08,0:58:20.35,Default,,0,0,0,,and X/G will be smaller than the square root of X.
Dialogue: 0,0:58:21.23,0:58:23.65,Default,,0,0,0,,So averaging always gives you something in between.
Dialogue: 0,0:58:24.53,0:58:28.13,Default,,0,0,0,,And then, it's not quite trivial, but it's possible to show that,
Dialogue: 0,0:58:28.17,0:58:31.76,Default,,0,0,0,,in fact, if G misses the square root of X by a little bit,
Dialogue: 0,0:58:31.81,0:58:37.99,Default,,0,0,0,,the average of G and X/G will actually keep getting closer to the square root of X.
Dialogue: 0,0:58:38.03,0:58:38.99,Default,,0,0,0,,So if you keep doing this enough,
Dialogue: 0,0:58:39.42,0:58:41.18,Default,,0,0,0,,you'll eventually get as close as you want.
Dialogue: 0,0:58:41.71,0:58:42.85,Default,,0,0,0,,And then there's another fact,
Dialogue: 0,0:58:43.02,0:58:47.65,Default,,0,0,0,,that you can always start out this process by using 1 as an initial guess.
Dialogue: 0,0:58:49.23,0:58:51.35,Default,,0,0,0,,And it'll always converge to the square root of X.
Dialogue: 0,0:58:52.24,0:58:56.77,Default,,0,0,0,,So that's this method of successive averaging due to Heron of Alexandria.
Dialogue: 0,0:58:56.81,0:58:59.21,Default,,0,0,0,,Let's write it in Lisp.
Dialogue: 0,0:59:00.57,0:59:02.61,Default,,0,0,0,,Well, the central idea is,
Dialogue: 0,0:59:02.65,0:59:07.19,Default,,0,0,0,,what does it mean to try a guess for the square root of X?
Dialogue: 0,0:59:08.30,0:59:09.37,Default,,0,0,0,,Let's write that.
Dialogue: 0,0:59:09.79,0:59:25.02,Default,,0,0,0,,So we'll say, define to try a guess for the square root of X,
Dialogue: 0,0:59:26.45,0:59:28.24,Default,,0,0,0,,what do we do? We'll say,
Dialogue: 0,0:59:28.29,0:59:45.26,Default,,0,0,0,,if the guess is good enough to be a guess for the square root of X,
Dialogue: 0,0:59:46.54,0:59:49.52,Default,,0,0,0,,then, as an answer, we'll take the guess.
Dialogue: 0,0:59:51.61,0:59:57.01,Default,,0,0,0,,Otherwise, we will try the improved guess.
Dialogue: 0,0:59:58.19,1:00:04.24,Default,,0,0,0,,We'll improve that guess for the square root of X,
Dialogue: 0,1:00:05.26,1:00:09.33,Default,,0,0,0,,and we'll try that as a guess for the square root of X.
Dialogue: 0,1:00:09.36,1:00:12.96,Default,,0,0,0,,Close the "try." Close the "if." Close the "define."
Dialogue: 0,1:00:13.31,1:00:14.81,Default,,0,0,0,,So that's how we try a guess.
Dialogue: 0,1:00:15.85,1:00:17.60,Default,,0,0,0,,And then, the next part of the process said,
Dialogue: 0,1:00:17.73,1:00:21.90,Default,,0,0,0,,in order to compute square roots, we'll say,
Dialogue: 0,1:00:21.93,1:00:30.17,Default,,0,0,0,,define to compute the square root of X,
Dialogue: 0,1:00:30.80,1:00:35.79,Default,,0,0,0,,we will try 1 as a guess for the square root of X.
Dialogue: 0,1:00:37.42,1:00:39.59,Default,,0,0,0,,Well, we have to define a couple more things.
Dialogue: 0,1:00:40.08,1:00:43.36,Default,,0,0,0,,We have to say, how is a guess good enough?
Dialogue: 0,1:00:43.84,1:00:45.29,Default,,0,0,0,,And how do we improve a guess?
Dialogue: 0,1:00:45.85,1:00:47.10,Default,,0,0,0,,So let's look at that.
Dialogue: 0,1:00:47.39,1:00:54.24,Default,,0,0,0,,The algorithm to improve a guess for the square root of X,
Dialogue: 0,1:00:54.64,1:00:57.18,Default,,0,0,0,,we average-- that was the algorithm--
Dialogue: 0,1:00:57.18,1:01:02.16,Default,,0,0,0,,we average the guess with the quotient of dividing X by the guess.
Dialogue: 0,1:01:02.99,1:01:04.57,Default,,0,0,0,,That's how we improve a guess.
Dialogue: 0,1:01:05.85,1:01:08.80,Default,,0,0,0,,And to tell whether a guess is good enough, well, we have to decide something.
Dialogue: 0,1:01:08.86,1:01:11.36,Default,,0,0,0,,This is supposed to be a guess for the square root of X,
Dialogue: 0,1:01:11.37,1:01:14.03,Default,,0,0,0,,so one possible thing you can do is say,
Dialogue: 0,1:01:14.06,1:01:16.07,Default,,0,0,0,,when you take that guess and square it,
Dialogue: 0,1:01:16.64,1:01:18.41,Default,,0,0,0,,do you get something very close to X?
Dialogue: 0,1:01:18.59,1:01:21.10,Default,,0,0,0,,So one way to say that is to say,
Dialogue: 0,1:01:21.12,1:01:24.31,Default,,0,0,0,,I square the guess, subtract X from that,
Dialogue: 0,1:01:25.15,1:01:27.15,Default,,0,0,0,,and see if the absolute value of that
Dialogue: 0,1:01:27.20,1:01:32.05,Default,,0,0,0,,whole thing is less than some small number, which depends on my purposes.
Dialogue: 0,1:01:34.70,1:01:41.42,Default,,0,0,0,,So there's a complete procedure for how to compute the square root of X.
Dialogue: 0,1:01:41.47,1:01:43.53,Default,,0,0,0,,Let's look at the structure of that a little bit.
Dialogue: 0,1:01:47.84,1:01:49.12,Default,,0,0,0,,I have the whole thing.
Dialogue: 0,1:01:49.15,1:01:55.44,Default,,0,0,0,,I have the notion of how to compute a square root.
Dialogue: 0,1:01:55.53,1:01:56.88,Default,,0,0,0,,That's some kind of module.
Dialogue: 0,1:01:57.05,1:01:58.46,Default,,0,0,0,,That's some kind of black box.
Dialogue: 0,1:01:58.72,1:02:08.02,Default,,0,0,0,,It's defined in terms of how to try a guess for the square root of X.
Dialogue: 0,1:02:09.31,1:02:14.10,Default,,0,0,0,,"Try" is defined in terms of, well,
Dialogue: 0,1:02:14.61,1:02:18.03,Default,,0,0,0,,telling whether something is good enough and telling how to improve something.
Dialogue: 0,1:02:18.73,1:02:19.68,Default,,0,0,0,,So good enough.
Dialogue: 0,1:02:19.89,1:02:28.85,Default,,0,0,0,,"Try" is defined in terms of "good enough" and "improve".
Dialogue: 0,1:02:30.96,1:02:32.56,Default,,0,0,0,,And let's see what else I fill in.
Dialogue: 0,1:02:32.71,1:02:34.29,Default,,0,0,0,,Well, I'll go down this tree.
Dialogue: 0,1:02:34.73,1:02:38.49,Default,,0,0,0,,"Good enough" was defined in terms of absolute value, and square.
Dialogue: 0,1:02:40.97,1:02:44.13,Default,,0,0,0,,And improve was defined in terms of something called averaging
Dialogue: 0,1:02:45.17,1:02:46.70,Default,,0,0,0,,and then some other primitive operator.
Dialogue: 0,1:02:46.72,1:02:48.88,Default,,0,0,0,,Square root's defined in terms of "try".
Dialogue: 0,1:02:48.88,1:02:53.31,Default,,0,0,0,,"Try" is defined in terms of "good enough" and "improve",
Dialogue: 0,1:02:54.01,1:02:55.39,Default,,0,0,0,,but also "try" itself.
Dialogue: 0,1:02:55.58,1:03:00.86,Default,,0,0,0,,So "try" is also defined in terms of how to try itself.
Dialogue: 0,1:03:02.75,1:03:04.72,Default,,0,0,0,,Well, that may give you some problems.
Dialogue: 0,1:03:04.72,1:03:08.16,Default,,0,0,0,,Your high school geometry teacher probably told you
Dialogue: 0,1:03:08.67,1:03:12.57,Default,,0,0,0,,that it's naughty to try and define things in terms of themselves,
Dialogue: 0,1:03:12.88,1:03:13.92,Default,,0,0,0,,because it doesn't make sense.
Dialogue: 0,1:03:13.92,1:03:14.72,Default,,0,0,0,,But that's false.
Dialogue: 0,1:03:16.03,1:03:19.68,Default,,0,0,0,,Sometimes it makes perfect sense to define things in terms of themselves.
Dialogue: 0,1:03:20.16,1:03:24.38,Default,,0,0,0,,And this is the case. And we can look at that.
Dialogue: 0,1:03:24.38,1:03:26.89,Default,,0,0,0,,We could write down what this means, and say,
Dialogue: 0,1:03:26.91,1:03:30.33,Default,,0,0,0,,suppose I asked Lisp what the square root of 2 is.
Dialogue: 0,1:03:32.65,1:03:34.67,Default,,0,0,0,,What's the square root of 2 mean?
Dialogue: 0,1:03:35.79,1:03:43.61,Default,,0,0,0,,Well, that means I try 1 as a guess for the square root of 2.
Dialogue: 0,1:03:46.97,1:03:50.92,Default,,0,0,0,,Now I look. I say, gee, is 1 a good enough guess for the square root of 2?
Dialogue: 0,1:03:51.65,1:03:53.69,Default,,0,0,0,,And that depends on the test that "good enough" does.
Dialogue: 0,1:03:54.61,1:03:56.56,Default,,0,0,0,,And in this case, "good enough" will say,
Dialogue: 0,1:03:56.65,1:03:59.05,Default,,0,0,0,,no, 1 is not a good enough guess for the square root of 2.
Dialogue: 0,1:03:59.79,1:04:08.22,Default,,0,0,0,,So that will reduce to saying, I have to try an improved--
Dialogue: 0,1:04:08.64,1:04:12.63,Default,,0,0,0,,improve 1 as a guess for the square root of 2,
Dialogue: 0,1:04:15.15,1:04:17.46,Default,,0,0,0,,and try that as a guess for the square root of 2.
Dialogue: 0,1:04:19.13,1:04:22.07,Default,,0,0,0,,Improving 1 as a guess for the square root of 2
Dialogue: 0,1:04:22.09,1:04:25.08,Default,,0,0,0,,means I average 1 and 2 divided by 1.
Dialogue: 0,1:04:27.10,1:04:29.10,Default,,0,0,0,,So this is going to be average.
Dialogue: 0,1:04:29.58,1:04:39.44,Default,,0,0,0,,This piece here will be the average of 1 and the quotient of 2 by 1.
Dialogue: 0,1:04:40.83,1:04:42.75,Default,,0,0,0,,That's this piece here.
Dialogue: 0,1:04:43.85,1:04:46.72,Default,,0,0,0,,And I'm gonna try... And this is 1.5.
Dialogue: 0,1:04:49.07,1:04:54.40,Default,,0,0,0,,So this square root of 2 reduces to trying 1 for the square root of 2,
Dialogue: 0,1:04:54.56,1:05:04.83,Default,,0,0,0,,which reduces to trying 1.5 as a guess for the square root of 2.
Dialogue: 0,1:05:06.03,1:05:08.06,Default,,0,0,0,,So that makes sense.
Dialogue: 0,1:05:08.11,1:05:09.52,Default,,0,0,0,,Let's look at the rest of the process.
Dialogue: 0,1:05:09.73,1:05:15.00,Default,,0,0,0,,If I try 1.5, that reduces.
Dialogue: 0,1:05:15.01,1:05:19.05,Default,,0,0,0,,1.5 turns out to be not good enough as a guess for the square root of 2.
Dialogue: 0,1:05:20.22,1:05:22.00,Default,,0,0,0,,So that reduces to trying the average of
Dialogue: 0,1:05:22.01,1:05:26.17,Default,,0,0,0,,1.5 and 2 divided by 1.5 as a guess for the square root of 2.
Dialogue: 0,1:05:28.29,1:05:30.37,Default,,0,0,0,,That average turns out to be 1.333.
Dialogue: 0,1:05:31.18,1:05:35.24,Default,,0,0,0,,So this whole thing reduces to trying 1.333 as a guess for the square root of 2.
Dialogue: 0,1:05:35.28,1:05:36.06,Default,,0,0,0,,And then so on.
Dialogue: 0,1:05:38.01,1:05:41.66,Default,,0,0,0,,That reduces to another called a "good enough", 1.4 something or other.
Dialogue: 0,1:05:41.73,1:05:44.47,Default,,0,0,0,,And then it keeps going until the process finally stops
Dialogue: 0,1:05:44.85,1:05:47.92,Default,,0,0,0,,with something that "good enough" thinks is good enough, which,
Dialogue: 0,1:05:47.97,1:05:51.28,Default,,0,0,0,,in this case, is 1.4142 something or other.
Dialogue: 0,1:05:52.51,1:05:56.05,Default,,0,0,0,,So the process makes perfect sense.
Dialogue: 0,1:05:59.93,1:06:03.10,Default,,0,0,0,,This, by the way, is called a recursive definition.
Dialogue: 0,1:06:14.40,1:06:20.96,Default,,0,0,0,,And the ability to make recursive definitions is a source of incredible power.
Dialogue: 0,1:06:21.95,1:06:23.05,Default,,0,0,0,,And as you can already see I've hinted at,
Dialogue: 0,1:06:23.09,1:06:27.21,Default,,0,0,0,,it's the thing that effectively allows you to do these infinite computations
Dialogue: 0,1:06:27.25,1:06:28.83,Default,,0,0,0,,that go on until something is true,
Dialogue: 0,1:06:29.73,1:06:33.66,Default,,0,0,0,,without having any other constricts other than the ability to call a procedure.
Dialogue: 0,1:06:35.97,1:06:37.47,Default,,0,0,0,,Well, let's see, there's one more thing.
Dialogue: 0,1:06:37.71,1:06:44.21,Default,,0,0,0,,Let me show you a variant of this definition of square root here on the slide.
Dialogue: 0,1:06:44.43,1:06:48.16,Default,,0,0,0,,Here's sort of the same thing.
Dialogue: 0,1:06:48.40,1:06:51.49,Default,,0,0,0,,What I've done here is packaged the definitions of
Dialogue: 0,1:06:51.52,1:06:56.16,Default,,0,0,0,,"improve" and "good enough" and "try" inside "square root".
Dialogue: 0,1:06:56.75,1:07:00.99,Default,,0,0,0,,So, in effect, what I've done is I've built a square root box.
Dialogue: 0,1:07:01.81,1:07:08.53,Default,,0,0,0,,So I've built a box that's the square root procedure that someone can use.
Dialogue: 0,1:07:08.57,1:07:11.47,Default,,0,0,0,,They might put in 36 and get out 6.
Dialogue: 0,1:07:11.81,1:07:13.83,Default,,0,0,0,,And then, packaged inside this box
Dialogue: 0,1:07:14.16,1:07:23.85,Default,,0,0,0,,are the definitions of "try" and "good enough" and "improve."
Dialogue: 0,1:07:26.78,1:07:28.35,Default,,0,0,0,,So they're hidden inside this box.
Dialogue: 0,1:07:28.40,1:07:30.76,Default,,0,0,0,,And the reason for doing that is that,
Dialogue: 0,1:07:31.18,1:07:32.85,Default,,0,0,0,,if someone's using this square root,
Dialogue: 0,1:07:33.21,1:07:34.73,Default,,0,0,0,,if George is using this square root,
Dialogue: 0,1:07:34.75,1:07:37.36,Default,,0,0,0,,George probably doesn't care very much that,
Dialogue: 0,1:07:38.29,1:07:40.03,Default,,0,0,0,,when I implemented square root,
Dialogue: 0,1:07:40.21,1:07:44.45,Default,,0,0,0,,I had things inside there called "try" and "good enough" and "improve".
Dialogue: 0,1:07:46.40,1:07:49.33,Default,,0,0,0,,And in fact, Harry might have a cube root procedure
Dialogue: 0,1:07:49.37,1:07:50.96,Default,,0,0,0,,that has "try" and "good enough" and "improve".
Dialogue: 0,1:07:51.44,1:07:53.34,Default,,0,0,0,,And in order to not get the whole system confused,
Dialogue: 0,1:07:53.36,1:07:57.66,Default,,0,0,0,,it'd be good for Harry to package his internal procedures inside his cube root procedure.
Dialogue: 0,1:07:58.40,1:08:00.06,Default,,0,0,0,,Well, this is called block structure,
Dialogue: 0,1:08:00.32,1:08:08.96,Default,,0,0,0,,this particular way of packaging internals inside of a definition.
Dialogue: 0,1:08:09.97,1:08:12.96,Default,,0,0,0,,And let's go back and look at the slide again.
Dialogue: 0,1:08:13.12,1:08:18.57,Default,,0,0,0,,The way to read this kind of procedure is to say, to define "square root",
Dialogue: 0,1:08:19.87,1:08:21.84,Default,,0,0,0,,well, inside that definition,
Dialogue: 0,1:08:22.13,1:08:25.49,Default,,0,0,0,,I'll have the definition of an "improve" and
Dialogue: 0,1:08:25.56,1:08:28.88,Default,,0,0,0,,the definition of "good enough" and the definition of "try."
Dialogue: 0,1:08:29.73,1:08:32.38,Default,,0,0,0,,And then, subject to those definitions,
Dialogue: 0,1:08:32.48,1:08:35.07,Default,,0,0,0,,the way I do square root is to try 1.
Dialogue: 0,1:08:36.08,1:08:39.33,Default,,0,0,0,,And notice here, I don't have to say 1 as a guess for the square root of X,
Dialogue: 0,1:08:39.87,1:08:42.32,Default,,0,0,0,,because since it's all inside the square root,