Adam Blank Lecture 17 Winter 2017 CSE 120 Computer Science Principles
CSE 120: Computer Science Principles Proofs & Computation e w h e q 0 q 1 q 2 q 3 h,e w,e w,h w,h q garbage w,h,e
CSE = Abstraction 1
CSE = Abstraction 2 At the very lowest level is hardware which Justin has talked about. At the very highest level is Theory which is what today is about!
To Infinity And Beyond! 3 In this lecture, we will explore the abstract! And we will apply it to computation! But we start simple... How many numbers are there?
To Infinity And Beyond! 3 In this lecture, we will explore the abstract! And we will apply it to computation! But we start simple... How many numbers are there?... Infinity, of course!
The Biggest Number Ever 4 What s the biggest number you can name?
The Biggest Number Ever 4 What s the biggest number you can name? 0, 1, 2,..., 4000000000000000,... If you give me a number, I can get a bigger one by adding 1: x x+1 If we collect all of these numbers together, we call the resulting set the natural numbers.
Listing Out Numbers 5 Imagine an incredibly large (infinite, actually) index of numbers: 0: 1: 2: 3: 4: 5: 6: 7:... We say a set of numbers is countable (or the same size as the natural numbers) whenever we can list them out.
Even Numbers 6 Obvious Theorem There are as many even numbers as odd numbers.
Even Numbers 6 Obvious Theorem There are as many even numbers as odd numbers. 0: 1: 2: 3: 4: 5: 6: 7: Are there more even numbers than natural numbers?
0: 1: 2: 3: 4: 5: 6: 7: 8:... Integers 7 Are there more integers than natural numbers?
0: 1: 2: 3: 4: 5: 6: 7: 8:... Fractions 8 Are there more fractions than natural numbers?
Strings 9 Program Are there more Strings than natural numbers? 1 List out Strings of length 1: 0 a 1 b 2 c 3... 2 List out Strings of length 2: 4 aa 5 ab 6 ac 7... 3 List out Strings of length 3: 4... 7 aaa 8 aab 9 aac 10...
Real Numbers 10 Are there more real numbers than natural numbers?
Describable Numbers 11 Incredibly, this is enough machinery to prove interesting results.
Describable Numbers 11 Incredibly, this is enough machinery to prove interesting results. Definition (Describable) A number is describable when it can unambiguously be described by some String. Example one
Describable Numbers 11 Incredibly, this is enough machinery to prove interesting results. Definition (Describable) A number is describable when it can unambiguously be described by some String. Example one two
Describable Numbers 11 Incredibly, this is enough machinery to prove interesting results. Definition (Describable) A number is describable when it can unambiguously be described by some String. Example one two π
Describable Numbers 11 Incredibly, this is enough machinery to prove interesting results. Definition (Describable) A number is describable when it can unambiguously be described by some String. Example one two π the smallest number with four million digits
Describable Numbers 11 Incredibly, this is enough machinery to prove interesting results. Definition (Describable) A number is describable when it can unambiguously be described by some String. Example one two π the smallest number with four million digits
Describable Numbers 12 Definition (Describable) A number is describable when it can unambiguously be described by some String. Definition (Interesting) A number is interesting when it s the smallest number with some interesting property.
Describable Numbers 12 Definition (Describable) A number is describable when it can unambiguously be described by some String. Definition (Interesting) A number is interesting when it s the smallest number with some interesting property. Example 0 is interesting because it s the smallest non-negative number
Describable Numbers 12 Definition (Describable) A number is describable when it can unambiguously be described by some String. Definition (Interesting) A number is interesting when it s the smallest number with some interesting property. Example 0 is interesting because it s the smallest non-negative number 1 is interesting because it s 1 x = x for all x
Describable Numbers 12 Definition (Describable) A number is describable when it can unambiguously be described by some String. Definition (Interesting) A number is interesting when it s the smallest number with some interesting property. Example 0 is interesting because it s the smallest non-negative number 1 is interesting because it s 1 x = x for all x 2 is interesting because it s the smallest prime number
Describable Numbers 13 Definition (Describable) A number is describable when it can unambiguously be described by some String. Definition (Interesting) A number is interesting when it s the smallest number with some interesting property. Questions
Describable Numbers 13 Definition (Describable) A number is describable when it can unambiguously be described by some String. Definition (Interesting) A number is interesting when it s the smallest number with some interesting property. Questions What is the smallest uninteresting number?
Describable Numbers 13 Definition (Describable) A number is describable when it can unambiguously be described by some String. Definition (Interesting) A number is interesting when it s the smallest number with some interesting property. Questions What is the smallest uninteresting number? Is every interesting number describable?
Describable Numbers 13 Definition (Describable) A number is describable when it can unambiguously be described by some String. Definition (Interesting) A number is interesting when it s the smallest number with some interesting property. Questions What is the smallest uninteresting number? Is every interesting number describable? Is every real number describable?
Computable Numbers 14 Definition (Computable) A number is computable when it can unambiguously printed out by some program. Example Question 0 is interesting because text("0", 0, 0) 1 is interesting because text("1", 0, 0) π is interesting because... Is every number computable?
Computability 15 We now know there is something that isn t computable. But can we find something specific?
Computability 15 We now know there is something that isn t computable. But can we find something specific? Halting Problem Given a program P as input, can we determine if it ever finishes running?
Computability 15 We now know there is something that isn t computable. But can we find something specific? Halting Problem Given a program P as input, can we determine if it ever finishes running? It turns out the answer is no!
Computability 15 We now know there is something that isn t computable. But can we find something specific? Halting Problem Given a program P as input, can we determine if it ever finishes running? It turns out the answer is no! The Idea Hypothetically, consider what would happen if someone really smart has written a program:
Computability 15 We now know there is something that isn t computable. But can we find something specific? Halting Problem Given a program P as input, can we determine if it ever finishes running? It turns out the answer is no! The Idea Hypothetically, consider what would happen if someone really smart has written a program: HALT(P) which returns true when P finishes and false if it doesn t.
Computability 15 We now know there is something that isn t computable. But can we find something specific? Halting Problem Given a program P as input, can we determine if it ever finishes running? It turns out the answer is no! The Idea Hypothetically, consider what would happen if someone really smart has written a program: HALT(P) which returns true when P finishes and false if it doesn t. Then, we will find a program CONFUSE which will confuse the HALT program...
Computability 15 We now know there is something that isn t computable. But can we find something specific? Halting Problem Given a program P as input, can we determine if it ever finishes running? It turns out the answer is no! The Idea Hypothetically, consider what would happen if someone really smart has written a program: HALT(P) which returns true when P finishes and false if it doesn t. Then, we will find a program CONFUSE which will confuse the HALT program... which means it doesn t work.
Computability 15 We now know there is something that isn t computable. But can we find something specific? Halting Problem Given a program P as input, can we determine if it ever finishes running? It turns out the answer is no! The Idea Hypothetically, consider what would happen if someone really smart has written a program: HALT(P) which returns true when P finishes and false if it doesn t. Then, we will find a program CONFUSE which will confuse the HALT program... which means it doesn t work. So, it can t be written!
Halting Problem 16 Suppose we have a program HALT such that: HALT(P) returns true when P finishes and false if it doesn t. Our Program 1 void CONFUSE() { 2 if (HALT(SOURCE_CODE(CONFUSE))) { 3 while (true) { 4 text("ha ha", 0, 0); 5 } 6 } 7 else { 8 return; 9 } 10 }
A Flow Chart 17 Input: 0 1 1 0 1 0 1 1 0 1 Work: read 0,1 input 0 0, Read Input input 1 1, input Erase and Store read 1, read 0, Match 0 read read 0,1 Match 1 read read read accept At Left, Match 0 read At Left, Match 1 read 1 read 0 read 0, fail read 1, read 0,1 Goto End read
This is a Turing Machine! 18 Some infinite tapes:
This is a Turing Machine! 18 Some infinite tapes: (how many doesn t matter; one tape for input and work, etc.) Input: 0 1 1 0 1 0 1 1 0 1 Work:
This is a Turing Machine! 18 Some infinite tapes: (how many doesn t matter; one tape for input and work, etc.) Input: 0 1 1 0 1 0 1 1 0 1 Work: A finite-state controller: read 0,1 input 0 0, Read Input input 1 1, input Erase and Store read 0 read 1,, Match 0 read read 0,1 Match 1 read At Left, Match 0 read accept read read At Left, Match 1 read 1 read 0 read 0, fail read 1, read 0,1 Goto End read
This is a Turing Machine! 18 Some infinite tapes: (how many doesn t matter; one tape for input and work, etc.) Input: 0 1 1 0 1 0 1 1 0 1 Work: A finite-state controller: read 0,1 input 0 0, Read Input input 1 1, input Erase and Store read 0 read 1,, Match 0 read read 0,1 Match 1 read At Left, Match 0 read accept read read At Left, Match 1 read 1 read 0 read 0, fail read 1, read 0,1 Goto End read That s it. These things can decide exactly the same languages as register machines, and lambda calculus.