Cs3102: Theory of Computation Class 18: Proving Undecidability Spring 2010 University of Virginia David Evans.

Slides:



Advertisements
Similar presentations
Formal Models of Computation Part III Computability & Complexity
Advertisements

David Evans cs302: Theory of Computation University of Virginia Computer Science Lecture 17: ProvingUndecidability.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Lecture 3 Universal TM. Code of a DTM Consider a one-tape DTM M = (Q, Σ, Γ, δ, s). It can be encoded as follows: First, encode each state, each direction,
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 26: Proving Uncomputability Visualization.
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.
The Recursion Theorem Sipser – pages Self replication Living things are machines Living things can self-reproduce Machines cannot self reproduce.
Turing -Recognizable vs. -Decidable
Class 39: Universality cs1120 Fall 2009 David Evans University of Virginia.
David Evans CS200: Computer Science University of Virginia Computer Science Class 27: Modeling Computation.
1 COMP 382: Reasoning about algorithms Unit 9: Undecidability [Slides adapted from Amos Israeli’s]
Nathan Brunelle Department of Computer Science University of Virginia Theory of Computation CS3102 – Spring 2014 A tale.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
Reducibility Sipser 5.1 (pages ). CS 311 Fall Reducibility.
Reducibility Sipser 5.1 (pages ).
1 Introduction to Computability Theory Lecture13: Mapping 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.
CS 302: Discrete Math II A Review. An alphabet Σ is a finite set (e.g., Σ = {0,1}) A string over Σ is a finite-length sequence of elements of Σ For x.
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
Fall 2004COMP 3351 Reducibility. Fall 2004COMP 3352 Problem is reduced to problem If we can solve problem then we can solve problem.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 5 Reducibility Contents Undecidable Problems from Language Theory.
Courtesy Costas Busch - RPI1 Reducibility. Courtesy Costas Busch - RPI2 Problem is reduced to problem If we can solve problem then we can solve problem.
Class 19: Undecidability in Theory and Practice David Evans cs302: Theory of Computation University of Virginia Computer.
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 20: Busy Beavers Spring 2010 University of Virginia David Evans Office hours: I am not able to hold my Thursday morning.
Cs3102: Theory of Computation Class 17: Undecidable Languages Spring 2010 University of Virginia David Evans.
Remaining Topics Decidability Concept 4.1 The Halting Problem 4.2
Class 37: Computability in Theory and Practice cs1120 Fall 2011 David Evans 21 November 2011 cs1120 Fall 2011 David Evans 21 November 2011.
MA/CSSE 474 Theory of Computation More Reduction Examples Non-SD Reductions.
Cs3102: Theory of Computation Class 24: NP-Completeness Spring 2010 University of Virginia David Evans.
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.
David Evans cs302: Theory of Computation University of Virginia Computer Science Lecture 16: Universality and Undecidability.
Class 24: P=NP? David Evans cs302: Theory of Computation University of Virginia Computer Science PS6 (the last one) is.
1 Computability CS 101E Spring 2007 Michele Co. 2 So Far In Class We’ve seen the following programming constructs –if, if-else, if-else-if –switch –for.
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,
 2005 SDU Lecture13 Reducibility — A methodology for proving un- decidability.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 7 Undecidability cont. Jan Maluszynski, IDA, 2007
Turing -Recognizable vs. -Decidable
CSE 311 Foundations of Computing I Lecture 28 Computability: Other Undecidable Problems Autumn 2011 CSE 3111.
1 Chapter 9 Undecidability  Turing Machines Coded as Binary Strings  Universal Turing machine  Diagonalizing over Turing Machines  Problems as Languages.
David Evans CS200: Computer Science University of Virginia Computer Science Class 26: Halting Problem It is plain at any.
Fall 2013 Lecture 27: Turing machines and decidability CSE 311: Foundations of Computing.
Decidability and Undecidability Proofs
Busch Complexity Lectures: Reductions
CSE 311 Foundations of Computing I
Reductions Costas Busch - LSU.
CS154, Lecture 10: Rice’s Theorem, Oracle Machines
CS154, Lecture 8: Undecidability, Mapping Reductions
CSCE 411 Design and Analysis of Algorithms
CS154, Lecture 10: Rice’s Theorem, Oracle Machines
CS154, Lecture 8: Undecidability, Mapping Reductions
CSE 311 Foundations of Computing I
Decidable Languages Costas Busch - LSU.
Decidability Turing Machines Coded as Binary Strings
Decidability Turing Machines Coded as Binary Strings
Undecidable problems:
Halting Problem.
Class 24: Computability Halting Problems Hockey Team Logo
Instructor: Aaron Roth
Subject Name: FORMAL LANGUAGES AND AUTOMATA THEORY
More undecidable languages
CSE 311: Foundations of Computing
More Undecidable Problems
Presentation transcript:

cs3102: Theory of Computation Class 18: Proving Undecidability Spring 2010 University of Virginia David Evans

Menu Revisiting the Halting Problem – Proof by Paradox – Universal Programming Languages Reduction Proofs Barbara Liskov’s Turing Award: CLU and Data Abstraction

Halting Problem

Halting Problem is Undecidable

HALTS Python

Suppose halts solves Halting Problem >>> halts('3 + 3') True >>> halts(""" i = 0 while i < 100: i = i * 2""") False def halts(code):... ?... Input: a string representing a Python program. Output: If evaluating the input program would ever finish, output true. Otherwise, output false.

halts(""" def is_sum_of_two_primes(n): for a in range(2, n/2): for b in range(2, n/2): if a + b == n and is_prime(a) and is_prime(b): return True return False i = 2 while is_sum_of_two_primes(i): i = i + 1 return False """) Goldbach Conjecture: Every even integer can be written as the sum of two primes. (Open problem since 1742.)

Undecidability of Halts def paradox(): if halts('paradox()'): while True: pass def paradox(): if halts('paradox()'): while True: pass Does paradox() halt? Yes?: If paradox halts, the if test is true and it evaluates to an infinite loop: it doesn’t halt! No?: If paradox doesn’t halt, the if test is false and it finishes. It halts!

Universal Programming Language Universal Turing Machine: a Turing machine that can simulate every other Turing machine – Every algorithm can be implemented by a UTM Universal Programming Language: a programming language that can simulate a Universal Turing Machine – All real implementations have limits (can’t really simulate infinite tape), but all common PLs are effectively universal

Proofs of Undecidability To prove a language is undecidable, need to show there is no Turing Machine that can decide the language. This is hard: requires reasoning about all possible TMs.

Proof by Reduction 0. We know X does not exist. (e.g., X = a TM that can decide A TM ) X 1. Assume Y exists. (e.g., Y = a TM that can decide B ) Y 2. Show how to use Y to make X. Y 3. Contradiction: Since X does not exist, but Y could be used to make X, then Y must not exist.

Reduction Proofs B B reduces to A A means that can decide B can be used to make that can decide A The name “reduces” is confusing: it is in the opposite direction of the making. The name “reduces” is confusing: it is in the opposite direction of the making. Hence, A is not a harder problem than B. Y Y X X

Converse? Y that can solve B can be used to make X that can solve A A is not a harder problem than B. A reduces to B Does this mean B is as hard as A? No! Y can be any solver for B. X is one solver for A. There might be easier solvers for A. No! Y can be any solver for B. X is one solver for A. There might be easier solvers for A.

Reduction = Proof by Contradiction and Construction Assume M B is a TM that decides L B. Do a construction using M B to build M A, a TM that decides L A. Since L A is undecidable, M A cannot exist. We have reached a contradiction, so (as long as nothing else is questionable) our assumption must be wrong. This shows L A reduces to L B, proving L B is at least as hard as L A.

Reduction Pitfalls Be careful: the direction matters a great deal – To show L B is at least as hard to decide as L A, we need to show that a machine M B that decides L B could be used to build a machine M A that decides L A. – To show equivalence, need reductions in both directions. You can’t assume anything about M B other than it decides L B. The construction of M A must involve only things you know you can do: otherwise the contradiction might be because something else doesn’t exist. What does can do mean here?

What “Can Do” Means The transformations in a reduction proof are limited by what you are proving For undecidability proofs, you are proving something about all TMs: the reduction transformations are anything that a TM can do that is guaranteed to terminate For complexity proofs (later), you are proving something about how long it takes: the time it takes to do the transformation is limited

Halting Problem is Undecidable What are L B, L A, M B, M A ?

Reduction = Proof by Contradiction and Construction Assume M B is a TM that decides L B. Do a construction using M B to build M A, a TM that decides L A. Since L A is undecidable, M A cannot exist. We have reached a contradiction, so (as long as nothing else is questionable) our assumption must be wrong.

Reduction Proof

Equivalence of Machines Is EQ DT decidable?

EQ DM Is Undecidable Suppose M EQ decides EQ DT. Can we use M EQ to decide HALTS TM ?

Reduction Proof Assumption M EQ TM that decides EQ DT Accept or Reject

Reduction Proof Construction M EQ TM that decides EQ DT Accept or Reject Accept or Reject M H that decides HALTS TM

Constructing M H M EQ TM that decides EQ DT Accept or Reject Accept or Reject M H that decides HALTS TM

EQ DT Is Undecidable If we had a TM that decides EQ DT, we could use it to do something we know is impossible: build a TM that decides HALTS TM.

Empty Language

Proving Undecidability M E TM that decides E TM Accept or Reject Accept or Reject M H that decides HALTS TM

Reducing HALTS TM to E TM

Reducing A TM to E TM If a problem is undecidable, any undecidable problem can be reduced to it. (But not all choices are as simple and elegant.) If a problem is undecidable, any undecidable problem can be reduced to it. (But not all choices are as simple and elegant.)

SQUARE

SQUARE: Valid Proof? Not a valid proof. The reduction is in the wrong direction!

Rice’s Theorem Any nontrivial property about the language of a Turing machine is undecidable. Henry Gordon Rice, 1951 “Nontrivial” means the property is true for some TMs, but not for all TMs.

Generalizing Rice’s Theorem Any nontrivial property about the language of a Turing machine is undecidable. Any nontrivial property about the execution of any universal computing system is undecidable.

Rice Hall

Rice’s Theorem: Proof Sketch H decides HALTS. Thus, M P must not exist. Thus, P must not be decidable. H decides HALTS. Thus, M P must not exist. Thus, P must not be decidable. What are we assuming about P ?

Which of these are Undecidable? Does TM M accept any strings? Does TM M accept all strings? Does TM M accept “Hello”? Does TM M 1 accept more strings than TM M 2 ? Does TM M take more than 1000 steps to process input w ? Decidable Undecidable Note: for PS5 problems 2 and 4, you may use Rice’s theorem to get an intuition about the right answer, but cannot use it for your proof.

Type Safety >>> s = "hello" >>> s + 3 Traceback (most recent call last): File " ", line 1, in s + 3 TypeError: Can't convert 'int' object to str implicitly Not decidable: very sketchy proof: halts(P) = not wellTyped (‘removeTypeErrors(P); s = “hello”; s + 3’) Not decidable: very sketchy proof: halts(P) = not wellTyped (‘removeTypeErrors(P); s = “hello”; s + 3’)

Well-Typed Java? public class Test { static public void main(String args[]) { String s; s = "Hello"; s = s + 3; System.out.println("s = " + s); } > javac Test.java > java Test s = Hello3 > javac Test.java > java Test s = Hello3 public class Test { static public void main(String args[]) { String s; s = "Hello"; s = s - 3; System.out.println("s = " + s); } > javac Test.java Test.java:5: operator - cannot be applied to java.lang.String,int > javac Test.java Test.java:5: operator - cannot be applied to java.lang.String,int

Type Safety This is decidable: your Java compiler should do this (and should always terminate)! WELLTYPED JAVA ( ) = { P is a Java program that does not use type casts or array assignments and P never produces a run-time type error. } WELLTYPED JAVA ( ) = { P is a Java program that does not use type casts or array assignments and P never produces a run-time type error. }

CLU Type Safety WELLTYPED CLU ( ) = { P is a CLU program and P never produces a run-time type error. } WELLTYPED CLU ( ) = { P is a CLU program and P never produces a run-time type error. }

Thursday’s Class