CS360 A3

CS360 A3 - Assignment 3: solution set prepared by Jalaj...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Assignment 3: solution set prepared by Jalaj Upadhyay Question 1 (a) We first give the grammar and then prove the correctness. S AB B aBb | C bCc | The correctness of the above grammar can be seen by making the following observation: the grammar produces a a or a c if and only if it produces a b; therefore, n a ( x ) + n c ( x ) = n b ( x ) for all x L ( G ) and no x / L ( G ) is produced by the grammar. It also produces all set of a * b * before producing b * c * because of S AB. (b) We first give the grammar and then prove the correctness. S aSc | B | C B bBc | C C cC | c Note that / G ; therefore, there is no production rule that gives just as output. Now we prove the correctness of the above grammar. Let us consider any arbitrary word w L . Since it is in L , the number of c is more than n a ( w )+ n b ( w ) . This can be produced by the grammar by first applying S aSc , n a ( w ) times; then S B once followed by B bBc , n b ( w ) times; and finally B C once followed by C cC to cover the extra c s. Now consider any word w L ( w will have n a ( w ) + n b ( w ) n c ( w ) . However, it is simple to see that G cannot produce such a word because the production rule of S and B has at least one non-terminal output, c ; therefore, there is no way a c is not produced when an a or a b is generated. (c) Let A := { (0 ,Z , Z ) , (1 ,Z , 1 Z ) , (0 , , 00) , (0 , 1 , ) , (1 , , ) , (1 , 1 , 11) } and B := { (1 ,Z , 1 Z ) , (1 , , ) , (1 , 1 , 11) } , where the tuple ( a,b,c ) means that if a is read and b is on the top of the stack, replace it by c . A PDA that accepts L is as follow: ( q s , A ) q s ( q s , B ) q 1 ( q 1 , B ) q 2 ( q 2 , A ) q 2 ( q 2 , ( ,Z ,Z )) q f , where ( a,b ) c means that move to state c when you are in state a and the tuple b is present. The start stateis present....
View Full Document

This note was uploaded on 01/14/2012 for the course CS 360 taught by Professor Johnwatrous during the Winter '08 term at Waterloo.

Page1 / 3

CS360 A3 - Assignment 3: solution set prepared by Jalaj...

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

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