Your SlideShare is downloading. ×
To lec 03
To lec 03
To lec 03
To lec 03
To lec 03
To lec 03
To lec 03
To lec 03
To lec 03
To lec 03
To lec 03
To lec 03
To lec 03
To lec 03
To lec 03
To lec 03
To lec 03
To lec 03
To lec 03
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

To lec 03

1,135

Published on

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,135
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
12
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Theory of Automata By Amjad Khan Khalil amjad@aup.edu.pk
  • 2. Regular Expression PracticeContinue Write down the regular expression defined over Σ={a,b} where each string ends with double a’s or double b’s. Write down the regular expression defined over Σ={a,b} Where each string start with double b’s and end with double a’s. Write down the regular expression for the language defined over Σ={a,b} where each string have exactly one double b’s. Write down the regular expression for the language defined over Σ={a,b} where each string have exactly one triple a’s. Write down the regular expression defined over Σ={0,1} which consist of even number of 0’s and even number of 1’s. Write down a regular expression for the language defined over Σ={a,b} where each string consist of odd number of a’s and odd number of b’s.
  • 3. Practice continue Find the shortest string that is in the language represented by the regular expression a*(ab)*b*. Find the shortest string that is not in the language represented by the regular expression a*(ab)*b*. Consider the language S*, where S={aa, b} How many words this language have of length 2? of length 3? Construct a regular expression defining each of the following languages over the alphabet Σ = {a, b}  All strings that end in double letter  All strings that do not end in double letter  All words that contain exactly two b’s or exactly three b’s, not more Show that the following pairs of regular expressions define the same language over the alphabet Σ = {a, b} or not???  (ab)*a and a(ba)*  (a*+b*) and (a+b)*  (a*+b*)* and (a+b)*
  • 4. Practice Continue Write RE of strings of a and b, which must end on triple b’s Write RE of strings of a and c followed by 3 b’s Write RE of strings of a and c, followed by any numbers of b’s
  • 5. Practice ContinueA language is defined over Σ={0,1} , you need to Write a regular expression for each of the following sets of binary strings. contains at least three consecutive 1s Does not contains two consecutive 0’s Contains at most two 0’s contains the substring 101 contains the substring 1101100 Write down the regular expression for the language defined over Σ={a,b} that does not contain aab
  • 6. Equivalent Regular Expression Two or more regular expressions are said to be equivalent if they generate the same language. Exp: Write down the regular expression for the language defined over Σ={a,b} where each string ends with aa or bb. then R1= (a|b)*(aa|bb) R2=(a|b)*aa|(a|b)*bbAs both the above mentioned regular expression defined the same language so both are equivalent.
  • 7. Con’t Now consider the following two regular expression R1= (a*|b*) R2= (a|b)* Then both of the regular expressions are equal?????????????? The answer is NO! Because the R1 does not generate the string which is the concatenation of a and b while the R2 generate such string which is the concatenation of a and b.
  • 8. Con’t If R1=(aa|bb) and R2=(a|b) then show that the following are equal or not? R1|R2 R1.R2 R1* We need to check that all the above Regular Expression generate the same language or not.
  • 9. Some important identities ϵ.R=R. ϵ=R ϵ*=ϵ Φ*= ϵ R+R=R|R=R R*.R*=R* (R*)*=R* R+ Φ =R (ϵ+R)*=(ϵ|R)*=R* (R+R)S*=(R|R)S*=RS*
  • 10. What is Regular language? The language generated by any regular expression is called a regular language. It is to be noted that if R1, R2 are regular expressions, corresponding to the languages L1 and L2 then the languages generated by R1| R2 R1R2 R2R1 and R1*( or R2*) are also regular languages.
  • 11. Example If R1 = (aa+bb) and R2 = (a+b) then the language of strings generated by R1+R2, is also a regular language, expressed by (aa+bb) + (a+b) If R1 = (aa+bb) and R2 = (a+b) then the language of strings generated by R1R2, is also a regular language, expressed by (aa+bb)(a+b) If R = (aa+bb) then the language of strings generated by R*, is also a regular language, expressed by (aa+bb)*
  • 12. All finite languages are regular Consider the following regular expression R.E=(aa|ab) Thus the language generated by this regular expression is L={aa,ab} Which is a language of length 2 where each string start from a. Thus L is a regular language.
  • 13. What is finite automaton.(FA) It is the fourth way of defining the language and can be defined as the collection of the following.  Finite number of states, having one initial and having none, one or many final states.  Finite set of input letters (Σ) from which input strings are formed.  Finite set of transitions i.e. for each state and for each input letter there is a transition showing how to move from one state to another. It should be noted that for one language there may two or more FA’s which all be correct but for a single FA there will be exactly one language.
  • 14. Points to be noted We should take care of the following points while constructing an FA.  A state may be denoted by any name.  A transition is denoted by an arrow initiates from one stated and terminates on another.  The label(letter or digit) above the arrow shows the inputs.  If an arrow initiate from a state and terminate on the same state is called loop.  The loop represent any combination of the label including NULL.  An FA is also called finite state machine or transition diagram.
  • 15. Points to be noted It may be noted that to indicate the initial state an arrow head can also be placed before that state and the final state can be indicated by double circle. It is also to be noted while expressing the FA by its transition diagram the labels of states are not necessary.
  • 16. Example A language is defined over Σ={a,b} then construct a finite state machine that accept any combination of b’s but must end with a.
  • 17. ExampleΣ = {a,b}States: x, y, z where x is an initial state and z is final state.Transitions:1. At state x reading a, go to state z2. At state x reading b, go to state y3. At state y reading a, b go to state y4. At state z reading a, b go to state z
  • 18. Con’t These transition can be expressed by the table called transition table as under:
  • 19. Con’t The finite state machine or transition diagram will be as under:The above transition diagram is an FAaccepting the language of strings, defined over Σ = {a, b}, starting with a.It may be noted that this language may be expressed by the regular expression a(a + b)*

×