1 / 12

Finite State Automata

Finite State Automata. Lecture 4. Finite State Automata FSA. Abstract machines that recognizes strings Can mechanically construct FSA that accepts strings from RE Easy to simulate FSA in Computer program Basis for scanners. Yes. FSA for L. No. FSA for R. RE R. RE NDFSA. NDFSA DFSA.

kurt
Télécharger la présentation

Finite State Automata

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 Automata Lecture 4

  2. Finite State Automata FSA • Abstract machines that recognizes strings • Can mechanically construct FSA that accepts strings from RE • Easy to simulate FSA in Computer program • Basis for scanners Yes FSA for L No FSA for R RE R RE NDFSA NDFSA DFSA

  3. What is FSA? • Set of States • Set of Transitions between States • Start State • Set of Final States • Operation • Start in Start State • While input remains do read a character if transition on current state and character then set current state to new state else reject input if current state is a final state then accept state else reject state

  4. FSA Diagrams • C.A.T • C.A.(T|R) Final State Start State T C A 2 3 4 1 Start State 4 C A T 2 3 1 5 R

  5. FSA Examples • A* • Identifiers • Floating Point Numbers A 1 Start State [a-z, A-Z] [a-z, A-Z] 2 1 [0-9] [0-9] Start State [0-9] [0-9] . 3 2 4 1

  6. Non-Deterministic FSA • Two Types of FSA • Deterministic FSA or DFSA • Every transition is labeled with a character • NO duplicate labels on transition from a state • Non-deterministic (NDSFSA) • Transitions can be labeled with empty string • Duplicate labels allowed • TWO Types are equivalent in Power • NDFSA are typically easier to write • Can convert one to another l A 4 1 5 A

  7. NDFSA Example Optionally Signed decimal numbers (+ | - | l) . [0-9]* . (‘.’| l ) . [0-9]* [0-9] 3 [0-9] + [0-9] . - [0-9] 2 4 1 6 l Start State . 5 [0-9]

  8. Two Theorems • For Every RE , there exists a NDFSA M such that L(R) = L(N) • For Every NDFSA N, there exists a DFSA M such that L(N) = L(M) • Hence, for every Regular expression R , there exists a DFSA M such that L(R) = L(M) • And, best of AL, we can easily construct these FSA!

  9. Proof of Theorem 1 • Give rules of constructing NDSFA from R a M(a) 1) a a 4) a* M(a) M(b) l l 2) a.b Final state Start state M(a) l l 3) a|b M(b) l l

  10. Example for Constructing NDFSA from RE • (0|1|2 |…|9)* is (…(0|1)| …|9)* l 0 l l l 1 l l l --- 9 l l l

  11. Proof of Theorem 2 • Basic Idea: keep track of set of states NDFSA may reach on an input • But DFSA may be exponentially larger than NDFSA

  12. Example of Power-set Construction • (a|b)*.b.b a l b b 2 4 1 6 b a a b II I III b b a

More Related