Pumping with Al and Izzy Richard Beigel CIS Temple University.

Post on 18-Jan-2016

218 views 0 download

Transcript of Pumping with Al and Izzy Richard Beigel CIS Temple University.

Pumping with Al and

IzzyRichard Beigel

CIS

Temple University

Fundamental question: Which languages are regular and which are not?

• To prove L is regular– give a regular expression that generates L (definition)

– construct an NFA that accepts L

– use closure properties

• To prove L is not regular, use– Myhill-Nerode Theorem ( many prefix-inequivalent

strings)

– Pumping Theorem

– closure properties

The Pumping Theorem for Regular Languages

If L is regular thenN

z such that z L and |z| N

u,v,w such that z = uvw , |uv| N, and |v| > 0

i [uviw L]

All those quantifiers make my brain hurt!

N

z such that z L and |z| N

u,v,w such that z=uvw , |uv| N, and |v| > 0

i [uviw L]

Al and Izzy to the Rescue!

For All

There Izzy

2-Player Games• Players alternate turns• A record is kept of all plays• A strategy

for a player maps a record to his next play• The final record is evaluated to see who won

For each predicate there is a corresponding 2-player game

• As the formula is read left-to-right

– Izzy picks values under each existential () quantifier

– Al picks values under each universal () quantifier

• Izzy wins iff the base predicate is true for the selected values

Example: ( m) ( n > 0)[m < n] The Game The Predicate

1 Izzy picks m2 Al picks n such that

n > 0

Izzy wins iff m < n

m

n such that n > 0

m < n

Izzy has a winning strategy iff the predicate is true.Al has a winning strategy iff the predicate is false.

Example: ( m) ( n > 0)[m > n] The Game The Predicate

1 Izzy picks m2 Al picks n such that

n > 0

Izzy wins iff m > n

m

n such that n > 0

m > n

Izzy has a winning strategy iff the predicate is true.Al has a winning strategy iff the predicate is false.

Izzy has a winning strategy iff the predicate is true.Al has a winning strategy iff the predicate is false.

• Proof by induction on the number of quantifiers in P

• Inductive hypothesis (I.H.): If P is a predicate with n quantifiers and n variables, then P is true iff Izzy has a winning strategy in the corresponding game, and P is false iff Al has a winning strategy.

• Base case: n = 0. Then P is a Boolean constant, and Izzy wins iff P = true.

Izzy has a winning strategy iff the predicate is true.Al has a winning strategy iff the predicate is false.

• Inductive case: P = (Q x) P(x, x2,…, xn+1) where P has n quantifiers.

• Case 1: Q = . – If P is true, there is a value c such that P(c, x2,…, xn+1)

is true. Izzy picks x = c and then continues with his winning strategy (by I.H.) for P(c, x2,…, xn+1).

– If P is false, every value c makes P(c, x2,…, xn+1) false. Al just uses his strategy (by I.H.) for P(c, x2,…, xn+1)

Q is a quantifier, I.e., or

Q is a quantifier, I.e., or

Izzy has a winning strategy iff the predicate is true.Al has a winning strategy iff the predicate is false.

• Inductive case: P = (Q x) P(x, x2,…, xn+1) where P has n quantifiers.

• Case 2: Q = . – If P is true, every value c makes P(c, x2,…, xn+1) true.

Izzy just uses his winning strategy (by I.H.) for P(c,x2,…,xn+1).

– If P is false, there is a value c such that P(c, x2,…, xn+1) is false. Al picks x = c and then continues with his strategy (by I.H.) for P(c, x2,…, xn+1)

Al and Izzy Pumping Game Predicate

1 Izzy picks N2 Al picks z such that

z L and |z| N3 Izzy picks u,v,w such

that z = uvw, |uv| N, and |v| > 0

4 Al picks i

Izzy wins iff uviw L

N

z such that z L and |z| N

u,v,w such that z = uvw , |uv| N, and |v| > 0

i

uviw L

A paradigm for proving nonregularity

• If L is regular then the predicate given by the pumping theorem is true.

• If Al has a winning strategy then the predicate given by the pumping theorem is false then L is not regular.

• To prove nonregularity, just give a winning strategy for Al!

A winning strategy for Al proves {an bn : n 0} is not regular

1 Izzy picks N2 Al picks z such that

z L and |z| N3 Izzy picks u,v,w such

that z = uvw, |uv| N, and |v| > 0

4 Al picks i

Izzy wins iff uviw L

Al wins iff uviw L

Let z = aN bN

v = ak where k > 0

Let i = 0

uviw = uw = aNkbNL since k > 0

A winning strategy for Al proves {an : n is prime} is not regular

1 Izzy picks N2 Al picks z such that

z L and |z| N3 Izzy picks u,v,w such

that z = uvw, |uv| N, and |v| > 0

4 Al picks i

Izzy wins iff uviw L

Al wins iff uviw L

Let z = ap where p is prime and p N

v = ak where k > 0

Let i = p + 1

uviw = uvv(i1)w = a(p+

(i1)k) = a(p+pk) = ap(k+1) L since k>0

Summary

• Predicates are equivalent to 2-player games

• You can prove or disprove a predicate by giving a winning strategy

• You can prove a language is nonregular by giving a winning strategy for Al in the pumping game

What else?

2-player games are also useful in– cryptography– security– interactive proofs– zero-knowledge proofs