HiveBrain v1.2.0
Get Started
← Back to all entries
patternModerate

Construct a PDA for the complement of $a^nb^nc^n$

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
thepdaforcomplementconstruct

Problem

I am wondering if this is even possible, since $\{a^n b^n c^n \mid n \geq 0\} \not\in \mathrm{CFL}$. Therefore a PDA that can distinguish a word $w\in\{a^n b^n c^n \mid n \geq 0\}$ from the rest of $\{a^b^c^*\}$ might as well accept it, which sounds contradictory to me.

I guess I need to take advantage of the non-deterministic nature of PDAs but I'm out of ideas. If you could offer some advice I would very much appreciate it.

Solution

No, this is context-free. To accept $a^nb^nc^n$, you need to make sure that three numbers are equal. To accept $a^b^c^* \setminus a^nb^nc^n$, you just need to make sure that you're in one of the following three cases:

  • The number of $a$s is different from the number of $b$s; or



  • The number of $a$s is different from the number of $c$s; or



  • The number of $b$s is different from the number of $c$s.



Write a PDA for each of these cases, then combine them by jumping nondeterministically to each one from the start state.

Context

StackExchange Computer Science Q#7190, answer score: 17

Revisions (0)

No revisions yet.