• Keine Ergebnisse gefunden

Theory of Computer Science B6. Regular Languages: Pumping Lemma Gabriele R¨oger

N/A
N/A
Protected

Academic year: 2022

Aktie "Theory of Computer Science B6. Regular Languages: Pumping Lemma Gabriele R¨oger"

Copied!
15
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Theory of Computer Science

B6. Regular Languages: Pumping Lemma

Gabriele R¨oger

University of Basel

March 24, 2021

(2)

Theory of Computer Science

March 24, 2021 — B6. Regular Languages: Pumping Lemma

B6.1 Pumping Lemma

Gabriele R¨oger (University of Basel) Theory of Computer Science March 24, 2021 2 / 15

(3)

B6.1 Pumping Lemma

(4)

Pumping Lemma: Motivation

You can show that a language is regular by specifying

an appropriate grammar, finite automaton, or regular expression.

How can you you show that a language is notregular?

I Direct proof that no regular grammar exists that generates the language

difficult in general

I Pumping lemma: use a necessary property that holds for all regular languages.

Picture courtesy of imagerymajestic / FreeDigitalPhotos.net Gabriele R¨oger (University of Basel) Theory of Computer Science March 24, 2021 4 / 15

(5)

Pumping Lemma

Theorem (Pumping Lemma)

If L is a regular language then there is a number p∈N

(apumping number for L) such that all words x ∈L with|x| ≥p can be split into x =uvw with the following properties:

1 |v| ≥1,

2 |uv| ≤p, and

3 uviw ∈L for all i = 0,1,2, . . .. Question: what ifLis finite?

(6)

Pumping Lemma: Proof

Theorem (Pumping Lemma)

If L is a regular language then there is a number p∈N

(apumping number for L) such that all words x ∈L with|x| ≥p can be split into x =uvw with the following properties:

1 |v| ≥1,

2 |uv| ≤p, and

3 uviw ∈L for all i = 0,1,2, . . .. Proof.

For regularLthere exists a DFAM =hQ,Σ, δ,q0,Eiwith L(M) =L. We show thatp =|Q|has the desired properties.

Consider an arbitraryx ∈ L(M) with length|x| ≥ |Q|. Including the start state,M visits |x|+ 1 states while readingx. Because of

|x| ≥ |Q|at least one state has to be visited twice. . . .

Gabriele R¨oger (University of Basel) Theory of Computer Science March 24, 2021 6 / 15

(7)

Pumping Lemma: Proof

Theorem (Pumping Lemma)

If L is a regular language then there is a number p∈N

(apumping number for L) such that all words x ∈L with|x| ≥p can be split into x =uvw with the following properties:

1 |v| ≥1,

2 |uv| ≤p, and

3 uviw ∈L for all i = 0,1,2, . . .. Proof (continued).

Choose a splitx =uvw so M is in the same state after readingu and after readinguv. Obviously, we can choose the split in a way that|v| ≥1 and |uv| ≤ |Q|are satisfied. . . .

(8)

Pumping Lemma: Proof

Theorem (Pumping Lemma)

If L is a regular language then there is a number p∈N

(apumping number for L) such that all words x ∈L with|x| ≥p can be split into x =uvw with the following properties:

1 |v| ≥1,

2 |uv| ≤p, and

3 uviw ∈L for all i = 0,1,2, . . .. Proof (continued).

The wordv corresponds to a loop in the DFA after readingu and can thus be repeated arbitrarily often. Every subsequent

continuation withw ends in the same end state as reading x.

Thereforeuviw ∈ L(M) =L is satisfied for alli = 0,1,2, . . ..

Gabriele R¨oger (University of Basel) Theory of Computer Science March 24, 2021 8 / 15

(9)

Pumping Lemma: Application

Using the pumping lemma (PL):

Proof of Nonregularity

I IfL is regular,thenthe pumping lemma holds for L.

I By contraposition: if the PL doesnothold for L, then Lcannot be regular.

I That is: if there is no p ∈Nwith the properties of the PL, then Lcannot be regular.

(10)

Pumping Lemma: Caveat

Caveat:

The pumping lemma is anecessary conditionfor a language to be regular, but not asufficient one.

there are languages that satisfy the pumping lemma conditions but are notregular

for such languages, other methods are needed to show that they are not regular (e.g., the Myhill-Nerode theorem)

Gabriele R¨oger (University of Basel) Theory of Computer Science March 24, 2021 10 / 15

(11)

Pumping Lemma: Example

Example

The languageL={anbn|n∈N}is not regular.

Proof.

AssumeLis regular. Then let p be a pumping number forL.

The wordx=apbp is inL and has length ≥p.

Letx =uvw be a split with the properties of the PL.

Then the wordx0 =uv2w is also inL. Since|uv| ≤p,uv consists only of symbolsaand x0=a|u|a2|v|ap−|uv|bp=ap+|v|bp.

Since|v| ≥1 it follows thatp+|v| 6=p and thus x0 ∈/L.

This is a contradiction to the PL. L is not regular.

(12)

Pumping Lemma: Another Example I

Example

The languageL={abnacn+2|n∈N} is not regular.

Proof.

AssumeLis regular. Then let p be a pumping number forL.

The wordx=abpacp+2 is in Land has length ≥p.

Letx =uvw be a split with the properties of the PL.

From|uv| ≤p and|v| ≥1 we know that uv consists of onea followed by at mostp−1 bs.

We distinguish two cases,|u|= 0 and |u|>0. . . .

Gabriele R¨oger (University of Basel) Theory of Computer Science March 24, 2021 12 / 15

(13)

Pumping Lemma: Another Example II

Example

The languageL={abnacn+2|n∈N} is not regular.

Proof (continued).

If|u|= 0, then wordv starts with an a.

Hence,uv0w =bp−|v|+1acp+2 does not start with symbol a and is therefore not inL. This is a contradiction to the PL.

If|u|>0, then wordv consists only of bs.

Consideruv0w =abp−|v|acp+2. As |v| ≥1, this word does not contain two morecs than bs and is therefore not in language L.

This is a contradiction to the PL.

We have in all cases a contradiction to the PL.

(14)

Pumping Lemma: Exercise

This was an exam question in 2020:

Use the pumping lemma to prove that L={ambn|m≥0,n <m} is not regular.

Gabriele R¨oger (University of Basel) Theory of Computer Science March 24, 2021 14 / 15

(15)

Summary

I The pumping lemmacan be used to show that a language isnot regular.

Referenzen

ÄHNLICHE DOKUMENTE

GNFAs are like NFAs but the transition labels can be arbitrary regular expressions over the input alphabet. q 0

I DFAs, NFAs and regular grammars can all describe exactly the regular languages.. I Are there other concepts with the

Pumping lemma: use a necessary property that holds for all regular languages.. Picture courtesy of imagerymajestic

I If you read a 1 at the first tape position, move every non-blank symbol on the tape one position to the right, write a 1 in the first tape position and accept...

for 2.: identical to (1), only that M B only recognizes B and therefore the simulation does not necessarily terminate if y 6∈ B. Since y 6∈ B iff x 6∈ A, the procedure still

for 2.: identical to (1), only that M B only recognizes B and therefore the simulation does not necessarily terminate if y 6∈ B. Since y 6∈ B iff x 6∈ A, the procedure still

I Instead, we prove a much more general result, Rice’s theorem, which shows that a very large class of different problems are undecidable.. I Rice’s theorem can be summarized

An oracle machine is like a Turing machine that has access to an oracle which can solve some decision problem in constant timeE. Example