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.

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.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
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.
Turing -Recognizable vs. -Decidable
Computability & Complexity. Scenario I can’t write this program because I’m too dumb.
1 The Limits of Computation Intractable and Non-computable functions.
1 COMP 382: Reasoning about algorithms Unit 9: Undecidability [Slides adapted from Amos Israeli’s]
CSE115/ENGR160 Discrete Mathematics 02/28/12
Nathan Brunelle Department of Computer Science University of Virginia Theory of Computation CS3102 – Spring 2014 A tale.
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.
Proof Points Key ideas when proving mathematical ideas.
The Halting Problem Sipser 4.2 (pages ).
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.
Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages.
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]
CSE115/ENGR160 Discrete Mathematics 03/03/11 Ming-Hsuan Yang UC Merced 1.
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.
Today - Limits of computation - Complexity analysis examples.
Analysis of Algorithms CS 477/677
Fall 2006Costas Busch - RPI1 Undecidable Problems (unsolvable problems)
Prof. Busch - LSU1 Undecidable Problems (unsolvable problems)
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.
Lecture , 3.1 Methods of Proof. Last time in 1.5 To prove theorems we use rules of inference such as: p, p  q, therefore, q NOT q, p  q, therefore.
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.
1 Ethics of Computing MONT 113G, Spring 2012 Session 13 Limits of Computer Science.
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.
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.
1 Sections 1.5 & 3.1 Methods of Proof / Proof Strategy.
Halting Problem Introduction to Computing Science and Programming I.
Notes on local determinism Days 12, 13 and 14 of Comp Sci 480.
Naïve Set Theory. Basic Definitions Naïve set theory is the non-axiomatic treatment of set theory. In the axiomatic treatment, which we will only allude.
The Halting Problem Can we design a program that, given any other program and its input, tells whether that program will halt when run on that input?
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)
Russell’s Paradox and the Halting Problem Lecture 24 Section 5.4 Wed, Feb 23, 2005.
Complexity & Computability. Limitations of computer science  Major reasons useful calculations cannot be done:  execution time of program is too long.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Math Review 1.
Powerpoint Templates Page 1 Powerpoint Templates Impossible Math Problems (or should we say, undecidable) Math Club 4/16/2012.
CSE 311 Foundations of Computing I Lecture 28 Computability: Other Undecidable Problems Autumn 2011 CSE 3111.
CompSci On the Limits of Computing  Reasons for Failure 1. Runs too long o Real time requirements o Predicting yesterday's weather 2. Non-computable.
Fundamentals of Informatics Lecture 12 The Halting Problem Bas Luttik.
Very Hard Problems I am so not kidding about this. Please grab a handout.
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.
THE HALTING PROBLEM - PROOF. Review  What makes a problem decidable?  3 properties of an efficient algorithm?  What is the meaning of “complete”, “mechanistic”,
Computability. Turing Machines Read input letter & tape letter, write tape letter, move left or right.
Recursively Enumerable and Recursive Languages. Definition: A language is recursively enumerable if some Turing machine accepts it.
Decidability.
Undecidable Problems Costas Busch - LSU.
Busch Complexity Lectures: Undecidable Problems (unsolvable problems)
CSE 105 theory of computation
CSCE 411 Design and Analysis of Algorithms
CSE 311 Foundations of Computing I
Decidable Languages Costas Busch - LSU.
Halting Problem.
CSE 311: Foundations of Computing
More Undecidable Problems
CSE 105 theory of computation
Presentation transcript:

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 a tool that would warn us that our program has this bug? (We could make a lot of money if we could develop such a tool!)

Example Infinite loop - we get into a loop but for some reason we never get out of it. for (i = 0; i < 10; i--) { document.writeln(“Help, I’m in an infinite loop! ”); }

Example Output Help, I’m in an infinite loop! …

Definition Design a program, H, that will do the following: 1.Take as its input a description of a program P (in binary, say). 2.Halt eventually and answer "yes" if P will eventually halt, or halt and answer "no" if P will run forever.

Halting Problem In other words, Program H will always halt and give the correct answer no matter what program has been given as input. H programHalts? Yes or No

Proving the Halting Problem We want to prove that the halting problem is non-computable. In other words, there is no algorithm that we can use to tell whether or not a program will halt. We will use proof by contradiction.

Proof by Contradiction Prove: if x+y >= 2, then x>=1 or y>=1. –Assume that x+y>=2 and that x<1 and y<1. –Then, x+y < 1+1 = 2. –This is a contradiction since x+y >=2! –Thus our assumption that x<1 and y<1 is false. Note: NOT(x>=1 or y>=1) = (x<1 and y<1) by DeMorgan’s Laws.

Proof by Contradiction: We’ll assume that the Halting Problem CAN be computed. We’ll develop another program that uses the Halting Problem function. We’ll find ourselves caught in a paradox (the contradiction). We’ll have proven that our original assumption is false.

Assume Halting Problem OK Let H be a program (or sub-program) that determines whether a program will halt. H programHalts? Yes or No

Let’s Build Another Program Let P be a program that uses H. For any given program, P will call H and pass it the given program. H program

What does P do? Now, P acts as follows: –P takes a program as input and feeds the program to H as input. –If H answer yes, then P will enter an infinite loop and run forever. –If H answer no, then P will stop.

What does P do ? H program Yes No

The program P function P (program) { var halts = H(program); if (halts == True) infinite loop; else stop; }

What Can We Do With P? Let’s give P a copy of itself as its input. H Yes No program:

What If P Halts? H Yes No program:

What If P Loops Indefinitely? H Yes No program:

The Paradox If P is a program that halts when given itself as its input, then, when given itself as input, P will go into an infinite loop. If P is a program that loops indefinitely when given itself as its input, then, when given itself as input, P will halt immediately.

What Went Wrong? There’s nothing wrong with P, itself. The problem must be with the assumption that we could write H.

So, Proof by Contradiction: We assumed that the Halting Problem COULD be computed. We developed another program that used the Halting Problem function. We found ourselves caught in a paradox (the contradiction). We proved that the Halting Problem is not computable.

Conclusions Self-referentiality is a real problem with programs Rice’s theorem says that “Any nontrivial property of programs is undecidable.” Thus, we can’t write programs to answer questions about programs.

Intractability The Traveling Salesperson Problem is intractable. Proving it is beyond the scope of this class. We will just understand the problem and how hard it is.

Traveling Sales Problem A salesperson has a group of cities that he/she needs to visit. There are a bunch of distances between the cities. Our salesperson has to visit all the cities by following a path with the least distance (or cost).

TSP Example #1

TSP Answer #1

TSP Example #2

TSP Answer #2

Traveling Sales Problem Conclusions: –The only correct algorithm we could come up with had to examine all possible paths. –The only correct algorithm that anyone has come up with has to examine all possible paths. –Thus this algorithm is O(n!) and intractable.