Pda CFG
Pda CFG
(b) For each ((p, x, A), (q, X1 X2 · · · Xn )) ∈ ∆ with n > 0 and for all r, q1 , . . . , qn−1 ∈ Q,
the rule
hp, A, ri −→ xhq, X1 , q1 ihq1 , X2 , q2 i · · · hqn−1 , Xn , ri.
(c) For each ((p, x, A), (q, ε)) ∈ ∆ and for all r ∈ Q, the rule
Step-I: Conversion to Simple PDA. All the transitions are satisfying the condition in (1)
but not of (2). So we include the following transitions in ∆.
Step-II: ∗ Construction of CFG from A . We have the following production rules in the
required CFG.
Type (a):
[as q is only final state] S −→ hp, ε, qi (10)
Type(b):
[for (3) with r = p] hp, ε, pi −→ 0hp, 0, pi (11)
∗
One may remove 1 from the Γ as we are not using it in stack, i.e. Γ = {0}. That minimizes the number
of production rules of CFG. In fact, the transitions (7) and (9) can be dropped from ∆. Accordingly, we
will not have the production rules: (17), (18), (19), (20), (23) and (24)
[for (3) with r = q] hp, ε, qi −→ 0hp, 0, qi (12)
Type(c):
[for (4) with r = p] hp, ε, pi −→ hq, ε, pi (25)
Type(d):
[for state p] hp, ε, pi −→ ε (29)
(p, 0011, ε) ` (p, 011, 0) ` (p, 11, 00) ` (q, 11, 00) ` (q, 1, 0) ` (q, ε, ε)
2
Proof Continued. For p, q ∈ Q, A ∈ Γ ∪ {ε} and x ∈ Σ∗ , we claim that
∗ ∗
hp, A, qi =⇒ x if and only if (p, x, A) ` (q, ε, ε).
∗
Since, x ∈ L(G) ⇐⇒ x ∈ L(A ) is equivalent to hq0 , A, qf i =⇒ x if and only if
∗
(q0 , x, A) ` (qf , ε, ε), for some qf ∈ F , the above claim suffices.
∗ ∗
⇒: Assume hp, A, qi =⇒ x. We prove that (p, x, A) ` (q, ε, ε) by induction on the length of
the derivation.
∗
Basis: If the derivation hp, A, qi =⇒ x has only one step then hp, A, qi −→ x is a rule of
∗
type (d). Then A = x = ε and p = q so that (p, x, A) = (q, ε, ε). Hence, (p, x, A) ` (q, ε, ε).
∗ ∗
Inductive hypothesis: If a derivation hp, A, qi =⇒ x has k or fewer steps then (p, x, A) `
(q, ε, ε).
k+1 k
Induction: Assume hp, A, qi =⇒ x and write hp, A, qi =⇒ α =⇒ x. Then the rule
hp, A, qi −→ α is of type (b) or (c) (refer construction part).
α = yhp0 , X1 , p1 i · · · hpn−1 , Xn , pn = qi
∗
so that ((p, y, A), (p0 , X1 · · · Xn )) ∈ ∆. Let x = yy1 · · · yn such that hpi−1 , Xi , pi i =⇒ yi , for
1 ≤ i ≤ n. Thus for each i these derivations are of k or fewer steps so that
∗
(pi−1 , yi , Xi ) ` (pi , ε, ε).
Case-II: hp, A, qi −→ α is of type (c). Then, α = yhr, ε, qi and ((p, y, A), (r, ε)) ∈ ∆,
where x = yz for some z ∈ Σ∗ , so that
∗
(p, x, A) = (p, yz, A) ` (r, z, ε) ` (q, ε, ε).
∗ ∗
⇐: Assume (p, x, A) ` (q, ε, ε). We prove that hp, A, qi =⇒ x by induction on the length of
the computation.
∗
Basis: If a computation (p, x, A) ` (q, ε, ε) has zero steps, then p = q and x = ε = A. Then
∗
the conclusion hp, A, qi =⇒ x holds trivially as hp, ε, pi −→ ε is a type (d) production rule.
∗ ∗
Inductive hypothesis: If a computation (p, x, A) ` (q, ε, ε) has k or fewer steps then hp, A, qi =⇒
x.
k+1
Induction: Suppose (p, x, A) ` (q, ε, ε) and write, for n ≥ 0,
k
(p, x, A) ` (r, z, X1 · · · Xn ) ` (q, ε, ε).
3
Then there is y ∈ Σ∗ such that x = yz and (p, y, A) ` (r, ε, X1 · · · Xn ). This implies that
or
n ≥ 1, A = Bn and ((p, y, ε), (r, X1 · · · Xn−1 )) ∈ ∆.
Since A is a simple the latter case implies the former so that ((p, y, A), (r, X1 · · · Xn )) ∈ ∆,
in any case.
Now, if n ≥ 1, each Xi is eventually removed from the stack via a sequence of states
say r = p0 , p1 , . . . , pn−1 , pn = q by consuming the corresponding input say z1 , . . . , zn , where
z = z1 · · · zn . That is,
Notice each computation (in each iteration) has k or fewer steps. Then, for 0 ≤ i ≤ n, by
∗
inductive hypothesis hpi , Xi+1 , pi+1 i =⇒ zi+1 . Also, since ((p, y, A), (r, X1 · · · Xn )) ∈ ∆, we
have
hp, A, qi −→ yhr = p0 , X1 , p1 ihp1 , X2 , p2 i · · · hpn−1 , Xn , pn = qi
is a production rule of type (b). Thus by combining these we have