Pushdown Automata (PDAs)

Similar documents
A Bijective Approach to the Permutational Power of a Priority Queue

ITI Introduction to Computing II

Section 8.2 Polar Coordinates

Context-Free Languages

gr0 GRAPHS Hanan Samet

Chapter Eight Notes N P U1C8S4-6

Markscheme May 2017 Calculus Higher level Paper 3

ON INDEPENDENT SETS IN PURELY ATOMIC PROBABILITY SPACES WITH GEOMETRIC DISTRIBUTION. 1. Introduction. 1 r r. r k for every set E A, E \ {0},

October 6, Equivalence of Pushdown Automata with Context-Free Gramm

OSCILLATIONS AND GRAVITATION

Suggested Solutions to Homework #4 Econ 511b (Part I), Spring 2004

New problems in universal algebraic geometry illustrated by boolean equations

Probablistically Checkable Proofs

Sesqui-pushout rewriting

Theory of Computation (IV) Yijia Chen Fudan University

Math 301: The Erdős-Stone-Simonovitz Theorem and Extremal Numbers for Bipartite Graphs

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen

Permutations and Combinations

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Pushdown Automata (2015/11/23)

Part V: Closed-form solutions to Loop Closure Equations

working pages for Paul Richards class notes; do not copy or circulate without permission from PGR 2004/11/3 10:50

gr0 GRAPHS Hanan Samet

CSE 105 THEORY OF COMPUTATION

Lecture 18: Graph Isomorphisms

Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. The stack

1D2G - Numerical solution of the neutron diffusion equation

Chapter 3: Theory of Modular Arithmetic 38

Theory of Computation

Physics 2A Chapter 10 - Moment of Inertia Fall 2018

Lab 10: Newton s Second Law in Rotation

Physics Tutorial V1 2D Vectors

To Feel a Force Chapter 7 Static equilibrium - torque and friction

The Substring Search Problem

( ) [ ] [ ] [ ] δf φ = F φ+δφ F. xdx.

1. Draw a parse tree for the following derivation: S C A C C A b b b b A b b b b B b b b b a A a a b b b b a b a a b b 2. Show on your parse tree u,

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

Likelihood vs. Information in Aligning Biopolymer Sequences. UCSD Technical Report CS Timothy L. Bailey

Harvard CS 121 and CSCI E-207 Lecture 10: Ambiguity, Pushdown Automata

When two numbers are written as the product of their prime factors, they are in factored form.

Syntactical content of nite approximations of partial algebras 1 Wiktor Bartol Inst. Matematyki, Uniw. Warszawski, Warszawa (Poland)

AP-C WEP. h. Students should be able to recognize and solve problems that call for application both of conservation of energy and Newton s Laws.

Fractional Zero Forcing via Three-color Forcing Games

AST 121S: The origin and evolution of the Universe. Introduction to Mathematical Handout 1

Motithang Higher Secondary School Thimphu Thromde Mid Term Examination 2016 Subject: Mathematics Full Marks: 100

CISC4090: Theory of Computation

5 Context-Free Languages

Computational Models - Lecture 4

9.1 The multiplicative group of a finite field. Theorem 9.1. The multiplicative group F of a finite field is cyclic.

Pushdown Automata (Pre Lecture)

10/04/18. P [P(x)] 1 negl(n).

As is natural, our Aerospace Structures will be described in a Euclidean three-dimensional space R 3.

Vanishing lines in generalized Adams spectral sequences are generic

Web-based Supplementary Materials for. Controlling False Discoveries in Multidimensional Directional Decisions, with

Conspiracy and Information Flow in the Take-Grant Protection Model

Do Managers Do Good With Other People s Money? Online Appendix

Computational Models - Lecture 5 1

Introduction to Theory of Computing

MATH 415, WEEK 3: Parameter-Dependence and Bifurcations

CALCULUS II Vectors. Paul Dawkins

Definition: A grammar G = (V, T, P,S) is a context free grammar (cfg) if all productions in P have the form A x where

Solutions to Problem Set 8

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs

CSE 105 THEORY OF COMPUTATION

On a quantity that is analogous to potential and a theorem that relates to it

Many Electron Atoms. Electrons can be put into approximate orbitals and the properties of the many electron systems can be catalogued

arxiv: v1 [math.nt] 12 May 2017

Stanford University CS259Q: Quantum Computing Handout 8 Luca Trevisan October 18, 2012

PUSHDOWN AUTOMATA (PDA)

Power efficiency and optimum load formulas on RF rectifiers featuring flow-angle equations

Supplementary information Efficient Enumeration of Monocyclic Chemical Graphs with Given Path Frequencies

Lecture 16 Root Systems and Root Lattices

CISC 4090 Theory of Computation

arxiv: v1 [math.co] 4 May 2017

Lab #4: Newton s Second Law

A STUDY OF HAMMING CODES AS ERROR CORRECTING CODES

CPS 220 Theory of Computation Pushdown Automata (PDA)

Assignment solution

Locally Evolving Splicing Systems

Surveillance Points in High Dimensional Spaces

Pushdown Automata. Chapter 12

The Strain Compatibility Equations in Polar Coordinates RAWB, Last Update 27/12/07

Electric Charge and Field

Math 2263 Solutions for Spring 2003 Final Exam

HASHING METHODS. Hanan Samet

Chapter 1: Introduction to Polar Coordinates

HOW TO TEACH THE FUNDAMENTALS OF INFORMATION SCIENCE, CODING, DECODING AND NUMBER SYSTEMS?

2. Electrostatics. Dr. Rakhesh Singh Kshetrimayum 8/11/ Electromagnetic Field Theory by R. S. Kshetrimayum

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Goodness-of-fit for composite hypotheses.

ON THE INVERSE SIGNED TOTAL DOMINATION NUMBER IN GRAPHS. D.A. Mojdeh and B. Samadi

Voltage ( = Electric Potential )

Accept or reject. Stack

Phys 201A. Homework 6 Solutions. F A and F r. B. According to Newton s second law, ( ) ( )2. j = ( 6.0 m / s 2 )ˆ i ( 10.4m / s 2 )ˆ j.

Physics 211: Newton s Second Law

(n 1)n(n + 1)(n + 2) + 1 = (n 1)(n + 2)n(n + 1) + 1 = ( (n 2 + n 1) 1 )( (n 2 + n 1) + 1 ) + 1 = (n 2 + n 1) 2.

3.1 Random variables

Classical Worm algorithms (WA)

Geometry of the homogeneous and isotropic spaces

Splay Trees Handout. Last time we discussed amortized analysis of data structures

Transcription:

CHAPTER 2 Context-Fee Languages Contents Context-Fee Gammas definitions, examples, designing, ambiguity, Chomsky nomal fom Pushdown Automata definitions, examples, euivalence with context-fee gammas Non-Context-Fee Languages the pumping lemma fo context-fee languages Theoy of Computation, Feodo F. Dagan, Kent State Univesity 1 Pushdown Automata (PDAs) A new type of computational model. It is like a NFA but has an exta component called stack. The stack povides additional memoy beyond the finite amount available in the contol. The stack allows pushdown automata to ecognize some non-egula languages. Pushdown automata ae euivalent in powe to context-fee gammas. State contol a a b b Schematic of a finite automaton input a a b b Theoy of Computation, Feodo F. Dagan, Kent State Univesity 2 x yz State contol stack A PDA can wite symbols on stack and ead them back late Witing a symbol is pushing, emoving a symbol is popping input Schematic of a pushdown automaton Access to the stack, fo both eading and witing, may be done only at the top (last in, fist out) A stack is valuable because it can hold an unlimited amount of infomation. 1

Example Conside the language n n { 0 1 : n 0}. Finite automaton is unable to ecognize this language. A PDA is able to do this. Infomal desciption how the PDA fo this language woks. Read symbols fom the input. As each 0 is ead, push it into the stack. As soon as 1s ae seen, pop a 0 off the stack fo each 1 ead. If eading the input is finished exactly when the stack becomes empty of 0s, accept the input. If the stack becomes empty while 1s emain o if the 1s ae finished while the stack still contains 0s o if any 0s appea in the input following 1s, eject the input. Theoy of Computation, Feodo F. Dagan, Kent State Univesity 3 A pushdown automaton (PDA) is specified by a 6-tuple Q Σ ( Q, Σ, Γδ, 0, F ) Γ δ : Q Σ Γ Ρ( Q Γ ) 0 Q F Q Fomal Definition of PDAs, whee is a finite set of states, is a finite input alphabet, is a finite stack alphabet, is the tansition function, is the initial state, is the set of final states. Non-deteministic Is a collection of all subsets Σ = ΣU{ } Γ = ΓU{ } It computes as follows: it accepts input w if w can be witten as w = w,,..., 1 w2 wn, whee each w and a seuence of states,,,..., i Σ 0 1 2 n Q and stings * s0, s1, s2,..., s n Γ exist that satisfy the next thee conditions (the stings si epesent the seuence of stack contents that PDA has on the accepting banch of the computation. 1. 0 = 0, s0 = 2. ( i + 1, b) δ ( i, wi + 1, a), i = 0,..., n 1, * whee si = at, si+ 1 = bt fo some b Γ and t Γ. 3. n F Theoy of Computation, Feodo F. Dagan, Kent State Univesity 4 2

Example Conside the language n n { 0 1 : n 0}. M = ( Q, Σ, Γδ,, F) Q = {,, 3, 4} Input: 0 1 Σ = {0,1} Stack: 0 $ 0 $ 0 $ Γ = {0,$} δ : {(,0)} {(3, )} F = {, 4} 3 {(3, )} {(4, )} 4 {(,$)} b c : when the machine is eading an a fom the input it may eplace the symbol b on the top of stack with a c. Any of b, and c may be. a is, the machine may take this tansition without eading any input symbol. b is, the machine may take this tansition without eading and popping any stack symbol. c is, the machine does not wite any symbol on the stack when going along this tansition. 0, 0 1,0 $ 1,0 3 4 Theoy of Computation, Feodo F. Dagan, Kent State Univesity 5 Moe Examples Language i j k { a b c : i, j, k 0 and i = j o i = k}. a b,a c, $ 3 4 b, 5 c,a 6 7 Language { ww R : w {0,1 }*}. $ 0, 0 1,1 1, 1 0,0 3 4 Theoy of Computation, Feodo F. Dagan, Kent State Univesity 6 3

Euivalence with Context-fee Gammas Context-fee gammas and pushdown automata ae euivalent in thei desciptive powe. Both descibe the class of context-fee languages. Any context-fee gamma can be conveted into a pushdown automaton that ecognizes the same language, and vice vesa. We will pove the following esult Theoem. A language is context-fee if and only if some pushdown automaton ecognizes it. This theoem has two diections. We state each diection as a sepaate lemma. Lemma 1. If a language is context-fee, then some pushdown automaton ecognizes it. We have a context-fee gamma G descibing the context-fee language L. We show how to convet G into an euivalent PDA P. The PDA P will accept sting w iff G geneates w, i.e., if thee is a leftmost deivation fo w. Recall that a deivation is simply the seuence of substitution made as a gamma geneates a sting. S S AS A1S 011S 011AS 0110A1S 0110011 0110011 lm lm lm lm lm lm lm S AS A 0A1 A1 01 Theoy of Computation, Feodo F. Dagan, Kent State Univesity 7 How do we check that G geneates 0110011? S A AS 0A1 A1 01 0A11 S 0A111S S AS A1S 011S 011AS 0110A1S 0110011S 0110011 lm lm lm lm lm lm lm A11S 0A1 S 0A11 S 00A11S 0011S 01S 011 01AS... Pomising vaiants Idea We can use stack to stoe an intemediate sting of vaiables and teminals. It is bette to keep only pat (suffix) of the intemediate sting, the symbols stating with the fist vaiable. Any teminal symbols appeaing befoe the fist vaiable ae matched immediately with symbols in the input sting. Use non-deteminism, make copies. Theoy of Computation, Feodo F. Dagan, Kent State Univesity 8 4

Infomal desciption of PDA P 1. Place the make symbol $ and the stat symbol on the stack. 2. Repeat the following steps foeve. a) If top of stack is a vaiable symbol A, non-deteministically select one of the ules fo A and substitute A by the sting on the ight-hand side of the ule. b) If the top of stack is teminal symbol ead the next symbol fom the input and compae it to a. If they match, pop a and epeat. If they do not match, eject on this banch of the non-deteminism. c) If the top of the stack is the symbol $, ente the accept state. Doing so accepts the input if it has all been ead. 0A11 S 0A111S S AS A1S 011S 011AS 0110A1S 0110011S 0110011 lm lm lm lm lm lm lm A11S 0A1 S 0A11 S 00A11S 0011S Theoy of Computation, Feodo F. Dagan, Kent State Univesity 9 Constuction of PDA P stat S$ loop A w fo each ule A w a, a fo each teminal a Sting of teminals and vaiables accept Fo w >1 use extensions s z 1 s xyz y 2 x Theoy of Computation, Feodo F. Dagan, Kent State Univesity 10 5

S T atb b Ta Example stat $ S S b T a T T a loop accept, S b, T a, a b, b Theoy of Computation, Feodo F. Dagan, Kent State Univesity 11 Euivalence with Context-fee Gammas We ae woking on the poof of the following esult Theoem. A language is context-fee if and only if some pushdown automaton ecognizes it. We have poved Lemma 1. If a language is context-fee, then some pushdown automaton ecognizes it. We have shown how to convet a given CFG G into an euivalent PDA P. Now we will conside the othe diection Lemma 2. If a pushdown automaton ecognizes some language, then it is context-fee. We have a PDA P, and want to ceate a CFG G that geneates all stings that P accepts. That is G should geneate a sting if that sting causes the PDA to go fom its stat state to an accept state (takes P fom stat state to an accept state). Theoy of Computation, Feodo F. Dagan, Kent State Univesity 12 6

Example 4 $ 1,0 3 0, 0 1,0 sting 000111 takes P fom stat state to a finite state; sting 00011 does not. Let P be an abitay PDA. Design a Gamma Fo each pai of states p and in P the gamma will contain a vaiable This vaiable will geneate all stings that can take P fom state p with empty stack to with an empty stack Clealy, all those stings can also take P fom p to, egadless of the stack contents at p, leaving the stack at in the same condition as it was at p. A p Theoy of Computation, Feodo F. Dagan, Kent State Univesity 13 Design a Gamma (cont.) Fist we modify P slightly to give it the following thee featues. 1. It has a single accept state, accept....... 2. It empties its stack befoe accepting. 3. Each tansition eithe pushes a symbol onto stack (a push move) o pops one off the stack (a pop move), but does not do both at the same time. b c Theoy of Computation, Feodo F. Dagan, Kent State Univesity 14 b c b b 7

Design a Gamma (ideas) Fo any sting x that take P fom p to, stating and ending with an empty stack, P s fist move on x must be a push; the last move on x must be a pop. (Why?) If the symbol pushed at the beginning is the symbol popped at the end, the stack is empty only at the beginning and the end of P s computation on x. We simulate this by the ule A p aasb, whee a is the input symbol ead at the fist move, b is the symbol ead at the last move, is the state following p, and s the state peceding. t p Else, the initially pushed symbol must get popped at some point befoe the end of x, and thus the stack becomes empty at this point. We simulate this by the ule Ap Ap A, is the state when the stack becomes empty. p Theoy of Computation, Feodo F. Dagan, Kent State Univesity 15 s b,t Let P = Q, Σ, Γ, δ,,{ We constuct G as follows. The vaiables ae The stat vaiable is Rules: ( 0 accept Fomal Design A 0 accept Fo each p,,,s fom Q,, t Γ, b Σ if we have p put the ule A aa b in G. }). { : p, Q} A p t b,t p... s s Fo each p,, fom Q,, put the ule A A A in G. Fo each p fom Q,, put the ule in G. A pp p p Theoy of Computation, Feodo F. Dagan, Kent State Univesity 16 8