Algorithms CSCI 235, Spring 2019 Lecture 37 The Halting Problem

Slides:



Advertisements
Similar presentations
Lecture 19. Reduction: More Undecidable problems
Advertisements

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.
THE CHURCH-TURING T H E S I S “ TURING MACHINES” Pages COMPUTABILITY THEORY.
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.
Computability & Complexity. Scenario I can’t write this program because I’m too dumb.
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.
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.
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
Recursively Enumerable and Recursive Languages
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.
Fall 2004COMP 3351 Reducibility. Fall 2004COMP 3352 Problem is reduced to problem If we can solve problem then we can solve problem.
1 Decidability continued. 2 Undecidable Problems Halting Problem: Does machine halt on input ? State-entry Problem: Does machine enter state halt on input.
1 Foundations of Software Design Fall 2002 Marti Hearst Lecture 29: Computability, Turing Machines, Can Computers Think?
Fall 2004COMP 3351 A Universal Turing Machine. Fall 2004COMP 3352 Turing Machines are “hardwired” they execute only one program A limitation of Turing.
Courtesy Costas Busch - RPI1 Reducibility. Courtesy Costas Busch - RPI2 Problem is reduced to problem If we can solve problem then we can solve problem.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 18 Instructor: Paul Beame.
CS21 Decidability and Tractability
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.
Algorithms: Selected Exercises Goals Introduce the concept & basic properties of an algorithm.
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.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 15-1 Mälardalen University 2012.
Great Theoretical Ideas in Computer Science about AWESOME Some Generating Functions Probability Infinity Computability With Alan! (not Turing) Mind-
Halting Problem Introduction to Computing Science and Programming I.
Remaining Discussions from Previous Class Please be precise in your writing –Specially because some of the proofs are written in plain English Queue automata.
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
Complexity & Computability. Limitations of computer science  Major reasons useful calculations cannot be done:  execution time of program is too long.
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.
Recursively Enumerable and Recursive Languages
Donghyun (David) Kim Department of Mathematics and Computer Science North Carolina Central University 1 Chapter 4 Decidability Some slides are in courtesy.
CompSci Today’s Topics Computer Science Noncomputability Upcoming Special Topic: Enabled by Computer -- Decoding the Human Genome Reading Great.
Costas Busch - RPI1 Decidability. Costas Busch - RPI2 Another famous undecidable problem: The halting problem.
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
The Acceptance Problem for TMs
Introduction to Computing Science and Programming I
CIS Automata and Formal Languages – Pei Wang
Recursively Enumerable and Recursive Languages
Unsolvable Problems December 4, 2017.
MCC 2093 Advanced Theoretical Computer Science
LIMITS OF ALGORITHMIC COMPUTATION
Turing Machines Acceptors; Enumerators
Decidability and Enumerability
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.
Discrete Math for CS CMPSC 360 LECTURE 43 Last time: Variance
CSE 311: Foundations of Computing
Formal Languages, Automata and Models of Computation
CS21 Decidability and Tractability
CSE 311: Foundations of Computing
Cpt S 317: Spring 2009 Reading: Chapter 8 & 9
Instructor: Aaron Roth
Automata, Grammars and Languages
More Undecidable Problems
CSE 105 theory of computation
Algorithms CSCI 235, Spring 2019 Lecture 36 P vs
CIS Automata and Formal Languages – Pei Wang
Presentation transcript:

Algorithms CSCI 235, Spring 2019 Lecture 37 The Halting Problem

Existence of Noncomputable Functions Noncomputable functions cannot be solved by any computer program. The set of all possible programs is countable. The set of all possible functions is uncountable. Therefore, if we try to match up each function with a program that computes it, we will always leave some functions out. These left-over functions are noncomputable.

Automatic Program Testing Every program must be extensively tested to make sure that it runs properly under a variety of conditions. Testing can be very time consuming. It would be nice if we could automate the testing. To automate testing, we could write a program that reads in other programs and reports back some information about that program.

Checking for Infinite Loops It would be very useful to write a program to report whether or not a piece of code contains an infinite loop. Examples of infinite loops:

The Halting Problem We would like to write a program that reads in other programs. If the input program halts on all inputs (e.g. it has no infinite loops) our program should output: "Halts on all inputs." Otherwise, our program should output: "Does not halt on all inputs." The problem of writing such a program is called: Turing's Halting Problem

Testing for loops To write our program, we could list known cases of infinite loops and check for them: Case 1: Our language has only while loops and recursion is not allowed. Other cases:

Does it always halt? Testing all possible examples would be difficult. Input(x) while x > 1 do if (x div 2) * 2 = x {e.g. x is even} x <- x div 2 else x <- 3* x + 1 write(x) What happens when x starts as 17? Does this always halt?

Its harder than it sounds Theorem: No finite program can be written that will check other programs and halt in a finite time giving a solution to Turing's halting problem. Proof (by contradiction): Assume that such a program exists Show that this assumption leads to impossible consequences. Therefore the program cannot exist.

Assume halt( ) program exists Assume there exists a program, halt( ), that takes 2 inputs, a program and an input to that program and tests to see whether the the program halts for that input. halt(p, x) ... {Code to compute whether p halts} if ... then return "Halts" else return "Does not halt"

Showing that halt( ) cannot exist In class we will show that the existence of halt( ) leads to a logical contradiction, and therefore it cannot exist. If we can show that halt( ) cannot exist, then the more general "halts on all inputs" cannot exist (because we could construct halt( ) from it).

Other non-computable functions Other non-computable problems: Showing that 2 programs are equivalent (for each input they give the same output Determining whether a given output will occur for some input. Determining the correctness of a program Almost every problem related the the behavior of a program.

The Turing Test In 1950, Alan Turing proposed the following test for determining whether a machine can demonstrate intelligence: A human judge engages in a natural language conversation with one human and one machine, each of which try to appear human. The conversation occurs via text messaging, so the judge cannot see the person/machine with which he is conversing. If the judge cannot reliably tell which is which, then the machine is said to pass the test.