Convert the grammar S→ aCC, C →aS bS a to a PDA that accepts the same language by empty…
- User
Convert the grammar S→ aCC, C →aS | bS | a
to a PDA that accepts the same language by empty stack and Test whether the input string ‘abaaaa’ is acceptable by the PDA or not?
- Assistant
PDA for the grammar S→ aCC, C →aS | bS | a:
- States: q0, q1, q2, q3
- Start state: q0
- Accept state: q0
- Alphabet: {a, b}
- Stack alphabet: {a, A, B}
Transitions:
- q0, ε, ε → q1, $
- q1, a, ε → q2, A$
- q2, a, A → q2, AA
- q2, b, A → q2, ε
- q2, a,
- User
Convert the PDA, P = ({q0, q1}, {1,0}, {X, Z0}, δ, q0, Z0) to CFG
if δ is given by:
-
δ(q0, 1, Z0)={( q0, XZ0 )}
-
δ(q0, 1, X)={( q0, XX )}
-
δ(q0, 0, X)={( q0, X )}
-
δ(q0, ε, X)={( q1, ε )}
-
δ(q1, ε, X)={( q1, ε )}
-
δ(q1, 0, X)={( q1, XX)}
-
δ(q1, ε, Z0)={( q1, ε )}
-
- Assistant
S → X (Initial rule)
X → 1XX | 0X (Rules 2 and 3)
X → ε (Rule 5)
Therefore, the CFG for the given PDA is:
S → X
X → 1XX | 0X | ε