Module 7 Halting Problem –Fundamental program behavior problem –A specific unsolvable problem –Diagonalization technique revisited Proof more complex 1.

Slides:



Advertisements
Similar presentations
PROOF BY CONTRADICTION
Advertisements

Lecture 19. Reduction: More Undecidable problems
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
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.
Lecture 9 Recursive and r.e. language classes
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
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
Module 5 Topics Proof of the existence of unsolvable problems
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 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.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 19 Instructor: Paul Beame.
Today - Limits of computation - Complexity analysis examples.
1 Lecture 7 Halting Problem –Fundamental program behavior problem –A specific unsolvable problem –Diagonalization technique revisited Proof more complex.
1 Lecture 16 FSA’s –Defining FSA’s –Computing with FSA’s Defining L(M) –Defining language class LFSA –Comparing LFSA to set of solvable languages (REC)
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 Lecture 7 Topics –Problems about program behavior At least problem input is a program/algorithm –Halting Problem Fundamental problem about program behavior.
1 Module 4: Formal Definition of Solvability Analysis of decision problems –Two types of inputs:yes inputs and no inputs –Language recognition problem.
1 Module 8 Halting Problem revisited –Universal Turing machine half-solves halting problem –A universal Turing machine is an operating system/general purpose.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 18 Instructor: Paul Beame.
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 10 Recursive and r.e. language classes –representing solvable and half-solvable problems Proofs of closure properties –for the set of recursive.
1 Lecture 6 Topics –Proof of the existence of unsolvable problems Problems/languages not in REC Proof Technique –There are more problems/languages than.
Section 3.1: Proof Strategy Now that we have a fair amount of experience with proofs, we will start to prove more difficult theorems. Our experience so.
CS 3813: Introduction to Formal Languages and Automata Chapter 12 Limits of Algorithmic Computation These class notes are based on material from our textbook,
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.
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
CompSci Today’s Topics Computer Science Noncomputability Upcoming Special Topic: Enabled by Computer -- Decoding the Human Genome Reading Great.
1 Recursively Enumerable and Recursive Languages.
Recursively Enumerable and Recursive Languages. Definition: A language is recursively enumerable if some Turing machine accepts it.
Decidability.
1 A Universal Turing Machine. 2 Turing Machines are “hardwired” they execute only one program A limitation of Turing Machines: Real Computers are re-programmable.
CSE15 Discrete Mathematics 03/06/17
Recursion Version 1.0.
The Acceptance Problem for TMs
A Universal Turing Machine
Recursively Enumerable and Recursive Languages
This statement is false.
CSE 311 Foundations of Computing I
Lecture12 The Halting Problem
Automata, Grammars and Languages
2.4 Sequences and Summations
HIERARCHY THEOREMS Hu Rui Prof. Takahashi laboratory
Busch Complexity Lectures: Undecidable Problems (unsolvable problems)
Andreas Klappenecker [based on slides by Prof. Welch]
CSCE 411 Design and Analysis of Algorithms
How Hard Can It Be?.
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
Discrete Math for CS CMPSC 360 LECTURE 43 Last time: Variance
Formal Languages, Automata and Models of Computation
Instructor: Aaron Roth
CSE 311: Foundations of Computing
Instructor: Aaron Roth
CSE 105 theory of computation
MA/CSSE 474 Theory of Computation
Algorithms CSCI 235, Spring 2019 Lecture 37 The Halting Problem
Lecture 4: Unsolvable Problems
MA/CSSE 474 Theory of Computation
Presentation transcript:

Module 7 Halting Problem –Fundamental program behavior problem –A specific unsolvable problem –Diagonalization technique revisited Proof more complex 1

Definition Input –Program P Assume the input to program P is a single nonnegative integer –This assumption is not necessary, but it simplifies the following unsolvability proof –To see the full generality of the halting problem, remove this assumption –Nonnegative integer x, an input for program P Yes/No Question –Does P halt when run on x? Notation –Use H as shorthand for halting problem when space is a constraint 2

Example Input * Program with one input of type unsigned bool main(unsigned Q) { int i=3; if ((Q = = 0) || (Q= = 1)) return false; while (i<Q) { if ((Q-i) = = 1) return (false); i--; } return (true); } Input x 5 3

Three key definitions 4

Definition of list L *  P * is countably infinite where  P = {characters, digits, white space, punctuation} Type program will be type string with  P as the alphabet Define L to be the strings in  P * listed in enumeration order –length 0 strings first –length 1 strings next –…–… Every program is a string in  P –For simplicity, consider only programs that have one input the type of this input is an unsigned Consider strings in  P * that are not legal programs to be programs that always crash (and thus halt on all inputs) 5

Definition of P H * If H is solvable, some program must solve H Let P H be a procedure which solves H –We declare it as a procedure because we will use P H as a subroutine Declaration of P H –bool P H (program P, unsigned x) In general, the type of x should be the type of the input to P Comments –We do not know how P H works –However, if H is solvable, we can build programs which call P H as a subroutine 6

Definition of program D bool main(unsigned y) /* main for program D */ { program P = generate(y); if (P H (P,y)) while (1>0); // Infinite loop else return (yes); // Termination } /* generate the yth string in  P * in enumeration order */ program generate(unsigned y) bool P H (program P, unsigned x) /* how P H solves H is unknown */ 7

Generating P y from y * We won’t go into this in detail here –This was the basis of the question at the bottom of slide 21 of lecture 5 (alphabet for that problem was {a,b} instead of  P ). –This is the main place where our assumption about the input type for program P is important for other input types, how to do this would vary Specification –0 maps to program –1 maps to program a –2 maps to program b –3 maps to program c –…–… –26 maps to program z –27 maps to program A –…–… 8

Properties of D Takes One input y –Treats y as an encoding of program P –Runs P on input y –(Observe that y is being used in two ways) –If P halts on y then D goes into an infinite loop –If P does not halt on y then D stops Note that because we assumed that H is solvable, P H is guaranteed to halt and say that P does not halt on y. Next, we want to evaluate what happens if D (encoding of D as an integer) is provided as an input to D –We will show that this creates a contradiction proving that D cannot exist 9

Argument Overview * 10 H is solvable D is NOT on list L P H exists Definition of Solvability D exists D’s code D is on list L L is list of all programs D does NOT exist P H does NOT exist H is NOT solvable p → q is logically equivalent to (not q) → (not p)

Trace Program D with input (encoding of D) bool main(unsigned y) /* main for program D */ { program P = generate(y); if (P H (P,y)) while (1>0); else return (yes); } 11 Generated program is D Input y = encoding of D Does D halt on D? Yes No But Code of D says that it does not But Code of D says that it does Thus, program P H must not exist

Placing the Halting Problem 12 Solvable  ll Problems H

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 13

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