# notes1 - Some notes on the equivalence of npdas and...

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

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.

Unformatted text preview: Some notes on the equivalence of npdas and context-free grammars. Theorem. A language is context-free iff there is an npda that accepts it. This theorem is proved in two Lemmas: Lemma 1 . Let G be a context-free grammar. Then there is an npda M such that L ( M ) = L ( G ) . Lemma 2 . Let M be an npda. Then there is a context-free grammar G such that L ( M ) = L ( G ) . For the proof of Lemma 1, we will describe a procedure which, given a context-free grammar G = ( V, T, S, P ), produces an equivalent npda M = ( Q, , , , q , z, F ). We set Q = { q , q 1 , q f } , F = { q f } , = T , = V T { z } . Now for the function: (1) ( q , , z ) = { ( q 1 , Sz ) } . (2) ( q 1 , w ) ( q 1 , , A ) for all w ( V T ) * and all A V such that A w is in P . (3) ( q 1 , a, a ) = { ( q 1 , ) } for each a . (4) ( q 1 , , z ) = { ( q f , ) } . Example. Let G be the grammar given by: S aSb | A | B | A aA | B bB | bb This grammar is my solution to exercise (6b) from section 5.1. L ( G ) = { a n b m : n 6 = m- 1 } . Let us employ the procedure described above. This will give us an npda M with the following function. ( q , , z ) = { ( q 1 , Sz ) } . ( q 1 , , S ) = { ( q 1 , aSb ) , ( q 1 , A ) , ( q 1 , B ) , ( q 1 , ) } . ( q 1 , , A ) = { ( q 1 , aA ) , ( q 1 , ) } . ( q 1 , , B ) = { ( q 1 , bB ) , ( q 1 , bb ) } . ( q 1 , a, a ) = { ( q 1 , ) } ( q 1 , b, b ) = { ( q 1 , ) } ( q 1 , , z ) = { ( q f , ) } . In order to see that the npda M is equivalent to the grammar G , notice that there is a one-to-one correspondence between left-most derivations of sentences from G and sequences of valid moves of M . Example. Here is a typical derivation from G : S asb aaSbb aaAbb aaaAbb aaabb. Here is the corresponding sequence of valid moves of M : ( q , aaabb, z ) ( q 1 , aaabb, Sz ) ( q 1 , aaabb, aSbz ) ( q 1 , aabb, Sbz ) ( q 1 , aabb, aSbbz ) ( q 1 , abb, Sbbz ) ( q 1 , abb, Abbz ) ( q 1 , abb, aAbbz ) ( q 1 , bb, Abbz ) ( q 1 , bb, bbz ) ( q 1 , b, bz ) ( q 1 , , z ) ( q 1 , , ) accept 1 That is all I will say about Lemma 1. Now let us discuss Lemma 2. Definition. Let M = ( Q, , , , q , z, F ) be an npda. We say that M is in standard reduced form iff (a) M has exactly three states: Q = { q , q 1 , q f } . (b) F = { q f } . (c) There is a symbol S with S 6 = z such that the only clause which involves the state q is the clause: ( q , , z ) = { ( q 1 , Sz ) } . (d) The only -clause which involves the state q f is the clause: ( q 1 , , z ) = { ( q f , ) } ....
View Full Document

## This note was uploaded on 07/17/2011 for the course MAD 3512 taught by Professor Staff during the Spring '07 term at University of Florida.

### Page1 / 9

notes1 - Some notes on the equivalence of npdas and...

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

View Full Document
Ask a homework question - tutors are online