nfas continued closure properties of regular languages
play

NFAs continued, Closure Properties of Regular Languages Lecture 5 - PowerPoint PPT Presentation

CS/ECE 374: Algorithms & Models of Computation, Fall 2018 NFAs continued, Closure Properties of Regular Languages Lecture 5 September 11, 2018 Nikita Borisov (UIUC) CS/ECE 374 1 Fall 2018 1 / 49 Regular Languages, DFAs, NFAs Theorem


  1. CS/ECE 374: Algorithms & Models of Computation, Fall 2018 NFAs continued, Closure Properties of Regular Languages Lecture 5 September 11, 2018 Nikita Borisov (UIUC) CS/ECE 374 1 Fall 2018 1 / 49

  2. Regular Languages, DFAs, NFAs Theorem Languages accepted by DFAs, NFAs, and regular expressions are the same. Nikita Borisov (UIUC) CS/ECE 374 2 Fall 2018 2 / 49

  3. Regular Languages, DFAs, NFAs Theorem Languages accepted by DFAs, NFAs, and regular expressions are the same. DFAs are special cases of NFAs (trivial) NFAs accept regular expressions (today) DFAs accept languages accepted by NFAs (today) Regular expressions for languages accepted by DFAs (later in the course) Nikita Borisov (UIUC) CS/ECE 374 2 Fall 2018 2 / 49

  4. Part I Closure Properties of NFAs Nikita Borisov (UIUC) CS/ECE 374 3 Fall 2018 3 / 49

  5. A simple transformation Theorem For every NFA N there is another NFA N ′ such that L ( N ) = L ( N ′ ) and such that N ′ has the following two properties: N ′ has single final state f that has no outgoing transitions The start state s of N is different from f Nikita Borisov (UIUC) CS/ECE 374 4 Fall 2018 4 / 49

  6. Closure Properties of NFAs Are the class of languages accepted by NFAs closed under the following operations? union intersection concatenation Kleene star complement Nikita Borisov (UIUC) CS/ECE 374 5 Fall 2018 5 / 49

  7. Example 3, 7, 4 3, 7, 4 3 7 4 All strings that contain the substring 374 Nikita Borisov (UIUC) CS/ECE 374 6 Fall 2018 6 / 49

  8. Example 3, 7, 4 3, 7, 4 3 7 4 All strings that contain the substring 374 3, 7, 4 3, 7, 4 4 7 3 All strings that contain the substring 473 Nikita Borisov (UIUC) CS/ECE 374 6 Fall 2018 6 / 49

  9. Example II 3, 7, 4 3, 7, 4 3 7 4 ϵ 3, 7, 4 3, 7, 4 ϵ 4 7 3 All strings that contain either 374 or 473 Nikita Borisov (UIUC) CS/ECE 374 7 Fall 2018 7 / 49

  10. Closure under union Theorem For any two NFAs N 1 and N 2 there is a NFA N such that L ( N ) = L ( N 1 ) ∪ L ( N 2 ) . Nikita Borisov (UIUC) CS/ECE 374 8 Fall 2018 8 / 49

  11. Closure under union Theorem For any two NFAs N 1 and N 2 there is a NFA N such that L ( N ) = L ( N 1 ) ∪ L ( N 2 ) . q 1 f 1 N 1 q 2 f 2 N 2 Nikita Borisov (UIUC) CS/ECE 374 8 Fall 2018 8 / 49

  12. Closure under concatenation Theorem For any two NFAs N 1 and N 2 there is a NFA N such that L ( N ) = L ( N 1 ) · L ( N 2 ) . Nikita Borisov (UIUC) CS/ECE 374 9 Fall 2018 9 / 49

  13. Closure under concatenation Theorem For any two NFAs N 1 and N 2 there is a NFA N such that L ( N ) = L ( N 1 ) · L ( N 2 ) . q 1 q 2 f 2 f 1 N 1 N 2 Nikita Borisov (UIUC) CS/ECE 374 9 Fall 2018 9 / 49

  14. Closure under Kleene star Theorem For any NFA N 1 there is a NFA N such that L ( N ) = ( L ( N 1 )) ∗ . q 1 f 1 N 1 Nikita Borisov (UIUC) CS/ECE 374 10 Fall 2018 10 / 49

  15. Closure under Kleene star Theorem For any NFA N 1 there is a NFA N such that L ( N ) = ( L ( N 1 )) ∗ . ε q 1 f 1 N 1 Nikita Borisov (UIUC) CS/ECE 374 11 Fall 2018 11 / 49

  16. Closure under Kleene star Theorem For any NFA N 1 there is a NFA N such that L ( N ) = ( L ( N 1 )) ∗ . ε q 1 f 1 N 1 Does not work! Why? Nikita Borisov (UIUC) CS/ECE 374 11 Fall 2018 11 / 49

  17. Closure under Kleene star Theorem For any NFA N 1 there is a NFA N such that L ( N ) = ( L ( N 1 )) ∗ . ε q 0 q 1 f 1 N 1 ε Nikita Borisov (UIUC) CS/ECE 374 12 Fall 2018 12 / 49

  18. Part II NFAs capture Regular Languages Nikita Borisov (UIUC) CS/ECE 374 13 Fall 2018 13 / 49

  19. Regular Languages Recap Regular Languages Regular Expressions ∅ regular ∅ denotes ∅ { ǫ } regular ǫ denotes { ǫ } { a } regular for a ∈ Σ a denote { a } R 1 ∪ R 2 regular if both are r 1 + r 2 denotes R 1 ∪ R 2 R 1 R 2 regular if both are r 1 r 2 denotes R 1 R 2 R ∗ is regular if R is r ∗ denote R ∗ Regular expressions denote regular languages — they explicitly show the operations that were used to form the language Nikita Borisov (UIUC) CS/ECE 374 14 Fall 2018 14 / 49

  20. NFAs and Regular Language Theorem For every regular language L there is an NFA N such that L = L ( N ) . Proof strategy: For every regular expression r show that there is a NFA N such that L ( r ) = L ( N ) Induction on length of r Nikita Borisov (UIUC) CS/ECE 374 15 Fall 2018 15 / 49

  21. NFAs and Regular Language For every regular expression r show that there is a NFA N such that L ( r ) = L ( N ) Induction on length of r Base cases: ∅ , ǫ , a for a ∈ Σ Nikita Borisov (UIUC) CS/ECE 374 16 Fall 2018 16 / 49

  22. NFAs and Regular Language For every regular expression r show that there is a NFA N such that L ( r ) = L ( N ) Induction on length of r Inductive cases: r 1 , r 2 regular expressions and r = r 1 + r 2 . Nikita Borisov (UIUC) CS/ECE 374 17 Fall 2018 17 / 49

  23. NFAs and Regular Language For every regular expression r show that there is a NFA N such that L ( r ) = L ( N ) Induction on length of r Inductive cases: r 1 , r 2 regular expressions and r = r 1 + r 2 . By induction there are NFAs N 1 , N 2 s.t L ( N 1 ) = L ( r 1 ) and L ( N 2 ) = L ( r 2 ) . Nikita Borisov (UIUC) CS/ECE 374 17 Fall 2018 17 / 49

  24. NFAs and Regular Language For every regular expression r show that there is a NFA N such that L ( r ) = L ( N ) Induction on length of r Inductive cases: r 1 , r 2 regular expressions and r = r 1 + r 2 . By induction there are NFAs N 1 , N 2 s.t L ( N 1 ) = L ( r 1 ) and L ( N 2 ) = L ( r 2 ) . We have already seen that there is NFA N s.t L ( N ) = L ( N 1 ) ∪ L ( N 2 ) , hence L ( N ) = L ( r ) Nikita Borisov (UIUC) CS/ECE 374 17 Fall 2018 17 / 49

  25. NFAs and Regular Language For every regular expression r show that there is a NFA N such that L ( r ) = L ( N ) Induction on length of r Inductive cases: r 1 , r 2 regular expressions and r = r 1 + r 2 . By induction there are NFAs N 1 , N 2 s.t L ( N 1 ) = L ( r 1 ) and L ( N 2 ) = L ( r 2 ) . We have already seen that there is NFA N s.t L ( N ) = L ( N 1 ) ∪ L ( N 2 ) , hence L ( N ) = L ( r ) r = r 1 · r 2 . Nikita Borisov (UIUC) CS/ECE 374 17 Fall 2018 17 / 49

  26. NFAs and Regular Language For every regular expression r show that there is a NFA N such that L ( r ) = L ( N ) Induction on length of r Inductive cases: r 1 , r 2 regular expressions and r = r 1 + r 2 . By induction there are NFAs N 1 , N 2 s.t L ( N 1 ) = L ( r 1 ) and L ( N 2 ) = L ( r 2 ) . We have already seen that there is NFA N s.t L ( N ) = L ( N 1 ) ∪ L ( N 2 ) , hence L ( N ) = L ( r ) r = r 1 · r 2 . Use closure of NFA languages under concatenation Nikita Borisov (UIUC) CS/ECE 374 17 Fall 2018 17 / 49

  27. NFAs and Regular Language For every regular expression r show that there is a NFA N such that L ( r ) = L ( N ) Induction on length of r Inductive cases: r 1 , r 2 regular expressions and r = r 1 + r 2 . By induction there are NFAs N 1 , N 2 s.t L ( N 1 ) = L ( r 1 ) and L ( N 2 ) = L ( r 2 ) . We have already seen that there is NFA N s.t L ( N ) = L ( N 1 ) ∪ L ( N 2 ) , hence L ( N ) = L ( r ) r = r 1 · r 2 . Use closure of NFA languages under concatenation r = ( r 1 ) ∗ . Nikita Borisov (UIUC) CS/ECE 374 17 Fall 2018 17 / 49

  28. NFAs and Regular Language For every regular expression r show that there is a NFA N such that L ( r ) = L ( N ) Induction on length of r Inductive cases: r 1 , r 2 regular expressions and r = r 1 + r 2 . By induction there are NFAs N 1 , N 2 s.t L ( N 1 ) = L ( r 1 ) and L ( N 2 ) = L ( r 2 ) . We have already seen that there is NFA N s.t L ( N ) = L ( N 1 ) ∪ L ( N 2 ) , hence L ( N ) = L ( r ) r = r 1 · r 2 . Use closure of NFA languages under concatenation r = ( r 1 ) ∗ . Use closure of NFA languages under Kleene star Nikita Borisov (UIUC) CS/ECE 374 17 Fall 2018 17 / 49

  29. Example (ε+0)(1+10) * (ε+0) (1+10) * ε (1+10) * 0 Nikita Borisov (UIUC) CS/ECE 374 18 Fall 2018 18 / 49

  30. Example ε (1+10) * 0 ε 10 * 0 1 ε 1 0 * 0 1 Nikita Borisov (UIUC) CS/ECE 374 19 Fall 2018 19 / 49

  31. Example ε 1 0 * 0 1 ε 1 0 3 ε 0 4 1 2 1 0 ε Final NFA simplified slightly to reduce states Nikita Borisov (UIUC) CS/ECE 374 20 Fall 2018 20 / 49

  32. Part III Equivalence of NFAs and DFAs Nikita Borisov (UIUC) CS/ECE 374 21 Fall 2018 21 / 49

  33. Equivalence of NFAs and DFAs Theorem For every NFA N there is a DFA M such that L ( M ) = L ( N ) . Nikita Borisov (UIUC) CS/ECE 374 22 Fall 2018 22 / 49

  34. Formal Tuple Notation for NFA Definition A non-deterministic finite automata (NFA) N = ( Q , Σ , δ, s , A ) is a five tuple where Q is a finite set whose elements are called states, Σ is a finite set called the input alphabet, δ : Q × Σ ∪ { ǫ } → P ( Q ) is the transition function (here P ( Q ) is the power set of Q ), s ∈ Q is the start state, A ⊆ Q is the set of accepting/final states. δ ( q , a ) for a ∈ Σ ∪ { ǫ } is a susbet of Q — a set of states. Nikita Borisov (UIUC) CS/ECE 374 23 Fall 2018 23 / 49

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend