§ Myhill Nerode Theorem
- Take a language L over an alphabet A.
- Define x∈A⋆ to have a disginguishing extension from y∈A⋆iff there exists a s∈A⋆ such that either (a) xs∈L∧ys∈L, or xs∈L∧ys∈L
- Said differently, given x and y, there suffix s which can distinguish x and y using the membership oracle for L.
- Now define x∼Ly ( x is indistinguishable from y) iff there is no distinguishing extension between x and y with respect to L.
- See that this is an equivalence relation:
- (1) Reflexivity : x cannot be distinguished from x (using L), because any suffix s cannot produce different outputs for x and x.
- (2) Symmetry : If x cannot be disguished from y (using L), then y cannot be distinguished from x (using L).
- (3) Transitivity : If x cannot be distinguished from y (using L) and y cannot be distinguished from z (using L), then x cannot be distinguished from z (using L). Intuition: What about y in this situation? It can't be indistinguishable from both x and z.
- Proof of Transitivity: Suppose for contradiction x can be distinguished from z. There there is a suffix s such that xs∈L while zs∈L (WLOG). Now what about ys? if ys∈L then we can distinguish yand z, contradicting assumption that y is indistinguishable from z. If y∈L then we can distinguish x from y contradicting assumption that x is indistinguishable from y.
- Hence, being indistinguishable is an equivalence relation, denoted by x∼y.
- Myhill nerode says that the minimal DFA for a language L has as many states as there are equivalence classes for ∼L.
§ Given DFA D of language L over A: ∼D implies ∼L
- Let L be a regular langugage over alphabet A and let D be a DFA (with finite number of states ∣D∣ in the DFA).
- Partition the set of all strings A∗⋆ via the relation ∼D: x∼Dy iff x and y end at the same state when fed to DFA.
- Thus will have ∣D∣ equivalence classes for ∼D, one for each state of the DFA.
- For any two strings such that x∼Dy, given any suffix s, we have that xs∼Dyssince we start at the same state at x (or y) and continue when we feed the suffix s.
- Thus, strings such that x∼Dy are indistinguishable for the DFA.
- So we have x∼Ly, since on any extension, both xs and ys either belong or don't belong to L.
§ given language L over A: show that ∼L implies ∼D.
- Let L be a langugage over alphabet A such that ∼L has finitely many equivalence classes.
- We will design DFA (called D)for L with as many states as equivalence classes.
- The start state of D is the equivalence class of the empty string with respect to ∼L.
- At an equivalence class/state T, given character c∈A, we move to T⋄c (extend Tby c).
- Formally, δ(T,c)≡T⋄c, where T⋄c≡{tc:t∈T}
- This is well defined, as if t∼Lt′ are in the equivalence class T, then we must have tc∼Lt′c.
- Suppose tc is distinguishable from t′c by a suffix s. Then we can distinguish between tand t′ via suffix cs. This contradicts t∼Lt′. Thus we have that t∼Lt implies tc∼Lt′c.
- Thus our transition function δ is well defined over equivalence classes A/∼L.
- A state T in D is accepting if the state contains \emph{any} string l∈L.
- That is, T is accepting iff there exists a l∈L such that l∈T.
- In this case, we infer that T⊆L, or any string in T is accepted by L.
- Suppose for contradiction that l∈L such that l∈T while also having a string z∈T, zinL.
- the empty string would distinguish the two strings l,z which contradicts z∼Llsince they are both in the equivalence class T.
- Thus for a regular language L there is a DFA D which accepts strings from L and has number of states ∣D∣ equal to number of equivalence clases ∣A/∼L∣.
§ DFA needs at least ∣A/∼L∣ states
- Let n≡∣A/∼L∣ be the number of equivalence classes of ∼L.
- Suppose a DFA D recongizes L and has fewer than ∣A/∼L∣ states.
- Let x1,x2,…xn be strings from different equivalence classes of L.
- Push these strings through D. Some two strings xi,xj must land on the state state d∈Dof D (by pigeonhole).
- We must have xi and xj distinguishable, since they come from different equivalence classes. So the DFA must accept one and reject the other.
- But the DFA can't tell the difference between xi and xj since they landed on the same state! So the DFA will accept or reject both.
- Thus, we have a contradiction from the assumptions (a) D has fewer states than n and (b) D recognizes L.
- Thus the DFA needs at least ∣A/∼L∣ states.
§ The two imply DFA minimization
- We have seen that every DFA for L needs at least ∣A/∼L∣ states.
- Now starting from L, we can build an automata D⋆ such that ∣D⋆∣ is exactly ∣A/∼L∣.
- Thus the automata D⋆ is a (the) minimal automata for L.