We can create PDAs with multiple stacks. At each step we look at the current state, the current input symbol, and the top of each stack.

Similar documents
Lecture 7: Primitive Recursion is Turing Computable. Michael Beeson

TAFL 1 (ECS-403) Unit- V. 5.1 Turing Machine. 5.2 TM as computer of Integer Function

Theory of Computations Spring 2016 Practice Final Exam Solutions

Automata Theory CS F-14 Counter Machines & Recursive Functions

More Simulations. CS154 Chris Pollett Apr 25, 2007.

Theory of Computations Spring 2016 Practice Final

Theory of Programming Languages COMP360

Source of Slides: Introduction to Automata Theory, Languages, and Computation By John E. Hopcroft, Rajeev Motwani and Jeffrey D.

Outline. Language Hierarchy

05. Turing Machines and Spacetime. I. Turing Machines and Classical Computability.

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016

Recursively Enumerable Languages, Turing Machines, and Decidability

CSE 105 THEORY OF COMPUTATION

CSCI 3130: Formal Languages and Automata Theory Lecture 16 The Chinese University of Hong Kong, Fall 2010

Turing Machines. A transducer is a finite state machine (FST) whose output is a string and not just accept or reject.

Midterm Exam II CIS 341: Foundations of Computer Science II Spring 2006, day section Prof. Marvin K. Nakayama

University of Nevada, Las Vegas Computer Science 456/656 Fall 2016

Introduction to Computers & Programming

Problems, Languages, Machines, Computability, Complexity

Skyup's Media. PART-B 2) Construct a Mealy machine which is equivalent to the Moore machine given in table.

The Turing Machine. Unsolvable Problems. Undecidability. The Church-Turing Thesis (1936) Decision Problem. Decision Problems

CMSC351 - Fall 2014, Homework #2

A Characterization of the Chomsky Hierarchy by String Turing Machines

CSE 105 THEORY OF COMPUTATION

CS 125 Section #4 RAMs and TMs 9/27/16

1. [5 points each] True or False. If the question is currently open, write O or Open.

From Theorem 8.5, page 223, we have that the intersection of a context-free language with a regular language is context-free. Therefore, the language

CS 44 Exam #2 February 14, 2001

Turing Machines Part Two

Name: CS 341 Practice Final Exam. 1 a 20 b 20 c 20 d 20 e 20 f 20 g Total 207

Turing Machines, continued

UNIT I PART A PART B

CSE 105 THEORY OF COMPUTATION

6.045J/18.400J: Automata, Computability and Complexity. Practice Quiz 2

In this section we will study problems for which we can prove that there is no algorithm solving them.

(a) R=01[((10)*+111)*+0]*1 (b) ((01+10)*00)*. [8+8] 4. (a) Find the left most and right most derivations for the word abba in the grammar

The Big Picture. Chapter 3

Theory of Languages and Automata

Enumerations and Turing Machines

Universal Turing Machine Chomsky Hierarchy Decidability Reducibility Uncomputable Functions Rice s Theorem Decidability Continued

Decidable Problems. We examine the problems for which there is an algorithm.

1 Parsing (25 pts, 5 each)

Theory of Computer Science

CIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions)

Computability via Recursive Functions

Introduction to the Theory of Computation, Sipser, PWS, ISBN X, 1996

arxiv: v1 [cs.cc] 9 Jan 2015

Computer Sciences Department

ECS 120 Lesson 16 Turing Machines, Pt. 2

Turing Machine Languages

Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

Specifying Syntax COMP360

20 Models Of Computation

pp Variants of Turing Machines (Sec. 3.2)

CSE 105 THEORY OF COMPUTATION

COMPUTABILITY THEORY AND RECURSIVELY ENUMERABLE SETS

EECE.3170: Microprocessor Systems Design I Summer 2017 Homework 4 Solution

ONE-STACK AUTOMATA AS ACCEPTORS OF CONTEXT-FREE LANGUAGES *

COMP Logic for Computer Scientists. Lecture 25

CS 275 Automata and Formal Language Theory. First Problem of URMs. (a) Definition of the Turing Machine. III.3 (a) Definition of the Turing Machine

Pushdown Automata. A PDA is an FA together with a stack.


Parsing Scheme (+ (* 2 3) 1) * 1

CpSc 421 Final Solutions

Chapter 2 Instruction Set Architecture

where is the transition function, Pushdown Automata is the set of accept states. is the start state, and is the set of states, is the input alphabet,

Closure Properties of CFLs; Introducing TMs. CS154 Chris Pollett Apr 9, 2007.

Subroutines. int main() { int i, j; i = 5; j = celtokel(i); i = j; return 0;}

CS21 Decidability and Tractability

p x i 1 i n x, y, z = 2 x 3 y 5 z

CS6160 Theory of Computation Problem Set 2 Department of Computer Science, University of Virginia

COMP 382: Reasoning about algorithms

Variants of Turing Machines

III. Supplementary Materials

Final Course Review. Reading: Chapters 1-9

I have read and understand all of the instructions below, and I will obey the Academic Honor Code.

Theory Bridge Exam Example Questions Version of June 6, 2008

Designing Sequential Logic Sequential logic is used when the solution to some design problem involves a sequence of steps:

Semantics of COW. July Alex van Oostenrijk and Martijn van Beek

CHAPTER 4. COMPUTABILITY AND DECIDABILITY

Assembly Language Manual for the STACK Computer

THEORY OF COMPUTATION

Lecture T4: Computability

4.1 Review - the DPLL procedure

Introduction to Automata Theory. BİL405 - Automata Theory and Formal Languages 1

CSCI 340: Computational Models. Turing Machines. Department of Computer Science

MATH Iris Loeb.

PDA s. and Formal Languages. Automata Theory CS 573. Outline of equivalence of PDA s and CFG s. (see Theorem 5.3)

Stack. 4. In Stack all Operations such as Insertion and Deletion are permitted at only one end. Size of the Stack 6. Maximum Value of Stack Top 5

Ling/CSE 472: Introduction to Computational Linguistics. 4/6/15: Morphology & FST 2

CMPT 125: Practice Midterm Answer Key

CISC 4090 Theory of Computation

(a) Give inductive definitions of the relations M N and M N of single-step and many-step β-reduction between λ-terms M and N. (You may assume the

Formal Grammars and Abstract Machines. Sahar Al Seesi

Post's Correspondence Problem. An undecidable, but RE, problem that. appears not to have anything to do with. TM's.

CSE-321 Programming Languages 2010 Midterm

COMP 250 Winter stacks Feb. 2, 2016

CMPSCI 250: Introduction to Computation. Lecture #14: Induction and Recursion (Still More Induction) David Mix Barrington 14 March 2013

Definition 2.8: A CFG is in Chomsky normal form if every rule. only appear on the left-hand side, we allow the rule S ǫ.

Advanced Computing Concepts Slide Set 1-5. Turing machines

Transcription:

Other Automata

We can create PDAs with multiple stacks. At each step we look at the current state, the current input symbol, and the top of each stack. From all of this information we decide what state to transition to and what to write on each stack.

Theorem: A TM can simulate a PDA with k stacks. Proof: Use a TM with k+1 tapes: one for the input, the other tapes each representing one stack. Theorem: A PDA with 2 stacks can simulate a TM. Proof: Suppose the current configuration is 10BXq00Y We will store this as X B 0 0 0 1 Y Z 0 Z 0 stack 1 stack 2

The current tape symbol is always at the top of stack 2; the symbol to its left is at the top of stack 1. We move Left on the tape by popping stack 1 onto stack 2; we move Right by popping stack 2 onto stack 1. The PDA controller can simulate the actions of the TM controller: read the tape symbol (top of stack 2), write a new tape symbol (pop stack 2, push new symbol) and move left or right.

Counter Machines A k-counter machine has a finite state controller and k counters in place of a stack or tape. Each counter is a non-negative integer. The only operations with a counter are Add 1 to the counter Subtract 1 from the counter Test the counter for being 0 Note that we can represent a counter with a stack. To increment the counter push something onto the stack; to decrement the counter pop the stack; to test for 0 ask if the stack is empty.

Theorem: Any language accepted by a 1-counter machine is contextfree. Theorem: Any language accepted by a k-counter machine is recursively enumerable (accepted by a TM) We will now show that we can simulate a TM with a 3-counter machine. We know we can simulate a TM on a PDA with two stacks so we'll show we can simulate the latter with 3 counters.

Suppose the stack alphabet has (r-1) symbols. Identify these symbols with the digits 1...(r-1). (We deliberately don't use 0.) Then represent the stack X 1 X 2... X n Z 0 by X 1 +X 2 r+x 3 r 2 +...+X n r n-1 ; i.e., treat the stack as a number in base r.

For example, suppose we have 9 stack symbols A,B,C,D,E,F,G,H, I, which we identify with 1,2,...9. Then the stack C B B C A Z 0 is represented by 13223.

To push symbol X onto the stack represented by a counter, multiply the counter by r and add X. To pop the stack, divide by r and ignore any remainder. To get the value at the top of the stack, take the counter mod r.

To simulate 2 stacks with 3 counters, we will use 2 counters to represent the contents of the two stacks and keep the other counter free. 1. We can have states that add a fixed number to a counter (by doing that many increments). 2. To multiply a counter A by r, first empty the free counter. Add r to the free counter and decrement A. Again add r to the free counter and decrement A. Continue until A is 0. The free counter now has A*r. Copy this to counter A. 3. To divide counter A by r, first empty the free counter. Decrement A r times then increment the free counter. Repeat until A can't be decremented r times. The value in the free counter is A/r.

4. We need to be able to compute A%r without changing A. Make a cycle of r nodes m 0 m 1... m r-1 m 0. Empty the free counter. Walk around the cycle of nodes at each step decrementing A and incrementing the free counter. When A is empty the free counter has the original value of A and the index i of m i is the value of A%r. So copy the free counter to A and then increment the free counter i times. These operations let us simulate the top, push and pop operations of two stacks with 3 counters.

Theorem: We can simulate a 3-counter machine with just 2 counters. Proof: Suppose the 3 counters have values i, j, k. Represent all three with one counter 2 i 3 j 5 k. a) To increment a counter multiply by 2, 3, or 5. b) To decrement a counter, divide by 2, 3, or 5. c) To determine if a counter is 0, look at the remainder when dividing by 2, 3, or 5. If the remainder is 0, the counter is not 0. Moral: a 2-counter machine is equivalent to a TM.

We can use a TM to simulate a computer Go to the assembly-language level of the computer. Use 4 tapes: One with 2 tracks for memory contents and addresses One for registers, including instruction pointer One for user input One for scratch work The instruction cycle is a) Copy the next instruction onto the scratch tape b) Fetch the arguments c) Perform the instruction d) Store the results All of this can be done on a TM.

We can also simulate a TM on a computer if we have a way to arbitrarily expand its memory. More on this later.

Here are 3 models of computation: A. Turing Machines B. Unrestricted grammars C. Recursive functions (Church, Kleene) -- functions that can be derived primitive functions via composition and recursion These are equivalent in the sense that Any language accepted by a TM can be derived from an unrestricted grammar. Any language derived from a grammar can be "enumerated" by a recursive function in the sense that f(n) is an encoding of the nth string in the language. Any recursive function can be computed by a TM.

Church's Thesis (Turing, Church 1936): Anything we might describe as an algorithm can be implemented on a TM. We say a programming language is Turing Complete if it is powerful enough to simulate a TM. Any algorithm can be implemented in a Turing Complete language.

We can simulate a TM on a computer and a computer on a TM. How do the running times compare? Theorem: There are polynomials p 1 and p 2 so that we can simulate n steps of a program on a computer with O(p 1 (n)) steps on a TM and n steps of a TM with O(p 2 (n)) steps on a computer. Proof: We can simulate a computer with a 4-tape TM. Each move on the computer requires a lookup of data. In n moves we can write at most n values into memory, so each lookup takes at most O(n) steps on the TM. Each move on a 4-tape TM requires looking up the current value at each of the tape heads, which takes time O(n). (continued..)

Altogether, each move on the computer can be simulated in O(n 2 ) moves on a standard TM, so p 1 (n) is n 3. We can simulate a TM on a computer where we represent the tape by two arrays -- one for positive indexes and one for negative indexes. In n steps we can write at most n symbols on the tape, so any index will be between -n and n. If n is huge incrementing and decrementing an index will no longer be constant time but it won't be any worse than O(n). p 2 (n) is n 2. Moral: Any problem solvable on a TM in polynomial time is solvable on a computer in polynomial time, and vice versa.