Just see the given problem in another perspective.
As add number of a's and b's, and that will equal to number of c's.
So for every a's and b's we will pop c's from the STACK.
First we have to count number of a's and b's that total number should be equal to number of c's.
That we will achieve by pushing a's and b's in STACK and then we will pop a's and b's whenever "c" comes.
So in the end of the strings if nothing is left in the STACK then we can say that language is accepted in the PDA.
We have designed the PDA for the problem:
.png)
STACK Transiton Function
δ(q0, a, Z) = (q0, aZ) δ(q0, a, a) = (q0, aa) δ(q0, b, a) = (q0, ba) δ(q0, b, b) = (q0, bb) δ(q0, c, b) = (q1, ε) δ(q1, c, b) = (q1, ε) δ(q1, c, a) = (q1, ε) δ(q1, ε, Z) = (qf, Z)
Note: qf is Final State
Explanation
Lets see, how this DPDA is working:We will take one input string: "aabbcccc"
- Scan string from left to right
- First input is 'a' and follow the rule:
- on input 'a' and STACK alphabet Z, push the input 'a' into STACK as : (a,Z/aZ) and state will be q0
- Second input is 'a' and so follow the rule:
- on input 'a' and STACK alphabet 'a', push the input 'a' into STACK as : (a,a/aa) and state will be q0
- Third input is 'b' and so follow the rule:
- on input 'b' and STACK alphabet 'a', push the input 'b' into STACK as : (b,a/ba) and state will be q0
- Fourth input is 'b' and so follow the rule:
- on input 'b' and STACK alphabet 'b', push the input 'b' into STACK as : (b,b/bb) and state will be q0
- Fifth input is 'c' and so follow the rule:
- on input 'c' and STACK alphabet 'b' and state is q0, pop one 'b' as : (c,b/ε) and state will be q1
- Sixth input is 'c' and top of STACK is 'b' so follow the rule:
- on input 'c' and STACK alphabet 'b' and state is q1, pop one 'b' as : (c,b/ε) and state remain q1
- Seventh input is 'c' and top of STACK is 'a' so follow the rule:
- on input 'c' and STACK alphabet 'a' and state is q1, pop one 'a' as : (c,a/ε) and state will be q1
- Eighth input is 'c' and top of STACK is 'a' so follow the rule:
- on input 'c' and STACK alphabet 'a' and state is q1, pop one 'a' as : (c,a/ε) and state will be remain q1
- We reached end of the string, so follow the rule:
- on input ε and STACK alphabet Z, go to final state(qf) as : (ε, Z/Z)
The explanation might be looking over descriptive but please be patient, It will all get clear once you start to get along with the explanation.
So we suggest you to keep doing the practice with the steps mentioned in the explnation