A pushdown automaton that recognizes the negation of a language

3.4k views Asked by At

As an example:

Say I want to design a PDA that recognizes the language of all strings over the alphabet {1,0} that are NOT palindromes. If I design a PDA that recognizes the language of all strings over the {1,0} that are palindromes and then swap all accept states for fail states and vice versa will I get the desired PDA?

EDIT: Is there a simple formal proof either way?

1

There are 1 answers

0
rici On BEST ANSWER

The set of context-free languages (or PDAs) is not closed under complementation. (There's a simple demonstration in the answer to What is the context free grammar for the complement of the double word over 0,1?, which constructs a CFG for the complement of {ww|w∈{0,1}*}. The fact that {ww|w∈{0,1}*} is not a CFL is well known.)

Inverting all the states of a state machine works fine for a finite-state automaton (and regular languages are closed under complement), but it won't work for a PDA precisely because of the stack.