Nonregular Languages

6
Nonregular Languages Nonregular Languages Section 1.4 CSC 4170 heory of Computatio

description

CSC 4170 Theory of Computation. Nonregular Languages. Section 1.4. 1.4.a. Pumping Lemma (preliminary version): Suppose L is the language recognized by a DFA with p states, and w is a string in L of length at least p. Then w may be divided into three parts, w = x y z , so that: - PowerPoint PPT Presentation

Transcript of Nonregular Languages

Page 1: Nonregular Languages

Nonregular LanguagesNonregular Languages

Section 1.4

CSC 4170

Theory of Computation

Page 2: Nonregular Languages

Pumping Lemma 1.4.a

Pumping Lemma (preliminary version): Suppose L is the language recognized by a DFA with p states, and w is a string in L of length at least p. Then w may be divided into three parts, w = xyz, so that:

1. For each i0, xyiz L; 2. |y| > 0; 3. |xy| p.

Example: Suppose a DFA with 6 states accepts Villanova. Then Villanova = xyz, e.g., with x = Vi, y = lla, z = nova, V i l l a n o v a so that the DFA also accepts Vinova (xy0z)

Villanova (xy1z)Villallanova (xy2z)Villallallanova (xy3z)Villallallallanova (xy4z) …

We also have: |lla| > 0, |Villa| 6.

Page 3: Nonregular Languages

Proof idea 1.4.b

V

i l

l

n

o

v

V i l l a n o v a

a

Page 4: Nonregular Languages

An equivalent formulation of the pumping lemma 1.4.c

Pumping Lemma (Theorem 1.70): Suppose L is a regular language. Then there is a number p, called the pumping length, such that any string w from L of length at least p can be divided into three parts, w = xyz, so that:

1. For each i0, xyiz L; 2. |y| > 0; 3. |xy| p.

Proof: Suppose L is a regular language. Then we know that theremust be a DFA recognizing L. Take the pumping length p to bethe number of states of this DFA. The rest of the theorem is then a repetition of the previous formulation of the pumping lemma.

Page 5: Nonregular Languages

Using the pumping lemma for proving nonregularity: Example 1

1.4.d

Example 1.73: Show the nonregularity of B = {0n1n | n0}

Proof by contradiction: Assume B is regular. Let then p be its pumping length.

Select wB with |w| p. By the pumping lemma, w=xyz and y can be pumped, so that

we must also have xyyzB.

Case 1: y only has 0s. But then xyyz has more 0s than 1s and B.

Case 2: y only has 1s. But then xyyz has more 1s than 0s and B.

Case 3: y has both 0s and 1s. But then xyyz has a 1 followed by a 0and B.

The assumption that B is regular took us to a contradiction. Hence the assumption was wrong, i.e. B is not regular.

Page 6: Nonregular Languages

Using the pumping lemma for proving nonregularity: Example 2

1.4.e

Example 1.75: Show the nonregularity of F = { ww | w {0,1}* }

Proof by contradiction: Assume F is regular. Let then p be its pumping length.

Observe that 0p10p1F.By the pumping lemma, 0p10p1 =xyz and y can be pumped.

By Condition 3, |xy|p. Therefore, y is entirely in the first 0p.Pumping y would produce a string that has only 0s is the

first half, and two 1s in the second half. Obviously this string cannot be in F, which contradicts with the pumping lemma.

The assumption that F is regular took us to a contradiction. Hence the assumption was wrong, i.e. F is not regular.