Home8PDAs

# Home8PDAs - CS 341 Automata Theory Elaine Rich Homework 8...

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

CS 341 Automata Theory Elaine Rich Homework 8 Due Thursday, Oct. 26 1) Prove that the grammar G = {{ S , a , b }, { a , b }, R , S }, where R = { S a S a , S b S b , S ε } correctly defines the language { ww R : w { a , b }*}. 2) Build a PDA for each of the following languages: a) L = { a n b m : m n , m - n is even} (a) L = { x c n : x { a , b }*, # a ( x ) = n or # b ( x ) = n } b) L = { w {0, 1}* : every 0 has a matching 1 somewhere}. No 1 can match more than one 0. So 10, 101011 L , but 001 L . c) L = { a n b m : m n 2 m } d) L = L 1 *, where L 1 = { xx R : x { a , b }*} 3) Show that the CF languages are closed under the operation pref defined on any language L over some alphabet Σ : pref ( L ) = { w : 5 x Σ *, wx L } (Hint: You can do this using either grammars or PDAs. If you choose to use grammars, you may wish to begin by converting the grammar to Chomsky Normal Form.) 4) In class, I asserted that the class of languages accepted by PDAs that accept by accepting state is equivalent to the class accepted by PDAs that accept by accepting state and empty stack. I proved half of that assertion (that for every accepting state/empty stack PDA there is an equivalent accepting state one). Prove the other half. 5) For each of the following grammars G , construct an unambiguous grammar for L ( G ). a) G = ({ S , a , b }, { a , b }, R , S ), where R = S ε S a S a S b S b S SS b) G = ({ S , a , b }, { a , b }, R , S ), where R = S ε S a S a S b S b S a S b S b S a S SS 6) Convert the following grammar to Chomsky normal form: G = ({ S , T , V , a , b , c }, { a , b , c }, R , S ), where R = S a TV a T a T a | b T b | ε | V V c V c | ε

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

View Full Document
CS 341 Automata Theory Elaine Rich Homework 8 Answers (Note: I’ve defined the PDAs here by writing out δ , rather than by drawing diagrams just because it’s hard to draw pictures in a form that can easily be read by everyone. It’s fine for you to draw yours as state transition diagrams.) 1) Prove that the grammar G = {{ S , a , b }, { a , b }, R , S }, where R = { S a S a , S b S b , S ε } correctly defines the language L = { ww R : w { a , b }*}. Show that G generates only strings in L : Let I be st = wS opt w R , for some w { a , b }*. I is true when st = S . It is preserved by each of the three rules (give details). When st is composed exclusively of nonterminals, it must be of the form ww R . So st L . Show that G generates all strings in L : By induction on the length of the string w . If | w | = 0, it can be generated by applying rule 3. Induction hypothesis: All strings in L of length up to k can be generated by G . Show that all strings of length k + 2 can be generated (since all strings in L are of even length). If w is a string of length k + 2 and w L , it can be rewritten as either a x a or b x b , where x L . | x | = k , so, by the induction hypothesis, x can be
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 5

Home8PDAs - CS 341 Automata Theory Elaine Rich Homework 8...

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

View Full Document
Ask a homework question - tutors are online