finite automata

41
06/12/22 FCS Finite Automata Closure Properties of Regular Languages Theorem. The class of regular languages is closed under union, intersection, subtraction, complementation, concatenation, Kleene closure and reversal. Note: closure under union, concatenation and Kleene closure comes from the fact that regular languages are represented by regular expressions; closure under intersection, subtraction and complementation comes from from the fact that regular languages are represented by DFAs. The only part still missing is the closure under reversal. 1

Upload: karif

Post on 13-Feb-2016

57 views

Category:

Documents


0 download

DESCRIPTION

Finite Automata. Closure Properties of Regular Languages Theorem . The class of regular languages is closed under union, intersection, subtraction, complementation, concatenation, Kleene closure and reversal. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Finite Automata

04/22/23 FCS

Finite Automata

Closure Properties of Regular Languages

Theorem. The class of regular languages is closed under union, intersection, subtraction, complementation, concatenation, Kleene closure and reversal.

Note: closure under union, concatenation and Kleene closure comes from the fact that regular languages are represented by regular expressions; closure under intersection, subtraction and complementation comes from from the fact that regular languages are represented by DFAs. The only part still missing is the closure under reversal.

1

Page 2: Finite Automata

04/22/23 FCS

Finite Automata

Closure Properties of Regular LanguagesProof. We could prove it by structural induction (on the number of operators applied), since R = , {}R = {} and {a}R = {a} for every a , and the extension through union, concatenation and Kleene closure is not hard.

We will prove it by construction, instead: Assume M is an NFA (or DFA), with language L(M). We construct and NFA M' such that L(M') = L(M)R. The equivalence of DFAs and NFAs will do the rest. This is the only proof (of any of the statements of the theorem) where NFAs are really used

2

Page 3: Finite Automata

04/22/23 FCS

Finite Automata

Closure Properties of Regular Languages

Details: Let M = (Q, , , q0, F). We construct M' as follows: if |F| > 1, introduce a new state s and connect every element in F to it via an -transition. Otherwise, let s be the single state in F.

Define: M' = (Q{s}, , ', {s}, {q0}), where q' '(q, a) q (q', a), a {}

All we have done is to "reverse the arrows", after a small adjustment. We have an NFA (we cannot expect a DFA, even if M was a DFA with a singleton accepting state - why?) whose accepting paths are exactly the reversal of the accepting paths of the original.

3

Page 4: Finite Automata

04/22/23 FCS

Finite Automata

Closure Properties of Regular Languages - SubstitutionsSubstitution. Let f be a mapping: f (a) = La, where a and La is a language over an alphabet . Extend the function f to * by f() = {} and f(a1a2…ak) f(a1)f(a2)…f(ak) for a1, …, ak . For any language L *, we apply f to L: f(L) = xLf(x).

Ex.: L = {01, 10}; f(0) = 0(0+1)*; f(1) = (0+1)*1.f(L) = f(01) f(10) = f(0)f(1) f(1)f(0)

= 0(0+1)*(0+1)*1(0+1)*10(0+1)*

= 0(0+1)*1 (0+1)*10(0+1)*

A substitution is called a homomorphism if, for any a , f (a) is a language with a single string (= a singleton string).

4

Page 5: Finite Automata

04/22/23 FCS

Finite Automata

Closure Properties of Regular Languages - SubstitutionsProposition. Let f be a substitution over ; assume that L * is a regular language and that f(a) is a regular language for each a . Then f(L) is a regular language.Proof. Let r be a RE for L, ra a RE for f(a) for each a . Replace each occurrence of a in r by f(a). We obtain a new regular expression r'. We observe:n For any two sets A, B *, f(AB) = f(A) f(B), f(AB) = f(A) f(B), and f(A*) = f(A)*.n For any two regular expressions r and s, (r + s)' = r' + s', (rs)' = r's', and (r*)' = (r')*.This could use detailed proof as set inclusions and RE equalities…

5

Page 6: Finite Automata

04/22/23 FCS

Finite Automata

Closure Properties of Regular Languages - SubstitutionsWe now start the induction:The base cases (0 operators): f() = (extending the definition to the empty language). Regularity is preserved: the empty language is regular and its image (also the empty language) is also regular. f({}) = {}. The image of the language consisting of the empty string is a regular language. f({a}) is a regular language for each a , by definition of f.

All three basis steps give rise to regular languages and their regular expressions starting from the regular language building blocks and their regular expressions.

6

Page 7: Finite Automata

04/22/23 FCS

Finite Automata

Closure Properties of Regular LanguagesThe structural induction step: Let r and s be regular expressions defining regular languages A and B * such that f(A) and f(B) are regular languages with regular expressions r' and s'. Assume the result holds for sets constructed with up to n operators; prove it holds if you apply any one of the operators to two such sets.We have:

r+s AB : f(AB) = f(A)f(B) r'+s' = (r+s)' and the image language is regular. Identical arguments will work for the remaining structural operations (concatenation and Kleene closure).

7

Page 8: Finite Automata

04/22/23 FCS

Finite Automata

Closure Properties of Regular Languages - QuotientsDefinition. The quotient of two languages, denoted by L1/L2 is given by

L1/L2 = {x | (y L2)[xy L1]}.

Proposition. If L1 is a regular language, then L1/L2 is regular.

Proof. Let M = (Q, , , q0, F) be a DFA accepting L1. By definition, for any x L1/L2 y L2 s.t. (q0, xy) = ((q0, x), y) F. If we define

F' = {q Q | (y L2)[(q, y) F]},

M' = (Q, , , q0, F') is a DFA that accepts L1/L2.

Note: The proof is not quite constructive, at the moment, since we would need to show that a finite number of strings in L2 suffices to construct F'.

8

Page 9: Finite Automata

04/22/23 FCS

Finite Automata

Closure Properties of Regular Languages - ExamplesEx. 2.37. Let L be regular over , k a pos. integer and : k . Then

L1 = {(a1, a2, …, ak)…(a(n-1)k, a(n-1)k+1, …, ank) | a1a2…ank L} is regular. Note that a string of length nk in L becomes a string of length n in L1.

Proof. Let L = L(M) for M = (Q, , , s, F). Let M' = (Q, , ', s, F), with (q Q, a ) '(q, a) = {(q, a1…ak) | (a1, …, ak) = a}.

Note: there is no requirement for to be 1-1.We can see that L1 = L(M').

Note that (q, a1…ak) is the state of M reached from q after consuming the string a1…ak.

9

Page 10: Finite Automata

04/22/23 FCS

Finite Automata

Closure Properties of Regular Languages - ExamplesDef.: for any language L,

MIN(L) = {x L | no proper prefix of x belongs to L}.

Ex. 2.38. If L is regular, then MIN(L) is regular.

Proof. Let L = L(M), where M = (Q, , , s, F) is a DFA. Let M' be the NFA obtained from M by deleting all the out-edges from the final states.It is clear that M' accepts MIN(L)…

10

Page 11: Finite Automata

04/22/23 FCS

Finite Automata

Closure Properties of Regular Languages - ExamplesDef.: for a, b {0, 1}, let a b denote the disjunction of a and b; for any two binary strings x and y, with |x| = |y|, let x y denote the bitwise disjunction of x and y.Ex. 2.39. Let A and B be regular over {0, 1}. Then

A B = {x y | x A, y B, |x| = |y|} is regular.Proof. Let MA = (QA, {0, 1}, A, sA, FA) and MB = (QB, {0, 1}, B, sB, FB) be the respective DFAs. We build a product NFA M' as follows:M' = (QA QB, {0, 1}, ', [sA, sB], FA FB) where

'([p, q], 0) = {[A(p, 0), B(q, 0)]}

'([p, q], 1) = {[A(p, 0), B(q, 1)], [A(p, 1), B(q, 0)], [A(p, 1), B(q, 1)]}.

11

Page 12: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite AutomataWe have seen that regular languages give rise to at least three different, and equivalent, notational devices that represent them. For one of them, at least, the following question is meaningful: does a regular language have a corresponding (unique) minimal DFA, in the sense that no other DFA accepting the language has fewer states? if the answer is yes, can we construct it?The constructions we have, from REs to NFAs to DFAs tend to "blow up" the number of states, up to exponential cardinality in the number of states of the NFA - which already "bloats" the number of atomic terms in the regular expression (digraph construction).

We could use a different characterization of regular languages.

12

Page 13: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite Automata - the IndexDefinition. For any language L *, we define a relation RL on *: x RL y (w *) [xw L yw L].

Proposition. RL is an equivalence relation on *: n it is reflexive: (x *) [x RL x]n it is symmetric: (x, y *) [x RL y y RL x]n it is transitive: (x, y, z *) [x RL y, y RL z x RL z]

Proof. An easy exercise.Corollary. RL partitions * into disjoint equivalence classes, where the class containing x is denoted by [x]RL

.

Proof. Another easy exercise.Definition. The number of equivalence classes of R in * is called the index of R and denoted by Index(R).

13

Page 14: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite Automata - the Index - ExampleEx. 2.46: Let L be the set of binary strings starting and ending with the same symbol. Find all equivalence classes of RL (in *).

Soln.: a) we first show that 8 x, y 2 *, x RL y x and y start with the same symbol and end with the same symbol. By contradiction. Assume x and y start with different symbols, with, say, x starting with a 0 and y starting with a 1. Then x0 L while y0 L, so that x RL y does not hold. This implies that x and y must start with the same symbol. Note further that x RL y x L y L ( *), and therefore, since they start with the same symbol, they must end with the same symbol.

14

Page 15: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite Automata - the Index - Example Assume x and y start with the same symbol and end with the same symbol. Since they start with the same symbol: xw L yw L for all w (0+1)+. Since x and y end with the same symbol, x L y L. Thus xw L yw L for any w (0+1)* = *.

We can now characterize the (5) equivalence classes:[]RL

= ,

[0] RL = 0 + 0(0 + 1)*0, [1] RL

= 1 + 1(0 + 1)*1,

[01] RL = 0(0 + 1)*1, [10] RL

= 1(0 + 1)*0

15

Page 16: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite Automata - the Index - Example

How do we find the classes of * induced by the relation RL? If we cannot guess them - and we usually can't - the only strategy left is to be systematic.n Start from the string 2 * and find the strings in * that belong to its class.n Move to the strings of length 1n Move to the strings of length 2 … etc.n Either the classes will begin repeating after a finite number of constructions (in which case the index will be finite), or not, in which case the index will be infinite.

16

Page 17: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite Automata - the Index - ExampleDetails: recall x RL y (w *) [xw L yw L], where L = + 0 + 1 + 0(0+1)*0 + 1(0+1)*1

Show: []RL = {}, where

[]RL ´ { y | y 2 * and (w *) [w = w L yw L]}

Since w 2 L , w 2 L, we are looking for those strings y s.t. yw 2 L , w 2 L. y = is, obviously, OK. Let's now start with the shortest non-trivial candidates: y = 0, 1. For each w 2 L, 0w 2 L if w = or w ends in 0, otherwise 0w L. So 0 []RL

. The same argument gives that 1 []RL. If

y is any other nontrivial string, it must be one of 0(0+1)*0, 0(0+1)*1, 1(0+1)*0 and 1(0+1)*1. Then 11 2 L and 0(0+1)*011, 0(0+1)*111 L. Similarly for 00 and 1(0+1)*000, 1(0+1)*100.So []RL

contains just one string: .

17

Page 18: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite Automata - the Index - ExampleWe now look at the classes of longer strings. The strings of length 1 will give rise to the classes [0] RL

and [1] RL.

Claim: [0] RL = 0 + 0(0 + 1)*0, [1] RL

= 1 + 1(0 + 1)*1.

Let's construct [0] RL, the construction of [1] RL

being similar.

[0]RL ´ { y | y 2 * and (w *) [0w = w L yw L]

Obviously, 0 2 [0] RL. The rest of the candidates must be of the form y

= 1, 0(0 + 1)*0, 0(0 + 1)*1, 1(0 + 1)*0 and 1(0 + 1)*1. For y = 1, the choice w = 1 will invalidate the condition; for y = 0(0 + 1)*0, the condition will hold for w = (both 0 and 0(0+1)*0 begin and end in 0) and for all other choices of w it will depend only on the last character of w being 0 or not. For y having the form of one the three remaining string types, we find failures for w = in the cases 0(0 + 1)*1 and 1(0 + 1)*0 and for w = 0 in the last one.

18

Page 19: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite Automata - the Index - Example

We still have to place two sets of strings: the ones denoted by 0(0 + 1)*1 and 1(0 + 1)*0. It should be clear that, after this placement, all strings in * will have been taken care of.An argument similar to those already encountered allows us to conclude that:

[01] RL = 0(0 + 1)*1, [10] RL

= 1(0 + 1)*0

19

Page 20: Finite Automata

04/22/23 FCS

Finite Automata

Minimum DFAs - the Index - Second Example

Problem 2.7.1a: find all equivalence classes of RL for the language L = (0 + 1)*01(0 + 1)*.

Soln: first observe that = {0, 1}. RL is defined over * (= all strings over {0, 1} - we are partitioning the set of all strings over {0, 1}) and, specifically,

x RL y , 8(w 2 *){xw 2 L , yw 2 L} for any two strings x, y 2 *.

Start with the class of the empty string: []RL.

Claim: []RL= [1]RL

= [11]RL =…= [1n]RL

=…

Note that both and 1n must be concatenated with a string containing 01 (thus in L) in order to give rise to a string in L.

20

Page 21: Finite Automata

04/22/23 FCS

Finite Automata

Minimum DFAs - the Index - Second Example

Problem 2.7.1a: find all equivalence classes of RL for the language L = (0 + 1)*01(0 + 1)*.

Claim: []RL=…= [0n]RL

=…= [1m0n]RL for m ≥ 1, n ≥ 1, i.e., w must

contain a 1 for the concatenation to be in L.Claim: [1]RL

= []Rl from the previous slide.

Claim: [01]RL = L.

All other strings in * belong to one of the classes just constructed.Automaton for L:

21

0 1

1 0 0, 1

Page 22: Finite Automata

04/22/23 FCS

Finite Automata

Minimum DFAs - the Index - Third Example

Problem 2.7.2a: show that for L = {0m1n | 0 ≤ m ≤ n}, Index(L) = 1.Soln: first observe that = {0, 1}. RL is defined over * (= all strings over {0, 1} - we are partitioning the set of all strings over {0, 1}) and, specifically,

x RL y , 8(w 2 *){xw 2 L , yw 2 L} for any two strings x, y 2 *.

Start with the class of the empty string: []RL: for what y 2 * is it true

that w 2 L , yw 2 L? It is clear that w 2 L , w 2 L, so that w = 0m1n for some 0 ≤ m ≤ n. Question: what must y look like so that yw 2 L for all w of the form 0m1n, 0 ≤ m ≤ n, and only for those ws? Assume y = 0k for some k > 0. Then 0k0m1n L 8 (0 ≤ m ≤ n < k + m). Similar arguments hold for any non-empty strings: []RL

= {}.

22

Page 23: Finite Automata

04/22/23 FCS

Finite Automata

Minimum DFAs - the Index - Third ExampleLet's now try x = 0k, k > 0. Let y = 0j, j ≠ k. We must satisfy the requirement 0kw 2 L , 0jw 2 L 8 (w 2 *). If we choose l = min{j, k}, then either 0k1l or 0k1l L. Since we have just shown that 0k and 0j, j ≠ k, belong to different equivalence classes, we must conclude that RL has infinitely many equivalence classes.

Notice that we do not need to identify all the distinct equivalence classes - there may be others, after all we have identified only

[]RL, [0]RL

, [02]RL, …, [0n]RL

,…but this is enough to reach the desired conclusion.

23

Page 24: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite AutomataLemma. Let L be accepted by the DFA M = (Q, , , q0, F), and let be the extended transition function of M. Then, for any strings x, y *, (s, x) = (s, y) x RL y.

Proof. If (s, x) = (s, y), then, for any w *, (s, xw) = ((s, x), w) = ((s, y), w) = (s, yw).

Thus, for any w *, xw L yw L.

Note. The lemma shows that, if L is accepted by a DFA M of n states, all strings with the same ending state are in the same equivalence class of RL. In particular Index(RL) ≤ n, and is thus finite. If we can find a DFA accepting L and with exactly Index(RL) states, we have found the desired minimum DFA.

24

Page 25: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite AutomataTheorem 2.48 (Myhill-Nerode). For any regular language L, its minimum DFA has exactly Index(RL) states.

Proof. Let L have alphabet . Define M = (Q, , , s, F) by:n Q = {[x]RL

| x *}, (and |Q| < if L is regular); n [x]RL

a) = [xa]Rl, for any a 2 ;

n s = []RL;

n F = {[x]RL| x L}.

The function is well-defined since: [x]RL = [y]RL

[xa]RL =

[ya]RL [x]RL

a) = [xa]RL = [ya]RL

= [y]RLa).

By induction on |y| we extend this to []RLx) = [x]RL

x *proving that

L(M) = L: x L [x]RL F []RL

x) F M accepts x. Since M has

Index(RL) states, it is, by the previous Lemma, a min. DFA for L.

25

Page 26: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite AutomataCorollary. A language L is regular Index(RL) < .

Proof. No use of regularity (other than for the finiteness of Q) was made in the Myhill-Nerode theorem. We can thus construct the minimum DFA for any language as along as Index(RL) < . Such languages L must be regular.

Note: the finiteness of DFAs allows us to obtain a "simplification" - we don't need to look at all of * to characterize RL, but only to strings up to a certain length.

26

Page 27: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite AutomataProposition. L is regular k N+ s.t. [x RL y [z * with |z| ≤ k, xz L yz L]].

This simply means that regular languages are really determined by finite sets of strings: you will have no surprises from "very long strings". This also means, in the language quotient case, that we don't need to look at all the strings in L2.

27

Page 28: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite AutomataProposition. L is regular k N+ s.t. [x RL y [z * with |z| ≤ k, xz L yz L]].Proof. Let M = (Q, , , s, F) be a DFA accepting L; let k = |Q|2 - 1.

This is obvious, since x RL y [z * xz L yz L], and therefore for all those z with |z| ≤ k.

Consider the product DFA M* = M M. Let w * with |w| > k. Let x, y 2 *. The computation path of M* on w starting from q1

* = [(s, x), (s, y)], to q2* =

[(s, xw), (s, yw)], contains at least |Q|2 + 1 states, while M* has |Q|2 states, and therefore it contains some cycles in the transition diagram of M*. Eliminate the cycles and keep only a simple path from q1

* to q2*, which

corresponds to the computation path for a string z with |z| ≤ k, so that q2* =

[(s, xz), (s, yz)] = [(s, xw), (s, yw)]. By assumption, xz L yz L : the states (s, xz) and (s, yz) are both in F or not in F. So xw L yw L and the result follows.

28

Page 29: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite Automata Assume k N+ s.t. [x RL y [z * with |z| ≤ k, xz L yz L]]. Each z can divide * in at most two parts: {x | xz L} and {x | xz L}. The number of equivalence classes of RL is thus, at most, 21+||+...||k, and so finite. Which implies regularity for L.

Note: we have developed some results and techniques which allow us to do two things

n we have a way of constructing a minimum DFA for a regular language;

n we have a way of determining (maybe) whether a language is regular or not (being unable to construct a DFA is quite different from proving that no DFA exists) by computing Index(RL) .

29

Page 30: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite Automata - ExampleEx. 2.51.: find the minimum DFA for the language L = (0 + 1)*01.Soln.: we compute the equivalence classes of RL (some "bit analysis"), beginning from the shortest string in *:

n []RL= {x {0, 1}* | (w {0, 1}*)[xw (0 + 1)*01 w (0 + 1)*01]}. We

need to characterize x []RL. What are the possible relevant endings of x? :

0, 1, 00, 01, 10, 11. There is no point in looking at longer strings, since L fixes the last two characters. x may not end with 0 (or 01): if it did x1 (or x) would be in (0+1)*01, which would imply that w = 1 (or w = ) is in (0 + 1)*01. Conversely, if x does not end with 0 or 01, then x []RL

. Thus []RL= + 1 +

(0 + 1)*11.n [0]RL

= {x {0, 1}* | (w {0, 1}*)[0w (0 + 1)*01 xw (0 + 1)*01]}. What must x end with? Since, for w = 1, 0w (0 + 1)*01]}, x must end with 0. Conversely, if x ends with 0, x [0]RL

. Thus [0]RL= (0 + 1)*0.

30

Page 31: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite Automata - Example

n [1]RL. Using the definition of []RL

we can see that 1 []RL and thus the

two classes must coincide (by RL being an equivalence relation).n [00]RL

. 00 [0]RL [00]RL

= [0]RL.

n [01]RL = {x {0, 1}* | (w {0, 1}*)[01w (0 + 1)*01 xw (0 +

1)*01]}. Either x ends in 01, or it cannot satisfy the condition. We must conclude that [01]RL

= (0+1)*01.n [10]RL

: since 10 2 [0]RL, we have

[10]RL

= [0]RL.

n [11]RL: since 11 2 []RL

, we have [11]RL

= []RL.

The classes are []RL, [0]Rl

and [01]RL. The minimum DFA has only 3 states:

0 011

0

0

1

0

1

31

Page 32: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite Automata - Example Ex. 2.53. Find the minimum DFA equivalent to the DFA:

0

4

1

2 3

5

0

01 1

0 1

1 0

1

0 0,1

32

Page 33: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite Automata - ExampleSoln. 1: M = (Q, , , q0, F), Q = {q0, q1, q2, q3, q4, q5}, L = L(M).

Recall: for states p and q, p R*

L q , Sp = {x 2 * | (s, x) = p)} is in same equiv. class as

Sq = {x 2 * | (s, x) = q)} .

, (8 w)[(p, w) 2 F , (q, w) 2 F].To find R*

L between any two states, construct a graph G:

Each vertex is an unordered pair (qi, qj). Let U be the set of vertices (qi, qj) with one vertex qi 2 F and the other vertex qj F. For each vertex (qi, qj) U (either both vertices are in F or not in F), with i ≠ j, draw edges (qi, qj) !a ((qi, a), (qj, a)) 8 a 2 .

Claim: qi R*L qj , there is no path in G from (qi, qj) to a vertex in U.

33

Page 34: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite Automata - ExampleHow do we use this construction? Construct G.U consists of the pairs (0, 2), (1, 3), (1, 2), (0, 3), (2, 4), (3, 4), (4, 5).The complement of U consists of (0, 0), (0, 1), (1, 1), (0, 4) (1, 4), (2, 2), (2, 3), (3, 3), (2, 5), (3, 5), (4, 4), (5, 5).Note: there is no point in starting from a (qi, qi) node - why?

From (0, 1):

(0, 1) (2, 3)

0

1 (4, 4)1

(5, 5)

0

0

1

0, 1

34

0

4

1

2 3

5

0

01 1

0 1

1 0

1

0 0,1

Page 35: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite Automata - ExampleThe next node in the list is (0, 4):

Note that from the nodes (0, 4), (1, 4), (2, 5) and (3, 5) we can reach a node in U. When we put together the two partial graphs (constructed this way for convenience, we get:

(0, 4) (2, 5)1

(5, 5)0

(1, 4)

0

(3, 5)1

(4, 5)1

1

01

0, 1

0

35

0

4

1

2 3

5

0

01 1

0 1

1 0

1

0 0,1

Page 36: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite Automata - ExampleThe minimal automaton is exactly the one corresponding to the graph with only black nodes:

(0, 4) (2, 5)1

(5, 5)0

(1, 4)

0

(3, 5)1 (4, 5)1

1

01

0

(0, 1) (2, 3)

0

1 (4, 4)1

(5, 5)

0

0

1

0, 1

36

Page 37: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite Automata - ExampleWe finish with just the minimal DFA, where we have highlighted it final nodes:

(5, 5)

(0, 1) (2, 3)

0

1 (4, 4)1

(5, 5)

0

0

1

0, 1

37

Page 38: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite Automata - ExampleSoln. 2: The critical step of soln. 1 is to determine, for a pair (qi, qj) whether there is a path in G from it to a vertex of U. You need only study pairs where i ≠ j, since you know the (qi, qi) belong to the same class. Create a table of pairs, marking all pairs in U with a 0:

0

0

0

0

0

0 0

0q0, q1, q2, q3, q4

q1,

q2,

q3,

q4,

q5

0

q0, q1, q2, q3, q4

0

0

0

0

0

0

1

0

1 0

q1,

q2,

q3,

q4,

q5

0

Of the unmarked pairs, mark with a 1 those for which there is an a 2 taking them to a pair marked with a 0.

38

Page 39: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite Automata - ExampleOf the unmarked pairs, mark with a 2 those for which there is an a 2 taking them to a pair marked with a 1. Keep on until no more markings. The pairs left unmarked must satisfy qi R*

L qj. Add the (qi, qi) needed to complete the graph

0

0

0

0

0

0

1

0

1 0q0, q1, q2, q3, q4

q1,

q2,

q3,

q4,

q5

0

0

2

0

0

0

2

0

0

1

0

1 0q0, q1, q2, q3, q4

q1,

q2,

q3,

q4,

q5

0

39

Page 40: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite Automata - ExampleSoln. 3: Split states into F and Q\F. Chase states from F: if any exit F, break F into an appropriate number of sub-blocks; same for Q\F. Keep on iterating until no new blocks appear.

0

4

1

2 3

5

0

01 1

0 1

1 0

1

0 0,1

0

4

1

2 3

5

0

01 1

0 1

1 0

1

0 0,1

40

Page 41: Finite Automata

04/22/23 FCS

Finite Automata

Minimum Deterministic Finite Automata - Example

0

4

1

2 3

5

0

01 1

0 1

1 0

1

0 0,1

0

4

1

2 3

5

0

01 1

0 1

1 0

1

0 0,1

0,1

1

2,3

4

0 0,1

5

01

1

41