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

slide-3
SLIDE 3

Regular?

Construct an NFA for the following languages

2/4/2020 CS332 ‐ Theory of Computation 3

𝑜 𝑜 𝑜 𝑜 𝑜 𝑜

slide-4
SLIDE 4

Proving a language is not regular

Theorem:

𝑜 𝑜

is not regular Proof: (by contradiction) Let be a DFA with states recognizing Consider running

  • n input

𝑙 𝑙

2/4/2020 CS332 ‐ Theory of Computation 4

slide-5
SLIDE 5

Regular or not?

2/4/2020 CS332 ‐ Theory of Computation 5

has equal number of s and s has equal number of s and s

slide-6
SLIDE 6

The Pumping Lemma

A systematic way to prove that a language is not regular

2/4/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/4/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/4/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/4/2020 CS332 ‐ Theory of Computation 9

𝑗 𝑘

||

… Let be a regular language. Let be a “long enough” string in . Then we can write such that

  • for

every

slide-10
SLIDE 10

Pumping Lemma (Formal)

2/4/2020 CS332 ‐ Theory of Computation 10

Let be a regular language. Then there exists a “pumping length” such that 1. 2. 3.

𝑗 

for all For every where , can be split into three parts where: Example: Let all s in appear before all s

slide-11
SLIDE 11

Using the Pumping Lemma

2/4/2020 CS332 ‐ Theory of Computation 11

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

General Strategy for proving is not regular

2/4/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/4/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/4/2020 CS332 ‐ Theory of Computation 14

Claim:

  • ∗ 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/4/2020 CS332 ‐ Theory of Computation 15

Claim:

  • ∗ 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/4/2020 CS332 ‐ Theory of Computation 16

Claim:

  • is not regular

Proof: Assume is regular with pumping length

  • 1. Find

with

  • 2. Show that

cannot be pumped Intuitively