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

β–Ά
bu cs 332 theory of computation
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

BU CS 332 – Theory of Computation

Lecture 4:

  • Non-regular languages
  • Pumping Lemma

Reading: Sipser Ch 1.4

Mark Bun February 3, 2020

slide-2
SLIDE 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

slide-3
SLIDE 3

Regular?

Construct an NFA for the following languages

2/3/2020 CS332 - Theory of Computation 3

{0π‘œ1π‘œ | 0 < π‘œ ≀ 2} 0π‘œ1π‘œ 0 < π‘œ ≀ 𝑙} {0π‘œ1π‘œ | π‘œ > 0}

slide-4
SLIDE 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

slide-5
SLIDE 5

Regular or not?

2/3/2020 CS332 - Theory of Computation 5

𝐷 = { π‘₯ | π‘₯ has equal number of 1s and 0s} 𝐸 = { π‘₯ | π‘₯ has equal number of 10s and 01s}

slide-6
SLIDE 6

The Pumping Lemma

A systematic way to prove that a language is not regular

2/3/2020 CS332 - Theory of Computation 6

slide-7
SLIDE 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

slide-8
SLIDE 8

Intuition for the Pumping Lemma

Imagine a DFA with π‘ž states that recognizes strings of length > π‘ž

2/3/2020 CS332 - Theory of Computation 8

Idea: If you can go around the cycle once, you can go around 0 or 2,3,4… times

slide-9
SLIDE 9

Pumping Lemma (Informal)

2/3/2020 CS332 - Theory of Computation 9

π‘Ÿ0 π‘Ÿπ‘— π‘Ÿπ‘˜ π‘Ÿ|π‘₯| … 𝑦 𝑧 𝑨 Let 𝑀 be a regular language. Let π‘₯ be a β€œlong enough” string in 𝑀. Then we can write π‘₯ = 𝑦𝑧𝑨 such that 𝑦𝑧𝑗𝑨 ∈ 𝑀 for every 𝑗 β‰₯ 0. 𝑗 = 0: 𝑗 = 2: 𝑗 = 1: 𝑗 = 3:

slide-10
SLIDE 10

Pumping Lemma (Formal)

2/3/2020 CS332 - Theory of Computation 10

Let 𝑀 be a regular language. Then there exists a β€œpumping length” π‘ž such that

  • 1. |𝑧| > 0
  • 2. |𝑦𝑧| ≀ π‘ž
  • 3. 𝑦𝑧𝑗𝑨 οƒŽ 𝑀 for all 𝑗 β‰₯ 0

For every π‘₯ ∈ 𝑀 where |π‘₯| β‰₯ π‘ž, π‘₯ can be split into three parts π‘₯ = 𝑦𝑧𝑨 where: Example: Let 𝑀 = {π‘₯ | all 𝑏’s in π‘₯ appear before all 𝑐’s} ; π‘ž = 1

slide-11
SLIDE 11

Using the Pumping Lemma

2/3/2020 CS332 - Theory of Computation 11

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
slide-12
SLIDE 12

General Strategy for proving 𝑀 is not regular

2/3/2020 CS332 - Theory of Computation 12

Proof by contradiction: assume 𝑀 is regular. Then there is a pumping length π‘ž.

slide-13
SLIDE 13

Pumping Lemma as a game

2/3/2020 CS332 - Theory of Computation 13

  • 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

slide-14
SLIDE 14

Example: Palindromes

2/3/2020 CS332 - Theory of Computation 14

Claim: 𝑀 = π‘₯π‘₯𝑆 π‘₯ ∈ 0,1 βˆ—} is not regular Proof: Assume 𝑀 is regular with pumping length π‘ž

  • 1. Find π‘₯ ∈ 𝑀 with π‘₯ > π‘ž
  • 2. Show that π‘₯ cannot be pumped

Intuitively

slide-15
SLIDE 15

Example: Palindromes

2/3/2020 CS332 - Theory of Computation 15

Claim: 𝑀 = π‘₯π‘₯𝑆 π‘₯ ∈ 0,1 βˆ—} is not regular Proof: Assume 𝑀 is regular with pumping length π‘ž

  • 1. Find π‘₯ ∈ 𝑀 with π‘₯ > π‘ž
  • 2. Show that π‘₯ cannot be pumped

Formally If π‘₯ = 𝑦𝑧𝑨 with |𝑦𝑧| ≀ π‘ž, then…

slide-16
SLIDE 16

Now you try!

2/3/2020 CS332 - Theory of Computation 16

Claim: 𝑀 = 0𝑗1π‘˜ 𝑗 > π‘˜ β‰₯ 0} is not regular Proof: Assume 𝑀 is regular with pumping length π‘ž

  • 1. Find π‘₯ ∈ 𝑀 with π‘₯ > π‘ž
  • 2. Show that π‘₯ cannot be pumped

Intuitively

slide-17
SLIDE 17

Now you try!

2/3/2020 CS332 - Theory of Computation 17

Claim: 𝑀 = 0𝑗1π‘˜ 𝑗 > π‘˜ β‰₯ 0} is not regular Proof: Assume 𝑀 is regular with pumping length π‘ž

  • 1. Find π‘₯ ∈ 𝑀 with π‘₯ > π‘ž
  • 2. Show that π‘₯ cannot be pumped

Formally If π‘₯ = 𝑦𝑧𝑨 with |𝑦𝑧| ≀ π‘ž, then…

slide-18
SLIDE 18

Choosing wisely

2/3/2020 CS332 - Theory of Computation 18

Claim: 𝐢𝐡𝑀𝐡𝑂𝐷𝐹𝐸 = π‘₯ π‘₯ has an equal # of 0s and 1s} is not regular Proof: Assume 𝑀 is regular with pumping length π‘ž

  • 1. Find π‘₯ ∈ 𝑀 with π‘₯ > π‘ž
  • 2. Show that π‘₯ cannot be pumped

Formally If π‘₯ = 𝑦𝑧𝑨 with |𝑦𝑧| ≀ π‘ž, then…

slide-19
SLIDE 19

Reusing a Proof

2/3/2020 CS332 - Theory of Computation 19

Pumping a language can be lots of work… Let’s try to reuse that work!

0π‘œ1π‘œ π‘œ β‰₯ 0} = 𝐢𝐡𝑀𝐡𝑂𝐷𝐹𝐸 ∩ π‘₯ all 0s in π‘₯ appear before all 1s}

How else might we show that 𝐢𝐡𝑀𝐡𝑂𝐷𝐹𝐸 is regular?

slide-20
SLIDE 20

Using Closure Properties

2/3/2020 CS332 - Theory of Computation 20

𝐢 𝐷 𝐡 ∩ = (Not regular) If 𝐡 is not regular, we can show a related language 𝐢 is not regular any of {∘, βˆͺ, ∩} or, for one language, {Β¬, R, *} By contradiction: If 𝐢 is regular, then 𝐢 ∩ 𝐷 (= 𝐡) is regular. (regular) But 𝐡 is not regular so neither is 𝐢!

slide-21
SLIDE 21

Example

2/3/2020 CS332 - Theory of Computation 21

Prove 𝐢 = {0𝑗1π‘˜|𝑗 β‰  π‘˜} is not regular using nonregular language 𝐡 = 0π‘œ1π‘œ π‘œ β‰₯ 0 and regular language 𝐷 = π‘₯ all 0s in π‘₯ appear before all 1s}