review
play

Review Languages and Grammars Alphabets, strings, languages CS 301 - PDF document

Review Languages and Grammars Alphabets, strings, languages CS 301 - Lecture 6 Regular Languages Deterministic Finite Automata Nonregular Languages and Nondeterministic Finite Automata Equivalence of NFA and DFA the


  1. Review • Languages and Grammars – Alphabets, strings, languages CS 301 - Lecture 6 • Regular Languages – Deterministic Finite Automata Nonregular Languages and – Nondeterministic Finite Automata – Equivalence of NFA and DFA the Pumping Lemma – Minimizing a DFA Fall 2008 – Regular Expressions – Regular Grammars – Properties of Regular Languages • Today: – Properties of Regular Languages – Pumping lemma for regular languages We say: Regular languages are closed under Reverse R NFA for L L ∪ L 1 Union: 1 2 L ′ M M 1 1 1 L 1 L Concatenation: 2 Star: L * 1 R Reversal: L 1 1. Reverse all transitions Complement: L 1 2. Make initial state final state Intersection: L ∩ L and vice versa 1 2 1

  2. Example Intersection M 1 L L L L DeMorgan’s Law: ∩ = ∪ 1 2 1 2 a n L 1 , L regular L { a b } 2 = b 1 L 1 , L regular 2 ′ M 1 L ∪ L regular 1 2 a R n L ∪ L L { ba } b regular = 1 2 1 L ∩ L regular 1 2 Example Standard Representations of Regular Languages n Regular Languages regular L { a b } = 1 L L { ab } ∩ = 1 2 DFAs L = { ab , ba } regular regular Regular 2 Grammars NFAs Regular Expressions 2

  3. When we say: We are given Elementary Questions a Regular Language L about We mean: Language is in a standard L representation Regular Languages Membership Question DFA w w ∈ L Question: Given regular language L and string w w ∈ L how can we check if ? DFA w L Answer: Take the DFA that accepts w ∉ L w and check if is accepted 3

  4. Question: Given regular language DFA L how can we check if is empty: ? L L ( L ) ≠ ∅ = ∅ DFA Answer: Take the DFA that accepts L L = ∅ Check if there is any path from the initial state to a final state DFA Question: Given regular language L how can we check L is infinite if is finite? L DFA Answer: Take the DFA that accepts L Check if there is a walk with cycle L is finite from the initial state to a final state 4

  5. ( L L ) ( L L ) ∩ ∪ ∩ = ∅ 1 2 1 2 Question: L L Given regular languages and 1 2 how can we check if ? L = L 1 2 and L L L L ∩ = ∅ ∩ = ∅ 1 2 1 2 L L L L 1 L 2 L 2 1 1 2 Answer: Find if ( L L ) ( L L ) ∩ ∪ ∩ = ∅ L ⊆ L L ⊆ L 1 2 1 2 1 2 2 1 L = L 1 2 ( L L ) ( L L ) ∩ ∪ ∩ ≠ ∅ 1 2 1 2 When we say: We are given a Regular Language L or L L L L ∩ ≠ ∅ ∩ ≠ ∅ 1 2 1 2 L L L L 1 2 2 1 We mean: Language is in a standard L representation L ⊄ L L ⊄ L 1 2 2 1 L ≠ L 1 2 5

  6. L How can we prove that a language n n { a b : n 0 } ≥ is not regular? Non-regular languages vv R { : v { a , b }*} ∈ Prove that there is no DFA that accepts L Regular languages a * b b * c a + Problem: this is not easy to prove b c ( a b ) * + + Solution: the Pumping Lemma !!! etc ... pigeons 4 The Pigeonhole Principle 3 pigeonholes 6

  7. n pigeons A pigeonhole must contain at least two pigeons ........... n > m pigeonholes m ........... The Pigeonhole Principle The Pigeonhole pigeons n Principle pigeonholes m There is a pigeonhole n > m with at least 2 pigeons and DFAs ........... 7

  8. a In walks of strings: no state is repeated aa DFA with states 4 aab b b b b b b a b b q q q q 1 2 3 4 a a b q q q q 1 2 3 4 a a a a w | w | 4 In walks of strings: a state If string has length : aabb ≥ is repeated bbaa w Then the transitions of string are more than the states of the DFA abbabb abbbabbabb ... Thus, a state must be repeated b b b b b b a a a a b b q q q q q q q q 1 2 3 4 1 2 3 4 a a a a 8

  9. In general, for any DFA: w In other words for a string : String has length number of states w a ≥ transitions are pigeons states are pigeonholes A state must be repeated in the walk of w q q walk of w walk of w ...... ...... ...... ...... q q Repeated state Repeated state Take an infinite regular language L There exists a DFA that accepts L The Pumping Lemma m states 9

  10. | w ≥ | m w If string has length (number of states w ∈ L Take string with w of DFA) then, from the pigeonhole principle: a state is repeated in the walk w w There is a walk with label : ......... ...... ...... q walk w walk w Write w = x y z q Let be the first state repeated in the y walk of w ...... ...... q ...... ...... q walk w z x 10

  11. | x y | m Observations: length number x z Observation: The string ≤ of states is accepted of DFA length | y | 1 ≥ y y ...... ...... ...... ...... q q z z x x x y y z x y y y z Observation: The string Observation: The string is accepted is accepted y y ...... ...... ...... ...... q q z z x x 11

  12. i x y z In General: The string In General: i 0 , 1 , 2 , ... = is accepted i 0 , 1 , 2 , ... = Language accepted by the DFA y y ...... ...... ...... ...... q q z z x x The Pumping Lemma: In other words, we described: • Given a infinite regular language L m • there exists an integer | w ≥ | m • for any string with length w ∈ L The Pumping Lemma !!! w = x y z • we can write | x y | m | y | 1 • with and ≤ ≥ i i 0 , 1 , 2 , ... x y z L • such that: = ∈ 12

  13. n n Theorem: The language L { a b : n 0 } = ≥ Applications is not regular of the Pumping Lemma Proof: Use the Pumping Lemma n n n n L { a b : n 0 } L { a b : n 0 } = ≥ = ≥ m Let be the integer in the Pumping Lemma Assume for contradiction L that is a regular language w w ∈ L Pick a string such that: | w ≥ | m length Since is infinite L we can apply the Pumping Lemma m b m w = a We pick 13

  14. m m m b m k a b x y z x y z a y a , k 1 Write: = = = ≥ From the Pumping Lemma i | x y | m , | y | 1 it must be that length ≤ ≥ x y z L From the Pumping Lemma: ∈ m m i 0 , 1 , 2 , ... = m m xyz a b a ... aa ... aa ... ab ... b = = x y z 2 Thus: x y z L ∈ k y a , k 1 Thus: = ≥ m b m k m k m + x y z a y a , k 1 a b L = = ≥ ∈ 2 x y z L From the Pumping Lemma: ∈ n n BUT: L { a b : n 0 } = ≥ m m + k 2 xy z a ... aa ... aa ... aa ... ab ... b L = ∈ m k m + a b L ∉ x y y z CONTRADICTION!!! m k m + a b L Thus: ∈ 14

  15. L Therefore: Our assumption that n n Non-regular languages { a b : n 0 } ≥ is a regular language is not true Regular languages Conclusion: L is not a regular language What’s Next • Read – Linz Chapter 1, 2.1, 2.2, 2.3, (skip 2.4) 3, and 4 – JFLAP Startup, Chapter 1, 2.1, 3, 4, 6.1 • Next Lecture Topics from Chapter 4.3 – More Pumping Lemma • Quiz 1 in Recitation on Wednesday 9/17 – Covers Linz 1.1, 1.2, 2.1, 2.2, 2.3 and JFLAP 1, 2.1 – Closed book, but you may bring one sheet of 8.5 x 11 inch paper with any notes you like. – Quiz will take the full hour • Homework – Homework Due Today – New Homework Assigned Friday Morning – New Homework Due Following Thursday 15

Recommend


More recommend