Documente Academic
Documente Profesional
Documente Cultură
Theory of Automata:08
Lecture 07:
Theory of Automata:08
Lecture Objective
Closure Properties
Complementation
Intersection
Lecture 07:
Theory of Automata:08
Closure Properties
A language that can be defined by a regular
expression is called a regular language.
Not all languages are regular, as we shall see in
the next lecture.
In this lecture we will focus on the class of all
regular languages and discuss some of their
properties.
Lecture 07:
Theory of Automata:08
Theorem 10
If L1 and L2 are regular languages, then L1 + L2, L1L2, and L*1
are also regular languages.
Notes:
L1 + L2 is the language of all words in either L1 or L2.
L1L2 is the product language of all words formed by
concatenating a word form L1 with a word from L2.
L1 is the language of all words that are the concatenation of
arbitrarily many factors from L1*.
The result stated in Theorem 10 is often expressed as The
set of regular languages is closed under union,
concatenation, and Kleene closure.
4
Lecture 07:
Theory of Automata:08
Proof by Machines
Because L1 and L2 are regular languages, there
must be TGs that accept them (by Kleenes
theorem).
Let TG1 accepts L1 and TG2 accepts L2.
Assume that TG1 and TG2 each have a unique
start state and a unique separate final state. If
this is not the case originally, then we can modify
the TGs so that this becomes true as in Kleenes
theorem,Part 2 of the proof (page 93).
5
Lecture 07:
Theory of Automata:08
Proof contd.
Then the TG described below accepts the language L1 +
L2.
Lecture 07:
Theory of Automata:08
Lecture 07:
Theory of Automata:08
Lecture 07:
Theory of Automata:08
Complements.
Intersections
Lecture 07:
Theory of Automata:08
Complements
Definition:
If L is a language over the alphabet , we define
its complement L` to be the language of all
strings of letters from that are not words in L.
Example:
Let L be the language over the alphabet = {a;
b} of all words that have a double a in them.
Then, L` is the language of all words that do not
have a double a in them.
Note that the complement of L` is L. That is
(L`)` = L
10
Lecture 07:
Theory of Automata:08
Theorem 11
11
Lecture 07:
Theory of Automata:08
Proof of theorem 11
If L is a regular language, then by Kleenes theorem,
there is some FA that accepts the language L.
Some states of this FA are final states and some are not.
Let us reverse the status of each state: If it was a final
state, make it a non-final state. If it was a non-final state,
make it a final state. The start state gets reversed as
follows: -
If an input string formerly ended in a non-final state, it
now ends in a final state, and vice versa.
The new machine we have just built accepts all input
strings that were not accepted by the original FA, and it
rejects all the input strings that used to be accepted by
FA.
Therefore, this machine accepts exactly the language L`.
So, by Kleenes theorem, L` is regular.
12
Lecture 07:
Theory of Automata:08
Intersection: Theorem 12
If L1 and L2 are regular languages, then L1 L2
is also a regular language. In other words,
the set of regular languages is closed under
intersection.
13
Lecture 07:
Theory of Automata:08
Proof of Theorem 12
By DeMorgans law (for sets of any kind):
L1 L2 = (L`1 + L`2)`
This means that the language L1 L2 consists of all
words that are not in either L`1 or L`2.
Because L1 and L2 are regular, then so are L`1 and L`2 by
Theorem 11.
Since L`1 and L`2 are regular, so is L`1 + L`2 by Theorem
10.
Now, since L`1 + L`2 is regular, so is (L`1 + L`2)` by
Theorem 11.
This means L1 \ L2 is regular, because
L1 L2 = (L`1 + L`2)` by DeMorgans law.
14
Lecture 07:
Theory of Automata:08
Pumping Lemma
Lecture 07:
Theory of Automata:08
Introduction
By using FAs and regular expressions, we have been able to define
many
languages. Although these languages have many different
structures, they take only a few basic forms:
Languages with required substrings
Languages that forbid some substrings
Languages that begin or end with certain substrings
Languages with certain even (or odd) properties, and so on.
We now turn our attention to some new forms, such as the language
PALINDROME, or the language PRIME of all words ap, where p is a
prime number.
We shall see that neither of these is a regular language. We can
describe them in English, but they can not be defined by an FA. We
need to build more powerful machines to define them.
16
Lecture 07:
Theory of Automata:08
17
Lecture 07:
Theory of Automata:08
Case Study
Consider the langugage
L = {; ab; aabb; aaabbb; aaaabbbb;
aaaaabbbbb; }
The language L can also be written as
L = {anbn for n = 0; 1; 2; 3; }
or for short
L = {anbn}
Note that although L is a subset of many regular
languages, such as a*b*; the language defined
by a*b* also includes such strings as aab and bb
that are not in L.
18
Lecture 07:
Theory of Automata:08
Example
Just for the sake of argument, let us assume that this FA has 95 states.
The first 96 letter as of this input string trace a path through this machine.
The path cannot visit a new state when each input letter is read, because
there are only 95 states. Therefore, at some point the path returns to a state
that it has already visited.
In other words, the path must contain a circuit in it. (A circuit is a loop that
can be made of several edges.)
19
Lecture 07:
Theory of Automata:08
So, the path first wanders up to the circuit and then starts to loop
around the circuit (maybe many times) until a b is read from the input.
At this point, the path can take a different turn following the b-edges,
and eventually end up at a final state where the word a 96b96 is
accepted.
Just for the sake of argument again, let us say that the circuit that the
a-edge path loops around has 7 states in it.
Then what would happen to the input string a96+7b96?
Just as in the case of the input string a96b96, the input string a96+7b96
would produce a path through the machine and loop around the
circuit exactly in the same way, but one more time than the path
produced by the input string a96b96.
Both paths, at exactly the same state in the circuit, begin to branch
off on the b-road.
20
Lecture 07:
Theory of Automata:08
Lecture 07:
Theory of Automata:08
Lecture 07:
Theory of Automata:08
Theorem 13
Let L be any regular language that has
infinitely many words. Then there exist some
three strings x, y, and z (where y is not the
null string) such that all the strings of the
form
xynz for n = 1, 2, 3,
are words in L.
23
Lecture 07:
Theory of Automata:08
Proof of theorem 13
Since L is regular, there is an FA that accepts exactly the
words in L.
Let w be some word in L that has more letters than there
are states in FA.
When w generates a path through the machine, the path
cannot visit a new state for each letter read, because
there are more letters than states. Therefore, the path
must at some point revisit a state that it has already
visited. In other words, the path contains a circuit in it.
24
Lecture 07:
Theory of Automata:08
Lecture 07:
Theory of Automata:08
Lecture 07:
Theory of Automata:08
27
Lecture 07:
Theory of Automata:08
Example
Consider the following FA that accepts an
infinite language and has only six states:
Lecture 07:
Theory of Automata:08
Example contd.
The x-part goes from the - state up to the first circuit: substring b
This string will loop twice around the circuit and is accepted.
The same thing happens with xyyyz, xyyyyz, and in general, for
xynz.
29
Lecture 07:
Theory of Automata:08
Lecture 07:
Theory of Automata:08
Lecture 07:
Theory of Automata:08
Example
Let EQUAL be the language of all words (over the
alphabet = {a; b}) that have the same total number of
as and bs:
EQUAL = {; ab; ba; aabb; abab; abba; baab; baba;
bbaa; aaabbb; }
Can you show that EQUAL is not regular?
Let L = {anban} = {b; aba; aabaa; }
Can you show that L is not regular?
32
Lecture 07:
Theory of Automata:08
Theorem 14
Let L be an infinite language accepted by a finite
automaton with N states. Then, for all words w in L
that have more than N letters, there are strings x, y,
and z, where y is not null and length(x) + length(y)
does not exceed N, such that w = xyz and all strings
of the form xynz for n = 1; 2; 3; are in L.
This is obviously just another version of Theorem 13 (the
pumping lemma), for which we have already provided
the proof.
The purpose of stressing the issue of lengths is
illustrated in the following example.
33
Lecture 07:
Theory of Automata:08
Example
We will show that the language PALINDROME is not
regular.
We cannot use the first version of the pumping lemma
(Theorem 13)vbecause the strings
x = a; y = b; z = a
satisfy the lemma and do not contradict the language,
since all the strings of the form xynz = abna are words in
PALINDROME.
So, we will use the second version of the pumping
lemma (Theorem 14) to show that PALINDROME is nonregular.
34
Lecture 07:
Theory of Automata:08
Example contd.
35
Lecture 07:
Theory of Automata:08
Lecture 07:
Theory of Automata:08
Example
Consider the language
PRIME = {ap where p is a prime}
Recall that a prime is a positive integer greater than 1
whose only positive divisors are 1 and itself, for example
2, 3, 5, 7 ...
Hence,
PRIME = {ap where p is a prime}
= {aa; aaa; aaaaa; aaaaaaa; }
Can you show that PRIME is non-regular?
37