Halting Problem.

Slides:



Advertisements
Similar presentations
Complexity Classes: P and NP
Advertisements

NP-Hard Nattee Niparnan.
CS211 Problems: unsolvable, unfeasible and unsolved Topic 2: Halting problem.
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.
1 The Limits of Computation Intractable and Non-computable functions.
The Theory of NP-Completeness
1 Introduction to Computability Theory Lecture15: 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 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 21 Instructor: Paul Beame.
1 Polynomial Time Reductions Polynomial Computable function : For any computes in polynomial time.
Analysis of Algorithms CS 477/677
Theory of Computing Lecture 20 MAS 714 Hartmut Klauck.
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.
Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
Cs3102: Theory of Computation Class 18: Proving Undecidability Spring 2010 University of Virginia David Evans.
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
CSE 311 Foundations of Computing I Lecture 30 Computability: Other Undecidable Problems Autumn 2012 CSE 3111.
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.
Halting Problem Introduction to Computing Science and Programming I.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
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.
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.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
CSE 311 Foundations of Computing I Lecture 28 Computability: Other Undecidable Problems Autumn 2011 CSE 3111.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
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.
Modeling Arithmetic, Computation, and Languages Mathematical Structures for Computer Science Chapter 8 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesTuring.
Decidability and Undecidability Proofs
CSC 172 P, NP, Etc.
NP-Completeness A problem is NP-complete if: It is in NP
The NP class. NP-completeness
NP-Complete Problems.
More NP-Complete and NP-hard Problems
The Acceptance Problem for TMs
Introduction to Computing Science and Programming I
CSE 105 theory of computation
Busch Complexity Lectures: Reductions
Linear Bounded Automata LBAs
Undecidable Problems Costas Busch - LSU.
1.5 Intractable problems.
Computable Problems.
Busch Complexity Lectures: Undecidable Problems (unsolvable problems)
CSE 105 theory of computation
Andreas Klappenecker [based on slides by Prof. Welch]
CSCE 411 Design and Analysis of Algorithms
How Hard Can It Be?.
Computational Complexity
CSE 311 Foundations of Computing I
Decidable Languages Costas Busch - LSU.
Time Complexity We use a multitape Turing machine
NP-Complete Problems.
Chapter 34: NP-Completeness
Instructor: Aaron Roth
CSE 311: Foundations of Computing
CSE 105 theory of computation
More Undecidable Problems
MA/CSSE 474 Theory of Computation
CSE 105 theory of computation
RAIK 283 Data Structures & Algorithms
Algorithms CSCI 235, Spring 2019 Lecture 37 The Halting Problem
Presentation transcript:

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 that our program has this bug?

Example while x < 3: x = x - 1 Infinite loop - we get into a loop but for some reason we never get out of it. while x < 3: x = x - 1

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

H 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 P Halts? 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 Assume that what we want to prove is false. Demonstrate that a logical contradiction results. We can conclude that the thing we were trying to prove must be true. Example: There is no largest integer.

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 P Halts? Yes or No

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

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

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

What if B Halts? B B loops H Yes B B No B Halts

What if B Loops Forever? B B loops H Yes B B No B Halts

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

What Went Wrong? There’s nothing wrong with B. 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 Rice’s theorem says that “Any nontrivial property of programs is undecidable.” Thus, we can’t write programs to answer questions about programs.

Intractability I’ve claimed that the traveling salesperson problem is intractable. The best algorithm we’ve seen so far is O(N!). How can we know that there isn’t a better algorithm? Maybe O(N)? The short answer is that we can’t. There is a longer answer that leads us to conclude that TSP is very likely intractable…

P and NP P the set of problems that can be solved in polynomial time by a Turing machine. NP the set of problems that can be solved in polynomial time by a non-deterministic Turing machine. Non-deterministic Turing Machine????

Non-Deterministic Turing Machines Easiest way to describe them is to say that they have the ability to instantly guess an answer, but they need to do the work of verifying that it is correct. Example: Traveling salesperson decision problem. Deterministic TM. Non-deterministic TM.

What’s the Difference? Everyone who is anyone believes that P and NP are different sets. In other words, there are some problems that can be solved in polynomial time using non-determinism, but can’t be solved in polynomial time deterministically.

NP-Completeness It has been proven that the problem SAT is NP-complete. (The SAT problem is to determine whether or not a given boolean expression can ever be true.) If we could solve SAT in polynomial time, then we could solve any other problem in NP in polynomial time. (No time for the proof of this.) It is NP-complete… At least as hard as every other problem in NP.

So What? This means that it is very very likely that SAT does not have a polynomial time algorithm. If it does, then P=NP, which no one believes. What does any of this have to do with TSP?

Reductions We would like to show a polynomial time reduction from SAT to TSP. This involves showing how to convert any instance of the SAT into an instance of the TSP problem that has the same solution. This would mean that any solution to the TSP problem would immediately give us a solution to SAT. We could conclude that the TSP solution is at least as hard as SAT, and by extension, at least has hard as every other problem in NP.

TSP How do we reduce TSP to SAT? It can be done, but it is beyond the scope of this lecture :) It turns out that many problems are NP-Complete.