0% found this document useful (0 votes)
62 views29 pages

12 State Minimization

Uploaded by

junioradamec
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views29 pages

12 State Minimization

Uploaded by

junioradamec
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

State Minimization

Athanasios Aris Panagopoulos


Section Summary
• Theorem (Myhill-Nerode)
• ≈L and ∼M Equivalence
• State minimization
• Hopcroft’s algorithm
DFA Minimization
For each regular language, there also exists a minimal automaton that
accepts it, that is, a DFA with a minimum number of states and this DFA is
unique (except that states can be given different names).

➢The minimal DFA ensures minimal computational cost for tasks such as
pattern matching and is typically called canonical.

➢Unlike deterministic finite automata, minimal NFAs may not be unique.


There may be multiple NFAs of the same size which accept the same
regular language, but for which there is no equivalent NFA or DFA with
fewer states.
Equivalence of Strings
Equivalence with respect to L, ≈L
• Let L ⊆ Σ* be a language and let 𝑥, 𝑦 ∈ Σ*
• (𝑥 ≈L 𝑦) if either both strings (𝑥𝑧 and 𝑦𝑧) belong to L or neither is in L
• (𝑥 ≈L 𝑦) if ∀𝑧 ∈ Σ*: 𝑥𝑧 ∈ L  𝑦𝑧 ∈ L
• ≈L is an equivalence relation
Example: ≈L Equivalence
L = (αb ∪ bα)*
Four equivalence classes
1. C1 = (αb ∪ bα)* = L
2. C2 = (αb ∪ bα)* α = Lα
3. C3 = (αb ∪ bα)* b = Lb
4. C4 = (αb ∪ bα)*(αα ∪ bb)(α ∪ b)* = L(αα ∪ bb)Σ*
These classes {C1, C2, C3, C4} partition Σ*
Equivalence of Strings
Equivalence with respect to M, ∼M
• Let M = {K, Σ, δ, s, F} be a deterministic finite automaton and let 𝑥, 𝑦
∈ Σ*
• (𝑥 ∼M y) if they both drive M from s to the same state

• (𝑥 ∼M y) if ∃q ∈ K: (s, 𝑥) ⊢𝑀 (q, e) and (s, 𝑦) ⊢∗𝑀 (q, e)
• ∼M is an equivalence relation
Example: Equivalence ∼M

• six equivalence classes


• Eq1 = (bα)* Eq2 = Lα Eq3 = (bα)*αbL
• Eq4 = (bα)*b Eq5 = L(αα ∪ bb)Σ* Eq6 = αbLb
• (Eq1, Eq2, Eq3, Eq4, Eq5, Eq6) partition of Σ*
Relations ≈L and ∼M
Theorem:
For any deterministic finite automaton M = {K, Σ, δ, s, F} and any strings
x, y ∈ Σ*
(x ∼M y) → (x ≈L(M) y)
• ∼M is a refinement of ≈L(M)
• each equivalence class ∼M is contained in some equivalence class ≈L(M)
• each equivalence class ≈L(M) is the union of one or more equivalence classes
of ∼M
Relation ≈L and ∼M
Proof:

If x ∼M y, let q ∈ K be the unique state that they drive M into ((s, 𝑥) ⊢𝑀
(q(𝑥), e)) then:
1. ∀z ∈ Σ*: 𝑥z ∈ L(M)  (q, 𝑧) ⊢∗𝑀 (𝑓, e), 𝑓 ∈ F
2. ∀z ∈ Σ*: 𝑦𝑧 ∈ L(M)  (q, 𝑧) ⊢∗𝑀 (𝑓, e), 𝑓 ∈ F
Hence:
➢ ∀z ∈ Σ*: 𝑥𝑧 ∈ L(M)  𝑦𝑧 ∈ L(M)
Theorem (Myhill-Nerode)
• Minimum number of states:
|equivalence classes of ≈L(M)| ≤ |equivalence classes of ∼M| =|K|

Theorem (Myhill-Nerode):
Let L ⊆ Σ* be a regular language. Then there exists deterministic finite automaton with precisely as
many states as there are equivalence classes in ≈L that accepts L (canonical or minimal deterministic
finite automaton for L)

Proof by Construction:
• K is the set of equivalence classes under ≈L
• S=[e] is the equivalence class of e under ≈L
• F = the equivalence classes of ≈L that are subsets of L
• δ(C1, 𝜎) = C2,where 𝜎 ∈ Σ, 𝑥 ∈ C1 και 𝑥𝜎 ∈ C2
Myhill-Nerode and Regularity
Corollary (Myhill-Nerode): A language L is regular if and only if ≈L has
finitely many equivalence classes
• what it means for a language L to be regular
• way for proving that a language is not regular

Example: L = {𝑎n bn: n ≥ 1}


• 𝑎i and 𝑎j , with i ≠ j, belong to different equivalent classes since for 𝑧 =
𝑏i, 𝑎i𝑏i ∈ L, while 𝑎j𝑏i ∉ L
• Hence ≈L has infinitely many equivalence classes and is not regular
Equivalence of states
The relation ≡
Let M = {K, Σ, δ, s, F} be a deterministic finite automaton and q, p ∈ K
• (q ≡ p) if q and p behave the same with respect to acceptance
• (q ≡ p) if ∀z ∈ Σ*: (q, 𝑧) ⊢∗𝑀 (𝑓1 , e)  (p, 𝑧) ⊢∗𝑀 (𝑓2 , e)
• The relation ≡ is an equivalence relation
Equivalence of states
• If two states are equivalent (q ≡ p), then the corresponding
equivalence classes of ∼M are subsets of the same equivalent class of
≈L
• the equivalence classes of ≡ are those sets of states of M that must be
clumped together to obtain the canonical automaton of L(M)
• the equivalence classes of ≡ can be computed algorithmically
DFA Minimization
There are three classes of states that can be removed or merged from the
original DFA without affecting the language it accepts.

1. Unreachable states are the states that are not reachable from the initial
state of the DFA, for any input string. These states can be removed.
2. Dead states are the states from which no final state is reachable. These
states can be removed unless the automaton is required to be complete.
3. Nondistinguishable states are those that cannot be distinguished from
one another for any input string. These states can be merged.
DFA Minimization
DFA minimization is usually done in three steps:

1. remove dead and unreachable states (this will accelerate the


following step),
2. merge nondistinguishable states,
3. optionally, re-create a single dead state ("sink" state) if the resulting
DFA is required to be complete.
DFA Minimization
Merging the nondistinguishable states of a DFA is typically based on
partition refinement, partitioning the DFA states into groups by their
behavior.
➢These groups represent equivalence classes whereby every two
states are equivalent if they have the same behavior for every input
sequence.
➢We start with the equivalence 0 that considers two sets: the
accepting and non accepting and we iteratively refine them based on
whether the transitions from any of these states leads to states
outside of the equivalence class.
➢We stop when we cannot refine anymore
DFA Minimization (Hopcroft’s algorithm)
P ← {Κ-F, { F }} Split(S)
while (P is still for each σ ∈ Σ
changing) if σ splits S into
T ← Ø s1 and s2
for each set p ∈ P then return {s1,s2}
T ← T U Split(p) return S
P ← T

Hopcroft minimization algorithm is the fastest known algorithm for this task for general FSAs
Example: DFA Minimization
Minimize the number of states of the given deterministic automaton
Example: DFA Minimization
Solution:
1. Remove all unreachable states
Example: DFA Minimization
Solution: (E stands for ≡ )
1. ≡0 = {𝑞1 , 𝑞3 }, {𝑞2 , 𝑞4 , 𝑞5 , 𝑞6 }
2. Minimize states 2. ≡1 = {𝑞1 , 𝑞3 }, {𝑞2 } {𝑞4 , 𝑞6 } {𝑞5 }
3. ≡2 = {𝑞1 , 𝑞3 }, {𝑞2 } {𝑞4 , 𝑞6 } {𝑞5 }
Practice: DFA Minimization
Minimize the number of states of the given deterministic automaton
Practice: DFA Minimization
Solution
Practice: DFA Minimization
Minimize the number of states of the given deterministic automaton
Practice: DFA Minimization
Solution

1. Remove all unreachable states 2. Minimize states


Practice: DFA Minimization
Minimize the number of states of the given deterministic automaton
Practice: DFA Minimization
Solution

1. Remove all unreachable states 2. Minimize states


Practice: DFA Minimization
Minimize the number of states of the given deterministic automaton

b α, b
α, b
α C α α
F H

A b B E
b α, b
α
b α, b
α D G I
b

α, b J
Practice: DFA Minimization
Solution
1. {A, B, C, D, E}, {F}, {G}, {H, I, J} b F
α α, b
2. {A, B, C, D}, {E}, {F}, {G}, {H, I, J} b
A B C,D α
3. {A, B}, {C, D}, {E}, {F}, {G}, {H, I, J} α, b E
4. {A}, {B}, {C, D}, {E}, {F}, {G}, {H, I, J} b
G
α α,
b
H,I,J
α,
b
References

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy