0

Assume language $L$ as follow:- $$ L = \{ a^n b^x c^m d^y | (n=m) \lor (x=y)\} $$ Is it possible to design DPDA/NPDA for this? I know if the condition would have been "and" then it is not possible. But is it possible with "or"?

My approach:- 1. Push all $a$'s to the stack.

  1. At $b$ define non deterministic behavior as follow:-

    2.1. Assume we are checking for $n=m$.So skip all the $b$'s.

    2.1.2.Whenever $c$ is encountered, pop $a$ for $c$.

    2.1.3. When $d$ is encountered check if stack is empty, if yes, then accept else reject.

    2.2. Assume we are checking $x=y$. So push all the $b$'s to the stack. Now when $c$'s are encountered skip them.

    2.2.1. When $d$'s are encountered, count them with $b$'s which are on top of stack.

    2.2.2. When input is finished and stack is empty or contains only $A$, then accept else reject.

Raphael
  • 72,336
  • 29
  • 179
  • 389
rahul sharma
  • 431
  • 5
  • 13

1 Answers1

1

Note that $$ L = \{ a^n b^x c^n d^y : n,x,y \geq 0 \} \cup \{ a^n b^x c^m d^x : n,m,x \geq 0 \}. $$ Try showing that each of these is context-free individually.

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503
  • Thanks.I was making it unnecessarily complex.It must be parsed by NPDA. DPDA will not be able to handle this.Am i correct? – rahul sharma Aug 02 '17 at 18:47
  • This seems right, but requires proof. – Yuval Filmus Aug 02 '17 at 18:48
  • I can use the properties.From your answer i can conclude that the two languages are DCFL, and DCFL are not closed under union.Hence the result(L) is not DCFL. Next in the hierarchy is CFL. And as CFL are closed under union ,hence L is CFL but not DCFL.Will this suffice? – rahul sharma Aug 02 '17 at 18:53
  • This is an awful argument. Try it on the languages ${a}$ and ${b}$, for example (not to mention any DCFL language and itself). – Yuval Filmus Aug 02 '17 at 18:54
  • I did't understand your point. Is my reasoning in the above question wrong?By DCFL are not closed under union i mean ,it may or may not be closed. – rahul sharma Aug 02 '17 at 18:59
  • Exactly. So the argument "the class of DCFL languages isn't closed under union, so the union of these two particular DCFL languages isn't DCFL" isn't valid. – Yuval Filmus Aug 02 '17 at 19:00
  • Yeah.I got that mistake.I don't know how should i prove that it is CFL but not DCFL. I was just trying to implement it in a deterministic manner.But it did'nt seem possible. – rahul sharma Aug 02 '17 at 19:04