The Myhill-Nerode Theoremansuman/flat2018/myhill-nerode-priti.pdfThe Myhill Nerode theorem...

Preview:

Citation preview

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

The Myhill-Nerode Theorem

Priti Shankarpriti@csa.iisc.ernet.in

Department of Computer Science and AutomationIndian Institute of Science

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Outline

1 Equivalence Relations

2 Right Invariance

3 Equivalence Relations Induced by DFA’s

4 The Myhill Nerode theorem

5 Applications of the Myhill Nerode Theorem

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Definition

A binary relation R on a set S is a subset of S × S. Anequivalence relation on a set satisfies

Reflexivity: For all x in S, xRxSymmetry: For x , y ∈ S xRy ⇐⇒ yRxTransitivity: For x , y , z ∈ S xRy and yRz =⇒ xRzEvery equivalence relation on S partitions S intoequivalence classes. The number of equivalenceclasses is called the index of the relation.

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Definition

A binary relation R on a set S is a subset of S × S. Anequivalence relation on a set satisfies

Reflexivity: For all x in S, xRxSymmetry: For x , y ∈ S xRy ⇐⇒ yRxTransitivity: For x , y , z ∈ S xRy and yRz =⇒ xRzEvery equivalence relation on S partitions S intoequivalence classes. The number of equivalenceclasses is called the index of the relation.

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Definition

A binary relation R on a set S is a subset of S × S. Anequivalence relation on a set satisfies

Reflexivity: For all x in S, xRxSymmetry: For x , y ∈ S xRy ⇐⇒ yRxTransitivity: For x , y , z ∈ S xRy and yRz =⇒ xRzEvery equivalence relation on S partitions S intoequivalence classes. The number of equivalenceclasses is called the index of the relation.

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Definition

A binary relation R on a set S is a subset of S × S. Anequivalence relation on a set satisfies

Reflexivity: For all x in S, xRxSymmetry: For x , y ∈ S xRy ⇐⇒ yRxTransitivity: For x , y , z ∈ S xRy and yRz =⇒ xRzEvery equivalence relation on S partitions S intoequivalence classes. The number of equivalenceclasses is called the index of the relation.

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Example 1

Let S = Σ+ where Σ = {a,b}.Define R as xRy whenever x and y both end in thesame symbol of Σ.How many equivalence classes does R partition Sinto?

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Example 1

Let S = Σ+ where Σ = {a,b}.Define R as xRy whenever x and y both end in thesame symbol of Σ.How many equivalence classes does R partition Sinto?

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Example 1

Let S = Σ+ where Σ = {a,b}.Define R as xRy whenever x and y both end in thesame symbol of Σ.How many equivalence classes does R partition Sinto?

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Right invariance

An equivalence relation on Σ∗ is said to be rightinvariant with respect to concatenation if ∀x , y ∈ Σ∗

and a in Σ xRy implies that xaRya.

Example:Let S = Σ∗ where Σ = {a,b} and R be defined asfollows:xRy if x and y have the same number of a′s.How many equivalence classes does R partition Sinto?Is R right invariant?

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Right invariance

An equivalence relation on Σ∗ is said to be rightinvariant with respect to concatenation if ∀x , y ∈ Σ∗

and a in Σ xRy implies that xaRya.

Example:Let S = Σ∗ where Σ = {a,b} and R be defined asfollows:xRy if x and y have the same number of a′s.How many equivalence classes does R partition Sinto?Is R right invariant?

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Right invariance

An equivalence relation on Σ∗ is said to be rightinvariant with respect to concatenation if ∀x , y ∈ Σ∗

and a in Σ xRy implies that xaRya.

Example:Let S = Σ∗ where Σ = {a,b} and R be defined asfollows:xRy if x and y have the same number of a′s.How many equivalence classes does R partition Sinto?Is R right invariant?

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Right invariance

An equivalence relation on Σ∗ is said to be rightinvariant with respect to concatenation if ∀x , y ∈ Σ∗

and a in Σ xRy implies that xaRya.

Example:Let S = Σ∗ where Σ = {a,b} and R be defined asfollows:xRy if x and y have the same number of a′s.How many equivalence classes does R partition Sinto?Is R right invariant?

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Right invariance

An equivalence relation on Σ∗ is said to be rightinvariant with respect to concatenation if ∀x , y ∈ Σ∗

and a in Σ xRy implies that xaRya.

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Equivalence relations induced by DFA’s

Let M = (Q,Σ, δ,q0,F ) be a DFA.Define a relation RM as follows:For x , y ∈ Σ∗ xRMy ⇐⇒ δ(q0, x) = δ(q0, y)

Is this an equivalence relation?If so how many equivalence classes does it have?That is, what is its index?

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Equivalence relations induced by DFA’s

Let M = (Q,Σ, δ,q0,F ) be a DFA.Define a relation RM as follows:For x , y ∈ Σ∗ xRMy ⇐⇒ δ(q0, x) = δ(q0, y)

Is this an equivalence relation?If so how many equivalence classes does it have?That is, what is its index?

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Equivalence relations induced by DFA’s

Let M = (Q,Σ, δ,q0,F ) be a DFA.Define a relation RM as follows:For x , y ∈ Σ∗ xRMy ⇐⇒ δ(q0, x) = δ(q0, y)

Is this an equivalence relation?If so how many equivalence classes does it have?That is, what is its index?

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Equivalence relations induced by DFA’s

Let M = (Q,Σ, δ,q0,F ) be a DFA.Define a relation RM as follows:For x , y ∈ Σ∗ xRMy ⇐⇒ δ(q0, x) = δ(q0, y)

Is this an equivalence relation?If so how many equivalence classes does it have?That is, what is its index?

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Equivalence relations induced by DFA’s

Let M = (Q,Σ, δ,q0,F ) be a DFA.Define a relation RM as follows:For x , y ∈ Σ∗ xRMy ⇐⇒ δ(q0, x) = δ(q0, y)

Is this an equivalence relation?If so how many equivalence classes does it have?That is, what is its index?

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Example

a,b

b

b

a a a

b

1 2 3 4

C1: All strings notcontaining more than 2consecutive a′s andwhich end in a b.

C2: All strings notcontaining more than 2consecutive a′s andwhich end in aC3: All strings notcontaining more than 2consecutive a′s andwhich end in aaC4: All strings containingat least threeconsecutive a′s

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Example

a,b

b

b

a a a

b

1 2 3 4

C1: All strings notcontaining more than 2consecutive a′s andwhich end in a b.

C2: All strings notcontaining more than 2consecutive a′s andwhich end in aC3: All strings notcontaining more than 2consecutive a′s andwhich end in aaC4: All strings containingat least threeconsecutive a′s

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Example

a,b

b

b

a a a

b

1 2 3 4

C1: All strings notcontaining more than 2consecutive a′s andwhich end in a b.

C2: All strings notcontaining more than 2consecutive a′s andwhich end in aC3: All strings notcontaining more than 2consecutive a′s andwhich end in aaC4: All strings containingat least threeconsecutive a′s

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Example

a,b

b

b

a a a

b

1 2 3 4

C1: All strings notcontaining more than 2consecutive a′s andwhich end in a b.

C2: All strings notcontaining more than 2consecutive a′s andwhich end in aC3: All strings notcontaining more than 2consecutive a′s andwhich end in aaC4: All strings containingat least threeconsecutive a′s

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Refinements of equivalence relationsAn equivalence relation R1 is a refinement of R2 ifR1 ⊆ R2 i.e. (x , y) ∈ R1 =⇒ (x , y) ∈ R2

Figure: R1 equivalence class boundaries–red lines and blacklines, R2 equivalence class boundaries– black lines

Here (x , y) ∈ R1 =⇒ (x , y) ∈ R2Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Example

Here R1 is not a refinement of R2 as (x , y) ∈ R1 does notimply (x , y) ∈ R2

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Example of a refinement of an equivalencerelation

Let S = {0,1}∗

For x , y ∈ S xR1y if x and y have the same parity.xR2y if x and y have the same parity and the samelength.What is the index of R1?What is the index of R2?Is one of them a refinement of the other?

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Example of a refinement of an equivalencerelation

Let S = {0,1}∗

For x , y ∈ S xR1y if x and y have the same parity.xR2y if x and y have the same parity and the samelength.What is the index of R1?What is the index of R2?Is one of them a refinement of the other?

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Example of a refinement of an equivalencerelation

Let S = {0,1}∗

For x , y ∈ S xR1y if x and y have the same parity.xR2y if x and y have the same parity and the samelength.What is the index of R1?What is the index of R2?Is one of them a refinement of the other?

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Example of a refinement of an equivalencerelation

Let S = {0,1}∗

For x , y ∈ S xR1y if x and y have the same parity.xR2y if x and y have the same parity and the samelength.What is the index of R1?What is the index of R2?Is one of them a refinement of the other?

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Example of a refinement of an equivalencerelation

Let S = {0,1}∗

For x , y ∈ S xR1y if x and y have the same parity.xR2y if x and y have the same parity and the samelength.What is the index of R1?What is the index of R2?Is one of them a refinement of the other?

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

Example of a refinement of an equivalencerelation

Let S = {0,1}∗

For x , y ∈ S xR1y if x and y have the same parity.xR2y if x and y have the same parity and the samelength.What is the index of R1?What is the index of R2?Is one of them a refinement of the other?

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

The Myhill Nerode theorem

Let L ⊆ Σ∗. The following statements are equivalent:1 L is recognized by a DFA2 L is the union of some of the equivalence classes of a

right invariant equivalence relation of finite index.3 Define an equivalence relation RL as follows. For

x , y ∈ Σ∗ (x , y) ∈ RL ⇐⇒ ∀z ∈ Σ∗xz ∈ L wheneveryz ∈ L. Then RL has finite index.

To prove this, we need to prove that1 =⇒ 2 =⇒ 3 =⇒ 1

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

The Myhill Nerode theorem

Let L ⊆ Σ∗. The following statements are equivalent:1 L is recognized by a DFA2 L is the union of some of the equivalence classes of a

right invariant equivalence relation of finite index.3 Define an equivalence relation RL as follows. For

x , y ∈ Σ∗ (x , y) ∈ RL ⇐⇒ ∀z ∈ Σ∗xz ∈ L wheneveryz ∈ L. Then RL has finite index.

To prove this, we need to prove that1 =⇒ 2 =⇒ 3 =⇒ 1

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

The Myhill Nerode theorem

Let L ⊆ Σ∗. The following statements are equivalent:1 L is recognized by a DFA2 L is the union of some of the equivalence classes of a

right invariant equivalence relation of finite index.3 Define an equivalence relation RL as follows. For

x , y ∈ Σ∗ (x , y) ∈ RL ⇐⇒ ∀z ∈ Σ∗xz ∈ L wheneveryz ∈ L. Then RL has finite index.

To prove this, we need to prove that1 =⇒ 2 =⇒ 3 =⇒ 1

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

To prove 1 =⇒ 21 L is recognized by a DFA2 L is the union of some of the equivalence classes of a

right invariant equivalence relation of finite index.

Let M = (Q,Σ, δ,q0,F ) be the DFA that recognizes L.The relation RM defined earlier as follows: forx , y ∈ Σ∗ xRMy ⇐⇒ δ(q0, x) = δ(q0, y) is anequivalence relation which is of finite index and isalso right invariant as M is a DFA.L is just the union of the equivalence classescorresponding to the final states of M

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

To prove 1 =⇒ 21 L is recognized by a DFA2 L is the union of some of the equivalence classes of a

right invariant equivalence relation of finite index.

Let M = (Q,Σ, δ,q0,F ) be the DFA that recognizes L.The relation RM defined earlier as follows: forx , y ∈ Σ∗ xRMy ⇐⇒ δ(q0, x) = δ(q0, y) is anequivalence relation which is of finite index and isalso right invariant as M is a DFA.L is just the union of the equivalence classescorresponding to the final states of M

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

To prove 1 =⇒ 21 L is recognized by a DFA2 L is the union of some of the equivalence classes of a

right invariant equivalence relation of finite index.

Let M = (Q,Σ, δ,q0,F ) be the DFA that recognizes L.The relation RM defined earlier as follows: forx , y ∈ Σ∗ xRMy ⇐⇒ δ(q0, x) = δ(q0, y) is anequivalence relation which is of finite index and isalso right invariant as M is a DFA.L is just the union of the equivalence classescorresponding to the final states of M

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

To prove 1 =⇒ 21 L is recognized by a DFA2 L is the union of some of the equivalence classes of a

right invariant equivalence relation of finite index.

Let M = (Q,Σ, δ,q0,F ) be the DFA that recognizes L.The relation RM defined earlier as follows: forx , y ∈ Σ∗ xRMy ⇐⇒ δ(q0, x) = δ(q0, y) is anequivalence relation which is of finite index and isalso right invariant as M is a DFA.L is just the union of the equivalence classescorresponding to the final states of M

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

To prove 1 =⇒ 21 L is recognized by a DFA2 L is the union of some of the equivalence classes of a

right invariant equivalence relation of finite index.

Let M = (Q,Σ, δ,q0,F ) be the DFA that recognizes L.The relation RM defined earlier as follows: forx , y ∈ Σ∗ xRMy ⇐⇒ δ(q0, x) = δ(q0, y) is anequivalence relation which is of finite index and isalso right invariant as M is a DFA.L is just the union of the equivalence classescorresponding to the final states of M

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

We next prove 2 =⇒ 32. L is the union of some of the equivalence classes of a

right invariant equivalence relation of finite index.3. Define an equivalence relation RL as follows. For

x , y ∈ Σ∗ (x , y) ∈ RL ⇐⇒ ∀z ∈ Σ∗xz ∈ L wheneveryz ∈ L. Then RL has finite index.Let E be the equivalence relation in (2). We showthat E is a refinement of RL. Hence since E has finiteindex, so does RL.We show that if (x , y) ∈ E then (x , y) ∈ RL, i.e.E ⊆ RL and hence E is a refinement of RL.(x , y) ∈ E =⇒ ∀z ∈ Σ∗, (xz, yz) ∈ E by repeateduse of right invariance. Hence xz is in an equivalenceclass in L iff yz is, thereby implying that (x , z) ∈ RL.Thus RL has finite index.

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

We next prove 2 =⇒ 32. L is the union of some of the equivalence classes of a

right invariant equivalence relation of finite index.3. Define an equivalence relation RL as follows. For

x , y ∈ Σ∗ (x , y) ∈ RL ⇐⇒ ∀z ∈ Σ∗xz ∈ L wheneveryz ∈ L. Then RL has finite index.Let E be the equivalence relation in (2). We showthat E is a refinement of RL. Hence since E has finiteindex, so does RL.We show that if (x , y) ∈ E then (x , y) ∈ RL, i.e.E ⊆ RL and hence E is a refinement of RL.(x , y) ∈ E =⇒ ∀z ∈ Σ∗, (xz, yz) ∈ E by repeateduse of right invariance. Hence xz is in an equivalenceclass in L iff yz is, thereby implying that (x , z) ∈ RL.Thus RL has finite index.

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

We next prove 2 =⇒ 32. L is the union of some of the equivalence classes of a

right invariant equivalence relation of finite index.3. Define an equivalence relation RL as follows. For

x , y ∈ Σ∗ (x , y) ∈ RL ⇐⇒ ∀z ∈ Σ∗xz ∈ L wheneveryz ∈ L. Then RL has finite index.Let E be the equivalence relation in (2). We showthat E is a refinement of RL. Hence since E has finiteindex, so does RL.We show that if (x , y) ∈ E then (x , y) ∈ RL, i.e.E ⊆ RL and hence E is a refinement of RL.(x , y) ∈ E =⇒ ∀z ∈ Σ∗, (xz, yz) ∈ E by repeateduse of right invariance. Hence xz is in an equivalenceclass in L iff yz is, thereby implying that (x , z) ∈ RL.Thus RL has finite index.

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

We next prove 2 =⇒ 32. L is the union of some of the equivalence classes of a

right invariant equivalence relation of finite index.3. Define an equivalence relation RL as follows. For

x , y ∈ Σ∗ (x , y) ∈ RL ⇐⇒ ∀z ∈ Σ∗xz ∈ L wheneveryz ∈ L. Then RL has finite index.Let E be the equivalence relation in (2). We showthat E is a refinement of RL. Hence since E has finiteindex, so does RL.We show that if (x , y) ∈ E then (x , y) ∈ RL, i.e.E ⊆ RL and hence E is a refinement of RL.(x , y) ∈ E =⇒ ∀z ∈ Σ∗, (xz, yz) ∈ E by repeateduse of right invariance. Hence xz is in an equivalenceclass in L iff yz is, thereby implying that (x , z) ∈ RL.Thus RL has finite index.

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

We next prove 2 =⇒ 32. L is the union of some of the equivalence classes of a

right invariant equivalence relation of finite index.3. Define an equivalence relation RL as follows. For

x , y ∈ Σ∗ (x , y) ∈ RL ⇐⇒ ∀z ∈ Σ∗xz ∈ L wheneveryz ∈ L. Then RL has finite index.Let E be the equivalence relation in (2). We showthat E is a refinement of RL. Hence since E has finiteindex, so does RL.We show that if (x , y) ∈ E then (x , y) ∈ RL, i.e.E ⊆ RL and hence E is a refinement of RL.(x , y) ∈ E =⇒ ∀z ∈ Σ∗, (xz, yz) ∈ E by repeateduse of right invariance. Hence xz is in an equivalenceclass in L iff yz is, thereby implying that (x , z) ∈ RL.Thus RL has finite index.

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

We now prove that 3 =⇒ 13. Define an equivalence relation RL as follows. For

x , y ∈ Σ∗ (x , y) ∈ RL ⇐⇒ ∀z ∈ Σ∗, xz ∈ L wheneveryz ∈ L. Then RL has finite index.

1. L is recognized by a DFA

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

We now prove that 3 =⇒ 13. Define an equivalence relation RL as follows. For

x , y ∈ Σ∗ (x , y) ∈ RL ⇐⇒ ∀z ∈ Σ∗, xz ∈ L wheneveryz ∈ L. Then RL has finite index.

1. L is recognized by a DFA

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

1 Construct a DFA ML = (QL,Σ, δL,q0L,FL).2 We first show that RL is right invariant. To see this

assume that (x , y) ∈ RL. Assume RL is not rightinvariant. Then there exists a ∈ Σ such that(xa, ya) /∈ RL. Let z be a "distinguishing" string for thepair (xa, ya). Then az is a distinguishing string for(x , y) contradicting the assumption that (x , y) ∈ RL.Therefore RL is right invariant.

3 Let [x ] denote the equivalence class containing x .The state set QL = {[x ] : x ∈ Σ∗}. The transitionfunction δL is defined as δL([x ],a) = [xa]. Thedefinition is consistent because had we chosen someother representative [y ] of the equivalence class,[xa] = [ya] by right invariance of RL so the transitionis to the same state of ML.

4 q0L = [ε]; FL = {[x ] : x ∈ L}Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

1 Construct a DFA ML = (QL,Σ, δL,q0L,FL).2 We first show that RL is right invariant. To see this

assume that (x , y) ∈ RL. Assume RL is not rightinvariant. Then there exists a ∈ Σ such that(xa, ya) /∈ RL. Let z be a "distinguishing" string for thepair (xa, ya). Then az is a distinguishing string for(x , y) contradicting the assumption that (x , y) ∈ RL.Therefore RL is right invariant.

3 Let [x ] denote the equivalence class containing x .The state set QL = {[x ] : x ∈ Σ∗}. The transitionfunction δL is defined as δL([x ],a) = [xa]. Thedefinition is consistent because had we chosen someother representative [y ] of the equivalence class,[xa] = [ya] by right invariance of RL so the transitionis to the same state of ML.

4 q0L = [ε]; FL = {[x ] : x ∈ L}Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

1 Construct a DFA ML = (QL,Σ, δL,q0L,FL).2 We first show that RL is right invariant. To see this

assume that (x , y) ∈ RL. Assume RL is not rightinvariant. Then there exists a ∈ Σ such that(xa, ya) /∈ RL. Let z be a "distinguishing" string for thepair (xa, ya). Then az is a distinguishing string for(x , y) contradicting the assumption that (x , y) ∈ RL.Therefore RL is right invariant.

3 Let [x ] denote the equivalence class containing x .The state set QL = {[x ] : x ∈ Σ∗}. The transitionfunction δL is defined as δL([x ],a) = [xa]. Thedefinition is consistent because had we chosen someother representative [y ] of the equivalence class,[xa] = [ya] by right invariance of RL so the transitionis to the same state of ML.

4 q0L = [ε]; FL = {[x ] : x ∈ L}Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

1 Construct a DFA ML = (QL,Σ, δL,q0L,FL).2 We first show that RL is right invariant. To see this

assume that (x , y) ∈ RL. Assume RL is not rightinvariant. Then there exists a ∈ Σ such that(xa, ya) /∈ RL. Let z be a "distinguishing" string for thepair (xa, ya). Then az is a distinguishing string for(x , y) contradicting the assumption that (x , y) ∈ RL.Therefore RL is right invariant.

3 Let [x ] denote the equivalence class containing x .The state set QL = {[x ] : x ∈ Σ∗}. The transitionfunction δL is defined as δL([x ],a) = [xa]. Thedefinition is consistent because had we chosen someother representative [y ] of the equivalence class,[xa] = [ya] by right invariance of RL so the transitionis to the same state of ML.

4 q0L = [ε]; FL = {[x ] : x ∈ L}Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

We need to prove that x ∈ L ⇐⇒ δL(q0L, x) ∈ FL i.e.x is accepted by ML

This is easy as δL(q0L, x) = [x ] and x is accepted byML iff [x ] ∈ FL ⇐⇒ x ∈ L.

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

We need to prove that x ∈ L ⇐⇒ δL(q0L, x) ∈ FL i.e.x is accepted by ML

This is easy as δL(q0L, x) = [x ] and x is accepted byML iff [x ] ∈ FL ⇐⇒ x ∈ L.

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

The MN theorem can be used to show that aparticular language is regular without actuallyconstructing the automaton or to show conclusivelythat a language is not regular.Example. Is the following language regularL1 = {xy : |x | = |y |, x , y ∈ Σ∗} ?Example. What about the languageL2 = {xy : |x | = |y | and y ends with a 1}?Example. What about the languageL3 = {xy : |x | = |y | and y contains a 1}?

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

The MN theorem can be used to show that aparticular language is regular without actuallyconstructing the automaton or to show conclusivelythat a language is not regular.Example. Is the following language regularL1 = {xy : |x | = |y |, x , y ∈ Σ∗} ?Example. What about the languageL2 = {xy : |x | = |y | and y ends with a 1}?Example. What about the languageL3 = {xy : |x | = |y | and y contains a 1}?

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

The MN theorem can be used to show that aparticular language is regular without actuallyconstructing the automaton or to show conclusivelythat a language is not regular.Example. Is the following language regularL1 = {xy : |x | = |y |, x , y ∈ Σ∗} ?Example. What about the languageL2 = {xy : |x | = |y | and y ends with a 1}?Example. What about the languageL3 = {xy : |x | = |y | and y contains a 1}?

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

The MN theorem can be used to show that aparticular language is regular without actuallyconstructing the automaton or to show conclusivelythat a language is not regular.Example. Is the following language regularL1 = {xy : |x | = |y |, x , y ∈ Σ∗} ?Example. What about the languageL2 = {xy : |x | = |y | and y ends with a 1}?Example. What about the languageL3 = {xy : |x | = |y | and y contains a 1}?

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

For the language L1 there are two equivalence classes ofRL1. The first C1 contains all strings of even length andthe second C2 all strings of odd length. All strings z ofodd length when concatenated with any string in C1 takeus to C2, and all strings z of even length whenconcatenated with any string in C1 take us back to C1

which is nothing but L1. Similarly all strings z of evenlength when concatenated with any string of C2 take usback to C2 and all strings of odd length to C1

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

For L2 we have the additional constraint that y ends with a1. Class C2 remains the same as that for L1. Class C1 isrefined into classes C ′1 which contains all strings of evenlength that end in a 1 and C ′′1 which contains all strings ofeven length which end in a 0. Thus L1 and L2 are bothregular.

Priti Shankar The Myhill-Nerode Theorem

Equivalence RelationsRight Invariance

Equivalence Relations Induced by DFA’sThe Myhill Nerode theorem

Applications of the Myhill Nerode Theorem

For L3 we have to distinguish for example, between theeven length strings in the sequence 01, 0001, 000001,...and in general 0i1 for i odd, as 00 distinguishes the firststring from all the others after it in the sequence(concatenation of 00 to 01 gives a string not in L3 butconcatenation of 00 to all the others gives a string in L3),0000 distinguishes the second from all the others after itin the sequence, and in general (00)2i distinguishes the i th

string from all the others after it in the sequence. As thereare an infinite number of strings that can be distinguishedfrom one another, the relation RL has infinite index andtherefore L3 is not regular.

Priti Shankar The Myhill-Nerode Theorem

Recommended