constructing automata from regular languages (original) (raw)

Constructing the automaton

Let Σ be an alphabet and R a subset of Σ*, the set of all words over Σ. Consider an equivalence relation ≡ on Σ* satisfying the following two conditions:

An example of this is the Nerode equivalence 𝒩R of R (in fact, the largest such relationMathworldPlanetmathPlanetmathPlanetmath).

We can construct an automaton A=(S,Σ,δ,I,F) based on ≡. Here’s how:

By condition 1, δ is well-defined, so A is a deterministic automaton. By the second condition above, [u]∈F iff u∈R.

By inductionMathworldPlanetmath, we see that δ⁢([u],v)=[u⁢v] for any word v over Σ. So

u≡v iff δ⁢([u],λ)=δ⁢([v],λ).

One consequence of this is that A is accessiblePlanetmathPlanetmath (all states are accessible).

In additionPlanetmathPlanetmath, R=L⁢(A), as u∈L⁢(A) iff δ⁢([λ],u)∈F iff [u]∈F iff u∈R.

Constructing the equivalence relation

Conversely, given a deterministic automaton A=(S,Σ,δ,{q0},F), a binary relation ≡ on Σ* may be defined:

u≡v iff δ⁢(q0,u)=δ⁢(q0,v).

This binary relation is clearly an equivalence relation, and it satisfies the two conditions above, with R=L⁢(A):

So [u]={v∈S∣δ⁢(q0,v)=δ⁢(q0,u)}.

Remark. We could have defined the binary relation u≡v to mean δ⁢(q,u)=δ⁢(q,v) for all q∈S. This is also an equivalence relation that satisfies both of the conditions above. However, this is stronger in the sense that ≡ is a congruence: if u≡v, then δ⁢(q,w⁢u)=δ⁢(δ⁢(q,w),u)=δ⁢(δ⁢(q,w),v)=δ⁢(q,w⁢v) so that w⁢u≡w⁢v. In this entry, only the weaker assumptionPlanetmathPlanetmath that ≡ is a right congruence is needed.

Characterization

Fix an alphabet Σ and a set R⊆Σ*. Let X the set of equivalence relations satisfying the two conditions above, and Y the set of accessible deterministic automata over Σ accepting R. Define f:X→Y and g:Y→X such that f⁢(≡) and g⁢(A) are the automaton and relation constructed above.

Proposition 1.
Proof.

Suppose ≡1↦fA↦g≡2. Then u≡1v iff δ⁢([u],λ)=δ⁢([v],λ) iff δ⁢([λ],u)=δ⁢([λ],v) iff u≡2v.

Conversely, suppose A1=(S1,Σ,δ1,q1,F2)↦g≡↦fA2=(S2,Σ,δ2,q2,F2). Then S2=Σ*/≡, q2=[λ], and F2 consists of all [u] such that u∈L⁢(A1). As a result, u∈L⁢(A2) iff δ2⁢([λ],u)=δ2⁢(q2,u)∈F2 iff [u]=δ2⁢([u],λ)∈F2 iff u∈L⁢(A1). This shows that A1 is equivalentMathworldPlanetmathPlanetmathPlanetmath to A2.

To show A1 is isomorphic to A2, define ϕ:S2→S1 by ϕ⁢([u])=δ1⁢(q1,u). Then

Thus, ϕ is a homomorphismMathworldPlanetmathPlanetmathPlanetmathPlanetmathPlanetmathPlanetmathPlanetmathPlanetmath from A1 to A2, together with the fact that ϕ is a bijection, A1 is isormorphic to A2. ∎

Proposition 2.

If ≡ is the Nerode equivalence of R, then the f⁢(≡) is a reduced automaton. If A is reduced, then g⁢(A) is the Nerode equivalence of R.

Proof.

Suppose ≡ is the Nerode equivlance. If f⁢(≡) is not reduced, reduce it to a reduced automaton A. Then ≡⊆g(A). Since g⁢(A) satisfies the two conditions above and ≡ is the largest such relation, ≡=g(A). Therefore f⁢(≡)=f⁢(g⁢(A)) is isomorphic to A. But A is reduced, so must f⁢(≡).

On the other hand, suppose A is reduced. Then g⁢(A)⊆𝒩R. Conversely, if u⁢𝒩R⁢v, then u⁢w∈R iff v⁢w∈R for any word w, so that δ⁢(q0,u⁢w)=δ⁢(q0,v⁢w), or δ⁢(δ⁢(q0,u),w)=δ⁢(δ⁢(q0,v),w), which implies δ⁢(q0,u) and δ⁢(q0,v) are indistinguishable. But A is reduced, this means δ⁢(q0,u)=δ⁢(q0,v). As a result u⁢g⁢(A)⁢v, or g⁢(A)=𝒩R. ∎

Definition. A Myhill-Nerode relation for R⊆Σ* is an equivalence relation ≡ that satisfies the two conditions above, and that Σ*/≡ is finite.

Combining from what we just discussed above, we see that a languagePlanetmathPlanetmath R is regularPlanetmathPlanetmath iff its Nerode equivalence is a Myhill-Nerode relation, which is the essence of Myhill-Nerode theorem.