Kleene’s Theorem 
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide01.html 
Kleene’s Theorem 
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide02.html 

prev  slides  next 
_{K}_{l}_{e}_{e}_{n}_{e}_{’}_{s} _{T}_{h}_{e}_{o}_{r}_{e}_{m} 
prev  slides  next 

Introduction 

There are various ways to state the following theorem  the variations come from the way finite automata (both deterministic and nondeterministic) are defined. 

Kleene’s Theorem 
Theorem: (Kleene’s Theorem) A language is regular if and only if it is accepted by a finite automaton. 

This is an important theorem: it asserts what we have come to expect, that the class of languages accepted by finite automata is exactly the same as the class of languages that can be described by regular expressions. 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 
Proving this theorem will take a little work 


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 

1 of 1 
10/27/2003 05:40 PM 
1 of 1 
10/27/2003 05:40 PM 

Kleene’s Theorem 
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide03.html 
Kleene’s Theorem 
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide04.html 

_{K}_{l}_{e}_{e}_{n}_{e}_{’}_{s} _{T}_{h}_{e}_{o}_{r}_{e}_{m} 
prev  slides  next 
_{K}_{l}_{e}_{e}_{n}_{e}_{’}_{s} _{T}_{h}_{e}_{o}_{r}_{e}_{m} 
prev  slides  next 

Introduction 
L(RE) is a subset of L(FA) 

Another way to say state this theorem is that the class of languages matched by regular expressions (i.e., the class of regular languages, denoted L(RE)) is equal to the class of languages accepted by finite automata, denoted L(FA). 
To prove this part we need to see that, given a regular language, there is some finite automaton that accepts strings in that language and rejects strings not in the language. 

Thus, to prove Kleene’s theorem we need to show 
We’ll use a constructive proof that mimics the definition of regular expressions. Recall that this definition is inductive, starting with the 

empty language 
, the empty string 
and strings consisting of a 

1. L(RE) 
L (FA) 
single symbol from . Other regular expressions can then be 

constructed using concatenation, union and Kleene star. 

2. L(FA) 
L (RE) 
Our approach will be to inductively show that, given finite automata that accept strings matching simple regular expressions, we can construct finite automata that will accept strings matching more complicated regular expressions constructed from these simple regular expressions. 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 

1 of 1 
10/27/2003 05:40 PM 
1 of 1 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 
10/27/2003 05:40 PM 
Kleene’s Theorem 
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide05.html 
Kleene’s Theorem 
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide06.html 

_{K}_{l}_{e}_{e}_{n}_{e}_{’}_{s} _{T}_{h}_{e}_{o}_{r}_{e}_{m} 
prev  slides  next 
_{K}_{l}_{e}_{e}_{n}_{e}_{’}_{s} _{T}_{h}_{e}_{o}_{r}_{e}_{m} 
prev  slides  next 

L(RE) is a subset of L(FA) 
L(RE) is a subset of L(FA): Concatenation 

Clearly finite automata exist that accept the empty language, the empty string, and strings of length one: 
Now suppose we have two finite automata R and S which accept strings matched by regular expressions r and s respectively. We can always construct a new finite automaton that accepts rs, the concatenation of r and s. All we need to do is to is to 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 
1. connect all final states in R to the start state in S with empty transitions. 

2. Only the final states originally in S remain final states. 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 

1 of 1 
10/27/2003 05:40 PM 
1 of 1 
10/27/2003 05:40 PM 

Kleene’s Theorem 
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide07.html 
Kleene’s Theorem 
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide08.html 

_{K}_{l}_{e}_{e}_{n}_{e}_{’}_{s} _{T}_{h}_{e}_{o}_{r}_{e}_{m} 
prev  slides  next 
_{K}_{l}_{e}_{e}_{n}_{e}_{’}_{s} _{T}_{h}_{e}_{o}_{r}_{e}_{m} 
prev  slides  next 

L(RE) is a subset of L(FA): Concatenation 
L(RE) is a subset of L(FA): Concatenation 

For example, suppose 
= {a, b} and we have a finite automaton 

This constructions depends on our new finite automaton working nondeterministically. This new automaton accepts strings matched by rs since the prefix of the string matched by r leaves R in a state now connected via an empty transition to the start state of S, so the suffix matched by _{s} will leave our new automaton in an accepting final state. Strings not matching rs will be rejected since they do not have a prefix matching r or a suffix matching s; thus either R will never get to a state connected to S when the remaining portion of the input string would lead S to an accepting state. 
that accepts strings matching (ab)* and finite automaton that accepts strings matching (a+b)*aa(a+b)*, i.e., strings with aa as a substring. Below we have a NFA that accepts (ab)*(a+b)*aa(a+b)*. 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 

1 of 1 
10/27/2003 05:40 PM 
1 of 1 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 
10/27/2003 05:40 PM 
Kleene’s Theorem 
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide09.html 
Kleene’s Theorem 
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide10.html 

_{K}_{l}_{e}_{e}_{n}_{e}_{’}_{s} _{T}_{h}_{e}_{o}_{r}_{e}_{m} 
prev  slides  next 
_{K}_{l}_{e}_{e}_{n}_{e}_{’}_{s} _{T}_{h}_{e}_{o}_{r}_{e}_{m} 
prev  slides  next 

L(RE) is a subset of L(FA): Union 
L(RE) is a subset of L(FA): Union 

Assume again that R and S are finite automata that accept strings matched by the regular expressions r and s respectively. We now want to construct a finite automaton that accepts the union of r and _{s}_{:} (r+s). This is easily done by creating a new start state and adding two new empty transitions; one from the new start state to the original start state of R and another from the new start state to the original start state of S. 
Using our example again, we can construct a NFA that accepts (ab)* + (a+b)*aa(a+b)*. 



As in the case of concatenation, this new automaton is an NFA and executes nondeterministically. 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 

1 of 1 
10/27/2003 05:40 PM 
1 of 1 
10/27/2003 05:40 PM 

Kleene’s Theorem 
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide11.html 
Kleene’s Theorem 
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide12.html 

_{K}_{l}_{e}_{e}_{n}_{e}_{’}_{s} _{T}_{h}_{e}_{o}_{r}_{e}_{m} 
prev  slides  next 
_{K}_{l}_{e}_{e}_{n}_{e}_{’}_{s} _{T}_{h}_{e}_{o}_{r}_{e}_{m} 
prev  slides  next 

L(RE) is a subset of L(FA): Kleene Star 
L(RE) is a subset of L(FA): Kleene Star 

Finally, we need to see that, given a finite automaton R that accepts strings matched by the regular expression r, we can construct a finite automaton that accepts r*. 
Using our example once again, we can construct a NFA that accepts ((a+b)*aa(a+b)*)*. 

Create a new start state and connect it via an empty transition to the original start state of R. 


Make the new start state a final accepting state. 

Next connect each final accepting state of R to R’s original start state with empty transitions. 

That’s it! 

1 of 1 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 
10/27/2003 05:40 PM 
1 of 1 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 
10/27/2003 05:40 PM 
Kleene’s Theorem 
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide13.html 
Kleene’s Theorem 
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide14.html 

_{K}_{l}_{e}_{e}_{n}_{e}_{’}_{s} _{T}_{h}_{e}_{o}_{r}_{e}_{m} 
prev  slides  next 
_{K}_{l}_{e}_{e}_{n}_{e}_{’}_{s} _{T}_{h}_{e}_{o}_{r}_{e}_{m} 
prev  slides  next 

L(RE) is a subset of L(FA) 
L(FA) is a subset of L(RE) 

The first part of proof is complete. As a basis step we saw that the empty language, the empty string and the singleton languages each have corresponding finite automata. Then, for the inductive step we saw that just as regular expressions are built up from these basic elements through concatenation, union and Kleene star, we can combine finite automata in a systematic way to obtain finite automata that accept exactly the strings matched by these compound regular expressions. 
Now let’s look at the second part of our theorem. We need to show that if a language is accepted by some finite automaton then there is a regular expression that matches every string in the language and does not match any strings outside of that language. 

As in the first part of the proof we will use a constructive argument. Now we will start with a finite automaton and show that we can aways construct a regular expression to match the strings accepted by it. 

Thus we know know that if we have a language defined by a regular expression that we can construct a finite automaton that accepts the same language (and rejects all strings not in that language). 
Since any finite automaton can be represented by a transition graph or diagram, we will show how to convert that to a new graph that contains the desired regular expression. 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 

1 of 1 
10/27/2003 05:40 PM 
1 of 1 
10/27/2003 05:40 PM 

Kleene’s Theorem 
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide15.html 
Kleene’s Theorem 
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide16.html 

_{K}_{l}_{e}_{e}_{n}_{e}_{’}_{s} _{T}_{h}_{e}_{o}_{r}_{e}_{m} 
prev  slides  next 
_{K}_{l}_{e}_{e}_{n}_{e}_{’}_{s} _{T}_{h}_{e}_{o}_{r}_{e}_{m} 
prev  slides  next 

L(FA) is a subset of L(RE) 
L(FA) is a subset of L(RE) 

Our algorithm is as follows: Start with the transition graph of a finite automaton. Notice that it’s edges are labeled with symbols that are regular expressions. 
3. Select a state other than the start state or the final state. Determine new regular expressions that represent paths through that state and create bypass edges labeled with these regular expressions. Every possible path through the state must be accounted for. Remove the state and all incident edges. 4. Repeat the last step until only the start state and the final state remain. 

1. Create a new, nonreenterable start state. Connect it via an empty transition to the original start state. (This step is required if the original start state is reenterable.) 

2. Create a new accepting final state and add empty transitions from each original final state to this new state. Mark all original final states as nonaccepting. 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 

1 of 1 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 
10/27/2003 05:40 PM 
1 of 1 
10/27/2003 05:41 PM 
Kleene’s Theorem 
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide17.html 
Kleene’s Theorem 
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide18.html 

_{K}_{l}_{e}_{e}_{n}_{e}_{’}_{s} _{T}_{h}_{e}_{o}_{r}_{e}_{m} 
prev  slides  next 
_{K}_{l}_{e}_{e}_{n}_{e}_{’}_{s} _{T}_{h}_{e}_{o}_{r}_{e}_{m} prev  slides  next 

L(FA) is a subset of L(RE) 
L(FA) is a subset of L(RE) 

For example, consider the finite automaton represented by the following transition diagram. 

Now, suppose we studied all paths that go through state 2 and we want to draw new paths on the graph that bypass state 2. To do this, we need to figure out exactly what strings are matched by paths through state 2 and use this information to construct regular expressions as labels for new transitions we will add to the graph. 

First we need to create a new start state, connecting it to the original start state with an empty transition. (In this example it’s not really necessary, but if the original start state had paths coming into it then it would be necessary.) We also need a final accepting state, connected to with empty transitions from the original accepting states. Finally, we make sure that the only accepting state is the new one we just added. 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 

1 of 1 
10/27/2003 05:41 PM 
1 of 1 
10/27/2003 05:41 PM 

Kleene’s Theorem 
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide19.html 
Kleene’s Theorem 
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide20.html 

_{K}_{l}_{e}_{e}_{n}_{e}_{’}_{s} _{T}_{h}_{e}_{o}_{r}_{e}_{m} 
prev  slides  next 
_{K}_{l}_{e}_{e}_{n}_{e}_{’}_{s} _{T}_{h}_{e}_{o}_{r}_{e}_{m} prev  slides  next 

L(FA) is a subset of L(RE) 
L(FA) is a subset of L(RE) 

Notice that we can enter state 2 from states 0, 3 and 4 and we can exit state 2 by transitioning to states 1 and 3. This lets us construct the following table: 
After adding edges with these labels and removing state 2 and it’s incident edges we have: 


Now let us eliminate state 1. As before, we construct a table: 

From 
To 
RE 
From
To
RE
0
4
aa*ab*a
3
4
aa*ab*a
4
4
ba*ab*a


0 
1 
aa*a 

0 
3 
aa*b 

3 
1 
aa*a 

3 
3 
aa*b 

4 
1 
ba*a 

4 
3 
ba*b 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 

1 of 1 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 
10/27/2003 05:41 PM 
1 of 1 
10/27/2003 05:41 PM 
Kleene’s Theorem
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide21.html
Kleene’s Theorem
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide22.html
_{K}_{l}_{e}_{e}_{n}_{e}_{’}_{s} _{T}_{h}_{e}_{o}_{r}_{e}_{m}
prev  slides  next
L(FA) is a subset of L(RE)
After adding edges with these labels and removing state 1 and its incident edges we have:
Finally, we seek to remove state 3, so we construct a table:
From 
To 
RE 
0 
4 
aa*b(aa*b)*aa*ab*a 
4 
4 
(b+ba*b)(aa*b)*aa*ab*a 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
1 of 1 
10/27/2003 05:41 PM 
Kleene’s Theorem 
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide23.html 
_{K}_{l}_{e}_{e}_{n}_{e}_{’}_{s} _{T}_{h}_{e}_{o}_{r}_{e}_{m}
prev  slides  next
Final thoughts on our proof of Kleene’s Theorem
Our text provides some discussion as to why these constructions constitute a proof. Actually, to be a formal proof we’d have to carefully specify the how each of the automata in the first part of the proof are described and we’d have to provide a formal definition of transition graphs with edges labeled by regular expressions.
1 of 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
10/27/2003 05:41 PM
_{K}_{l}_{e}_{e}_{n}_{e}_{’}_{s} _{T}_{h}_{e}_{o}_{r}_{e}_{m}
prev  slides  next
L(FA) is a subset of L(RE)
This gives us our (nearly final) transition graph
All that remains is to eliminate states 0 and 4, which can be done by inspection, yielding our final regular expression
(aa*ab*a+aa*b(aa*b)*aa*ab*a)((b+ba*b)(aa*b)*aa*ab*a+ba*ab*a)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
1 of 1 
10/27/2003 05:41 PM 
Kleene’s Theorem 
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide24.html 
_{K}_{l}_{e}_{e}_{n}_{e}_{’}_{s} _{T}_{h}_{e}_{o}_{r}_{e}_{m}
prev  slides  next
Complementation
It’s easy to show that we can construct a deterministic finite automata R’ that will accept the complementation of a regular language accepting by a deterministic finite automaton R.
All that is necessary is to make every nonaccepting state of R accepting in R’, and make every accepting state of R nonaccepting in R’.
Thus, strings that are accepted by R will not be accepted by R’ and vice versa.
This proves that the complement of a regular language is a regular language.
Question: Why is it important that we use a DFA rather than an NFA?
1 of 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
10/27/2003 05:41 PM
Kleene’s Theorem
http://localhost/~senning/courses/cs220/slides/kleenetheorem/slide25.html
_{K}_{l}_{e}_{e}_{n}_{e}_{’}_{s} _{T}_{h}_{e}_{o}_{r}_{e}_{m} 
prev  slides  next 

Intersection 

Finally, here is a very short proof of the fact that the intersection of two regular languages is regular. 

If A and B are both subsets of a set U then 

A 
B = U  (U  A) (U  B) 

This is easy to prove using a Venn diagram. Recognizing that languages are sets we conclude that 

L _{1} 

L _{2} = 

*  ( 
*  L _{1} )
(

*  L _{2} ) 

Since we know that the operations of complementation and union of regular languages are closed, we therefore know that the intersection of two regular languages is also regular. 

1 of 1 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 
10/27/2003 05:41 PM 
Molto più che documenti.
Scopri tutto ciò che Scribd ha da offrire, inclusi libri e audiolibri dei maggiori editori.
Annulla in qualsiasi momento.