Академический Документы
Профессиональный Документы
Культура Документы
Finishing Minimization,
The Myhill-Nerode Theorem,
and Streaming Algorithms
1
DFA Minimization Theorem:
2
Extending transition function δ to strings
Given M = (Q, Σ, δ, q0, F), we can extend δ to a
function ∆ : Q × Σ* → Q that works on strings:
∆(q, ε) = q
∆(q, σ) = δ(q, σ)
∆(q, σ1 …σk+1 ) = δ( ∆(q, σ1 …σk ), σk+1 )
∆(q, w) = the state of M reached after reading in w,
starting from state q
Note: ∆(q0, w) ∈ F ⇔ M accepts w
Def. w ∈ Σ* distinguishes states q1 and q2 iff
∆(q1, w) ∈ F ⇔ ∆(q2, w) ∉ F
3
Extending transition function δ to strings
Given M = (Q, Σ, δ, q0, F), we can extend δ to a
function ∆ : Q × Σ* → Q that works on strings:
∆(q, ε) = q
∆(q, σ) = δ(q, σ)
∆(q, σ1 …σk+1 ) = δ( ∆(q, σ1 …σk ), σk+1 )
∆(q, w) = the state of M reached after reading in w,
starting from state q
Note: ∆(q0, w) ∈ F ⇔ M accepts w
Def.ww∈∈Σ*
Def. Σ*distinguishes
distinguishesstates
statesqq1 1and
andqq2 2 iff
iff
exactlyone
exactly oneof ∆(q11,,w),
of∆(q ∆(q22,,w)
w),∆(q w)isisaafinal
finalstate
state
4
Fix M = (Q, Σ, δ, q0, F) and let p, q ∈ Q
Definition:
State p is distinguishable from state q
iff there is w ∈ Σ* that distinguishes p and q
iff there is w ∈ Σ* so that
exactly one of ∆(p, w), ∆(q, w) is a final state
5
Fix M = (Q, Σ, δ, q0, F) and let p, q, r ∈ Q
Define a binary relation ∼ on the states of M:
p ∼ q iff p is indistinguishable from q
p ≁ q iff p is distinguishable from q
6
Fix M = (Q, Σ, δ, q0, F) and let p, q, r ∈ Q
[q] := { p | p ~ q }
Q
q
q0
7
Algorithm: MINIMIZE-DFA
Input: DFA M
Output: DFA MMIN such that:
L(M) = L(MMIN)
MMIN has no inaccessible states
MMIN is irreducible
||
For all states p ≠ q of MMIN, p and q are distinguishable
Theorem: MMIN is the unique minimal DFA
that is equivalent to M
8
The Table-Filling Algorithm
Input: DFA M = (Q, Σ, δ, q0, F)
Output: (1) DM = { (p, q) | p, q ∈ Q and p ~
/ q}
(2) EQUIVM = { [q] | q ∈ Q }
q0
Base Case: For all (p, q) such that
q1
p accepts and q rejects ⇒ p /~ q
Iterate: If there are states p, q and
qi D D symbol σ ∈ Σ satisfying:
δ (p, σ) = p′
qn D ~/ ⇒ p ~/ q
q0 q1 qi qn δ (q, σ) = q′
Repeat until no more D’s can be added9
Algorithm MINIMIZE
Input: DFA M
Output: Equivalent minimal-state DFA MMIN
1. Remove all inaccessible states from M
2. Run Table-Filling algorithm on M to get:
EQUIVM = { [q] | q is an accessible state of M }
3. Define: MMIN = (QMIN, Σ, δMIN, q0 MIN, FMIN)
QMIN = EQUIVM, q0 MIN = [q0], FMIN = { [q] | q ∈ F }
δMIN( [q], σ ) = [ δ( q, σ ) ]
Claim: L(MMIN) = L(M)
10
1 0 0,1
0
q0 q1 q4
1 1
0,1 0 0 q5
q0
q1 q2 1
D q3
q3 D D
q4 D D
q5 D D D D
q0 q1 q3 q4 q5 11
1 0 0,1
0
q0 q1 q4
1 1
0 0 q5
q0
q1 D q3
q3 D D
q4 D D
q5 D D D D
q0 q1 q3 q4 q5 12
Thm: MMIN is the unique minimal DFA equivalent to M
Claim: Suppose L(M′)=L(MMIN) and M′ has no
inaccessible states and M’ is irreducible.
Then there is an isomorphism between M′ and MMIN
14
Base Case: q0 MIN a q0′
Recursive Step: If p a p′
σ σ Then q a q′
q q′
15
Base Case: q0 MIN a q0′
Recursive Step: If p a p′
σ σ Then q a q′
q q′
18
Suppose there are states q′ and q′′ such that
q a q′ and q a q′′
Now suppose q′ and q′′ are distinguishable…
MMIN M′
Accept
Accept
u w u w
q0 MIN q q0′ q′
Contradiction!
v w v w
Reject
Reject
Accept
u w u w
q0 MIN p q0′ q′
Contradiction!
v w v w
Reject
Reject
q0 MIN q q0′ q′
21
How can we prove that two regular
expressions are equivalent?
22
The Myhill-Nerode Theorem
23
In DFA Minimization, we defined
an equivalence relation between states.
We can also define a similar equivalence relation
over strings and languages:
Let L ⊆ Σ* and x, y ∈ Σ*
x ≡L y iff for all z ∈ Σ*, [xz ∈ L yz ∈ L]
L is not regular
if and only if
there are infinitely many equiv. classes of ≡L
28