190 likes | 202 Views
Learn to build finite automata corresponding to finite languages with step-by-step examples and explanations by Instructor Naveed Ullah Safi. Understand the concept of final states and dead states in finite automata construction.
E N D
FA corresponding to Finite languages Lecture 07 Instructor NaveedUllah Safi
FA corresponding to Finite languages • We can also build finite automaton for a given finite language. • To build an FA for a finite language, first we must identify all the strings in the given language. • Second we must construct that much final states in the FA as the number of strings in the language i:e the number of final states must be equal to the number of strings in the language. Instructor NaveedUllah Safi
a,b a,b FA corresponding to finite languages y • Example Consider the language L = {Λ, b, ab, bb}, The language L may be accepted by the following FA a a,b a b 1 3 4+ b b 2+ 5+ a,b a x Instructor NaveedUllah Safi 3
a,b a,b Note y a L = {Λ, b, ab, bb} a,b a b As there are four strings in the language so there will be four final states represented by 1, 2, 4 and 5. Also there are two dead states in this FA where someone if enter, then there is no way to leave that state 1 3 4+ b b 2+ 5+ a,b a x Instructor NaveedUllah Safi
Example Continued … • It is to be noted that the states x and y are called Dead States, Waste Baskets or Davey John Lockers, as the moment one enters these states there is no way to leave it. Instructor NaveedUllah Safi
Note • It is to be noted that to build an FA accepting the language having less number of strings, the tree structure may also help in this regard, which can be observed in the following transition diagram for the Language L, discussed in the previous example Instructor NaveedUllah Safi
4 a 3 a,b b a,b a 5+ a,b 1± 8 a,b 6 b a 2+ a,b b 7+ Instructor NaveedUllah Safi
Example Consider the language L = {aa, bab, aabb, bbba}, defined over Σ ={a, b}, expressed by aa + bab + aabb + bbba The above language may be accepted by the following FA Instructor NaveedUllah Safi
a,b x 5+ 3+ 9+ 1– y a,b Example Continued … a,b b a a a a b b 2 4 b b b a 6 7 8 a a b a,b 10 a b a,b 11+ Instructor NaveedUllah Safi
Example Consider the language L = {w belongs to {a,b}*: length(w) >= 2 and w neither ends in aa nor bb}. The language L may be expressed by the regular expression (a+b)*(ab+ba) This language may be accepted by the following FA Instructor NaveedUllah Safi
4+ 2 1– 5+ 3 Example Continued … a b a b a a b b b a Instructor NaveedUllah Safi
Note • It is to be noted that building an FA corresponding to the language L, discussed in the previous example, seems to be quite difficult, but the same can be done using tree structure Instructor NaveedUllah Safi
a aa a b a b a a ab Λ b a ba b a b a b b b bb Example continued … Instructor NaveedUllah Safi
Example • Consider the language L = {w belongs to {a,b}*: w does not end in aa}. The language L may be expressed by the regular expression Λ + a + b + (a+b)*(ab+ba+bb) This language may be accepted by the following FA Instructor NaveedUllah Safi
Example Continued … a aa a b a b a a ab Λ b a ba b a b a b b b Instructor NaveedUllah Safi bb
Task solution … Using the technique discussed by Martin, build an FA accepting the following language L = {w belongs to {a,b}*: length(w) >= 2 and second letter of w, from right is a}. Solution:The language L may be expressed by the regular expression (a+b)*(aa+ab) This language may be accepted by the following FA Instructor NaveedUllah Safi
Task continued … a aa a b a b a a ab Λ b a ba b a b a b b b Instructor NaveedUllah Safi bb
Task solution … • Using the technique discussed by Martin, build an FA accepting the following language L = {w belong to {a,b}*: w neither ends in ab norin ba}. • Solution: The language L may be expressed by the regular expression Λ + a + b + (a+b)*(aa+bb) This language may be accepted by the following FA Instructor NaveedUllah Safi
Task continued … a aa a b a b a a ab b a Λ ba b a b a b b b Instructor NaveedUllah Safi bb