Computable Problems. Computability What does it mean to be computable?

71
Computable Problems

Transcript of Computable Problems. Computability What does it mean to be computable?

Page 1: Computable Problems. Computability What does it mean to be computable?

Computable Problems

Page 2: Computable Problems. Computability What does it mean to be computable?

Computability

• What does it mean to be computable?

Page 3: Computable Problems. Computability What does it mean to be computable?

Computability

• What does it mean to be computable?– Can decide an answer using• Finite number of steps• Finite list of instructions

Page 4: Computable Problems. Computability What does it mean to be computable?

Alan Turing

• Father of Computer Science

Page 5: Computable Problems. Computability What does it mean to be computable?

Proof By Contradiction

• Proof by contradiction:– Assume something is true– Show it leads to a contradiction– Conclude the opposite

Page 6: Computable Problems. Computability What does it mean to be computable?

Proof By Contradiction• Given:

– The 3 angles in a triangle are each > 0 degrees– The 3 angles in a triangle add to 180

• Prove: – No triangle can have more than one 90 degree angle

Page 7: Computable Problems. Computability What does it mean to be computable?

Proof By Contradiction• Given:

– The 3 angles in a triangle are each > 0 degrees– The 3 angles in a triangle add to 180

• Prove: – No triangle can have more than one 90 degree angle

• Assume the opposite:– Triangle ABC has right angles A and B

Page 8: Computable Problems. Computability What does it mean to be computable?

Proof By Contradiction• Given:

– The 3 angles in a triangle are each > 0 degrees– The 3 angles in a triangle add to 180

• Prove: – No triangle can have more than one 90 degree angle

• Assume the opposite:– Triangle ABC has right angles A and B

• Find a contradiction:1. The measures of A + B + C = 180 (given)2. 90 + 90 + C = 180 (step 1 and our assumption)3. Measure of C = 0 (step 2 and additive property of equality)4. Measure of C > 0 (given)

• If givens/logic is correct, assumption must be incorrect

Page 9: Computable Problems. Computability What does it mean to be computable?

Proof By Contradiction

• Prove there are an infinite number of primes

Page 10: Computable Problems. Computability What does it mean to be computable?

Proof By Contradiction

• Assume there are a finite number of prime numbers– 2, 3, 5, 7, 11…

Page 11: Computable Problems. Computability What does it mean to be computable?

Proof By Contradiction

• Assume there are a finite number of prime numbers– 2, 3, 5, 7, 11…– Call them p1, p2, p3, p4, p5, …pn

Page 12: Computable Problems. Computability What does it mean to be computable?

Proof By Contradiction

• Assume there are a finite number of prime numbers– 2, 3, 5, 7, 11…– Call them p1, p2, p3, p4, p5 …pn

– Calculate q = (p1 * p2 * p3 * … * pn) + 1

Page 13: Computable Problems. Computability What does it mean to be computable?

Proof By Contradiction

• Assume there are a finite number of prime numbers– 2, 3, 5, 7, 11…– Call them p1, p2, p3, p4, p5…pn

– Calculate q = (p1 * p2 * p3 * … * pn) + 1Dividing q by any prime gives remainder 1

Page 14: Computable Problems. Computability What does it mean to be computable?

Proof By Contradiction

• Assume there are a finite number of prime numbers– 2, 3, 5, 7, 11…– Call them p1, p2, p3, p4, p5 …pn

– Calculate q = (p1 * p2 * p3 * … * pn) + 1Dividing q by any prime gives remainder 1 …thus q must be prime

Page 15: Computable Problems. Computability What does it mean to be computable?

Proof By Contradiction

• Assume there are a finite number of prime numbers– 2, 3, 5, 7, 11…– Call them p1, p2, p3, p4, p5…pn

– Calculate q = (p1 * p2 * p3 * … * pn) + 1Dividing q by any prime gives remainder 1 …thus q must be primeq can't be prime – it is bigger than biggest prime pn

Page 16: Computable Problems. Computability What does it mean to be computable?

Proof By Contradiction

• Assume there are a finite number of prime numbers– 2, 3, 5, 7, 11…– Call them p1, p2, p3, p4, p5…pn

– Calculate q = (p1 * p2 * p3 * … * pn) + 1Dividing q by any prime gives remainder 1 …thus q must be primeq can't be prime – it is bigger than biggest prime pn

– Conclude there are NOT a finite number of prime numbers

Page 17: Computable Problems. Computability What does it mean to be computable?

Programs Running Programs

• We can force a program to run another program as its input:

Page 18: Computable Problems. Computability What does it mean to be computable?

Yes

• Always Yes Program

Anything

Yes

Page 19: Computable Problems. Computability What does it mean to be computable?

Yes

• Always Yes Program

Anything

Yes

Input Resulthello.txt (2kB) YESaddressList.doc (86kB) YESnotepad.exe YES

Page 20: Computable Problems. Computability What does it mean to be computable?

No

• Always No Program

Anything

No

Page 21: Computable Problems. Computability What does it mean to be computable?

No

• Always No Program

Anything

NoInput Result

hello.txt (2kB) NOaddressList.doc (86kB) NOnotepad.exe NO

Page 22: Computable Problems. Computability What does it mean to be computable?

Size Checker

• Size Checker Program

File

Rule:Is size > 10 Kb?

Yes/No

Page 23: Computable Problems. Computability What does it mean to be computable?

Size Checker

• Size Checker Program

File

Rule:Is size > 10 Kb?

Yes/No

Input Resulthello.txt (2kB) NOaddressList.doc (86kB) YESnotepad.exe YES

Page 24: Computable Problems. Computability What does it mean to be computable?

Name Size Checker

• Name Checker Program

File

Rule:Is filename > 0 characters?

Yes/No

Input Resulthello.txt (2kB) YESaddressList.doc (86kB) YESnotepad.exe YES

Page 25: Computable Problems. Computability What does it mean to be computable?

Always Yes?

Input ResultYesNoSize CheckerName Size CheckerAlways Yes

File

Rule:Does this program

always say yes?

Yes/No

Page 26: Computable Problems. Computability What does it mean to be computable?

Always Yes?

Input ResultYes YESNo NOSize Checker NOName Size Checker YESAlways Yes

File

Rule:Does this program

always say yes?

Yes/No

Page 27: Computable Problems. Computability What does it mean to be computable?

Always Yes?

Always Yes ( Always Yes( X ) ) NO

Input ResultYes YESNo NOSize Checker NOName Size Checker YESAlways Yes NO

File

Rule:Does this program

always say yes?

Yes/No

Page 28: Computable Problems. Computability What does it mean to be computable?

Yes On Self

Input ResultYesNoSize Checker (19kb)Name Size CheckerAlways YesYes On Self

Rule:Does this program

say Yes if run on itself?

File

Yes/No

Page 29: Computable Problems. Computability What does it mean to be computable?

Yes On Self

Input ResultYes YESNo NOSize Checker (19kb) YESName Size Checker YESAlways Yes NOYes On Self

Rule:Does this program

say Yes if run on itself?

File

Yes/No

Page 30: Computable Problems. Computability What does it mean to be computable?

Yes On Self

Assume:YesSelf( YesSelf( ) ) Yes

Yes

Page 31: Computable Problems. Computability What does it mean to be computable?

Yes On Self

Assume:YesSelf( YesSelf( ) ) Yes

Then YesSelf( YesSelf() ) Must Yes

That is OK…

Yes

Page 32: Computable Problems. Computability What does it mean to be computable?

Yes On Self

Assume:YesSelf( YesSelf( ) ) NO

No

Page 33: Computable Problems. Computability What does it mean to be computable?

Yes On Self

Assume:YesSelf( YesSelf( ) ) NO

Then YesSelf( YesSelf() ) Must NO

That is OK…No

Page 34: Computable Problems. Computability What does it mean to be computable?

Yes On Self

Input ResultYes YESNo NOSize Checker (19kb) YESName Size Checker YESAlways Yes NOYes On Self Yes or No

Rule:Does this program

say Yes if run on itself?

File

Yes/No

Yes / No both valid… but has to stick with one

Page 35: Computable Problems. Computability What does it mean to be computable?

Anti Yes On Self

Rule:Get answer from Yes On Self(File)…

Say the opposite

File

Yes/NoInput YesSelf AntiYes YES NONo NO YESSize Checker (19kb) YES NOName Size Checker YES NOAlways Yes NO YESAnti Yes On Self

Page 36: Computable Problems. Computability What does it mean to be computable?

Yes On SelfAssume:AntiYesSelf( AntiYesSelf( ) ) YES

Yes

Page 37: Computable Problems. Computability What does it mean to be computable?

Yes On SelfAssume:AntiYesSelf( AntiYesSelf( ) ) YES

Then YesOnSelf( AntiYesSelf() ) must NO

Yes

Page 38: Computable Problems. Computability What does it mean to be computable?

Yes On SelfAssume:AntiYesSelf( AntiYesSelf( ) ) YES

Then YesOnSelf( AntiYesSelf() ) must NO

But if AntiYesSelf( AntiYesSelf( ) ) YESYesOnSelf( AntiYesSelf() ) must YES

Yes

Page 39: Computable Problems. Computability What does it mean to be computable?

Yes On SelfAssume:AntiYesSelf( AntiYesSelf( ) ) YES

Then YesOnSelf( AntiYesSelf() ) must NO

But if AntiYesSelf( AntiYesSelf( ) ) YESYesOnSelf( AntiYesSelf() ) must YES

Yes

Page 40: Computable Problems. Computability What does it mean to be computable?

Yes On SelfAssume:AntiYesSelf( AntiYesSelf( ) ) NO

Then YesOnSelf( AntiYesSelf() ) must YES

But if AntiYesSelf( AntiYesSelf( ) ) NOYesOnSelf( AntiYesSelf() ) must NO

NO

Page 41: Computable Problems. Computability What does it mean to be computable?

Yes On SelfAssume:AntiYesSelf( AntiYesSelf( ) ) NO

NO

Page 42: Computable Problems. Computability What does it mean to be computable?

Yes On SelfAssume:AntiYesSelf( AntiYesSelf( ) ) NO

Then YesOnSelf( AntiYesSelf() ) must YES

NO

Page 43: Computable Problems. Computability What does it mean to be computable?

Yes On SelfAssume:AntiYesSelf( AntiYesSelf( ) ) NO

Then YesOnSelf( AntiYesSelf() ) must YES

But if AntiYesSelf( AntiYesSelf( ) ) NOYesOnSelf( AntiYesSelf() ) must NO

NO

Page 44: Computable Problems. Computability What does it mean to be computable?

Anti Yes On Self

Anti Yes On Self Can'tAnswer YES or NO!

Assume result is YES: Assume result is No:

Rule:Get answer from Yes On Self(File)…

Say the opposite

File

Yes/No

Page 45: Computable Problems. Computability What does it mean to be computable?

Chain:

• If I can write Always Yes

Page 46: Computable Problems. Computability What does it mean to be computable?

Chain:

• If I can write Always Yes

• Then I can write Yes On Self

Page 47: Computable Problems. Computability What does it mean to be computable?

Chain:

• If I can write Always Yes

• Then I can write Yes On Self

• Then I can writeAnti Yes On Self

Page 48: Computable Problems. Computability What does it mean to be computable?

Chain:

• If I can write Always Yes

• Then I can write Yes On Self

• Then I can writeAnti Yes On Self

• But Anti Yes On SelfCan't Exist

Page 49: Computable Problems. Computability What does it mean to be computable?

Chain:

• If I can write Always Yes

• Then I can write Yes On Self

• Then I can writeAnti Yes On Self

• But Anti Yes On SelfCan't Exist

• I can NOT write AlwaysYes

Page 50: Computable Problems. Computability What does it mean to be computable?

Crash Detection

• What about detecting possible bugs?

Page 51: Computable Problems. Computability What does it mean to be computable?

Crash Detection

• What about detecting possible bugs?

Page 52: Computable Problems. Computability What does it mean to be computable?

Crash Detection

• What about detecting possible bugs?

Page 53: Computable Problems. Computability What does it mean to be computable?

Crash Detection

• What about detecting possible bugs?

Page 54: Computable Problems. Computability What does it mean to be computable?

Crash Detection

• What about detecting possible bugs?

Page 55: Computable Problems. Computability What does it mean to be computable?

Crash Detection

• AntiCrashOnSelf runs on itself:

Assume:AntiCrashSelf( AntiCrashSelf( ) ) YES

Page 56: Computable Problems. Computability What does it mean to be computable?

Crash Detection

• AntiCrashOnSelf runs on itself:

Assume:AntiCrashSelf( AntiCrashSelf( ) ) YES

Then AntiCrashSelf( AntiCrashSelf( ) ) Must Crash!

Page 57: Computable Problems. Computability What does it mean to be computable?

Crash Detection

• AntiCrashOnSelf runs on itself:

Assume:AntiCrashSelf( AntiCrashSelf( ) ) YES

Then AntiCrashSelf( AntiCrashSelf( ) ) Must Crash!

Page 58: Computable Problems. Computability What does it mean to be computable?

Crash Detection

• AntiCrashOnSelf runs on itself:

Assume:AntiCrashSelf( AntiCrashSelf( ) ) Crashes

Page 59: Computable Problems. Computability What does it mean to be computable?

Crash Detection

• AntiCrashOnSelf runs on itself:

Assume:AntiCrashSelf( AntiCrashSelf( ) ) Crashes

Then AntiCrashSelf( AntiCrashSelf( ) ) Must Output Yes

Page 60: Computable Problems. Computability What does it mean to be computable?

Crash Detection

• AntiCrashOnSelf runs on itself:

Assume:AntiCrashSelf( AntiCrashSelf( ) ) Crashes

Then AntiCrashSelf( AntiCrashSelf( ) ) Must Output Yes

Page 61: Computable Problems. Computability What does it mean to be computable?

Crash Detection

• What about detecting possible bugs?

• AntiCrashOnSelf runs on itself

YES: If it outputs Yes thenit must have crashed

No: If it outputs No thenit must not have crashed

Page 62: Computable Problems. Computability What does it mean to be computable?

Crash Detection

• What about detecting possible bugs?

Page 63: Computable Problems. Computability What does it mean to be computable?

Crash Detection

• What about detecting possible bugs?

Page 64: Computable Problems. Computability What does it mean to be computable?

Crash Detection

• What about detecting possible bugs?– Impossible to do perfectly– Must settle for pretty good most of the time

Page 65: Computable Problems. Computability What does it mean to be computable?

Alan Turing

• Father of Computer Science

Page 66: Computable Problems. Computability What does it mean to be computable?

The Turing Machine

• Hypothetical device– Reads and write symbols on a tape– Decides what to do based on list of rules

Page 67: Computable Problems. Computability What does it mean to be computable?

Universal Turing Machine

• Universal Turing Machine– Turing machine that can simulate other Turing

machines

Page 68: Computable Problems. Computability What does it mean to be computable?

Real Turing Machines

http://www.youtube.com/watch?feature=player_embedded&v=E3keLeMwfHY

Page 69: Computable Problems. Computability What does it mean to be computable?

Computers

• Turing machine can computer anything a state of the art PC can

Page 70: Computable Problems. Computability What does it mean to be computable?

Computers

• Turing machine can computer anything a state of the art PC can

• Anything a quantum computer can

Page 71: Computable Problems. Computability What does it mean to be computable?

Computers

• Turing machine can computer anything a state of the art PC can

• Anything a quantum computer can• Anything computable by any system consisting

of– Finite number of steps– Finite list of instructions