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

Slides:



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

PROOF BY CONTRADICTION
Lecture 19. Reduction: More Undecidable problems
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.
Copyright © Cengage Learning. All rights reserved.
1 COMP 382: Reasoning about algorithms Unit 9: Undecidability [Slides adapted from Amos Israeli’s]
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.
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.
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
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.
CSE115/ENGR160 Discrete Mathematics 03/03/11 Ming-Hsuan Yang UC Merced 1.
1 Module 11 Proving more specific problems are not solvable Input transformation technique –Use subroutine theme to show that if one problem is unsolvable,
Decidable and undecidable problems deciding regular languages and CFL’s Undecidable problems.
1 Uncountable Sets continued Theorem: Let be an infinite countable set. The powerset of is uncountable.
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 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.
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 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 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.
1 Reducibility. 2 Problem is reduced to problem If we can solve problem then we can solve problem.
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.
C++ fundamentals.
Cardinality of Sets Section 2.5.
February 18, 2015CS21 Lecture 181 CS21 Decidability and Tractability Lecture 18 February 18, 2015.
MA/CSSE 474 Theory of Computation More Reduction Examples Non-SD Reductions.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 15-1 Mälardalen University 2012.
Slide 1 Propositional Definite Clause Logic: Syntax, Semantics and Bottom-up Proofs Jim Little UBC CS 322 – CSP October 20, 2014.
Great Theoretical Ideas in Computer Science about AWESOME Some Generating Functions Probability Infinity Computability With Alan! (not Turing) Mind-
A Universal Turing Machine
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.
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.
CSE 311: Foundations of Computing Fall 2014 Lecture 27: Cardinality.
Recursively Enumerable and Recursive Languages
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.
Module 7 Halting Problem –Fundamental program behavior problem –A specific unsolvable problem –Diagonalization technique revisited Proof more complex 1.
This statement is false.
CSE 311 Foundations of Computing I
Busch Complexity Lectures: Undecidable Problems (unsolvable problems)
CSCE 411 Design and Analysis of Algorithms
Discrete Math for CS CMPSC 360 LECTURE 43 Last time: Variance
CS21 Decidability and Tractability
CSE 311: Foundations of Computing
Lecture 4: Unsolvable Problems
Presentation transcript:

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

2 Definition Input –Program P Assume the input to program P is a single unsigned int –This assumption is not necessary, but it simplifies some of 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?

3 Example Input Program with one input of type unsigned int bool main(unsigned int Q) { int i=2; if (Q == 0) return false; while (i<Q) { if (Q%i == 0) return (false); i++; } return (true); } Input x –73

4 Proof that H is not solvable

5 Definition of list L The set of all programs is countably infinite –For simplicity, assume these programs have one input the type of this input is an unsigned int This means there exists a list L where –each program is on this list –the programs will appear on this list by order of length length 0 programs first length 1 programs next … Simpler compared to last time –We built an algorithm D to work with any countably infinite list –Now, we get to work with this specific list

6 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 int 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

7 Argument Overview List L contains all programs (with one input of type unsigned int) –We use list L to specify a pattern of program behavior B which is distinct from all real program behaviors We construct a program D (with one input of type unsigned int) with the following properties –D satisfies the specification of program behavior B and is thus not on list L –D uses P H as a subroutine which means D exists if P H exists These two facts imply H is not solvable –Since L contains all programs but not D, D must not exist –Since D exists if P H exists, P H does not exist

8 Visualizing List L of Programs P0P0 P1P1 P2P2 P3P3 P4P4...  1234 HHHHH NHHHH HH H H H HH #Rows is countably infinite  p * is countably infinite #Cols is countably infinite Set of n  nnegative integers is countably infinite Consider each number to be a feature –A program halts or doesn’t halt on each integer –Several programs may be identical now (e.g. several always halt) –We have a fixed L this time

9 Specifying a non-existent program behavior B P0P0 P1P1 P2P2 P3P3 P4P4...  1234 HHHHH NHHHH HH H H H HH We specify a non-existent program behavior B by using a unique feature (number) to differentiate B from P i NH H H H B

10 Specification Insufficient Task not complete –The previous slide only provides a specification B for program D That is, B describes how program D should behave in order to not be on the list of all programs –We still need to construct an actual program D that behaves this way –Previous number of languages proof The specification of language D(L) was sufficient We were done at this point

11 Overview of D Program D with input y –(type for y: unsigned int) Given input y, generate the program (string) P y Run P H on P y and y Guaranteed to halt since P H decides H IF (P H (P y,y)) while (1>0); else return (yes); P0P0 P1P1 P2P2 PyPy...  12 HH HH NH H D...y HNH

12 Observation For some y, the computed P y of  P * will not be a legal program In particular, the computed P y will not be the y th legal program a b P i-1...  12 HH HH NH H D...i Not a program First Legal Program... i th Legal Program P0P0... y

13 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. –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 –…–…

14 bool main(unsigned int y) /* main for program D */ { program P = generate(y); if (P H (P,y)) while (1>0); else return (yes); } bool P H (program P, unsigned int x) /* how P H solves H is unknown */ Claims –Program D exhibits behavior B –Program D exists if P H exists Code for D and P H

15 Alternate Proof For every program P y, there is a number y that we associate with it The number we use to distinguish program P y from D is this number y Using this idea, we can arrive at a contradiction without explicitly using the table L –The diagonalization is hidden

16 H is not solvable, proof II Assume H is solvable –Let P H be the program which solves H –Use P H to construct program D which cannot exist Contradiction –This means program P H cannot exist. –This implies H is not solvable D is the same as before

17 Arguing D cannot exist If D is a program, it must have an associated number y What does D do on this number y? 2 cases –D halts on 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

18 Continued –D does not halt on this number 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

19 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

20 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