1 / 22

CSI 3104 /Winter 2006 : Introduction to Formal Languages Chapter 5: Finite Automata

CSI 3104 /Winter 2006 : Introduction to Formal Languages Chapter 5: Finite Automata. Chapter 5: Finite Automata We introduce the simplest deterministic theoretical machines: Finite Automata. Chapter 5: Finite Automata. A finite automaton (FA) is the following 3 things:

beau
Download Presentation

CSI 3104 /Winter 2006 : Introduction to Formal Languages Chapter 5: Finite 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. CSI 3104 /Winter 2006: Introduction to Formal Languages Chapter 5: Finite Automata Chapter 5: Finite Automata We introduce the simplest deterministic theoretical machines: Finite Automata. Dr. Nejib Zaguia CSI3104-W06

  2. Chapter 5: Finite Automata • A finite automaton (FA) is the following 3 things: • a finite set of states, one of which is designated as the start state, and some (maybe none) of which are designated the final states (or accepting states) • an alphabet of input letters • a finite set of transitions that indicate, for each state and letter of the input alphabet, the state to go to next state state letter Dr. Nejib Zaguia CSI3104-W06

  3. Chapter 5: Finite Automata • The language defined or accepted by a finite automaton is the set of words that end in a final state. • If w is in the language defined by a finite automaton, then we also say that the finite automaton accepts w. Dr. Nejib Zaguia CSI3104-W06

  4. a b x y z y x z z z z a a y is not final; aaa is not accepted a y x y aaa: x a b a a z z x y z is final; aaba is accepted aaba: x Chapter 5: Finite Automata Example: = {a,b} states = {x,y,z} start state : x final states: {z} transitions: Dr. Nejib Zaguia CSI3104-W06

  5. a x– a b x y z y x z z z z y a b b z+ b a Chapter 5: Finite Automata Transition Diagram Regular expression: (a+b)*b(a+b)* aaaabba? bbaabbbb? Dr. Nejib Zaguia CSI3104-W06

  6. a x– y a a a a x– y b a b x– y b z+ b a b z+ b a b b b z+ a b a b Chapter 5: Finite Automata bbaabbbb? aaaabba? Dr. Nejib Zaguia CSI3104-W06

  7. a a,b – + b a,b + Chapter 5: Finite Automata (a+b)* (a+b)(a+b)* = (a+b)+ Dr. Nejib Zaguia CSI3104-W06

  8. a a,b – b a,b a,b a,b + – Chapter 5: Finite Automata Finite Automata that Accept No Words No final state The middle state is not a final state and all transitions that go into this state do not exit. Dr. Nejib Zaguia CSI3104-W06

  9. Chapter 5: Finite Automata Two Ways to Study Finite Automata • Starting with a finite automaton (FA), analyze it to determine the language it accepts. • Starting from a language, build an FA. Dr. Nejib Zaguia CSI3104-W06

  10. a b 1 2 2 2 1 1 a,b 1+ 2 a,b Chapter 5: Finite Automata Example of 2: The language of all words with an even number of letters over the alphabet {a,b}: • Two states: 1 – even number, 2 – odd number • Start state: 1 • Final state: 1 • The transitions: Dr. Nejib Zaguia CSI3104-W06

  11. a,b y b x– a a,b z+ a,b b – a a,b a,b + + Chapter 5: Finite Automata a(a+b)* Not necessarily unique: Remark: 2 final states Dr. Nejib Zaguia CSI3104-W06

  12. Chapter 5: Finite Automata From Languages to Finite Automata • There is not necessarily a unique FA that accepts a given language. • Is there always at least one FA: • that accepts each possible language? • that defines a language associated with a given regular expression? Dr. Nejib Zaguia CSI3104-W06

  13. Chapter 5: Finite Automata • Example: Build an FA that accepts all words containing a triple letter (either aaa or bbb). • Build an FA that accepts aaa • Add a path that accepts bbb. • Add paths for words that contain a’s and b’s before or after the aaa or bbb. Dr. Nejib Zaguia CSI3104-W06

  14. 2 a,b a a 4+ a b 1– b b 3 Chapter 5: Finite Automata From Finite Automata to Languages • Does this FA accept the word ababa? • The word babbb? • 2 ways to get to state 4 • The only way to get to state 2 is by reading an input a. • The only way to get to state 3 is by reading an input b. • What language? This example shows that it is possible to characterize states by the purposes they serve. Dr. Nejib Zaguia CSI3104-W06

  15. a,b a a,b a,b – b a,b + Chapter 5: Finite Automata • The third letter is b. (aab + abb + bab + bbb)(a+b)* (a+b)(a+b)b(a+b)* • The regular expression is not unique. • Is there always at least one regular expression defining the language accepted by an FA? Dr. Nejib Zaguia CSI3104-W06

  16. a a + b – b a,b b a a,b Chapter 5: Finite Automata • Regular expression: baa • A “collecting bucket” state for all other words. Dr. Nejib Zaguia CSI3104-W06

  17. a a b + a b + – a,b b b a a,b a,b Chapter 5: Finite Automata • Regular expression: baa + ab Dr. Nejib Zaguia CSI3104-W06

  18. a a,b b b a,b + + a b b b a a a – – + + b a Chapter 5: Finite Automata L (a+b)*a + L Words that do not end in b. (a+b)*a Words that end in a. ? Dr. Nejib Zaguia CSI3104-W06

  19. b b a – + a Chapter 5: Finite Automata • The only letter that can change state is a. (b*ab*)(ab*ab*)* • an odd number of a’s Dr. Nejib Zaguia CSI3104-W06

  20. b a,b a a – + b Chapter 5: Finite Automata Words that contain a double a (a+b)*aa(a+b)* • Start state: the previous letter (if there is one) was not an a. • Middle state: we have just seen an a that was not preceded by an a. • Final state: we have seen a double a. Dr. Nejib Zaguia CSI3104-W06

  21. a b b a b + b + a a a a a b – – b a b a + b b Chapter 5: Finite Automata aabbaabb Dr. Nejib Zaguia CSI3104-W06

  22. b 1+ 2 b a a a a b 3 4 b Chapter 5: Finite Automata The Language EVEN-EVEN Dr. Nejib Zaguia CSI3104-W06

More Related