Escolar Documentos
Profissional Documentos
Cultura Documentos
Union
Concatenation
Kleene star
Complement
Intersection
So:
The null language is regular
The language consisting of the empty string,
{}, is regular
For each a in , {a} is regular
If L1 and L2 are regular:
L1 L2 is regular
L1L2 is regular
L1* is regular
Complement
Consider the special case in which L1 is all of
*. Here, L1 L2 is actually L2 (the
complement of L2)
Reversal
Theorem 4.2: The family of regular languages is
closed under reversal.
Proof: If L is a regular language, construct an NFA
with a single final state that accepts it. Now
change the initial vertex into a final vertex, the
final vertex into the initial vertex, and reverse
the direction on all the edges. For every string
w accepted by the original NFA, the modified
version of the NFA accepts wR.
Homomorphism
Definition 4.1: A homomorphism is a
substitution in which a single letter is
replaced with a string. Formally, if and
are alphabets, then a function
h : *
is a homomorphism.
If L is a language on S, then its homomorphic
image is:
h(L) = {h(w) : w L}
Homomorphism
Theorem 4.3: If L is a regular langugae,
then its homomorphic image h(L) is also
regular.
Thus the family of regular languages is
closed under homomorphism.
Right quotient
To form the right quotient of L1 with L2,
L1/L2, take all strings in L1 that have a
suffix belonging to L2 and remove the
suffix.
Example:
L1 = {ab, aab, aaab, aaaab}
L2 = {b}
L1/L2 = {a, aa, aaa, aaaa}
Right quotient
Theorem 4.4: If L1 and L2 are regular
languages, then L1/L2 is also regular.
Thus the family of regular languages is
closed under right quotient with another
regular language.
Proof: By construction see textbook, pp.
106-107.
Pumping Lemma
Theorem 4.8: Let L be a regular language. There exists a
positive integer m such that for any string w L with |w|
m, w may be written as w = xyz, for some x, y, and z
satisfying the following:
|xy| m,
|y| 1,
and xyiz L for every i 0
Pumping Lemma
In other words, every sufficiently long string in L can be
broken down into three parts in such a way that an
arbitrary number of repetitions of the middle part yields
another string in L. We say that the middle string is
pumped, hence the term pumping lemma.
Example
b
q0
q1
x=a
|x| = 1
Sequence of states = q0 q1
n = Number of different states passed through = 2
Example
b
q0
q1
x = bba so |x| = 3
Sequence of states = q0 q0 q1
n=2
Any string where |x| n must have repeated a state
Pumping
If a state is repeated one or more times, it
means that there must be a loop in the
transition diagram.
If there is a loop, then it can be pumped to
produce additional strings that belong to the
language
Example
If ba is in the language, and there are only 2
states in the automaton, then a, bba, bbba,
bbbba, etc. are also in the language.
b
q0
q1
Limits of a FA
Being in state q1 and having just read a 1
doesnt tell you anything about how many 1s
have already been processed. The FA simply
doesnt have the memory needed to retain
this information.
0
q0
q1
Limits of a FA
Moreover, if you have a loop like this in an FA,
the FA must accept any number of 1s in the
loop. There is no way to specify exactly as
many 1s as 0s this FA can accept 000111,
but must also accept 0111, 00001, etc.
0
q0
q1
Limits of an FA
Consequently, we cant build an FA that can tell
whether the number of 0s that it saw at the
beginning of the string exactly matches the
number of 1s at the end of the string.
But this is not a formal proof.
Proof idea
If a DFA has n states, then any path of length n must
visit n+1 states, and contains a cycle. (This is an
application of the pigeonhole principle.)
y
x
Proof
Suppose that qi = qi+p , where
0i<i+pn
x = uvw
u = a1a2ai
v = ai+1a2ai+p
w = ai+p+1ai+p+2any
y = part of string longer than n + 1
Remember that qi = qi+p
Proof
Assume a dfa with states labeled q0,q1,qn
Now take as string in L |w| m = n +1
To process w the machine could go through a set of states say,
q0, qi, qj, qf.
Since this sequence has exactly |w| +1 entries, at least one state
must be repeated, and this repetition starts no later than the
nth move.
So the sequence of states must look like
q0, qi, qj, , qr, qr, , qf
indicating there must be substrings x, y, z of w such that
*(q0, x) = qr
*(qr, y) = qr
*(qr, z) = qf
with |xy| n +1 = m and |y| 1
Proof (cont.)
From this it immediately follows that
*(q0, xz) = qf
as well as
*(q0, xy2z) = qf,
*(q0, xy3z) = qf,
and so on, completing the proof of the
theorem
Example
Example 4.7: The language L = {anbn | n 0} is not
regular.
The proof is by contradiction:
If L is regular, it must be accepted by some DFA.
Let m be the number of states of the DFA and consider
some w L such that |w| m.
By the pumping lemma, we can split w into three pieces,
w = xyz, such that for any n 0, the string xynz is in L.
So let w = ambm.
Because |xy| m, y must consist of all as.
But then xy2z will contain more as than bs.
This is a contradiction.
Homework
Use the pumping lemma to show that the language of
palindromes L = {w | w = wR, w {a,b}*} is not regular.
Homework
Use the pumping lemma (plus some closure
properties of regular languages) to show that the language
L = {w {a,b}* | w contains equal number of as and bs}
is not regular.
Homework
Use the pumping lemma to show that the language
L = {ww | w {a,b}*} is not regular.