1 2FLT
transparencies made for
Second Course in Formal Languages and Automata Theory
based on the book by Jeffrey Shallit of the same title
Hendrik Jan Hoogeboom, Leiden http://www.liacs.nl/~hoogeboo/second/ LIACS — Second Course ... I
Chapter 1
Review of Formal Languages and Automata Theory I 1 Chomsky hierarchy
grammar automaton 3 regular right-linear finite state A aB a →
2 context-free A α pushdown → (+lifo stack) 1 context-sensitive
(β ,A,βr) α linear bounded ℓ → α β β α → | |≥| | monotone 0 recursively enumerable α β turing machine → I 2 review of formal languages and automata theory
1.1 Sets 1.2 Symbols, strings, and languages 1.3 Regular expressions and regular languages 1.4 Finite automata 1.5 Context-free grammars and languages 1.6 Turing machines 1.7 Unsolvability 1.8 Complexity theory
Moved to respective chapters LIACS — Second Course ... III
Chapter 3
Finite Automata and Regular Languages III 1 finite automata and regular languages
3.0 Review 3.1 Moore and Mealy machines closure 3.2 Quotients 3.3 Morphisms and substitutions 3.4 Advanced closure properties of regular lan- guages 3.5 Transducers machines 3.6 Two-way finite automata 3.7 The transformation automaton 3.8 Automata, graphs, and Boolean matrices algebra 3.9 The Myhill-Nerode theorem 3.10 Minimization of finite automata 3.11 State complexity 3.12 Partial orders and regular languages 3.0 Review III 2 deterministic finite automaton
= (Q, Σ, δ, q , F ) A 0 finite Q states p, q control δ q Q initial state 0 ∈ p F Q final states Σ ⊆ input alphabet a,b w,x δ : Q Σ Q transition function a × → input tape δ : Q Σ Q ∗ × ∗ → b δ∗(q,ε)= q b p q δ∗(q,xa)= δ( δ∗(q,x), a) a a b L( )= x Σ∗ δ(q0,x) F b A { ∈ | ∈ } r s a a III 3 run
run on aababb b a a b a b b b p q p r s q r q p a a b does not accept b r s a a a b p r p q r p r s q s s q initial state p final states q, s III 4 nondeterministic finite automaton
= (Q, Σ, δ, q , F ) A 0 finite Q states p, q control δ q Q initial state 0 ∈ p F Q final states Σ ⊆ input alphabet a,b w,x δ : Q Σ 2Q transition function a × → input tape δ : Q Σ 2Q ∗ × ∗ → a,b δ (q,ε)= q ∗ { } δ∗(q,xa)= δ(r, a) a,b r δ∗(q,x) 0 a 1 2 ∈ L( )= x Σ δ(q ,x) F = ∅ A { ∈ ∗ | 0 ∩ }
Q Q δ(0, a) = 0, 1 δ′ : 2 Σ 2 (deterministic) { } × → (2 a) = ∅ δ , δ′(U, a)= p U δ(p, a) ∈ III 5 subset construction a,b
a a,b 0 1 2 b b 0 0, 2 { } { } a a b a b b a 0 0 0 0 0 0 0 a b a a a b 1 1 1 0, 1 0, 1, 2 a a b b { } { } 2 2 2 a
0 0 0 0 0 0 0 1 1 1 a,b 2 2 2 1 2 { } { } deterministic δ : 2Q Σ 2Q a,b ′ × → δ′(U, a)= p U δ(p, a) a,b ∈ 1, 2 a,b { } ∅ III 6 nfa regular expression
E E + E E E p 0 q p 0 1 2∗ 3 q
E1 E3 r r
E2 bb a a p q p q a a a+b(aa)*ab b b b b b ab p q b ba a a+ba(aa)*b r s r b(aa)*b bb+ba(aa)*ab a aa III 7 pumping lemma
long words ’loop’ and can be pumped
for every regular language L ∀ there exists a constant n 1 ∃ ≥ such that for every z L ∀ ∈ with z n | |≥ there exists a decomposition z = uvw ∃ with uv n, v 1 | |≤ | |≥ such that for all i 0, uviw L ∀ ≥ ∈
Lemma 1.4.4 III 8 proofs
- clever idea, intuition
- formal construction, specification
- show it works, e.g., induction
once the idea is understood, the other parts might be boring
but essential to test intuition
examples help to get the message III 9 closure properties
RLIN CF MON TYPE0 REG DPDA PDAe DLBA LBA REC RE intersection + – – +++ + complement + + – +++ – union + – + +++ + concatenation + – + +++ + star, plus + – + +++ + ε-free morphism + – + +++ + morphism + – + ––– + inverse morphism + + + +++ + intersect reg lang + + + +++ + mirror + – + +++ + fAFL fAFL AFL AFL AFL fAFL
, c, boolean operations ∩ ∪ , , regular operations ∪ ∗ h, h 1, R (full) trio operations − ∩ 3.1 Moore and Mealy machines 3.2 Quotients III 10 quotient L 1 L , L Σ 1 2 ⊆ ∗ L /L = x Σ xy L for some y L x 1 2 { ∈ ∗ | ∈ 1 ∈ 2 } L2 + + + + Ex. L1 = a bc , L2 = bc , L3 = c + L1/L2 = a + L1/L3 = a bc∗
Ex. Pref(L)= L/Σ∗
Example 3.2.1 and 3.2.5 III 11 quotient L 1 L , L Σ 1 2 ⊆ ∗ L /L = x Σ xy L for some y L x 1 2 { ∈ ∗ | ∈ 1 ∈ 2 } L2 2 Ex. L = an n 0 { | ≥ } 2 2 L/L = an m n m 0 = a(aa) +(a4) { − | ≥ ≥ } ∗ ∗ ‘ ’ m2 n2 = (m + n)(m n) ⊆ − − m n m + n m n m2 n2 − − ee e e mult four eo o o odd oe o o odd oo e e mult four
‘ ’ (k + 1)2 k2 = 2k + 1 odd ⊇ − (k + 2)2 k2 = 4k +4 multipleoffour −
Example 3.2.2 III 12 example L 1 L , L Σ 1 2 ⊆ ∗ L /L = x Σ xy L for some y L x 1 2 { ∈ ∗ | ∈ 1 ∈ 2 } L2 can ’hide’ computations
Ex. L = a2ncban n 1 ba2nban n 1 ba 1 { | ≥ }{ | ≥ }∗ L = c banban n 1 2 { | ≥ }∗
n L /L = a2 n 1 1 2 { | ≥ }
a16 c ba8 ba8 ba4 ba4 ba2 ba2 ba ba
cf. Thm 4.1.6 III 13 quotient
Thm. L, R Σ If R regular, then R/L regular. ⊆ ∗ F = q Q δ(q,y) F for some y L . ′ { ∈ | ∈ ∈ }
noncomputable ! (L arbitrary)
REG closed under quotient REG / REG = REG (see Ch.4) CF not closed, even CF / CF = RE CF / REG = CF
Theorem 3.2.2 3.3 Morphisms and substitutions III 14 morphism
‘monoid’ h : Σ ∆ → ∗ h : Σ ∆ h(xy)= h(x)h(y), h(ε)= ε ∗ → ∗ Σ ∆ h : 2 ∗ 2 ∗ h(L)= x L h(x) → ∈ 0 ab, 1 ba, 2 ε → → → 00212 ababba → 0n21n n 0 (ab)n(ba)n n 0 { | ≥ } → { | ≥ }
Thm. h(K L)= h(K) h(L) ∪ ∪ h(K L)= h(K) h(L) h(K∗)= h(K)∗
REG closed under morphisms
Theorem 3.3.1 III 15 substitution bb a a p q p q a a a+b(aa)*ab b b b b b ab p q b ba a a+ba(aa)*b r s r b(aa)*b bb+ba(aa)*ab a aa 1 p q 1 0 0
0 b(aa)*b → 1 a+b(aa)*ab → K = x 0, 1 # x is even { ∈{ }∗ | 1 } s(K)= x a, b #ax, # x are even { ∈{ }∗ | b } III 16 inverse morphism h : Σ ∆ , K ∆ → ∗ ⊆ ∗ h 1(K)= x Σ h(x) K − { ∈ ∗ | ∈ } Thm. REG closed under inverse morphism
a h(a)
δ′(p, a)= δ(p, h(a))
h : 0 ab, 1 ba → → h 1( bb, aba )= 0011 − { }∗ { }∗ a 1 b 1 b 0 b a 0
Theorem 3.3.9 III 17 shuffle
shuff(K, L)= K L shuffle abb aca = aabbca, aabcba, aabcab, aacabb, aacbab, aacbba, abbaca, { ababca, abacba, abacab, acabba, acabab, acaabb } x ε = ε x = x { } ax by = a(x by) b(ax y) ∪ K L = x K,y L x y ∈ ∈ Thm. K, L regular, then K L regular. but where is that stated?
Ex. 3.3.8 III 18 shuffle
abbba acac abacbacba ∋ K L using morphisms, intersection
copies of alphabet Σ, Σ = a a Σ , Σ = a a Σ 1 { 1 | ∈ } 2 { 2 | ∈ } h : Σ Σ Σ a a a ε 1 1 ∪ 2 → ∗ 1 → 2 → h : Σ Σ Σ a ε a a 2 1 ∪ 2 → ∗ 1 → 2 → g : Σ Σ Σ a a a a 1 ∪ 2 → ∗ 1 → 2 → h h abbba 1 a b a c b a c b a 2 acac ← 1 1 2 2 1 2 2 1 1 → K g L ∈ ↓ ∈ abacbacba
1 1 K L = g( h− (K) h− (L) ) 1 ∩ 2
Ex. 3.3.8 3.4 Advanced closure properties of regular languages III 19 exotic: halve, sqrt
1L = x Σ xy L for y with y = x . 2 { ∈ ∗ | ∈ | | | |} 1 Thm. L regular, then 2L regular
guess middle state, simulate halves in parallel
Q = q Q Q Q middle, 1st, 2nd ′ { 0′ } ∪ × × δ (q ,ε)= [q, q , q] q Q ε-move ′ 0′ { 0 | ∈ } δ ([q, p, r], a)= [q,δ(p, a),δ(r, b)] b Σ ′ { | ∈ } F = [q,q,p] q Q, p F ′ { | ∈ ∈ }
√ L = x Σ xx L . { ∈ ∗ | ∈ }
Theorem 3.4.1 III 20 cutting
cut L = x xy L for y with y = f( x ) . f { | ∈ | | | | } 1 f(n)= n 2L f(n) = 2n log L p.76 f(n)= n2 which f ?
see: transition matrix (Ch. 3.8) III 21 cyclic closure
cyc(L)= x x x x L . { 1 2 | 2 1 ∈ } Thm. If L is regular, then so is cyc(L)
guess middle, simulate halves in opposite order
Q = q Q Q 0, 1 ′ { 0′ } ∪ × ×{ } middle, state, phase δ (q ,ε)= [q,q, 0] q Q ε-move ′ 0′ { | ∈ } δ ([q,p,i], a)= [q,δ(p, a),i] ′ { } δ ([q, q , 0],ε)= [q, q , 1] q Q ′ f { 0 | f ∈ } F = [q,q, 1] q Q ′ { | ∈ }
Theorem 3.4.3 ⊲ In informal notation, (1) Note that the construction introduces x y ε-moves. q p q in , then 0 f A ε y ε q0′ [p, p, 0] [p, pf , 0] (2) Is this a proof? x [p, q , 1] [p, p, 1] in . 0 A′ The slide gives the intuition (‘guess middle’) and the formal construction For the reverse implication we need that (δ ([q, q , 0],ε) = [q, q0, 1] q indeed all computations in are of this ′ f { | f ∈ A′ Q ). form. ⊳ } What is missing is the (formal) argu- ment that the construction works, the correctness proof, i.e., that starting with automaton for L the constructed au- A tomaton actually accepts cyc(L). A′ Thus, if there is a computation for xy on , then there is a computation for yx on A (and vice versa). A′ 3.5 Transducers III 22 finite state transducers
FST finite state automaton with output ∼ = (Q, Σ, ∆, S, qin, F ) A S Q Σ ∆ Q ⊆ × ∗ × ∗ × ... (Σ ε ) (∆ ε ) ... ∪{ } × ∪{ }
T ( ) Σ ∆ transduction (translation) A ⊆ ∗ × ∗ x y rational relation b/b →A 0 b0 b/b K Σ a/a ⊆ ∗ T (K) = y ∆ (x, y) T ( ), x K a/ε a/a { ∈ ∗ | ∈ A ∈ } a/ε
1 b1 b/b b/b erase every 2nd a (keeping words ending in b)
Section 3.5 III 23 finite state transductions
intersection, quotient, concatenation ∗ with regular languages morphism, inverse morphism ∗ prefix, suffix ∗ ...erasing every second a ∗ b/b b/b T (K)= K x #ax even a/a ∩{ | }
a/a a/a b/b b/ε b/ε a/ε ε/ε
a/ε
copy x check y T (K)= x xy K and #ay even { | ∈ } III 24 rewriting quotient
K, L Σ ⊆ ∗ Σ = a a Σ Σ Σ = ∅ ′ { ′ | ∈ } ∩ ′ f : Σ Σ′ Σ f(a)= f(a′)= a ∪ → 1 f − non-det colouring h : Σ Σ h(a)= a → ′ ′ g : Σ Σ Σ g(a)= a, g(a )= ε ∪ ′ → ′ K/L = g( f 1(K) Σ h(L) ) − ∩ ∗
basic full trio operations: - morphism - inverse morphism - intersection regular III 25 full trio: finite state transductions
c/0 10 ε/1 0/c 10 1/ε a 100 1 1 h : b → 10 b/ /b → ε ε c 010 0 0 → ε/0 0/ε a/1 00 ε/0 1/a 00 0/ε
a/h(a) h(a)/a
b/b b/b a/a - every ’basic’ full trio operation is FST - FST’s are closed under composition sequence of full trio op’s is FST a/a ⇒ III 26 FST closed composition FST = (Q, Σ , Σ ,S , q , F ) Ai i i+1 i io i T ( )T ( ) FST = (Q , Σ , Σ ,S , q , F ) A1 A2 ⇒ A′ ′ 1 3 ′ 0′ ′ formally – Q = Q Q ′ 1 × 2 – qin = q , q ′ 10 20 – F = F F , and ′ 1 × 2 – S′ is defined by if (p , a, b, q ) S , and (p , b, c, q ) S 1 1 ∈ 1 2 2 ∈ 2 (with b = ε) then ( p1, p2 , a, c, q1, q2 ) S′ a/b ∈ a/c if (p , a, ε, q ) S and p Q , 1 1 ∈ 1 ∈ 2 b/c ⇒ then ( p , p , a, ε, q , p , ) S 1 1 ∈ ′ a/ε a/ε if p Q1 and (p2, ε, c, q2) S2, ⇒ ∈ ∈ then ( p, p , ε, c, p, q ) S ε/c ε/c 2 2 ∈ ′ ⇒ ‘implicit (p,ε,ε,p)’
Theorem 3.5.6 III 27 Nivat’s theorem
every full trio operation is a fs transduction Thm. every FST is composition of full trio op’s
R regular language over ‘transitions’ M a:ε, a:1, b:01 { } h and g select input and output
b/01 K b baaba ∋ h a/1 ↑ R b:01 b:01 a:ε a:1 b:01 a:ε ∋ M g a/ε ↓ T (K) 01 01 ε 1 01 ε M ∋ h g x R y input ←− computation −→ output 1 T (K)= g( h− (K) R ) M ∩ M Theorem 3.5.3 III 28 terminology
closure properties
trio: ( faithful cone) ≡ morphism, ε-free morphism, intersection regular full trio: ( cone) ≡ . . . , (arbitrary) morphism, . . . [full] semi-AFL: [full] trio & union [full] AFL: [full] semi-AFL & concatenation, Kleene plus 3.6 Two-way finite automata III 29 2way finite automata
like TM may move in both directions, no writing, tape bounded
= (Q, Σ, δ, q , F ) M 0 δ : Q (Σ ⊲,⊳ ) Q L, R × ∪{ } → ×{ } ⊲tape markers⊳ (!) δ( ,⊲) = ( , R), δ( ,⊳) = ( , L) configuration ⊲Σ QΣ ⊳ Q⊲ Σ ⊳ ∗ ∗ ∪ ∗ wqax wapx when δ(q, a) = (p, R) move ⊢ waqx wpax δ(q, a) = (p, L) ⊢ infinite loops possible !
L( )= w Σ q ⊲ w⊳ ⊲wp⊳, p F M { ∈ ∗ | 0 ⊢∗ ∈ }
Section 3.6 III 30 simulation of 2DFA
Shefferdson [1959] 2DFA DFA ⊆
b keep track of ‘excursions’ to the left τ : Q q¯ Q ℓ q¯ final, ℓ for loop p q ∪{ }→ ∪{ }
p1 p updating τ τx to τxb
q1 δ(p, b) = (q, R) then τxb(p)= q δ(p, b) = (p1, L), τx(p1)= q1, p2 δ(q1, b) = (p2, L),. . . , τx(pk)= qk q2 until one of the following occurs if q = ℓ then τ (p)= ℓ ... k xb if δ(qk, b) = (q, R) then τxb(p)= q ℓ qk q if qk = qi or qk = p then τxb(p)= ℓ
τx(¯q)= δ(q0,x)
Theorem 3.6.1 III 31 application two-way automata
root(L) = w Σ wn L for some n 1 { ∈ ∗ | ∈ ≥ } Thm. root(L) is regular (for regular L)
simulate for L on ⊲w⊳ M accept right when accepts M otherwise continue left at state reached
1 also 2(L) can be solved this way
and w Σ wn L for all n 1 ? { ∈ ∗ | ∈ ≥ }
Theorem 3.6.3 3.7 The transformation automaton 3.8 Automata, graphs, and Boolean matrices III 32 matrix multiplication
C = AB n Cij = i=1 AikBkj number of connections Boolean n Cij = k=1 Aik Bkj exists connection ∧
1 1 1
2 2 2
3 3 3
1 1 0 0 1 0 0 1 0 0 1 1 1 0 0 = 1 0 1 1 0 0 1 0 1 0 1 0
Section 3.8 III 33 automata and Boolean matrices
Q = q0, q1,...,qn 1 (ordered) { − } Ma Boolean matrix (Ma)ij =1 iff δ(qi, a) qj a,b 1 ∋ b a,b 1 0 0 1 1 0 b 0 2 Ma = 0 0 1 Mb = 1 0 1 1 0 0 0 0 0 a
Prop. (Mw) = 1 iff δ(q ,w) q ij i ∋ j 1 1 1 1 0 0 1 1 0 1 1 0 Mabb = 0 0 0 = 0 0 1 1 0 1 1 0 1 1 1 1 1 0 0 0 0 0 0 0 0
Thm. for w = a a ...a , a Σ 1 2 t i ∈ Mw = Ma Ma Ma 1 2 t
Cor. Mxy = MxMy
Theorem 3.8.1 0,1 0,1 1 0 0 0 0 Mε = 0 1 0 , 0 0 1 0 1 2 1 1 1 0 M0 = 0 0 1 , 0 0 1 1 0 0 1 10 100 0,1 1 0 0 1 M1 = 1 0 0 , 1 0 0 1 ε 1 1 1 1 1 01 0 0 011 1 M00 = 0 0 1 , 0 0 0 1 1 1 0 0 0 1 M01 = 0 0 1 , 0 0 1 00 001 1 1 1 0 0 0 M10 = 1 1 0 , 0 0 1 From diagram M000 = M00, etc. 1 0 1 M001 = 0 0 1 , 0 0 1 transformation automaton 1 0 0 M011 = 0 0 1 , 0 0 1 1 1 1 M100 = 1 1 1 0 0 1 III 34 computations as matrix multiplication characteristic vectors u0 = [1, 0, 0,..., 0] (row) (u ) =1 iff q F (column) F i i ∈
(Mw) =1 iff δ(q ,w) q ij i ∋ j
Thm. x L( ) iff u Mx u = 1 ∈ A 0 F
matrix represents computation
Theorem 3.8.3 III 35 transformation automaton
nondeterministic case = (Q, Σ, δ, q , F ) A 0 (Ma) =1 iff δ(q , a) q ij i ∋ j w = a1a2 ...at Mw = Ma Ma Ma 1 2 t = (Q , Σ,δ , q , ) A ′ ′ 0′ − transformation automaton Q = 0, 1 Q Q 0, 1-matrices ′ { } × q0′ = I identity matrix δ(M, a)= M Ma no final states specified
Thm. δ′(I,w)= M, then M = Mw i.e., (M) =1 iff δ(q ,w) q ij i ∋ j
Theorem 3.7.1 III 36 sqrt, log
√ L = x Σ xx L . { ∈ ∗ | ∈ } Q Q states Q = 0, 1 (the Mx’s) ′ { } × Mx after reading x final: (Mx)q p = 1 for some p Q [unique] 0 ∈ and (Mx)pq = 1 for some q F ∈
1L = x Σ xy L for y with y = x . 2 { ∈ ∗ | ∈ | | | |} (p, q) M k iff δ(p, u)= q for some u, u = k. ∈ | | M k+1 = M kM
Prop. log L = x xy L for y with y = 2 x . { | ∈ | | | | } k k 1 M 2 = (M 2 − )2
Prop 3.8.8 III 37 half-example a,b 1 b a,b 1 1 0 M = 1 0 1 b 0 1 0 0 2 a 2,3 1 1 1 a,b M 2 = 1 1 0 a,b 1 1 0 1 1 1 1,2 1,3 a M k = 1 1 1 (k 3) b ≥ b 1 1 1 b b b a,b a,b a,b 0,0 0,1 0,2 0,3 a,b M k[i,j] = 1 iff b b a length k path from i to j a,b 1,1 2,2
product: aut × transformation aut a (p,M k) (δ(p,a),M k+1) → III 38 monoids
monoid (M, , 1) ◦ - closed a b M ◦ ∈ - associative (a b) c = a (b c) ◦ ◦ ◦ ◦ - identity a 1 = 1 a = a ◦ ◦ (Σ , ,ε) strings ∗ (Zn n, , I) n n-matrices × ◦ × ( 0, 1 n n, , I) Boolean matrices: { } × ◦ finite monoid
monoid morphism h : (M, , 1) (M , , 1 ) ◦ → ′ ◦′ ′ h : M M → ′ - h(a) h(b) = h(a b) ◦′ ◦ - h(1)= 1′
* III 39 recognizable languages Def. L Σ recognizable iff ⊆ ∗ finite monoid (M, , 1), ◦ monoid morphism h : Σ M ∗ → S M such that L = h 1(S) ⊆ −
Cor. Mxy = MxMy Q Q : Σ∗ 0, 1 × automaton as monoid →{ } x Mx is a monoid morphism →
Thm. REC = REG (for strings)
= (M, Σ, δ, 1,S) AM monoid as automaton δ(m, a)= m h(a) m M, a Σ ◦ ∈ ∈ x L( ) iff δ(1,x) S iff h(x) = 1 h(x) S ∈ AM ∈ ◦ ∈ iff x h 1(S) ∈ −
* 3.9 The Myhill-Nerode theorem III 40 state equivalence equivalence relation - reflexive xRx for all x - symmetric xRy implies yRx - transitive xRy and yRz imply xRz equivalence class E = y S xRy { ∈ | } index of R
b b DFA = (Q, Σ, δ, q , F ) M 0 a ending in the same state xR y iff δ(q0,x)= δ(q0,y) a M
baabb R ε equivalence relation on Σ∗ M baabba R a - finite index Q M | | - right invariant xR y implies xzR yz M M right congruence - L(M) union of equivalence classes RM saturates L
Section 3.9 III 41 fundamental observation L Σ ⊆ ∗ xR y when, for all u, (xu L iff yu L) L ∈ ∈
equivalence relation on Σ∗ - index may be infinite - right invariant xRLy implies xzRLyz - L union of equivalence classes
R1, R2 equivalence relations R refinement of R : R R 1 2 1 ⊆ 2
Lem. L union of some classes of right-invariant equivalence relation E. Then E refinement of RL
Prf. xEy (right-invariant) xzEyz for all z (union ⇒ of classes) xz L iff yz L for all z xR y ⇒ ∈ ∈ ⇒ L
Lemma 3.9.3 III 42 example L Σ ⊆ ∗ xR y when, for all u, (xu L iff yu L) L ∈ ∈ 1 1 xRLy iff x− L = y− L 1 x− L = u xu L 1 { | ∈ } x− L may contain ε L = x a, b ∗ x ends in a or even b’s a,b a { ∈{ } | } { }∗ even b’s ( 2) ≥ [ε] even number b’s [a]=[ε], [b] odd ’s b [b] odd b’s, ending in b [ba], [bb]=[ε] ε a b bb [ba] odd b’s, ending in a [baa]=[ba], [bab]=[ε] ε √ √ √ − a b √ √ ba √− √ √ − − ba (x,y): xy L a b ∈ b b ε b a Theorem 3.9.5 III 43 Myhill-Nerode
Thm. L Σ . equivalent: ⊆ ∗ a. L regular b. L is union of equivalence classes of right-invariant equivalence relation E of finite index
c. RL has finite index
a. b. R for automaton ⇒ M M b. c. E is a refinement of R . index R index E ⇒ L L ≤ c. a. use equivalence classes as states ⇒ δ([x], a) = [xa]
automaton is ‘inside’ the language
Theorem 3.9.5 III 44 number of states 0 0 0 0 0 1 1 1 2 1 3 n state nfa 2n state dfa 0 0,1 all reachable ε 0,1 all nonequivalent
0 1
0 1 1 1 2 1 3 0 1 0 0 0 02 0 0 01 1 12 1 23 1 03 1 1 1 0 0 0 13 0 012 1 123 1 023 1 013 0
0 0
0123 0,1 Theorem 3.9.6 3.10 Minimization of finite automata III 45 minimal automaton L Σ ⊆ ∗ Σ∗/RL xR y when, for all u, (xu L iff yu L) L ∈ ∈ q xR y when δ(q0,x)= δ(q0,y) M xR y then xRLy M
Myhill-Nerode: RL-classes automaton p δ([x], a) = [xa]
Thm. unique minimal (det) automaton for L
= (Q, Σ, δ, q , F ) M 0 : Q Σ /R → ∗ L q [x], such that δ(q ,x)= q → 0 well-defined (R refines RL) M surjective (q = δ(q ,x) [x]) 0 → injective (surjective, same number states) respects transitions (right invariant) Theorem 3.10.1 III 46 state equivalence = (Q, Σ, δ, q , F ) dfa for L M 0 q’ Σ∗/RL xRLy when, for all u, (xu L iff yu L) q ∈ ∈ xR y when δ(q0,x)= δ(q0,y) M xR y then xRLy M p q indistinguishable ≡ δ(p, z) F iff δ(q,z) F p ∈ ∈ : Q Σ /R → ∗ L q [x], such that δ(q ,x)= q → 0 well-defined (R refines RL) M surjective (p = δ(q ,x) [x]) 0 → may not be injective respects transitions (right invariant) p = δ(q0,x), q = δ(q0,y) xR y (or [x] = [y]) iff p q L ≡ ⊲ find indistinguishable states ≡ III 47 naive-minimize
0. U p, q = 0 for all p, q Q { } ∈ 1. U p, q = 1 for all p F , q Q F { } ∈ ∈ − 3. repeat 5. T = U 8. if T δ(p, a),δ(q, a) = 1 then U p, q = 1 { } { } for all a Σ, all p, q with T p, q = 0 ∈ { } . until no changes 9. return(U)
U p, q =1 iff p q { } ≡
q a