Let's say that we have the context-free language L={0^n0^n, n>=0}.
For the PDA: Μ = {A, Q, H, δ, q0, h0, F} we have:
A = {"0"}
H = {X, I}
Q = {S, T}
q0 = S
h0 = X
F = {T}
Then, the δ function is:
___________________________________________________________________
| X | I | -| |
---+------------------------+--------------------------+-------------|
S | read("0")=> push(I) | read("0")=> push(I) | |
| keep=> move(T) | pop | |
---+------------------------+--------------------------+-------------|
T | | | success |
---------------------------------------------------------------------+
That's my solution, but it has a problem. The automaton must accept with strings such as 00, ε, 0000 and not with 0, or 000. Generally with strings that have even number of 0s.
Let's try 2 examples:
->for string 00:
MOVE STACK INPUT STATE DESCRIPTION_OF_MOVE
1 X '0'0 S reading_of 0
2 XI '0' S reading_of 0
3 XII ε S pop
4 XI ε S pop
5 X ε S ε-transition
6 X ε T success
->for string 000:
MOVE STACK INPUT STATE DESCRIPTION_OF_MOVE
1 X '0'00 S reading_of 0
2 XI '0'0 S reading_of 0
3 XII '0' S reading_of 0
4 XIII ε S pop
5 XII ε S pop
6 XI ε S pop
7 X ε S ε-transition
8 X ε T success
The last string shouldn't be accepted. I can't figure out how to check the number of pops before the recognition of the string to choose whether to accept it or not. Has anyone any idea, any clue to trigger me?