TURING MAHINES

Similar documents
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

More Turing Machines. CS154 Chris Pollett Mar 15, 2006.

Introduction to Turing Machines. Reading: Chapters 8 & 9

CSCC63 Worksheet Turing Machines

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

CS21 Decidability and Tractability

ACS2: Decidability Decidability

1 Showing Recognizability

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

Undecidability. We are not so much concerned if you are slow as when you come to a halt. (Chinese Proverb)

Decidability (What, stuff is unsolvable?)

Computability Theory. CS215, Lecture 6,

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

Computable Functions

CSCE 551 Final Exam, Spring 2004 Answer Key

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

Chapter 3: The Church-Turing Thesis

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

Turing Machines A Turing Machine is a 7-tuple, (Q, Σ, Γ, δ, q0, qaccept, qreject), where Q, Σ, Γ are all finite

CS20a: Turing Machines (Oct 29, 2002)

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018

CS5371 Theory of Computation. Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)

CS154, Lecture 10: Rice s Theorem, Oracle Machines

V Honors Theory of Computation

Theory of Computation (IX) Yijia Chen Fudan University

The Church-Turing Thesis

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

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2016, face-to-face day section Prof. Marvin K. Nakayama

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Most General computer?

Equivalence of TMs and Multitape TMs. Theorem 3.13 and Corollary 3.15 By: Joseph Lauman

Finish K-Complexity, Start Time Complexity

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

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2018, face-to-face day section Prof. Marvin K. Nakayama

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CPSC 421: Tutorial #1

Lecture 13: Foundations of Math and Kolmogorov Complexity

Decidability (intro.)

CSCI3390-Lecture 6: An Undecidable Problem

Part I: Definitions and Properties

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Lecture Notes: The Halting Problem; Reductions

Theory of Computation p.1/?? Theory of Computation p.2/?? We develop examples of languages that are decidable

What languages are Turing-decidable? What languages are not Turing-decidable? Is there a language that isn t even Turingrecognizable?

CS151 Complexity Theory. Lecture 1 April 3, 2017

Turing Machines (TM) The Turing machine is the ultimate model of computation.

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

Intro to Theory of Computation

Computational Models Lecture 8 1

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

Decidable Languages - relationship with other classes.

Reducability. Sipser, pages

Decidability: Church-Turing Thesis

acs-07: Decidability Decidability Andreas Karwath und Malte Helmert Informatik Theorie II (A) WS2009/10

Computational Models Lecture 8 1

16.1 Countability. CS125 Lecture 16 Fall 2014

Turing Machine Recap

Decidability. Human-aware Robotics. 2017/10/31 Chapter 4.1 in Sipser Ø Announcement:

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) October,

Turing Machines, diagonalization, the halting problem, reducibility

Turing Machines. Lecture 8

Griffith University 3130CIT Theory of Computation (Based on slides by Harald Søndergaard of The University of Melbourne) Turing Machines 9-0

Theory of Computation

COMP/MATH 300 Topics for Spring 2017 June 5, Review and Regular Languages

CS4026 Formal Models of Computation

Turing machines and linear bounded automata

Undecidability COMS Ashley Montanaro 4 April Department of Computer Science, University of Bristol Bristol, UK

CpSc 421 Homework 9 Solution

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

Turing machine recap. Universal Turing Machines and Undecidability. Alphabet size doesn t matter. Robustness of TM

Undecidable Problems and Reducibility

CSE 105 THEORY OF COMPUTATION

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

Computational Models Lecture 8 1

Turing machines and linear bounded automata

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

Computation Histories

Turing Machines. 22c:135 Theory of Computation. Tape of a Turing Machine (TM) TM versus FA, PDA

Theory of Computation

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

Chap. 4,5 Review. Algorithms created in proofs from prior chapters

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

Turing machines and linear bounded automata

CS20a: Turing Machines (Oct 29, 2002)

Final exam study sheet for CS3719 Turing machines and decidability.

Computability and Complexity

The Unsolvability of the Halting Problem. Chapter 19

CS 154 NOTES MOOR XU NOTES FROM A COURSE BY LUCA TREVISAN AND RYAN WILLIAMS

Computability and Complexity

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

Turing Machine Variants

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

DM17. Beregnelighed. Jacob Aae Mikkelsen

The Turing machine model of computation

Introduction to Languages and Computation

4.2 The Halting Problem

Transcription:

15-453 TURING MAHINES

TURING MACHINE FINITE STATE q 10 CONTROL AI N P U T INFINITE TAPE

read write move 0 0, R, R q accept, R q reject 0 0, R 0 0, R, L

read write move 0 0, R, R q accept, R 0 0, R 0 0, R, L

Definition: A Turing Machine is a 7-tuple T = (Q, Σ, Γ, δ, q 0, q accept, q reject ), where: Q is a finite set of states Σ is the input alphabet, where Σ Γ is the tape alphabet, where Γ and Σ Γ δ : Q Γ Q Γ {L, R} q 0 Q is the start state q accept Q is the accept state q reject Q is the reject state, and q reject q accept

CONFIGURATIONS 11010q 7 00110 corresponds to: q 7 1 1 0 1 0 0 0 1 1 0

A Turing Machine M accepts input w if there is a sequence of configurations C 1,, C k such that 1. C 1 is a start configuration of M on input w, ie C 1 is q 0 w 2. each C i yields C i+1, ie M can legally go from C i to C i+1 in a single step ua q i bv yields u q j acv if δ (q i, b) = (q j, c, L) ua qi bv yields uac q j v if δ (q i, b) = (q j, c, R)

A Turing Machine M accepts input w if there is a sequence of configurations C 1,, C k such that 1. C 1 is a start configuration of M on input w, ie C 1 is q 0 w 2. each C i yields C i+1, ie M can legally go from C i to C i+1 in a single step 3. C k is an accepting configuration, ie the state of the configuration is q accept

A Turing Machine M rejects input w if there is a sequence of configurations C 1,, C k such that 1. C 1 is a start configuration of M on input w, ie C 1 is q 0 w 2. each C i yields C i+1, ie M can legally go from C i to C i+1 in a single step 3. C k is a rejecting configuration, ie the state of the configuration is q reject

A TM decides a language if it accepts all strings in the language and rejects all strings not in the language A language is called decidable or recursive if some TM decides it

2 { 0 n n 0 } is decidable. PSEUDOCODE: 1. Sweep from left to right, cross out every other 0 2. If in stage 1, the tape had only one 0, accept 3. If in stage 1, the tape had an odd number of 0 s, reject 4. Move the head back to the first input symbol. 5. Go to stage 1.

2 { 0 n n 0 } x x, L 0 0, L q 2 x x, R, R, L x x, R q 0 q 1 0, R 0 x, R q 3 x x, R, R, R 0 x, R 0 0, R q reject q accept q 4, R x x, R

2 { 0 n n 0 } x x, R, R q 2 x x, L 0 0, L q 0 0000 q 1 000 xq 3 00, L x0q 4 0 x x, R q 0 q 1 0, R x x, R, R, R q reject q accept 0 x, R 0 x, R x0xq 3 q 3 x0q 2 x xq 2 0x q 4 0 0, R q 2 x0x q 2 x0x, R x x, R

A TM decides a language if it accepts all strings in the language and rejects all strings not in the language A language is called decidable or recursive if some TM decides it Theorem: L decidable <-> L decidable Proof: L has a machine M that accepts or rejects on all inputs. Define M to be M with accept and reject states swapped. M decides L.

Theorem: A,B decidable > A union B decidable Proof: Let M be a TM for A. Let M be a TM for B. Make a Union machine implementing the following pseudo-code: (Intuition: use the even squares to simulate M, and the odd squares to simulate M ) Double input size by writing each input symbol twice starting with q_0 symbols. Use cross product construction to allow the finite state control to remember state of each TM. Move pebble around to always be one square left of position of head in M or M, respectively. Odd phase: Bring head back to start symbol of tape, scan odd squares to find tape head location at pebble accept if either M or M accept.

A TM recognizes a language if it accepts all and only those strings in the language A language is called Turing-recognizable or recursively enumerable, (or r.e. or semidecidable) if some TM recognizes it A TM decides a language if it accepts all strings in the language and rejects all strings not in the language A language is called decidable or recursive if some TM decides it

A TM recognizes a language if it accepts all and only those strings in the language A language is called Turing-recognizable or recursively enumerable, (or r.e. or semidecidable) if some TM recognizes it FALSE: L r.e. <-> L r.e. Proof: L has a machine M that accepts or rejects on all inputs. Define M to be M with accept and reject states swapped. M decides L.

w Σ* w Σ* TM w L? TM w L? yes no yes no accept reject accept reject or no output L is decidable (recursive) L is semi-decidable (recursively enumerable, Turing-recognizable)

A language is called Turing-recognizable or recursively enumerable (r.e.) or semidecidable if some TM recognizes it A language is called decidable or recursive if some TM decides it r.e. languages recursive languages Theorem: If A and A are r.e. then A is recursive

Theorem: If A and A are r.e. then A is recursive Suppose M accepts A. M accepts A decidable Use Odd squares/ Even squares simulation of M and M. If x is accepted by the even squares reject it/ accepted by the odd squares then accept x.

TURING MACHINE with WRITE ONLY output tape. FINITE STATE CONTROL Outputs a sequence of strings separated by hash marks. Allows for a well defined infinite sequence of strings in the limit. The machine is said to enumerate the sequence of strings occurring on the

Lex-order has an enumerator strings of length 1, the length 2,. Pairs of binary strings have a lex-order enumerator for each n>0 list all pairs of strings a,b as #a#b# where total length of a and b is n. Let BINARY(w) = pair of binary strings be any fixed way of encoding a pair of binary strings with a single binary string

TURING MACHINE with WRITE ONLY output tape. FINITE STATE CONTROL Outputs a sequence of strings separated by hash marks. Allows for a well defined infinite sequence of strings in the limit. The machine is said to enumerate the set of strings occurring on the tape.

From every TM M accepting A. there is a TM M outputting A. For n = 0 to forever do { {Do n parallel simulations of M for n steps for the first n inputs} M(0). M(1), M(2), M(3).. } Odd/Even trick becomes modulo n trick. If M(x) accepts then output(x#)

From every TM M outputting A. there is a TM M accepting A. M (X) run M, accept if X output on tape.

Let Z + = {1,2,3,4 }. There exists a bijection between Z + and Z + Z + (or Q + ) (1,1) (1,2) (1,3) (1,4) (1,5) (2,1) (2,2) (2,3) (2,4) (2,5) (3,1) (3,2) (3,3) (3,4) (3,5) (4,1) (4,2) (4,3) (4,4) (4,5) (5,1) (5,2) (5,3) (5,4) (5,5)

w Σ* w Σ* TM w L? TM w L? yes no yes no accept reject accept reject or no output L is decidable (recursive) L is semi-decidable (recursively enumerable, Turing-recognizable)

MULTITAPE TURING MACHINES FINITE STATE CONTROL δ : Q Γ k Q Γ k {L,R} k

Theorem: Every Multitape Turing Machine can be transformed into a single tape Turing Machine FINITE STATE CONTROL 1 0 0 FINITE STATE CONTROL. 1 0 0 #. #. #

Theorem: Every Multitape Turing Machine can be transformed into a single tape Turing Machine FINITE STATE CONTROL 1 0 0 FINITE STATE CONTROL 1. 0 0 #. #. #

We can encode a TM as a string of 0s and 1s n states start state reject state 0 n 10 m 10 k 10 s 10 t 10 r 10 u 1 m tape symbols (first k are input symbols) accept state blank symbol ( (p, a), (q, b, L) ) = 0 p 10 a 10 q 10 b 10 ( (p, a), (q, b, R) ) = 0 p 10 a 10 q 10 b 11

THE CHURCH-TURING THESIS Intuitive Notion of Algorithms EQUALS Turing Machines

THE ACCEPTANCE PROBLEM A TM = { (M, w) M is a TM that accepts string w } Theorem: A TM is semi-decidable (r.e.) but NOT decidable A TM is r.e. : Define a TM U as follows: On input (M, w), U runs M on w. If M ever accepts, accept. If M ever rejects, reject. NB. When we write input (M, w) we really mean input code for (code for M, w)

Similarly, we can encode DFAs, NFAs, CFGs, etc. into strings of 0s and 1s So we can define the following languages: A DFA = { (B, w) B is a DFA that accepts string w } Theorem: A DFA is decidable Proof Idea: Simulate B on w A NFA = { (B, w) B is an NFA that accepts string w } Theorem: A NFA is decidable A CFG = { (G, w) G is a CFG that generates string w } Theorem: A CFG is decidable Proof Idea: Transform G into Chomsky Normal Form. Try all derivations of length up to 2 w -1

UNDECIDABLE PROBLEMS THURSDAY Feb 13

There are languages over {0,1} that are not decidable If we believe the Church-Turing Thesis, this is MAJOR: it means there are things that computers inherently cannot do We can prove this using a counting argument. We will show there is no onto function from the set of all Turing Machines to the set of all languages over {0,1}. (Works for any Σ) Hence there are languages that have no decider. Then we will prove something stronger: There are semi-decidable (r.e.) languages that are NOT decidable

Turing Machines Languages over {0,1}

Let L be any set and 2 L be the power set of L Theorem: There is no onto map from L to 2 L Proof: Assume, for a contradiction, that there is an onto map f : L 2 L Let S = { x L x f(x) } If S = f(y) then y S if and only if y S Can give a more constructive argument!

Theorem: There is no onto function from the positive integers to the real numbers in (0, 1) Proof: Suppose f is any function mapping the positive integers to the real numbers in (0, 1 1 2 3 4 5 : [ n-th digit of r ] = 0.28347279 2 0.88388384 8 0.77635284 6 0.11111111 1 0.12345678 5 : 1 if [ n-th digit of f(n) ] 1 2 otherwise f(n) r for all n ( Here, r = 11121... )

THE MORAL: No matter what L is, 2 L always has more elements than L

Not all languages over {0,1} are decidable, in fact: not all languages over {0,1} are semi-decidable {decidable languages over {0,1}} {semi-decidable languages over {0,1}} {Turing Machines} {Languages over {0,1}} {Strings of 0s and 1s} {Sets of strings of 0s and 1s} Set L Set of all subsets of L: 2 L

THE ACCEPTANCE PROBLEM A TM = { (M, w) M is a TM that accepts string w } Theorem: A TM is semi-decidable (r.e.) but NOT decidable A TM is r.e. : Define a TM U as follows: On input (M, w), U runs M on w. If M ever accepts, accept. If M ever rejects, reject. NB. When we write input (M, w) we really mean input code for (code for M, w)

THE ACCEPTANCE PROBLEM A TM = { (M, w) M is a TM that accepts string w } Theorem: A TM is semi-decidable (r.e.) but NOT decidable A TM is r.e. : Define a TM U as follows: On input (M, w), U runs M on w. If M ever accepts, accept. If M ever rejects, reject. Therefore, U accepts (M,w) M accepts w (M,w) A TM Therefore, U recognizes A TM U is a universal TM

A TM = { (M,w) M is a TM that accepts string w } A TM is undecidable: (proof by contradiction) Assume machine H decides A TM H( (M,w) ) = Accept Reject if M accepts w if M does not accept w Construct a new TM D as follows: on input M, run H on (M,M) and output the opposite of H D( M D ) = Reject Accept if M D accepts M D if M Ddoes not accept DM

OUTPUT OF H M 1 M 2 M 3 M 4 D M 1 accept accept accept reject accept M 2 reject accept reject reject reject M 3 accept reject reject accept accept M 4 accept reject reject reject accept : D reject reject? accept accept

Theorem: A TM is r.e. but NOT decidable Cor: A TM is not even r.e.!

A TM = { (M,w) M is a TM that accepts string w } A TM is undecidable: A constructive proof: Let machine H semi-decides A TM (Such, why?) H( (M,w) ) = Accept if M accepts w Reject or No output if M does not accept w Construct a new TM D as follows: on input M, run H on (M,M) and output Reject if H ( D, M, M D ) Accepts D( M D ) = Accept if H ( M D,, DM ) Rejects No output if H ( D, M, DM ) has No output H( (D,D) ) = No output No Contradictions!

We have shown: Given any machine H for semi-deciding A TM, we can effectively construct a TM D such that (D,D) A TM but H fails to tell us that. That is, H fails to be a decider on instance (D,D). In other words, Given any good candidate for deciding the Acceptance Problem, we can effectively construct an instance where the candidate fails.

THE classical HALTING PROBLEM HALT TM = { (M,w) M is a TM that halts on string w } Theorem: HALT TM is undecidable Proof: Assume, for a contradiction, that TM H decides HALT TM We use H to construct a TM D that decides A TM On input (M,w), D runs H on (M,w): If H rejects then reject If H accepts, run M on w until it halts: Accept if M accepts, ie halts in an accept state Otherwise reject

(M,w) ACCEPT if halts in accept state REJECT otherwise (M,w) If M halts D H Does M halt on w? w If M doesn t halt: REJECT M

In many cases, one can show that a language L is undecidable by showing that if it is decidable, then so is A TM We reduce deciding A TM to deciding the language in question A TM L We just showed: A TM Halt TM Is Halt TM A TM?