For each n≥1, let Σn be {a1,…,an}, where a1,…,an are different from each other. For a word w∈Σn∗, we write ∣w∣ai for the number of occurrences of ai in w. We define the languages L∀,n and L∃,n over Σn by:
L∀,n={w∈Σn∗∣∣w∣ai is even for every i∈{1,…,n}},
and
L∃,n={w∈Σn∗∣∣w∣ai is even for some i∈{1,…,n}}.
Answer the following questions.
(1) Give a deterministic finite state automaton with 4 states that accepts L∀,2.
(2) Give a non-deterministic finite state automaton with 7 states (without ϵ-transitions) that accepts L∃,3.
(3) Prove that, for every n≥1, every deterministic finite state automaton that accepts L∃,n has at least 2n states.
(4) Prove that, for every n≥1, every non-deterministic finite state automaton (without ϵ-transitions) that accepts L∀,n has at least 2n states.
Use seven states q0,Ea,Oa,Eb,Ob,Ec,Oc. The initial state is q0 and the accepting states are q0,Ea,Eb,Ec. The complete transition table is:
State
a
b
c
q0
{Oa,Eb,Ec}
{Ea,Ob,Ec}
{Ea,Eb,Oc}
Ea
{Oa}
{Ea}
{Ea}
Oa
{Ea}
{Oa}
{Oa}
Eb
{Eb}
{Ob}
{Eb}
Ob
{Ob}
{Eb}
{Ob}
Ec
{Ec}
{Ec}
{Oc}
Oc
{Oc}
{Oc}
{Ec}
After the first symbol, the automaton nondeterministically chooses which letter's parity to track. El and Ol record an even and odd number of occurrences of l, respectively. A word is accepted exactly when at least one tracked count is even. The initial state accepts the empty word, for which every count is zero. Every transition consumes one symbol, so no ϵ-transition is used.
Prove that, for every n≥1, every deterministic finite state automaton that accepts L∃,n has at least 2n states.
For each parity vector u∈{0,1}n, choose a word xu whose parity vector is u. If u=v, append a word z with parity vector 1−u. Then xuz has all counts odd and is rejected, whereas xvz still has at least one even count and is accepted. Thus the 2n words xu are pairwise distinguishable, so every DFA needs at least 2n states.
For each S⊆{1,…,n}, let xS=yS be the word containing one copy of ai for every i∈S. Then xSyS∈L∀,n. For S=T, however, xSyT∈/L∀,n because every letter indexed by S△T occurs once.
Fix an accepting path for each xSyS, and let qS be its state just after xS. If qS=qT for distinct S,T, the prefix of the path for xSyS and the suffix of the path for xTyT form an accepting path for xSyT, a contradiction. Hence all 2n states qS are distinct.