Automata Theory Tutorial on DFA Complement

if (q, ∑, δ, q0, f) be a dfa that accepts a language l, then the complement of the dfa can be obtained by swapping its accepting states with its non-accepting states and vice versa.

we will take an example and elaborate this below −

dfa accepting language l

this dfa accepts the language

l = {a, aa, aaa , ............. }

over the alphabet

∑ = {a, b}

so, re = a+.

now we will swap its accepting states with its non-accepting states and vice versa and will get the following −

dfa accepting complement language l

this dfa accepts the language

ľ = {ε, b, ab ,bb,ba, ............... }

over the alphabet

∑ = {a, b}

note − if we want to complement an nfa, we have to first convert it to dfa and then have to swap states as in the previous method.