95.1k views
5 votes
Use the pumping lemma for regular languages to prove these languages are not regular:

The set of even length bit strings in which the second half contains at least one 1 bit.
(if there are n bits in the string, the first half has n/2 bits, as does the second half.)

User Jlew
by
7.2k points

1 Answer

6 votes

To prove that the language L = {w ∈ {0,1}* : |w| is even and the second half of w contains at least one 1} is not regular, we will use the pumping lemma for regular languages.

Assume for contradiction that L is regular, and let p be the pumping length given by the pumping lemma. Consider the string s = 0^p 1^p, which is in L since it has an even length and the second half contains at least one 1. Since |s| = 2p ≥ p, the pumping lemma guarantees that we can write s as s = xyz, where:

|xy| ≤ p,

|y| > 0, and

xy^kz is in L for all k ≥ 0.

Let x, y, and z be such that s = xyz, where |xy| ≤ p and |y| > 0. Then, y consists entirely of 0s, since any 1 in y would be in the second half of s and we require the second half to contain at least one 1. Thus, we can write y = 0^j for some j > 0.

Consider the string s' = xy^2z. We can write s' as s' = x(y^j)y^{p-j}z, which has the form 0^a 1^b, where a = p+j and b = p-j+1. Since j > 0, we have j ≤ p and so a ≤ 2p. Therefore, s' is in L if and only if b > a/2, i.e., if and only if p-j+1 > (p+j)/2, which simplifies to j < (p+1)/3.

But we know that y = 0^j, so j ≤ p. Therefore, we have (p+1)/3 > j ≥ 1, which means that (p+1)/3 is a positive integer strictly less than p. However, this contradicts the choice of p as the pumping length, since we chose s = 0^p 1^p to have length 2p.

Since our assumption that L is regular led to a contradiction, we can conclude that L is not regular.

User Rafael Borja
by
8.8k points