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

Post on 30-Dec-2015

219 views 2 download

Tags:

transcript

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

Alan Turing

• Father of Computer Science

Proof By Contradiction

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

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

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

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

Proof By Contradiction

• Prove there are an infinite number of primes

Proof By Contradiction

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

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

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

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

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

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

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

Programs Running Programs

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

Yes

• Always Yes Program

Anything

Yes

Yes

• Always Yes Program

Anything

Yes

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

No

• Always No Program

Anything

No

No

• Always No Program

Anything

NoInput Result

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

Size Checker

• Size Checker Program

File

Rule:Is size > 10 Kb?

Yes/No

Size Checker

• Size Checker Program

File

Rule:Is size > 10 Kb?

Yes/No

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

Name Size Checker

• Name Checker Program

File

Rule:Is filename > 0 characters?

Yes/No

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

Always Yes?

Input ResultYesNoSize CheckerName Size CheckerAlways Yes

File

Rule:Does this program

always say yes?

Yes/No

Always Yes?

Input ResultYes YESNo NOSize Checker NOName Size Checker YESAlways Yes

File

Rule:Does this program

always say yes?

Yes/No

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

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

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

Yes On Self

Assume:YesSelf( YesSelf( ) ) Yes

Yes

Yes On Self

Assume:YesSelf( YesSelf( ) ) Yes

Then YesSelf( YesSelf() ) Must Yes

That is OK…

Yes

Yes On Self

Assume:YesSelf( YesSelf( ) ) NO

No

Yes On Self

Assume:YesSelf( YesSelf( ) ) NO

Then YesSelf( YesSelf() ) Must NO

That is OK…No

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

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

Yes On SelfAssume:AntiYesSelf( AntiYesSelf( ) ) YES

Yes

Yes On SelfAssume:AntiYesSelf( AntiYesSelf( ) ) YES

Then YesOnSelf( AntiYesSelf() ) must NO

Yes

Yes On SelfAssume:AntiYesSelf( AntiYesSelf( ) ) YES

Then YesOnSelf( AntiYesSelf() ) must NO

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

Yes

Yes On SelfAssume:AntiYesSelf( AntiYesSelf( ) ) YES

Then YesOnSelf( AntiYesSelf() ) must NO

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

Yes

Yes On SelfAssume:AntiYesSelf( AntiYesSelf( ) ) NO

Then YesOnSelf( AntiYesSelf() ) must YES

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

NO

Yes On SelfAssume:AntiYesSelf( AntiYesSelf( ) ) NO

NO

Yes On SelfAssume:AntiYesSelf( AntiYesSelf( ) ) NO

Then YesOnSelf( AntiYesSelf() ) must YES

NO

Yes On SelfAssume:AntiYesSelf( AntiYesSelf( ) ) NO

Then YesOnSelf( AntiYesSelf() ) must YES

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

NO

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

Chain:

• If I can write Always Yes

Chain:

• If I can write Always Yes

• Then I can write Yes On Self

Chain:

• If I can write Always Yes

• Then I can write Yes On Self

• Then I can writeAnti Yes On Self

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

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

Crash Detection

• What about detecting possible bugs?

Crash Detection

• What about detecting possible bugs?

Crash Detection

• What about detecting possible bugs?

Crash Detection

• What about detecting possible bugs?

Crash Detection

• What about detecting possible bugs?

Crash Detection

• AntiCrashOnSelf runs on itself:

Assume:AntiCrashSelf( AntiCrashSelf( ) ) YES

Crash Detection

• AntiCrashOnSelf runs on itself:

Assume:AntiCrashSelf( AntiCrashSelf( ) ) YES

Then AntiCrashSelf( AntiCrashSelf( ) ) Must Crash!

Crash Detection

• AntiCrashOnSelf runs on itself:

Assume:AntiCrashSelf( AntiCrashSelf( ) ) YES

Then AntiCrashSelf( AntiCrashSelf( ) ) Must Crash!

Crash Detection

• AntiCrashOnSelf runs on itself:

Assume:AntiCrashSelf( AntiCrashSelf( ) ) Crashes

Crash Detection

• AntiCrashOnSelf runs on itself:

Assume:AntiCrashSelf( AntiCrashSelf( ) ) Crashes

Then AntiCrashSelf( AntiCrashSelf( ) ) Must Output Yes

Crash Detection

• AntiCrashOnSelf runs on itself:

Assume:AntiCrashSelf( AntiCrashSelf( ) ) Crashes

Then AntiCrashSelf( AntiCrashSelf( ) ) Must Output Yes

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

Crash Detection

• What about detecting possible bugs?

Crash Detection

• What about detecting possible bugs?

Crash Detection

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

Alan Turing

• Father of Computer Science

The Turing Machine

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

Universal Turing Machine

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

machines

Real Turing Machines

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

Computers

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

Computers

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

• Anything a quantum computer can

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