7

It's known that the complement of a DFA can be easily formed. That is, given a machine $M$, we can construct $M'$ such that $L(M') = \Sigma^* \setminus L(M)$.

Is it possible to construct such a complement for a non-deterministic finite automation (NFA)? To my knowledge, it isn't.

Raphael
  • 73,212
  • 30
  • 182
  • 400
Unni
  • 71
  • 1
  • 1
  • 2

2 Answers2

8

I'm going to assume that you know that there is an equivalence between DFAs and NFAs in the following sense: For every NFA $M$ there exists a DFA $M'$ such that $L(M') = L(M)$. I'm also going to assume that you know how to, given $M$, calculate $M'$. These are standard methods and they (and their proofs) can be found in any good textbook on automata such as: Hopcroft and Ullman

Given these facts the result is almost immediate: Given an NFA $N$ all you have to do is calculate the corresponding DFA $N'$ and use the complement algorithm which you've mentioned you already know. The resulting DFA is an NFA (since DFAs are just special cases of NFAs) which accepts the complement of the language accepted by the NFA you started with.

So to answer your question, yes it is possible to construct such an NFA, however, if you want to do it quickly you may have some problems

Sam Jones
  • 1,151
  • 7
  • 17
8

The language represented by an NFA is regular. The complement of a regular language is regular. Every regular language can be represented by an NFA. Hence NFAs can be "complemented".

More concretely, convert your NFA to a DFA and then complement it.

What you're really asking is, probably, is there a more direct way to complement NFAs. There are examples in which there is a large gap between the NFA complexity of a language and its complement. For example, the language of all words over $\{1,\ldots,n\}$ which don't contain all symbols is accepted by an NFA of size $n$ (or $n+1$ if you don't allow multiple starting states), but its complement needs exponentially many states $2^n$.

Yuval Filmus
  • 280,205
  • 27
  • 317
  • 514