Proving Non-Regularity of Languages through Closure Properties in CS 273 - Prof. Sariel Ha, Study notes of Computer Science

This document from cs 273 lecture 9 discusses how to prove that certain languages are not regular using closure properties. A motivating example of the language l = anbn and its non-regularity proof, as well as an explanation of the pumping lemma and its contrapositive. The document also covers examples of non-regular languages and their proofs using closure properties.

Typology: Study notes

Pre 2010

Uploaded on 03/16/2009

koofers-user-8p9
koofers-user-8p9 🇺🇸

9 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 273, Lecture 9
Proving non-regularity
12 February 2008
Reminder: Exam Tuesday 19 Feb, 7-9 pm,
100 MSEB (Material Science and Engineering
Building, 1304 W. Green St.). Please check for
conflicts NOW. If you have one, send a note
to Margaret Fleck explaining the nature of the
conflict and including your schedule.
In this lecture, we will see how to prove that a language is not regular. This material is
taken from Sipser section 1.4 and from the “closure properties” handout posted for lecture
6.
We will see two methods for showing that a language is not regular. The “pumping
lemma” shows that certain key “seed” languages are not regular. From these seed languages,
we can show that many similar languages are also not regular, using closure properties.
1 Motivating example
Consider the language L=nanbn
n0o. Intuitively, Lcan not be regular, because we
have to remember how many a’s we have seen before reading the b’s, and this can not be
done with a finite number of states.
Claim 1.1 The language L=nanbn
n0ois not regular.
Proof: Suppose that Lwere regular. Then Lis accepted by some DFA M= (Q, Σ, δ, q0, F ).
Suppose that Mhas pstates.
Consider the string apbp. It is accepted using a sequence of states s0s1. . . s2p. Right after
we read the last a, the machine is in state sp.
In the sub-sequence s0s1. . . sp, there are p+ 1 states. Since Lhas only pdistinct states,
this means that two states in the sequence are the same (by the pigeonhole principle). Let
us call the pair of repeated states qiand qj,i < j. This means that the path through M’s
state diagram looks like, where ap=xyz1.
1
pf3
pf4
pf5

Partial preview of the text

Download Proving Non-Regularity of Languages through Closure Properties in CS 273 - Prof. Sariel Ha and more Study notes Computer Science in PDF only on Docsity!

CS 273, Lecture 9

Proving non-regularity

12 February 2008

Reminder: Exam Tuesday 19 Feb, 7-9 pm, 100 MSEB (Material Science and Engineering Building, 1304 W. Green St.). Please check for conflicts NOW. If you have one, send a note to Margaret Fleck explaining the nature of the conflict and including your schedule.

In this lecture, we will see how to prove that a language is not regular. This material is taken from Sipser section 1.4 and from the “closure properties” handout posted for lecture

We will see two methods for showing that a language is not regular. The “pumping lemma” shows that certain key “seed” languages are not regular. From these seed languages, we can show that many similar languages are also not regular, using closure properties.

1 Motivating example

Consider the language L =

anbn

∣ n^ ≥^0

. Intuitively, L can not be regular, because we

have to remember how many a’s we have seen before reading the b’s, and this can not be done with a finite number of states.

Claim 1.1 The language L =

anbn

∣ n ≥ 0

is not regular.

Proof: Suppose that L were regular. Then L is accepted by some DFA M = (Q, Σ, δ, q 0 , F ). Suppose that M has p states. Consider the string apbp. It is accepted using a sequence of states s 0 s 1... s 2 p. Right after we read the last a, the machine is in state sp. In the sub-sequence s 0 s 1... sp, there are p + 1 states. Since L has only p distinct states, this means that two states in the sequence are the same (by the pigeonhole principle). Let us call the pair of repeated states qi and qj , i < j. This means that the path through M’s state diagram looks like, where ap^ = xyz 1.

But this DFA will accept all strings of the form xypz 1 bp. That is, if |y| = m, it accepts all strings of length ap−m+jm, for any j ≥ 0. For any value of j other than 1, such strings are not in L. So our DFA M accepts some strings that are not in L. This is a contradiction, because L was supposed to accept L. Therefore, we must have been wrong in our assumption that L was regular.

2 The Pumping Lemma

The pumping lemma generalizes the above argument into a standard template, which we can prove once and then quickly apply to many languages.

Theorem 2.1 (Pumping Lemma.) Let L be a regular language. Then there exists an integer p (the “pumping length”) such that for any string w ∈ L with |w| ≥ p, w can be written as xyz with the following properties:

  • |xy| ≤ p.
  • |y| ≥ 1 (i.e. y is not the empty string).
  • xykz ∈ L for every k ≥ 0.

Proof: The proof is written out in full detail in Sipser, here we just outline it. Let M be a DFA accepting L, and let p be the number of states of M. Let w = c 1 c 2... cn be a string of length n ≥ p, and let the accepting state sequence (i.e., trace) for w be s 0 s 1... sn. There must be a repeat within the sequence from s 0 to sp, since M has only p states, and as such, the situation looks like the following.

So if we set z = z 1 z 2 , we now have x, y, and z satisfying the conditions of the lemma.

  • |xy| ≤ p because repeat is within first p + 1 states
  • |y| ≥ 1 because i and j are distinct
  • xykz ∈ L for every k ≥ 0 because a loop in the state diagram can be repeated as many or as few times as you want.

Which is equivalent to

∀p ∃w ∈ L |w| ≥ p and

∀x, y, z

w = xyz, |xy| ≤ p, |y| ≥ 1 ,

=⇒ ∃i xyiz /∈ L.

 (^) =⇒ L is not regular.

The translation into words is the contrapositive of the Pumping Lemma (stated in The- orem 3.1 below).

3.2 The contrapositive of the Pumping Lemma

Theorem 3.1 (Pumping Lemma restated.) Consider a language L. If for any integer p ≥ 0 there exists a word w ∈ L, such that |w| ≥ p, and for any breakup of w into three strings x, y, z, such that:

  • w = xyz,
  • |xy| ≤ p,
  • |y| ≥ 1 ,

implies that there exists an i such that xyiz /∈ L, then the language L is not regular.

3.3 Proving that a language is not regular

Let us assume that we want to show that a language L is not regular. Such a proof is done by contradiction. To prove L is not regular, we assume it is regular. This gives us a specific (but unknown) pumping length p. We then show that L satisfies the rest of the contrapositive version of the pumping lemma, so it can not be regular. So the proof outline looks like:

  • Suppose L is regular. Let p be its pumping length.
  • Consider w = [formula for a specific class of strings]
  • By the Pumping Lemma, we know there exist x, y, z such that w = xyz, |xy| ≤ p, and |y| ≥ 1.
  • Consider i = [some specific value, almost always 0 or 2]
  • xyiz is not in L. [explain why it can’t be]

Notice that our adversary picks p. We get to pick w whose length depends on p. But then our adversary gets to pick the specific division of w into x, y, and z.

4 Examples

4.1 The language L = anbn^ is not regular

Claim 4.1 The language L = anbn^ is not regular.

Proof: For any p ≥ 0, consider the word w = apbp, and consider any breakup of w into three parts, such that w = xyz |y| ≥ 1, and |xy| ≤ p. Clearly, xy is a prefix of w made out of only as. As such, the word xyyz has more as in it than bs, and as such, it is not in L. But then, by the Pumping Lemma (Theorem 3.1), L is not regular.

4.2 The language {ww} is not regular

Claim 4.2 The language L =

ww

∣ w^ ∈^ Σ∗

is not regular.

Proof: For any p ≥ 0, consider the word w = 0 p 10 p 1 , and consider any breakup of w into three parts, such that w = xyz |y| ≥ 1, and |xy| ≤ p. Clearly, xy is a prefix of w made out of only 0 s. As such, the word xyyz has more 0 s in its first part than the second part. As such, xyyz is not in L. But then, by the Pumping Lemma (Theorem 3.1), L is not regular.

Consider the word w used in the above claim:

  • It is concrete, made of specific characters, no variables left in it.
  • These strings are a subset of L, chosen to exemplify what is not regular about L.
  • Its length depends on p.
  • The 1 in the middle serves as a barrier to separate the two groups of 0 ’s. (Think about why the proof would fail if it was not there.)
  • The 1 at the end of w does not matter to the proof, but we nee it so that w ∈ L.

5 Proofs using closure properties

If we know certain seed languages are not regular, then we can use closure properties to show other languages are not regular. We remind the reader that homomorphism is a mapping h : Σ 1 → Σ∗ 2 (namely, every letter of Σ 1 is mapped to a string over Σ 2 ). We showed that if a language L over Σ 1 is regular, then the language h(L) is regular. We referred to this property as closure of regular languages under homomorphism.

Claim 5.1 The language L′^ = { 0 n 1 n^ | n ≥ 0 } is not regular.

7 A note on finite languages

A language L is finite if has a bounded number of words in it. Clearly, a finite language is regular (since you can always write a finite regular expression that matches all the words in the language). It is natural to ask why we can not apply the pumping lemma Theorem 2.1 to L? The reason is because we can always choose the threshold p to be larger than the length of the longest word in L. Now, there is no word in L with length larger than p in L. As such, the claim of the Pumping Lemma holds trivially for a finite language, but no word can be pumped - and as such L stays finite. So the pumping lemma makes sense even for finite languages!