section 3 non determinism regular expressions and kleene
play

Section 3 Non-Determinism, Regular Expressions, and Kleenes Theorem - PowerPoint PPT Presentation

Section 3 Non-Determinism, Regular Expressions, and Kleenes Theorem Automata Theory Non-Determinism, Regular Expressions, and Kleenes Theorem 109 / 289 Chapter Non-Determinism, Regular Expressions, and Kleenes 2 Theorem Examples


  1. Section 3 Non-Determinism, Regular Expressions, and Kleene’s Theorem Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem 109 / 289

  2. Chapter Non-Determinism, Regular Expressions, and Kleene’s 2 Theorem Examples Allowing Λ -transitions Definitions Making the automaton deterministic Regular languages Kleene Brzozowski et McCluskey Other Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem 110 / 289

  3. Non-determinism: possibly many computations on given input accept input when at least one of these computations accepts.

  4. Non-determinism ab or bba a 2 p a b a 1 p 2 s a , b a b 1 q 1 r b b a b a , b a , b a b b [M] see ֒ → E.2.18 (product construction) Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem Examples 111 / 289

  5. Third from end a a , b a , b a , b Also ֒ → deterministic b aab abb a b b b a a aaa a b aba bab bbb b b a a a b baa bba a n + 1 versus 2 n states. Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem Examples 112 / 289

  6. { aa , aba } ∗ { b } q 1 a a b q 0 q 4 a b q 2 q 3 a [M] E 3.6. also ֒ → E 2.22 Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem Examples 113 / 289

  7. Computation tree q 1 a a b q 0 q 4 a b q 2 q 3 a x = aaaabaab a a b q 2 q 3 q 2 q 3 q 0 a a a b q 0 q 2 q 3 q 0 a a q 1 q 0 a q 1 q 0 q 4 a a b a q 1 q 0 q 4 a b [M] E 3.6. also ֒ → E 2.22 Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem Examples 114 / 289

  8. Intro: Λ -transitions { aab } ∗ { a , aba } ∗ a 1 2 a a b Λ 0 3 a a 4 5 b NFA Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem Allowing Λ -transitions 115 / 289

  9. { ab , aba } ∗ Non-determinism q 3 a a b a q 0 q 1 q 2 b a a b b q 0 q 1 q 4 Λ a b q 2 a , b Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem Allowing Λ -transitions 116 / 289

  10. Computation tree when Λ ’s are around a 1 2 a a b Λ 0 3 a a 4 5 b a 4 b a a 3 4 5 3 a 3 b a a 3 a 4 5 3 3 Λ a 3 Λ 0 1 2 0 1 a a a b Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem Allowing Λ -transitions 117 / 289 [M] E 3.9

  11. Formalism From lecture 1: Definition (FA) [deterministic] finite automaton 5-tuple M = ( Q , Σ , q 0 , A , δ ) , – Q finite set states ; – Σ finite input alphabet ; – q 0 ∈ Q initial state; – A ⊆ Q accepting states; – δ : Q × Σ → Q transition function . [M] D 2.11 Finite automaton [L] D 2.1 Deterministic finite accepter, has ‘final’ states δ : Q × Σ → Q Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem Definitions 118 / 289

  12. 5-tuple M = ( Q , Σ , q 0 , A , δ ) Definition ( ֒ → FA) [deterministic] finite automaton – δ : Q × Σ → Q transition function ; Definition (NFA) nondeterministic finite automaton (with Λ -transitions) – δ : . . . Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem Definitions 119 / 289

  13. 5-tuple M = ( Q , Σ , q 0 , A , δ ) Definition ( ֒ → FA) [deterministic] finite automaton – δ : Q × Σ → Q transition function ; Definition (NFA) nondeterministic finite automaton (with Λ -transitions) – δ : Q × ( Σ ∪ { Λ } ) → . . . Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem Definitions 120 / 289

  14. Function value Example { aab } ∗ { a , aba } ∗ a 1 2 a a b Λ 0 3 a a 4 5 a b δ Λ b 0 { 3 } { 1 } ∅ NFA 3 { 3, 4 } ∅ ∅ Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem Definitions 121 / 289

  15. 5-tuple M = ( Q , Σ , q 0 , A , δ ) Definition ( ֒ → FA) [deterministic] finite automaton – δ : Q × Σ → Q transition function ; Definition (NFA) nondeterministic finite automaton (with Λ -transitions) – δ : Q × ( Σ ∪ { Λ } ) → 2 Q Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem Definitions 122 / 289

  16. Extended transfer function Without Λ -transitions: extend δ to subsets P : δ ( P , σ ) = � p ∈ P δ ( p , σ ) = { q ∈ Q | q ∈ δ ( p , σ ) for some p ∈ P } . σ P δ ( P , σ ) σ σ δ ∗ ( q , x ) . . . Now, with Λ -transitions: δ ∗ ( q , x ) . . . Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem Definitions 123 / 289

  17. Λ -closure NFA M = ( Q , Σ , q 0 , A , δ ) S ⊆ Q Definition – S ⊆ Λ ( S ) – q ∈ Λ ( S ) , then δ ( q , Λ ) ⊆ Λ ( S ) a b a Λ Λ Λ Λ 1 2 3 4 5 6 7 8 q 0 ∈ δ ∗ ( q 0 , Λ ) ∈ δ ∗ ( q 0 , a ) ∈ δ ∗ ( q 0 , ab ) ∈ δ ∗ ( q 0 , aba ) Definition – δ ∗ ( q , Λ ) = Λ ( { q } ) q ∈ Q – δ ∗ ( q , y σ ) = Λ ( δ ( δ ∗ ( q , y ) , σ ) ) q ∈ Q , y ∈ Σ ∗ , σ ∈ Σ [M] D 3.13 & 3.14 Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem Definitions 124 / 289

  18. Example NFA- Λ Λ Λ ( { q 0 } ) = { q 0 , p , t } δ ∗ ( q 0 , Λ ) = { q 0 , p , t } a b Λ · a δ ( { q 0 , p , t } , a ) = { p , u } b a p r s δ ∗ ( q 0 , a ) = Λ ( { p , u } ) = { p , u } Λ Λ Λ a · b q 0 w δ ( { p , u } , b ) = { r , v } δ ∗ ( q 0 , ab ) = Λ ( { r , v } ) = Λ Λ u v t a { r , v , w , q 0 , p , t } b ab · a a b δ ( { r , v , w , q 0 , p , t } , a ) = { s , v , p , u } δ ∗ ( q 0 , aba ) = Λ ( { s , v , p , u } ) = { s , w , q 0 , p , t , v , u } [M] E 3.15 Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem Definitions 125 / 289

  19. NFA M = ( Q , Σ , q 0 , A , δ ) Theorem q ∈ δ ∗ ( p , x ) iff there is a path in [the transition graph of] M from p to q with label x (possibly including Λ -transitions). δ ∗ ( q 0 , x ) = ∅ no path for x from initial state Definition A string x ∈ Σ ∗ is accepted by M = ( Q , Σ , q 0 , A , δ ) if δ ∗ ( q 0 , x ) ∩ A � = ∅ . The language L ( M ) accepted by M is the set of all strings accepted by M . [M] D 3.14 [L] D 2.2 Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem Definitions 126 / 289

  20. Idea a , b ∅ b b { aab } ∗ { a , aba } ∗ 0 b b a a a a b 1 2 1 2 05 134 5 a a b a a a a b b b Λ a 0 3 0 3 234 34 3 a a a a a a a a 4 5 4 5 b b NFA - Λ NFA FA Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem Making the automaton deterministic 127 / 289

  21. Theorem For every language L ⊆ Σ ∗ accepted by an NFA M = ( Q , Σ , q 0 , A , δ ) , there is an NFA M 1 with no Λ -transitions that also accepts L. [M] T 3.17 The precise inductive proof of this result does not have to be known for the exam. However, the construction in the next slides has to be known. Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem Making the automaton deterministic 128 / 289

  22. Construction: removing Λ -transitions Different from book! Λ a Λ a Λ a Λ 1 2 3 4 5 6 7 8 a a a Example 5 a 5 a a b a a b Λ a b 1 2 3 4 a a b 1 2 3 4 a Λ a [M] E 3.19 but fewer edges! Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem Making the automaton deterministic 129 / 289

  23. Formal construction Different from book! a Λ Λ p q p r a Λ -removal NFA M = ( Q , Σ , q 0 , A , δ ) construct NFA M 1 = ( Q , Σ , q 0 , A 1 , δ 1 ) without Λ -transitions – whenever q ∈ Λ M ( { p } ) and r ∈ δ ( q , a ) , add r to δ 1 ( p , a ) – whenever Λ M ( { p } ) ∩ A � = ∅ , add p to A 1 . In particular, – non- Λ -transitions are maintained – A ⊆ A 1 Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem Making the automaton deterministic 130 / 289

  24. Example L = { aab } ∗ { a , aba } ∗ a a 1 2 1 2 a a a a b b Λ a 0 3 0 3 a a a a a 4 5 4 5 b b Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem Making the automaton deterministic 131 / 289

  25. NFA example 1) removing Λ -transitions { a } ∗ [ { ab } ∗ { b } ∪ { b } ∗ { a } ] 3 a b a 2 b Λ 1 5 a Λ 4 q δ ( q , a ) δ ( q , b ) δ ( q , Λ ) Λ ( { q } ) 1 1 − 2, 4 1, 2, 4 2 3 5 − 2 b 3 − 2 − 3 4 5 4 − 4 5 − − − 5 [M] E 3.23 Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem Making the automaton deterministic 132 / 289

  26. NFA example 1) removing Λ -transitions { a } ∗ [ { ab } ∗ { b } ∪ { b } ∗ { a } ] 3 3 b a b a a a a 2 2 b b Λ a , b 1 5 1 5 a a b Λ 4 4 b b [M] E 3.23 but fewer edges! Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem Making the automaton deterministic 133 / 289

  27. Theorem For every language L ⊆ Σ ∗ accepted by an NFA M = ( Q , Σ , q 0 , A , δ ) without Λ -transitions, there is an FA M 1 that also accepts L. [M] T 3.18 The precise inductive proof of this result does not have to be known for the exam. However, the construction in the next slides has to be known. Automata Theory Non-Determinism, Regular Expressions, and Kleene’s Theorem Making the automaton deterministic 134 / 289

Recommend


More recommend