CSE 105 THEORY OF COMPUTATION Fall 2016 - - PowerPoint PPT Presentation

cse 105
SMART_READER_LITE
LIVE PREVIEW

CSE 105 THEORY OF COMPUTATION Fall 2016 - - PowerPoint PPT Presentation

CSE 105 THEORY OF COMPUTATION Fall 2016 http://cseweb.ucsd.edu/classes/fa16/cse105-abc/ T oday's learning goals Sipser Ch 1.11.4 Are there non-regular languages? Pumping Lemma for Regular Languages Identify some nonregular sets


slide-1
SLIDE 1

CSE 105

THEORY OF COMPUTATION

Fall 2016 http://cseweb.ucsd.edu/classes/fa16/cse105-abc/

slide-2
SLIDE 2

T

  • day's learning goals Sipser Ch 1.1–1.4
  • Are there non-regular languages?
  • Pumping Lemma for Regular Languages
  • Identify some nonregular sets
slide-3
SLIDE 3

DFAs and Counting

  • Which of the following languages is regular?

L1 = {0n1n | n < 10}

L2 = {0n1n | n > 10} A) L1 B) L2 C) Both L1 and L2 D) Neither L1 nor L2 E) I don’t know

slide-4
SLIDE 4

DFAs and Counting

  • Which of the following languages is regular?

L1 = {0n1n | n < 10}

L2 = {0n1n | n > 10}

  • Correct answer is (A): Only L1
  • Why is L1 regular?

Easy: because it is a fjnite language (of size 10)

  • But why is L2 not regular? Defjnitions look so

similar!

slide-5
SLIDE 5

A DFA for L1

  • Give a DFA for

L1 = {0n1n | n < 10}

  • How many states do you need?

A) 10 (or fewer) B) 20 (or fewer) C) 100 (or fewer) D) Exaclty 2048 E) I don’t know

slide-6
SLIDE 6

Let’s solve it in JFLAP (n<5)

slide-7
SLIDE 7

One more question

  • Which of the following languages are regular?

L1 = {0n1n | n >= 0 }

L2 = {0n1n | (5<n) and (n<10)}

L3 = Complement of L2

L4 = {0n1n | not(5<n) or not(n<10)} A) All four B) L2, L3 C) L2, L3, L4 D) None E) I don’t know

slide-8
SLIDE 8

Intuition

  • DFAs can count up to 10
  • DFAs can count up to any fjxed bounded number

k, given enough states.

  • But they cannot count indefjnitely:

Given a long enough string 0000000000...0, they will loose count when they “run out” of states

  • How can we formalize this into a proof?
slide-9
SLIDE 9

Bounds on DFA

  • in DFA, memory = states
  • Automata can only "remember"…
  • …fjnitely far in the past
  • …fjnitely much information
  • If a computation path visits the same state more than
  • nce, the machine can't tell the difgerence between

the fjrst time and future times it visited that state.

slide-10
SLIDE 10

A non-regular language

  • Proof that L={0n1n | n≥0} is not regular
  • Proof: assume L is regular (for contradiction)

– L=L(M) is the language of a DFA = (Q,…) with

a fjnite number of states p=|Q|

– Consider computation on input 0p1p – Computation has length 2p+1>|Q| – Must visit the same state twice – This gives many other accepting computations

slide-11
SLIDE 11

Proof details

  • Assume L(M)={0n1n | n≥0}
  • M has p=|Q| states and accepts 0p1p
  • M must visit the same state twice while reading 0p
  • Break the computation/input in three parts

Accepts not only 000000111111

But also 00111111, 000000000111111

00(000)k01111111

  • Contradicts the defjnition of L(M)

00 01111 11 000

slide-12
SLIDE 12

Pumping Lemma: What and Why

  • Pumping lemma abstracts this pattern of

reasoning to prove that a language is not regular

  • Pumping Lemma: asserts a property satisfjed by

all regular languages

  • Using the pumping lemma

Assume (for contradition) that L is regular

Therefore it satisfjes pumping property

Derive a contradiction.

slide-13
SLIDE 13

Pumping Lemma: informal

  • All suffjciently long strings accepted by

a DFA can be pumped

slide-14
SLIDE 14

Pumping

  • Focus on computation path through DFA

x y z Idea: if one long string xyz is accepted, then many other strings have to be accepted too: xz, xyz, xyyz, xyyyz, ...

slide-15
SLIDE 15

Pumping Lemma

Sipser p. 78 Theorem 1.70

slide-16
SLIDE 16

Pumping Lemma

Sipser p. 78 Theorem 1.70

# states in DFA recognizing A # states in DFA recognizing A T ransition labels along loop Transition labels along loop

slide-17
SLIDE 17

Question

  • Which of the following sentences best describes

the pumping lemma:

A) It is a property of every regular language B) It is a property of every non-regular language C) It is a closure property of regular languages D) It is a closure property of non-regular languages E) I don’t know

slide-18
SLIDE 18

Answer

  • The pumping lemma asserts a property satisfjed

by every regular language

  • But we use it to prove nonregular languages

Assume L is regular (for contradiction)

Apply pumping property

Get a contradiction

Therefore L is not regular

slide-19
SLIDE 19

Using the Pumping Lemma

Claim: The set L = {0n1n | n ≥ 0} is not regular.

slide-20
SLIDE 20

Using the Pumping Lemma

Claim: The set L = {0n1n | n ≥ 0} is not regular. Proof: Assume, towards a contradiction, that L is regular.

Pumping Lemma gives property of all regular sets. Can we get a contradiction by assuming that the Pumping Lemma applies to this set? Pumping Lemma gives property of all regular sets. Can we get a contradiction by assuming that the Pumping Lemma applies to this set?

slide-21
SLIDE 21

Using the Pumping Lemma

Claim: The set L = {0n1n | n ≥ 0} is not regular. Proof: Assume, towards a contradiction, that L is regular. Therefore, the Pumping Lemma applies to L and gives us some number p, the pumping length of L. In particular, this means that every string in L that is

  • f length p or more can be "pumped".

…Idea: can we fjnd some long string in L that can't be?

slide-22
SLIDE 22

Using the Pumping Lemma

Claim: The set L = {0n1n | n ≥ 0} is not regular. Proof: …In particular, this means that every string in L that is of length p or more can be "pumped". Goal: pick a string s in L of length greater than or equal to p such that any division of s as s =xyz with |y|>0 and |xy|≤ p gives some value i≥0 with xyiz not in L So we have a contradiction, and L is not regular.

slide-23
SLIDE 23

Using the Pumping Lemma

Claim: The set L = {0n1n | n ≥ 0} is not regular. Proof: … Goal: pick a string s in L of length greater than or equal to p such that any division of s as s =xyz with |y|>0 and |xy|≤ p gives some value i≥0 with xyiz not in L Choose s = 0p1p. Consider any s=xyz with |y|>0, |xy|≤p.

slide-24
SLIDE 24

Using the Pumping Lemma

Claim: The set L = {0n1n | n ≥ 0} is not regular. Proof: … Goal: pick a string s in L of length greater than or equal to p such that any division of s as s =xyz with |y|>0 and |xy|≤ p gives some value i≥0 with xyiz not in L Choose s = 0p1p. Consider any s = xyz with |y|>0, |xy|≤p. Since |xy|≤p, x=0m , y = 0n , z = 0r1p with m+n+r =p, j>0.

slide-25
SLIDE 25

Using the Pumping Lemma

Claim: The set L = {0n1n | n ≥ 0} is not regular. Proof: … Goal: pick a string s in L of length greater than or equal to p such that any division of s as s =xyz with |y|>0 and |xy|≤ p gives some value i≥0 with xyiz not in L Choose s = 0p1p. Consider any s = xyz with |y|>0, |xy|≤p. Since |xy|≤p, x=0m , y = 0n , z = 0r1p with m+n+r =p, j>0. Picking i=0: xyiz = xz = 0m0r1p = 0m+r1p , not in L!

slide-26
SLIDE 26

Using the Pumping Lemma

Claim: The set L = {0n1n | n ≥ 0} is not regular. Proof: … Goal: pick a string s in L of length greater than or equal to p such that any division of s as s =xyz with |y|>0 and |xy|≤ p gives some value i≥0 with xyiz not in L Choose s = 0p1p. Consider any s = xyz with |y|>0, |xy|≤p. Since |xy|≤p, x=0m , y = 0n , z = 0r1p with m+n+r =p, j>0. Picking i=0: xyiz = xz = 0m0r1p = 0m+r1p , not in L! This is a contradiction with the Pumping Lemma applied to L, so L must not be regular.

slide-27
SLIDE 27

Key ingredients in proof

Claim: Language L is not regular. Proof: Assume, towards a contradiction, that L is regular. By the Pumping Lemma, there is a pumping length p for L. Consider the string s = …… You must pick s carefully: we want |s|≥p and s in L.

*Confjrm these facts as part of your proof* Now we will prove a contradiction with the statement "s can be pumped"

Consider an arbitrary choice of x,y,z such that s = xyz, |y|>0, | xy|≤p. This means that...What properties are guaranteed about x,y,z? Consider i=… In this case, xyiz = …, which is not in L, a contradiction with the Pumping Lemma applying to L and so L is not regular.

slide-28
SLIDE 28

Using the Pumping Lemma

Claim: The set L = {0n1n | n ≥ 0} is not regular. In proof, we used s = 0p1p and i=0 Claim: The set {anbman | m,n≥ 0} is not regular. In proof, we used s = apbap and i=3

slide-29
SLIDE 29

And another

Claim: The set {w wR | w is a string over {0,1} } is not regular. Proof: …Consider the string s = …… You must pick s carefully: we want |s|≥p and s in L. Now we will

prove a contradiction with the statement "s can be pumped" Consider i=…

Which s and i let us complete the proof?

  • A. s = 0p0p, i=2 B. s = 0110, i=0 C. s = 0p110p, i=1 D. s = 1p001p,

i=3

  • E. I don't know