describing finite state machines
play

Describing Finite State Machines Murray Cole Describing Finite - PowerPoint PPT Presentation

I V N E U R S E I H T Y T O H F G R E U D I B N Describing Finite State Machines Murray Cole Describing Finite State Machines 1 A Notation for FSMs? FSMs are a useful tool (reactive systems are everywhere)


  1. I V N E U R S E I H T Y T O H F G R E U D I B N Describing Finite State Machines Murray Cole Describing Finite State Machines

  2. � � � 1 A Notation for FSMs? FSMs are a useful tool (reactive systems are everywhere) graphical notation gets cumbersome, so need a “better” notation Regular Expressions do the job for acceptors (with real applications in Unix commands, text processing, compilers) Describing Finite State Machines

  3. ✓ ✆ ☎ ✡ ☎ ☞ ☎ � ✆ ☎ ✎ ☎ ✂ ✁ ✕ ✏ ✟ ✞ ✆ � � ☎ ☎ ✎ 2 Regular Expressions ✁✄✂ ☎✝✆ ☎✝✞ ☎✠✟ ☎✝✡ ☎✠☛ ☎✠☞ ☎✠✌ ☎✠✍ ✁✄✂ ☎✝✆ ☎✠☛ ☎✠✌ ☎✠✍ ✎✔✓ ✁✠✏ ☎✒✑ ✎✖✓ Each of these defines a set of strings corresponding to a language Describing Finite State Machines

  4. ✄ ✂ ✄ ✂ ✂ ✄ ✄ ✂ � ✁ � � � � 3 Syntax and Semantics any symbol from the input alphabet stands for itself (means the set containing just that symbol as a string) the symbol stands for the empty string (means the set containing just the empty string) the symbol stands for no strings at all (means the empty set) if and are RE’s, stands for a sequence of an then an (means the set of strings which are formed from a string from followed by a string from ) Describing Finite State Machines

  5. � ✄ ✂ ✂ ✓ ✄ ✂ ✂ ✂ ☎ ✂ ✂ � ✄ � ✂ � � ✄ 4 Syntax and Semantics if and are RE’s, stands for the choice of or an (means the set of strings which are in the set union of and ) if is a RE, stands for zero or more repeats s (means the set closure of the set of strings which are in ) the operators have precedences, repeat sequence choice, and we can use parentheses ‘(’ and ‘)’ to group expressions (like arithmetic expressions in Java) Describing Finite State Machines

  6. ✆ ✎ ✂ ☎ ✆ ✁ ☎ ✑ ☎ ✓ ✂ ✁ ✓ ✎ ✕ ☎ ✑ ✁ ✏ ✎ ✕ ☎ ✑ ✁ ✑ ✓ 5 Examples Write down all the strings in the language defined by ✎ ✁� Write some of the strings in the language defined by ✎ ✄✂ and some strings which aren’t Give an informal description of the language defined by ✁✠✏ Write down a regular expression defining the language of A s and B s in which every string contains an odd number of B s Describing Finite State Machines

  7. ✂ ✄ ☎ ✌ ✁ ✄ ☎ ✁ ✓ ✠ ☎ ✁ ☎ ✁ ✂ ✡ ✂ ☎ ✡ ✁ ✂ ✎ ☛ � ☞ ☞ � ☛ ✄ � ✁ ✠ ☎ ✄ ☎ � ✌ ✁ ☎ ☎ ✂ ☎ ✂ ☎ ✟ ☎ ✡ ☎ ☛ ☎ 6 Java Floating Point Numbers Use italics ( etc) to stand for sub-expressions (not symbols) �✄✂ ☎ ✟✞ ☎ ✝✆ ☎✝✆ ☎✝✞ ☎✠✍ So, +12.01E-34 is a valid constant while -12E+5 is’nt Describing Finite State Machines

  8. ☎ ✂ ☎ ✁ ✌ ☎ � ☎ ☞ ☎ � ☎ ✟ ✁ ✎ ✓ ☎ � ✁ ✡ ✄ ✡ ✡ ☎ ✏ ☎ ✡ ✂ ✡ ✡ ☎ ✁ ☎ � ☎ Describing Finite State Machines Variable Names ☎✝✆ ☎✝✞ ☎✝✡ ☎✠☛ ☎✠✍ 7

  9. ✂ � ☎ ✂ ✂ ✁ ✁ ☎ ✄ ✎ ☎ ☎ ✂ ☎ ✁ ✄ ✂ ✎ ☎ � ✂ ✄ ✄ ✂ ✂ ✁ ✂ ☎ ✁ ☎ ✂ ☎ ✂ ☎ ☎ ☎ ✁ ✁ ✂ ☎ ✂ ☎ ✂ ☎ ✂ ☎ 8 Algebraic Laws Regular expressions are a kind of algebra Like other algebras, there are rules which let us manipulate expressions (usually with the goal of simplifying them) (1) (2) (3) (4) ☎ ✁� ☎ ✁� (5) (6) Describing Finite State Machines

  10. ✂ ✂ ☎ � ☎ ✓ ✂ ✂ ☎ ✓ ✓ ✂ ☎ ✓ ✂ ✂ ✁ � ✂ ✂ ✓ ✓ ✂ ✁ ✓ ✓ ✎ ✓ ✄ ✂ ✁ ✁ ☎ ✓ ✎ ✄ ☎ ✂ ☎ ✁ ✎ ✄ ✎ ✄ ✁ ✂ ✓ ✎ � ✁ ☎ ✂ ☎ � ✎ ✄ ✂ ✁ ✎ ✂ ✄ ✎ � ✄ ☎ � ✂ ☎ � ✄ ✄ ☎ ✂ ✁ ✂ � ✂ ☎ ✄ Describing Finite State Machines More Algebraic Laws ☎ ✁� (14) (13) (12) (11) (10) (9) (8) (7) 9

  11. ✎ � ☎ ✓ ✎ ✂ � ✁ ✂ ☎ ✂ ✓ ✎ ✂ � ✁ ☎ ✓ � ✁ ✂ ✁ ☎ � ☎ ✓ ✎ ✂ � ✂ � � ☎ � ☎ ✓ ✎ ✂ ✂ � � ☎ ✁ ☎ ✓ ✎ ✂ � ✁ ✂ ✂ ✓ ✎ � ✂ ✁ � ✓ � ✎ ✁ ✁ ✂ � ☎ ✓ ✎ ✂ � ☎ ✓ ✂ ✓ ✎ � ✂ ✁ � ✎ ✁ 10 An example Show that (This is in the lecture note - you add the rules used) Describing Finite State Machines

  12. � � � � 11 Power of Regular Expressions For every regular expression there is an equivalent FSM acceptor For every FSM acceptor there is an equivalent regular expression Even true for acceptors with the “extra” compositions like interleaving and intersection. Regular expressions are widely used in file and text processing, and in the definition and compilation of programming languages Describing Finite State Machines

  13. � � � 12 Summary Regular expressions define sets of strings (languages) – sequence, choice, repetition We can manipulate them with algebraic rules They have the same power as FSM acceptors Describing Finite State Machines

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend