1 / 172

CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 4

CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 4 School of Innovation, Design and Engineering Mälardalen University 2012. 1. Content.

ami
Download Presentation

CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 4

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 4 School of Innovation, Design and Engineering Mälardalen University 2012 1

  2. Content Regular Expressions and Regular LanguagesNFADFA Subset Construction (Delmängdskonstruktion)FA  RE State Elimination (Tillståndseliminering)Minimizing DFA by Set Partitioning (Särskiljandealgoritmen)Grammar: Lineargrammar. Regulargrammar. Application: Compiler. LexicalAnalysis.

  3. Two Basic Theoremsabout Finite State Automata Based on C Busch, RPI, Models of Computation

  4. 1: KleeneTheoremNFADFA Let M be NFA accepting L. Then there exists DFA M´ that accepts L as well.For each NFA there exists corresponding DFA that accepts the same language.

  5. II: Finite Language TheoremAny finite language is regular.Any finite language is FSA-acceptable. Proof: every finite language is a union of single strings which are regular because described by regular expressions Example L = {abba, abb, abab} L is expressed by the regular expression “abba|abb|abab“ FSA = Finite State Automaton = DFA/NFA

  6. Some Properties of Regular Languages, Summary

  7. Union: Concatenation: Are Regular Languages Star: Properties For regular languages and we will prove that:

  8. Union: Concatenation: Star: Regular languages are closed under

  9. Regular language Regular language NFA NFA Single final state Single final state

  10. Example

  11. Union (Thompson’s construction) • NFA for

  12. NFA for Example

  13. Concatenation (Thompson’s construction) • NFA for

  14. Example • NFA for

  15. Star Operation (Thompson’s construction) • NFA for

  16. Example • NFA for

  17. Reverse of a Regular Language

  18. Theorem The reverse of a regular language is a regular language Proof idea Construct NFA that accepts : invert the transitions of the NFA that accepts

  19. Proof Since is regular, there is NFA that accepts Example:

  20. Invert Transitions

  21. Make old initial state a final state and vice versa

  22. Add a new initial state

  23. is regular Resulting machine accepts

  24. Regular ExpressionsandRegular Languages

  25. Theorem: Regular expressions are representation of regular languages and they are equivalent. Regular expressions describe regular languages in formal language theory. They have the same expressive power as regular grammars.

  26. 1. For any regular expression the language is regular Theorem - Part 1 Languages Generated by Regular Expressions Regular Languages

  27. 2. For any regular language there is a regular expression with Theorem - Part 2 Languages Generated by Regular Expressions Regular Languages

  28. Proof - Part 1 For any regular expression the language is regular Proof by induction on the size of

  29. NFAs Induction Basis • Primitive Regular Expressions: (where ) Regular Languages

  30. Assume for regular expressions and Inductive Hypothesis that and are regular languages

  31. Inductive Step • We will prove: regular languages

  32. By definition of regular expressions:

  33. By inductive hypothesis we know: and are regular languages Regular languages are closed under union concatenation star

  34. Therefore regular languages is a regular language And trivially

  35. Proof – Part 2 For any regular language there is a regular expression with Proof by construction of regular expression

  36. Since is regular take the NFA that accepts it Single final state

  37. From construct the equivalent • Generalized Transition Graph • transition labels are regular expressions Example QED

  38. Summary: Operations on Regular Expressions • RE Regular language description • a+b {a,b} • (a+b)(a+b) {aa, ab, ba, bb} • a* {, a, aa, aaa, …} • a*b {b,ab, aab, aaab, …} • (a+b)* {, a, b, aa, ab, ba, aaa, bbb…}

  39. Algebraic Properties

  40. Operator Precedence • 1. Kleene star • 2. Concatenation • 3. Union • allows dropping unnecessary parentheses.

  41. Converting Regular Expression to aDFA

  42. 6 Example: From a Regular Expression to an NFA Example : (a+b)*abb step by step construction (a+b) a  3 2  1   4 5 b

  43. 7 Example: From a Regular Expression to an NFA Example : (a+b)*abb (a+b)*  a 3 2     0 1 6   4 5 b 

  44. Example: From a Regular Expression to an NFA Example : (a+b)*abb (a+b)*abb  a 3 2    0  1 6 a 7 8   4 5 b b 9  b 10

  45. Converting FA to a Regular ExpressionState Eliminationhttp://www.math.uu.se/~salling/Movies/FA_to_RegExpression.mov

  46. , 2 1 3 Example • Add a new start (s) and a new final (f) state: • From s to the ex-starting state (1) • From each ex-final state (1,3) to f

  47. s ; ; , ; , ; , 2 1 The original: 3 f Let’s remove state 1! Each combination of input/output to 1 will generate a new path once state 1 is gone

  48. s (  ) , ; When state 1 is gone we must be able to make all those transitions! , 2 1 Previous: 3 , f

  49. s (  ) ; , 2 1 3 f

  50. s ( (   ) ) ; , , 2 1 3 f

More Related