1 / 100

Finite-State Machines with No Output Longin Jan Latecki Temple University

Based on Slides by Elsa L Gunter, NJIT, and by Costas Busch. Finite-State Machines with No Output Longin Jan Latecki Temple University. Big Picture: Three Equivalent Representations. Regular expressions. Each can describe the others. Regular languages. Finite automata.

ananda
Download Presentation

Finite-State Machines with No Output Longin Jan Latecki Temple University

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. Based on Slides by Elsa L Gunter, NJIT, and by Costas Busch Finite-State Machines with No OutputLongin Jan Latecki Temple University

  2. Big Picture: Three Equivalent Representations Regular expressions Each can describe the others Regular languages Finite automata • Kleene’s Theorem: • For every regular expression, there is a deterministic finite-state automaton that defines the same language, and vice versa. • More in Ch. 13.4

  3. Kleene closure • A and B are subsets of V*, where V is a vocabularyThe concatenation of A and B isAB={xy: x string in A and y string in B} • Example: A={0, 11} and B={1, 10, 110}AB={01,010,0110,111,1110,11110} • What is BA? • A0={λ}An+1=AnA for n=0,1,2,…

  4. Let A be any subset of V*. Kleene closure of A, denoted by A*, is Examples: If C={11}, then C*={12n: n=0,1,2,…} If B={0,1}, then B*=V*.

  5. Regular Expressions Regular expressions describe regular languages Example: describes the language

  6. Given regular expressions and Are regular expressions Recursive Definition Primitive regular expressions:

  7. Not a regular expression: Examples A regular expression:

  8. Languages of Regular Expressions : language of regular expression Example

  9. Definition For primitive regular expressions:

  10. Definition (continued) For regular expressions and

  11. Example Regular expression:

  12. Example Regular expression

  13. Example Regular expression

  14. = { all strings with at least two consecutive 0 } Example Regular expression

  15. = { all strings without two consecutive 0 } Example Regular expression

  16. Equivalent Regular Expressions • Definition: • Regular expressions and • are equivalent if

  17. and are equivalent regular expr. Example = { all strings without two consecutive 0 }

  18. Example: Lexing • Regular expressions good for describing lexemes (words) in a programming language • Identifier= (a  b  …  z  A  B  …  Z) (a  b  …  z  A  B  …  Z  0  1  …  9  _  ‘ )* • Digit = (0  1  …  9)

  19. Implementing Regular Expressions • Regular expressions, regular grammars reasonable way to generates strings in language • Not so good for recognizing when a string is in language • Regular expressions: which option to choose, how many repetitions to make • Answer: finite state automata

  20. Finite (State) Automata • A FA is similar to a compiler in that: • A compiler recognizes legal programs in some (source) language. • A finite-state machine recognizes legal strings in some language. • Example: Pascal Identifiers • sequences of one or more letters or digits, starting with a letter: letter | digit letter S A

  21. Finite Automaton Input String Output “Accept” or “Reject” Finite Automaton

  22. Finite State Automata • A finite state automation over an alphabet is illustrated by a state diagram: • a directed graph • edges are labeled with elements of alphabet, • some nodes (or states), marked as final • one node marked as start state

  23. Transition Graph initial state accepting state transition state

  24. Initial Configuration Input String

  25. Reading the Input

  26. Input finished accept

  27. Rejection

  28. Input finished reject

  29. Another Rejection

  30. reject

  31. Another Example

  32. Input finished accept

  33. Rejection Example

  34. Input finished reject

  35. Finite State Automata • A finite state automation M=(S,Σ,δ,s0,F) consists of • a finite set S of states, • a finite input alphabet Σ, • a state transition function δ: S x Σ S, • an initial state s0, • F subset of S that represent the final states.

  36. Finite Automata • Transition s1as2 • Is read ‘In state s1 on input “a” go to state s2’ • If end of input • If in accepting state => accept • Otherwise => reject • If no transition possible (got stuck) => reject • FSA = Finite State Automata

  37. Input Alphabet

  38. Set of States

More Related