1 Minimizing Finite Automata Here is an example of a non-minimal fjnite automaton: collapse equivalent states and delete unreachable states to minimize the start state. 5. Defjne the equivalence of two states in a deterministic fjnite au- has infjnitely many equivalence classes. (b) Compute the smallest number of states in any deterministic many equivalence classes.) 1 Outline of this section: 2. Defjne strings equivalent with respect to a deterministic fjnite au- classes, and vice versa. This is 1. Defjne strings equivalent with respect to a language L . notated as x ≈ L y . This is defjned by x ≈ L y ifg { z : xz ∈ L } = { z : yz ∈ L } . If L is regular then ≈ L has fjnitely many equivalence tomaton M . This is written x ∼ M y . Two strings are equivalent with respect to M if they cause M to end up in the same state. 3. Use ≈ L to (a) Characterize regular languages. ( L is regular ifg ≈ L has fjnitely fjnite automaton recognizing L . (It is equal to the number of equivalence classes of ≈ L .) 4. It is possible to show a language L non-regular by showing that ≈ L tomaton. p ≡ q in M if L ( M p ) = L ( M q ) where M x is M with x as 6. Compute which states of an automaton M are equivalent; then M .
2 Here is an equivalent minimal automaton: Example 1.1.1 The equivalence 1.1 r1 a,b a q s a,b a,b b r2 a,b a,b q r s a,b Equivalence with Respect to L x ≈ L y ifg { z : xz ∈ L } = { z : yz ∈ L } Note that L need not be regular for this defjnition. relation ≈ L can also be defjned this way: If there is a z such that xz ∈ L and yz ̸∈ L then x ̸≈ L y If there is a z such that xz ̸∈ L and yz ∈ L then x ̸≈ L y Otherwise x ≈ L y . Let L be { ab, ac, bb, bc } . x { z : xz ∈ L } a { b, c } { b, c } b c ϕ { ϵ } ab ac { ϵ } ϵ L abc ϕ
3 even length strings this way in the limit. • The number of equivalence classes is just the number of sets found a new equivalence class. Here is a way to think of equivalence classes: There are two equivalence classes. odd length strings even length strings What is an equivalence class? odd length strings odd length strings Thus a ≈ L b and ab ≈ L ac but a ̸≈ L c and b ̸≈ L c , for example. There are four equivalence classes, corresponding to the four values of { z : xz ∈ L } as x varies. Let L be { w ∈ { 0 , 1 } ∗ : | w | is even } . x { z : xz ∈ L } 0 1 00 01 101 Thus 0 ≈ L 1 , 00 ≈ L 01 , 0 ≈ L 101 , 0 ̸≈ L 00 , and 1 ̸≈ L 01 , for example. Defjnition 1.1 (Equivalence Class) Given a set S and an equivalence relation R , the equivalence classes of S are • disjoint subsets S 1 , S 2 , . . . of S • whose union is S • and such that if x, y ∈ S i then xRy • but if x and y are in difgerent subsets S i and S j for i ̸ = j then it is not true that xRy . For the relation ≈ L , there is one equivalence class for each value of { z : xz ∈ L } . List all the elements of the set S , say, x 1 , x 2 , x 3 , . . . . • If some x i is not equivalent to any element seen so far, then x i starts • If some x j is equivalent to some x i seen earlier, then x j is in the same equivalence class as x i .
4 • Make each one into a state and show how one can construct a minimal Also, write nondeterministic. 1.3 • The resulting automaton is minimal for this language. draw the arrows. • Explain how to choose the start state and accepting states and how to deterministic fjnite automaton from them. A convenient defjnition • How many equivalence classes are there? 1.2 • Find them using the listing idea given above. Do these in class. Problems If L is regular, then one can test if x ≈ L y this way: • Let M be a minimal deterministic fjnite automaton recognizing L . • Then x ≈ L y ifg x and y both drive M from the start state to the same state of M . This can be an easy way to test if x ≈ L y if you can guess M . What are the equivalence classes for a ∗ b ∗ ? How about for { a n b n : n ≥ 0 } ? What are the equivalence classes? If M is a deterministic or nondeterministic fjnite state automaton, write a s → M t if M , in state s , reading a symbol a ∈ Σ , can end up in state t . • That is, δ ( s, a ) = t if M is deterministic, and ( s, a, t ) ∈ ∆ if M is w ∗ → s M t if M , in state s , reading a string w ∈ Σ ∗ , can end up in state t . • If M is deterministic, then t is determined by s and w . • If M is nondeterministic, then there could be more than one such t , one, or none, for a given s and w .
1.4 state. Consider again this automaton: 5 Defjnition 1.2 (2.5.2) Equivalence with respect to M • Two strings x, y ∈ Σ ∗ are equivalent with respect to M , written x ∼ M x y ∗ ∗ → → M u implies t = u , where s is the start state of y , if s M t and s M . • That is, when M reads the string x starting in the start state, it ends up in the same state as when it reads the string y starting in the start r1 a,b a q s a,b a,b b r2 • The strings a and b are not equivalent with respect to M , because they cause M to end up in states r 1 and r 2 , respectively, starting at the start state q . • However, the strings aa and ba are equivalent with respect to M , be- cause both strings cause M to end up in state s . • Also, aa and aaa are equivalent with respect to M . Theorem 1.1 (2.5.1) For any deterministic fjnite automaton M = ( K, Σ , δ, s, F ) , and any strings x, y ∈ Σ ∗ , if x ∼ M y then x ≈ L ( M ) y . Proof: Suppose x ∼ M y . We want to show that x ≈ L ( M ) y , that is, for all z , xz ∈ L ( M ) ifg yz ∈ L ( M ) . y x ∗ ∗ → → • Suppose s M t 1 and s M t 2 , where s is the start state of M . • Because x ∼ M y , t 1 = t 2 .
6 Diagram: Example: xz yz ∗ ∗ → → • Now, for some states u 1 and u 2 , s M u 1 and s M u 2 . • However, in reading xz , M will fjrst read x and go to t 1 . • Then, starting in state t 1 , M will read z and go to u 1 . • In reading yz , M will fjrst read y and go to t 2 , which equals t 1 . • Then, starting in state t 2 , M will read z and go to state u 2 . • Because t 1 = t 2 and M is deterministic, u 1 = u 2 . • Thus xz is accepted ifg u 1 is an accepting state, ifg u 2 is an ac- cepting state, ifg yz is accepted. • So xz ∈ L ( M ) ifg yz ∈ L ( M ) . • Therefore x ≈ L ( M ) y . z t1 u1 x s y u2 t2 z a,b r1 a a,b q p b r2 M a,b
7 an accepting state. In general, • In this example, a ∼ M b because both a and b lead from the start state to state q . • Now, we claim that also a ≈ L ( M ) b . • This means that if az ∈ L ( M ) then bz ∈ L ( M ) and vice versa. • Let’s look at some z to see why this is true. • Consider z = a . • Then aa ∈ L ( M ) because a leads from the start state to state q and then a leads from state q to state r 1 , so aa leads to the state r 1 which is an accepting state of M . • Is bz ∈ L ( M ) also? • Yes, because b leads from the start state to state q and then a leads from state q to state r 1 . • Consider z = b . • Then ab ̸∈ L ( M ) because a leads to state q and then b leads to state r 2 which is not an accepting state. • Is bz ∈ L ( M ) ? • No because b leads to state q and then b leads to state r 2 which is not • The same holds for any z so az ∈ L ( M ) ifg bz ∈ L ( M ) , so a ≈ L ( M ) b . • if z leads from state q to an accepting state of M , then az ∈ L ( M ) and bz ∈ L ( M ) . • If z leads from state q to a non-accepting state of M , then az ̸∈ L ( M ) and bz ̸∈ L ( M ) . • So az ∈ L ( M ) ifg bz ∈ L ( M ) , so a ≈ L ( M ) b .
This theorem implies that: Also, The detailed proof is in the text. which has a number of states equal to the number of equivalence classes of • This is at least as large or larger than the number of equivalence classes Why? 8 Why? If there were more equivalence classes than states, then there must least as many states as the number of equivalence classes of the relation any deterministic fjnite automaton M recognizing L has to have at ≈ L . be some state q of M and two strings x, y in Σ ∗ such that x ̸≈ L y but x and y both end up in state q , so that x ∼ M y , This is impossible by the theorem. If L is regular then ≈ L has fjnitely many equivalence classes. • If L is regular then there is a fjnite automaton M recognizing L . • M has fjnitely many states. • But the number of states of M is the same as the number of equivalence classes of ∼ M (or larger if some states are unreachable), so the number of equivalence classes of ∼ M is fjnite. of ≈ L , which therefore must be fjnite. If x is an element of Σ ∗ then let [ x ] be the equivalence class of x , that is, the set of y such that x ≈ L y . Theorem 1.2 (2.5.2, Myhill-Nerode Theorem) Let L ⊆ Σ ∗ be a reg- ular language. Then there is a minimal deterministic fjnite automaton M the relation ≈ L . Proof: The states of M are the equivalence classes of ≈ L . The start state of M is [ e ] . The accepting states of M are the set of equivalence classes that are subsets of L . Defjne δ ([ x ] , a ) to be [ xa ] for x ∈ Σ ∗ and a ∈ Σ .
Recommend
More recommend