1

We can have acceptance with empty stack, but in that case our stack at the start has to have a A in it, otherwise this machine will accept the empty string which is wrong

But can we have a non empty stack at the start? is my method right?

Richard Jones
  • 307
  • 3
  • 11

1 Answers1

2

But can we have a non empty stack at the start?

By the formal definition PDA has the initial stack symbol $Z$ with which a computation starts.

The idea is to use three stack symbols $Z, Z_{even}, Z_{odd}$ to keep track of whether the number of $a$s read so far is even or odd. If the PDA reaches the end of string and topmost symbol is $Z_{odd}$ then empty the stack.

fade2black
  • 9,827
  • 2
  • 24
  • 36
  • Thanks for the answer, so therefore we can have a DPDA which accepts this language with one state for this right? – Richard Jones Sep 26 '17 at 15:43
  • @fade2black, I read that acceptance of DCFL by empty stack is possible only if prefix property is not satisfied. Here if we have a string aaaaa, then prefix of this string(aaa) also belongs to the language so we can't decide when to pop and if we pop all three a's, then we can't read the input further as stack becomes empty and string is accepted. Is that prefix property only valid for DPDA with only one stack symbol ? – Zephyr Oct 08 '17 at 17:51
  • @EdaiBossinShid Sorry for the late reply (just seen after Zephyr's comment). I think better late than never. If we try to design a DPDA with a single state then it must accept by empty stack. But this language does not have the prefix property (see this post) so it is impossible to come up with a DPDA accepting by empty stack. My hint which suggests a PDA with three stack symbols is in not a DPDA. – fade2black Oct 08 '17 at 21:04
  • @Zephyr it does not matter how many stack symbols you use. If a language does not have the prefix property then it cannot be accepted by a DPDA with empty stack (see also this post). – fade2black Oct 08 '17 at 21:07
  • @fade2black Under your answer, there is a comment which says L={b^n ,n>=0} is accepted by DPDA if we have more stack symbols and states. So it means DPDA can have more than one stack symbols. Is it correct? – Zephyr Oct 08 '17 at 21:26
  • @Zephyr which comment? I cannot see a comment saying "L={b^n ,n>=0}...". That said, yes DPDA (also PDA or NPDA) can have any finite number of stack symbols (see this definition). – fade2black Oct 08 '17 at 21:32
  • @fade2black Actually I asked it because you said previously that " a PDA with 3 stack symbols is not a DPDA". – Zephyr Oct 08 '17 at 21:38
  • @fade2black also, it would be great if you could answer this question https://cs.stackexchange.com/questions/82197/pda-prefix-property – Zephyr Oct 08 '17 at 21:39