2001Lec7 - CSE 2001: Introduction to Theory of Computation...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
2/28/2006 CSE 2001, Winter 2006 1 CSE 2001: Introduction to Theory of Computation Winter 2006 Suprakash Datta datta@cs.yorku.ca Office: CSEB 3043 Phone: 416-736-2100 ext 77875 Course page: http://www.cs.yorku.ca/course/2001 Some of these slides are adapted from Wim van Dam’s slides ( www.cs.berkeley.edu/~vandam/CS172/ ) 2/28/2006 CSE 2001, Winter 2006 2 Next Equivalence of PDA’s, CFL’s Non-CF languages CFL pumping lemma Closure properties of CFLs 2/28/2006 CSE 2001, Winter 2006 3 PDAs and CFL Theorem 2.12 : A language L is context-free if and only of there is a pushdown automata M that recognizes L. Two step proof : 1) Given a CFG G, construct a PDA M G 2) Given a PDA M, make a CFG G M 2/28/2006 CSE 2001, Winter 2006 4 Converting a CFL to a PDA Basic idea • Start with the start symbol • Non-deterministically apply rules • Stop when a string of terminals is left. • Compare with input – accept if match. Detail: • How do you store the intermediate string on the stack? 2/28/2006 CSE 2001, Winter 2006 5 Converting a CFL to a PDA - 2 •In q start , initialize the stack to contain S$ and make an ε -transition to q loop . q loop , if top of stack contains a variable A, replace it with a terminal w for some rule A w • Else, if top of stack contains a terminal w, compare with next input symbol. If unequal, reject. • Else if the top of the stack is $ (empty stack), make an ε -transition to q accept . 2/28/2006 CSE 2001, Winter 2006 6 Converting a PDA to a CFG Basic idea: • For each pair of states p,q use a variable A pq which generates all strings that take the PDA from p to q. • The start variable is A q 0 q accept • Details: Assume that the PDA – Has a single accept state – Empties stack before accepting – Each transition either pops or pushes.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2/28/2006 CSE 2001, Winter 2006 7 Converting a PDA to a CFG - 2 p,q,r,s Q, t ∈Γ , a,b ∈Σ ε , if δ (p,a, ε ) contains (r,t) and if δ (s,b,t) contains (q, ε ) add the rule A pq aA rs b p,q,r Q, add the rule A pq A pr A rq p Q, add the rule A pp → ε 2/28/2006 CSE 2001, Winter 2006 8 Converting a PDA to a CFG - 3 Correctness - Easier direction: If A pq generates x, then x brings PDA P from p with empty stack to q with empty stack.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/11/2010 for the course CSE CSE 2001 taught by Professor N during the Winter '10 term at York University.

Page1 / 6

2001Lec7 - CSE 2001: Introduction to Theory of Computation...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online