Let the language be : $$ L = \{ w \in \{a,b\}^* : \#_a(w) = \#_b(w)\}. $$ Now the PDA that I've designed for this language and seen at many other places is :

Let the PDA be denoted by M such that,
M = ({q0,q1}, {a,b}, {z0, a,b}, q0, delta, z0, q1)

Transitions for accepting L:
delta(q0, a, z0) = (q0, az0)
delta(q0, a, a)  = (q0, aa)
delta(q0, b, z0) = (q0, bz0)
delta(q0, b, b)  = (q0, bb)
delta(q0, a, b)  = (q0, epsilon)
delta(q0, b, a)  = (q0, epsilon)
delta(q0, epsilon, z0) = (q1, z0)

Now, if a PDA has to be termed as DPDA, then it should follow the following 2 properties strictly :

 1. delta(q, a, b) will contain atmost 1 element
 2. if delta(q, epsilon, b) != empty_set 
      then, for every input symbol c on state q, 
            delta(q, c, b) == empty_set should hold true 

Source : An Introduction To Formal Languages And Automata 6th Edition, Peter Linz

But the above mentioned PDA contains the following 2 transitions that violate the second condition:

delta(q0, epsilon, z0) = (q1, z0)
delta(q0, a, z0) = (q0, az0)
delta(q0, b, z0) = (q0, bz0)

Issue : According to my understanding of DPDA, this PDA should be a NPDA. But at few places I've seen this PDA marked as DPDA, which I feel is wrong. So can you help me clear this doubt?

  • 1
    $\begingroup$ Your PDA is not deterministic, but it can be turned into one. You should have a way of detecting that you're at an accepting position. $\endgroup$ – Yuval Filmus Oct 27 '19 at 18:30
  • $\begingroup$ The accepting position as in the accepting criteria? According to me, the string will be accepted whenever all of it's symbols have been read and the stack contains only the stack start symbol. Is it correct? $\endgroup$ – Argon Oct 28 '19 at 0:49
  • $\begingroup$ Accepting position means having encountered an identical number of a’s and b’s. $\endgroup$ – Yuval Filmus Oct 28 '19 at 5:32
  • 1
    $\begingroup$ You wrote delta(q0, b, bb) = (q0, bb), is this a typo? $\endgroup$ – Christopher Boo Oct 28 '19 at 12:23
  • $\begingroup$ @ChristopherBoo Yes, it was a typo. Made the edit. Thanks for the correction. $\endgroup$ – Argon Oct 28 '19 at 12:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.