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/3/2020 CS332 - Theory of Computation 2

  3. Regular? Construct an NFA for the following languages {0 𝑜 1 𝑜 | 0 < 𝑜 ≤ 2} 0 𝑜 1 𝑜 0 < 𝑜 ≤ 𝑙} {0 𝑜 1 𝑜 | 𝑜 > 0} 2/3/2020 CS332 - Theory of Computation 3

  4. Proving a language is not regular Theorem: 𝐵 = {0 𝑜 1 𝑜 | 𝑜 > 0} is not regular Proof: (by contradiction) Let 𝑁 be a DFA with 𝑙 states recognizing 𝐵 Consider running 𝑁 on input 0 𝑙 1 𝑙 2/3/2020 CS332 - Theory of Computation 4

  5. Regular or not? 𝐷 = { 𝑥 | 𝑥 has equal number of 1 s and 0 s } 𝐸 = { 𝑥 | 𝑥 has equal number of 10 s and 01 s } 2/3/2020 CS332 - Theory of Computation 5

  6. The Pumping Lemma A systematic way to prove that a language is not regular 2/3/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/3/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/3/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 𝑗 ≥ 0. 𝑗 = 0: 𝑗 = 2: 𝑗 = 1: 𝑗 = 3: 2/3/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. |𝑧| > 0 before all 𝑐’ s } ; 𝑞 = 1 2. |𝑦𝑧| ≤ 𝑞 3. 𝑦𝑧 𝑗 𝑨  𝑀 for all 𝑗 ≥ 0 2/3/2020 CS332 - Theory of Computation 10

  11. Using the Pumping Lemma Theorem: 𝐵 = {0 𝑜 1 𝑜 | 𝑜 > 0} is not regular Proof: (by contradiction) Assume instead that 𝐵 is regular. Then 𝐵 has a pumping length 𝑞 . What happens if we try to pump 0 𝑞 1 𝑞 ? If 𝐵 is regular, 𝑥 can be split into 𝑥 = 𝑦𝑧𝑨 , where 1. |𝑧| > 0 2. |𝑦𝑧| ≤ 𝑞 3. 𝑦𝑧 𝑗 𝑨  𝐵 for all 𝑗 ≥ 0 2/3/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/3/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/3/2020 CS332 - Theory of Computation 13

  14. Example: Palindromes Claim: 𝑀 = 𝑥𝑥 𝑆 𝑥 ∈ 0,1 ∗ } is not regular Proof: Assume 𝑀 is regular with pumping length 𝑞 1. Find 𝑥 ∈ 𝑀 with 𝑥 > 𝑞 2. Show that 𝑥 cannot be pumped Intuitively 2/3/2020 CS332 - Theory of Computation 14

  15. Example: Palindromes Claim: 𝑀 = 𝑥𝑥 𝑆 𝑥 ∈ 0,1 ∗ } is not regular Proof: Assume 𝑀 is regular with pumping length 𝑞 1. Find 𝑥 ∈ 𝑀 with 𝑥 > 𝑞 2. Show that 𝑥 cannot be pumped If 𝑥 = 𝑦𝑧𝑨 with | 𝑦𝑧 | ≤ 𝑞 , then… Formally 2/3/2020 CS332 - Theory of Computation 15

  16. Now you try! Claim: 𝑀 = 0 𝑗 1 𝑘 𝑗 > 𝑘 ≥ 0} is not regular Proof: Assume 𝑀 is regular with pumping length 𝑞 1. Find 𝑥 ∈ 𝑀 with 𝑥 > 𝑞 2. Show that 𝑥 cannot be pumped Intuitively 2/3/2020 CS332 - Theory of Computation 16

  17. Now you try! Claim: 𝑀 = 0 𝑗 1 𝑘 𝑗 > 𝑘 ≥ 0} is not regular Proof: Assume 𝑀 is regular with pumping length 𝑞 1. Find 𝑥 ∈ 𝑀 with 𝑥 > 𝑞 2. Show that 𝑥 cannot be pumped If 𝑥 = 𝑦𝑧𝑨 with | 𝑦𝑧 | ≤ 𝑞 , then… Formally 2/3/2020 CS332 - Theory of Computation 17

  18. Choosing wisely Claim: 𝐶𝐵𝑀𝐵𝑂𝐷𝐹𝐸 = 𝑥 𝑥 has an equal # of 0 s and 1 s } is not regular Proof: Assume 𝑀 is regular with pumping length 𝑞 1. Find 𝑥 ∈ 𝑀 with 𝑥 > 𝑞 2. Show that 𝑥 cannot be pumped If 𝑥 = 𝑦𝑧𝑨 with | 𝑦𝑧 | ≤ 𝑞 , then… Formally 2/3/2020 CS332 - Theory of Computation 18

  19. Reusing a Proof Pumping a language can be lots of work… Let’s try to reuse that work! How else might we show that 𝐶𝐵𝑀𝐵𝑂𝐷𝐹𝐸 is regular? 0 𝑜 1 𝑜 𝑜 ≥ 0} = 𝐶𝐵𝑀𝐵𝑂𝐷𝐹𝐸 ∩ 𝑥 all 0 s in 𝑥 appear before all 1 s } 2/3/2020 CS332 - Theory of Computation 19

  20. Using Closure Properties If 𝐵 is not regular, we can show a related language 𝐶 is not regular ∩ 𝐶 𝐷 𝐵 = (Not regular) (regular) any of {∘ , ∪ , ∩} or, for one language, {¬ , R , * } By contradiction: If 𝐶 is regular, then 𝐶 ∩ 𝐷 (= 𝐵) is regular. But 𝐵 is not regular so neither is 𝐶 ! 2/3/2020 CS332 - Theory of Computation 20

  21. Example Prove 𝐶 = {0 𝑗 1 𝑘 |𝑗 ≠ 𝑘} is not regular using nonregular language 𝐵 = 0 𝑜 1 𝑜 𝑜 ≥ 0 and regular language 𝐷 = 𝑥 all 0 s in 𝑥 appear before all 1 s } 2/3/2020 CS332 - Theory of Computation 21

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