- 2073 Chaitra
PDA for aⁱbʲcᵏ with i = j + k
Short answer
Push A for each a. Then pop an A for each b or c, using states to enforce order a* b* c*. Accept if stack returns to Z0 at input end. For aaaabbcc, 4 a's equal 2+2, accepted.
Design a PDA that accepts those strings having the total number of 'a' equal to the sum of the number of 'b' and 'c' in the sequence a, b, c (i.e. aⁱbʲcᵏ : i = j + k). Hence test for "aaaabbcc".
L = { aⁱbʲcᵏ : i = j + k, i, j, k ≥ 0 }. The a's must be matched by the b's and the c's together.
Idea: push A for each a. Each b or c pops one A. The string is accepted if the stack returns to Z0 exactly when the input ends. The order abc* is enforced by the states.
M = ({q0, q1, q2, qf}, {a, b, c}, {A, Z0}, δ, q0, Z0, {qf})
| # | Transition | Meaning |
|---|---|---|
| 1 | δ(q0, a, Z0) = {(q0, AZ0)} | push A |
| 2 | δ(q0, a, A) = {(q0, AA)} | push A |
| 3 | δ(q0, b, A) = {(q1, ε)} | first b pops A |
| 4 | δ(q1, b, A) = {(q1, ε)} | each b pops A |
| 5 | δ(q0, c, A) = {(q2, ε)} | no b's: first c pops A |
| 6 | δ(q1, c, A) = {(q2, ε)} | first c pops A |
| 7 | δ(q2, c, A) = {(q2, ε)} | each c pops A |
| 8 | δ(q0, ε, Z0) = δ(q1, ε, Z0) = δ(q2, ε, Z0) = {(qf, Z0)} | accept |
a,A/AA b,A/ε c,A/ε
↺ ↺ ↺
─► (q0) ─b,A/ε─► (q1) ─c,A/ε─► (q2)
└──────── c,A/ε ──────────────▲
each of q0, q1, q2 --ε,Z0/Z0--> ((qf))
(State q0 also reaches qf by ε,Z0/Z0, which accepts the empty string.)
Test for aaaabbcc (i = 4, j = 2, k = 2)
(q0, aaaabbcc, Z0)
⊢ ... 4 moves ... (q0, bbcc, AAAAZ0)
⊢ (q1, bcc, AAAZ0) b
⊢ (q1, cc, AAZ0) b
⊢ (q2, c, AZ0) c
⊢ (q2, ε, Z0) c
⊢ (qf, ε, Z0) accept
aaaabbcc is accepted because 4 = 2 + 2. A string like aaabbcc (3 ≠ 4) exposes Z0 too early with input left, so it is rejected.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- PDA for aⁿb^(3n) · Theory of Computation, chapter 3
- PDA configuration; PDA for a^(3n)b^n · Theory of Computation, chapter 3
- PDA for a^n b^(n+m) c^m · Theory of Computation, chapter 3
- PDA for aⁿb^(2n+1) · Theory of Computation, chapter 3
- PDA for palindromes over {a,b} · Theory of Computation, chapter 3
- PDA for wwᴿ; accept abbbba · Theory of Computation, chapter 3
- Design NFA for strings ending with aba · Discrete Structure, chapter 2
- Design FSA for strings beginning with baa · Discrete Structure, chapter 2
- Design FSA accepting even number of a's · Discrete Structure, chapter 2 · asked 4×
- Design FSA accepting odd number of b's · Discrete Structure, chapter 2 · asked 4×