CSCC63 Worksheet Turing Machines

Similar documents
Chapter 3: The Church-Turing Thesis

CS21 Decidability and Tractability

CSE 105 THEORY OF COMPUTATION

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

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

Computability Theory. CS215, Lecture 6,

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

1 Showing Recognizability

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

The Church-Turing Thesis

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

Turing machines COMS Ashley Montanaro 21 March Department of Computer Science, University of Bristol Bristol, UK

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

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

ECS 120 Lesson 15 Turing Machines, Pt. 1

Harvard CS 121 and CSCI E-121 Lecture 14: Turing Machines and the Church Turing Thesis

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

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

TURING MAHINES

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Homework Assignment 6 Answers

Busch Complexity Lectures: Turing Machines. Prof. Busch - LSU 1

CS4026 Formal Models of Computation

Theory of Computation

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

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

Turing Machines Part II

Turing Machines. Our most powerful model of a computer is the Turing Machine. This is an FA with an infinite tape for storage.

Lecture 14: Recursive Languages

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CpSc 421 Homework 9 Solution

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

CSCI3390-Assignment 2 Solutions

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

Foundations of

CS 525 Proof of Theorems 3.13 and 3.15

Part I: Definitions and Properties

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

Most General computer?

SE 3310b Theoretical Foundations of Software Engineering. Turing Machines. Aleksander Essex

Computation Histories

V Honors Theory of Computation

Undecidable Problems and Reducibility

Chapter 8. Turing Machine (TMs)

Decidability (What, stuff is unsolvable?)

Turing Machines. Lecture 8

Introduction to Turing Machines

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

Busch Complexity Lectures: Turing s Thesis. Costas Busch - LSU 1

SCHEME FOR INTERNAL ASSESSMENT TEST 3

The Turing machine model of computation

The tape of M. Figure 3: Simulation of a Turing machine with doubly infinite tape

ECS 120 Lesson 20 The Post Correspondence Problem

Lecture 12: Mapping Reductions

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

Variants of Turing Machine (intro)

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

Designing 1-tape Deterministic Turing Machines

CS 21 Decidability and Tractability Winter Solution Set 3

Turing Machines. Nicholas Geis. February 5, 2015

Homework. Turing Machines. Announcements. Plan for today. Now our picture looks like. Languages

Theory of Computation

IV. Turing Machine. Yuxi Fu. BASICS, Shanghai Jiao Tong University

Reducability. Sipser, pages

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

1 Unrestricted Computation

CpSc 421 Final Exam December 15, 2006

Further discussion of Turing machines

Theory of Computation (IX) Yijia Chen Fudan University

Non-emptiness Testing for TMs

CS154, Lecture 10: Rice s Theorem, Oracle Machines

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

CSE 105 THEORY OF COMPUTATION

Computability and Complexity

Introduction to Turing Machines. Reading: Chapters 8 & 9

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

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

CSCE 551 Final Exam, April 28, 2016 Answer Key

Automata and Computability. Solutions to Exercises

Computability Theory

Finite Automata. Mahesh Viswanathan

Theory of Computation - Module 4

COMP-330 Theory of Computation. Fall Prof. Claude Crépeau. Lec. 16 : Turing Machines

CS20a: Turing Machines (Oct 29, 2002)

MA/CSSE 474 Theory of Computation

Computational Models - Lecture 6

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

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

Homework 5 Solution CSCI 2670 October 6, c) New text q 1 1##1 xq 3 ##1 x#q 5 #1 q reject. Old text. ~q 3 ##1 ~#q 5 #1

1 Reducability. CSCC63 Worksheet Reducability. For your reference, A T M is defined to be the language { M, w M accepts w}. Theorem 5.

Decidability (intro.)

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

Q = Set of states, IE661: Scheduling Theory (Fall 2003) Primer to Complexity Theory Satyaki Ghosh Dastidar

Fundamentals of Computer Science

Automata Theory (2A) Young Won Lim 5/31/18

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

Turing Machines. Chapter 17

Turing Machine properties. Turing Machines. Alternate TM definitions. Alternate TM definitions. Alternate TM definitions. Alternate TM definitions

Transcription:

1 An Example CSCC63 Worksheet Turing Machines Goal. Design a turing machine, M that accepts only strings of the form {w#w w {0, 1} }. Idea. Describe in words how the machine would work. Read first symbol and cross it off (replace with new symbol x ), move right until #, keep moving right until first non-x symbol to verify same as first symbol seen earlier (remembered through states), cross it off and go back to leftmost non-x symbol to repeat. If more than one # or different symbols or more symbols on one side than the other, reject; otherwise, accept. State Diagram. Draw the state diagram. Use the notation (a, b, c) for transitions where a is the input symbol, b is the symbol to be printed and c is one of L or R for the direction to move the head. q1 (1, x, R) q3 q8 (_,,R) (0, x,r) q2 q5 q_accept q4 (1,x,L) (0,x,L) (x,,l) (0,,L) (1,,L) q6 (#,,L) q7 Note that (a,b,c) means on input a, print b and move c. 1

2 Turing Machine Formal Definition A Turing machine is a 7-tuple (Q, Σ, Γ, d, q 0, q accept, q reject ), where Q is a fixed, non-empty, finite set of states Σ is a fixed, non-empty, finite set of symbols (the input alphabet, with blank symbol not in Σ) Γ is a fixed, non-empty, finite set of symbols (the tape alphabet, with Σ subset of Γ and in Γ ). We use to denote a blank. q 0 Q is the start state (or initial state ) q accept Q is an accepting state q reject Q is a rejecting state (q reject q accept ) δ is the transition function. 3 Definitions δ : Q {q accept, q reject } Γ Q Γ {L, R} Configuration of a TM. The current state, tape content, and head position. Notation. uqv where q Q, strings u, v Γ. We use to denote a blank. q: is the current state, uv: the concatenation of u and v form the current tape content (non-blank portion) head position: head is on leftmost symbol of v. Observations. For all states q i, q j Q, symbols a, b, c Γ and strings u, v Γ, since the tape is infinite to the right, configuration uqv is equivalent to uqv, uqv, etc. if δ(q i, b) = (q j, c, R), then configuration uq i bv yields... ucq j v in one step of computation; if δ(q i, b) = (q j, c, L), then configuration uaq i bv yields... uq j acv and q i bv yields... q j cv (because head cannot move off left end). 4 Another Example. Given input string w L sum where L sum = {1 n 01 m 01 n+m n 1, m 0, n, m N}. Describe a Turing machine M sum that decides L sum. Decides means that the Turing machine halts and recognizes the language. Idea. 2

Add the first set of 1 s and then check whether they are equal. To add, simply walk through the 1s until a 0 is reached, change to a 1, then continue walking right until a 0 is reached, go left, replace the 1 with a 0, then return to the start. Now we need only check that the number of 1s in the the string 1 001 are equal. We already did this with our 1#1 example. High-level Algorithm. M sum = On input string w: 1. Sweep left to right, reading 1 s until a 0 is found (if no 0 reject). 2. Replace 0 with a 1 and move right. 3. Sweep left to right reading 1 s until a 0 is found (if no 0 reject). 4. At 0, go left and replace 1 by a 0. 5. Move left until start of tape found. 6. Use a procedure similar to the previous example but replace w#w with u00u where u {1}. 3

5 Variations of the Turing Machine 5.1 Multitape Allow more than 1 tape, each with an independent head. Initially, all tapes blank except tape 1 that contains input. In one step, current state and symbols are read on all tapes to determine the next state, symbols written and head movements for all tapes. Q. What is δ multi? For a regular TM, δ is defined to be: δ : Q Γ Q Γ {L, R}. δ multi : Q Γ k Q Γ k {L, R} k. Note: Different from k independent machines running concurrently! Q. How can we show that the original Turing machine is just as powerful as the multitape? keep track of contents of k tapes separated by special symbol, keep track of head positions by using additional symbols (duplicates of tape alphabet), and use additional states to remember k symbols to read/write (since k is fixed). Simulating one step of multi-tape machine requires single-tape machine to scan over its entire tape twice: once to read k tapes, once to update k tapes. Another Example: Define A = {0 2n n 0}, the language consisting of all strings of 0s whose length is a power of 2. Design a TM M that decides A. Main idea: M = On input string w : 1. 2. 3. 4. 5. 1. Sweep left to right across the tape, crossing off every other 0. 2. If in stage 1 the tap contained a single 0, accept. 3. If in stage 1 the tape contained more than a single 0 and the number of 0s was odd, reject. 4. Return the head to the left-hand end of the tape. 5. Go to stage 1. 4

6 Enumerators No input. Two tapes and a special state q print. Machine computes and whenever it enters state q print, string written on second tape is printed. The language enumerated by an enumerator is the set of strings printed during computation (could be infinite if computation never halts). Theorem 3.21 A language is Turing-recognizable if and only if some enumerator enumerates it. Q. What is this saying? That we can use enumerators and Turing machines interchangeably when talking about recognizable languages. Proof Idea. ( ) Given enumerator E for language A, construct TM M that recognizes A as follows: M = On input w: Explanation 1. Run E; every time a string is printed, compare it with w. 2. Accept if w is ever printed. Reject if E stops without printing w. If w A, then E eventually prints w so M accepts w. If w A, then E never prints w so M rejects or loops on w. ( ) Given TM M that recognizes A, construct enumerator E for A as follows: Let s 1, s 2, s 3,... be a complete list of all strings in Σ (e.g., in lexicographic order): E = Repeat for i = 1, 2, 3,... 1. Run M for i steps on each input string s 1, s 2,..., s i. 2. Print every string that is accepted. Explanation If w A, then M accepts w so E will eventually print w (infinitely many times why??). If w A, then M rejects or loops on w so E will never print w. 5