Fundamentals of Informatics Lecture 12 The Halting Problem Bas Luttik.

Slides:



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

Chapter 11: Models of Computation
CS211 Problems: unsolvable, unfeasible and unsolved Topic 2: Halting problem.
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]
Nathan Brunelle Department of Computer Science University of Virginia Theory of Computation CS3102 – Spring 2014 A tale.
1 Section 14.1 Computability Some problems cannot be solved by any machine/algorithm. To prove such statements we need to effectively describe all possible.
1 Introduction to Computability Theory Lecture15: Reductions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture13: Mapping Reductions Prof. Amos Israeli.
Prof. Busch - LSU1 Decidable Languages. Prof. Busch - LSU2 Recall that: A language is Turing-Acceptable if there is a Turing machine that accepts Also.
Undecidability. Church-Turing Thesis n A Turing machine that halts on all inputs is the precise formal notion corresponding to the intuitive notion of.
CPSC 411, Fall 2008: Set 12 1 CPSC 411 Design and Analysis of Algorithms Set 12: Undecidability Prof. Jennifer Welch Fall 2008.
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
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]
CHAPTER 4 Decidability Contents Decidable Languages
1 Foundations of Software Design Fall 2002 Marti Hearst Lecture 29: Computability, Turing Machines, Can Computers Think?
Fall 2005Costas Busch - RPI1 Recursively Enumerable and Recursive Languages.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 18 Instructor: Paul Beame.
January 28, 2015CS21 Lecture 101 CS21 Decidability and Tractability Lecture 10 January 28, 2015.
Turing Machines CS 105: Introduction to Computer Science.
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.
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.
Cs3102: Theory of Computation Class 18: Proving Undecidability Spring 2010 University of Virginia David Evans.
1 CO Games Development 2 Week 21 Turing Machines & Computability Gareth Bellaby.
MA/CSSE 474 Theory of Computation More Reduction Examples Non-SD Reductions.
Introduction to CS Theory Lecture 15 –Turing Machines Piotr Faliszewski
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 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.
Halting Problem Introduction to Computing Science and Programming I.
©Brooks/Cole, 2003 Chapter 17 Theory of Computation.
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)
 2005 SDU Lecture13 Reducibility — A methodology for proving un- decidability.
Complexity & Computability. Limitations of computer science  Major reasons useful calculations cannot be done:  execution time of program is too long.
Fundamentals of Informatics Lecture 3 Turing Machines Bas Luttik.
Fundamentals of Informatics Lecture 13 Reduction Bas Luttik.
Fundamentals of Informatics Lecture 4 From Turing Machines to Algorithms Bas Luttik.
CSE 311 Foundations of Computing I Lecture 28 Computability: Other Undecidable Problems Autumn 2011 CSE 3111.
Capabilities of computing systems Numeric and symbolic Computations A look at Computability theory Turing Machines.
Lecture 17 Undecidability Topics:  TM variations  Undecidability June 25, 2015 CSCE 355 Foundations of Computation.
Overview of the theory of computation Episode 3 0 Turing machines The traditional concepts of computability, decidability and recursive enumerability.
Lecture 24UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 24.
Umans Complexity Theory Lectures Lecture 1b: Turing Machines & Halting Problem.
Chapter 12 Theory of Computation Introduction to CS 1 st Semester, 2014 Sanghyun Park.
1 Chapter 9 Undecidability  Turing Machines Coded as Binary Strings  Universal Turing machine  Diagonalizing over Turing Machines  Problems as Languages.
Turing Machines Sections 17.6 – The Universal Turing Machine Problem: All our machines so far are hardwired. ENIAC
CompSci Today’s Topics Computer Science Noncomputability Upcoming Special Topic: Enabled by Computer -- Decoding the Human Genome Reading Great.
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:
MA/CSSE 474 Theory of Computation Universal Turing Machine Church-Turing Thesis (Winter 2016, these slides were also used for Day 33)
Decidability.
Chapters 11 and 12 Decision Problems and Undecidability.
The Acceptance Problem for TMs
CSE 311 Foundations of Computing I
CSE 105 theory of computation
LIMITS OF ALGORITHMIC COMPUTATION
Turing Machines Acceptors; Enumerators
Chapter 9 TURING MACHINES.
Busch Complexity Lectures: Undecidable Problems (unsolvable problems)
Decidable Languages Costas Busch - LSU.
Decidability Turing Machines Coded as Binary Strings
Decidability Turing Machines Coded as Binary Strings
Halting Problem.
Presentation transcript:

Fundamentals of Informatics Lecture 12 The Halting Problem Bas Luttik

Are computers omnipotent? A quote from TIME magazine (1984): “Put the right kind of software into a computer, and it will do whatever you want it to. There may be limits on what you can do with the machines themselves, but there are no limits on what you can do with software”. Primary goal of the day: to convince you that the above statement is very wrong! Computers cannot be programmed to do anything you like, and this is fundamental! Secondary goal of the day: to convince you that the world will always need smart and well-trained computer scientists.

Algorithms should be provably correct! A complete description of an algorithm consists of three parts: 1. the algorithm 2. a proof of the algorithm’s correctness 3. a derivation of the algorithm’s running time Algorithm verifier 1.Algorithmic problem P 2.Algorithm A 1.Algorithmic problem P 2.Algorithm A Yes: algorithm A correctly solves problem P No: algorithm A does not correctly solve problem P

Algorithms should provably terminate! To prove correctness (with a loop invariant) we need to show three things: 1. initialization 2. maintenance 3. termination: the loop terminates, and when it does the invariant helps to show that the algorithm is correct. Termination verifier Algorithm A Yes: A terminates on every valid input No: A does not terminate on every valid input

The termination problem Will the following loops terminate if the initial value of x is positive?  while x < 15 do set x to x+1  Yes (irrespective of the initial value of x)  while x ≠ 1 do set x to x-2  Yes if the initial value is an odd positive number; No otherwise.  while x ≠ 1 do if x is even then set x to x/2 else set x to 3x+1  Nobody knows for sure (yet)!

Solving the termination problem How would you solve the termination problem? Naïve (and incorrect!) idea for building a termination verifier: 1.Write algorithm that can simulate any other algorithm. 2.To find out whether algorithm A terminates on input I, simulate the execution of A on I. 3.If the simulation terminates, then say yes. 4.If the simulation does not terminate, then say no. This will not work: if the simulation does not terminate, the termination verifier will never report anything! We shall argue in this lecture that it is fundamentally impossible! First, however, we move the problem to the well-delineated setting of Turing machines.

To refresh your memory A Turing machine consists of 1. A finite collection of states (with a special initial state and some halting states) 2. A finite alphabet of tape symbols 3. A transition table determining for every combination of a non-halting state and scanned tape symbol:  a new tape symbol,  a direction of movement, and  a next current state. There exist so-called universal TMs capable of simulating the behavior of any other TM on the basis of an on-tape description. “Everything that can be computed with a computer (now and in the future), can be computed by some Turing machine”

Constructing Turing machines Exercises 1. Construct a Turing machine L that only has a terminating computation on input sequence 0; the terminating computation should result in output sequence 0. On every other input sequence the computation of L does not terminate. (Assume that input sequences consist of 0s and 1s only). 2. Construct a Turing machine D that duplicates the input sequence separating the two copies with the symbol #. (You may assume that the input sequence consists of 0s and 1s only.) 3. Construct a Turing machine L;D that first runs L and then runs D on its input sequence. It is straightforward to ‘compose’ Turing machines (sequentially).

T outputs 1 if M halts on s, and 0 if M does not halt s yes no input sequence s for M description of M The Halting Problem for TMs Given a Turing machine M and an input sequence s, determine whether M’s computation on s will eventually terminate. T T T reports “yes” if M halts on s, and “no” if M does not halt s #

The exTerminator T T description of M input sequence s for M description of M D D L L 0/1 0 0 go into infinite loop unless input sequence is 0 X Note: If T exists, then X exists too and it must have a description!

A termination issue If X terminates on its own description, then T reports 1. So L goes into an infinite loop, and thus X does not terminate. Contradiction! If X does not terminate on its own description, then T reports 0. So L terminates, and thus X terminates. Contradiction! Both possible answers lead to a logical contradiction. Something must be wrong; it can only be our assumption that T exists. Conclusion: there does not exist a Turing machine that can determine for every arbitrary TM M and input s whether M terminates on s. Does X terminate on its own description?

Halting problem explained For a nice animation of the proof of the unsolvability of the halting problem, see:

Questions  Can’t we adapt the idea of universal Turing machines to solve the halting problem?  It is easy to characterize the inputs on which some particular Turing machine (e.g., the Loop-machine or the Duplicator) will terminate. Why does this not contradict the unsolvability of the halting problem?

Decision problems Solvable Unsolvable A decision problem is a set of related yes/no questions, usually infinitely many. For instance, the halting problem (“given TM M and input s, decide whether M terminates on s”) consists of questions: Does M 0 terminate on s 0 ? Does M 0 terminate on s 1 ? Etc. Does M 1 terminate on s 0 ? Etc. there is an algorithm* that correctly answers all the questions of a decision problem there is no algorithm* that correctly answers all the questions of a decision problem *By the Church-Turing thesis, we can replace algorithm by Turing machine.

More decision problems  Given a 10-digit number, is it a valid credit card number?  solvable!  Given a (finite) graph G, vertices v and u in G, and integer k, is there a path in G of length less than k?  solvable! A decision problem consisting of finitely many questions only is solvable!  Does the algorithm while x ≠ 1 do if x is even then set x to x/2 else set x to 3x+1 halt for every x?  solvable!

Tiling a room Tile types: Is it possible to tile every room of arbitrary size with these tile types?

Tiling a room Is it possible to tile every room of arbitrary size with these tile types? Tile types:

The Tiling Problem Given a set of tile types, decide whether every room can be tiled using tiles of that type. The Tiling Problem is unsolvable! So: there is no a computer program (and there will never be!) that decides whether arbitrary finite sets of tile types can tile rooms any size.

The world of computational problems Solvable Unsolvable Given a graph G, vertices v and u in G, and integer k, is there a path in G of length less than k? Given a set of tile types, can every room be tiled? Given a 10-digit number, is it a valid credit card number? Given a computer program and a set of requirements, does the program satisfy the requirements?

Algorithms should provably terminate! To prove correctness (with a loop invariant) we need to show three things: 1. initialization 2. maintenance 3. termination: when the loop terminates, the invariant (usually along with the reason that the loop terminated) gives useful property that helps show that the algorithm is correct. Termination verifier 1.Algorithmic problem P 2.Algorithm A 1.Algorithmic problem P 2.Algorithm A Yes: A terminates on every valid input No: A does not terminate on every valid input A termination verifier (or, in fact, any program that verifies anything interesting about algorithms) cannot be built! Not now, not tomorrow, not in the far future! Not with more powerful hardware, not with more sophisticated software! It is fundamentally impossible! A termination verifier (or, in fact, any program that verifies anything interesting about algorithms) cannot be built! Not now, not tomorrow, not in the far future! Not with more powerful hardware, not with more sophisticated software! It is fundamentally impossible!

Material Chapter 59 (see reader) presents a proof of the unsolvability of the Halting problem. Chapter 66 (see reader) sheds more light on the Church-Turing thesis. Deadline: January 15, 2016

Recommended reading David Harel: Computers LTD (What they really can’t do) Oxford University Press, 2003.