Equivalence of DFA and NFA
Minimization of DFA
CS 133 : Automata Theory and Computability Regular Languages and Finite Automata Henry N. Adorna Nestine Hope S. Hernandez Algorithms and Complexity Laboratory Department of Computer Science University of the Philippines, Diliman {hnadorna,nshernandez}@dcs.upd.edu.ph
LEC 2
Equivalence of DFA and NFA
Regular Languages and Finite Automata
Equivalence of DFA and NFA
Minimization of DFA
Minimization of DFA
Equivalence of DFA and NFA
Regular Languages and Finite Automata
Equivalence of DFA and NFA
Minimization of DFA
Minimization of DFA
Equivalence of DFA and NFA
Minimization of DFA
Theorem Every nondeterministic finite automaton(NFA) has an equivalent deterministic finite automaton(DFA).
Equivalence of DFA and NFA
Minimization of DFA
Theorem Every nondeterministic finite automaton(NFA) has an equivalent deterministic finite automaton(DFA).
Proof.
Let N = (Q, Σ, δ, q0 , F ) be the NFA recognizing some language A.
Equivalence of DFA and NFA
Minimization of DFA
Theorem Every nondeterministic finite automaton(NFA) has an equivalent deterministic finite automaton(DFA).
Proof.
Let N = (Q, Σ, δ, q0 , F ) be the NFA recognizing some language A. We construct a DFA M = (Q0 , Σ, δ 0 , q00 , F 0 ) recognizing A. Let’s first consider the easier case wherein N has no ε arrows.
Equivalence of DFA and NFA
Minimization of DFA
Theorem Every nondeterministic finite automaton(NFA) has an equivalent deterministic finite automaton(DFA).
Proof.
Let N = (Q, Σ, δ, q0 , F ) be the NFA recognizing some language A. We construct a DFA M = (Q0 , Σ, δ 0 , q00 , F 0 ) recognizing A. Let’s first consider the easier case wherein N has no ε arrows. 1. Q0 = ℘(Q). 2. For R ∈ Q0 and a ∈ Σ, let δ 0 (R, S a) = {q ∈ Q|q ∈ δ(r, a) for some r ∈ R}. That is, δ 0 (R, a) = δ(r, a) r∈R
3. q00 = {q0 }
4. F 0 = {R ∈ Q0 |R contains an accept state of N }
Example
Equivalence of DFA and NFA
Now, let’s consider the case wherein N may have ε arrows.
Minimization of DFA
Equivalence of DFA and NFA
Minimization of DFA
Now, let’s consider the case wherein N may have ε arrows. For any state R of M, we define E(R) to be the collection of states that can be reached from R by going only along ε arrows, including the members of R themselves. That is, E(R) = {q|q can be reached from R by traveling along 0 or more ε arrows }.
Proof.
Let N = (Q, Σ, δ, q0 , F ) be the NFA recognizing some language A. We construct a DFA M = (Q0 , Σ, δ 0 , q00 , F 0 ) recognizing A. 1. Q0 = ℘(Q).
Equivalence of DFA and NFA
Minimization of DFA
Now, let’s consider the case wherein N may have ε arrows. For any state R of M, we define E(R) to be the collection of states that can be reached from R by going only along ε arrows, including the members of R themselves. That is, E(R) = {q|q can be reached from R by traveling along 0 or more ε arrows }.
Proof.
Let N = (Q, Σ, δ, q0 , F ) be the NFA recognizing some language A. We construct a DFA M = (Q0 , Σ, δ 0 , q00 , F 0 ) recognizing A. 1. Q0 = ℘(Q). 2. For R ∈ Q0 and a ∈ Σ, let δ 0 (R, a) = {q ∈ Q|q ∈ E(δ(r, a)) for some r ∈ R}.
Equivalence of DFA and NFA
Minimization of DFA
Now, let’s consider the case wherein N may have ε arrows. For any state R of M, we define E(R) to be the collection of states that can be reached from R by going only along ε arrows, including the members of R themselves. That is, E(R) = {q|q can be reached from R by traveling along 0 or more ε arrows }.
Proof.
Let N = (Q, Σ, δ, q0 , F ) be the NFA recognizing some language A. We construct a DFA M = (Q0 , Σ, δ 0 , q00 , F 0 ) recognizing A. 1. Q0 = ℘(Q). 2. For R ∈ Q0 and a ∈ Σ, let δ 0 (R, a) = {q ∈ Q|q ∈ E(δ(r, a)) for some r ∈ R}. 3. q00 = E({q0 })
Equivalence of DFA and NFA
Minimization of DFA
Now, let’s consider the case wherein N may have ε arrows. For any state R of M, we define E(R) to be the collection of states that can be reached from R by going only along ε arrows, including the members of R themselves. That is, E(R) = {q|q can be reached from R by traveling along 0 or more ε arrows }.
Proof.
Let N = (Q, Σ, δ, q0 , F ) be the NFA recognizing some language A. We construct a DFA M = (Q0 , Σ, δ 0 , q00 , F 0 ) recognizing A. 1. Q0 = ℘(Q). 2. For R ∈ Q0 and a ∈ Σ, let δ 0 (R, a) = {q ∈ Q|q ∈ E(δ(r, a)) for some r ∈ R}. 3. q00 = E({q0 })
4. F 0 = {R ∈ Q0 |R contains an accept state of N }
Equivalence of DFA and NFA
Minimization of DFA
Now, let’s consider the case wherein N may have ε arrows. For any state R of M, we define E(R) to be the collection of states that can be reached from R by going only along ε arrows, including the members of R themselves. That is, E(R) = {q|q can be reached from R by traveling along 0 or more ε arrows }.
Proof.
Let N = (Q, Σ, δ, q0 , F ) be the NFA recognizing some language A. We construct a DFA M = (Q0 , Σ, δ 0 , q00 , F 0 ) recognizing A. 1. Q0 = ℘(Q). 2. For R ∈ Q0 and a ∈ Σ, let δ 0 (R, a) = {q ∈ Q|q ∈ E(δ(r, a)) for some r ∈ R}. 3. q00 = E({q0 })
4. F 0 = {R ∈ Q0 |R contains an accept state of N }
Equivalence of DFA and NFA
Minimization of DFA
Now, let’s consider the case wherein N may have ε arrows. For any state R of M, we define E(R) to be the collection of states that can be reached from R by going only along ε arrows, including the members of R themselves. That is, E(R) = {q|q can be reached from R by traveling along 0 or more ε arrows }.
Proof.
Let N = (Q, Σ, δ, q0 , F ) be the NFA recognizing some language A. We construct a DFA M = (Q0 , Σ, δ 0 , q00 , F 0 ) recognizing A. 1. Q0 = ℘(Q). 2. For R ∈ Q0 and a ∈ Σ, let δ 0 (R, a) = {q ∈ Q|q ∈ E(δ(r, a)) for some r ∈ R}. 3. q00 = E({q0 })
4. F 0 = {R ∈ Q0 |R contains an accept state of N }
Example
Equivalence of DFA and NFA
Minimization of DFA
Example N2 :
DN2 :
Equivalence of DFA and NFA
Minimization of DFA
Example N2 :
DN2 :
Equivalence of DFA and NFA
Minimization of DFA
Convert an NFA to a DFA
Theorem Every nondeterministic finite automaton(NFA) has an equivalent deterministic finite automaton(DFA). Let N = (Q, Σ, δ, q0 , F ) be the NFA recognizing some language A. We construct a DFA M = (Q0 , Σ, δ 0 , q00 , F 0 ) recognizing A. 1. Q0 = ℘(Q). 2. For R ∈ Q0 and a ∈ Σ, let δ 0 (R, a) = {q ∈ Q|q ∈ E(δ(r, a)) for some r ∈ R}.
3. q00 = E({q0 })
4. F 0 = {R ∈ Q0 |R contains an accept state of N }
Example N1 :
Equivalence of DFA and NFA
Minimization of DFA
Theorem If the language L is recognized by some NFA M0 , then it can also be recognized by some DFA M1 .
Equivalence of DFA and NFA
Minimization of DFA
Theorem If the language L is recognized by some NFA M0 , then it can also be recognized by some DFA M1 .
Corollary A language is regular if and only if some NFA recognizes it.
Equivalence of DFA and NFA
Regular Languages and Finite Automata
Equivalence of DFA and NFA
Minimization of DFA
Minimization of DFA
Equivalence of DFA and NFA
Minimization of DFA
Equivalence of States
Definition We say that states p and q are equivalent if for all input strings ω, ˆ ω) is an accepting state if and only if δ(q, ˆ ω) is an accepting state. δ(p,
Equivalence of DFA and NFA
Minimization of DFA
Equivalence of States
Definition We say that states p and q are equivalent if for all input strings ω, ˆ ω) is an accepting state if and only if δ(q, ˆ ω) is an accepting state. δ(p, If two states are not equivalent, then we say they are distinguishable.
Equivalence of DFA and NFA
Minimization of DFA
Equivalence of States
Definition We say that states p and q are equivalent if for all input strings ω, ˆ ω) is an accepting state if and only if δ(q, ˆ ω) is an accepting state. δ(p, If two states are not equivalent, then we say they are distinguishable. That is, state p is distinguishable from state q if ˆ ω) and δ(q, ˆ ω) is there is at least one string ω such that one of δ(p, accepting, and the other is not accepting.
Equivalence of DFA and NFA
Minimization of DFA
Equivalence of States
Definition We say that states p and q are equivalent if for all input strings ω, ˆ ω) is an accepting state if and only if δ(q, ˆ ω) is an accepting state. δ(p, If two states are not equivalent, then we say they are distinguishable. That is, state p is distinguishable from state q if ˆ ω) and δ(q, ˆ ω) is there is at least one string ω such that one of δ(p, accepting, and the other is not accepting.
Equivalence of DFA and NFA
Minimization of DFA
Table of state inequivalences
Equivalence of DFA and NFA
Minimization of DFA
Minimum-state DFA
Equivalence of DFA and NFA
Minimization of DFA
Another Example
17
Minimize the ff DFA: LANGUAGES HAPTER 3. REGULAR
A
Start
0
0, 1
1
B
E
F
0
1 0
1 C
0, 1
0
1
D
en M ! = M . Next, we let X be the least subset of QM ! × QM ! such that: 1. AM ! × (QM ! − AM ! ) ⊆ X; 2. (QM ! − AM ! ) × AM ! ⊆ X;
3. for all q, q ! , r, r! ∈ QM ! and a ∈ alphabet(M ! ), if (q, r) ∈ X, (q ! , a, q) ∈ TM ! and (r ! , a, r) ∈ TM ! , then (q ! , r! ) ∈ X.
Equivalence of DFA and NFA
Minimization of DFA
Since {B, D} ∈ Z and [δM ! (B, 1)] = [E] = {E, F}, we have Another Example (!B, D", 1, !E, F") ∈ TN .
17
Minimize the ff DFA: LANGUAGES HAPTER 3. REGULAR
• Since {E, F} ∈ Z and [δM ! (E, 0)] = [F] = {E, F}, we have 0, 1 1 (!E, F", 0, !E, F") ∈ TN0 . Start
A
B
E
F
0
1 Since {E, F} ∈ Z and [δM ! (E, 1)] = [F] = {E, F}, we have 0 0 1 (!E, F", 1, !E, F") ∈ TN . 1
Thus our DFA N Cis:
0, 1
D
0
en M ! = M . ! ! Next, we let X be the least 0 subset of1 QM × QM such that: Start
!A"
1. AM ! × (QM ! − AM ! ) ⊆ X;
!B, D"
!E, F"
0, 1
1
0, 1 2. (QM ! − AM ! ) × AM ! ⊆ X;
3. for all q, q ! , r, r! ∈!C" QM ! and a ∈ alphabet(M ! ), if (q, r) ∈ X, (q ! , a, q) ∈ TM ! and (r ! , a, r) ∈ TM ! , then (q ! , r! ) ∈ X.
Equivalence of DFA and NFA
Minimization of DFA
Questions? See you next meeting!