Let ,
L = W W^R
The language L is a contest free language. So we can construct a push Down automata for L.
There are generally two kinds of push down automata :
- Deterministic push down automata.
2. Non-Deterministic push down automata.
For the above language L Non-Deterministic push down automata is possible.
Here we can construct a PDA that accepts the language L and for the resultant PDA make all non-final states as final states and final state as non-final state.
PDA for W W^R is:
Initially Let q0 be the initial state and qf be the finial state.
∆(q0,0,Z0) = (q0, 0 Z0)
∆(q0,1,Z0) = (q0, 1 Z0)
∆(q0,0,1) = (q0, 01)
∆(q0,1,0) = (q0, 10)
∆(q0,0,0) = (q0, 00) or ∆(q0,0,0) = (q1, 00)
∆(q0,1,1) = (q0, 11) or ∆(q0,1,1) = (q1, 11)
∆(q1,0,0) = (q1,€)
∆(q1,b,b) = (q1,€)
∆(q1,€,Z0) = (qf,Z0)
where
∆ represents state transition.
€ represents pop operation.
The above is the Non-Deterministic PDA which accepts language W W^R.
Now to construct a PDA which do not accept W W^R we need to make the initial state q0,q1 as final states and qf as non final state. And any string which does not reach qf is accepted by the PDA.
The PDA which accepts strings that are not of form W W^R is enclosed below:
PDA for W W^R.
In the above diagram q0,q1 are final states and qf is a non-final state.
Any string which do not reach qf is accepted by PDA and if the string reaches PDA then the string must be rejected by PDA.