1 Lecture 7 Topics –Problems about program behavior At least problem input is a program/algorithm –Halting Problem Fundamental problem about program behavior.

Slides:



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

Lecture 19. Reduction: More Undecidable problems
Copyright © Cengage Learning. All rights reserved.
1 COMP 382: Reasoning about algorithms Unit 9: Undecidability [Slides adapted from Amos Israeli’s]
Computability and Complexity 5-1 Classifying Problems Computability and Complexity Andrei Bulatov.
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
1 Introduction to Computability Theory Lecture15: Reductions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
1 Lecture 4 Topics –Problem solving Subroutine Theme –REC language class The class of solvable problems Closure properties.
CPSC 411, Fall 2008: Set 12 1 CPSC 411 Design and Analysis of Algorithms Set 12: Undecidability Prof. Jennifer Welch Fall 2008.
1 Lecture 4: Formal Definition of Solvability Analysis of decision problems –Two types of inputs:yes inputs and no inputs –Language recognition problem.
Hardness Results for Problems P: Class of “easy to solve” problems Absolute hardness results Relative hardness results –Reduction technique.
1 Module 2: Fundamental Concepts Problems Programs –Programming languages.
Lecture 9 Recursive and r.e. language classes
1 Lecture 14 Language class LFSA –Study limits of what can be done with FSA’s –Closure Properties –Comparing to other language classes.
Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages.
1 Module 9 Recursive and r.e. language classes –representing solvable and half-solvable problems Proofs of closure properties –for the set of recursive.
Lecture 8 Recursively enumerable (r.e.) languages
Fall 2003Costas Busch - RPI1 Decidability. Fall 2003Costas Busch - RPI2 Recall: A language is decidable (recursive), if there is a Turing machine (decider)
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
Lecture 2: Fundamental Concepts
1 Module 2: Fundamental Concepts Problems Programs –Programming languages.
Module 5 Topics Proof of the existence of unsolvable problems
1 Lecture 1: Course Overview Course: CSE 360 Instructor: Dr. Eric Torng TA: Huamin Chen.
1 Module 7 Halting Problem –Fundamental program behavior problem –A specific unsolvable problem –Diagonalization technique revisited Proof more complex.
1 Module 11 Proving more specific problems are not solvable Input transformation technique –Use subroutine theme to show that if one problem is unsolvable,
1 Uncountable Sets continued Theorem: Let be an infinite countable set. The powerset of is uncountable.
Fall 2004COMP 3351 The Chomsky Hierarchy. Fall 2004COMP 3352 Non-recursively enumerable Recursively-enumerable Recursive Context-sensitive Context-free.
1 Lecture 10 Proving more specific problems are not recursive Reduction technique –Use subroutine theme to show that if one problem is unsolvable, so is.
1 Lecture 7 Halting Problem –Fundamental program behavior problem –A specific unsolvable problem –Diagonalization technique revisited Proof more complex.
CHAPTER 4 Decidability Contents Decidable Languages
1 Lecture 2 Topics –Importance of this material Fundamental Limitations –Connecting Problems and Languages Problems –Search, function and decision problems.
1 Lecture 7 Halting Problem –Fundamental program behavior problem –A specific unsolvable problem –Diagonalization technique revisited Proof more complex.
1 Lecture 5 Topics –Closure Properties for REC Proofs –2 examples Applications.
Linear Bounded Automata LBAs
1 Lecture 11 Proving more specific problems are not solvable Input transformation technique –Use subroutine theme to show that if one problem is unsolvable,
1 Module 11 Proving more specific problems are not solvable Input transformation technique –Use subroutine theme to show that if one problem is unsolvable,
1 Module 4: Formal Definition of Solvability Analysis of decision problems –Two types of inputs:yes inputs and no inputs –Language recognition problem.
Lecture 27UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 27.
Fall 2006Costas Busch - RPI1 Undecidable Problems (unsolvable problems)
Prof. Busch - LSU1 Undecidable Problems (unsolvable problems)
1 Introduction to Computability Theory Lecture11: The Halting Problem Prof. Amos Israeli.
1 Lecture 11 Proving more specific problems are not solvable Input transformation technique –Use subroutine theme to show that if one problem is unsolvable,
Hardness Results for Problems P: Class of “easy to solve” problems Absolute hardness results Relative hardness results –Reduction technique.
1 Module 10 Recursive and r.e. language classes –representing solvable and half-solvable problems Proofs of closure properties –for the set of recursive.
Hardness Results for Problems
1 Lecture 6 Topics –Proof of the existence of unsolvable problems Problems/languages not in REC Proof Technique –There are more problems/languages than.
1 Lecture 11 Studying structure of REC –Complexity theory overview –Automata theory preview Motivating Problem –string searching.
MA/CSSE 474 Theory of Computation More Reduction Examples Non-SD Reductions.
1 The Halting Problem and Decidability How powerful is a TM? Any program in a high level language can be simulated by a TM. Any algorithmic procedure carried.
Great Theoretical Ideas in Computer Science about AWESOME Some Generating Functions Probability Infinity Computability With Alan! (not Turing) Mind-
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)
Computability Universal Turing Machine. Countability. Halting Problem. Homework: Show that the integers have the same cardinality (size) as the natural.
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.
CSE 311 Foundations of Computing I Lecture 28 Computability: Other Undecidable Problems Autumn 2011 CSE 3111.
Fundamentals of Informatics Lecture 12 The Halting Problem Bas Luttik.
Recursively Enumerable and Recursive Languages
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
1 Chapter 9 Undecidability  Turing Machines Coded as Binary Strings  Universal Turing machine  Diagonalizing over Turing Machines  Problems as Languages.
The Church-Turing Thesis Chapter Are We Done? FSM  PDA  Turing machine Is this the end of the line? There are still problems we cannot solve:
Costas Busch - RPI1 Decidability. Costas Busch - RPI2 Another famous undecidable problem: The halting problem.
Decidability.
Module 7 Halting Problem –Fundamental program behavior problem –A specific unsolvable problem –Diagonalization technique revisited Proof more complex 1.
CSE 311 Foundations of Computing I
Undecidable Problems Costas Busch - LSU.
Busch Complexity Lectures: Undecidable Problems (unsolvable problems)
CSCE 411 Design and Analysis of Algorithms
Decidable Languages Costas Busch - LSU.
Discrete Math for CS CMPSC 360 LECTURE 43 Last time: Variance
Presentation transcript:

1 Lecture 7 Topics –Problems about program behavior At least problem input is a program/algorithm –Halting Problem Fundamental problem about program behavior A specific unsolvable problem Diagonalization technique revisited –Proof more complex

2 Problems about Programs What are some problems you might define where at least one input is a program?

3 Program correctness How do we determine whether or not a program P we have written is correct? –Testing Run program P on some inputs x 1, x 2, … What are some weaknesses to this method? What might be a better approach?

4 Halting Problem (H) definition Input –Program P –Input string x for program P Yes/No Question –Does P halt when run on x? Question –How does H compare to other problems about program behavior?

5 Example Input Program P –Variables Integer array A[10] Integer max,i; –Instructions read input string into array A; max = A[0]; for (i=1;i<10;i++) IF A[i] > max THEN max = A[i]; return max; Input x –10;5;700;3;-10;13;75;82;91;100

6 H is not solvable Assume H is solvable –Let P H be the program which decides H [P H used as a subroutine] Let L be a listing of all programs –L exists because the set of programs is countably infinite –Furthermore, we can specify what L is this time Construct a program D which is not on list L –Use P H to do so [Subroutine theme] Contradiction –This implies H is not recursive –This means program P H does not exist.

7 Representing L P0P0 P1P1 P2P2 P3P3 P4P HHHHH NHHHH HH H H H HH #Rows is countably infinite  * is countably infinite #Cols is countably infinite  * is countably infinite Consider each string to be a feature –A program halts or doesn’t halt on each string –Several programs may be identical now (e.g. several always halt)

8 Specifying D P0P0 P1P1 P2P2 P3P3 P4P HHHHH NHHHH HH H H H HH We specify D by using a unique feature (string) to differentiate D from P i NH H H H D

9 Specification Insufficient Task not complete –The previous slide only provides a specification for program D That is, it describes how program D should behave –We still need to construct an actual program D –Previous number of languages proof The specification of language D was sufficient We were done at this point

10 Constructing D Program D with input y Figure out which program P i should be different from D with respect to input y Run P H on P i and y [subroutine] Guaranteed to halt since P H decides H IF (P H (P i,y) = yes) THEN loop ELSE halt P0P0 P1P1 P2P2 PiPi HH HH NH H D...y HNH

11 Constructing D continued How do we compute P i from y? –Expand the rows to include all of  * including nonprograms –Now P i is simply y assuming y is a program –If y is not a program, it doesn’t matter what D does on input y 0 1 y HH HH NH H D...y Not a program P0P0... PiPi

12 Example Input Again Input y –Integer array A[10] Integer max,i; read input string... Program P –Variables Integer array A[10] Integer max,i; –Instructions read input string into array A; max = A[0]; for (i=1;i<10;i++) IF A[i] > max THEN max = A[i]; return max; Key Point: –string y used to differentiate D from program P

13 Program D with input string y “Double” y to produce string y:y Run P H on y:y [Subroutine Theme] If P H (y:y) = yes THEN loop ELSE halt –If y denotes a program, D is different than that program –If y is an illegal string, D can do anything –Conclusion: D is different from all programs Constructing D continued

14 Alternate Proof We think of y as a string which encodes program P y The string we use to distinguish program P y from D is the encoding of P y, namely y Using this idea, we can arrive at a contradiction without explicitly using the table L –The diagonalization is hidden

15 H is not solvable, proof II Assume H is solvable –Let P H be the program which decides H [Subroutine Theme] Use P H to construct a program D which cannot exist Contradiction –This means program P H cannot exist. –This implies H is not recursive D is the same as before

16 Arguing D cannot exist If D is a program, its encoding must be some string y What does D do on its own encoding y? 2 cases –D halts on its own encoding y This means P H (D:y) = NO –Definition of D This means D does not halt on y –P H solves H Contradiction This case is not possible

17 Continued –D does not halt on its own encoding y This means P H (D:y) = YES –Definition of D This means D halts on y –P H solves H Contradiction This case is not possible –Both cases are not possible, but one must be for D to exist –Thus D cannot exist

18 Implications The Halting Problem is one of the simplest problems we can formulate about program behavior We can use the fact that it is unsolvable to show that other problems about program behavior are also unsolvable This has important implications restricting what we can do in the field of software engineering –In particular, “perfect” debuggers/testers do not exist –We are forced to “test” programs for correctness even though this approach has many flaws We shall see next time that this also forces us to consider a new language class

19 Summary Halting Problem definition –Basic problem about program behavior Halting Problem is unsolvable (not in REC) –We have identified a specific unsolvable problem –Diagonalization technique Proof more complicated because we actually need to construct D, not just give a specification