1 / 132

Lecture 5: Finite Automata

Lecture 5: Finite Automata. 虞台文. 大同大學資工所 智慧型多媒體研究室. Content. Alphabets and Languages Deterministic Finite Automata Nondeterministic Finite Automata Equivalence of DFA &NFA Properties of Languages Accepted by FA’s Finite Automata & Regular Expressions Languages Not Accepted by FA’s.

Download Presentation

Lecture 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. Lecture 5: Finite Automata 虞台文 大同大學資工所 智慧型多媒體研究室

  2. Content • Alphabets and Languages • Deterministic Finite Automata • Nondeterministic Finite Automata • Equivalence of DFA &NFA • Properties of Languages Accepted by FA’s • Finite Automata & Regular Expressions • Languages Not Accepted by FA’s

  3. Lecture 5: Finite Automata Alphabets and Languages 大同大學資工所 智慧型多媒體研究室

  4. Alphabets • Alphabet  a finite set of symbols • Examples:  binary alphabet  decimal alphabet  Roman alphabet  Greek alphabet  my alphabet

  5. Strings • String over an alphabet ()  a finitesequence of symbols from  • * the set of allstrings over  • Examples:

  6. More on Strings • String length # symbols in a string, e.g., • A string, w, can be considered as a function , e.g., • Some string operations: • Concatenation • Reversal • Duplication

  7. More on Strings • Substring • Suffix • Prefix  a prefix of w and a substring of w.  a suffix of w and a substring of w.  a substring of w.

  8. Countability of * * is countably infinite for any finite alphabet . Example: * can be enumerated by:

  9. Languages • Language L over   any subset of * i.e., L* • How many possible languages over ? • How to specify a language?  uncountably infinite

  10. Operations of Languages • Complement • Union • Intersection

  11. Operations of Languages • Complement, Union and Intersection • Concatenation • Closure or Kleene Star • Positive Closure

  12. ? ? 1909 – 1994 Example: Kleene Star

  13. ? ? 1909 – 1994 Example: Kleene Star  

  14. ? ? 1909 – 1994 Example: Kleene Star 

  15. Language Recognition Device A machine or algorithm to answer the question

  16. Lecture 5: Finite Automata Deterministic Finite Automata 大同大學資工所 智慧型多媒體研究室

  17. a b a a b b a b a a q0 q5 q1 Finite control q2 q4 q3 Finite State Machine Input tape Reading Head

  18. Definition  Deterministic Finite Automaton A deterministicfinite automaton is a 5-tuple (K, , , s, F) K: a finite set of states : a finite set of symbols : the transition functionK K sK: the initial state FK: the set of final states

  19. 1 1 q0 q1 0 0 > 1 0 0 symbol  1 0 1 q2 q3 q0 q2 q1 q1 q3 q0 state q2 q0 q3 q3 q1 q2 (K, , , s, F) Example K={q0, q1, q2, q3} ={0, 1} s=q0 F={q0}

  20. 1 Input tape 0 1 1 0 0 1 0 1 1 q0 q1 0 0 Reading Head > q0 q1 1 0 0 Finite control q3 q2 1 q2 q3 Operations of a DFA

  21. 1 Input tape 0 1 1 0 0 1 0 1 1 q0 q1 0 0 Reading Head > q0 q1 1 0 0 Finite control q3 q2 1 q2 q3 Operations of a DFA Strings are fed into the device by means of an input tape. • Main part of the machine • Initially, • putting reading head at the leftmost • in state s = q0 • Sense input symbol • Change state based on  • Move head right one cell • Give answer when head reaches end

  22. 1 Input tape 0 1 1 0 0 1 0 1 1 q0 q1 0 0 Reading Head > q0 q1 1 0 0 Finite control q3 q2 1 q2 q3 DFA As a Language Acceptor Accepted • The input string is accepted by the machine if the reading head ends at a final state. • Otherwise, it is rejected. JFLAP Rejected

  23. 1 Input tape 0 1 1 0 0 1 0 1 1 q0 q1 0 0 Reading Head > q0 q1 1 0 0 Finite control q3 q2 1 q2 q3 DFA As a Language Acceptor What language the machine accepts? • The input string is accepted by the machine if the reading head ends at a final state. • Otherwise, it is rejected.

  24. 1 Input tape 0 1 1 0 0 1 0 1 1 0 0 Reading Head q0 q1 > q0 q1 1 0 0 Finite control q3 q2 1 q2 q3 DFA As a Language Acceptor What language the machine accepts? • The input string is accepted by the machine if the reading head ends at a final state. • Otherwise, it is rejected. q3

  25. w u Input tape a b a a b b a b a a Reading Head q0 q5 q1 Finite control q2 q4 q3 M = (K, , , s, F) Memory Configuration of a DFA

  26. w u Input tape a b a a b b a b a a Reading Head q0 q5 q1 Finite control q2 q4 q3 M = (K, , , s, F) Memory Configuration of a DFA Does not effect the result.

  27. M = (K, , , s, F) Memory Configuration of a DFA

  28. Memory Configuration of a DFA M = (K, , , s, F)

  29. w u Input tape a b a a b b a b a a Reading Head q0 q5 q1 Finite control q2 q4 q3 Memory Configuration of a DFA

  30. Yields in One Step if

  31. * Yields in some (including zero) steps if

  32. String Acceptance by a DFA M = (K, , , s, F) w* is said to be accepted by M iff such that

  33. Language Defined by a DFA M = (K, , , s, F) Language L(M) denotes the set of all strings accepted by M, i.e.,

  34. 1 1 q0 q1 0 0 (q2, 100100110) (q3, 00100110) > (q1, 0100110) 1 0 0 (q3, 100110) (q2, 00110) 1 (q0, 0110) q2 q3 (q2, 110) (q3, 10) (q2, 0) (q0, ) w=0100100110 Example wL(M)? (q0, 0100100110) M

  35. 1 1 q0 q1 0 0 (q2, 100100110) (q3, 00100110) > (q1, 0100110) 1 0 0 (q3, 100110) (q2, 00110) 1 (q0, 0110) q2 q3 (q2, 110) (q3, 10) (q2, 0) (q0, ) w=0100100110  Example wL(M)? (q0, 0100100110) M

  36. 1 1 q0 q1 0 0 > 1 0 0 1 q2 q3 Example M

  37. a b a a > q0 q1 q2 q3 a b b b Example

  38. a a a b a b > a, b > a, b b b a, b a, b a, b Exercises • Describe informally the languages accepted by the deterministic finite automata shown below: (a) (b)

  39. Exercises • Construct deterministic finite automata accepting each of the following languages • {w{a, b}*: each a in w is immediately preceded and immediately followed by a b}. • {w{a, b}*: w has abab as a substring}. • {w{a, b}*: w has neither aa nor bb as a substring}. • {w{a, b}*: w has both ab and ba as a substring}.

  40. Lecture 5: Finite Automata Nondeterministic Finite Automata 大同大學資工所 智慧型多媒體研究室

  41. Review  Deterministic Finite Automaton A deterministicfinite automaton is a 5-tuple (K, , , s, F) K: a finite set of states : a finite set of symbols : the transition functionK K sK: the initial state FK: the set of final states

  42. non ,  Definition Nondeterministic Finite Automaton A nondeterministicfinite automaton is a 5-tuple (K, , , s, F) A deterministicfinite automaton is a 5-tuple (K, , , s, F) K: a finite set of states : a finite set of symbols : the transition functionK 2K : the transition functionK K 2K sK: the initial state FK: the set of final states

  43. a  a p p Transition Functions of FA’s : K K : K 2K  K q Q K

  44. a  a p p Transition Functions of FA’s : K K : K 2K Change to one of state in Q nondeterministically. Change to state q deterministically.  K q Q K

  45. M = (K, , , s, F) Yields in One Step if

  46. * if is possible. M = (K, , , s, F) Yields in some (including zero) steps

  47. String Acceptance by a NFA M = (K, , , s, F) w* is said to be accepted by M iff such that

  48. Language Defined by an NFA M = (K, , , s, F) Language L(M) denotes the set of all strings accepted by M, i.e.,

  49. a a b a > a q0 q1 q2 q3 b > q0 a b b b q4 a b a,b Example: L=(ab+aba)* NFA DFA q1 q2

  50. a > q0 a  > q0 b a a b b L=(ab+aba)* Extension: -Move & Multi-Move q1 NFA q2 q1 q2

More Related