CS154, Lecture 7: Turing Machines.

Slides:



Advertisements
Similar presentations
Turing Machines Memory = an infinitely long tape Persistent storage A read/write tape head that can move around the tape Initially, the tape contains only.
Advertisements

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Variants of Turing machines
THE CHURCH-TURING T H E S I S “ TURING MACHINES” Pages COMPUTABILITY THEORY.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
1 Introduction to Computability Theory Lecture14: Recap 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.
Lecture 5 Turing Machines
CS5371 Theory of Computation Lecture 10: Computability Theory I (Turing Machine)
Fall 2005Costas Busch - RPI1 Recursively Enumerable and Recursive Languages.
Fall 2004COMP 3351 A Universal Turing Machine. Fall 2004COMP 3352 Turing Machines are “hardwired” they execute only one program A limitation of Turing.
January 28, 2015CS21 Lecture 101 CS21 Decidability and Tractability Lecture 10 January 28, 2015.
MA/CSSE 474 Theory of Computation More Reduction Examples Non-SD Reductions.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 15-1 Mälardalen University 2012.
A Universal Turing Machine
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
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.
CS 461 – Nov. 7 Decidability concepts –Countable = can number the elements  –Uncountable = numbering scheme impossible  –A TM undecidable –Language classes.
Lecture 17 Undecidability Topics:  TM variations  Undecidability June 25, 2015 CSCE 355 Foundations of Computation.
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.
Turing Machines Sections 17.6 – The Universal Turing Machine Problem: All our machines so far are hardwired. ENIAC
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY * Read chapter 4 of the book for next time * Lecture9x.ppt.
Recursively Enumerable and Recursive Languages. Definition: A language is recursively enumerable if some Turing machine accepts it.
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.
The Acceptance Problem for TMs
A Universal Turing Machine
Turing Machines Alan Turing ( ) mathematician and logician.
Recursively Enumerable and Recursive Languages
CSCI 2670 Introduction to Theory of Computing
Busch Complexity Lectures: Reductions
Reductions Costas Busch - LSU.
CS21 Decidability and Tractability
Pumping Lemma Revisited
CSE 105 theory of computation
BCS 2143 Theory of Computer Science
CSE 105 theory of computation
CSE 2001: Introduction to Theory of Computation Fall 2013
Turing Machines Acceptors; Enumerators
CS154, Lecture 10: Rice’s Theorem, Oracle Machines
Busch Complexity Lectures: Undecidable Problems (unsolvable problems)
فصل سوم The Church-Turing Thesis
Intro to Theory of Computation
CS154, Lecture 10: Rice’s Theorem, Oracle Machines
CSE 105 theory of computation
CSE 105 theory of computation
Decidable Languages Costas Busch - LSU.
Reducability Sipser, pages
CS21 Decidability and Tractability
CS21 Decidability and Tractability
Proposed in Turing’s 1936 paper
CS154, Lecture 13: P vs NP.
CS154, Lecture 12: Time Complexity
Formal Languages, Automata and Models of Computation
Recall last lecture and Nondeterministic TMs
Decidability and Tractability
CSCI 2670 Introduction to Theory of Computing
Instructor: Aaron Roth
CSE 105 theory of computation
CSE 105 theory of computation
CSE 105 theory of computation
Instructor: Aaron Roth
Instructor: Aaron Roth
Turing Machines Everything is an Integer
Intro to Theory of Computation
CSE 105 theory of computation
CSE 105 theory of computation
CSE 105 theory of computation
Presentation transcript:

CS154, Lecture 7: Turing Machines

Turing Machine (1936) INFINITE REWRITABLE TAPE FINITE STATE CONTROL A … INFINITE REWRITABLE TAPE

Turing Machine (1936)

Turing Machines versus DFAs TM can both write to and read from the tape The head can move left and right The input doesn’t have to be read entirely, and the computation can continue further (even, forever) after all input has been read Accept and Reject take immediate effect

This Turing machine decides the language {0} Σ = {0} read write move 0 → 0, R  → , R qaccept 0 → 0, R  → , R qreject This Turing machine decides the language {0}

This Turing machine recognizes the language {0} Σ = {0} read write move 0 → 0, R  → , R qaccept 0 → 0, R  → , R 0 → 0, R  → , L This Turing machine recognizes the language {0}

Deciding the language L = { w#w | w  {0,1}* } STATE STATE STATE STATE STATE STATE STATE STATE STATE STATE STATE STATE STATE q0, FIND # qGO LEFT q1, FIND # q0, FIND # q1, FIND # q#, FIND  q1, FIND # q#, FIND  q0, FIND  q1, FIND  q0, FIND  q1, FIND  qGO LEFT q1, FIND  and so on… X 1 1 1 X # # X 1 1 1 If there’s no # on the tape (or more than one #), reject. While there is a bit to the left of #, Replace the first bit with X, and check if the first bit b to the right of the # is identical. (If not, reject.) Replace that bit b with an X too. If there’s a bit to the right of #, then reject else accept

Definition: A Turing Machine is a 7-tuple T = (Q, Σ, Γ, , q0, qaccept, qreject), where: Q is a finite set of states Σ is the input alphabet, where   Σ Γ is the tape alphabet, where   Γ and Σ  Γ  : Q  Γ → Q  Γ  {L, R} q0  Q is the start state qaccept  Q is the accept state qreject  Q is the reject state, and qreject  qaccept

Turing Machine Configurations

Defining Acceptance and Rejection for TMs Let C1 and C2 be configurations of a TM M Definition: C1 yields C2 if M is in configuration C2 after running M in configuration C1 for one step Suppose (q1, b) = (q2, c, L) Then aaq1bb yields aq2acb Suppose (q1, a) = (q2, c, R) Then cabq1a yields cabcq2 Let w  Σ* and M be a Turing machine M accepts w if there are configs C0, C1, ..., Ck, s.t. C0 = q0w Ci yields Ci+1 for i = 0, ..., k-1, and Ck contains the accept state qaccept

A TM M recognizes a language L if M accepts exactly those strings in L A language L is recognizable (a.k.a. recursively enumerable) if some TM recognizes L A TM M decides a language L if M accepts all strings in L and rejects all strings not in L A language L is decidable (a.k.a. recursive) if some TM decides L

A Turing machine for deciding { 0 | n ≥ 0 } Turing Machine PSEUDOCODE: Sweep from left to right, cross out every other 0 If in step 1, the tape had only one 0, accept If in step 1, the tape had an odd number of 0’s, reject Move the head back to the first input symbol. Go to step 1. Why does this work? Idea: Every time we return to stage 1, the number of 0’s on the tape has been halved.

Step 4 2n { 0 | n ≥ 0 } Step 1 Step 2 Step 3

{ 0 | n ≥ 0 } q00000 2n q1000 xq300 x0q40 x0xq3 x0q2x xq20x …

Multitape Turing Machines  : Q  Γk → Q  Γk  {L,R}k

Theorem: Every Multitape Turing Machine can be transformed into a single tape Turing Machine

Theorem: Every Multitape Turing Machine can be transformed into a single tape Turing Machine

Theorem: Every Multitape Turing Machine can be transformed into a single tape Turing Machine

Theorem: Every Multitape Turing Machine can be transformed into a single tape Turing Machine

Theorem: Every Multitape Turing Machine can be transformed into a single tape Turing Machine

Theorem: L is decidable iff both L and L are recognizable

Recall: Given L  Σ*, define L := Σ* \ L Theorem: L is decidable iff both L and L are recognizable Given: a TM M1 that recognizes L and a TM M2 that recognizes L, want to build a new machine M that decides L How? Any ideas? M1 always accepts x, when x is in L M2 always accepts x, when x isn’t in L

Recall: Given L  Σ*, define L := Σ* \ L Theorem: L is decidable iff both L and L are recognizable Given: a TM M1 that recognizes L and a TM M2 that recognizes L, want to build a new machine M that decides L Simulate M1 (x) on one tape, M2 (x) on another. Exactly one of the two will accept If M1 accepts then accept If M2 accepts then reject

Nondeterministic Turing Machines Have multiple transitions for a state, symbol pair Theorem: Every nondeterministic Turing machine N can be transformed into a Turing Machine M that accepts precisely the same strings as N. Proof Idea (more details in Sipser) Pick a natural ordering on all strings in {Q  Γ  #}* M(w): For all strings D  {Q  Γ  #}* in the ordering, Check if D = C0#  #Ck where C0, …,Ck is some accepting computation history for N on w. If so, accept.

It is all Zeros and Ones One of the most popular and overemphasized clichés about computer scientists. Proxy for: genius / nerd / insensitive / anti-social / … (still bits are quite fundamental, “more than atoms”)

Bit Strings Encoding Encode a finite string in Σ* as a bit string: encode each character as log | Σ | bits. For x  Σ* define bΣ(x) to be its binary encoding For x, y  Σ*, to encode the pair of x and y can add as x, y over Σ’ = Σ{,}. Or sometimes better: (x, y) := 0|bΣ(x)|1 bΣ(x) bΣ(y)

TM Encoding ( (p, i), (q, j, L) ), ( (p, i), (q, j, R) ) , … Can encode a TM as a bit string: n (states), m (tape symbols), (first) k (are input symbols), s (start state), t (accept state), r (reject state), u (blank symbol), transition1, transition2, … ( (p, i), (q, j, L) ), ( (p, i), (q, j, R) ) , … Similarly, we can encode DFAs and NFAs as bit strings

0n10m10k10s10t10r10u1 … ( (p, i), (q, j, L) ) = 0p10i10q10j10 Other ways to encode a TM exist: start state reject state n states 0n10m10k10s10t10r10u1 … m tape symbols (first k are input symbols) blank symbol accept state ( (p, i), (q, j, L) ) = 0p10i10q10j10 ( (p, i), (q, j, R) ) = 0p10i10q10j100

Binary languages about computations Define the following languages over {0,1}: ADFA = { (B, w) | B encodes a DFA over some Σ, and B accepts w  Σ* } ANFA = { (B, w) | B encodes an NFA, B accepts w } ATM = { (M, w) | M encodes a TM, M accepts w }

ATM = { (M, w) | M encodes a TM over some Σ, ATM = { (M, w) | M encodes a TM over some Σ, w encodes a string over Σ and M accepts w} Technical Note: We’ll use an decoding of pairs, TMs, and strings so that every binary string decodes to some pair (M, w) If x  {0,1}* doesn’t decode to (M,w) in the usual way, then we define that x decodes to the pair (D, ε) where D is a “dummy” TM that accepts nothing. Then, we can define the complement of ATM very simply: ATM = { (M, w) | M does not accept w }

Universal Turing Machines Theorem: There is a Turing machine U which takes as input: (1) the code of an arbitrary TM M (2) an input string w such that U accepts (M, w)  M accepts w. This is a fundamental property of TMs: There is a Turing Machine that can run arbitrary Turing Machine code! Note that DFAs/NFAs do not have this property: ADFA and ANFA are not regular.

The Church-Turing Thesis Everyone’s Intuitive Notion of Algorithms = Turing Machines This is not a theorem – it is a falsifiable scientific hypothesis. And it has and is still been tested

Theorem: ADFA is decidable ADFA = { (D, w) | D is a DFA that accepts string w } Theorem: ADFA is decidable Proof: A DFA is a special case of a TM. Run the universal U on (D, w) and output its answer. ANFA = { (N, w) | N is an NFA that accepts string w } Theorem: ANFA is decidable. (Why?) ATM = { (M, w) | M is a TM that accepts string w } Theorem: ATM is recognizable but not decidable!

There are non-recognizable languages Assuming the Church-Turing Thesis, this means there are problems that NO computing device can solve! 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 finite Σ) That is, every mapping from Turing machines to languages fails to cover all possible languages

“There are more problems to solve than there are programs to solve them.” Languages over {0,1}

f : A  B is not onto  (9 b 2 B)(8 a 2 A)[f(a)  b] Let L be any set and 2L be the power set of L Theorem: There is no onto function from L to 2L Proof: Assume, for a contradiction, there is an onto function f : L  2L Define S = { x  L | x  f(x) }  2L If f is onto, then there is a y  L with f(y) = S Suppose y  S. By definition of S, y  f(y) = S. Suppose y  S. By definition of S, y  f(y) = S. Contradiction!

f : A  B is not onto  (9 b 2 B)(8 a 2 A)[f(a)  b] Let L be any set and 2L be the power set of L Theorem: There is no onto function from L to 2L Let f : L  2L be an arbitrary function Define S = { x  L | x  f(x) } 2 2L For all x  L, If x  S then x  f(x) [by definition of S] If x  S then x  f(x) In either case, we have f(x)  S. (Why?) Therefore f is not onto!

What does this mean? No function from L to 2L can “cover” all the elements in 2L No matter what the set L is, the power set 2L always has strictly larger cardinality than L

2M Thm:There are non-recognizable languages ⊆ Proof: Suppose all languages are recognizable. Then for all L, there’s a Turing machine M for recognizing L. Hence there is an onto R: {Turing Machines}  {Languages} {Languages over {0,1}} {Turing Machines} ⊆ {Sets of strings of 0s and 1s} {0,1}* Set M 2M But there is no onto function from {Turing Machines} ⊆ M to 2^M. Contradiction!

Russell’s Paradox in Set Theory In the early 1900’s, logicians were trying to define consistent foundations for mathematics. Suppose X = “Universe of all possible sets” Frege’s Axiom: Let f : X  {0,1} Then {S  X | f(S) = 1} is a set. Define F = { S  X | S  S } Suppose F  F. Then by definition, F  F. So F  F and by definition F  F. This logical system is inconsistent!