MATH 245 CH7 - DISCRETE DISCRETE MATHEMATICS W W L CHEN c W...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: DISCRETE DISCRETE MATHEMATICS W W L CHEN c W W L Chen, 1991, 2008. c W W L Chen, 1997, 2003. This chapter is available free to all individuals, on the understanding that it is not to be used for financial gains, This chapter is available free to all individuals, on the understanding that it is not to be used for financial gain, and may be downloaded and/or photocopied, with or without permission from the author. and may be downloaded and/or photocopied, with or without permission from the author. However, this document may not be kept on any information storage and retrieval system without permission However, this document may not be kept on any information storage and retrieval system without permission from the author, unless such system is not accessible to any individuals other than its owners. from the author, unless such system is not accessible to any individuals other than its owners. Chapter 7 FINITE STATE AUTOMATA 7.1. Deterministic Finite State Automata 7.1. Deterministic Finite State Automata different In this chapter, we discuss a slightly different version of finite state machines which is closely related to regular languages. We begin by an example which helps to illustrate the changes. Consider finite state machine which will recognize the input string 101 Example 7.1.1. Consider a a finite statemachine which will recognize the input string 101 and nothing else. This machine can be described by the following state diagram: start s1 1 ,0 s2 1 ,0 0 ,0 s3 1 ,1 0 ,0 0 ,0 s∗ 0 ,0 1 ,0 0 ,0 1 ,0 s4 We now make the following observations. At the end of a finite input string, the machine is at state s4 We now make the following observations. At the end of a finite input string, the machine is at state s4 if and only if the input string is 101. In other words, the input string 101 will send the machine to the if and only if the input string is 101. In other words, the input string 101 will send the machine to the state s4 at the end of the process, while any other finite input string will send the machine to a state state s4 at the end of the process, while any other finite input string will send the machine to a state different from s4 at the end of the process. The fact that the machine is at state s4 at the end of the different from s4 at the end of the process. The fact that the machine is at state s4 at the end of the process is therefore confirmation that the input string has been 101. On the other hand, the fact that process is therefore confirmation that the input string has been 101. On the other hand, the fact that the machine is not at state s4 at the end of the process is therefore confirmation that the input string the machine is not at state s4 at the end of the process is therefore confirmation that the input string has not been 101. It is therefore not necessary to use the information from the output string at all if we has not been 101. It is therefore not necessary to use the information from the output string at all if we give state s4 special status. The state s∗ can be considered a dump. The machine will go to this state give state s4 special status. The state s∗ can be considered a dump. The machine will go to this state at the moment it is clear that the input string has not been 101. Once the machine reaches this state, at the moment it is clear that the input string has not been 101. Once the machine reaches this state, it can never escape from this state. We can exclude the state s∗ from the state diagram, and further it can never escape from this state. We can exclude the state s∗ from the state diagram, and further Chapter 7 : Finite State Automata page 1 of 31 7–2 WW 7–2 W W L Chen : Discrete Mathematics Discrete Mathematics L Chen : Discrete Mathematics c W W L Chen, 1991, 2008 simplify the state diagram by stipulating that if ν (sii,, x) iis not indicated, then it is understood that simplify the state diagram by stipulating that if ν (si , x) is not indicated, then it is understood that simplify the state diagram by stipulating that if ν (s x) s not indicated, then it is understood that ν (sii,, x) = s∗ .. If we implement all of the above, then we obtain the following simplified state diagram, ν (si , x) = s∗ . If we implement all of the above, then we obtain the following simplified state diagram, ν (s x) = s∗ If we implement all of the above, then we obtain the following simplified state diagram, with the indication that s4 has special status and that s1 is the starting state: with the indication that s4 has special status and that s1 is the starting state: with the indication that s4 has special status and that s1 is the starting state: start start s1 s1 1 1 s2 s2 0 0 s3 s3 1 1 s4 s4 We can also describe the same information in the following transition table: We can also describe the same information in the following transition table: We can also describe the same information in the following transition table: 0 0 0 s∗ s∗ s∗ s3 s3 s3 s∗ s∗ s∗ s∗ s∗ s∗ s∗ s∗ s ∗ ν ν ν +s1 + +s1 + +s1 + s2 s2 s2 s3 s3 s3 −s4 − −s4 − −s4 − s∗ s∗ s∗ 1 1 1 s2 s2 s2 s∗ s∗ s∗ s4 s4 s4 s∗ s∗ s∗ s∗ s∗ s ∗ We now modify our definition a finite state machine accordingly. We now modify our definition of a finite state machine accordingly. We now modify our definition of of finite state machine accordingly. a Definition. A deterministic finite state automaton is a 5-tuple A = (S , I , ν, T , s1 ), where Definition. A deterministic finite state automaton isis a 5-tuple A = SSIIν, TT s1 ),), where Definition. A deterministic finite state automaton a 5-tuple A = ( ( , , , , ν, , , s1 where (a) S is the finite set of states for A; (a) S is the finite set of states for A;; (a) S is the finite set of states for A (b) I is the finite input alphabet for A; (b) I is the finite input alphabet for A;; (b) I is the finite input alphabet for A (c) ν : S × I → S is the next-state function; (c) ν :: S × I → S is the next-state function; (c) ν S × I → S is the next-state function; (d) T is a non-empty subset of S ;; and (d) T is a non-empty subset of S ; and (d) T is a non-empty subset of S and (e) s1 ∈ S is the starting state. (e) s1 ∈ S is the starting state. (e) s ∈ S is the starting state. 1 Remarks. (1) The states in T areare usually called the accepting states. Remarks. (1) The states in T are usually called the accepting states. Remarks. (1) The states in T usually called the accepting states. (2) If not indicated otherwise, we shall always take state s1 as the starting state. (2) If indicated otherwise, we we shall always take state s as starting state. (2) If not not indicated otherwise, shall always take state s1 as1 the the starting state. Example 7.1.2. We shall construct a deterministic finite state automaton which will recognize the Example 7.1.2. We shall construct a deterministic finite the Example 7.1.2. We shall construct a deterministic finite state automaton which will recognize the input strings 101 and 100(01)∗ ∗ and nothing else. This automaton candescribed by the following state input strings 101 and 100(01)and nothing else. This automaton can be be described by the following input strings 101 and 100(01)∗ and nothing else. This automaton can be described by the following state diagram: state diagram: diagram: start start s1 s1 1 1 s2 s2 0 0 s3 s3 1 1 0 0 s5 s5 0 0 1 1 s6 s6 s4 s4 We can also describe the same information in the following transition table: We can also describe the same information in the following transition table: We can also describe the same information in the following transition table: 0 0 0 s∗ s∗ s∗ s3 s3 s3 s5 s5 s5 s∗ s∗ s∗ s6 s6 s6 s∗ s∗ s∗ s∗ s∗ s∗ ν ν ν 1 1 1 s2 s2 s2 s∗ s∗ s∗ s4 s4 s4 s∗ s∗ s∗ s∗ s∗ s∗ s5 s5 s5 s∗ s∗ s∗ page 2 of 31 +s1 + +s1 + +s1 + s2 s2 s2 s3 s3 s3 −s4 − −s4 − −s4 − −s5 − −s5 − −s5 − s6 s6 s6 s∗ s∗ s∗ Chapter 7 : Finite State Automata Discrete Mathematics c WWL Chapter 7 : Finite State AutomataChen, 1991, 2008 7–3 Example 7.1.3. We shall construct a deterministic finite state automaton which will recognize the input 7.1.3. We shall construct a deterministic finite state automaton which will recognize the strings 1(01) 1(001)∗ (0 + ∗ (0 and nothing else. else. This automaton can be described by the following input strings∗1(01)∗ 1(001)1)1 + 1)1 and nothing This automaton can be described by the following state diagram: state diagram: start s1 1 s2 1 0 1 s4 1 1 s6 0 0 s3 s7 1 s5 1 s8 We can also describe the same information in the following transition table: We can also describe the same information in the following transition table: ν 0ν1 01 s∗ s2 s∗ s2 s3 s4 s3 s4 s∗ s2 s∗ s2 s5 s7 s5 s7 s6 s9 s6 s9 s∗ s4 s∗ s4 s∗ s8 s∗ s8 s∗ s∗ s∗ s∗ s∗ s∗ s∗ s∗ s∗ s∗ s∗ s∗ s9 +s1 + +s1 + s 2 s2 s3 s3 s4 s4 s5 s5 s6 s6 s7 s7 −s8 − −s8 − −s9 − −s9 − s ∗ s∗ 7.2. Equivalance of States and Minimization 7.2. Equivalance of States and Minimization Note that in Example 7.1.3, we can take ν (s5 , 1) = s8 and save a state s9 . As is in the case of finite Note that in Example a reduction take ν s5 , 1) on 8 and save a state s9 . As is in state machines, there is7.1.3, we canprocess (based = sthe idea of equivalence of states. the case of finite state machines, there is a reduction process based on the idea of equivalence of states. Suppose that A = (S , I , ν, T , s1 ) is a deterministic finite state automaton. Suppose that A = (S , I , ν, T , s1 ) is a deterministic finite state automaton. Definition. We say that two states si , sj ∈ S are 0-equivalent, denoted by si ∼0 sj , if either both = si , sj ∈ T or both saysj ∈ T two states si ,∈jN∈ we say that two states si , sj ∈ byare k -equivalent, denoted Definition. We si , that . For every k s , S are 0-equivalent, denoted S si ∼0 sj , if either both = by sji ∼kT j , if both 0ss, sand for every every 1, .∈. , k, and say that∈ I m , we have sj(si , x) are ν (-equivalent, = = si , s = s or si ∼ i j j ∈ T . For m = k . N we every x two states si , ν ∈ S ∼0 k sj , x) (here ∈ ν (si , x) = νi si ,kxsj.,.ifxm∼0 sj and for every m =the. .automaton after∈ I m , we have ν (sixx=∼x1ν (sjxm) ) denoted by s ( ∼ 1 . si = denotes the state of 1, . , k and every x the input string , ) =0 . . . , x , = starting si , x) = νsisi , x1 . . . xm ) denotessay that two states si , sj ∈ Safter equivalent,string x = x1s. .∼xsj , (here ν ( at state ( ). Furthermore, we the state of the automaton are the input denoted by i = m . if si ∼k sj for every kFurthermore, we say that two states si , sj ∈ S are equivalent, denoted by si ∼ sj , = starting at state si ). ∈ N ∪ {0}. = if si ∼k sj for every k ∈ N ∪ {0}. = Remark. Recall that for a finite state machine, two states si , sj ∈ S are k -equivalent if Remark. Recall that for a finite state machine, two states si , sj ∈ S are k -equivalent if ω (si , x1 x2 . . . xk ) = ω (sj , x1 x2 . . . xk ) ω (si , x1 x2 . . . xk ) = ω (sj , x1 x2 . . . xk ) Chapter 7 : Finite State Automata page 3 of 31 Discrete Mathematics c W W L Chen, 1991, 2008 for every x = x1 x2 . . . xk ∈ I k . For a deterministic finite state automaton, there is no output function. However, we can adopt a hypothetical output function ω : S × I → {0, 1} by stipulating that for every x ∈ I, ω (si , x) = 1 if and only if ν (si , x) ∈ T . Suppose that ω (si , x1 x2 . . . xk ) = y1 y2 . . . yk and ω (sj , x1 x2 . . . xk ) = y1 y2 . . . yk . Then the condition ω (si , x1 x2 . . . xk ) = ω (sj , x1 x2 . . . xk ) is equivalent to the conditions y1 = y1 , y2 = y2 , . . . , yk = yk which are equivalent to the conditions ν (si , x1 ), ν (sj , x1 ) ∈ T ν (si , x1 x2 ), ν (sj , x1 x2 ) ∈ T ν (si , x1 x2 . . . xk ), ν (sj , x1 x2 . . . xk ) ∈ T This motivates our definition for k -equivalence. Corresponding to Proposition 6A, we have the following result. The proof is reasonably obvious if we use the hypothetical output function just described. PROPOSITION 7A. (a) For every k ∈ N ∪ {0}, the relation ∼k is an equivalence relation on S . = (b) Suppose that si , sj ∈ S and k ∈ N, and that si ∼k sj . Then si ∼k−1 sj . Hence k -equivalence implies = = (k − 1)-equivalence. (c) Suppose that si , sj ∈ S and k ∈ N ∪ {0}. Then si ∼k+1 sj if and only if si ∼k sj and ν (si , x) ∼k = = = ν (sj , x) for every x ∈ I . THE MINIMIZATION PROCESS. (1) Start with k = 0. Clearly the states in T are 0-equivalent to each other, and the states in S \T are 0equivalent to each other. Denote by P0 the set of 0-equivalence classes of S . Clearly P0 = {T , S \T }. (2) Let Pk denote the set of k -equivalence classes of S (induced by ∼k ). In view of Proposition 7A(b), we = now examine all the states in each k -equivalence class of S , and use Proposition 7A(c) to determine Pk+1 , the set of all (k + 1)-equivalence classes of S (induced by ∼k+1 ). = (3) If Pk+1 = Pk , then increase k by 1 and repeat (2). (4) If Pk+1 = Pk , then the process is complete. We select one state from each equivalence class. Example 7.2.1. Let us apply the Minimization process to the deterministic finite state automaton discussed in Example 7.1.3. We have the following: ν ∼0 = A A A A A A A B B A ν ∼1 = A A A A B A B C C A ν ∼2 = A A A B C A C D D A ν ∼3 = A B A C D B D E E A page 4 of 31 or or . . . or ν (si , x1 ), ν (sj , x1 ) ∈ T , ν (si , x1 x2 ), ν (sj , x1 x2 ) ∈ T , ν (si , x1 x2 . . . xk ), ν (sj , x1 x2 . . . xk ) ∈ T . 0 +s1 + s2 s3 s4 s5 s6 s7 −s8 − −s9 − s∗ s∗ s3 s∗ s5 s6 s∗ s∗ s∗ s∗ s∗ 1 s2 s4 s2 s7 s9 s4 s8 s∗ s∗ s∗ 0 1 0 1 0 A A A C A A A A A A 1 A B A C D B D A A A AA AA AA AA AB AA AB AA AA AA AA AA AA BB AC AA AC AA AA AA Chapter 7 : Finite State Automata Discrete Mathematics Chapter 7 : Finite State Automata Chen, 1991, 2008 7–5 c WWL Continuing this process, we obtain the following: Continuing this process, we obtain the following: ν ν 01 1 0 ss∗ ss2 ∗ 2 ss3 ss4 3 4 ss∗ ss2 ∗ 2 ss5 ss7 5 7 ss6 ss9 6 9 ss∗ ss4 ∗ 4 ss∗ ss8 ∗ 8 ss∗ ss∗ ∗ ∗ ss∗ ss∗ ∗ ∗ ss∗ ss∗ ∗ ∗ ++ +ss1 + 1 ss2 2 ss3 3 ss4 4 ss5 5 ss6 6 ss7 7 −− −ss8 − 8 −− −ss9 − 9 ss∗ ∗ ∼ = ∼33 = A A B B A A C C D D B B D D E E E E A A ν ν 01 1 0 AB AB AC AC AB AB DD DD BE BE AC AC AE AE AA AA AA AA AA AA ∼ = ∼44 = A A B B A A C C D D B B E E F F F F G G ν ν 01 1 0 GB GB AC AC GB GB DE DE BF BF GC GC GF GF GG GG GG GG GG GG ∼ = ∼55 = A A B B A A C C D D E E F F G G G G H H 0 0 H H A A H H D D E E H H H H H H H H H H ν ν 1 1 B B C C B B F F G G C C G G H H H H H H ∼6 = ∼6 = A A B B A A C C D D E E F F G G G G H H Choosing s1 and s8 and discarding s3 and s9 , we have the following minimized transition table: Choosing s1 and s8 and discarding s3 and s9 , we have the following minimized transition table: 0 0 s∗ s∗ s1 s1 s5 s5 s6 s6 s∗ s∗ s∗ s∗ s∗ s∗ s∗ s∗ ν ν 1 1 s2 s2 s4 s4 s7 s7 s8 s8 s4 s4 s8 s8 s∗ s∗ s∗ s∗ +s1 + +s1 + s2 s2 s4 s4 s5 s5 s6 s6 s7 s7 −s8 − −s8 − s∗ s∗ Note that any reference to the removed state s9 is now taken over by the state s8 . We also have the 9 8 We following state diagram of the minimized automaton: start s1 1 0 s2 1 s4 1 1 s6 0 0 s7 1 s5 1 s8 Remark. As is in the case of finite state machines, we can further remove any state which is unreachable Remark. As is in the case of finite state machines, we can further remove any state which is unreachable from the starting state s1 if any such state exists. Indeed, such states can be removed before or after from the starting state s1 if any such state exists. Indeed, such states can be removed before or after the application of the Minimization process. the application of the Minimization process. 7.3. Non-Deterministic Finite State Automata 7.3. Non-Deterministic Finite State Automata To motivate our discussion in this section, we consider a very simple example. To motivate our discussion in this section, we consider a very simple example. Chapter 7 : Finite State Automata page 5 of 31 7–6 WW Discrete Mathematics L Chen : Discrete Mathematics c W W L Chen, 1991, 2008 Example 7.3.1. Consider the following state diagram: Consider the following state diagram: start (1) t1 1 1 0 t2 t3 0 t4 (1) Suppose that at state t1 and with input 1, the automaton has equal probability of moving to state t2 or Suppose that at state t1 and with input 1, the automaton has equal probability of moving to state t2 or to state t3 . Then with input string 10, the automaton may end up at state t1 (via state t2 ) or state t4 to state t3 . Then with input string 10, the automaton may end up at state t1 (via state t2 ) or state t4 (via state t3 ). On the other hand, with input string 1010, the automaton may end up at state t1 (via (via state t3 ). On the other hand, with input string 1010, the automaton may end up at state t1 (via states t2 , t1 and t2 ), state t4 (via states t2 , t1 and t3 ) or the dumping state t∗ (via states t3 and t4 ). Note states t2 , t1 and t2 ), state t4 (via states t2 , t1 and t3 ) or the dumping state t∗ (via states t3 and t4 ). Note that t4 is an accepting state while the other states are not. This is an example of a non-deterministic that t4 is an accepting state while the other states are not. This is an example of a non-deterministic finite state automaton. Any string in the regular language 10(10)∗ may send the automaton to the finite state automaton. Any string in the regular language 10(10)∗ may send the automaton to the accepting state t4 or to some non-accepting state. The important point is that there is a chance that accepting state t4 or to some non-accepting state. The important point is that there is a chance that the automaton may end up at an accepting state. On the other hand, this non-deterministic finite state the automaton may end up at an accepting state. On the other hand, this non-deterministic finite state automaton can be described by the following transition table: automaton can be described by the following transition table: 0 0 t1 t1 t4 t4 ν ν 1 1 t2 , t3 t2 , t3 +t1 + +t1 + t2 t2 t3 t3 −t4 − −t4 − Here it is convenient not to include any reference to the dumping state t∗ .. Note also that we can think Here it is convenient not to include any reference to the dumping state t∗ Note also that we can think of ν (ti ,, x) as a subset of S .. of ν (t x) as a subset of S i Our goal in chapter is to show that that for any language with alphabet 0 and 1, 0 and 1, it is Our goal in thisthis chapter is to show for any regular regular language with alphabet it is possible to possible to design a deterministicautomaton that will recognize will recognize language. that language. design a deterministic finite state finite state automaton that precisely that precisely Our technique Our technique is to constructing a non-deterministic finite state automaton and then converting itthen is to do this by first do this by first constructing a non-deterministic finite state automaton and to a converting it to a deterministic finite state automaton. deterministic finite state automaton. The reason this approach is that non-deterministic finite state state automata are easier to design; The reason for for this approach is that non-deterministic finite automata are easier to design; indeed, indeed, the technique involved systematic. On the On thehand, the conversion processprocess to deterthe technique involved is very is very systematic. other other hand, the conversion to deterministic ministic finite state automata is rather implement. finite state automata is rather easy to easy to implement. InIn this section, we shall considernon-deterministic finite state automata. In Section 7.4, we shall this section, we shall consider non-deterministic finite state automata. In Section 7.4, we shall consider their relationship to regular languages. We shall then discuss in Section 7.5 a process which consider their relationship to regular languages. We shall then discuss in Section 7.5 a process which will convert non-deterministic finite state automata to deterministic finite state automata. will convert non-deterministic finite state automata to deterministic finite state automata. Definition. AA non-deterministic finite state automaton is a 5-tuple A = SSI Iν, T T t1t),), where Definition. non-deterministic finite state automaton is a 5-tuple A = ( ( , , , , ν, , , 1 where (a) S is the finite set of states for A;; (a) S is the finite set of states for A (b) I is the finite input alphabet for A;; (b) I is the finite input alphabet for A (c) ν :: S × I → P (S ) iis the next-state function, where P (S ) iis the collection of all subsets of S ;; (c) ν S × I → P (S ) s the next-state function, where P (S ) s the collection of all subsets of S (d) T is a non-empty subset of S ;; and (d) T is a non-empty subset of S and (e) t1 ∈ S is the starting state. (e) t1 ∈ S is the starting state. Remarks. (1) The states in T areare usually called the accepting states. (1) The states in T usually called the accepting states. (2) If indicated otherwise, we we shall always take state t as starting state. (2) If not not indicated otherwise, shall always take state t1 as1 the the starting state. Chapter 7 : Finite State Automata page 6 of 31 Discrete Mathematics Chapter 7 : Finite State Automata Chen, 1991, 7–7 c WWL 2008 (3) convenience, we we do not reference to the dumping state state t∗ . the conversion process (3) For For convenience,do not makemake reference to the dumpingt∗ . Indeed,Indeed, the conversion process in Section 7.5 will be clearerclearer do we do not include t∗ in S simply leave entries blank in the in Section 7.5 will be much much if we if not include t∗ in S and and simply leave entries blank in the transition table. transition table. For practical convenience, shall modify our our approach slightly by introducing null transitions. For practical convenience, we we shall modify approach slightly by introducing null transitions. These These are useful in the early stages indesign of a of a non-deterministic finite state automaton and can are useful in the early stages in the the design non-deterministic finite state automaton and can be be removed later on. To motivate this, we elaborate on our earlier example. removed later on. To motivate this, we elaborate on our earlier example. Example 7.3.2. Let λ λ denote the null string. Then the non-deterministic finite state automaton Let denote the null string. Then the non-deterministic finite state automaton deExample described by the state diagram (1) can be represented by the following state diagram: scribed by the state diagram (1) can be represented by the following state diagram: start λ t1 1 0 t2 t5 1 t3 0 t4 In this case, the input string 1010 can be interpreted as 10λ10 and so will be accepted. On the other In this case, the input string 1010 can be interpreted as 10λ10 and so will be accepted. On the other hand, the same input string 1010 can be interpreted as 1010 and so the automaton will end up at state hand, the same input string 1010 can be interpreted as 1010 and so the automaton will end up at state t1 (via states t2 , t1 and t2 ). However, the same input string 1010 can also be interpreted as λ1010 and t1 (via states t2 , t1 and t2 ). However, the same input string 1010 can also be interpreted as λ1010 and so the automaton will end up at the dumping state t∗ (via states t5 , t3 and t4 ). We have the following so the automaton will end up at the dumping state t∗ (via states t5 , t3 and t4 ). We have the following transition table: transition table: 0 0 t1 t1 t4 t 4 +t1 + +t1 + t2 t2 t3 t3 −t4 − −t4 − t5 t 5 ν ν 1 1 t2 t 2 λ λ t5 t 5 t3 t3 Remarks. (1) While null transitions are useful inin the earlystages in the design of a non-deterministic Remarks. (1) While null transitions are useful the early stages in the design of a non-deterministic finite state automaton, we have to remove them later on. finite state automaton, we have to remove them later on. (2) can think of of transitions as free free transitions. can can be removed provided that for (2) We We can thinknull null transitions as transitions. TheyTheybe removed provided that for every every ti and ievery every input λ, = λ,take take ,ν () ito )denote the the collectionall the the states that can state state t and input x = x we we ν (ti x t , x to denote collection of of all states that can be be reached from state by by inputwith thethe help null transitions. reached from state ti ti input x x with help of of null transitions. (3) If collection ν (t , λ i λ) contains an accepting state, then state ti ti should also considered an (3) If the the collection iν (t) ,contains an accepting state, then thethe stateshould also be be considered an accepting state, evenit is notnot explicitly given such. accepting state, even if if it is explicitly given as as such. (4) Theoretically, ν t ) contains ti . However, this piece of useless information can be ignored in (4) Theoretically, ν (ti ,(λi , λ) contains. tiHowever, this piece of useless information can be ignored in view of (2) above. view of (2) above. (5) Again, in view of above, it is convenient not to refer to t or to include it in S (5) Again, in view of (2)(2) above, it is convenient not to refer to ∗t∗or to include it in S .. It is very is very convenient to represent by a blank entry in the transition table the fact that ν (tii,, x) does not contain convenient to represent by a blank entry in the transition table the fact that ν (t x) does not contain any state. any state. InIn practice, we may not needto use transition tables where null transitions are involved. We may practice, we may not need to use transition tables where null transitions are involved. may design a non-deterministic finite state automaton by drawing a state diagram with null transitions. We design a non-deterministic finite state automaton by drawing a state diagram with null transitions. We then produce from this state diagram a transition table for the automaton without null transitions. We then produce from this state diagram a transition table for the automaton without null transitions. We illustrate this technique through the use of two examples. illustrate this technique through the use of two examples. Chapter 7 : Finite State Automata page 7 of 31 7–8 WW Discrete Mathematics L Chen : Discrete Mathematics c W W L Chen, 1991, 2008 Example 7.3.3. Consider the non-deterministic finite state automaton described earlier by following Example 7.3.3. Consider the non-deterministic finite state automaton described earlier by following state diagram: state diagram: start λ t1 1 0 t2 t5 1 t3 0 t4 It is clear that ν (t1 ,, 0) is empty, while ν (t1 ,, 1) contains states t2 and t3 (the latter via state t5 with the It is clear that ν (t1 0) is empty, while ν (t1 1) contains states t2 and t3 (the latter via state t5 with the help of a null transition) but not states t1 ,, t4 and t5 .. We therefore have the following partial transition help of a null transition) but not states t1 t4 and t5 We therefore have the following partial transition table: table: 0 +t1 + 1 t2 2 t3 3 −t4 − 4 t5 5 ν 1 t2 , t3 23 Next, it is clear that ν (t2 , 0) contains states t1 and t5 (the latter via state t1 with the help of a null 2 1 5 1 transition) but not states t2 , t3 and t4 , while ν (t2 , 1) is empty. We therefore have the following partial 23 4 2 transition table: 0 0 +t 1 + +t1 + t2 t2 t3 t3 −t4 − − t4 − t5 t5 t1 t5 t1 ,, t5 ν ν 1 1 t2 t3 t2 ,, t3 With similar arguments, we can complete the transition table as follows: 0 +t1 + 1 t2 2 t3 3 −t4 − 4 t5 5 t1 , t5 15 t4 4 ν 1 t2 , t3 23 t3 3 Example 7.3.4. Consider the non-deterministic finite state automaton described by following state 7.3.4. Consider the non-deterministic finite state automaton described by diagram: start t1 1 1 1 t2 λ λ t3 0 λ 0 t4 Chapter 7 : Finite State Automata 0 t5 1 t6 page 8 of 31 Discrete Mathematics Chapter 7 : Finite State AutomataChen, 1991, 2008 7–9 c WWL It is clear that ν (t1 , 0) contains states t3 and t4 (both via state t5 with the help of a null transition) as It is clear that ν (t1 , 0) contains states t3 and t4 (both via state t5 with the help of a null transition) as well as t6 (via states t5 , t2 and t3 with the help of three null transitions), but not states t1 , t2 and t5 . well as t6 (via states t5 , t2 and t3 with the help of three null transitions), but not states t1 , t2 and t5 . On the other hand, ν (t1 , 1) contains states t2 and t4 as well as t3 (via state t2 with the help of a null On the other hand, ν (t1 , 1) contains states t2 and t4 as well as t3 (via state t2 with the help of a null transition) and t6 (via state t5 with the help of a null transition), but not states t1 and t5 . We therefore transition) and t6 (via state t5 with the help of a null transition), but not states t1 and t5 . We therefore have the following partial transition table: have the following partial transition table: 0 0 t3 , t4 , t6 t ,t ,t 3 4 ν ν +t1 + +t 1 + t2 t2 −t3 − −t 3 − t4 t4 t5 t5 t6 t 6 6 1 1 t2 , t3 , t4 , t6 t ,t ,t ,t 2 3 4 6 With similar arguments, we can complete the entries of the transition table as follows: With similar arguments, we can complete the entries of the transition table as follows: 0 0 t3 , t4 , t6 t3 , t4 , t6 t6 t6 t6 t6 t3 , t4 , t6 t3 , t4 , t6 ν ν 1 1 t2 , t3 , t4 , t6 t2 , t3 , t4 , t6 t1 , t2 , t3 , t5 t1 , t2 , t3 , t5 t6 t6 +t1 + +t 1 + t2 t2 −t3 − −t 3 − t4 t4 t5 t5 t6 t6 Finally, note that since t3 is an accepting state, and can be reached from states t1 , t2 and t5 with the help 3 12 5 of null transitions. Hence these three states should also be considered accepting states. We therefore have the following transition table: 0 +t1 − −t2 − −t3 − t4 −t5 − t6 t3 , t4 , t6 t6 t6 t3 , t4 , t6 ν 1 t2 , t3 , t4 , t6 t1 , t2 , t3 , t5 t6 It It possible to to remove the null transitions inmore systematic way. WeWe first illustrate the ideas is is possible remove the null transitions in a a more systematic way. first illustrate the ideas by considering two examples. by considering two examples. Example 7.3.5. Consider the non-deterministic finite state automaton described by following state Consider the non-deterministic finite state automaton described by diagram: start t1 1 t2 λ 1 t3 1 λ 1 t4 0 0 1 t5 Chapter 7 : Finite State Automata λ t6 page 9 of 31 Discrete Mathematics c W W L Chen, 1991, 2008 This can be represented by the following transition table with null transitions: 0 +t1 + t2 −t3 − t4 −t5 − t6 t5 ν 1 t2 t2 t3 t3 , t4 λ t3 t4 t6 t4 We shall modify this (partial) transition table step by step, removing the column of null transitions at the end. (1) Let us list all the null transitions described in the transition table: t2 − − − t3 − −→ t3 − − − t4 − −→ t5 − − − t6 − −→ We shall refer to this list in step (2) below. (2) We consider attaching extra null transitions at the end of an input. For example, the inputs 0, 0λ, 0λλ, . . . are the same. Consider now the first null transition on our list, the null transition from state t2 to state t3 . Clearly if we arrive at state t2 , we can move on to state t3 via the null transition, as illustrated below: ? − − − t2 − − − t3 − −→ − −→ Consequently, whenever state t2 is listed in the (partial) transition table, we can freely add state t3 to it. Implementing this, we modify the (partial) transition table as follows: 0 +t 1 + t2 −t 3 − t4 −t 5 − t6 t5 ν 1 t2 , t3 t2 , t3 t3 t3 , t4 λ t3 t4 t6 ? λ λ λ λ t4 Consider next the second null transition on our list, the null transition from state t3 to state t4 . Clearly if we arrive at state t3 , we can move on to state t4 via the null transition. Consequently, whenever state t3 is listed in the (partial) transition table, we can freely add state t4 to it. Implementing this, we modify the (partial) transition table as follows: 0 +t 1 + t2 −t 3 − t4 −t 5 − t6 Chapter 7 : Finite State Automata 1 ν λ t3 , t4 t4 t6 t5 t2 , t3 , t4 t2 , t3 , t4 t3 , t4 t3 , t4 t4 page 10 of 31 Discrete Mathematics c W W L Chen, 1991, 2008 Consider finally the third null transition on our list, the null transition from state t5 to state t6 . Clearly if we arrive at state t5 , we can move on to state t6 via the null transition. Consequently, whenever state t5 is listed in the (partial) transition table, we can freely add state t6 to it. Implementing this, we modify the (partial) transition table as follows: ν 1 t2 , t3 , t4 t2 , t3 , t4 t3 , t4 t3 , t4 0 +t1 + t2 −t3 − t4 −t5 − t6 t5 , t6 λ t3 , t4 t4 t6 t4 We now repeat the same process with the three null transitions on our list, and observe that there are no further modifications to the (partial) transition table. If we examine the column for null transitions, we note that it is possible to arrive at one of the accepting states t3 or t5 from state t2 via null transitions. It follows that the accepting states are now states t2 , t3 and t5 . Implementing this, we modify the (partial) transition table as follows: ν 1 t2 , t3 , t4 t2 , t3 , t4 t3 , t4 t3 , t4 0 +t1 + −t2 − −t3 − t4 −t5 − t6 t5 , t6 λ t3 , t4 t4 t6 t4 We may ask here why we repeat the process of going through all the null transitions on the list. We shall discuss this point in the next example. (3) We now update our list of null transitions in step (1) in view of extra information obtained in step (2). Using the column of null transitions in the (partial) transition table, we list all the null transitions: t2 − − − t3 , t4 − −→ t3 − − − t4 − −→ t5 − − − t6 − −→ We shall refer to this list in step (4) below. (4) We consider attaching extra null transitions before an input. For example, the inputs 0, λ0, λλ0, . . . are the same. Consider now the first null transitions on our updated list, the null transitions from state t2 to states t3 and t4 . Clearly if we depart from state t3 or t4 , we can imagine that we have first arrived from state t2 via a null transition, as illustrated below: t2 − − − t3 − − − ? − −→ − −→ t2 − − − t4 − − − ? − −→ − −→ Consequently, any destination from state t3 or t4 can also be considered a destination from state t2 with the same input. It follows that we can add rows 3 and 4 to row 2. Implementing this, we Chapter 7 : Finite State Automata page 11 of 31 λ ? λ ? λ λ λ 7–12 MathematicsW L Chen : Discrete Mathematics W Discrete c W W L Chen, 1991, 2008 modify the (partial) transition table as follows: modify the (partial) transition table as follows: 0 0 t5 , t6 t5 , t6 ν ν 1 1 t2 , t3 , t4 t2 , t3 , t4 t2 , t3 , t4 t2 , t3 , t4 t2 , t3 , t4 t2 , t3 , t4 t3 , t4 t3 , t4 t3 , t4 t ,t 3 4 +t1 + +t1 + −t2 − −t2 − −t3 − −t3 − t4 t4 −t5 − −t5 − t6 t 6 λ λ t3 , t4 t3 , t4 t4 t4 t6 t6 t4 t4 Consider next the second null transition on our updated list, the null transition from state t3 to state Consider next the second null transition on our updated list, the null transition from state t3 to state t4 . Clearly if we depart from state t4 , we can imagine that we have first arrived from state t3 via t4 . Clearly if we depart from state t4 , we can imagine that we have first arrived from state t3 via a null transition. Consequently, any destination from state t4 can also be considered a destination a null transition. Consequently, any destination from state t4 can also be considered a destination from state t3 with the same input. It follows that we can add row 4 to row 3. Implementing this, from state t3 with the same input. It follows that we can add row 4 to row 3. Implementing this, we realize that there is no change to the (partial) transition table. Consider finally the third null we realize that there is no change to the (partial) transition table. Consider finally the third null transition on our updated list, the null transition from state t5 to state t6 . Clearly if we depart from transition on our updated list, the null transition from state t5 to state t6 . Clearly if we depart from state t6 , we can imagine that we have first arrived from state t5 via a null transition. Consequently, state t6 , we can imagine that we have first arrived from state t5 via a null transition. Consequently, any destination from state t6 can also be considered a destination from state t5 with the same input. any destination from state t6 can also be considered a destination from state t5 with the same input. It follows that we can add row 6 to row 5. Implementing this, we modify the (partial) transition It follows that we can add row 6 to row 5. Implementing this, we modify the (partial) transition table as follows: table as follows: 0 0 +t1 + +t1 + −t2 − −t2 − −t3 − −t3 − t4 t4 −t5 − −t5 − t6 t6 t5 , t6 t5 , t6 t4 t4 t4 t4 ν ν 1 1 t2 , t3 , t4 t2 , t3 , t4 t2 , t3 , t4 t2 , t3 , t4 t2 , t3 , t4 t2 , t3 , t4 t3 , t4 t3 , t4 t3 , t4 t3 , t4 λ λ t3 , t4 t3 , t4 t4 t4 t6 t6 (5) We can now remove the column of null transitions to obtain the transition table below: 0 +t1 + −t2 − −t3 − t4 −t5 − t6 t5 , t6 t4 t4 ν 1 t2 , t3 , t4 t2 , t3 , t4 t2 , t3 , t4 t3 , t4 t3 , t4 Example 7.3.6. Consider the non-deterministic finite state automaton described by following state 7.3.6. Consider the non-deterministic finite state automaton described diagram: start t1 1 1 t2 λ t3 0 t4 1 λ λ t5 Chapter 7 : Finite State Automata 0 t6 0 t7 page 12 of 31 Discrete Mathematics c W W L Chen, 1991, 2008 This can be represented by the following transition table with null transitions: 0 +t1 + t2 t3 t4 t5 −t6 − −t7 − ν 1 t2 t4 t5 t6 t7 t1 λ t3 t6 t2 We shall modify this (partial) transition table step by step, removing the column of null transitions at the end. (1) Let us list all the null transitions described in the transition table: t2 − − − t3 − −→ t3 − − − t6 − −→ t6 − − − t2 − −→ We shall refer to this list in step (2) below. (2) We consider attaching extra null transitions at the end of an input. In view of the first null transition from state t2 to state t3 , whenever state t2 is listed in the (partial) transition table, we can freely add state t3 to it. We now implement this. Next, in view of the second null transition from state t3 to state t6 , whenever state t3 is listed in the (partial) transition table, we can freely add state t6 to it. We now implement this. Finally, in view of the third null transition from state t6 to state t2 , whenever state t6 is listed in the (partial) transition table, we can freely add state t2 to it. We now implement this. We should obtain the following modified (partial) transition table: 0 +t1 + t2 t3 t4 t5 −t6 − −t7 − 1 ν λ t2 , t3 , t6 t2 , t6 t2 , t3 , t6 λ λ λ t2 , t3 , t6 t4 t5 t2 , t6 t7 t1 We now repeat the same process with the three null transitions on our list, and obtain the following modified (partial) transition table: 0 +t 1 + t2 t3 t4 t5 −t 6 − −t 7 − Chapter 7 : Finite State Automata ν 1 t2 , t3 , t6 λ t2 , t3 , t6 t2 , t3 , t6 t2 , t3 , t6 t4 t5 t2 , t3 , t6 t7 t1 page 13 of 31 Discrete Mathematics c W W L Chen, 1991, 2008 Observe that the repetition here gives extra information like the following: t7 − − − t3 − −→ We see from the state diagram that this is achieved by the following: t7 − − − t6 − − − t2 − − − t3 − −→ − −→ − −→ If we do not have the repetition, then we may possibly be restricting ourselves to only one use of a null transition, and will only get as far as the following: t7 − − − t6 − − − t2 − −→ − −→ We now repeat the same process with the three null transitions on our list one more time, and observe that there are no further modifications to the (partial) transition table. This means that we cannot attach any extra null transitions at the end. If we examine the column for null transitions, we note that it is possible to arrive at one of the accepting states t6 or t7 from states t2 or t3 via null transitions. It follows that the accepting states are now states t2 , t3 , t6 and t7 . Implementing this, we modify the (partial) transition table as follows: 0 +t 1 + −t 2 − −t 3 − t4 t5 −t 6 − −t 7 − ν 1 t2 , t3 , t6 t4 t5 t2 , t3 , t6 t7 t1 λ t2 , t3 , t6 t2 , t3 , t6 t2 , t3 , t6 0 λ 0 λ λ 0 (3) We now update our list of null transitions in step (1) in view of extra information obtained in step (2). Using the column of null transitions in the (partial) transition table, we list all the null transitions: t2 − − − t2 , t3 , t6 − −→ t3 − − − t2 , t3 , t6 − −→ t6 − − − t2 , t3 , t6 − −→ We shall refer to this list in step (4) below. (4) We consider attaching extra null transitions before an input. In view of the first null transitions from state t2 to states t2 , t3 and t6 , we can add rows 2, 3 and 6 to row 2. We now implement this. Next, in view of the second null transitions from state t3 to states t2 , t3 and t6 , we can add rows 2, 3 and 6 to row 3. We now implement this. Finally, in view of the third null transitions from state t6 to states t2 , t3 and t6 , we can add rows 2, 3 and 6 to row 6. We now implement this. We should obtain the following modified (partial) transition table: 0 +t 1 + −t 2 − −t 3 − t4 t5 −t 6 − −t 7 − Chapter 7 : Finite State Automata λ λ λ ν 1 t2 , t3 , t6 t7 t1 λ t2 , t3 , t6 t2 , t3 , t6 t2 , t3 , t6 t4 , t5 t4 , t5 t4 , t5 t2 , t3 , t6 page 14 of 31 Discrete Mathematics c W W L Chen, 1991, 2008 (5) We can now remove the column of null transitions to obtain the transition table below: 0 +t 1 + −t 2 − −t 3 − t4 t5 −t 6 − −t 7 − t4 , t5 t4 , t5 t4 , t5 t2 , t3 , t6 ν 1 t2 , t3 , t6 t7 t1 ALGORITHM FOR REMOVING NULL TRANSITIONS. (1) Start with a (partial) transition table of the non-deterministic finite state automaton which includes information for every transition shown on the state diagram. Write down the list of all null transitions shown in this table. (2) Follow the list of null transitions in step (1) one by one. For any null transition ti − − − tj − −→ on the list, freely add state tj to any occurrence of state ti in the (partial) transition table. After completing this task for the whole list of null transitions, repeat the entire process again and again, until a full repetition yields no further changes to the (partial) transition table. We then examine the column of null transitions to determine from which states it is possible to arrive at an accepting state via null transitions only. We include these extra states as accepting states. (3) Update the list of null transitions in step (1) in view of extra information obtained in step (2). Using the column of null transitions in the (partial) transition table, we list all the null transitions originating from all states. (4) Follow the list of null transitions in step (3) originating from each state. For any null transitions ti − − − tj1 , . . . , t jk − −→ on the list, add rows j1 , . . . , jk to row i. (5) Remove the column of null transitions to obtain the full transition table without null transitions. Remarks. (1) It is important to repeat step (2) until a full repetition yields no further modifications. Then we have analyzed the network of null transitions fully. (2) There is no need for repetition in step (4), as we are using the full network of null transitions obtained in step (2). (3) The network of null transitions can be analyzed by using Warshall’s algorithm on directed graphs. See Section 20.1. λ λ 7.4. Regular Languages Recall that a regular language on the alphabet I is either empty or can be built up from elements of I by using only concatenation and the operations + (union) and ∗ (Kleene closure). It is well known that a language L with the alphabet I is regular if and only if there exists a finite state automaton with inputs in I that accepts precisely the strings in L. Chapter 7 : Finite State Automata page 15 of 31 Discrete Mathematics c W W L Chen, 1991, 2008 Here we shall concentrate on the task of showing that for any regular language L on the alphabet 0 7–161, we can construct a finite state automaton that accepts precisely the strings in L. This will follow W W L Chen : Discrete Mathematics and 7–16 the following result. W W L Chen : Discrete Mathematics from 7–16 W W L Chen : Discrete Mathematics 7–16 W W L Chen : Discrete Mathematics PROPOSITION 7B. Consider languages with alphabet 0 and 1. PROPOSITION 7B. Consider languages there alphabet finite state automaton that accepts precisely (a) For each of the languages L = ∅, λ, 0, 1, with exists a 0 and 1. PROPOSITIONL.languages L = languages there alphabet finite state automaton that accepts precisely (a) For strings in 7B. Consider ∅, λ, 0, 1, with exists a 0 and 1. the each of the (a) the strings in the finite state = languages there B accept finite state automaton that accepts precisely (b) For each that L.languages L automata1A with alphabet 0 and 1. the strings in the languages L and Suppose of the7B. Consider ∅, λ, 0, , and exists a precisely PROPOSITION PROPOSITIONL.languages L existsλa0finitewith B automaton AB. that strings inthat languages L and (b) the strings in the Then there automata1A and exists a 0 and 1 the accepts the accepts precisely Suppose thatthe finite state = ∅, , , , state accept precisely M each of (a) For respectively.7B. Consider languages there alphabet finite state automatonprecisely the strings in (a) the rlanguagethe .languages L existsλa 0, 1A there B automaton AB that strings inthat languages L and (b) For strings in theThen there automata , and exists a finite state automaton the acceptsstrings in Suppose that LM . M espectively. finite state = ∅, , finite state accept precisely the accepts precisely the precisely the each of L M strings in the . language L (c) Suppose that LM finite state automata A and B accept precisely the accepts in the languages L and Suppose that the finite state automata A state accept precisely the strings precisely the strings in (b) the respectively. . Then there exists a finiteand B automaton AB that strings in the languages L and (b) M rlanguage LM finitethere exists a finiteand B automaton AB that strings in the languages strings the respectively. Then state automata A state accept precisely the accepts precisely the strings in (c) Suppose that theThen there exists a finite state automaton A + B that accepts precisely the L and M espectively. . M respectively. Then there exists a finiteand B automaton AB that accepts in the languages strings (c) the the language L + M . Suppose that LM . A + the strings precisely the strings in in language the finite state automata A state accept precisely B that accepts precisely the L and thethe language Lfinite there exists a finiteand B automaton A + Bstrings in in the languages.strings M language LM . finitestate automaton state accept precisely that accepts language L in respectively. Then . stateautomata A A accepts precisely thethe strings theprecisely the LThen +M (d) Suppose that the (c) Suppose that the and (c) Suppose that the finite. stateautomata A thataccepts precisely+ Bstrings in theprecisely the∗ .L and in respectively. Then state automaton A B automaton A the strings in (d) M the exists atheLfinitethere exists a finiteand acceptsprecisely thethe strings in the languages strings that finite M there language + state automaton A∗ state accept precisely that accepts language L. Then M respectively. L + state automaton finiteA accepts precisely + B strings (d) in theexists a the finite. state automaton thataccepts precisely the strings in theprecisely the∗ . Then Suppose that finite M L there language Then there exists a A∗ state automaton A the that accepts language L . strings in theexists a the finite. state automaton thataccepts precisely the strings in the language L∗ . Then M there language L + state automaton A∗ concatenation, union the strings in the language L. finite(c) and (d) deal with A accepts precisely and Kleene closure respectively. (d) Suppose parts (b), Note that that (d) there that parts (b),stateand (d) dealA∗ thataccepts precisely theand Kleene the language L∗ . Then Suppose that the finite state automaton Aconcatenation, union strings in the language L. Note exists a finite (c) automaton with accepts precisely the strings in closure respectively. Note exists a finite (c) automaton with concatenation, union and Kleene closure respectively. there that parts (b),stateand (d) dealA∗ that accepts precisely the strings in the language L∗ . For the remainder of this section, we shall use non-deterministic finite state automata with null For that parts (b), (c) automata with null Notethe remainder of this section, we shall use non-deterministic finite state also respectively. transitions. Recall that null and (d) deal with concatenation,Section and Kleene closure show in Section transitions can be removed; see union 7.3. We shall For that parts (b), (c) and (d) deal with removed; see Section 7.3. We state automata with null Notethe remainder null transitions can be concatenation, union and Kleene closure respectively. transitions. Recall that of this section, we shall use non-deterministic finite shall also show in Section 7.5 how we may convert a non-deterministic finite state automaton into a deterministic one. transitions. Recall that null transitions we shall use non-deterministic aWe state automata with null 7.5 how we may convertof non-deterministic be removed;automaton intofinite shall also show in Section For the remainder a this section, can finite state see Section 7.3. deterministic one. For the Recall that a this section, can finite state see Section 7.3. deterministic one. 7.5 how we may convertnull transitions we shall use non-deterministic aWe state automata with null transitions. isremainder of non-deterministic be removed;automaton intofinite shall also show in Section Part (a) is transitions. mayeasily proved. The finitecan beautomata automaton into aWe shall also show in Section Part (a) easily proved. The finite state automata 7.5 how we Recall that null transitions state removed; see Section 7.3. deterministic one. convert a non-deterministic finite state Part (a) is convert a non-deterministic finite state 7.5 how we mayeasily proved. The finite state automata automaton into a deterministic one. t1 t1 start start and Part (a) is easily proved. The finite state automata Part (a) is easily proved. The finite state automata t1 t1 start start and accept precisely the languages ∅ and λ respectively. On the start hand, the finite state automata other t1 t1 start and accept precisely the languages ∅ and λ respectively. On the other hand, the finite state automata other t1 t1 accept precisely the languages ∅ and λ respectively. On the start hand, the finite state automata start and 0 1 t1 t2 t1 t2 start and accept precisely the languages ∅ and λ respectively. On the start hand, the finite state automata other 0 1 accept precisely the languages ∅ and λ respectively. On the start hand, the finite state automata other t1 t2 t1 t2 start and 0 1 respectively. 1 accept precisely the languages 0 and t1 t2 t1 t2 start start and 0 1 accept precisely the languages 0 and 1 respectively. t1 t2 t1 t2 start start and accept precisely the languages 0 and 1 the finite state automata A and B accept precisely the strings in CONCATENATION. Suppose thatrespectively. accept precisely the languages 0 and 1 respectively. CONCATENATION. Suppose that the finite state automata A and B accept precisely the strings in accept precisely the languages 0 and Then the finite state automaton AB constructed as follows accepts the languages L and M respectively. 1 respectively. CONCATENATION. language Then the languagesstrings in the Supposethat the finite state automata A and B constructed as follows accepts precisely the L and M Suppose that : finite state automata A and B accept precisely the strings in CONCATENATION.respectively. LMthethe finite state automaton AB accept precisely the strings in the languages L and M respectively. Then finite The automata A are B states of A and B strings in CONCATENATION.respectively. LMthethe finite state automaton AB constructed as follows accepts precisely label strings in theA and B that fferently. state states of AB and theaccept precisely the combined. language Then (1) We the L states the languages theand M of Suppose all di: the finite state automaton AB constructed as follows accepts preciselylabel strings in ofespectively. LM fferently. The states of A. AB c states of A and B combined. the L state r language Then the languagesstrings in theAB is taken di:: be the starting stateof AB are theonstructed as follows accepts (1) We the theand M theA and B all to the finite state automaton (2) The starting states of language LM precisely (1) precisely label stringsstates oflanguageall diffbe the starting stateof AB are B . states of A and B combined. (2) The the the states of A AB taken to: erently. The states states of the (3) We starting state of A and B LM to be the accepting of A. accepting in of and B taken (1) We label the states theAB is areall differently. The states of AB are the states of A and B combined. (2) The acceptingstate of AB is taken to be be starting , w introduce extra starting all (1) Weaddition to states of AB areall diffbe the startingBstate states are B . states of A and B combined. (3) In starting state of A and Btransitionsthe theand state of A. (4) The label the statesthe AB is taken to erently. The stateseof AB. of the null transitions from each existing taken to in A accepting of A (2) (3) In the accepting statesexisting taken to be theand B The accepting states AB are taken to in A of state introduce extra null transitions from each (2) The startingto states ofof A arethe to be the stateaccepting states of B .. (4) The accepting all the of AB totransitions be startingB ,. we of A. of B of addition state of AB is taken starting the accepting states (3) (3) The accepting states ofof A arethe starting stateaccepting states of Bextra null transitions from each (4) In the accepting statesexisting transitions be theand B ,, we introduce extra null transitions from each In addition to all the AB to taken to in A of of addition to all the existing transitions in A and B . we introduce . (4) (4) In the accepting statesexisting automata state of B of the accepting the of A to the starting A and B Example 7.4.1.to allstates of statetransitions instate of B ,.. we introduce extra null transitions from each The finite A to the starting of addition Example 7.4.1. The finite state automata state of B . of the accepting states of A to the starting 0 1 t1 t2 t4 t3 Example 7.4.1. The finite state0 automata start start and Example 7.4.1. The finite state automata 1 0 1 Example 7.4.1. The finite state automata t1 t2 t4 t3 start start and ∗ t t2 t4 t3 start start accept precisely the strings1 of the 0 languages 0(00)and 1(11)∗ respectively. The finite1state automaton and t1 of the 0 t2 0(00)and 1(11)∗ respectively. The finite1state automaton t4 t3 ∗ start start accept precisely the strings languages and 0 1 λ accept precisely the strings of the languages 0(00)∗ and 1(11)∗ respectively. The finite state automaton t1 t3 t4 start accept precisely the strings of the languages 0 0(00)∗ t2 1(11)∗ respectively. The finite state automaton and 0 1 λ accept precisely the strings of the languages 0(00)∗ and 1(11)∗ respectively.1 The finite state automaton t1 t2 t3 t4 start λ t1 t2 t3 t4 start accepts precisely the strings of the language 0(00)∗ 1(11)∗ . λ 0 1 0 1 t1 t3 t4 ∗ t2 ∗ start accepts precisely the strings of the language 0(00) 1(11) . 0 1 Remark. It is the strings of the the two 0(00)∗ the ∗ . accepts precisely important to keep languageparts of1(11)automaton AB apart by a null transition in one Remark. It Suppose, instead, that two 0(00) ∗ the ∗ accepts precisely important to keep languageparts of1(11)automaton AB2apart by a null transition in one direction only. is the strings of the thewe combine ∗ 1(11)∗ .. accepts precisely the strings of the language 0(00) the accepting state t of the first automaton with the directionstate t3 important to keep thewe combineof the automaton AB 2apart by a null transition in one starting Remark.only. is of the second automaton. Then the finite state state t of the first automaton with the It Suppose, instead, that two parts the accepting automaton Remark.only.t3 important to keep thewe combinethe finite state state t apart by a null transition in one It Suppose, instead, that two parts the accepting automaton starting state is of the second automaton. Then of the automaton AB of the first automaton with the direction : Finite State Automata 2 Chapter 7 page 16 of 31 0 1 directionstate t Suppose, instead, that we combine the accepting state t2 of t first automaton with the starting only. 3 of the second automaton. Then the 0finite state automatonthe t1 t2 start 4 1 1 starting state t3 of the second automaton. Then the 0finite state automaton 4 t1 t2 t start 0 0 1 1 0 1 0 0 1 1 t language 0(00)2 1(11)∗1 t∗ start accepts the string 011001 which is not in the 1 . 0 0 t language 0(00)2 1(11)∗1 t∗ start is not in the 1 accepts the string 011001 which . 0 1 0 0 1 1 t4 t4 start t1 0 0 t2 and start t3 1 1 t4 accept precisely the strings of the languages 0(00)∗ and 1(11)∗ respectively. The finite state automaton Discrete Mathematics start t1 0 0 t2 λ t3 1 1 c t4 W L Chen, 1991, 2008 W accepts precisely the strings of the language 0(00)∗ 1(11)∗ . Remark. ItIt isimportant to keep the two parts of the automaton AB apart by a null transition in one is important to keep the two parts of the automaton AB apart direction only. Suppose, instead, that we combine theChapter 7 :state t2 State Automata accepting Finite of the first automaton with the 7–17 2 7–17 starting state t3 of the second automaton. Then the Chapter 7 :automaton Automata finite state Finite State 3 Chapter 7 : Finite State Automata 7–17 t1 t2 t4 start 0 1 UNION. Suppose that the finite state automata A and B accept precisely the strings in the languages UNION. respectively. Then finite statestate automaton A +∗B constructed the follows acceptslanguages Suppose that L and M string 011001the theis finite automata A and B accept precisely as strings in the precisely accepts the string 011001 which finite in the language A +∗1(11)∗ accepts the which not automata A and B 1(11)precisely as strings in the precisely UNION. Suppose that the the is statestate language 0(00)accept ∗.. L and M respectively. Then finite: not in the automaton0(00) B constructed the follows acceptslanguages the strings in the language L + M L strings espectively. Then the : theand M rin the language L + Mfinite state automaton A + B constructed as follows accepts precisely (1) We label the states of finite UNION. in the states of A M B all differently. The states of A + B are the states of A and B the strings Suppose that theL +and: B all differently. and B states of A + B the strings in the A and B (1) We label the language A and state automata A The accept precisely are the states of languages combined plus an extra state t . L and M respectively.extra A the t 1B all differently. The statesconstructed are follows acceptsA and B (1) combined the statesThen andfinite state automaton A + B of A + B as the states of precisely We label plus an of state . (2) strings in the state extra L + Mt: taken to be the state t1 . The starting language + B is1 . the combined plus an of A state 1 (2) The starting state of A + B is taken to be the state t1 . (3) The starting states of A + is taken differently. The (1) We accepting states A and B taken to be the accepting of A + A are B states of (2) The label the state of of A B B areall to to be state t1 . statesstates of B and thecombined. A and B (3) The accepting states of + + Bt are takenbe the the accepting states of A and B combined. combined plus an extra state 1 . (4) In addition to all the of A + Btransitions to be and accepting states of A and Btransitions from t1 to A , (3) The accepting all states existing transitions in A the B, we introduce extra null combined. are (4) In addition tostatetheA and from t takenbestarting state e introduce extra null transitions from t1 to (2) the starting state of existingis taken to inthe and Bt1 w of B . The starting of A + B state . 1 to the (4) theaddition to all of A and+ Btransitions in be and state e introduce of A and B combined.from t1 to (3) In starting state the of A from t1 taken to A the accepting states extra null transitions The accepting states existing are to the starting B , w of B . the addition to all of Aexisting transitions in A and state ofintroduce extra null transitions from t to (4) In starting state the and from t1 to the starting B , we B . 1 Example 7.4.2. state of A and from t1 to the starting state of B . the starting The finite state automata Example 7.4.2. The finite state automata Example 7.4.2. The finite state automata 0 1 Example 7.4.2. The finite state automata t2 t3 t5 t4 start start and 0 1 0 1 t2 t3 t5 t4 start start and 0 1 0 1 t2 t3 t5 t4 start start and accept precisely the strings of the languages 0(00)∗ and 1(11)∗ respectively. The finite state automaton accept precisely the strings of the languages 0(00)∗ and 1(11)∗ respectively. The finite state automaton accept precisely the strings of the languages 0(00)∗ and 1(11)∗ respectively. The finite state automaton accept precisely the strings of the languages 0(00)∗ and 1(11)∗ respectively. The finite state automaton λ λ λ 0 1 0 1 t2 t2 t2 0 0 0 0 0 0 t3 t3 t3 start start start t1 t1 t1 λ λ λ t4 t4 t4 1 1 1 1 1 1 t5 t5 t5 accepts precisely the strings of the language 0(00)∗ + 1(11)∗ , while the finite state automaton accepts precisely the strings of the language 0(00)∗ + 1(11)∗ while the finite state automaton accepts precisely the strings of the language 0(00)∗ + 1(11)∗ ,, while the finite state automaton accepts precisely the strings of the language 0(00)∗ + 1(11)∗ , while the finite state automaton 0 t2 t3 0 0 t2 t3 0 0 λ λ t2 t3 λ λ start start start t1 t1 t1 λ 0 λ t4 t5 1 λ 1 t4 t5 1 1 t4 t5 ∗1 ∗ ∗ accepts precisely the strings of the language (0(00)∗ + 1(11)∗ )0(00)∗ accepts precisely the strings of the language (0(00)∗ + 1(11)∗ )0(00)∗ .. accepts precisely the strings of the language (0(00) + 1(11) )0(00) . ∗ ∗ accepts precisely the strings of the that the finite state 1(11)∗ )0(00)A. accepts precisely the strings in the KLEENE CLOSURE. Suppose language (0(00) + automaton ∗ state automaton A accepts precisely the strings in the KLEENE .CLOSURE. Supposeautomaton A constructed as follows accepts precisely the strings in language L Then the finite state that the finite KLEENE .CLOSURE. Suppose that the finite constructed as follows accepts precisely the stringsthe ∗ language L Then the finite state automaton A∗ state automaton A accepts precisely the strings in in the language L∗ : KLEENE Then the finite Suppose that the finite state automaton A accepts precisely the strings in in language L.CLOSURE. thestate automaton A constructed as follows accepts precisely the stringsthe ∗ ∗ the language L∗ : A are (1) The states of states of A. ∗ language L. L : the constructed as follows accepts precisely the strings in the language Thenstate finite∗ state automaton Astarting state of A. (2) The states The starting ∗ of A is taken A (1) language L∗of A∗ are the states of to .be the the The states of A are the states of A. : (1) In addition to all the existing transitions in A, we introduce extra null transitions from each of the (3) (2) The starting state of A∗ is be the starting state of A. (1) The statesstates∗ ofof the is taken to be the starting state of A. (2) The starting stateare A∗ thetaken to . state of A. accepting of A A to states of A starting (3) The startingto all the A∗ ∗ taken to be the starting introduce extra null transitions from each of the In addition state of existing transitions in A, we state of A. (2) The accepting state of (4) accepting states of A existingtaken to be in starting state of A. (3) In addition to all the toA is isstarting statethe A,. we introduce extra null transitions from each of the the transitions of A (3) accepting states ofthe to the starting state in A,. we introduce extra null transitions from each of the In addition to all A existing transitions of A (4) The accepting state of A∗ is taken to be the starting state of A. accepting states Automata Chapter 7 : Finite State of of A∗ is taken to be the A. page 17 of 31 (4) The accepting stateA to the starting state of starting state of A. (4) The accepting state of A∗ is taken to be the starting state of A. Remark. Of course, each of the accepting states of A are also accepting states of A∗ since it is possible Remark. via a null transition. However, itstates of A are also accepting states of A∗ this stage.possible to reach A Of course, each of the accepting is not important to worry about this at since it is Remark. Of course, each of the accepting is not important to worry about this at∗ since it is to reach A via a null transition. However, itstates of A are also accepting states of A this stage. possible λ λ λ 1 λ λ t6 t6 t6 0 0 0 0 0 0 t7 t7 t7 Discrete 7–18 MathematicsW L Chen : W W L Chen : 7–18 W 7–18 W W L Chen : 7–18 W W L Chen : 7–18 W W L Chen : Discrete Mathematics Discrete Mathematics Discrete Mathematics Discrete Mathematics Discrete Mathematics c W W L Chen, 1991, 2008 Remark. each of the accepting states of A are also accepting states of A Example Of course, follows from our last example that the finite state automaton ∗ since it is possible Example 7.4.3. It follows from our last example that the finite state automaton 7.4.3. It Example 7.4.3. null follows from our last it is not important to worry about this at this stage. to reach A7.4.3. It follows from our last example that the finite state automaton via a It transition. However, example that the finite state automaton Example Example 7.4.3. It follows from our last example that the 0finite state automaton 0 t2 t3 Example 7.4.3. It follows from our last example that the finite state automaton 0 t2 t3 0 0 t2 t3 0 t2 t3 0 0 t t3 λ2 λ λ λ λ 0λ λ λ λ λ start start start start start t1 t1 t1 t1 t λ1 λ λ λ λ λ λ λ λ 1λ 1 t4 1 t4 1 1 t4 1 t4 1 1 ∗ t4 ∗∗ accepts precisely the strings of the language (0(00) ∗ + 1(11) ∗) ∗. 1 accepts precisely the strings of the language (0(00)∗ + 1(11)∗ )∗ . accepts precisely the strings of the language (0(00) + 1(11) ) . accepts precisely the strings of the language (0(00)∗ + 1(11)∗ )∗ . ∗ ∗∗ ∗ ∗∗ accepts precisely The finite state automaton Example 7.4.4. the strings of the automaton Example 7.4.4. The finite state language (0(00) + 1(11) ) . Example 7.4.4. The finite state automaton Example 7.4.4. The finite state automaton Example 7.4.4. The finite state automaton 1 t2 1 start Example 7.4.4. The finite state automaton t2 start 1 t2 start 1 t2 start 1 t2 start 1 1 1 1 1 t5 t5 t5 t5 t5 t4 t4 t t4 4 t40 0 0 0 t30 t3 t t3 3 t3 automaton accepts precisely the strings of the language 1(011)∗ . The finite state automaton accepts precisely the strings of the language 1(011)∗ . The finite state accepts precisely the strings of the language 1(011)∗ . The finite state automaton ∗ accepts precisely the strings of the language 1(011)∗ . The finite state automaton 0 1 accepts precisely the strings of the language t1(011)∗ .0 The finite state automaton t6 t7 1 start t5 t6 t7 start 0 1 t5 t6 t7 start 0 1 t5 t6 t7 start 5 0 1 accepts precisely the strings of the language t5 The finite state automaton7 t6 t start accepts precisely the strings of the language 01. The finite state automaton 01. accepts precisely the strings of the language 01. The finite state automaton accepts precisely the strings of the language 01. The finite state automaton 1 accepts precisely the strings of the language 01. The8finite state automaton t t9 1 start t8 t9 start 1 t8 t9 start 1 t8 t9 start 1 accepts precisely the strings of thestart t8 t9 accepts precisely the strings of the language 1. It follows that the finite state automaton language 1. It follows that the finite state automaton accepts precisely the strings of the language 1. It follows that the finite state automaton accepts precisely the strings of the language 1. It follows that the finite state automaton 1 accepts precisely the strings of the language 1. It follows that the finite state automaton t2 t4 1 t2 t4 1 t2 t4 1 t2 t4 1 λ t2 t40 λ λ λ start start start start start t1 t1 t1 t1 t1 λ λ λ λ λ λ λ λ λ λ λ 1 1 1 1 1 0 0 0 t5 t5 t5 t5 t 05 0 0 0 λ λ λ λ λ t30 t3 t3 t3 t3λ λ λ λ 1 1 1 1 1 0 t7 t6 1 t7 t6 1 t7 t6 1 t7 t6 1 ∗ ∗ t7 accepts precisely the strings of the language 1 (1(011)t + (01)∗ )1. accepts precisely the strings of the language (1(011)∗6+ (01)∗ )1. accepts precisely the strings of the language (1(011)∗ + (01)∗ )1. ∗ accepts precisely the strings of the language (1(011) + (01) )1. accepts precisely the strings of the language (1(011)∗ + (01)∗ )1. Chapter 7 : Finite State Automata accepts precisely the strings of the language (1(011)∗ + (01)∗ )1. t8λ t8 t8 t8 t8 t9 t9 t t9 9 t9 page 18 of 31 Discrete Mathematics c W W L Chen, 1991, 2008 7.5. Conversion to Deterministic Finite State Automata In this section, we describe a technique which enables us to convert a non-deterministic finite state automaton without null transitions to a deterministic finite state automaton. Recall that we have already discussed in Section 7.3 how we may remove null transitions and obtain the transition table of a non-deterministic finite state automaton. Hence our starting point in this section is such a transition table. Suppose that A = (S , I , ν, T , t1 ) is a non-deterministic finite state automaton, and that the dumping state t∗ is not included in S . Our idea is to consider a deterministic finite state automaton where the states are subsets of S . It follows that if our non-deterministic finite state automaton has n states, then we may end up with a deterministic finite state automaton with 2n states, where 2n is the number of different subsets of S . However, many of these states may be unreachable from the starting state, and so we have no reason to include them. We shall therefore describe an algorithm where we shall eliminate all such unreachable states in the process. We shall illustrate the Conversion process with two examples, the first one complete with running commentary. Example 7.5.1. Consider the non-deterministic finite state automaton described by the following transition table: 0 +t 1 + t2 −t 3 − t4 t5 t2 , t3 t5 t2 t5 ν 1 t1 , t4 t2 t3 t5 t1 Here S = {t1 , t2 , t3 , t4 , t5 }. We begin with a state s1 representing the subset {t1 } of S . To calculate ν (s1 , 0), note that ν (t1 , 0) = {t2 , t3 }. We now let s2 denote the subset {t2 , t3 } of S , and write ν (s1 , 0) = s2 . To calculate ν (s1 , 1), note that ν (t1 , 1) = {t1 , t4 }. We now let s3 denote the subset {t1 , t4 } of S , and write ν (s1 , 1) = s3 . We have the following partial transition table: 0 +s1 + s2 s3 s2 ν 1 s3 t1 t2 , t3 t1 , t4 Next, note that s2 = {t2 , t3 }. To calculate ν (s2 , 0), note that ν (t2 , 0) ∪ ν (t3 , 0) = {t2 , t5 }. We now let s4 denote the subset {t2 , t5 } of S , and write ν (s2 , 0) = s4 . To calculate ν (s2 , 1), note that ν (t2 , 1) ∪ ν (t3 , 1) = {t2 , t3 } = s2 , so ν (s2 , 1) = s2 . We have the following partial transition table: 0 +s1 + s2 s3 s4 Chapter 7 : Finite State Automata ν 1 s3 s2 t1 t2 , t3 t1 , t4 t2 , t5 page 19 of 31 s2 s4 Discrete Mathematics c W W L Chen, 1991, 2008 Next, note that s3 = {t1 , t4 }. To calculate ν (s3 , 0), note that ν (t1 , 0) ∪ ν (t4 , 0) = {t2 , t3 } = s2 , so ν (s3 , 0) = s2 . To calculate ν (s3 , 1), note that ν (t1 , 1) ∪ ν (t4 , 1) = {t1 , t4 , t5 }. We now let s5 denote the subset {t1 , t4 , t5 } of S , and write ν (s3 , 1) = s5 . We have the following partial transition table: 0 +s1 + s2 s3 s4 s5 s2 s4 s2 ν 1 s3 s2 s5 t1 t2 , t3 t1 , t4 t2 , t5 t1 , t4 , t5 Next, note that s4 = {t2 , t5 }. To calculate ν (s4 , 0), note that ν (t2 , 0) ∪ ν (t5 , 0) = {t5 }. We now let s6 denote the subset {t5 } of S , and write ν (s4 , 0) = s6 . To calculate ν (s4 , 1), note that ν (t2 , 1) ∪ ν (t5 , 1) = {t1 , t2 }. We now let s7 denote the subset {t1 , t2 } of S , and write ν (s4 , 1) = s7 . We have the following partial transition table: 0 +s1 + s2 s3 s4 s5 s6 s7 s2 s4 s2 s6 ν 1 s3 s2 s5 s7 t1 t2 , t3 t1 , t4 t2 , t5 t1 , t4 , t5 t5 t1 , t2 Next, note that s5 = {t1 , t4 , t5 }. To calculate ν (s5 , 0), note that ν (t1 , 0) ∪ ν (t4 , 0) ∪ ν (t5 , 0) = {t2 , t3 , t5 }. We now let s8 denote the subset {t2 , t3 , t5 } of S , and write ν (s5 , 0) = s8 . To calculate ν (s5 , 1), note that ν (t1 , 1) ∪ ν (t4 , 1) ∪ ν (t5 , 1) = {t1 , t4 , t5 } = s5 , so ν (s5 , 1) = s5 . We have the following partial transition table: 0 +s1 + s2 s3 s4 s5 s6 s7 s8 Chapter 7 : Finite State Automata ν 1 s3 s2 s5 s7 s5 t1 t2 , t3 t1 , t4 t2 , t5 t1 , t4 , t5 t5 t1 , t2 t2 , t3 , t5 page 20 of 31 s2 s4 s2 s6 s8 Discrete Mathematics c W W L Chen, 1991, 2008 Next, note that s6 = {t5 }. To calculate ν (s6 , 0), note that ν (t5 , 0) = {t5 } = s6 , so ν (s6 , 0) = s6 . To calculate ν (s6 , 1), note that ν (t5 , 1) = {t1 } = s1 , so ν (s6 , 1) = s1 . We have the following partial transition table: 0 +s1 + s2 s3 s4 s5 s6 s7 s8 s2 s4 s2 s6 s8 s6 ν 1 s3 s2 s5 s7 s5 s1 t1 t2 , t3 t1 , t4 t2 , t5 t1 , t4 , t5 t5 t1 , t2 t2 , t3 , t5 Next, note that s7 = {t1 , t2 }. To calculate ν (s7 , 0), note that ν (t1 , 0) ∪ ν (t2 , 0) = {t2 , t3 , t5 } = s8 , so ν (s7 , 0) = s8 . To calculate ν (s7 , 1), note that ν (t1 , 1) ∪ ν (t2 , 1) = {t1 , t2 , t4 }. We now let s9 denote the subset {t1 , t2 , t4 } of S , and write ν (s7 , 1) = s9 . We have the following partial transition table: 0 +s1 + s2 s3 s4 s5 s6 s7 s8 s9 s2 s4 s2 s6 s8 s6 s8 ν 1 s3 s2 s5 s7 s5 s1 s9 t1 t2 , t3 t1 , t4 t2 , t5 t1 , t4 , t5 t5 t1 , t2 t2 , t3 , t5 t1 , t2 , t4 Next, note that s8 = {t2 , t3 , t5 }. To calculate ν (s8 , 0), note that ν (t2 , 0) ∪ ν (t3 , 0) ∪ ν (t5 , 0) = {t2 , t5 } = s4 , so ν (s8 , 0) = s4 . To calculate ν (s8 , 1), note that ν (t2 , 1) ∪ ν (t3 , 1) ∪ ν (t5 , 1) = {t1 , t2 , t3 }. Chapter 7 : Finite State Automata page 21 of 31 Discrete Mathematics c W W L Chen, 1991, 2008 We now let s10 denote the subset {t1 , t2 , t3 } of S , and write ν (s8 , 1) = s10 . We have the following partial transition table: 0 +s1 + s2 s3 s4 s5 s6 s7 s8 s9 s10 s2 s4 s2 s6 s8 s6 s8 s4 ν 1 s3 s2 s5 s7 s5 s1 s9 s10 t1 t2 , t3 t1 , t4 t2 , t5 t1 , t4 , t5 t5 t1 , t2 t2 , t3 , t5 t1 , t2 , t4 t1 , t2 , t3 Next, note that s9 = {t1 , t2 , t4 }. To calculate ν (s9 , 0), note that ν (t1 , 0) ∪ ν (t2 , 0) ∪ ν (t4 , 0) = {t2 , t3 , t5 } = s8 , so ν (s9 , 0) = s8 . To calculate ν (s9 , 1), note that ν (t1 , 1) ∪ ν (t2 , 1) ∪ ν (t4 , 1) = {t1 , t2 , t4 , t5 }. We now let s11 denote the subset {t1 , t2 , t4 , t5 } of S , and write ν (s9 , 1) = s11 . We have the following partial transition table: ν 0 +s1 + s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s2 s4 s2 s6 s8 s6 s8 s4 s8 1 s3 s2 s5 s7 s5 s1 s9 s10 s11 t1 t2 , t3 t1 , t4 t2 , t5 t1 , t4 , t5 t5 t1 , t2 t2 , t3 , t5 t1 , t2 , t4 t1 , t2 , t3 t1 , t2 , t4 , t5 Next, note that s10 = {t1 , t2 , t3 }. To calculate ν (s10 , 0), note that ν (t1 , 0) ∪ ν (t2 , 0) ∪ ν (t3 , 0) = {t2 , t3 , t5 } = s8 , so ν (s10 , 0) = s8 . To calculate ν (s10 , 1), note that ν (t1 , 1) ∪ ν (t2 , 1) ∪ ν (t3 , 1) = {t1 , t2 , t3 , t4 }. We now let s12 denote the subset {t1 , t2 , t3 , t4 } of S , and write ν (s10 , 1) = s12 . We have the following Chapter 7 : Finite State Automata page 22 of 31 Discrete Mathematics c W W L Chen, 1991, 2008 partial transition table: 0 +s1 + s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12 s2 s4 s2 s6 s8 s6 s8 s4 s8 s8 ν 1 s3 s2 s5 s7 s5 s1 s9 s10 s11 s12 t1 t2 , t3 t1 , t4 t2 , t5 t1 , t4 , t5 t5 t1 , t2 t2 , t3 , t5 t1 , t2 , t4 t1 , t2 , t3 t1 , t2 , t4 , t5 t1 , t2 , t3 , t4 Next, note that s11 = {t1 , t2 , t4 , t5 }. To calculate ν (s11 , 0), note that ν (t1 , 0) ∪ ν (t2 , 0) ∪ ν (t4 , 0) ∪ ν (t5 , 0) = {t2 , t3 , t5 } = s8 , so ν (s11 , 0) = s8 . To calculate ν (s11 , 1), note that ν (t1 , 1) ∪ ν (t2 , 1) ∪ ν (t4 , 1) ∪ ν (t5 , 1) = {t1 , t2 , t4 , t5 } = s11 , so ν (s11 , 1) = s11 . We have the following partial transition table: 0 +s1 + s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12 s2 s4 s2 s6 s8 s6 s8 s4 s8 s8 s8 ν 1 s3 s2 s5 s7 s5 s1 s9 s10 s11 s12 s11 t1 t2 , t3 t1 , t4 t2 , t5 t1 , t4 , t5 t5 t1 , t2 t2 , t3 , t5 t1 , t2 , t4 t1 , t2 , t3 t1 , t2 , t4 , t5 t1 , t2 , t3 , t4 Next, note that s12 = {t1 , t2 , t3 , t4 }. To calculate ν (s12 , 0), note that ν (t1 , 0) ∪ ν (t2 , 0) ∪ ν (t3 , 0) ∪ ν (t4 , 0) = {t2 , t3 , t5 } = s8 , so ν (s12 , 0) = s8 . To calculate ν (s12 , 1), note that ν (t1 , 1) ∪ ν (t2 , 1) ∪ ν (t3 , 1) ∪ ν (t4 , 1) = {t1 , t2 , t3 , t4 , t5 }. We now let s13 denote the subset {t1 , t2 , t3 , t4 , t5 } of S , and write ν (s12 , 1) = s13 . We have the following Chapter 7 : Finite State Automata page 23 of 31 Discrete Mathematics c W W L Chen, 1991, 2008 partial transition table: ν 0 +s1 + s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12 s13 s2 s4 s2 s6 s8 s6 s8 s4 s8 s8 s8 s8 1 s3 s2 s5 s7 s5 s1 s9 s10 s11 s12 s11 s13 t1 t2 , t3 t1 , t4 t2 , t5 t1 , t4 , t5 t5 t1 , t2 t2 , t3 , t5 t1 , t2 , t4 t1 , t2 , t3 t1 , t2 , t4 , t5 t1 , t2 , t3 , t4 t1 , t2 , t3 , t4 , t5 Next, note that s13 = {t1 , t2 , t3 , t4 , t5 }. To calculate ν (s13 , 0), note that ν (t1 , 0) ∪ ν (t2 , 0) ∪ ν (t3 , 0) ∪ ν (t4 , 0) ∪ ν (t5 , 0) = {t2 , t3 , t5 } = s8 , so ν (s13 , 0) = s8 . To calculate ν (s13 , 1), note that ν (t1 , 1) ∪ ν (t2 , 1) ∪ ν (t3 , 1) ∪ ν (t4 , 1) ∪ ν (t5 , 1) = {t1 , t2 , t3 , t4 , t5 } = s13 , so ν (s13 , 1) = s13 . We have the following partial transition table: ν 0 +s1 + −s2 − s3 s4 s5 s6 s7 −s8 − s9 −s10 − s11 −s12 − −s13 − s2 s4 s2 s6 s8 s6 s8 s4 s8 s8 s8 s8 s8 1 s3 s2 s5 s7 s5 s1 s9 s10 s11 s12 s11 s13 s13 This completes the entries of the transition table. In this final transition table, we have also indicated all the accepting states. Note that t3 is the accepting state in the original non-deterministic finite state automaton, and that it is contained in states s2 , s8 , s10 , s12 and s13 . These are the accepting states of the deterministic finite state automaton. The confident reader, out of boredom, may have read only part of the last example. However, the next example must be studied carefully. Chapter 7 : Finite State Automata page 24 of 31 Discrete Mathematics c W W L Chen, 1991, 2008 Example 7.5.2. Consider the non-deterministic finite state automaton described by the following transition table: 0 +t1 + −t2 − t3 t4 t3 t4 ν 1 t2 t1 , t2 Here S = {t1 , t2 , t3 , t4 }. We begin with a state s1 representing the subset {t1 } of S . The reader should check that we should arrive at the following partial transition table: 0 +s1 + s2 s3 s2 ν 1 s3 t1 t3 t2 Next, note that s2 = {t3 }. To calculate ν (s2 , 0), we note that ν (t3 , 0) = ∅. Hence we write ν (s2 , 0) = s∗ , the dumping state. This dumping state s∗ has transitions ν (s∗ , 0) = ν (s∗ , 1) = s∗ . To calculate ν (s2 , 1), we note that ν (t3 , 1) = {t1 , t2 }. We now let s4 denote the subset {t1 , t2 } of S , and write ν (s2 , 1) = s4 . We have the following partial transition table: 0 +s1 + s2 s3 s4 s∗ s2 s∗ s∗ ν 1 s3 s4 s∗ t1 t3 t2 t1 , t2 ∅ The reader should try to complete the entries of the transition table: 0 +s1 + s2 s3 s4 s∗ s2 s∗ s∗ s2 s∗ ν 1 s3 s4 s∗ s3 s∗ t1 t3 t2 t1 , t2 ∅ On the other hand, note that t2 is the accepting state in the original non-deterministic finite state automaton, and that it is contained in states s3 and s4 . These are the accepting states of the deterministic finite state automaton. Inserting this information and deleting the right hand column gives the following complete transition table: 0 +s1 + s2 −s3 − −s4 − s∗ Chapter 7 : Finite State Automata ν 1 s3 s4 s∗ s3 s∗ page 25 of 31 s2 s∗ s∗ s2 s∗ 7–26 W W L Chen : Discrete Mathematics 7–26 W 7–26 MathematicsW L Chen : Discrete Mathematics W W L Chen : Discrete Mathematics Discrete c W W L Chen, 1991, 2008 7.6. A Complete Example 7.6. A Complete Example A Complete Example 7.6. A Complete Example 7.6. In this last section, we shall design from scratch the deterministic finite state automaton which will In this last section, we shall design from scratch the deterministic finite state automaton which will last section, we shall which will In this precisely the strings in the language scratch the deterministic finite state automatondiscussed in accept precisely the strings in design from 1(01)∗ 1(001)∗ (0 + 1)1. Recall that this has been discussed in accept precisely the strings in the language 1(01)∗ 1(001)∗ (0 + 1)1. Recall that this has been discussed in the language 1(01)∗ 1(001)∗ (0 + 1)1. Recall that this has been ∗ ∗ accept Examples 7.1.3 and 7.2.1. The reader is advised that it is extremely important to fill in all the missing Examples 7.1.3 and 7.2.1. The reader is advised that it is extremely important to fill in all the missing 7.1.3 and 7.2.1. The Examples the discussion here. reader is advised that it is extremely important to fill in all the missing details in the discussion here. details in the discussion here. in details We start with non-deterministic finite state automata with null transitions, and break the language We start with non-deterministic finite state automata with null transitions, and break start finite state We start with non-deterministic finite state automata with null transitions, and break the language ∗ ∗ into We parts:with non-deterministic + 1) and 1. automata with null transitions, and break the language into six parts: 1, (01)∗ , 1, (001)∗ , (0 + 1) and 1. These six parts are joined together by concatenation. six parts: 1, (01) ∗, 1, (001) ∗, (0 + 1) and 1. These six parts are joined together by concatenation. 1, (01)∗ , 1, (001)∗ , (0 1) These six parts are joined together by concatenation. 1, (0 into six Clearly the three automata Clearly the three automata Clearly the three automata Clearly the three automata start start start start start start start start start t1 t1 t1 t5 t5 t5 t13 t13 t13 1 1 1 t2 t2 t2 t6 t6 t6 t14 t14 t14 1 1 1 1 1 1 are the same and accept precisely the strings of the language 1. are the same and accept precisely the strings of the language 1. are the same and accept precisely the strings of the language 1. On the other hand, the automaton On the other hand, the automaton On the other hand, the automaton On the other hand, the automaton start start start t3 t3 t3 0 0 0 1 1 1 t4 t4 t4 accepts precisely the strings of the language (01)∗ , and the automaton accepts precisely the strings of the language (01)∗ , and the automaton accepts precisely the strings of the language (01)∗ , and the automaton start start start t7 t7 t7 0 0 0 t8 t8 t8 0 0 0 1 1 1 t9 t9 t9 accepts precisely the strings of the language (001)∗ . Note that we have slightly simplified the construction ∗ accepts precisely the strings of the language (001)∗ . Note that we have slightly simplified the construction accepts precisely the strings of the language (001)∗ . Note that we have slightly simplified the construction here by removing null transitions. here by removing null transitions. by removing null transitions. here Finally, the automaton Finally, the automaton Finally, the automaton Finally, the automaton t11 t11 t11 0 0 0 start start start t10 t10 t10 1 1 1 t12 t12 t12 accepts precisely the strings of the language (0 + 1). accepts precisely the strings of the language (0 + 1). accepts precisely the strings of the language (0 + 1). accepts removing null transitions. here by removing the strings of the language (0 + 1). here by precisely null transitions. here by removing null transitions. here by removing null transitions. Chapter 7 : Finite State Automata Again, we have slightly simplified the construction Again, we have slightly simplified the construction Again, we have slightly simplified the construction Again, we have slightly simplified the construction page 26 of 31 Discrete Mathematics Chapter 7 : Finite State Automata Chen, 1991,7–27 c WWL 2008 Combining the six parts, we obtain the following state diagram of a non-deterministic Combining the six parts, we obtain the following state diagram of a non-deterministic finite state automaton with null transitions that accepts precisely the strings of the language 1(01)∗ 1(001)∗ (0 + 1)1: start t1 1 t2 λ λ t5 1 t6 λ 1 t9 0 t4 1 0 t3 λ t11 0 t7 λ 0 t8 t14 1 t13 λ t12 1 t10 Removing null transitions, we obtain the following transition table of a non-deterministic finite state Removing null transitions, we obtain the following transition table of a non-deterministic finite state automaton without null transitions that accepts precisely the strings of 1(01)∗ 1(001)∗ (0 + 1)1: automaton without null transitions that accepts precisely the strings of 1(01)∗ 1(001)∗ (0 + 1)1: 0 0 t1 t1 t2 t2 t3 t3 t4 t4 t5 t5 t6 t6 t7 t7 t8 t8 t9 t9 t10 t10 t11 t11 t12 t12 t13 t13 t14 t14 t4 t4 t4 t4 t8 , t11 , t13 t8 , t11 , t13 t8 , t11 , t13 t8 , t11 , t13 t9 t9 t11 , t13 t11 , t13 ν ν 1 1 t2 , t3 , t5 t2 , t3 , t5 t6 , t7 , t10 t6 , t7 , t10 t6 , t7 , t10 t6 , t7 , t10 t3 , t5 t3 , t5 t6 , t7 , t10 t6 , t7 , t10 t12 , t13 t12 , t13 t12 , t13 t12 , t13 t7 , t10 t7 , t10 t12 , t13 t12 , t13 t14 t14 t14 t14 t14 t14 Applying the conversion process, we obtain the following deterministic finite state automaton correApplying the conversion process, we obtain the following deterministic finite state automaton corresponding to the original non-deterministic finite state automaton: sponding to the original non-deterministic finite state automaton: 0 +s1 + s2 s3 s4 s5 s6 s7 s8 −s9 − s10 s∗ Chapter 7 : Finite State Automata ν 1 s2 s4 s5 s7 s4 s9 s9 s10 s∗ s7 s∗ t1 t2 , t3 , t5 t4 t6 , t7 , t10 t3 , t5 t8 , t11 , t13 t12 , t13 t9 t14 t7 , t10 ∅ page 27 of 31 s∗ s3 s∗ s6 s3 s8 s∗ s∗ s∗ s6 s∗ 7–28 W W L Chen : Discrete Mathematics c W W L Chen, 1991, 2008 Discrete Mathematics Removing the last column and applying the Minimization process, represents the first few steps: applying the Minimization process, Removing the last column and represents the first few steps: ν ν ν ∼0 ∼1 0ν 1 0ν 1 0ν 1 = = ∼0 ∼1 0s 01 01 = = +s1 + s∗ 1 2 A AA A AA +s12+ s∗3 s24 A AA A AA s ss A AA A AA s23 s3∗ s45 A AA A AA s ss A AA A AA s34 s∗6 s57 A AA A AA s ss A AA A BB s45 s63 s74 A AA A BB s ss A AA A AA s56 s38 s49 A AA A AA s ss A AB B AC s67 s8∗ s99 A AB B AC s ss A AB B AC s78 s∗ s9 A AB B AC s A AA A AA 10 s8 ss∗ ss∗ A AA A AA −s9 − B AA C AA ∗ 10 −s9 − s∗6 s∗7 B AA C AA ss A AA A BB 10 ss∗ s6∗ s7∗ A AA A BB ss A AA A AA 10 s∗ s∗ s∗ A AA A AA we have the following table which we have the following table which ∼2 = ∼2 = A A A A B B A A C C C A A D D B B A A ν 0 ν1 01 AA AA AB AB AA AC CA CC AB AB AD AD AD AB D AA B AC CA CC AA AA ∼3 = ∼ = A3 A B B A A C C B B D D D D B B E E C C A A Unfortunately, the process here is going to be rather long, but let us continue nevertheless. Continuing Unfortunately, obtain the following: this process, wethe process here is going to be rather long, but let us continue nevertheless. Continuing this process, we obtain the following: ν ν ν ν ∼3 ∼4 ∼5 ∼6 0ν 1 0ν 1 0ν 1 0 ν1 = = = = ∼3 ∼4 ∼5 ∼6 01 01 01 01 = = = = +s1 + s∗ s2 A AB A GB A HB A +s1 + s∗ s2 A AB A GB A HC A s2 s3 s4 B AC B AC B AB B s2 s3 s4 B AC B AC B AB C B s3 s∗ s5 A AB A GB A H A s3 s∗ s5 A AB A GB A HB A s4 s6 s7 C DD C DE C DE C s4 s6 s7 C DD C DE C DC E C s5 s3 s4 B AC B AC B A B s5 s3 s4 B AC B AC B AC B s6 s8 s9 D BE D BF D FG D s6 s8 s9 D BE D BF D FG G D s7 s∗ s9 D AE E GF E H E s7 s∗ s9 D AE E GF E HG E s8 s∗ s10 B AC B GC F HC F s8 − ss ss B AC B GC F HH C F ∗ 10 −s9 E AA F GG G H G ∗ ∗ −s9 − s∗ s∗ E AA F GG G HE H G s10 s6 s7 C DD C DE C D C ss s6 s7 C DD C DE C DE C 10 s∗ s∗ A AA G GG H HH H ∗ s∗ s∗ s∗ A AA G GG H HH H Choosing s1 , s2 and s4 and discarding s3 , s5 and s10 , we have the following minimized transition table: Choosing s1 , s2 and s4 and discarding s3 , s5 and s10 , we have the following minimized transition table: 0 0 s∗ s∗ s1 s1 s6 s6 s8 s8 s∗ s∗ s∗ s∗ s∗ s∗ s∗ s ∗ ν ν +s1 + +s1 + s2 s2 s4 s4 s6 s6 s7 s7 s8 s8 −s9 − −s9 − s∗ s ∗ 1 1 s2 s2 s4 s4 s7 s7 s9 s9 s9 s9 s4 s4 s∗ s∗ s∗ s ∗ This can be described by the following state diagram: start s1 1 0 s2 s7 1 1 s4 s9 1 s8 0 0 1 1 s6 Chapter 7 : Finite State Automata page 28 of 31 Discrete Mathematics Chapter 7 : Finite State AutomataL Chen, 1991, 2008 7–29 c WW Problems for Chapter 7 Problems for Chapter 7 1. Suppose that I = {0,, 1}.. Consider the following deterministic finite state automaton: 1. Suppose that I = {0 1} Consider the following deterministic finite state automaton: 0 0 +s1 + +s1 + −s2 − −s2 − s3 s3 ν ν 1 1 s2 s3 s2 s3 s3 s2 s3 s2 s1 s3 s1 s3 d)d) 0100010 0100010 h)h) 1100111010011 1100111010011 Decide which of the following strings are accepted: Decide which of the following strings are accepted: a)a) 101 101 b)b) 10101 10101 c) c) 11100 11100 e) e) 10101111 10101111 f) f) 011010111 011010111 g)g) 00011000011 00011000011 2. Consider the deterministic finite state automaton A = (S ,, I ,, ν, T ,, s1 ), where I = {0,, 1},, described 2. Consider the deterministic finite state automaton A = (S I ν, T s1 ), where I = {0 1} described by the following state diagram: by the following state diagram: start s1 1 s2 0 1 s3 1 0 0 1 s4 s5 a)a) How many states does the automaton A have? How many states does the automaton A have? b)b) Construct the transition table for this automaton. Construct the transition table for this automaton. c) c) Apply the Minimization process to this automaton and show that no state can be removed. Apply the Minimization process to this automaton and show that no state can be removed. 3. Suppose that I = {0,, 1}.. Consider the following deterministic finite state automaton: 3. Suppose that I = {0 1} Consider the following deterministic finite state automaton: 0 0 s2 s2 s5 s5 s5 s5 s4 s4 s3 s3 s1 s 1 ν ν +s1 − +s1 − −s2 − −s2 − −s3 − −s3 − −s4 − −s4 − s5 s5 s6 s 6 1 1 s5 s5 s3 s3 s2 s2 s6 s6 s5 s5 s4 s 4 a)a) Draw state diagram for the automaton. Draw a a state diagram for the automaton. b) Apply the Minimization process to the automaton. b) Apply the Minimization process to the automaton. 4. Suppose that I = {0,, 1}.. Consider the following deterministic finite state automaton: 4. Suppose that I = {0 1} Consider the following deterministic finite state automaton: 0 0 s2 s2 s∗ s∗ s∗ s∗ s7 s7 s7 s7 s5 s5 s5 s5 s∗ s∗ ν ν 1 1 s3 s3 s4 s4 s6 s6 s6 s6 s∗ s∗ s4 s4 s∗ s∗ s∗ s∗ +s1 + +s1 + s2 s2 s3 s3 s4 s4 −s5 − −s5 − s6 s6 −s7 − −s7 − s∗ s∗ a)a) Draw state diagram for the automaton. Draw a a state diagram for the automaton. b)b) Apply the Minimization process to the automaton. Apply the Minimization process to the automaton. Chapter 7 : Finite State Automata page 29 of 31 7–30 W W L Chen : : Discrete Mathematics 7–30 W W L Chen Discrete Mathematics Discrete Mathematics c W W L Chen, 1991, 2008 5. Let II= {{0,11}. 5. Let = 0, }. 5. Let I = {0, 1}finite state automaton to accept all strings which contain exactly two 1’s and which a) Design aa .finite state automaton to accept all strings which contain exactly two 1’s and which Design a) a) start and finish with the same symbol. all strings which contain exactly two 1’s and which Design a finite state automaton to accept start and finish with the same symbol. start and finish with the same symbol. b) Design aafinite state automaton to accept all strings where all the 0’s precede all the 1’s. b) Design finite state automaton accept all all strings where all the precede b) c) Design finite state automaton to to accept all strings of length at0’s 0’s 1 andall all the 1’s. of Design a a finite state automaton to accept strings where all the least precede the 1’s. sum all strings at least 1 andwhere the sum of where the Design c) c) the firstfinite state theautomatonthe string is strings ofof length least 1 and where the sum of Design a a finite state length ofto to accept even. accept all length at digit and automaton of the string is even. the first digit and the length the string is even. the first digit and the length of 6. Consider the following non-deterministic finite state automaton A = ((S ,II ,νν,TT, ,tt1 ) without null 1 ) without null 6. Consider the following non-deterministic finite state automaton A = S , , , Consider the following 6. transitions, where I = {non-deterministic finite state automaton A = (S , I , ν, T , t11 without null ) transitions, where I = {00,11}: where I = { , 1}: transitions, 0, }: start start tt1 1 1 11 1 00 0 tt2 2 2 00 0 11 1 11 1 11 1 tt3 3 3 00 0 00 0 tt4 4 4 00 0 11 1 11 1 tt5 5 5 a) a) Describe the automaton by transition table. Describe the automaton by a a) Describe the automaton byaatransition table. transition table. b) Convert to deterministic finite state automaton. b) b) Convert a aadeterministic finite state automaton. Convert to to deterministic finite state automaton. c) c) Minimize the number of states. Minimize the number of of states. c) Minimize the number states. 7. Consider the following non-deterministic finite state automaton A = ((S ,II ,νν,TT, ,tt1 )with null tran) 7. Consider the following non-deterministic finite state automaton A = S , , , 7. Consider the following non-deterministic finite state automaton A = (S , I, ν, T , t11 with null tran1 ) with null transitions, where II= {{0,11}: sitions, where I = {0, 1}: where = 0, }: sitions, start start tt1 1 1 11 1 λλ λ λλ λ 11 1 00 0 00 0 00 0 tt2 2 2 tt4 4 4 11 1 tt3 3 3 11 1 11 1 tt5 5 5 tt6 6 6 a) Remove the null transitions, and describe the resulting automaton byaatransition table. transition table. a) a) Remove the null transitions, and describe the resulting automaton by transition table. Remove the null transitions, and describe the resulting automaton by a b) Convert to deterministic finite state automaton. b) Convert a aadeterministic finite state automaton. to deterministic finite state automaton. b) Convert to c) Minimize the number states. c) c) Minimize the number of states. Minimize the number of of states. 8. Consider the following non-deterministic finite state automaton A = ((S ,II ,νν,TT, ,tt4 )with null tran) 8. Consider the following non-deterministic finite state automaton A = S , , , 8. Consider the following non-deterministic finite state automaton A = (S , I, ν, T , t44 with null tran4 ) with null transitions, where II= {{0,11}: 0, 1}: sitions, where = sitions, where I = {0, }: 00 0 11 1 λλ λ tt1 1 1 11 1 tt2 2 2 11 1 00 0 00 0 00 0 tt3 3 3 11 1 00 0 start start tt4 4 4 λλ λ 11 1 tt5 5 5 a) Remove the null transitions, and describe the resulting automaton by aatransition table. a) Remove the null transitions, and describe resulting automaton by by transition table. a)b) Convert tonull transitions, and describe thethe resulting automaton a transition table. Remove the a deterministic finite state automaton. state automaton. b) Convert a deterministic finite state automaton. b) c) Minimize to a number of states. Convert to the deterministic finite c) Minimize the number states. of states. c) Minimize the number of Chapter 7 : Finite State Automata page 30 of 31 Discrete Mathematics c WWL Chapter 7 : Finite State Automata Chen, 1991,7–31 2008 9. Consider the following non-deterministic finite state automaton A = (S , I , ν, T , t1 ) with null tranν, sitions, where I = {0, 1}: 1 start t1 0 λ 1 0 t2 1 λ t3 1 0 t4 1 λ λ t5 1 λ t6 0 0 t7 0 t8 0 1 t9 a) Remove the null transitions, and describe the resulting automaton by a transition table. a) Remove the null transitions, and describe the resulting automaton by a transition table. b) Convert to a deterministic finite state automaton. b) Convert to a deterministic finite state automaton. c) Minimize the number of states. c) Minimize the number of states. 10. Consider the following non-deterministic finite state automaton A = (S , I , ν, T , t4 t6 ) with null 10. Consider the following non-deterministic finite state automaton A = (S , I , ν, T , t4 t6 ) with null transitions, where I = {0, 1}: transitions, where I = {0, 1}: 0 t1 1 λ 1 t2 0 1 1 0 λ 1 start t4 t5 1 1 t3 0 1 start t6 0 t7 a) a) Remove the null transitions, and describe the resulting automaton by transition table. Remove the null transitions, and describe the resulting automaton by a a transition table. b) Convert to deterministic finite state automaton. b) Convert to a a deterministic finite state automaton. c) c) How many states does the deterministic finite state automaton have on minimization? How many states does the deterministic finite state automaton have on minimization? 11. Prove that the set of all binary strings in which there are exactly as many 0’s as 1’s is not a regular 11. Prove that the set of all binary strings in which there are exactly as many 0’s as 1’s is not a regular language. language. 12. For each of the following regular languages with alphabet 0 and 1, design a non-deterministic finite 12. For each of the following regular languages with alphabet 0 and 1, design a non-deterministic finite state automaton with null transitions that accepts precisely all the strings of the language. Remove state automaton with null transitions that accepts precisely all the strings of the language. Remove the null transitions and describe your result in a transition table. Convert it to a deterministic finite the null transitions and describe your result in a transition table. Convert it to a deterministic finite state automaton, apply the Minimization process and describe your result in a state diagram. state automaton, apply the∗ Minimization process and describe your result in a state diagram. ∗ ∗ ∗ a) a) (01) (0 + 1)(011 + 10) ∗ (01)∗ (0 + 1)(011 + 10)∗∗ b) b) (100 + 01)(011 + ∗ (100 + + 01) (100 + 01)(011 + 1) 1) (100 01)∗ c) c)λ(+ + 01)1(010 + (01) )01 ( λ 01)1(010 + (01)∗ )01∗ Chapter 7 : Finite State Automata page 31 of 31 ...
View Full Document

Ask a homework question - tutors are online