← Lex Fridman

Donald Knuth: Programming, Algorithms, Hard Problems & the Game of Life

第219期2021-09-09English

嘉宾:Donald Knuth

收听本集00:00 / 2:27:39
阅读设置
按你的习惯阅读
正文字号
下载播客精读
把这一篇,带走慢慢读

精读待补充

下载功能还未开放

§01Transcript · 00:00–22:07

00:00The following is a conversation with Donald Knuth, his second time on this podcast.

00:04Don is a legendary computer scientist, Turing Award winner, father of algorithm analysis,

00:12author of the art of computer programming, creator of tech that led to latech, and one of the kindest

00:20and most fascinating human beings I've ever got a chance to talk to. I wrote him a letter a long

00:26time ago. He responded, and the rest, as they say, is history. We've interacted many times since then,

00:33and every time has been joyful and inspiring. To support this podcast, please check out our

00:39sponsors in the description. This is the Lex Friedman Podcast, and here is my conversation

00:45with Donald Knuth. Your first large-scale program, you wrote it in IBM 650 Assembler in the summer

00:53of 1957? I wrote it in decimal machine language. I didn't know about Assembler until a year later.

01:00But the year, 1957, and the program is Tic-Tac-Toe. Yeah, and I learned about Assembler later that

01:07summer. I probably did. In 1957, hardly anybody had heard of Assembler. You looked at the user

01:11manuals. How would you write a program for this machine? It would say 69, which meant load the

01:21distributor, and then you would give the address of the number you wanted to load into the distributor.

01:26Yesterday, my friend Doug Spicer at the Computer History Museum sent me a link to something that

01:35just went on YouTube. It was IBM's progress report from 1956, which is very contemporary with 1957.

01:45And in 1956, IBM had donated to Stanford University an IBM 650, one of the first ones,

01:52when they showed a picture of the assembly line for IBM 650s. And they said, "This is number 500

01:58or something coming off the assembly line." And I had never seen so many IBM 650s. I did in this

02:05movie that's on YouTube now. And it showed the picture from Stanford. They said, "Look, we

02:18donated one of these to Stanford, one to MIT," and they mentioned one other college. And in December

02:25of '56, they donated to my university, K-STEC. But anyway, they showed a picture then of a class

02:34session where a guy was teaching programming. And on the blackboard, it said 69, 8,000. I mean,

02:41he was teaching them how to write code for this IBM 650, which was in decimal numbers.

02:51So the instructions were 10 decimal digits. You had two digits that said what to do, four digits

03:00to say what to do it to, and four more digits to say where to get your next instruction.

03:07And there's a manual that describes what each of the numbers mean.

03:11And the manual was actually... If the manual had been well-written, I probably never would

03:16have gone into computer science, but it was so badly written, I figured that I must have a talent

03:21for it because I'm only a freshman and I could write a better manual. And-

03:27That's what you did.

03:28And so I started working at the computer center and wrote some manuals then. But yeah, but this

03:39was the way we did it. And my first program then was June of 1957.

03:46The Tic-Tac-Toe.

03:47No, that was the second program. The first program was factoring a number.

03:55Okay.

03:56So you dial a number on the switches. I mean, you sat at this big mainframe

04:03and you turn the dials, set a number, and then it would punch out the factors of that number on

04:12cards.

04:13So that's the input is the number?

04:15The input was, yeah, the input was a number, a 10-digit number, and the output was its factors.

04:25And I wrote that program. I still have a copy of it somewhere.

04:32How many lines of code? Do you remember?

04:36Well, yeah, it started out as about 20, but then I kept having to debug it. And I discovered

04:42debugging, of course, when I wrote my first program.

04:45What does debugging look like on a program with just all numbers?

04:50Well, you sit there and you... I don't remember how I got it into the machine,

04:54but I think there was a way to punch it on cards. So each instruction would be one card.

05:00Maybe I could get seven instructions on a card, eight instructions, I don't know. But anyway,

05:04so I'm sitting there at the console of the machine. I mean, I'm doing this at night when

05:09nobody else is around.

05:10Of course.

05:10And so you have one set of switches where you dial the number I'm inputting, but there's another

05:17switch that says, "Okay, now execute one instruction and show me what you did." Or there were another

05:26four switches I'd say, "Stop if you get to that instruction." So I could say, "Now go until you

05:33get there again and watch." Okay, so I could watch. It would take that number and it would

05:39divide it by two. And if there's no remainder, then okay, two is a factor. So then I work on...

05:46But if not divisible by two, divide by three. Okay, keep trying until you know you're at the end.

05:54And you would find a bug if you were just surprised that something weird happened?

06:01Well, certainly. I mean, first of all, I might have

06:05tried to divide by one instead of two. You're off by one error, as people make all the time.

06:12But maybe I go to the wrong instruction. Maybe I left something in a register that I shouldn't have

06:19done. But the first bugs were pretty... Probably on the first night, I was able to get the factors

06:27of 30 as equal to two, three, and five. Okay? Sorry to interrupt. So you're sitting there

06:34late at night. It feels like you spent many years late at night working on a computer.

06:42Oh, yeah. So what's that like? So most of the world is sleeping,

06:46and you have to be there at night because that's when you get access to the computer.

06:51Between my freshman and sophomore year, I didn't need sleep. I used to do all nighters. When I was

06:56in high school, I used to do the whole student newspaper every Monday night. I would just stay

07:05up all night, and it would be done on Tuesday morning. I didn't get ulcers and stuff like that

07:14until later. I don't know if you know Rodney Brooks.

07:19Rod Brooks, of course. Yeah. He told me a story.

07:26He really looked up to you. He was actually afraid of you.

07:28Well, vice versa, I must say.

07:31But he tells a story when you were working on tech, that they screwed up something with a

07:37machine. I think this might have been MIT. I don't know. And you were waiting for them to fix the

07:43machine so you can get back to work late at night. Oh, that happened all the time.

07:49He was really intimidated. He's like, "Dr. Knuth is not happy with this."

07:54That's interesting. But no, no. The machine at Danford AI Lab was down an awful lot because

08:03they had many talented programmers changing the operating system every day.

08:09And so the operating system was getting better every day, but it was also crashing. So I wrote

08:17almost the entire manual for tech during downtime of that machine. But that's another story.

08:24Well, he was saying it's a hardware problem. They tried to fix it and they reinserted something and

08:31smoke was everywhere. Oh, wow.

08:33Because he was hurt.

08:33Well, that didn't happen as often as the operating system.

08:35Anyway, it's a funny story because you're saying there's this tall Don Knuth that I look up to and

08:45there was pressure to fix the computer. It's funny. The kind of things we remember that stick

08:53in our memory.

08:54Well, okay. Yeah. Well, I could tell you a bunch of Rodbrook stories too, but let's go back to the

09:00650. So I'm debugging my first program and I had more bugs in it than number of lines of code. I

09:13mean, the number of lines of code kept growing. And let me explain. So I had to punch the answers

09:18on cards. So suppose I'm factoring the number 30, then I got to put two somewhere on the card. I

09:29got to put a three somewhere on the card. I got to put a five somewhere on the card. And you know

09:34what? It was my first program. I probably screwed up and it fell off the edge of the card or

09:41something like that. But I didn't realize that there are some tensioned numbers that have more

09:48than eight factors. And the card has only 80 columns. And so I need 10 columns for every

09:54factor. So my first program didn't take account for the fact that I would have to punch more than

09:59one card. My first program just lined the stuff up in memory and then I punched the card. So by

10:06the time I finished, I had to deal with lots of things. Also, if you put a large prime number in

10:16there, my program might have sat there for 10 minutes. The 650 was pretty slow. And so it would

10:22sit there spinning its wheels and you wouldn't know if it was in a loop or whatever. You said

10:2610 digit is the input? 10 digits, yeah. So I think the largest is sort of 9999999997 or something

10:34like that. That would take me a while for that first one. Anyway, that was my first program.

10:40Well, what was your goal with that program? Was there something you were hoping to find a large

10:46prime maybe or the opposite? No, my goal was to see the lights flashing and

10:51understand how this magical machine would be able to do something that took so long by hand.

10:58So what was your second program?

10:59My second program was a converted number from binary to decimal or something like that. It was

11:09much simpler. It didn't have that many bugs in it. My third program was Tic-Tac-Toe.

11:14Yeah. And it had some machines. So the Tic-Tac-Toe program is interesting on many levels,

11:20but one of them is that it had some, you can call machine learning in it.

11:25That's, yeah, that's right. I don't know how long it's going to be before the name of our field has

11:34changed from computer science to machine learning. But anyway, it was my first experience with

11:42machine learning. Okay, so here we had... Yeah. How does the program... Well, first of all,

11:46what is the problem you were solving? What is Tic-Tac-Toe? What are we talking about? And then

11:55how is it designed? Right. So you've got a three by three grid and each can be in three states. It

12:04can be empty or it can have an X or an O. Yeah. All right. So three to the ninth is a... Well,

12:12what is... How big is it? I should know. But it's 81 times 81 times three. So

12:21anyway, eight is like two to the third. So that would be like two to the sixth.

12:31But that'd be 64. Then you have to... Anyway. I love how you're doing the calculation.

12:38Anyway, the three comes from the fact that it's either empty, an X or an O. Right. And the 650

12:49was a machine that had only 2,010 digit words. You go from 0,0,0,0 to 1,9,9,9 and that's it.

13:02And each word, you have a 10 digit number. So that's not many bits. I mean, I got to have...

13:10In order to have a memory of every position I've seen, I need three to the ninth bits.

13:18Okay. But it was a decimal machine too. It didn't have bits. But it did have strange instruction

13:25where if you had a 10 digit number, but all the digits were either eight or nine,

13:30you'd be 89988 or something like that. You could make a test whether it was eight or nine. That

13:40was one of the strange things IBM engineers put into the machine. I have no idea why.

13:45Well, hardly ever used. But anyway, I needed one digit for every position I'd seen. Zero meant it

13:54was a bad position. Nine meant it was a good position. I think I started out at five or six.

14:01But if you win a game, then you increase the value of that position for you, but you decrease it

14:10for your opponent. But I had that much total memory for every possible position was one digit.

14:21And I had a total of 20,000 digits, which had to also include my program and all the logic and

14:28everything, including how to ask the user what the moves are and things like this. Okay. So I think I

14:36had to work it out. Every position in tic-tac-toe is equivalent to roughly eight others because you

14:44can rotate the board, which gives you a factor of four, and you can also flip it over.

14:50And that's another factor too. So I might have needed only three to the ninth over eight positions

14:58plus a little bit. But anyway, that was a part of the program to squeeze it into this tiny...

15:06So you tried to find an efficient representation that took account for that kind of rotation?

15:12I had to, otherwise I couldn't do the learning.

15:14Wow.

15:16But I had three parts to my tic-tac-toe program, and I called it brain one, brain two, and brain

15:24three. So brain one just played a... Let's see. At random.

15:35Okay.

15:37It's your turn. Okay. You got to put an X somewhere. It has to go in an empty space,

15:40but that's it. Okay. Choose one and play there. Brain two

15:51had a canned routine, and I think it also... Maybe it assumed you were the first player,

15:59or maybe it allowed you to be first. I think you're allowed to be either first or second,

16:03but it had a canned built-in strategy known to be optimum for tic-tac-toe. Before I forget,

16:09by the way, I learned many years later that Charles Babbage had thought about programming

16:18tic-tac-toe for his dream machine that he was never able to finish.

16:23Wow. So that was the program he thought about?

16:26More than 100 years ago.

16:27Yeah. Wow.

16:28Yeah. He did that. Okay. And I had, however, been influenced by a demonstration at the

16:38Museum of Science and Industry in Chicago. It's like Boston's science museum. I think

16:44Bell Labs had prepared a special exhibit about telephones and relay technology, and they had a

16:51tic-tac-toe playing machine as part of that exhibit. So that had been one of my...

16:58Something I'd seen before I was a freshman in college and inspired me to see if I could write

17:05a program for it. Okay. So anyway, brain one, random, knowing nothing. Brain two,

17:13knowing everything. Then brain three was the learning one. And I could play brain one against

17:22brain one, brain one against brain two, and so on. And so you could also play against the user,

17:28against a live universe. So I started going, the learning thing, and I said, "Okay,

17:35take two random people just playing tic-tac-toe, knowing nothing." And after about... I forget the

17:47number now, but it converged after about 600 games to a safe draw. The way my program learned was

17:56actually, it learned how not to make mistakes. It didn't try to do anything for winning, it just

18:05tried to say not losing. Yeah, draw. Yeah, not lose.

18:07So that was probably because of the way I designed the learning thing. I could have had a different

18:12reinforcement function that would reward brilliant play. But anyway, it didn't...

18:21And if I took a novice against a skilled player, it was able to learn how to play a good game.

18:29And that was really my... But after I finished that, I felt I understood programming.

18:38Was there... Did a curiosity and interest in learning systems persist for you?

18:48So why did you want Brain 3 to learn? Yeah, I think naturally, we're talking

18:58about Rod Brooks. He was teaching all kinds of very small devices to learn stuff. If a leaf

19:07drops off of a tree, he was saying something, "Well, it learns if there's wind or not."

19:17But I mean, he pushed that a little bit too far, but he said he could probably train some little

19:22mini bugs to scour out dishes if he had enough financial support. I don't know.

19:27Can I ask you about that? Because he also mentioned that during those years,

19:36there was discussion about, inspired by Turing, about computation, of what is computation.

19:46Yeah. And...

19:47Yeah, I never thought about any stuff like that. That was way too philosophical. I mean,

19:56I was a freshman after all. I mean, I didn't... I was pretty much a machine.

20:05So it's almost like, yeah, I got you. It's a tinkering mindset, not a philosophical mindset.

20:13It was just exciting to me to be able to control something, but not to say, "Hmm,

20:21am I solving a big problem or something like that? Or is this a step for humankind or anything?"

20:26No, no way.

20:26When did you first start thinking about computation in the big sense? You know,

20:34like the universal Turing machine sense?

20:35Well, I mean, I had to pass an exam. I had to take classes on computability when I was a senior.

20:45So we read this book by Martin Davis and, yeah, this is cool stuff. But I learned about it because

20:52I needed to pass the exams, but I didn't invent any of that boring stuff. But I had great fun

21:00playing with the machine. I wrote programs because it was fun to write programs and get this...

21:09I mean, it was like watching miracles happen.

21:13You mentioned in an interview that when reading a program, you can tell when the author of the

21:22program changed. How the heck can you do that? What makes a distinct style for a programmer,

21:31do you think? There's different... Hemingway has a style of writing versus James Joyce or something.

21:39Yeah, those are pretty easy to imitate, but it's the same with music and whatever.

21:50During the pandemic, I spent a lot more time playing the piano and I found something that I'd

21:55had when I was taking lessons before I was a teenager. And it was Yankee Doodle played in

22:07the style of... You had Beethoven and you had Debussy and Chopin, and the last one was Gershwin.

§02Transcript · 22:19–44:50

22:19And I played over and over again. I thought it was so brilliant, but it was so easy. But also

22:26to appreciate how this author, Mario, somebody or other, had been able to reverse engineer

22:35the styles of those composers. But now, particularly to your question, I mean,

22:47it was pretty obvious in this program I was reading, it was a compiler and it had been

22:53written by a team at Carnegie Mellon. And I have no idea which program was responsible for it,

23:02but you would get to a part where the guy would just not know how to move things between registers

23:09very efficiently. And so everything that could be done in one instruction would take three or

23:15something like that. That would be a pretty obvious change in style. But there were also

23:21flashes of brilliance where you could do in one instruction. Normally I used two, because you knew

23:28enough about the way the machine worked that you could accomplish two goals in one step.

23:34So it was mostly the brilliance of the concept more than the semicolons or the use of short

23:44sentences versus long sentences or something like that.

23:46So you would see the idea in the code, and you can see the different style of thinking expressed.

23:52Right. It was stylistic. I mean, I could identify authors by the amount of technical

24:01aptitude they had, but not by style in the sense of rhythm or something like that.

24:08So if you think about Mozart, Beethoven, Bach, if somebody looked at Don Knuth's code,

24:15would they be able to tell that this is a distinct style of thinking going on here?

24:22What do you think? And what would be the defining characteristic of the style?

24:31Well, my code now is literate programming, so it's a combination of English and C mostly. But

24:40if you just looked at the C part of it, you would also probably notice that I use a lot of global

24:49variables that other people don't. And I expand things in line more than instead of calling.

24:55Anyway, I have different subset of C that I use.

25:00Okay. But that's a little bit stylistic.

25:02But with literate programming, you alternate between English and C or whatever.

25:08And by the way, people listening to this should look up literate programming. It's

25:14very interesting concept that you proposed and developed over the years.

25:21Yeah. That's the most significant thing, I think, to come out of the tech project.

25:30I realized that my programs were to be read by people and not just by computers, and

25:44that typography could massively enhance that. And so, I mean, they're just wondering if they're

25:53going to look it up, that they should also look up this book called Physically Based Rendering

25:58by Matt Farr. And gosh, anyway, it got an Academy Award. But all the graphic effects you see in

26:10movies are accomplished by algorithms. And the whole book is a literate program. It tells you not

26:19only how you do all the shading and bring images in that you need for animation and textures and so

26:28on, but it also, you can run the code. And so, I find it an extension of how to teach programming

26:42by telling a story as part of the program. So, it works as a program, but it's also readable

26:51by humans. Yes, and especially by me a week later or a year later.

26:58That's a good test. You yourself understand the code easily a week or a month or a year later.

27:06So, it's the greatest thing since sliced bread.

27:12Programming? Or literate?

27:14Literate programming.

27:15Okay. You heard it here first. Okay. You dodged this question in an interview I listened to.

27:24So, let me ask you again here. What makes for a beautiful program?

27:29What makes for a beautiful program?

27:31Yeah. What are the characteristics you see? Like you just said, literate programming.

27:36What are the characteristics you see in a program that make you sit back and say, "That's pretty

27:41good"?

27:43Well, the reason I didn't answer is because there are dozens and dozens of answers to that.

27:48Because you can define beauty, the same person will define beauty a different way from hour to

27:56hour. I mean, it depends on what you're looking for. At one level, it's beautiful just if it

28:02works at all. Another level, it's beautiful if it can be understood easily. It's beautiful if it's

28:18literate programming, it's beautiful, it makes you laugh. I mean…

28:21Yeah. I'm actually… So, I'm with you. I think beauty, if it's readable…

28:26Readable, yeah.

28:28If you understand what's going on and also understand the elegance of thought behind it.

28:35And then also, as you said, wit and humor. I was always… I remember having this conversation. I

28:42had this conversation on Stack Overflow, whether humor is good in comments. And I think it is.

28:51Whether humor is good in comments.

28:53Like when you add comments in the code.

28:55Yeah.

28:56I always thought a little bit of humor is good. It shows personality. It shows character,

29:03shows wit and fun and all those kinds of things of the personality of the programmer.

29:08Yeah. Okay. So, a couple days ago, I received a wonderful present from my former editor at

29:17Aston Wesley. He's downsizing his house and he found that somebody at the company had

29:24found all of their internal files about the art of computer programming from the 1960s,

29:32and they gave it to him. And then, before throwing it in the garbage. And then, so he said, "Oh,

29:40yeah." He planned to keep it for posterity, but now he realized that posterity is a bit too much

29:46for him to handle, so he sent it to me. And so, I just received this big stack of letters,

29:56some of which I had written to them, but many of which they had written to

30:01early guinea pigs who were telling them whether they should publish or not. And one of the things

30:08was in the comments to volume one, the major reader was Bob Floyd,

30:19who is my great co-worker in the '60s, died early, unfortunately. And he commented about the humor

30:35in it. And so, we had, he ran it by me, he says, "Keep this joke in or not."

30:41They also sent it out to focus groups. What do you think about humor in a book about computer

30:49programming? What's the conclusion? And I stated my philosophy is that the ideal thing is that it's

30:57something where the reader knows that there's probably a joke here if he only understood it,

31:04and this is a motivation to understand, to think about it a little bit. But anyway,

31:11very delicate humor. I mean, it's really, each century invents a different kind of humor too.

31:19Different cultures have different kinds of humor. Yeah, like we talked about Russia a little bit

31:27offline. There's dark humor. And when a country goes through something difficult-

31:35Right, "Veteran of the Night Live" and stuff like this. And Jack Benny, I mean,

31:39Steve Allen wrote this book about humor, and it was the most boring book. But he was one of my

31:47idols. But yeah, it's called "The Funny Men" or something like that. But yeah, okay. So anyway,

31:54I think it's important to know that this is part of life, and it should be fun and not.

32:00And so I wrote this organ composition, which is based on the Bible, but I didn't refrain from

32:10putting little jokes in it also in the music. It's hidden in the music.

32:15It's there, yeah. A little humor is okay?

32:19Yeah. I mean, not egregious humor. So in this correspondence, there were

32:24things I said, "Yeah, I really shouldn't have done that." But other ones I insisted on. And I've got

32:35jokes in there that nobody has figured out yet. In fact, in volume two, I've got a cryptogram,

32:45a message, enciphered. And in order to decipher it, you're going to have to break an RSA key,

32:53which is larger than people know how to break. And so if computers keep getting faster and faster,

33:00then it might be 100 years, but somebody will figure out what this message is, and they will

33:05laugh. I mean, I've got a joke in there. So that one you really have to work for.

33:12I don't know if you've heard about this. Let me explain it. Maybe you'll find it interesting.

33:18So OpenAI is a company that does AI work, and they have this language model. It's a neural

33:26network that can generate language pretty well. But they also, on top of that, developed something

33:35called OpenAI Codex. And together with GitHub, they developed a system called OpenAI Copilot.

33:42Let me explain what it does. There's echoes of literate programming in it. So what you do

33:50is you start writing code, and it completes the code for you. So for example, you start,

33:57let's go to your factoring program. You write in JavaScript and Python and any language

34:04that it trained on. You write the first line and some comments, like what this code does,

34:12and it generates the function for you. And it does an incredibly good job. It's not provably right,

34:19but it often does a really good job of completing the code for you.

34:23- I see. But how do you know whether it did a good job or not?

34:26- You could see a lot of examples where it did a good job. And so it's not a thing that

34:34generates the code for you. It starts, it gives you, so it puts the human in the seat of fixing

34:41issues versus writing from scratch. Do you find that kind of idea at all interesting?

34:47- Every year we're going to be losing more and more control over what machines are doing. And

34:53people are saying, well, it seems to, when I was a professor at Caltech,

35:00in the sixties, we had this guy who talked a good game. He could give inspiring lectures and you'd

35:10think, well, certainly the things he was talking about an hour later, you say, well, what did he

35:16say? But he really felt that it didn't matter whether computers got the right answer or not.

35:23It just mattered whether it made you happy or not. In other words, if your boss paid for it,

35:29then you had a job, you could take care of your wife.

35:35- So happiness is more important than truth.

35:37- Exactly. He didn't believe in truth, but he was a philosopher.

35:40- I like it. And somehow you see...

35:45- We're going that way. I mean, so many more things are taken over by saying, well, this seems to

35:52work. And when there's a competing interest involved, neither side understands why the

36:01decision is being made. We realize now that it's bad, but consider what happens five years, 10

36:11years down the line, when things get even more further detached and each thing is based on

36:17something from the previous year.

36:19- Yeah. So you start to lose... The more you automate, the more you start to lose track of

36:25some deep human thing.

36:27- Exponentially.

36:27- Exponentially. So that's the dark side. The positive side is the more you automate,

36:36the more you let humans do what humans do best. So maybe programming, maybe humans should focus

36:45on a small part of programming that requires that genius, the magic of the human mind,

36:50and the mess you let the machine generate. I mean, that's the positive, but of course,

36:57it does come with the darkness of automation. What's better, correctness?

37:02- I'm never going to try to write a book about that. I'm never going to recommend to any of

37:08my students to work for them.

37:09- So you're on the side of correctness, not beauty.

37:13- I'm on the side of understanding.

37:16- Understanding.

37:17- And I think these things are really marvelous if what they do is, all of a sudden we have a

37:25better medical diagnosis or it'll help guide some scientific experiment or something like this,

37:31curing diseases or whatever. But when it affects people's lives in a serious way,

37:43so if you're writing code for, "Oh yeah, here, this is great. This will make a slaughter bot."

37:50- Okay. So I see. So you have to be very careful. Like right now, it seems like fun and games.

37:59It's useful to write a little JavaScript program that helps you with a website.

38:04But like you said, one year passes, two years passes, five years, and you forget.

38:10You start building on top of it, and then all of a sudden you have autonomous weapon systems.

38:14- Well, we're all dead. It doesn't matter in that sense.

38:19- Well, in the end, this whole thing ends anyway.

38:25- There is a heat death of the universe predicted, but I'm trying to postpone that for...

38:35- For a little bit? Well, it'd be nice that at the end, as we approach the heat death of the

38:42universe, there's still some kind of consciousness there to appreciate it. Hopefully human consciousness.

38:51- I'll settle for 10 to the 10 to the 10 to the 10th year, some finite number. But

38:55things like this might be the reason we don't pick up any signals from extraterrestrial...

39:04- They don't want anything to do with us. Oh, because they...

39:07- Because they invented it too.

39:10- So you do have a little bit of worry on the existential threats of AI and automation.

39:22So like removing the human from the picture.

39:25- Et cetera, yeah. People have more potential to do harm now by far than they did 100 years ago.

39:35- But are you optimistic about... So humans are good at creating destructive things,

39:42but also humans are good at solving problems.

39:44- Yeah, I mean, there's half empty and half full, you know.

39:46- So are we half full?

39:50- I can go... So let me put it this way, because it's the only way I can be optimistic. But

40:00think of things that have changed because of civilization. They don't occur just in nature.

40:11So just imagine the room we're in, for example. Okay, we've got pencils, we've got books, we've

40:20got tables, we've got microphones, clothing, food. All these things were added. Somebody

40:28invented them one by one, and millions of things that we inherit, okay? And it's inconceivable

40:38that so many millions of billions of things wouldn't have problems, and we'd get it all right.

40:46And each one would have no negative effects and so on. So it's very amazing that as much

40:57works as does work. - It's incredibly amazing. And actually,

41:03that's the source of my optimism as well, including for artificial intelligence. So

41:09we drive over bridges, we use all kinds of technology, we don't know how it works,

41:17and there's millions of brilliant people involved in building a small part of that,

41:22and it doesn't go wrong, and it works. And I mean, it works, and it doesn't go wrong often enough

41:30for us to suffer. - And we can identify

41:32things that aren't working and try to improve on them.

41:37- In a often suboptimal way. - Oh, absolutely.

41:41- But it's still so- - But the kind of things that I know how to

41:48improve require human beings to be rational, and I'm losing my confidence that human beings

41:54are rational. - Yeah, yeah. Now, here you go again with

41:58the worst-case analysis. They may not be rational, but they're clever and beautiful in their own kind

42:11of way. I tend to think that most people have the desire and the capacity to be good to each other,

42:19and love will ultimately win out. If they're given the opportunity, that's where they lean.

42:25In "The Art of Computer Programming," you wrote, "The real problem is that programmers have spent

42:32far too much time worrying about efficiency in the wrong places and at the wrong times.

42:37Premature optimization is the root of all evil," in parentheses, or at least most of it,

42:44in programming. Can you explain this idea? What's the wrong time? What is the wrong place for

42:53optimization? - So, first of all, the word

42:56optimization. I started out writing software, and optimization was, I was a compiler writer,

43:05so optimization meant making a better translation so that it would run faster on a machine. So,

43:15an optimized program is just like, you run a program and you set the optimization level

43:21to the compiler. So, that's one word for optimization. At that time, I happened to

43:30be looking in an unabridged dictionary for some reason or other, and I came to the word optimize.

43:36What's the meaning of the word optimize? And it says, "To view with optimism."

43:42And you look in Webster's dictionary of English language in the early 1960s, that's what optimize

43:51meant. Okay. So, people started doing cost optimization, other kinds of things,

43:59whole subfields of algorithms and economics and whatever are based on what they call optimization

44:09now. But to me, optimization, when I was saying that, was changing a program to make it more

44:20tuned to the machine. And I found out that when a person writes a program,

44:26he or she tends to think that the parts that were hardest to write are going to be hardest for the

44:36computer to execute. So, maybe I have 10 pages of code, but I had to work a week writing this page.

44:46I mentally think that when the computer gets to that page, it's going to slow down.

44:50Right.

§03Transcript · 44:52–1:06:37

44:52It's going to say, "Oh, I don't understand what I'm doing. I better be more careful." Anyway,

44:56this is, of course, silly, but it's something that we don't know when we write a piece of code. We

45:04don't know whether the computer is actually going to be executing that code very much.

45:10So, people had a very poor understanding of what the computer was actually doing.

45:17I made one test where we studied a Fortran compiler,

45:23and it was spending more than 80% of its time reading the comments card.

45:28But as a programmer, we were really concerned about how fast it could take a complicated

45:35expression that had lots of levels of parentheses and convert that into something. But that was just

45:43less than 1%. So, if we optimize that, we didn't know what we were doing. But if we knew that it

45:53was spending 80% of its time on the comments card in 10 minutes, we could make the compiler run more

45:59than twice as fast.

46:01You could only do that once you've completed the program, and then you empirically study where...

46:05I had some kind of profiling that I knew what was important. Yeah.

46:09So, you don't think this applies generally? I mean, there's something that rings true to this

46:15across all of them.

46:15I'm glad that it applied generally, but it was only my good luck. I said it, but I said it in

46:23a limited context, and I'm glad if it makes people think about stuff.

46:28But it applies in another sense too, that is, sometimes I will do optimization in a way that

46:41does help the actual running time, but makes the program impossible to change next week,

46:49because I've changed my data structure or something that made it less adaptable.

46:56So, one of the great principles of computer science is laziness, or whatever you call it,

47:04late binding. Hold off decisions when you can. And we understand now,

47:14quantitatively, how valuable that is.

47:18What do you mean we understand?

47:23People have written thesis about how late binding will improve the... I mean, just-in-time

47:31manufacturing or whatever, you can defer a decision instead of doing your advanced planning

47:37and say, "I'm going to allocate 30% to this and 50%..."

47:41So, in all kinds of domains, there's an optimality to laziness in many cases.

47:45Decision is not made in advance. So, instead, you design, in order to be flexible,

47:53to change with the way the wind is blowing.

47:56Yeah. But so, the reason that line resonated with a lot of people is because there's something

48:04about the programmer's mind that wants, that enjoys optimization. So, it's a constant struggle

48:11to balance laziness and late binding with the desire to optimize, the elegance of a well-optimized

48:23code is something that's compelling to programming.

48:25Yeah. It's another concept of beauty.

48:30Let me ask you a weird question. So, Roger Penrose has talked about computation, computers,

48:39and he proposed that the way the human mind discovers mathematical ideas is something more

48:49than a computer, that a universal Turing machine cannot do everything that a human mind can do.

48:57Now, this includes discovering mathematical ideas, and it also includes, he's written a

49:04book about it, consciousness. So, I don't know if you know, Roger, but...

49:08My daughter's kids played with his kids in Oxford.

49:14Nice. So, do you think there is such a limit to the computer? Do you think consciousness is more

49:21than a computation? Do you think the human mind, the way it thinks, is more than a computation?

49:27I mean, I can say yes or no, but I have no reason.

49:33I mean...

49:36So, you don't find it useful to have an intuition in one way or the other? Like,

49:40when you think about algorithms, isn't it useful to think about...

49:43I think it's an unanswerable question, in my opinion, is no better than anybody else's.

49:49You think it's unanswerable. So, you don't think eventually science...

49:52How many angels can dance on the head of a... I mean, I don't know.

49:54But angels...

49:56Anyway, there are lots of things that we can speculate about, but I don't want somebody to

50:04say, "Oh, yeah, Cano said this, and so he's smart, and so that must be..." I mean, I say it's

50:12something that we'll never know.

50:14Interesting. Okay, that's a strong statement. I personally think it's something we will know

50:22eventually. Like, there's no reason to me why the workings of the human mind

50:28are not within the reach of science.

50:30That's absolutely possible, and I'm not denying it.

50:34Yeah. But right now, you don't have a good intuition one way or the other.

50:37That's also possible that an AI created the universe. Intelligent design has all been done

50:45by an AI. All of these things are... But you're asking me to pronounce on it, and I don't have

50:54any expertise. I'm a teacher that passes on knowledge, but I don't know... The fact that I

51:02vote yes or no on...

51:06Well, you do have expertise as a human, not as a teacher or a scholar of computer science.

51:13I mean, that's ultimately the realm of where the discussion of human thought and consciousness is.

51:21I know where Penrose is coming from. I'm sure he has no... He might even have thought he

51:27proved it, but...

51:28No, he doesn't. He doesn't prove it. He is following intuition.

51:33I mean, you have to ask John McCarthy. John McCarthy, I think,

51:38was totally unimpressed by these statements.

51:41So you don't think... So even like the Turing paper on the Turing test that starts by asking,

51:52"Can machines think?" You don't think these kind of... So Turing doesn't like that question.

51:59Yeah. I don't consider it important, let's just put it that way,

52:03because it's in the category of things that it would be nice to know, but I think it's

52:10beyond knowledge. And so I don't... I'm more interested in knowing about the Riemann hypothesis

52:19or something.

52:19So when you say... It's an interesting statement, "beyond knowledge."

52:23Yeah.

52:24I think what you mean is it's not sufficiently well... It's not even known well enough to be

52:31able to formalize it in order to ask a clear question. And so that's why it's beyond knowledge,

52:37but that doesn't mean it's not eventually going to be formalized.

52:41Yeah. Maybe consciousness will be understood some day, but the last time I checked,

52:49it was still 200 years away. I haven't been specializing in this by any means, but I went

52:56to lectures about it 20 years ago when I was... There was a symposium at the American Academy

53:02in Cambridge, and it started out by saying essentially,

53:06"Everything that's been written about consciousness is hogwash."

53:12I tend to disagree with that a little bit. So consciousness for the longest time still

53:22is in the realm of philosophy. So it's just conversations without any basis and understanding.

53:28Still, I think once you start creating artificial intelligence systems that interact with humans,

53:38and they have personality, they have identity, you start flirting with the question of consciousness,

53:45not from a philosophical perspective, but from an engineering perspective.

53:49Yeah.

53:50And then it starts becoming much more... I feel like...

53:53Yeah. Don't misunderstand me. I certainly don't disagree with that at all.

53:59Even at these lectures that we had 20 years ago, there were neurologists pointing out that

54:08that human beings had actually decided to do something before they were conscious of making

54:14that decision. I mean, they could tell that signals were being sent to their arms before

54:22they knew that they were sick, and things like this are true. And Les Valiant has

54:31an architecture for the brain, and more recently, Christos Papadimitriou,

54:37in the Academy of Science Proceedings a year ago with two other people, but I know Christos

54:45very well. And he's got this model of this architecture by which you could create things

54:58that correlate well with experiments that are done on consciousness. And he actually has a

55:08machine language in which you can write code and test hypotheses. And so we might have a big

55:22breakthrough. My personal feeling is that consciousness, the best model I've heard of

55:30to explain the miracle of consciousness is that somehow inside of our brains, we're having a

55:45continual survival for the fittest competition. As I'm speaking to you, all the possible things I

55:52might be wanting to say... Are all in there. There's like a voting going on.

55:57Yeah, right. And one of them is winning, and that's affecting the next sentence and so on.

56:06And there was this book, Machine Intelligence or something?

56:11On Intelligence.

56:12On Intelligence. Yeah. Bill Atkinson was a total devotee of that book.

56:21Well, I like whether it's consciousness or something else, I like the storytelling part

56:27that it feels like for us humans, it feels like there's a concrete... It's almost like

56:35literary programming. I don't know what the programming going on on the inside,

56:38but I'm getting a nice story here about what happened. And it feels like I'm in control and

56:44I'm getting a nice clear story. But it's also possible there's a computation going on

56:48that's really messy. There's a bunch of different competing ideas. And in the end,

56:54it just kind of generates a story for you to... A consistent story for you to believe.

57:00And that makes it all nice.

57:01Yeah. And so I prefer to talk about things that I have some expertise in

57:07than things which I'm only on the sideline.

57:13So there's a tricky thing. I don't know if you have any expertise in this.

57:18You might be a little bit on the sideline. It'd be interesting to ask though.

57:21What are your thoughts on cellular automata in the game of life?

57:24Have you ever played with those kinds of little games?

57:28I think the game of life is wonderful and shows all kinds of stuff about how things can evolve

57:43without the creator understanding anything more than the power of learning in a way. But to me,

57:51the most important thing about the game of life is how it focused for me

57:58what it meant to have free will or not. Because the game of life is obviously totally deterministic.

58:09Yes.

58:09I find it hard to believe that anybody who's ever had children cannot believe in free will. On the

58:17other hand, this makes it crystal clear. John Conway said he wondered whether it was immoral

58:30to shut the computer off after he got into a particularly interesting play of the game of life.

58:34Wow. Yeah. So to me, the reason I love the game of life is exactly as you said,

58:43a clear illustration that from simple initial conditions with simple rules,

58:48you know exactly how the system is operating, is deterministic. And yet, if you allow yourself to

58:58lose that knowledge a little bit, enough to see the bigger organisms that emerge,

59:06and then all of a sudden they seem conscious. They seem not conscious, but living.

59:11If the universe is finite, we're all living in the game of life to slow down. I mean,

59:17it's sped up a lot. But do you think technically some of the ideas that you used for analysis of

59:26algorithms can be used to analyze the game of life? Can we make sense of it or is it too weird?

59:33Yeah. I mean, I've got a dozen exercises in volume for fascicle six that actually work

59:43rather well for that purpose. Bill Gosspers came up with the algorithm that allowed Gali to run

59:57thousands and thousands of times faster. You know the website called Gali? G-O-L-L-Y.

60:04It simulates the cellular automata, a game of life.

60:07Yeah. You got to check it out. Yeah.

60:09Can I ask you about John Conway?

60:11Yes. In fact, I'm just reading now the issue of mathematical intelligence that came in last week.

60:20It's a whole issue devoted to remembrance of him.

60:27Did you know him?

60:29I slept overnight in his house several times.

60:33Yeah.

60:36He recently passed away.

60:37Yeah. He died a year ago, May, I think it was, of COVID.

60:49What are some memories of him, of his work that stand out for you? On a technical level,

60:58did any of his work inspire you? On a personal level, did he himself inspire you in some way?

61:04Absolutely, all of those things. But let's see, when did I first meet him? I guess I first met

61:11him at Oxford in 1967 when I was...

61:14Wow. Okay. That's a long time ago.

61:17Yeah. You were minus 20 years old or something. I don't know, 1967. But there was a conference where

61:25Minus 20 years old.

61:28I think I was speaking about something known as the Knuth-Bendix algorithm now. But he gave a

61:37famous talk about knots. I didn't know at the time, but that talk had now... It was the source

61:48of thousands and thousands of papers since then. He was reported on something that he had done

61:55in high school, almost 10 years earlier, before this conference, but he never published it.

62:05He climaxed his talk by building some knots. You have these little plastic things that you

62:13can stick together. It's something like Lego, but easier. He made a whole bunch of knots in front of

62:23the audience and so on, and then disassembled it. It was a dramatic lecture. Before he had learned

62:31how to give even more dramatic lectures later. All right.

62:35Were you at that lecture?

62:37And I was there, yeah, because I was at the same conference. For some reason, I happened to be in

62:46Calgary at the same day that he was visiting Calgary. It was the spring of '72, I'm pretty sure.

62:58And we had lunch together. He wrote down during the lunch on a napkin,

63:03all of the facts about what he called numbers. He covered the napkin with the theorems about his

63:20idea of numbers. I thought it was incredibly beautiful. Later in 1972, my sabbatical year

63:31began and I went to Norway. In December of that year, in the middle of the night,

63:37the thought came to me, Conway's theory about numbers would be a great thing to teach students

63:46how to invent research and what the joys are of research. I had also read a book in dialogue

63:58by Alfred Rényi, kind of a Socratic thing where the two characters were talking to each other

64:07about mathematics. At the end, in the morning, I woke up my wife and said, "Jill, I think I want

64:18to write a book about Conway's theory. You know, I'm supposed to be writing the Art of Computer

64:28Programming and doing all this other stuff, but I really want to write this other book."

64:34And so we made this plan, but I said, "I thought I could write it in a week."

64:39And we made the plan then. So in January, I rented a room in a hotel in downtown Oslo. We

64:47were in sabbatical in Norway. And I rented the hotel in downtown Oslo and did nothing else

64:56except write up Conway's theory. And I changed the name to Surreal Numbers. So this book is now

65:03published as Surreal Numbers. And we'd always wondered, "Would he like to have an affair in a

65:13hotel room?" So we figured out that she would visit me twice during the week. Things like this,

65:19you know, we would try to sneak in. This hotel was run by a mission organization. These ladies were

65:28probably very strict. But anyway, so- Yeah.

65:30And- It's a wild week in every way.

65:35But the thing is, I had lost that napkin in which he wrote the theory. But I looked for it,

65:42but I couldn't find it. So I tried to recreate from memory what he had told me at that lunch

65:48in Calgary. And as I wrote the book, I was going through exactly what the characters in the book

65:57were supposed to be doing. So I start with the two axioms and start out the whole thing. And

66:02everything is defined, flows from that, but you have to discover why. And every mistake that I

66:09make as I'm trying to discover it, my characters make too. And so it's a long, long story. But I

66:18worked through this week. And it was one of the most intense weeks of my life. And I described it

66:31in other places. But anyway, after six days, I finished it. And on the seventh day, I rested.

66:37And I sent to my secretary to type it. It was flowing as I was writing it,

§04Transcript · 1:06:46–1:27:50

66:46faster than I could think almost. But after I finished it, and try to write a letter to my

66:54secretary, telling her how to type it, I couldn't write anymore.

66:57You gave it everything.

66:59The muse had left me completely.

67:00Can you explain how that week could have happened? Like why is that seems like such a magical week?

67:06I have no idea. But anyway, there was some, it was almost as if I was channeling.

67:13So the book was typed, I sent it to Conway. And he said, well, Dan, you got the one axiom wrong.

67:21There's a difference between less than or equal and not greater than. I don't know.

67:30The opposite of being greater than and less than or equal. But anyway,

67:36technically, it can make a difference when you're developing a logical theory.

67:41And the way I had chosen was harder to do than John's original.

67:45So, and we visited him at his house in Cambridge. In April, we took a boat actually from Norway

67:53over to across the channel and so on and stayed with him for some days. And,

67:58and he told he talked, we talked about all kinds of things he has. He had

68:08puzzles that I'd never heard of before. He had a great way to solve the game of solitaire.

68:13Many of the common interests that we'd, you know, he'd never written them up. But anyway,

68:20then in the summertime, I took another week off and went to a place in the mountains of Norway and

68:30rewrote the book using the correct axiom. So that was the most intensive connection with Conway.

68:38After that, it started with a napkin.

68:41It started with a napkin. But we would run into each other. Yeah, the next really,

68:50I was giving lectures in Montreal. I was giving a series of seven lectures about a topic called

69:02stable marriages. And he arrived in Montreal between my sixth and seventh lecture. And we met

69:13at a party. And I started telling him about the topic I was doing. And he sat and thought about

69:21it. He came up with a beautiful theory to show that the, I mean, in technical terms, it's that

69:29the set of all stable marriages, it forms a lattice. And there was a simple way to find the

69:35greatest lower bound of two stable pairings and least upper bound of two stable marriage. And so

69:42I could use it in my lecture the next day. And he came up with this theorem during the party.

69:47And it's a brilliant.

69:51It's a distributive lesson. I mean, it added greatly to the theory of stable matching.

70:00So you mentioned your wife, Jill, you mentioned stable marriage. Can you tell the story of how

70:07you two met?

70:07So we celebrated 60 years of wedded bliss last month. And we met because I was dating her

70:17roommate. This was my sophomore year, her freshman year. I was dating her roommate and

70:24I wanted her advice on strategy or something like this. And anyway, I found I enjoyed her

70:32advice better than her. I enjoyed her roommate.

70:35You guys were majoring the same thing?

70:39No, no, no.

70:40Because I read something about working on a computer in grad school, on a difficult

70:47computer science topic.

70:48So she's an artist and I'm a geek.

70:55Okay. What was she doing with a computer science book? Or I read, was it the manual that she was

71:01reading? What was she reading?

71:02I wrote the manual that she had to take a class in computer science.

71:07Okay. And so...

71:09You're the tutor.

71:10No, no. Yeah. There were terrible times trying to learn certain concepts, but I learned art

71:22from her. And so we worked together occasionally in design projects, but every year we write a

71:31Christmas card and we each have to compromise our own notions of beauty.

71:39Yes. When did you fall in love with her?

71:43That day that I asked her about her roommate.

71:48Okay.

71:50I mean, no, I... Okay. So you're... I don't mind telling these things, depending on how

71:57you far, how far you go, but... But let me tell you...

72:02I promise. I promise not to go too far.

72:05Let me tell you this, that I never really enjoyed kissing until I found how she did it.

72:13Wow. And 60 years.

72:17Is there a secret you can say in terms of stable marriages of how you stayed together so long?

72:26The topic stable marriage, by the way, is not... It is a technical term.

72:32Yes.

72:34It's a joke, Don.

72:36But two different people will have to learn how to compromise and work together, and you're

72:48going to have ups and downs and crises and so on. And so as long as you don't set your expectation on

72:58having 24 hours of bliss, then there's a lot of hope for stability. But if you decide that it's...

73:06That there's going to be no frustration, then...

73:11So you're going to have to compromise on your notions of beauty when you write Christmas cards.

73:18That's it.

73:18You mentioned that Richard Feynman was someone you looked up to.

73:24Yep.

73:27Probably you've met him in Caltech.

73:28Well, we knew each other. Yeah, at Caltech for sure.

73:34You are one of the seminal personalities of computer science. He's one for physics.

73:41Is there specific things you picked up from him by way of inspiration or...?

73:49So we used to go to each other's lectures, but if I saw him sitting in the front row,

73:57it would throw me for a loop, actually. I would miss a few sentences.

74:05What unique story do I have? I mean, I often refer to his time in Brazil,

74:16where he essentially said they were teaching all the physics students the wrong way. They were just

74:22learning how to pass exams and not learning any physics. And he said, "If you want me to prove it,

74:29here, I'll turn to any page of this textbook, and I'll tell you what's wrong with this page."

74:36And he did so. And the textbook had been written by his host, and it was a big embarrassing

74:44incident, but he had previously asked his host if he was supposed to tell the truth.

74:48But anyway, it epitomizes the way education goes wrong in all kinds of fields,

74:58and has to periodically be brought back from a process of giving credentials to a process of

75:08giving knowledge. Yeah, that's probably a story that continues to this day in a bunch of places.

75:14Where it's too easy for educational institutions to fall into credentialism versus inspirationalism.

75:26I don't know if those are words, but sort of understanding versus just giving a little

75:33plaque. And it's very much like what we were talking about. If you want the computer to,

75:43if you want to be able to believe the answer, a computer is doing. One of the things Bob Floyd

75:50showed me in the '60s, there was a, he loved this cartoon. There were two guys standing in front of,

75:58in those days, a computer was a big thing, you know. And the first guy says to the other guy,

76:03he said, "This machine can do in one second what it would take a million people to do in a hundred

76:11years." And the other guy says, "Oh, so how do you know it's right?" That's a good line.

76:18Is there some interesting distinction between physics and math to you? Have you looked at

76:26physics much? Like speaking of Richard Feynman, the difference between the physics community,

76:33the physics way of thinking, the physics intuition versus the computer science,

76:38the theoretical computer science, the mathematical sciences, do you see that as a gap or are they

76:42strongly overlapping? It's quite different, in my opinion. I started as a physics major and I

76:50switched into math. And probably the reason was that I could get A+ on the physics exam, but I

76:58never had any idea why I would have been able to come up with the problems that were on those exams.

77:06But in math, I knew why the teacher set those problems and I thought of other problems that

77:15I could set too. And I believe it's quite a different mentality. It has to do with your

77:23philosophy of geekdom? Some of my computer scientist friends are really good at physics

77:31and others are not. And I'm really good at algebra, but not at geometry. Talk about different

77:40parts of mathematics. So they're different kinds of physical, but physicists think of things in

77:46terms of waves. And I can think of things in terms of waves, but it's like a dog walking on hind

77:53legs if I'm thinking about it. So you basically, you like to see the world in discrete ways and

78:00then physics is more continuous. Yeah. I'm not sure if Turing would have been a great physicist.

78:07I think he was a pretty good chemist, but I don't know. But anyway, I see things.

78:14I believe that computer science is largely driven by people who have brains who are good at

78:28resonating with certain kinds of concepts. And quantum computers, it takes a different kind of

78:37brain. Yeah, that's interesting. Yeah. Well, quantum computers is almost like at the intersection

78:42in terms of brain between computer science and physics, because it involves both at least at

78:49this time. But there is like the physicists I've known, they have incredibly powerful intuition.

78:59And I mean, statistical mechanics. So I study statistical mechanics and

79:05random processes are related to algorithms in a lot of ways. But there's lots of different

79:15flavors of physics as there are different flavors of mathematics as well. But the thing is that I

79:23don't see, well, actually when they talk to physicists, use a completely different language

79:30than when they're talking to, when they're writing expository papers. And so I didn't

79:35understand quantum mechanics at all from reading about it in Scientific American.

79:39But when I read how they described it to each other, talking about eigenvalues and various

79:47mathematical terms that made sense, then it made sense to me. But Hawking said that

79:56every formula you put in a book, you lose half of your readers. And so he didn't put any formulas

80:01in the book. So I couldn't understand his book at all. You could say you understood it, but I

80:06really didn't. Well, Feynman also spoke in this way. So Feynman, I think, prided himself on a

80:17really strong intuition, but at the same time, he was hiding all the really good, the deep

80:22computation he was doing. So there was one thing that I was never able to, I wish I'd had more time

80:31to work out with him, but I guess I could describe it for you. There's something that

80:37got my name attached to it called Knuth-Arrow notation, but it's a notation for very large

80:44numbers. And so I find out that somebody invented it in the 1830s. It's fairly easy to understand

80:55anyway. So you start with X plus X plus X plus X, N times, and you can call that XN.

81:04So XN is multiplication. Then you take X times X, times X times X, and N times. That gives you

81:13exponentiation, X to the Nth power. So that's one arrow. So XN with no arrows is multiplication.

81:22X arrow N is X to the Nth power. Yeah. So just to clarify for the...

81:27So X times X times X, N times is obviously XN.

81:34X plus X plus X, N times.

81:38Oh yeah. Okay. And then...

81:40XN, no arrows.

81:41And then multiplication is X to the N. And then here, the arrow is when you're doing the same

81:48kind of repetitive operation for the exponential.

81:51So I put in one arrow and I get X to the Nth power. Now I put in two arrows, and that takes

81:57X to the X to the X to the X to the X, N times power. So in other words, if it's two double arrow

82:08three, that would be two to the two to the two. So that would be two to the fourth power. That'd

82:14be 16. Okay. So that's the double arrow. And now you can do a triple arrow, of course, and so on.

82:28And I had this paper called, well, essentially big numbers. You try to impress your friend,

82:38but by saying a number they never thought of before. And I gave a special name for it,

82:46and designed a font for it that has script K and so on. But it really is 10, I think,

82:53like 10 quadruple arrow three or something like that. And I claim that that number is so mind

83:00boggling that you can't comprehend how large it is. But anyway, I talked to Feynman about this,

83:07and he said, "Oh, let's just use double arrow. But instead of taking integers, let's consider

83:15complex numbers." So you have, I mean, okay, X arrow, arrow two, that means X to the X.

83:23But what about X double arrow 2.5? Well, that's not too hard to figure out. That's

83:33interpolate between those. But what about X double arrow I, or one plus I, or some complex number?

83:44And so he claimed that there was no analytic function that would do the job.

83:53But I didn't know how he could claim that that wasn't true.

84:00And his next question was, did then have a complex number of arrows?

84:05Yeah, okay.

84:10Wow, okay.

84:11So that's Feynman.

84:13Can you describe what the Knuth-Morris-Pratt algorithm does, and how did you come to develop

84:24it? One of the many things that you're known for, and has your name attached to it.

84:28Yeah, all right. So it should be actually Morris-Pratt-Knuth,

84:33but we decided to use alphabetical order when we published the paper.

84:39The problem is something that everybody knows now if they're using a search engine.

84:45You have a large collection of text, and you want to know if the word Knuth appears anywhere in the

84:56text, let's say, or some other word that's less interesting than Knuth.

85:02That's the most interesting word.

85:05Like Morris or something.

85:05Like Morris, right.

85:07So anyway, we have a large piece of text, and it's all one long, one-dimensional thing.

85:15You know, first letter, second letter, et cetera, et cetera, et cetera.

85:19And so the question, we'd like to be able to do this quickly.

85:24And the obvious way is, let's say we're looking for Morris.

85:30So we would go through and wait till we get to letter M.

85:36Then we look at the next word, and sure enough, it's an O, and then an R.

85:40But then, too bad, the next letter is E.

85:46So we missed out on Morris.

85:50And so we go back and start looking for another.

85:54I'll go over again.

85:55So that's the obvious way to do it.

85:57All right.

86:00And Jim Morris noticed there was a more clever way to do it.

86:06The obvious way would have started, let's say, we found that letter M at character position 1000.

86:13So it was started next at character position 1001.

86:18But he said, no, look, we already read the O and the R, and we know that they aren't M's.

86:27So we don't have to read those over again.

86:32And this gets pretty tricky when the word isn't Morris, but it's more like abracadabra,

86:41where you have patterns that are occurring.

86:44Like repeating patterns, at the beginning, at the middle, and--

86:49Right.

86:49So he worked it out, and he put it into the system software at Berkeley, I think it was,

86:57where he was writing some Berkeley Unix, I think it was some routine that was supposed

87:03to find occurrences of patterns in text.

87:05And we didn't explain it.

87:11And so he found out that several months later, somebody had looked at it, didn't look right,

87:18and so they ripped it out.

87:19So he had this algorithm, but it didn't make it through, because it wasn't understood.

87:27Nobody knew about this particularly.

87:29Von Pratt also had independently discovered it a year or two later.

87:36I forget why.

87:39I think Von was studying some technical problem about palindromes or something like that.

87:50Von wasn't working on text searching, but he was working on an abstract problem that was related.

§05Transcript · 1:27:59–1:50:06

87:59Well, at that time, Steve Cook was a professor at Berkeley, and it was the greatest mistake that

88:08Berkeley CS department made, was not to give him tenure.

88:12So Steve went to Toronto.

88:17But I knew Steve while he was at Berkeley, and he had come up with a very peculiar theorem

88:24about a technical concept called a stack automaton.

88:29And a stack automaton is a machine that can't do everything a Turing machine can do, but

88:37it can only look at something at the top of a stack, or it can put more things on the stack,

88:43or it can take things off the stack.

88:46It can't remember a long string of symbols, but it can remember them in reverse order.

88:52So if you tell a stack automaton A, B, C, D, E, it can tell you afterwards E, D, C, B, A.

89:00It doesn't have any other memory except this one thing that it can see.

89:06And Steve Cook proved this amazing thing that says, if a stack automaton can recognize a language

89:16where the strings of the language are length N, in any amount of time whatsoever,

89:21to the stack automaton, you might use a zillion steps, a regular computer can recognize that

89:28same language in time N log N. So Steve had a way of transforming a computation that goes on and on

89:35and on and on, into using different data structures, into something that you can do on a regular

89:42computer, fast. The stack automaton goes slow, but somehow the fact that it can do it at all

89:52means that there has to be a fast way. So I thought this was a pretty cool theorem.

89:58And so I tried it out on a problem where I knew a stack automaton could do it,

90:07but I couldn't figure out a fast way to do it on a regular computer. I thought I was a pretty

90:12good programmer, but by golly, I couldn't think of any way to recognize this language efficiently.

90:21So I went through Steve Cook's construction. I filled my blackboard with all the, everything

90:29that stack automaton did, you know, I wrote down. And then I tried to see patterns in that,

90:40and how did he convert that into a computer program on a regular machine? And finally,

90:46I psyched it out. What was the thing I was missing so that I could say, oh yeah,

90:53this is what I should do in my program. And now I have a efficient program. And so I would never

91:02have thought about that if I hadn't had his theorem, which was a purely abstract thing.

91:09So you used this theorem to try to intuit how to use the stack automaton for the string matching

91:16problem?

91:16Yeah. So the problem I had started with was not the string matching problem, but then I realized

91:24that the string matching problem was another thing which could be done by a stack automaton.

91:30And so when I looked at what that told me, then I had a nice algorithm for this

91:36string matching problem. And it told me exactly what I should remember as I'm going through the

91:44string. And I worked it out, and I wrote this little paper called "Automata Theory Can Be

91:50Useful." And the reason was that it was the first, I mean, I had been reading all kinds of papers

91:56about automata theory, but it never taught me, it never improved my programming for everyday

92:03problems. It was something that you published in journals and it was interesting stuff. But

92:10here was a case where I couldn't figure out how to write the program. I had a theorem from

92:15automata theory, then I knew how to write the program. So this was, for me, a change in life.

92:24I started to say, maybe I should learn more about automata theory. And I showed this note to Vaughn

92:32Pratt, and he said, "Hey, that's similar to something I was working on." And then, and Jim

92:40Morris was at Berkeley too at the time. Anyway, he's had an illustrious career, but I haven't kept

92:48track of Jim, but Vaughn is my colleague at Stanford and my student later. But this was before

92:55Vaughn, Vaughn was still a graduate student and hadn't come to Stanford yet. So we found out that

93:01we'd all been working on the same thing. So it was our algorithm, we each discovered it

93:05independently, but each of us had discovered a different part of the elephant, a different

93:13aspect of it. And so we could put our things together. It was my job to write the paper.

93:19How did the elephant spring to life?

93:22Spring to life was because I had drafted this paper, automata theory can be useful,

93:31which was seen by Vaughn and then by Jim. And then we combined, because maybe they had also

93:37been thinking of writing something up about it.

93:40About specifically the string match?

93:42Specifically the string match problem, period.

93:45Let me ask a ridiculous question. Last time we talked, you told me what the most beautiful

93:54algorithm is actually for strongly connected graphs. What is the hardest problem, puzzle,

94:02idea in computer science for you personally that you had to work through? Just something that was

94:09just a...

94:09The hardest thing that I've ever been involved with?

94:13Yeah.

94:13Okay. Well, yeah, that's, I don't know how to answer questions like that, but in this case,

94:19it's pretty clear. Because it's called the birth of the giant component. Okay, so now let me explain

94:32that because this is actually gets into physics too. And it gets into something called Bose-Einstein

94:38statistics, but anyway, it's got some interesting stories and it connected with Berkeley again.

94:46So start with the idea of a random graph. Now this is, here we just say we have N points that

94:58are totally unconnected and there's no geometry involved. There's no saying some points are

95:05further apart than others. All points are exactly alike. And let's say we have a hundred points

95:13and we number them from zero to nine, nine. All right. Now let's take pi, the digits of pi, so

95:25two at a time. So we had 31, 41, 59, 26. We can go through pi. And so we take the first two, 31,

95:3641, and let's put a connection between 0.31 and 0.41. That's an edge in the graph.

95:48Then we take 59, 26 and make another edge. And the graph gets bigger, gets more and more connected

95:58as we add these things one at a time. Okay. We started out with N points and we add M edges.

96:07Okay. Each edge is completely, we forgot about edges we had before. We make an edge twice.

96:15We make an edge from a point to itself even. Maybe pi is going to have a run of four digits in there.

96:23But anyway, we're evolving a graph at random. And a magical thing happens

96:34when the number of edges is like 0.49. And so maybe N is a million and I have 490,000 edges.

96:48Then it almost all the time, it consists of isolated trees, not even any loops.

97:01It's a very small number of edges so far. A little less than half N.

97:06But if I had 0.51 edges, it's a little more than half N. So a million points, 510,000 edges.

97:16Now it probably has one component that's much bigger than the others.

97:29And we call that the giant component. >> Can you clarify, first of all,

97:35is there a name for this kind of super cool pi random graph?

97:39>> Well, I call it the pi graph. No, no, the pi graph is actually, my pi graph is based on

97:51binary representation of pi, not the decimal representation of pi. But anyway,

97:57let's suppose I was rolling dice instead. >> So it doesn't have to be pi?

98:04>> It could be any source. The point is every step, choose totally at random one of those endpoints.

98:12Choose totally at random another one of the endpoints. Make that an edge. That's the process.

98:20>> Yeah. So there's nothing magical about pi that you were just giving us as an example?

98:24>> No, no. I was using pi to, I was sort of saying pi is sort of random that nobody knows

98:29a pattern in. >> Exactly. Got it. Got it.

98:31>> But it's not, yeah, I could have just as well drawn straws or something. This was a concept

98:39invented by Erdos and Rényi, and they called it the evolution of random graphs. And if you start

98:44out with a large number n and you repeat this process, all of a sudden a big bang happens

98:51at one half n. There'll be two points together, then maybe we'll have three,

98:56and then they maybe branch out a little bit. But they'll all be separate until we get to

99:04one half n. And we pass one half n, and all of a sudden there's substance to it. There's a big

99:14clump of stuff that's all joined together. >> So it's almost like a phase transition

99:18of some kind. >> It's exactly, it's a phase transition,

99:21but it's a double phase transition. It turns out it happens, there's actually two things going on

99:29at once at this phase transition, which is very remarkable about it. Okay. So a lot of the most

99:38important algorithms are based on random processes. And so I want to understand random processes

99:44and how, so there are data structures that sort of grow this way. Okay. So Dick Karp, one of the

99:50leading experts on randomized algorithms, had his students looking at this at Berkeley. And we heard

100:00a rumor that the students had found something interesting happening. The students are

100:07generating this, or simulating this random evolution of graphs, and they're taking snapshots

100:14every so often to take a look at what the graph is. And the rumor was that every time they looked,

100:22there was only one component that had loops in it, almost always. They do a million experiments,

100:28and only three or four times did they ever happen to see a loop at this point.

100:36I mean, no, more than one component with a loop. So they watch until the graph gets

100:43completely full. So it starts out totally empty and gets more and more edges all the time.

100:50And so, okay, certainly a loop comes along once, but now all the loops stay somehow joined to that

100:59one. There never were two guys with loops. Wow, interesting.

101:06In these experiments. Okay. So anyway, almost always, certainly not always. But with very high

101:16probability, this seemed to be true. So we heard about this rumor at Stanford, and we said, "Hmm,

101:23if that's true, then a lot more must also be true. So there's a whole theory out there waiting to be

101:29discovered that we haven't ever thought about. So let's take a look at it." And so we looked

101:34closer and we found out, no, actually, it's not true. But in fact, it's almost true. Namely,

101:43there's a very short interval of time when it's true. And if you don't happen to look at it

101:50during that short interval of time, then you miss it. So in other words, there'll be a period where

101:58there are two or three components that have loops, but they join together pretty soon.

102:05Okay. So-

102:07If you don't have a real fast shutter speed, you're going to miss that instant.

102:15So separate loops don't exist for long.

102:18That's it. Yeah. I started looking at this to make it quantitative. And the basic problem was

102:25to slow down the Big Bang so that I could watch it happening. I think I can explain it actually

102:31in fairly elementary terms, even without writing a formula-

102:37Let's try.

102:37Like Hawking would do. And so let's watch the evolution. And at first,

102:46these edges are coming along and they're just making things without loops, which we call trees.

102:52So then all of a sudden, a loop first appears. So at that point, I have one component that has a loop.

102:58Now I say that the complexity of a component is the number of edges minus the number of vertices.

103:07So if I have a loop, I have like a loop of length five, has five edges and five vertices.

103:16Mm-hmm.

103:16Or I could put a tail on that, and that would be another edge, another vertex.

103:22It's like a zero, one, two complexity kind of thing.

103:25So if the complexity is zero, we have one loop I call it, a cycle, or I call it a cyclic component.

103:33So a cyclic component looks like a wheel to which you attach fibers or trees.

103:44They go branching, but there are no more loops. There's only one loop and everything else

103:49feeds into that loop. And that has complexity zero. But a tree itself has complexity minus one,

103:57because it has, like it might have 10 vertices and nine edges to tie them together.

104:05So nine minus 10 is minus one. So complexity minus one is a tree. It's got to be connected.

104:13That's what I mean by a component. It's got to be connected.

104:15If I have 10 things connected, I have to have nine edges.

104:19Can you clarify why when complexity goes, can go above zero? I'm a little confused why.

104:28Right. So the complexity plus one is the number of loops. So if complexity is zero, I have one loop.

104:35If complexity is one, that means I have one more edge than I have vertices.

104:43So I might have like 11 edges and 10 vertices. So it turns, we call it a bicycle because

104:51it's got two loops and it's got to have two loops in it.

104:54Why can't it be trees just going off of the loop?

105:00I would need more edges than that.

105:03Oh, right. Right. Okay. I got it.

105:06So every time I get another loop, I get another excess of edges over vertices.

105:11I got you.

105:12Okay. So in other words, we start out and after I have one loop, I have one component that has

105:20a cycle in it. Now the next step, according to the rumor, would be that at the next step,

105:29I would have a bicycle in the evolution of almost all graphs. It would go from cycle to bicycle.

105:38But in fact, there's a certain probability it goes from cycle to two different cycles.

105:46And I worked out the probability was something like five out of 24.

105:51That's pretty high.

105:53It was substantial.

105:55But still, soon they're going to merge together almost. Okay.

106:01That's so cool.

106:03But then it splits again after you have either two or one, one. The next step is you either have

106:11three or you have two, one or you have one, one, one. Okay. And so I worked out the probability

106:17for those transitions. And I worked it out up to the first five transitions.

106:25And I had these strange numbers, five 24s. And I stayed up all night and about 3 a.m.

106:33I had the numbers computed and I looked at them and here were the denominator was something like

106:40223023. So the probability was something over 23023.

106:51I don't know how you worked that out, but-

106:53I had a formula that I could calculate the probability.

106:56And I could find the limiting probability as n goes to infinity. And it turned out to be

107:02this number, but the denominator was two three. And I looked at the denominator and I said,

107:06wait a minute, this number factors because 1001 is equal to seven times 11 times 13.

107:14I had learned that in my first computer program. So 23023 is seven times 11 times 13 times 23.

107:28That's not a random number. There has to be a reason why those small primes appear

107:34in the denominator. But my thing, so all of a sudden that suggested

107:38another way of looking at the problem where small prime factors would occur.

107:45So what would that be?

107:48So that said, oh yeah, let me take the logarithm of this formula. And sure enough,

107:54it's going to simplify. And it happened. And I wouldn't have noticed it except for this

108:01factorization. So I go to bed and I say, oh, okay, this looks like I'm slowing down the big bang. I

108:08can figure out what's going on here. And the next day it turned out Bill Gates comes to Stanford to

108:15visit. They're trying to sell him on donating money for a new computer science building.

108:20Sure.

108:21And I said, so they gave me an appointment to talk to Bill. And I wrote down on the blackboard

108:28this evolutionary diagram, going from one to two, five 24ths and all this business.

108:34And I wrote it down. And anyway, at the end of the day, he was discussing people with the

108:41development office. And he said, boy, I was really impressed with what Professor Knuth said

108:50about this giant component. And so, I love this story because it shows that

108:57theoretical computer science is really worthwhile.

109:01Have you ever talked to Bill Gates about it since then?

109:05Yeah.

109:06That's a cool little moment in history.

109:09Anyway, he happened to visit on exactly the day after I had found this pattern. And that allowed

109:19me to crack the problem so that I could develop the theory some more and understand what's happening

109:27because I could now write down explicit formulas for stuff. And so, it would work not only the

109:37first few steps, but also the whole study, the whole process. And I worked further and further

109:43with two authors, co-authors. And we finally figured out that the probability that the rumor

109:51was true. In other words, look at the evolution of a random graph going from zero to complete

110:00and say, what's the probability that at every point in time, there was only one component with

110:06a cycle? We started with this rumor saying there's only one component with a cycle. And-

§06Transcript · 1:50:13–2:11:44

110:13So, the rumor was that it's 100%.

110:17Rumor was that it was 100%. It turned out the actual numbers is like 87%. I should remember

110:26the number, but I don't have it with me. But anyway, but the number, it turned out to be like

110:3412 over pi squared or eight over pi. Anyway, it was a nice, it related to pi. And we could never

110:44done that with... So, that's the hardest problem I ever solved in my life was to prove that this

110:50probability is- It was proven. The probability was proven.

110:55Yeah. I was able to prove this, and this shed light on a whole bunch of other things about

111:02random graphs. That was sort of the major thing we were after.

111:07That's super cool. What was the connection to physics that you mentioned?

111:11Well, Bose-Einstein statistics is a study of how molecules bond together

111:18without geometry, without distance.

111:26You created the tech typesetting system and released it as open source. Just on that little

111:34aspect, why did you release it as open source? What is your vision for open source?

111:40Okay. Well, the word open source didn't exist at that time, but I didn't want proprietary rights

111:48over it because I saw how proprietary rights were holding things back. In the late '50s,

111:58people at IBM developed a language called Fortran. They could have kept it proprietary. They could

112:05have said, "Only IBM can use this language. Everybody else has to." But they didn't. They

112:11said, "Anybody who can translate Fortran into the language of their machines is allowed to

112:20make Fortran compilers, too." On the other hand, in the typography industry, I had seen

112:28a lot of languages that were developed for composing pages. Each manufacturer had his own

112:37language for composing pages. That was holding everything back because people

112:43were tied to a particular manufacturer, and then a new equipment is invented a year later. But

112:50printing machines, they have to expect to amortize the cost over 20, 30 years.

112:55So you didn't want that for tech?

112:58I didn't need the income. I already had a good job. People were buying enough books that it would

113:18bring me plenty of supplemental income for everything my kids needed for education,

113:25whatever. So there was no reason for me to try to maximize income any further. Income is

113:32sort of a threshold function. If you don't have enough, you're starving. But if you get over the

113:39threshold, then you start thinking about philanthropy or else, or trying to take it

113:45with you. But anyway, my income was over the threshold. So I didn't need to keep it. And so,

113:56I specifically could see the advantage of making it open for everybody.

114:02Do you think most software should be open?

114:05So I think that people should charge for non-trivial software, but not for trivial software.

114:13Yeah, you give an example of, I think, Adobe Photoshop versus GIMP on Linux,

114:18as Photoshop has value.

114:21So it's definitely worth paying for all this stuff. I mean, well, they keep adding

114:31stuff that my wife and I don't care about, but somebody obviously does. But they have

114:41built in a fantastic undo feature, for example, in Photoshop, where you can go through a sequence

114:52of a thousand complicated steps on graphics, and it can take you back anywhere in that sequence.

114:58Yeah, that's a long history.

115:00With really beautiful algorithms. I mean, yeah, it's...

115:03Oh, that's interesting. I didn't think about what algorithm. It must be some kind of efficient

115:07representation.

115:08It's really, yeah, no. I mean, there's a lot of really subtle Nobel Prize class creation

115:15of intellectual property in there. And with patents, you get a limited time to... I mean,

115:29eventually, the idea of patents is that you publish so that it's not a trade secret.

115:37That said, you've said that I currently use Ubuntu Linux on a standalone laptop.

115:44It has no internet connection. I occasionally carry flash memory drives between the machine

115:50and the Macs that I use for network surfing and graphics. But I trust my family jewels

115:56only to Linux. Why do you love Linux?

116:00The version of Linux that I use is stable. Actually, I'm going to have to upgrade one

116:07of these days, but...

116:07To a newer version of Ubuntu?

116:10Yeah, I'll stick with Ubuntu. But right now, I'm running something that doesn't support

116:17a lot of the new software. The last stable... I don't remember the number, like 14. Anyway,

116:27it's quite... And I'm going to get a new computer. I'm getting new solid state memory instead of a

116:36hard disk.

116:36Yeah, the basics. Well, let me ask you, sticking on the topic of tech,

116:42when thinking about beautiful typography, what is your favorite letter, number, or symbol?

116:55I know, I know, ridiculous question, but is there a...

116:57Let me show you here.

116:59Look at the last page.

117:06The very end of the index.

117:12What is that?

117:15There's a book by Dr. Seuss called On Beyond Zebra, and he gave a name to that.

117:21Did you say Dr. Seuss gave a name to that?

117:24Dr. Seuss, this is S-E-U-S-S. He wrote children's books in the '50s, '40s and '50s.

117:33Wait, are you talking about Cat in the Hat?

117:36Cat in the Hat, yeah. That's it, yeah.

117:39I like how you hit the spelling.

117:41On Beyond Zebra. Did it get to the Soviet Union?

117:46Yeah, Dr. Seuss did not come to the Soviet Union, but...

117:54Since you... Oh, actually, I think he did, actually, a little bit when we were...

117:58That was a book, maybe Cat in the Hat or Green Eggs and Ham, I think was used to learn English.

118:10Okay.

118:11So I think it made it in that way.

118:12Okay. I didn't like those as much as Bartholomew Cubbins, but I used to know

118:21Bartholomew Cubbins by heart when I was young.

118:24So what the heck is this symbol we're looking at? There's so much going on.

118:28He has a name for it at the end of his book on Beyond Zebra.

118:31Who made it?

118:33He did.

118:34He did. So there's... It looks like a bunch of vines. Is that symbol existent?

118:43By the way, he made a movie in the early '50s. I don't remember the name of the movie now.

118:50You can probably find it easily enough. But it features dozens and dozens of pianos all playing

118:57together at the same time. But all the scenery is sort of based on the kind of artwork that

119:05was in his books and the fantasy based of Soosland or something. And I saw the movie

119:15only once or twice, but it's quite... I'd like to see it again.

119:20That's really fascinating that you gave them... They gave them shout out here.

119:26Okay. Is there some elegant basic symbol that you're attracted to?

119:32Something that gives you pleasure? Something used a lot? Pi?

119:39Pi, of course. I try to use pi as often as I can when I need a random example,

119:47because it doesn't have any known characters. So for instance, I don't have it here to show you,

119:59but do you know the game called Masyu? M-A-S-Y-U? No. It's a great recreation. I mean,

120:11Sudoku is easier to understand, but Masyu is more addictive. You have black and white stones like

120:21on a go board, and you have to draw a path that goes straight through a white stone and

120:28makes a right angle turn at the black stone. And it turns out to be really, really nice puzzle

120:36because it doesn't involve numbers, but it's visual, but it's really pleasant to play with.

120:43So I wanted to use it as example in art of computer programming. And I have

120:52exercise on how to design cool Masyu puzzles. You can find that on Wikipedia, certainly,

120:59as an example, M-A-S-Y-U. And so I decided I would take pi, the actual image of it, and I had pixels,

121:12and I would put a stone wherever it belongs in the letter pi, in the Greek letter pi.

121:20But the problem was find a way to make some of the stones white, some of the stones black,

121:26so that there's a unique solution to the Masyu puzzle. That was a good test case for my algorithm

121:33on how to design Masyu puzzles because I insisted in advance that the stones had to be placed in

121:40exactly the positions that make the letter pi, make a Greek letter pi. All right. That's cool.

121:48And it turned out there was a unique way to do that. And so pi is a source of examples where I

121:59can prove that I'm starting with something that isn't canned. And most recently, I was writing

122:07about something called graceful graphs. Graceful graphs is the following. You have a graph that has

122:16M edges to it. And you attach numbers to every vertex in the following way. So every time you

122:27have an edge between vertices, you take the difference between those numbers. And that

122:34difference has got to be, I'll tell you what edge it is. So one edge, two numbers will be one apart.

122:41There'll be another edge where the numbers are two apart. And so it's a great computer problem.

122:47Can you find a graceful way to label a graph? So I started with a graph that I use for

122:55an organic graph, not a mathematically symmetric graph or anything. And I take

123:04the 49 states of the United States. The edges go from one state to the next state. So for example,

123:12California, be next to Oregon, Nevada, Arizona. And I include District of Columbia. So I have 49.

123:24I can't get Alaska and Hawaii in there because they don't touch. You have to be able to drive

123:30from one to the other. So is there a graceful labeling of the United States? Each state gets

123:37a number. And then if California is number 30 and Oregon is number 11, that edge is going to be

123:44number 19. The difference between those. So is there a way to do this for all the states? And

123:52so I was thinking of having a contest for people to get it as graceful as they could.

124:00But my friend Tom Rukiki actually solved the problem by proving that. I mean, I was able to

124:08get it down within seven or something like that. He was able to get a perfect solution.

124:13The actual solution or to prove that a solution exists?

124:17More precisely, I had figured out a way to put labels on so that all the edges were labeled

124:25somewhere between one and 117. But there were some gaps in there because I should really have

124:32gone from one to 105 or whatever the number is. So I gave myself too much, a lot of slack. He did

124:40it without any slack whatsoever, perfect graceful labeling. And so I call out the contest because

124:49problems already solved and too easy in a sense because Tom was able to do it in an afternoon.

124:55He, sorry, he gave the algorithm or for this particular?

124:58For the United States.

125:00For the United States.

125:01This problem is incredibly hard. I mean-

125:04For the general.

125:05General.

125:05Okay. But it's like coloring.

125:08But it was very lucky that it worked for the United States.

125:10I think. But the theory is still very incomplete. But anyway, then Tom came back a couple of days

125:18later and he had been able to not only find a graceful labeling, but the label of Washington

125:26was 31. The label of Idaho was 41 following the digits of pi. Going across the topic,

125:38the United States, he has the digits of pi perfectly.

125:41Did he do it on purpose?

125:42He was able to still get a graceful labeling with that extra thing.

125:48What?

125:49Wow.

125:49Wow.

125:51It's a miracle. Okay. But I like to use pi in my book, you see, and this is the-

126:00All roads lead to pi.

126:04Yeah.

126:05Somehow often hidden in the middle of like the most difficult problems.

126:11Can I ask you about productivity?

126:15Productivity.

126:17Yeah. You said that, "My scheduling principle is to do the thing I hate most on my to-do list.

126:26By week's end, I'm very happy." Can you explain this process to a productive life?

126:32Oh, I see. But all the time I'm working on what I don't want to do, but still, I'm glad to have

126:41all those unpleasant tasks finished.

126:42Yes. Is that something you would advise to others?

126:46Yeah. I don't know how to say it. During the pandemic, I feel my productivity actually

126:54went down by half because I have to communicate by writing, which is slow. I don't like to send

127:07out a bad sentence, so I go through and reread what I've written and edit and fix it. So everything

127:14takes a lot longer when I'm communicating by text messages instead of just together with somebody

127:25in a room. It's also slower because the libraries are closed and stuff.

127:30But there's another thing about scheduling that I learned from my mother that I should

127:35probably tell you, and that is different from what people in robotics field do, which is called

127:42planning. So she had this principle that was, "See something that needs to be done and do it."

127:51Instead of saying, "I'm going to do this first, and I'm going to do this first," just, you know...

127:59Just do it.

128:03Oh, yeah. Pick this up, you know.

128:04But you're... At any one moment, there's a set of tasks that you can do, and you're saying a

128:10good heuristic is to do the one you want to do least.

128:15Right. The one I haven't got any good reason to... I'll never be able to do it any better than I am

128:24now. There are some things that I know, if I do something else first, I'll be able to do that one

128:32better. But there's some that are going to be harder because, you know, I've forgotten some of

128:39the groundwork that went into it or something like that. So I just finished a pretty tough part of

128:46the book, and so now I'm, you know, doing the parts that are more fun. But the other thing is,

128:56as I'm writing the book, of course, I want the reader to think that I'm happy all the time I'm

129:02writing the book. You know, it's upbeat. I can have humor. I can say, "This is cool." You know,

129:09"Wow." And this. I have to disguise the fact that it was painful in any way to come up with this.

129:18The road to that excitement is painful. Yeah, it's laden with pain. Okay. Is there...

129:23You've given some advice to people before, but can you...

129:30You give me too much credit, but anyway, this is my turn to say things that I believe. But

129:38I want to preface it by saying I also believe that other people do a lot of these things

129:48much better than I do, so I can only tell you my side of it.

129:53So can I ask you to give advice to young people today, to high school students,

130:01to college students, whether they're geeks or the other kind, about how to live a life

130:08they can be proud of, how to have a successful career, how to have a successful life?

130:16It's always the same as I've said before, I guess, not to do something because it's trendy,

130:25but it's something that you personally feel that you were called to do,

130:30rather than somebody else expects you to do. How do you know you're called to do something?

130:37You try it and it works or it doesn't work. I mean, you learn about yourself.

130:44Life is a binary search. You try something and you find out, oh yeah, I have a background that

130:49helped me with this, or maybe I could do this if I worked a little bit harder. But you try

130:57something else and you say, well, I have really no intuition for this and it looks like it doesn't

131:05have my name on it. Was there advice along the way that you got about what you should and shouldn't

131:13work on, or do you just try to listen to yourself? Yeah, I probably overreacted another way. When

131:19something, when I see everybody else going some way, I probably say, hmm, too much competition.

131:28But mostly I played with things that were interesting to me. And then later on I found,

131:40actually the most important thing I learned was how to be interested in almost anything.

131:44I mean, not to be bored. It hurts. It makes me very sad when I see kids talking to each other

§07Transcript · 2:11:52–2:21:21

131:52and they say, that was boring. And to me, a person should feel upset if he had to admit that he

132:07wasn't able to find something interesting. It's a skill. They're saying, I haven't learned how to

132:15enjoy life. I have to have somebody entertain me instead of...

132:20That's really interesting. It is a skill. David Foster Wallace, I really like the thing he says

132:28about this, which is the key to life is to be unboreable. And I do really like you saying that

132:35it's a skill, because I think that's really good advice, which is if you find something boring,

132:41that's not, I don't believe it's because it's boring. It's because you haven't developed the

132:50skill, how to find the beauty in it, how to find the fun in it. That's a really good point.

132:57Sometimes it's more difficult than others to do this. I mean, during the COVID,

133:05lots of days when I never saw another human being, but I still find other ways to...

133:14It still was a pretty fun time.

133:17Yeah. I came a few minutes early today and I walked around Foster City. I didn't know

133:28what was going on in Foster City. I saw some beautiful flowers at the nursery at Home Depot

133:33a few blocks away.

133:34Life is amazing. It's full of amazing things like this. Yeah. Sometimes I'll sit there and

133:43just stare at a tree. Nature is beautiful. Let me ask you the big ridiculous question. I don't think

133:49I asked you last time. So I have to ask this time in case you have a good answer. What is the meaning

133:55of life? Our existence here on earth, the whole thing. No, no, you can't. I will not allow you to

134:09try to escape answering this question. You have to answer definitively because there's surely,

134:16surely, Don Knuth, there must be an answer.

134:19What is the answer? Is it 42?

134:22Yes. Well, I don't think it's in numerical. That's the SDS.

134:26That was in Zen. Okay. But all right. So anyway, it's only for me, but I personally

134:37think of my belief that God exists, although I have no idea what that means. But I believe that there

134:49is something beyond human capabilities. It might be some AI, but whatever it is, but whatever. But

135:07I do believe that there is something that goes beyond the realm of human understanding,

135:17but that I can try to learn more about how to resonate with whatever that being would like me to

135:30do. So you think you can have occasional glimpses of that being? I strive for that. Not that I

135:40ever think I'm going to get close to it, but it's not for me. It's saying, what should I do

135:48that that being wants me to do? I'm trying to ask,

135:55I mean, does that being want me to be talking to Lex Friedman right now? And I said, yes. Okay.

136:06Thank you.

136:09Well, thank you. But what I'm trying to say is, I'm not trying to say, of all the

136:17strategies I could choose or something, which one? I try to do it not strategically, but I try to

136:26imagine that I'm following somebody's wishes.

136:32Even though you're not smart enough to...

136:36To know what they are.

136:37Yeah. That funny little dance.

136:39Well, I mean, this AI or whatever, it probably is smart enough to help to give me clues.

136:47And to make the whole journey from clue to clue a fun one.

136:56Yeah. I mean, as so many people have said, it's the journey, not the destination.

137:01And people live through crises, help each other. Things come up, history repeats itself.

137:10You try to say in the world today, is there any government that's working? I read history. I know

137:20that things were...

137:21They were a lot worse in many ways.

137:28There's a lot of bad things all the time. And I read about, I look at things and people had

137:36good ideas and they were working on great projects. And then I know that it didn't succeed,

137:41though, in the end. But the new insight I've gotten, actually, in that way was, I was reading...

137:48What book was I reading recently? It was by Ken Follett, and it was called The Man from St.

137:56Petersburg. But it was talking about the prequel to World War I. And Winston Churchill,

138:04according to this book, sees that Germany has been spending all its gold reserves

138:10building up a huge military. And there's no question that if Germany would attack England,

138:18that England would be wiped out. So he wants Russia to help to attack Germany from the other

138:26side, because Germany doesn't have enough of an army to be fighting two wars at one.

138:32Okay, now, then there's an anarchist in Russia, who sees that wars are

138:44something that leaders start, but actually people get killed. And so he wants to stop

138:52any alliance between England and Russia, because that would mean that thousands and thousands of

139:00people in Russia would be killed that wouldn't be otherwise killed. All right, and so his life's goal

139:10is to assassinate a Russian prince who's visiting England, because that will make,

139:17will mean the Tsar will not form the alliance. All right. So we have this

139:21question about what should the government do? Should it actually do something that will lead to,

139:30you know, is the war inevitable? Or is there a way to have peace? And it struck me that if I were

139:39in a position of responsibility for people's lives, in most cases, I wouldn't have any confidence that

139:47any of my decisions were good. That these questions are too hard, probably for any human

139:55being, but certainly for me. Well, I think coupling the not being sure that the decisions are right,

140:05so that that's actually a really good thing, coupled with the fact that you do have to make

140:11a decision and carry the burden of that. And ultimately, I have faith in human beings,

140:19in the great leaders to arise and help build a better world. I mean, that's the hope of democracy.

140:28Yeah, Ben, let's hope that we can enhance their abilities with algorithms.

140:35Well put, Don. It's such a huge honor. You've been an inspiration to me and to millions for

140:46such a long time. Thank you for spending your really valuable time with me. Once again,

140:52it's a huge honor. I really enjoyed this conversation.

140:55Thanks for listening to this conversation with Donald Knuth. To support this podcast,

141:00please check out our sponsors in the description. And now, let me leave you with some words from

141:05Don Knuth himself. Science is what we understand well enough to explain to a computer. Art is

141:12everything else we do. Thank you for listening. I hope to see you next time.

141:18Bye.

141:19Bye.

141:20Bye.

141:21Bye.

— 读到这里,多懂一点。 —