381hw9solns

# 381hw9solns - CS381 Homework#9 Solutions Question 1(6.3.2...

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

CS381, Homework #9 Solutions Question 1 (6.3.2) Convert the following CFG to a PDA S aAA A aS | bS | a The PDA P = ( Q, Σ , Γ , δ, q 0 , Z 0 , F ) is defined as Q = { q } Σ = { a, b } Γ = { a, b, S, A } q 0 = q Z 0 = S F = {} And the transition function is defined as: δ ( q, , S ) = { ( q, aAA ) } δ ( q, , I ) = { ( q, aS ) , ( q, bS ) , ( q, a ) } δ ( q, a, a ) = { ( q, ) } δ ( q, b, b ) = { ( q, ) } 1

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

View Full Document
Homework 9 Exercise 6.3.3 Solutions In the following, S is the start symbol, e stands for the empty string, and Z is used in place of Z 0 . 1. S -> [qZq] | [qZp] The following four productions come from rule (1). 2. [qZq] -> 1[qXq][qZq] 3. [qZq] -> 1[qXp][pZq] 4. [qZp] -> 1[qXq][qZp] 5. [qZp] -> 1[qXp][pZp] The following four productions come from rule (2). 6. [qXq] -> 1[qXq][qXq] 7. [qXq] -> 1[qXp][pXq] 8. [qXp] -> 1[qXq][qXp] 9. [qXp] -> 1[qXp][pXp] The following two productions come from rule (3). 10. [qXq] -> 0[pXq] 11. [qXp] -> 0[pXp] The following production comes from rule (4). 12. [qXq] -> e The following production comes from rule (5). 13. [pXp] -> 1 The following two productions come from rule (6). 14. [pZq] -> 0[qZq] 15. [pZp] -> 0[qZp]
Exercise 7.2.1(b) We will use L to denote the language {a n b n c i | i n}. For any constant n > 0, take a string to be z = a n b n c n . Clearly z ε L. Now the string will be decomposed into z = uvwxy, with vwx ε and |vwx| n. We then have several cases to consider: • vwx ε a + Pump up, and we will have more a’s than b’s. It does not belong to L.

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.