Lecture 8
Sept 29, 2011
• Regular expressions – examples
• Converting DFA to regular expression. (same works
for NFA to r.e. conversion.)
• Converting R.E. to NFA
• Pumping lemma
Theorem: A language is regular if and only if it is accepted
by a regular expression.
Proof: Show how to convert from regular expression to NFA and viceversa.
Let L be accepted by a regular expression. We prove that it is regular,
i.e., there is a NFA for L.
Cases to consider:
(1) empty-set (2) single symbol {a} (3) {e}
(4) (a) R1 + R2
(b) R1 . R2
(c) R1*
(1), (2) and (3) are easy base cases. For (4), inductively construct NFA’s
for R1 and R2, and from it construct an NFA for R.
Converse is shown as follows:
Given a DFA (or NFA), we remove states one by one until
we have one state left. At this point, we can write down the
regular expression.
The idea is to use generalized NFA, one in which the
transitions are labeled not by a single symbol, but by a
regular expression.
Example of GNFA:
Conversion from DFA to regular expression
Key step: how to remove a state of a GNFA
So far, we have seen how to design DFA, NFA or regular
expressions for various languages.
We also learned how to convert:
• NFA DFA
• DFA regular expression
• Regular expression NFA
But there are many languages for which we can never build
a DFA or an NFA or a regular expression.
Can you think of such a language?
Two fundamental examples
• L = { an bn | n > 0}
This contains strings e, ab, aabb, aaabbb, … etc.
Why is it not possible to create a DFA for L?
• L’ = { w | w is a balanced parentheses string over [, ] }
This includes strings such as [ ], [ ][ ], [ [ ] ], etc.
How can we show that it is impossible to build DFA for these
languages?
Characteristics of Regular Languages
A tool known as pumping lemma is used to show that
certain languages are not regular.
Idea: Because a DFA D has a finite number of states, say
nD, before reading nD + 1 input characters, D must
enter some state q for a second time.
The Pumping Lemma
If L is a regular language, then:
• a value n such that:
• w in L such that |w| > n,
• x,y,z such that w = xyz
where |y| > 0, |xy| < n
• i > 0, xyiz L
Proof: let L = L(D)
Given w = w1 w2 … wk,
let s1s2 … sk+1 be the consecutive states reached
by DFA D on w (where s1= s the start state)
If k>nD, then by the pigeon hole principle, we know
i,j, (i<j), i, j{1 … k+1} such that si = sj
Then x = w1 w2 … wi-1 puts D in state si
and so does xy = w1 w2 … wi-1 wi … wj-1
… and so does xyt = w1 w2 … wi-1 (wi … wj-1)t
Proof … visualization
s1 x = w1 w2 … wi-1
sk+1
accept
si
z = wj … wk
y = wi … wj-1
Proof … continued
z = wj … wk takes D from state si to sk+1, an accept state
So xytz = w1 w2 … wi-1 (wi … wj-1)t wj … wk takes D from
the start state to the same accept state
Crucial use of the Pumping Lemma:
to show that L is not regular!
Using the contrapositive
A implies B
B implies A
the Pumping Lemma in contrapositive form
If n in Z
w such that |w| > n
x,y,z such that w = xyz
and |y|>0 and |xy|<n
i>0 s.t. xyiz is NOT in L
then
L is NOT a regular language
Applications of pumping lemma
Therefore L is not regular.
A technique for showing lower-bound on the number of
states in a DFA
Example: Consider the regular language L = { x | the 5-th symbol from
the right-end of x is 1} over the alphabet S = {0, 1}.
We will show that any DFA for this language requires at least 32 states.
Let w0 = 00000, w1 = 00001, …, w31 = 11111 be the list of all strings of
length 5 over S.
Let M be any DFA accepting L. Let qj = d(s, wj) be the state reached from
the starting state on input wj. We will argue that all qj’s must be distinct.
(The proof will be completed in lecture.)
Note: Problem 4 of HW 4 requires you to use this technique.
© Copyright 2025 Paperzz