1 / 93

Lecture 3: Finite State Machines

This lecture covers finite state machines, regular languages, and the differences between deterministic and non-deterministic finite state machines. It also discusses right-linear grammars and their conversion to NFAs.

annettec
Download Presentation

Lecture 3: Finite State Machines

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. Lecture 3: Finite State Machines Xiaoyin Wang CS 5363 Spring 2019

  2. Last Class • Formal Languages • What are languages? • What are grammars? • Phrase-Structure Grammars • Classification of Grammars (and corresponding languages)

  3. Today’s Class • Finite State Machines • Regular Languages and FSMs • DFA vs. NFA

  4. Finite State Machines • A state transition system • Takes a sequence of characters as its input • State transits according to the input • Whether an input is accepted: • If the system stops at an acceptance state

  5. Finite State Machines • Two types of machines • Recognizers • No output • Transducers • Moore Machine: Output on states • Mealy Machine : Output on transitions

  6. Finite State Machine Input Tape String Output “Accept” or “Reject” State Transition

  7. Transition Graph initial state accepting state transition state

  8. Alphabet For every state, there is a transition for every symbol in the alphabet

  9. Initial Configuration head Input Tape Input String Initial state

  10. Scanning the Input

  11. Input finished accept

  12. A Rejection Case Input String

  13. Input finished reject

  14. Another Rejection Case Tape is empty Input Finished reject

  15. Language Accepted:

  16. To accept a string: all the input string is scanned and the last state is accepting To reject a string: all the input string is scanned and the last state is non-accepting

  17. Formal Definition • Deterministic Finite Automaton (DFA) : set of states : input alphabet : transition function : initial state : set of accepting states

  18. Set of States Example

  19. Input Alphabet :the input alphabet never contains Example

  20. Initial State Example

  21. Set of Accepting States Example

  22. Transition Function Describes the result of a transition from state with symbol

  23. Example:

  24. Transition Table for symbols states

  25. Language Accepted by DFA Language of DFA : it is denoted as and contains all the strings accepted by We say that a language is accepted (or recognized) by DFA if

  26. For a DFA • Language accepted by :

  27. Language rejected by :

  28. Today’s Class • Finite State Machines • FSM and Regular Languages • DFA vs. NFA

  29. Grammar is right-linear Example:

  30. Construct NFA such that • every state is a grammar variable: special final state

  31. Add edges for each production:

  32. In General • A right-linear grammar • has variables: • and productions: or

  33. We construct the NFA such that: • each variable corresponds to a node: special final state

  34. For each production: • we add transition

  35. For each production: • we add transitions and intermediate nodes

  36. Convert to a right-linear grammar

  37. In General For any transition: Add production: variable terminal variable

  38. In General If p is acceptance state Add production:

More Related