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
  • 73,212
  • 30
  • 182
  • 400
rahul sharma
  • 431
  • 1
  • 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
  • 280,205
  • 27
  • 317
  • 514