1 / 98

Finite-State Machines with No Output

Finite-State Machines with No Output. Kleene closure. A and B are subsets of V*, where V is a vocabulary The concatenation of A and B is AB={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?

tiana
Download Presentation

Finite-State Machines with No Output

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. Finite-State Machines with No Output

  2. 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,…

  3. Let A be any subset of V*. Kleene closure of A, denoted by A*, is If B={0,1}, B*=V*.

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

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

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

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

  8. Definition For primitive regular expressions:

  9. Definition (continued) For regular expressions and

  10. Example Regular expression:

  11. Example Regular expression

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

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

  14. 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

  15. 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.

  16. EXAMPLE 1 Consider the language { ambn| m, n  N}, which is represented by the regular expression a*b*. A regular grammar for this language can be written as follows: S | aS | B B  b | bB.

  17. 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

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

  19. 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 of “accepting”. • one node marked as start state

  20. Transition Graph initial state accepting state transition state

  21. Initial Configuration Input String

  22. Reading the Input

  23. Input finished accept

  24. Rejection

  25. Input finished reject

  26. Another Rejection

  27. reject

  28. Another Example

  29. Input finished accept

  30. Rejection Example

  31. Input finished reject

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

  33. 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

  34. Example FSA Construct the state diagram for M=(S,I,f,s0,F), where S={s0, s1, s2, s3}, I={0,1}, F={s0, s3}and the transition function:

  35. Language accepted by FSA • The language accepted by a FSA is the set of strings accepted by the FSA. • in the language of the FSM shown below: x, tmp2, XyZzy, position27. • not in the language of the FSM shown below: • 123, a?, 13apples. letter | digit letter S A

  36. Example: • FSA that accepts three letter English words that begin with p and end with d or t. • Here we use the convenient notation of making the state name match the input that has to be on the edge leading to that state. a t p i o d u

  37. FA Definition: The language contains all input strings accepted by = { strings that bring to an accepting state} Languages Accepted by FAs

More Related