An example of a decidable language that is not a CFL Implementation-level description of a TM State diagram of TM

Similar documents
An example of a decidable language that is not a CFL Implementation-level description of a TM State diagram of TM

Pumping Lemma for CFLs

jflap demo Regular expressions Pumping lemma Turing Machines Sections 12.4 and 12.5 in the text

Cliff s notes for equivalence of CFLs and L(PDAs) LisaCFL L = L(M) for some PDA M L=L(M)forsomePDAM L = L(G) for some CFG G

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

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

V Honors Theory of Computation

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

Further discussion of Turing machines

Computability and Complexity

Foundations of

CSE 105 THEORY OF COMPUTATION

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

1 Unrestricted Computation

CSCC63 Worksheet Turing Machines

CS21 Decidability and Tractability

Introduction to Turing Machines

CS4026 Formal Models of Computation

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

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

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

Turing Machines. Lecture 8

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

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

Decidability and Undecidability

Chapter 3: The Church-Turing Thesis

Theory of Computation

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

Introduction to Turing Machines. Reading: Chapters 8 & 9

Turing Machines Part III

Chapter 8. Turing Machine (TMs)

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

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

Computational Models Lecture 8 1

Decidable Languages - relationship with other classes.

Announcements. Problem Set 6 due next Monday, February 25, at 12:50PM. Midterm graded, will be returned at end of lecture.

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

Part I: Definitions and Properties

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

Computational Models Lecture 8 1

Computational Models Lecture 8 1

Homework Assignment 6 Answers

Turing Machines Part II

Decidability: Church-Turing Thesis

Computability Theory. CS215, Lecture 6,

CSCE 551 Final Exam, Spring 2004 Answer Key

Most General computer?

The Unsolvability of the Halting Problem. Chapter 19

Chapter 1 - Time and Space Complexity. deterministic and non-deterministic Turing machine time and space complexity classes P, NP, PSPACE, NPSPACE

Automata and Computability. Solutions to Exercises

1 Showing Recognizability

Reducability. Sipser, pages

CSE 105 THEORY OF COMPUTATION

Automata and Computability. Solutions to Exercises

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Turing Machines Part II

Complexity Theory Part I

Lecture 12: Mapping Reductions

CS154, Lecture 10: Rice s Theorem, Oracle Machines

CPSC 421: Tutorial #1

The Church-Turing Thesis

The Turing machine model of computation

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

Turing Machines Part II

Turing Machines. Fall The Chinese University of Hong Kong. CSCI 3130: Formal languages and automata theory

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

Computation Histories

CSE 105 THEORY OF COMPUTATION

Decidable and undecidable languages

Computational Models - Lecture 6

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Lecture 23: Rice Theorem and Turing machine behavior properties 21 April 2009

SCHEME FOR INTERNAL ASSESSMENT TEST 3

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

Announcements. Using a 72-hour extension, due Monday at 11:30AM.

Theory of Computation (IX) Yijia Chen Fudan University

CSE 105 THEORY OF COMPUTATION

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

Undecidable Problems and Reducibility

Time Complexity (1) CSCI Spring Original Slides were written by Dr. Frederick W Maier. CSCI 2670 Time Complexity (1)

CS20a: Turing Machines (Oct 29, 2002)

CS151 Complexity Theory. Lecture 1 April 3, 2017

MA/CSSE 474 Theory of Computation

Finite Automata. Mahesh Viswanathan

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

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

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Variants of Turing Machine (intro)

CSE 105 Theory of Computation

More About Turing Machines. Programming Tricks Restrictions Extensions Closure Properties

Announcements. Problem Set 7 graded; will be returned at end of lecture. Unclaimed problem sets and midterms moved!

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

CS154, Lecture 17: conp, Oracles again, Space Complexity

CSE 105 THEORY OF COMPUTATION

CS 525 Proof of Theorems 3.13 and 3.15

Testing Emptiness of a CFL. Testing Finiteness of a CFL. Testing Membership in a CFL. CYK Algorithm

Non-emptiness Testing for TMs

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

Fundamentals of Computer Science

Computability and Complexity

Transcription:

Turing Machines Review An example of a decidable language that is not a CFL Implementation-level description of a TM State diagram of TM Varieties of TMs Multi-Tape TMs Nondeterministic TMs String Enumerators 1 Turing Machines Blank part of tape Just like a DFA except: You have an infinite tape memory (or scratchpad) on which you receive your input and on which you can do your calculations You can read one symbol at a time from a cell on the tape, write one symbol, then move the read/write pointer (head) left (L) or right (R) 2

Who s Turing? Alan Turing (1912-1954): one of the most brilliant mathematicians of the 20 th century (one of the founding fathers of computing) Click on Theory Hall of Fame link on class web under Lectures Introduced the Turing machine as a formal model of what it means to compute and solve a problem (i.e. an algorithm ) Paper: On computable numbers, with an application to the Entscheidungsproblem, Proc. London Math. Soc. 42 (1936). 3 How do Turing Machines compute? δ(current state, symbol under the head) = (next state, symbol to write over current symbol, direction of head movement) Diagram shows: δ(q 1,1) = (q rej, 0, L) (R = right, L = left) In terms of Configurations : 110q 1 10 11q rej 000 4

Solving Problems with Turing Machines We know L = {0 n 1 n 0 n n 0} is not a CFL (pumping lemma) Show L is decidable Construct a decider M such that L(M) = L A decider is a TM that always halts (in q acc or q rej ) and is guaranteed not to go into an infinite loop for any input 5 Idea for a Decider for {0 n 1 n 0 n n 0} General Idea: Match each 0 with a 1 and a 0 following the 1. Implementation Level Description of a Decider for L: On input w: 1. If first symbol = blank, ACCEPT 2. If first symbol = 1, REJECT 3. If first symbol = 0, Write a blank to mark left end of tape a. If current symbol is 0 or X, skip until it is 1. REJECT if blank. b. Write X over 1. Skip 1 s/x s until you see 0. REJECT if blank. c. Write X over 0. Move back to left end of tape. 4. At left end: Skip X s until: a. You see 0: Write X over 0 and GOTO 3a b. You see 1: REJECT c. You see a blank space: ACCEPT 6

State Diagram 0 R q 0 _,R 0 q 1 X,R skip0 q 0 X,L skip1 q go-left X L 0 L 1 L 0 X,R Try running the decider on: 010, 001100, ACCEPT 0, 000, 0100, REJECT What about 010010? q REJ q ACC q at-left 7 Houston, we have a problem with our Turing machine 8

What s the problem? 0 R q 0 _,R 0 q 1 X,R skip0 q 0 X,L skip1 q go-left X L 0 L 1 L 0 X,R q REJ q ACC The decider accepts incorrect strings: 010010, 010001100 ACCEPT!!! q at-left Maybe it s the GOTO? Accepts (0 n 1 n 0 n ) * Need to fix it E. W. Dijkstra 9 An Aside: Dijsktra on GOTOs For a number of years I have been familiar with the observation that the quality of programmers is a decreasing function of the density of go to statements in the programs they produce. Opening sentence of: Go To Statement Considered Harmful by Edsger W. Dijkstra, Letter to the Editor, Communications of the ACM, Vol. 11, No. 3, March 1968, pp. 147-148. 10

A Simple Fix (to the Decider) Scan initially to make sure string is of the form 0*1*0* On input w: 1. If first symbol = blank, ACCEPT Add this 2. If first symbol = 1, REJECT 3. If first symbol = 0: if w is not in 00*11*00*, REJECT; else, Write a blank to mark left end of tape a. If current symbol is 0 or X, skip until it is 1. REJECT if blank. b. Write X over 1. Skip 1 s/x s until you see 0. REJECT if blank. c. Write X over 0. Move back to left end of tape. 4. At left end: Skip X s until: a. You see 0: Write X over 0 and GOTO 3a b. You see 1: REJECT c. You see a blank space: ACCEPT GOTO okay here 11 The Decider TM for L in all its glory q 0 q REJ 0 _,R 0 R 0 R 0 R q 1 q2 0 R q3 0 L 1 L _ L q REW q REJ q 1 X,R skip0 q 0 X,L skip1 q go-left New part tests for 00*11*00* X L 0 L 1 L q ACC 0 X,R q at-left 12

Varieties of TMs What if we allow multiple tapes? What if we allow nondeterminism? What if I take nap? 13 Various Types of TMs Multi-Tape TMs: TM with k tapes and k heads δ: Q Γ k Q Γ k {L,R} k δ(q i, a 1,, a k ) = (q j, b 1,, b k, L, R,, L) Nondeterministic TMs (NTMs) δ: Q Γ Pow(Q Γ {L,R}) δ(q i, a) = {(q 1, b, R), (q 2, c, L),, (q m, d, R)} Enumerator TM for L: Prints all strings in L (in any order, possibly with repetitions) and only the strings in L Other types: TM with Two-way infinite tape, TM with multiple heads on a single tape, 2D infinite tape TM, Random Access Memory (RAM) TM, etc. 14

Surprise! All TMs are born equal Each of the preceding TMs is equivalent to the standard TM They recognize the same set of languages (the Turingrecognizable languages) Proof idea: Simulate the deviant TM using a standard TM Example 1: Multi-tape TM on a standard TM Represent k tapes sequentially on 1 tape using separators # Use new symbol a to denote a head currently on symbol a 0 1........... b a h.......... 3 2 2.......... # 0 1 # b a h # 3 2 2 #....... (See text for details) 15 Example 2: Simulating Nondeterminism Any nondeterministic TM N can be simulated by a deterministic TM M NTMs: δ: Q Γ Pow(Q Γ {L,R}) No ε transitions but can simulate them by reading and writing same symbol N accepts w iff there is at least 1 path in N s tree for w ending in q ACC General proof idea: Simulate each branch sequentially Proof idea 1: Use depth first search? No, might go deep into an infinite branch and never explore other branches! Proof idea 2: Use breadth first search Explore all branches at depth n before n+1 a q 0 (q 1, b, R) (q 2, c, L) a b q REJ a q ACC This branch does not halt 16

Simulating Nondeterminism: Details, Details Use a 3-tape DTM M for breadthfirst traversal of N s tree on w: Tape 1 keeps the input string w Tape 2 stores N s tape during simulation along 1 path (given by tape 3) up to a particular depth, starting with w Tape 3 stores current path number E.g. ε = root node q 0 213 = path made up of 3 rd child of 1 st child of 2 nd child of root See text for more details a q 0 (q 1, b, R) (q 2, c, L) q REJ Does not halt a 213 q ACC 17 Next Class: We ll rap up Chapta 3 and cova undecidability Can t wait for undecidability! That guy needs help Have a great weekend! 18