1 Turing Machines and Equivalent Models Section 13.1 Turing Machines.

Slides:



Advertisements
Similar presentations
Restricted Machines Presented by Muhannad Harrim.
Advertisements

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.
Introduction to Computability Theory
Lecture 16 Deterministic Turing Machine (DTM) Finite Control tape head.
Variants of Turing machines
1 Section 14.1 Computability Some problems cannot be solved by any machine/algorithm. To prove such statements we need to effectively describe all possible.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture11: Variants of Turing Machines Prof. Amos Israeli.
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture7: PushDown Automata (Part 1) Prof. Amos Israeli.
Fall 2004COMP 3351 Turing Machines. Fall 2004COMP 3352 The Language Hierarchy Regular Languages Context-Free Languages ? ?

Fall 2004COMP 3351 Reducibility. Fall 2004COMP 3352 Problem is reduced to problem If we can solve problem then we can solve problem.
Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov.
Key to Homework #2 1. What is the language of L-system G = ({a, b, c}, h, acb ), where the rewriting rule h is defined as follows: h (a) = aa h (b) = cb.
Courtesy Costas Busch - RPI1 Reducibility. Courtesy Costas Busch - RPI2 Problem is reduced to problem If we can solve problem then we can solve problem.
Prof. Busch - LSU1 Turing Machines. Prof. Busch - LSU2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Chapter 9 Turing Machine (TMs).
Finite State Machines Data Structures and Algorithms for Information Processing 1.
1 Turing Machines. 2 A Turing Machine Tape Read-Write head Control Unit.
Turing Machines A more powerful computation model than a PDA ?
CSCI 2670 Introduction to Theory of Computing September 28, 2005.
1 Section 14.2 A Hierarchy of Languages Context-Sensitive Languages A context-sensitive grammar has productions of the form xAz  xyz, where A is a nonterminal.
1 111 Computability, etc. Midterm review. Turing machines. Finite state machines. Push down automata. Homework: FSA, PDA, TM problems (can work in teams)
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Models of Computation - Turing Machines Dale Roberts, Lecturer.
Lecture Pushdown Automata. stack stack head finite control tape head tape.
Computability Construct TMs. Decidability. Preview: next class: diagonalization and Halting theorem.
Turing Machines Chapter 17. Languages and Machines SD D Context-Free Languages Regular Languages reg exps FSMs cfgs PDAs unrestricted grammars Turing.
1 Turing Machines Reading: Chapter 8. 2 Turing Machines are… Very powerful (abstract) machines that could simulate any modern day computer (although very,
The Church-Turing Thesis Chapter 3 Giorgi Japaridze Theory of Computability.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 3 The Church-Turing Thesis Contents Turing Machines definitions, examples,
Fundamentals of Informatics Lecture 3 Turing Machines Bas Luttik.
TM Design Macro Language D and SD MA/CSSE 474 Theory of Computation.
1 Section 13.1 Turing Machines A Turing machine (TM) is a simple computer that has an infinite amount of storage in the form of cells on an infinite tape.
Lecture 24UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 24.
1 Turing Machines - Chap 8 Turing Machines Recursive and Recursively Enumerable Languages.
Lecture 16b Turing Machines Topics: Closure Properties of Context Free Languages Cocke-Younger-Kasimi Parsing Algorithm June 23, 2015 CSCE 355 Foundations.
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 3 The Church-Turing Thesis Contents Turing Machines definitions, examples,
1 Introduction to Turing Machines
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 12 Mälardalen University 2007.
Summary of Previous Class There are languages that are not decidable –(we have not proved this yet) Why not extend Turing machines just as we did with.
Turing Machines Sections 17.6 – The Universal Turing Machine Problem: All our machines so far are hardwired. ENIAC
1 Chapter Pushdown Automata. 2 Section 12.2 Pushdown Automata A pushdown automaton (PDA) is a finite automaton with a stack that has stack operations.
1 8.4 Extensions to the Basic TM Extended TM’s to be studied: Multitape Turing machine Nondeterministic Turing machine The above extensions make no increase.
1 Section 12.2 Pushdown Automata A pushdown automaton (PDA) is a finite automaton with a stack that has stack operations pop, push, and nop. PDAs always.
Chapter 9 Turing Machines What would happen if we change the stack in Pushdown Automata into some other storage device? Truing Machines, which maintains.
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Universal Turing Machine
CS6800 Advance Theory of Computation Spring 2016 Nasser Alsaedi
Lecture # 21.
Formal Languages, Automata and Models of Computation
Busch Complexity Lectures: Turing Machines
Reductions Costas Busch - LSU.
PDA’s - A new format for FAs
Pushdown Automata PDAs
PDAs Accept Context-Free Languages
Pushdown Automata PDAs
CSE 105 theory of computation
Turing Machines 2nd 2017 Lecture 9.
NPDAs Accept Context-Free Languages
Turing Machines Acceptors; Enumerators
Chapter 9 TURING MACHINES.
Turing Machines (TM) Deterministic Turing Machine (DTM)
Non-Deterministic Finite Automata
CS21 Decidability and Tractability
Decidability and Tractability
Computability Catch up last lecture. Turing machines. Variations
Variants of Turing machines
Presentation transcript:

1 Turing Machines and Equivalent Models Section 13.1 Turing Machines

2 A Turing machine (TM) is a simple computer that has an infinite amount of storage in the form of cells on an infinite tape. There is a control unit that contains a finite set of state transition instructions.

3 Operations An instruction reads the symbol in the current tape cell, writes a symbol to the same cell, and then moves the tape head one cell left or right or remains at the same cell, after which the machine enters a new state.

4 Assumptions The symbol Λ denotes a blank cell. The tape head is initially at the left end of a nonempty input string (unless specified otherwise) There is a designated start state. There is one “halt” state. The moves are denoted by L, S, R for move left, stay, and move right.

5 Example Instructions are represented in graphical form or as 5-tuples, as shown in the example. This instruction executes if the current state of the TM is i and the current input symbol is a. The TM writes b into that cell, moves right one cell and enters state j.

6 Acceptance An input string on the tape is accepted by the TM if the machine enters the halt state. The language of a TM is the set of all strings accepted by the machine.

7 Example/Quiz Given the following simple TM. (0, a, a, R, halt). What is the language of the TM? Answer: If an input string begins with the letter a, then the TM executes the instruction and halts. So the string is accepted. Therefore, the language of the TM is the set of all strings that begin with the letter a.

8 Example Construct a TM to accept the language {ab n | n ∊ N}. Solution. Let the start state be state 0. The idea is to see whether a is in the current cell. If so, move right to scan b’s until Λ is found. (0, a, a, R, 1) (1, Λ, Λ, S, halt) (1, b, b, R, 1).

9 Quiz Construct a TM to accept the language {ab n a | n ∊ N}. Solution. Let the start state be state 0. The idea is to see whether a is in the current cell. If so, move right to scan b’s until a is found. Then make sure there is Λ to the right. (0, a, a, R, 1) (1, a, a, R, 2) (1, b, b, R, 1) (2, Λ, Λ, S, halt).

10 Quiz Construct a TM to accept the language of the regular expression a(a + b)*. Solution. Let the start state be state 0. The idea is to see whether a is in the current cell. If so, move right to scan any a’s or b’s until Λ is found. (0, a, a, R, 1) (1, a, a, R, 1) (1, b, b, R, 1) (1, Λ, Λ, S, halt).

11 Example/Quiz Find a TM to accept {a n b n | n ∊ N}. Solution. Let the start state be state 0. The idea is to see whether a is in the current cell. If so, write X and scan right looking for a b to replace by Y. (0, Λ, Λ, S, halt) accept Λ (0, a, X, R, 1) mark a with X (0, Y, Y, R, 3) no more a’s Scan right looking for b to pair with a: (1, a, a, R, 1) (1, Y, Y, R, 1) (1, b, Y, L, 2) mark b with Y Scan back left looking for X: (2, a, a, L, 2) (2, Y, Y, L, 2) (2, X, X, R, 0) Scan right looking for Λ and halt: (3, Y, Y, R, 3) (3, Λ, Λ, S, halt)

12 TMs are very powerful For example, the preceding example can be generalized to a TM that accepts the non- context free language {a n b n c n | n ∊ N}. (See Example 13.2 in the Text.) So a TM can handle two stacks. In fact, a TM can handle any number of stacks.

13 Turing Machines with Output Specify the form of the output on the tape when the machine halts. Example/Quiz. Find a TM to add 4 to a natural number represented in binary. Start with the tape head at the right end of the input string and halt with the tape head at the left end of the output string. Solution. Let the start state be 0. Move two cells left: (0, 0, 0, L, 1) (0, 1, 1, L, 1) (1, 0, 0, L, 2) (1, 1, 1, L, 2) (1, Λ, 0, L, 2) Add 1: (2, 0, 1, L, 3) Move left (2, 1, 0, L, 2) Carry (2, Λ, 1, S, halt) Done Find left end of the string: (3, 0, 0, L, 3) (3, 1, 1, L, 3) (3, Λ, Λ, R, halt) Done

14 Quiz How would you construct a TM to add 5 to a binary number? One Solution: Add 1, move back to right end, and then use the preceding solution. For this purpose, let the start state be 4. Add 1: (4, 0, 1, R, 5) Move right (4, 1, 0, L, 4) Carry (4, Λ, 1, R, 5) Move right Find right end of the string: (5, 0, 0, R, 5) (5, 1, 1, R, 5) (5, Λ, Λ, L, 0) Go add 4

15 Example/Quiz Find a TM to move any string over {a, b} to the left one cell position. Assume the tape head ends at the left end of any nonempty output string. Solution. Let the start state be 0. Find a or b to move: (0, a, Λ, L, 1) Go write a (0, b, Λ, L, 2) Go write b (0, Λ, Λ, L, 4) Done Write a or b: (1, Λ, a, R, 3) Write a (2, Λ, b, R, 3) Write b (3, Λ, Λ, R, 0) Skip Λ Move to left end of output: (4, Λ, Λ, L, 5) (5, a, a, L, 5) (5, b, b, L, 5) (5, Λ, Λ, R, halt).

16 A trace for input aba (tape head is underlined): Λ a b a Λ (0, a, Λ, L, 1) Λ Λ b a Λ (1, Λ, a, R, 3) a Λ b a Λ (3, Λ, Λ, R, 0) a Λ b a Λ (0, b, Λ, L, 2) a Λ Λ a Λ (2, Λ, b, R, 3) a b Λ a Λ. (3, Λ, Λ, R, 0) a b Λ a Λ (0, a, Λ, L, 1) a b Λ Λ Λ (1, Λ, a, R, 3) a b a Λ Λ (3, Λ, Λ, R, 0) a b a Λ Λ (0, Λ, Λ, L, 4) a b a Λ Λ (4, Λ, Λ, L, 5) a b a Λ Λ (5, a, a, L, 5) a b a Λ Λ (5, b, b, L, 5) a b a Λ Λ (5, a, a, L, 5) Λ a b a Λ Λ (5, Λ, Λ, R, halt) Λ a b a Λ Λ Output.

17 Quiz (Exercise 2). Find a TM to search for the symbol # on an otherwise empty tape, where the tape head starts at a random cell. A Solution: Use a new symbol, say x, to mark cells that have been searched as the machine alternately looks left and right. A Sample Trace: # Λ Λ Λ Λ # Λ x Λ Λ # x x Λ Λ # x x x Λ # x x x Λ.

18 Alternative Definitions of Turing Machine

19 Quiz Why are they all equal in power to the original definition of a Turing machine? An n-head or n-tape instruction contains n- tuples for the cell contents and move operations. Example. A typical instruction for a 2-head or a 2-tape TM is (0, (a, b), (c, d), (L, R), 1).

20 Example/Quiz Implement some sample PDA instructions as TM instructions for a 2-tape TM. Assume one tape holds the input string and the other tape holds the stack. Assume the input is scanned left to right and the stack grows from right to left.

21 Sample Instructions PDA Instruction: 1. (i, a, X, nop, j) 2. (i, a, X, pop, j) 3. (i, a, X, push(Y), j) 4. (i, Λ, X, pop, j). TM Instruction: 1. (i, (a, X), (a, X), (R, S), j) 2. (i, (a, X), (a, Λ), (R, R), j) 3. (i, (a, X), (a, X), (S, L), k) and (k, (a, Λ), (a, Y), (R, S), j) 4. For each letter a: (i, (a, X), (a, Λ), (S, R), j).

22 Nondeterministic Turing Machines Example. Generate an arbitrary string over {a, b} of length n. Solution: Assume the input is any string over {a, b} of length n. The tape head is at the right end of the output string. (0, a, a, R, 0) (0, a, b, R, 0) (0, b, a, R, 0) (0, b, b, R, 0) (0, Λ, Λ, L, halt).

23 Nondeterministic TMs have the same power as deterministic TMs The idea: Any nondeterministic TM can be simulated by a deterministic TM that simulates all 1-step computations, then all 2-step computations, and so on. The process stops if some computation enters the halt state.

24 The End of Section 13-1