Download presentation
Presentation is loading. Please wait.
1
Lecture5 Non-regular languages
2004 SDU
2
Are all languages regular?
Answer: No! One argument: # of DFA’s on ? # of languages on ? the latter is larger than the former. 2004 SDU
3
Pumping Lemma First technique to show that specific given languages are not regular. The idea: Each regular language satisfies the pumping lemma, so, if a language does not, then, it is non-regular! 2004 SDU
4
Statement of Pumping Lemma
If A is a regular language, then there is a number p (pumping length) where, if s is any string in A of length at least p, then s must be able to be divided into three pieces, s = xyz, satisfying the following conditions: 1. for each i 0, xyiz A, 2. |y| > 0, and 3. |xy| p. 2004 SDU
5
Describing the pumping lemma (contd.)
Take string with There is a walk with label: w1 w2 wn s1 sn-1 sn s0 2004 SDU
6
Describing the pumping lemma (contd.)
, number of states. If string has length Then, a state is repeated in the walk ...... ...... 2004 SDU
7
Describing the pumping lemma (contd.)
Write w=xyz , here si is the first repeat state, and sl is the second apperance of si y=wi+1…wl sl-1 si+1 wl wi+1 w1 wi w2 ...... ...... wn s0 s1 wl+1 si(sl) sn z=wl+1…wn x=w1…wi 2004 SDU
8
Describing the pumping lemma (contd.)
Observations : |xy| = |s0,…,si,si+1…,sl-1,si| - 1 (p+1)-1=p |y| = |si,…,sl-1,si|-1 2-1=1 y=wi+1…wl sl-1 si+1 wl wi+1 w1 wi w2 ...... s0 s1 si(sl) x=w1…wi 2004 SDU
9
Describing the pumping lemma (contd.)
Observation: the string xz is accepted. w1 ...... wi w2 ...... wn s0 s1 wl+1 sn si(sl) z=wl+1…wn x=w1…wi 2004 SDU
10
Describing the pumping lemma (contd.)
Observation: the string xyyz is accepted. y=wi+1…wl sl-1 si+1 wi+1 wl wn wl+1 w1 w2 ...... wi ...... s0 s1 si(sl) sn z=wl+1…wn x=w1…wi 2004 SDU
11
Proof of pumping lemma Idea: If a string w of length m is accepted by a DFA with p states, and m p, then there is a repeat state (let i be the first one) in the accepting state sequence. s0w1 s1…wisiwi+1si+1…wlsl(=si)wl+1sl+1…wmsm z y x |xy| = |w1,…,wl| = |s0,…,si, si+1, …, si| - 1 (p+1)-1 = p |y| = |wi+1, …,wl | = |si, si+1, …, si| - 1 2-1=1 xz (= w1…wiwl+1…wm): s0, …, si, sl+1, …, sm xyyz( = w1…wiwi+1…wlwi+1…wlwl+1…wm): s0,…, si, si+1, .., sl, si+1, …, sl, sl+1, …,sm 2004 SDU
12
An exmaple 1 1,+ + + s1 s4 s2 1 1 s0 + Let p = 4. Input: 1+1+1 x = “1”
y = “+1” z = “+1” Actually, we can also choose p as 3 even 2, why? Consider input 111, 11, or 1+1. Can they be pumped? What is the minimum pumping length? 2004 SDU
13
Application of Pumping Lemma
Example 1: A = { 0n1n | n 0} is not regular. Proof. By contradiction. Assume, on the contrary, that A is regular. Then the pumping lemma holds for A. Let p be a pumping length. Let w = 0p1p. Then w is in A and is longer than p. Then by pumping Lemma, w can be divided into w=xyz such that For each i 0, xyiz A |y| > 0, and |xy| p. Then x and y are all 0’s. So, xyyz has more 0’s than 1’s and is in A. A contradiction. So, A is not regular. y 2004 SDU
14
Application of Pumping Lemma
Example 2: B={ w | w{0,1}* and has an equal number of 0’s and 1’s} is not regular. Proof. By contradiction. Assume, on the contrary, that B is regular. Then the pumping lemma holds for B. Let p be a pumping length. Let w = 0p1p. Then w is in B and is longer than p. Then by pumping Lemma, w can be divided into w=xyz such that For each i 0, xyiz B |y| > 0, and |xy| p. Then x and y are all 0’s. So, xyyz has more 0’s than 1’s and is in B. A contradiction. So, B is not regular. Another proof. Let B’=B0*1*. If B is regular, then B’=A is regular, a contradiction. 2004 SDU
15
Application of Pumping Lemma
Example 3: C = {ww | w {0,1}*} is not regular. Proof. By contradiction. Assume, on the contrary, that C is regular. Then the pumping lemma holds for C. Let p be a pumping length. Let w = 0p10p1. Then w is in C and is longer than p. Then by pumping Lemma, w can be divided into w=xyz such that For each i 0, xyiz C |y| > 0, and |xy| p. Then x and y are all 0’s. Obviously xyyz cannot be represented as ww. A contradiction to that xyyz C. So, C is not regular. 2004 SDU
16
Application of Pumping Lemma
Example 4: D={1a | a = n2 for some n 0} is not regular. Proof. By contradiction. Assume, on the contrary, that D is regular. Then the pumping lemma holds for D. Let p be a pumping length. Let w = 1b, b=p2. Then w is in D and is longer than p. Then by pumping Lemma, w can be divided into w=xyz such that For each i 0, xyiz D |y| > 0, and |xy| p. Then xyyz=1c, where p2 < c = p2 + |y| p2 + p, then c cannot be expressed as n2 for any n. A contradiction to that xyyz D. So, D is not regular. 2004 SDU
17
Application of Pumping Lemam
Example 5: E={0i1j | i > j} is not regular. Proof. By contradiction. Assume, on the contrary, that E is regular. Then the pumping lemma holds for E. Let p be a pumping length. Let w = 0p1p-1. Then w is in E and is longer than p. Then by pumping Lemma, w can be divided into w=xyz such that For each i 0, xyiz E |y| > 0, and |xy| p. Then both x and y are strings of all 0’s. Then xz = 0x1p-1, where x p-1. A contradiction to that xz E. So, E is not regular. 2004 SDU
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.