Theory of Computer Science. Theory of Computer Science. D7.1 Introduction. D7.2 Turing Machines as Words. D7.3 Special Halting Problem

Similar documents
Theory of Computer Science

Theory of Computer Science. Theory of Computer Science. D8.1 Other Halting Problem Variants. D8.2 Rice s Theorem

Theory of Computer Science

Theory of Computer Science. Theory of Computer Science. E2.1 P and NP. E2.2 Polynomial Reductions. E2.3 NP-Hardness and NP-Completeness. E2.

Theory of Computer Science

Theory of Computer Science. Theory of Computer Science. E2.1 P and NP. E2.2 Polynomial Reductions. E2.3 NP-Hardness and NP-Completeness. E2.

Theory of Computer Science. D5.1 Introduction. Theory of Computer Science. D5.2 Primitive Recursion vs. LOOP. D5.3 µ-recursion vs.

Introduction to Turing Machines. Reading: Chapters 8 & 9

Limits of Computability

Computational Models Lecture 8 1

Computational Models Lecture 8 1

CPSC 421: Tutorial #1

Computational Models Lecture 8 1

Theory of Computer Science

Theory of Computer Science. Theory of Computer Science. E1.1 Motivation. E1.2 How to Measure Runtime? E1.3 Decision Problems. E1.

Decision Problems with TM s. Lecture 31: Halting Problem. Universe of discourse. Semi-decidable. Look at following sets: CSCI 81 Spring, 2012

Introduction to Turing Machines

There are two main techniques for showing that problems are undecidable: diagonalization and reduction

Theory of Computer Science. Theory of Computer Science. E3.1 Overview. E3.2 Cook-Levin Theorem E3.3 3SAT. E3.4 Summary. Further Reading (German)

Decidability: Church-Turing Thesis

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

On Rice s theorem. Hans Hüttel. October 2001

Theory of Computer Science

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

CSE 105 THEORY OF COMPUTATION

Theory of Computation

Further discussion of Turing machines

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

CSE 105 THEORY OF COMPUTATION

1 Showing Recognizability

CSCE 551: Chin-Tser Huang. University of South Carolina

Functions on languages:

Chapter 6: Turing Machines

Part I: Definitions and Properties

Lecture 12: Mapping Reductions

ACS2: Decidability Decidability

Turing Machines. Wolfgang Schreiner

CS20a: Turing Machines (Oct 29, 2002)

(a) Definition of TMs. First Problem of URMs

Turing Machines (TM) Deterministic Turing Machine (DTM) Nondeterministic Turing Machine (NDTM)

Computability and Complexity

16.1 Countability. CS125 Lecture 16 Fall 2014

Computable Functions

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

6.045J/18.400J: Automata, Computability and Complexity. Quiz 2. March 30, Please write your name in the upper corner of each page.

CSE 105 THEORY OF COMPUTATION

Non-emptiness Testing for TMs

1 Acceptance, Rejection, and I/O for Turing Machines

TURING MAHINES

Mapping Reducibility. Human-aware Robotics. 2017/11/16 Chapter 5.3 in Sipser Ø Announcement:

CS20a: Turing Machines (Oct 29, 2002)

Decidability. Linz 6 th, Chapter 12: Limits of Algorithmic Computation, page 309ff

Undecidability. Andreas Klappenecker. [based on slides by Prof. Welch]

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Section 14.1 Computability then else

Undecidable Problems and Reducibility

Turing Machines Part III

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

More About Turing Machines. Programming Tricks Restrictions Extensions Closure Properties

The Turing Machine. Computability. The Church-Turing Thesis (1936) Theory Hall of Fame. Theory Hall of Fame. Undecidability

CMPT 710/407 - Complexity Theory Lecture 4: Complexity Classes, Completeness, Linear Speedup, and Hierarchy Theorems

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

Decidable Languages - relationship with other classes.

The Unsolvability of the Halting Problem. Chapter 19

CSE 105 THEORY OF COMPUTATION

CS 125 Section #10 (Un)decidability and Probability November 1, 2016

Theory of Computer Science. Theory of Computer Science. E4.1 Overview E4.2 3SAT. E4.3 Graph Problems. E4.4 Summary.

Decidability and Undecidability

Turing Machine Recap

1 The decision problem for First order logic

CSE 105 THEORY OF COMPUTATION

DM17. Beregnelighed. Jacob Aae Mikkelsen

Reducability. Sipser, pages

CS154, Lecture 10: Rice s Theorem, Oracle Machines

Turing Machines. Lecture 8

Decidability (What, stuff is unsolvable?)

Theory of Computation

Turing s thesis: (1930) Any computation carried out by mechanical means can be performed by a Turing Machine

Computation Histories

Opleiding Informatica

CSE 105 THEORY OF COMPUTATION

} Some languages are Turing-decidable A Turing Machine will halt on all inputs (either accepting or rejecting). No infinite loops.

Theory of Computer Science. Theory of Computer Science. E5.1 Routing Problems. E5.2 Packing Problems. E5.3 Conclusion.

UNIT-VIII COMPUTABILITY THEORY

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 8 Nancy Lynch

CS 7220 Computational Complexity and Algorithm Analysis

CS5371 Theory of Computation. Lecture 14: Computability V (Prove by Reduction)

TAKE-HOME: OUT 02/21 NOON, DUE 02/25 NOON

Foundations of Informatics: a Bridging Course

CSE 105 Theory of Computation

CpSc 421 Homework 9 Solution

MA/CSSE 474 Theory of Computation

Equivalent Variations of Turing Machines

Turing Machines. The Language Hierarchy. Context-Free Languages. Regular Languages. Courtesy Costas Busch - RPI 1

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

Theory of Computation

Computability Crib Sheet

Computational Models Lecture 9, Spring 2009

The Church-Turing Thesis

Transcription:

Theory of Computer Science May 2, 2018 D7. Halting Problem and Reductions Theory of Computer Science D7. Halting Problem and Reductions Gabriele Röger University of Basel May 2, 2018 D7.1 Introduction D7.2 Turing Machines as Words D7.3 Special Halting Problem D7.4 Reprise: Type-0 Languages D7.5 Reductions Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 1 / 32 Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 2 / 32 Overview: Computability Theory Further Reading (German) Turing-Computability Imperative Models of Computation LOOP- and WHILE- Computability GOTO-Computability Literature for this Chapter (German) Computability Functional Models of Computation Undecidable Problems Primitive and µ-recursion (Semi-)Decidability Halting Problem Theoretische Informatik kurz gefasst by Uwe Schöning (5th edition) Chapter 2.6 Reductions Rice s Theorem Other Problems Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 3 / 32 Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 4 / 32

Further Reading (English) D7. Halting Problem and Reductions Introduction Literature for this Chapter (English) Introduction to the Theory of Computation by Michael Sipser (3rd edition) Chapters 4.2 and 5.1 D7.1 Introduction Notes: Sipser does not cover all topics we do. His definitions differ from ours. Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 5 / 32 Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 6 / 32 D7. Halting Problem and Reductions Introduction Undecidable Problems We now know many characterizations of semi-decidability and decidability. What s missing is a concrete example for an undecidable (= not decidable) problem. Do undecidable problems even exist? Yes! Counting argument: there are (for a fixed Σ) as many decision algorithms (e. g., Turing machines) as numbers in N 0 but as many languages as numbers in R. Since N 0 cannot be surjectively mapped to R, languages with no decision algorithm exist. But this argument does not give us a concrete undecidable problem. main goal of this chapter D7.2 Turing Machines as Words Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 7 / 32 Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 8 / 32

Turing Machines as Inputs Encoding a Turing Machine as a Word (1) The first undecidable problems that we will get to know have Turing machines as their input. programs that have programs as input : cf. compilers, interpreters, virtual machines, etc. We have to think about how we can encode arbitrary Turing machines as words over a fixed alphabet. We use the binary alphabet Σ = {0, 1}. As an intermediate step we first encode over the alphabet Σ = {0, 1, #}. Step 1: encode a Turing machine as a word over {0, 1, #} Reminder: Turing machine M = Q, Σ, Γ, δ, q 0,, E Idea: input alphabet Σ should always be {0, 1} enumerate states in Q and symbols in Γ and consider them as numbers 0, 1, 2,... blank symbol always receives number 2 start state always receives number 0 Then it is sufficient to only encode δ explicitly: Q: all states mentioned in the encoding of δ E: all states that never occur on a left-hand side of a δ-rule Γ = {0, 1,, a 3, a 4,..., a k }, where k is the largest symbol number mentioned in the δ-rules Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 9 / 32 Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 10 / 32 Encoding a Turing Machine as a Word (2) Encoding a Turing Machine as a Word (3) encode the rules: Let δ(q i, a j ) = q i, a j, D be a rule in δ, where the indices i, i, j, j correspond to the enumeration of states/symbols and D {L, R, N}. encode this rule as w i,j,i,j,d = ##bin(i)#bin(j)#bin(i )#bin(j )#bin(m), 0 if D = L where m = 1 if D = R 2 if D = N For every rule in δ, we obtain one such word. All of these words in sequence (in arbitrary order) encode the Turing machine. Step 2: transform into word over {0, 1} with mapping 0 00 1 01 # 11 Turing machine can be reconstructed from its encoding. How? Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 11 / 32 Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 12 / 32

Encoding a Turing Machine as a Word (4) Turing Machine Encoded by a Word Example (step 1) δ(q 2, a 3 ) = q 0, a 2, N becomes ##10#11#0#10#10 δ(q 1, a 1 ) = q 3, a 0, L becomes ##1#1#11#0#0 Example (step 2) ##10#11#0#10#10##1#1#11#0#0 111101001101011100110100110100111101110111010111001100 Note: We can also consider the encoded word (uniquely; why?) as a number that enumerates this TM. This is not important for the halting problem but in other contexts where we operate on numbers instead of words. goal: function that maps any word in {0, 1} to a Turing machine problem: not all words in {0, 1} are encodings of a Turing machine solution: Let M be an arbitrary fixed deterministic Turing machine (for example one that always immediately stops). Then: Definition (Turing Machine Encoded by a Word) For all w {0, 1} : { M if w is the encoding of some DTM M M w = M otherwise Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 13 / 32 Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 14 / 32 D7. Halting Problem and Reductions Special Halting Problem D7. Halting Problem and Reductions Special Halting Problem Special Halting Problem Our preparations are now done and we can define: D7.3 Special Halting Problem Definition (Special Halting Problem) The special halting problem or self-application problem is the language K = {w {0, 1} M w started on w terminates}. German: spezielles Halteproblem, Selbstanwendbarkeitsproblem Note: word w plays two roles as encoding of the TM and as input for encoded machine Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 15 / 32 Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 16 / 32

D7. Halting Problem and Reductions Special Halting Problem Semi-Decidability of the Special Halting Problem D7. Halting Problem and Reductions Special Halting Problem Undecidability of the Special Halting Problem (1) Theorem (Semi-Decidability of the Special Halting Problem) The special halting problem is semi-decidable. Proof. We construct an interpreter for DTMs that receives the encoding of a DTM as input w and simulates its computation on input w. If the simulated DTM stops, the interpreter returns 1. Otherwise it does not return. This interpreter computes χ K. Note: TMs simulating arbitrary TMs are called universal TMs. German: universelle Turingmaschine Theorem (Undecidability of the Special Halting Problem) The special halting problem is undecidable. Proof. Proof by contradiction: we assume that the special halting problem K were decidable and derive a contradiction. So assume K is decidable. Then χ K is computable (why?). Let M be a Turing machine that computes χ K, i. e., given a word w writes 1 or 0 onto the tape (depending on whether w K) and then stops.... Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 17 / 32 Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 18 / 32 D7. Halting Problem and Reductions Special Halting Problem Undecidability of the Special Halting Problem (2) D7. Halting Problem and Reductions Reprise: Type-0 Languages Proof (continued). Construct a new machine M as follows: 1 Execute M on the input w. 2 If the tape content is 0: stop. 3 Otherwise: enter an endless loop. D7.4 Reprise: Type-0 Languages Let w be the encoding of M. How will M behave on input w? M run on w stops iff M run on w outputs 0 iff χ K (w ) = 0 iff w / K iff M w run on w does not stop iff M run on w does not stop Contradiction! This proves the theorem. Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 19 / 32 Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 20 / 32

D7. Halting Problem and Reductions Reprise: Type-0 Languages Back to Chapter C8: Closure Properties D7. Halting Problem and Reductions Reprise: Type-0 Languages Back to Chapter C8: Decidability Intersection Union Complement Product Star Type 3 Yes Yes Yes Yes Yes Type 2 No Yes No Yes Yes Type 1 Yes (1) Yes Yes (1) Yes Yes Type 0 Yes (1) Yes No (2) Yes Yes Proofs? (1) without proof (2) proofs in later chapters (part D) Word problem Emptiness problem Equivalence problem Intersection problem Type 3 Yes Yes Yes Yes Type 2 Yes Yes No No Type 1 Yes No (1) No No Type 0 No (2) No (2) No (2) No (2) (1) without proof (2) proof in later chapters (part D) Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 21 / 32 Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 22 / 32 D7. Halting Problem and Reductions Reprise: Type-0 Languages Answers to Old Questions Closure properties: K is semi-decidable (and thus type 0) but not decidable. K is not semi-decidable, thus not type 0. Type-0 languages are not closed under complement. D7.5 Reductions Decidability: K is type 0 but not decidable. word problem for type-0 languages not decidable emptiness, equivalence, intersection problem: later in exercises (We are still missing some important results for this.) Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 23 / 32 Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 24 / 32

Overview: Computability Theory What We Achieved So Far: Discussion Turing-Computability Computability Imperative Models of Computation Functional Models of Computation Undecidable Problems LOOP- and WHILE- Computability GOTO-Computability Primitive and µ-recursion (Semi-)Decidability Halting Problem Reductions We now know a concrete undecidable problem. But the problem is rather artificial: how often do we want to apply a program to itself? We will see that we can derive further (more useful) undecidability results from the undecidability of the special halting problem. The central notion for this is reducing a new problem to an already known problem. Rice s Theorem Other Problems Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 25 / 32 Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 26 / 32 Reductions: Definition Reduction Property Definition (Reduction) Let A Σ and B Γ be languages, and let f : Σ Γ be a total and computable function such that for all x Σ : x A if and only if f (x) B. Then we say that A can be reduced to B (in symbols: A B), and f is called reduction from A to B. German: A ist auf B reduzierbar, Reduktion von A auf B Theorem (Reductions vs. Semi-Decidability/Decidability) Let A and B be languages with A B. Then: 1 If B is decidable, then A is decidable. 2 If B is semi-decidable, then A is semi-decidable. 3 If A is not decidable, then B is not decidable. 4 If A is not semi-decidable, then B is not semi-decidable. In the following, we use 3. to show undecidability for further problems. Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 27 / 32 Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 28 / 32

Reduction Property: Proof Reductions are Preorders Proof. for 1.: The following algorithm computes χ A (x) given input x: y := f (x) result := χ B (y) RETURN result for 2.: identical to (1), but use χ B (instead of χ B) to compute χ A (instead of χ A) for 3./4.: contrapositions of 1./2. logically equivalent Theorem (Reductions are Preorders) The relation is a preorder: 1 For all languages A: A A (reflexivity) 2 For all languages A, B, C: If A B and B C, then A C (transitivity) German: schwache Halbordnung/Quasiordnung, Reflexivität, Transitivität Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 29 / 32 Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 30 / 32 Reductions are Preorders: Proof D7. Halting Problem and Reductions Summary Summary Proof. for 1.: The function f (x) = x is a reduction from A to A because it is total and computable and x A iff f (x) A. for 2.: exercises The special halting problem (self-application problem) is undecidable. However, it is semi-decidable. important concept in this chapter: Turing machines represented as words Turing machines taking Turing machines as their input reductions: embedding a problem as a special case of another problem important method for proving undecidability: reduce from a known undecidable problem to a new problem Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 31 / 32 Gabriele Röger (University of Basel) Theory of Computer Science May 2, 2018 32 / 32