# 12 - 12 PA CFG Theorem 1 If a language is context-free then...

This preview shows pages 1–4. Sign up to view the full content.

12: PA CFG Theorem 1 If a language is context-free, then it is accepted by a PA. The proof is a constructive proof. We Frst sketch the idea. We construct a PA from the given C±G as follows: 1. Push the start nonterminal of the C±G onto the stack 2. Repeat the following steps: (a) If the top of the stack is a nonterminal, say A , nonde- terministically select one of the rules for A , and replace A in the stack by the string on the right hand side of the rule (recall: leftmost symbol in the string ends up topmost in the stack). (b) If the top of the stack is a terminal symbol, say a ,read the next symbol from the input and compare it with a . If they match, repeat step (2). If not, reject this branch of non-determinism. Recall: a string is accepted by a PA i² there exists a compu- tation sequence such that when the entire input string is read, the PA is in a Fnal state and the stack is empty. 1

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

View Full Document
PA CFG Proof : Given a CFG G =( V, Σ ,R,S ). Construct the following PA M that accepts L ( G ). M =( { p,q } , Σ ,V, Δ ,p, { q } ) where Δ contains the follow- ing transitions: 1. (( p,e,e ) , ( q,S )) 2. (( q,e,A ) , ( q,x )) for each rule A x in R 3. (( q,a,a ) , ( q,e )) for each a Σ p q e, e -> S e, A -> x a, a -> e 2
The transitions of M are designed such that what is stored in the stack in fact mimics a leftmost derivation of the in-

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 11

12 - 12 PA CFG Theorem 1 If a language is context-free then...

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

View Full Document
Ask a homework question - tutors are online