bu cs 332 theory of computation
play

BU CS 332 Theory of Computation Lecture 4: Reading: Non regular - PowerPoint PPT Presentation

BU CS 332 Theory of Computation Lecture 4: Reading: Non regular languages Sipser Ch 1.4 Pumping Lemma Mark Bun February 3, 2020 The Philosophical Question Weve seen techniques for showing that languages are regular


  1. BU CS 332 – Theory of Computation Lecture 4: Reading: • Non ‐ regular languages Sipser Ch 1.4 • Pumping Lemma Mark Bun February 3, 2020

  2. The Philosophical Question • We’ve seen techniques for showing that languages are regular • Could it be the case that every language is regular? 2/4/2020 CS332 ‐ Theory of Computation 2

  3. Regular? Construct an NFA for the following languages 𝑜 𝑜 𝑜 𝑜 𝑜 𝑜 2/4/2020 CS332 ‐ Theory of Computation 3

  4. Proving a language is not regular 𝑜 𝑜 Theorem: is not regular Proof: (by contradiction) Let be a DFA with states recognizing 𝑙 𝑙 Consider running on input 2/4/2020 CS332 ‐ Theory of Computation 4

  5. Regular or not? has equal number of s and s has equal number of s and s 2/4/2020 CS332 ‐ Theory of Computation 5

  6. The Pumping Lemma A systematic way to prove that a language is not regular 2/4/2020 CS332 ‐ Theory of Computation 6

  7. Why do we teach this? Cons: • The statement is difficult (5 quantifiers!) • Some non ‐ regular languages can still be pumped Pros: • Proof illuminates essential structure of finite automata • Generalizes to other models of computation / classes of languages (CFLs, self ‐ assembly) • Applying it can be fun! 2/4/2020 CS332 ‐ Theory of Computation 7

  8. Intuition for the Pumping Lemma Imagine a DFA with states that recognizes strings of length Idea: If you can go around the cycle once, you can go around 0 or 2,3,4… times 2/4/2020 CS332 ‐ Theory of Computation 8

  9. Pumping Lemma (Informal) Let be a regular language. Let be a “long enough” string in . … | � | 0 𝑗 𝑘 � Then we can write such that for every 2/4/2020 CS332 ‐ Theory of Computation 9

  10. Pumping Lemma (Formal) Let be a regular language. Then there exists a “pumping length” such that For every where , can be split into three parts where: Example: Let all s in appear 1. before all s 2. 𝑗  3. for all 2/4/2020 CS332 ‐ Theory of Computation 10

  11. Using the Pumping Lemma 𝑜 𝑜 Theorem: is not regular Proof: (by contradiction) Assume instead that is regular. Then has a pumping length . 𝑞 𝑞 ? What happens if we try to pump If is regular, can be split into , where 1. | 𝑧 | � 0 2. | 𝑦𝑧 | � 𝑞 3. 𝑦𝑧 𝑗 𝑨  𝐵 for all 𝑗 � 0 2/4/2020 CS332 ‐ Theory of Computation 11

  12. General Strategy for proving is not regular Proof by contradiction: assume is regular. Then there is a pumping length . 2/4/2020 CS332 ‐ Theory of Computation 12

  13. Pumping Lemma as a game 1. YOU pick the language 𝑀 to be proved nonregular. 2. ADVERSARY picks a possible pumping length 𝑞 . 3. YOU pick 𝑥 of length at least 𝑞 . 4. ADVERSARY divides 𝑥 into 𝑦 , 𝑧 , 𝑨 , obeying rules of the Pumping Lemma: | 𝑧 | � 0 and | 𝑦𝑧 | � 𝑞 . 5. YOU win by finding 𝑗 � 0 , for which 𝑦𝑧 � 𝑨 is not in 𝑀 . If regardless of how the ADVERSARY plays this game, you can always win, then is nonregular 2/4/2020 CS332 ‐ Theory of Computation 13

  14. Example: Palindromes ∗ is not regular � Claim: Proof: Assume is regular with pumping length 1. Find with 2. Show that cannot be pumped Intuitively 2/4/2020 CS332 ‐ Theory of Computation 14

  15. Example: Palindromes ∗ is not regular � Claim: Proof: Assume is regular with pumping length 1. Find with 2. Show that cannot be pumped Formally If = with | | , then… 2/4/2020 CS332 ‐ Theory of Computation 15

  16. Now you try! � � Claim: is not regular Proof: Assume is regular with pumping length 1. Find with 2. Show that cannot be pumped Intuitively 2/4/2020 CS332 ‐ Theory of Computation 16

Recommend


More recommend