CSE 311 Foundations of Computing I Lecture 28 Computability: Other Undecidable Problems Autumn 2011 CSE 3111.

Slides:



Advertisements
Similar presentations
David Evans cs302: Theory of Computation University of Virginia Computer Science Lecture 17: ProvingUndecidability.
Advertisements

CS211 Problems: unsolvable, unfeasible and unsolved Topic 2: Halting problem.
Lecture 19. Reduction: More Undecidable problems
CS 461 – Nov. 9 Chomsky hierarchy of language classes –Review –Let’s find a language outside the TM world! –Hints: languages and TM are countable, but.
Problem: Give as many proofs as you can for the Pythagorean Theorem. i.e., a 2 + b 2 = c 2 holds for any right triangle with sides a & b and hypotenuse.
Computability & Complexity. Scenario I can’t write this program because I’m too dumb.
1 COMP 382: Reasoning about algorithms Unit 9: Undecidability [Slides adapted from Amos Israeli’s]
1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026.
CSE115/ENGR160 Discrete Mathematics 02/28/12
Nathan Brunelle Department of Computer Science University of Virginia Theory of Computation CS3102 – Spring 2014 A tale.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
1 Introduction to Computability Theory Lecture15: Reductions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
Prof. Busch - LSU1 Decidable Languages. Prof. Busch - LSU2 Recall that: A language is Turing-Acceptable if there is a Turing machine that accepts Also.
CPSC 411, Fall 2008: Set 12 1 CPSC 411 Design and Analysis of Algorithms Set 12: Undecidability Prof. Jennifer Welch Fall 2008.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 20 Instructor: Paul Beame.
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 19 Instructor: Paul Beame.
1 Foundations of Software Design Fall 2002 Marti Hearst Lecture 29: Computability, Turing Machines, Can Computers Think?
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 18 Instructor: Paul Beame.
1 Introduction to Computability Theory Lecture11: The Halting Problem Prof. Amos Israeli.
1 Reducibility. 2 Problem is reduced to problem If we can solve problem then we can solve problem.
Halting Problem. Background - Halting Problem Common error: Program goes into an infinite loop. Wouldn’t it be nice to have a tool that would warn us.
Cs3102: Theory of Computation Class 18: Proving Undecidability Spring 2010 University of Virginia David Evans.
CSE 311 Foundations of Computing I Lecture 30 Computability: Other Undecidable Problems Autumn 2012 CSE 3111.
MA/CSSE 474 Theory of Computation More Reduction Examples Non-SD Reductions.
Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems.
Great Theoretical Ideas in Computer Science for Some.
Great Theoretical Ideas in Computer Science about AWESOME Some Generating Functions Probability Infinity Computability With Alan! (not Turing) Mind-
Halting Problem Introduction to Computing Science and Programming I.
CSE 311 Foundations of Computing I Lecture 26 Computability: Turing machines, Undecidability of the Halting Problem Spring
CSE 311 Foundations of Computing I Lecture 29 Computability: Turing machines, Undecidability of the Halting Problem Autumn 2012 CSE 3111.
Great Theoretical Ideas in Computer Science.
Halting Problem and TSP Wednesday, Week 8. Background - Halting Problem Common error: Program goes into an infinite loop. Wouldn’t it be nice to have.
CS 3813: Introduction to Formal Languages and Automata Chapter 12 Limits of Algorithmic Computation These class notes are based on material from our textbook,
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
 2005 SDU Lecture13 Reducibility — A methodology for proving un- decidability.
Complexity & Computability. Limitations of computer science  Major reasons useful calculations cannot be done:  execution time of program is too long.
SNU OOPSLA Lab. 1 Great Ideas of CS with Java Part 1 WWW & Computer programming in the language Java Ch 1: The World Wide Web Ch 2: Watch out: Here comes.
Fundamentals of Informatics Lecture 13 Reduction Bas Luttik.
Fundamentals of Informatics Lecture 12 The Halting Problem Bas Luttik.
CSE 311: Foundations of Computing Fall 2014 Lecture 27: Cardinality.
Recursively Enumerable and Recursive Languages
Overview of the theory of computation Episode 3 0 Turing machines The traditional concepts of computability, decidability and recursive enumerability.
1 Chapter 9 Undecidability  Turing Machines Coded as Binary Strings  Universal Turing machine  Diagonalizing over Turing Machines  Problems as Languages.
Undecidability and The Halting Problem
CompSci Today’s Topics Computer Science Noncomputability Upcoming Special Topic: Enabled by Computer -- Decoding the Human Genome Reading Great.
Fall 2014 Lecture 29: Turing machines and more decidability CSE 311: Foundations of Computing.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Undecidable.
Recursively Enumerable and Recursive Languages. Definition: A language is recursively enumerable if some Turing machine accepts it.
Fall 2013 Lecture 27: Turing machines and decidability CSE 311: Foundations of Computing.
CSE 311: Foundations of Computing Fall 2014 Lecture 28: Undecidability.
Introduction to Computing Science and Programming I
CSE 311 Foundations of Computing I
CS154, Lecture 11: Self Reference, Foundation of Mathematics
CS154, Lecture 10: Rice’s Theorem, Oracle Machines
Busch Complexity Lectures: Undecidable Problems (unsolvable problems)
CSE 105 theory of computation
CS154, Lecture 10: Rice’s Theorem, Oracle Machines
CSE 311 Foundations of Computing I
Decidable Languages Costas Busch - LSU.
Halting Problem.
CSE 311: Foundations of Computing
Instructor: Aaron Roth
CSE 311: Foundations of Computing
Instructor: Aaron Roth
CSE 105 theory of computation
Algorithms CSCI 235, Spring 2019 Lecture 37 The Halting Problem
Lecture 23: Computability CS200: Computer Science
Intro to Theory of Computation
Presentation transcript:

CSE 311 Foundations of Computing I Lecture 28 Computability: Other Undecidable Problems Autumn 2011 CSE 3111

Announcements Reading – 7th edition: p. 201 – 6th edition: p 177 – 5th edition: p. ? Answer Catalyst Survey about which time you will take the final exam (by Sunday). – Review session Saturday/Sunday – List of Final Exam Topics and sampling of some typical kinds of exam questions on the web Autumn 2011CSE 3112

Last lecture highlights Turing machine definition – Intuitive justification, Church-Turing Thesis Programs ≡ Turing machines – Distinction between the executing program P and its code Program Interpreter U (Universal TM) – Takes as input: (,x) where is the code of a program and x is an input string – Simulates P on input x Autumn 2011CSE 3113

Last lecture highlights Halting Problem – Input: the code of a program P and an input x for P, i.e. given (,x) – Output: 1 if P halts on input x 0 if P does not halt on input x Theorem (Turing): There is no program that solves the halting problem. It is “undecidable” Proof idea: “diagonalization” – Table of the Halting Problem answers – Each row is a fingerprint of its program – If there is a program H for the Halting problem then we can create a new program D that can’t be in any row Autumn 2011CSE 3114

input x program code (,x) entry is 1 if program P halts on input x and 0 if it runs forever

input x program code Want to create a new program whose halting properties are given by the flipped diagonal Flipped Diagonal

7 Code for D assuming subroutine H that solves the Halting Problem Function D(x): – if H(x,x)=1 then while (true); /* loop forever */ – else no-op; /* do nothing and halt */ – endif D’s fingerprint is different from every row of the table – D can’t be a program so H cannot exist!

More on the proof The Halting Problem takes exactly the same kind of input as the Universal machine U does. – Though H can’t exist, we know that U does Why can’t we apply the same diagonalization trick to a table of what U does? – We’ll just write a 1 in the table if U halts rather than write the output of U Autumn 2011CSE 3118

input x program code → 1 1 → → → → → 1 → 1 1 → → 1 → → → → → → → → 1 1 → 1 → 1 1 → 1 →.... → → → → → → → 1 1 → → 1 1 → → → → → → → → 1 1 → 1 → (,x) entry is 1 if program P halts on input x and → (runs forever) if it runs forever U

→ 1 1 → → → → → 1 → 1 1 → → 1 → → → → → → → → 1 1 → 1 → 1 1 → 1 →.... → → → → → → → 1 1 → → 1 1 → → → → → → → → 1 1 → 1 → input x program code (,x) entry is 1 if program P halts on input x and → (runs forever) if it runs forever U Using U instead of H in D to get D’ won’t flip the diagonal, it will just make it all →

Another view of the proof We can forget the table and just create the code for D assuming that the code for H exists Function D(x): if H(x,x)=1 then – while (true); /* loop forever */ else – no-op; /* do nothing and halt */ endif Then ask what does D do on input ? – Does it halt? Autumn 2011CSE 31111

D halts on input ⇔ H outputs 1 on input (, ) [since H solves the halting problem and so H(,x) outputs 1 iff D halts on input x] ⇔ D runs forever on input [since D goes into an infinite loop on x iff H(x,x)=1] Autumn 2011CSE Function D(x): if H(x,x)=1 then – while (true); /* loop forever */ else – no-op; /* do nothing and halt */ endif Does D halt on input ? Another view of the proof

D halts on input ⇔ H outputs 1 on input (, ) [since H solves the halting problem and so H(,x) outputs 1 iff D halts on input x] ⇔ D runs forever on input [since D goes into an infinite loop on x iff H(x,x)=1] Autumn 2011CSE Function D(x): if H(x,x)=1 then – while (true); /* loop forever */ else – no-op; /* do nothing and halt */ endif Does D halt on input ? Another view of the proof Contradiction!

SCOOPING THE LOOP SNOOPER A proof that the Halting Problem is undecidable by Geoffrey K. Pullum (U. Edinburgh) Autumn 2011CSE No general procedure for bug checks succeeds. Now, I won’t just assert that, I’ll show where it leads: I will prove that although you might work till you drop, you cannot tell if computation will stop. For imagine we have a procedure called P that for specified input permits you to see whether specified source code, with all of its faults, defines a routine that eventually halts. You feed in your program, with suitable data, and P gets to work, and a little while later (in finite compute time) correctly infers whether infinite looping behavior occurs...

SCOOPING THE LOOP SNOOPER Autumn 2011CSE Here’s the trick that I’ll use -- and it’s simple to do. I’ll define a procedure, which I will call Q, that will use P’s predictions of halting success to stir up a terrible logical mess.... And this program called Q wouldn’t stay on the shelf; I would ask it to forecast its run on itself. When it reads its own source code, just what will it do? What’s the looping behavior of Q run on Q?... Full poem at:

16 Using undecidability of the halting problem We have one problem that we know is impossible to solve – Halting problem Showing this took serious effort We’d like to use this fact to derive that other problems are impossible to solve – don’t want to go back to square one to do it

17 Another undecidable problem The “always halts” problem – Given:, the code of a program Q – Output: 1 if Q halts on every input 0 if not. Claim: the “always halts” problem is undecidable Proof idea: – Show we could solve the Halting Problem if we had a solution for the “always halts” problem. – No program solving for Halting Problem exists  no program solving the “always halts” problem exists

18 What we would like To solve the Halting Problem need to handle inputs of the form (,x) Our program will create a new program code so that – If P halts on input x then Q always halts – If P runs forever on input x then Q runs forever on at least one input In fact, the we create will act the same on all inputs

19 Creating from (,x) Given (,x) modify code of P to: – Replace all input statements of P that read input x, by assignment statements that ‘hard-code’ x in P This creates a new program text It would be easy to write a program T that changes (,x) to

20 The transformation int main(){ … scanf(“%d”,&u); … scanf(“%d”,&v); … } int main(){ … u = 123; … v = 712; … } (,x) <Q><Q>

21 Program to solve Halting Problem if “always halts” were decidable Suppose “always halts” were solvable by program A On input (,x) – execute the program T to transform (,x) into as on last slide – call A with (the output of T) as its input and use A’s output as the answer. This would do the job of H which we know can’t exist so A can’t exist

Claim: Given (,x) it is undecidable to determine whether or not P tries to divide by 0 when run on input x Autumn 2011CSE 31122

Claim: Given (,x) it is undecidable to determine whether or not P accesses an array out of bounds when run on input x Autumn 2011CSE 31123

24 The “yes” problem – Given:, the code of a program R – Output: 1 if R outputs “yes” on every input 0 if not. Claim: the “yes” problem is undecidable

25 Same kind of idea as “always halts” To solve the Halting Problem need to be able to handle inputs of the form (,x) We’ll create a new program code so that – If P halts on input x then R always outputs “yes” – If P runs forever on input x then R does something else on at least one input.

26 Creating from (,x) Given (,x) modify code of P to: – Remove all output statements from P – Replace all input statements of P that read input x, by assignment statements that hard-code x in P – Add a new last statement that prints “yes” This creates a new program text It would be easy to write a program T that changes (,x) to

27 Program to solve Halting Problem if the “yes” problem were decidable Suppose the “yes” problem were solvable by program Y On input (,x) – execute the code to transform (,x) into as on last slide – call Y with (the output of T) as its input and use Y’s output as the answer.

28 Equivalent program problem Input: the codes of two programs, and Output: 1 if P produces the same output as Q does on every input 0 otherwise Claim: The equivalent program problem is undecidable

Autumn 2011CSE 31129

30 A general phenomenon: Can’t tell a book by its cover Suppose you have a problem C that asks, given program code, to determine some property of the input-output behavior of P, answering 1 if P has the property and 0 if P doesn’t have the property. Rice’s Theorem: If C’s answer isn’t always the same then there is no program deciding C

31 Even harder problems Recall that with the halting problem, we could always get at least one of the two answers correct – if it halted we could always answer 1 (and this would cover precisely all 1’s we need to do) but we can’t be sure about answering 0 There are natural problems where you can’t even do that! – The equivalent program problem is an example of this kind of even harder problem.

32 Quick lessons Don’t rely on the idea of improved compilers and programming languages to eliminate major programming errors – truly safe languages can’t possibly do general computation Document your code!!!! – there is no way you can expect someone else to figure out what your program does with just your code....since....in general it is provably impossible to do this!