0% found this document useful (0 votes)
18 views38 pages

ToA - Lecture 09 10 - Kleenes Theorem

Uploaded by

wosqa nisar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views38 pages

ToA - Lecture 09 10 - Kleenes Theorem

Uploaded by

wosqa nisar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 38

Lecture – 09 & 10

Kleene’s Theorem
Kleene’s Theorem
• Any language that can be defined by
• regular expression, or
• finite automaton, or
• transition graph
• can be defined by all three methods.
Proof
• The three sections of our proof will be :
• Every language that can be defined by a finite automaton can also be defined by a transition graph.
• Every language that can be defined by a transition graph can also be defined by a regular expression.
• Every language that can be defined by a regular expression can also be defined by a finite automaton.
• When we have proven these three parts, we have finished our theorem.
TGs into REs
• Constructive algorithm
• We present a procedure that starts out with a transition graph and ends up with a regular expression
that defines the same language.
• To be acceptable as a method of proof, any algorithm must satisfy two criteria
• It must work for every conceivable TG
• It must guarantee to finish its job in a finite time (a finite number of steps).
• For the purposes of theorem-proving alone, it does not have to be a good algorithm (quick,
least storage used, etc.). It just has to work in every case.
TGs into REs
• We already studied that a transition graph (T) may have multiple start states.
• We first want to simplify T so that it has only one start state that has no incoming edges.
TGs into REs
• We do this by introducing a new state that we label with a minus sign and that we connect
to all the previous start states by edges labeled with .
• Then we drop the minus signs from the previous start states.
TGs into REs
• Another simplification we can make in T is that it can be modified to have a unique
unexcitable final state without changing the language it accepts.

becomes
TGs into REs
• Let us suppose that T has some state (called state x) inside it (not the - or + state) that has
more than one loop circling back to itself, where and are all regular expressions or simple
strings. In this case, we can replace the three loops by one loop labeled with a regular
expression

becomes
TGs into REs
• Similarly, suppose two states are connected by more than one edge going in the same
direction, where the labels and are each regular expressions or simple strings. We can
replace this with a single edge that is labeled with a regular expression:

becomes
TGs into REs
• We can now define the bypass and state elimination operation.
• In some cases, if we have three states in a row connected by edges labeled with regular expressions (or
simple strings), we can eliminate the middleman and go directly from one outer state to the other by a
new edge labeled with a regular expression that is the concatenation of the two previous labels.

becomes
TGs into REs
• We can do this trick only as long as state 2 does not have a loop going back to itself. If state 2
does have a loop, we must use this model:

becomes
TGs into REs
• If state 1 is connected to state 2 and state 2 is connected to more than one other state (say,
to states 3, 4, and 5)
• When we eliminate the edge from state 1 to state 2, we have to add edges that show how to go from
state 1 to states 3, 4, and 5.

becomes
TGs into REs
• What have we done to transition graph T?
• Without changing the set of words that it accepts; we have eliminated one of its states.
• We can repeat this process again and again until we have eliminated all the states from T
except for the unique start state and the unique final state.

becomes
TGs into REs – Example
TGs into REs – Example
TGs into REs – Example
TGs into REs – Example
TGs into REs – Example
TGs into REs – Example
TGs into REs – Example
• Current Regular Expression

• Final Regular Expression


TGs into REs – Algorithm
• General rules defining the constructive algorithm that proves that all TGs can be turned into
regular expressions that define the exact same language:
• Create a unique, unenterable minus state and a unique, unleavable plus state.
• One by one, in any order, bypass and eliminate all the non - or + states in the TG.
• A state is bypassed by connecting each incoming edge with each outgoing edge.
• The label of each resultant edge is the concatenation of the label on the incoming edge with the label on the loop
edge if there is one and the label on the outgoing edge.
• When two states are joined by more than one edge going in the same direction, unify them by adding
their labels.
• Finally, when all that is left is one edge from - to + , the label on that edge is a regular expression that
generates the same language as was recognized by the original machine.
REs into FAs
• Rules
• There is an FA that accepts any particular letter of the alphabet. There is an FA that accepts only the
word .
• If there is an FA called , that accepts the language defined by the regular expression and there is an FA
called that accepts the language defined by the regular expression , then there is an FA that we shall call
that accepts the language defined by the regular expression ().
• If there is an FA called , that accepts the language defined by the regular expression and there is an FA
called that accepts the language defined by the regular expression , then there is an FA that we shall call
that accepts the language defined by the regular expression ().
• If is a regular expression and is a finite automaton that accepts exactly the language defined by , then
there is an FA called that will accept exactly the language defined by .
Proof – Rule 1
• If x is in , then the FA accepts only the word x

• One FA that accepts only


Proof – Rule 2
• Suppose we have the machine which accepts the language of all words over the alphabet
that have a double somewhere in them
Proof – Rule 2
• The machine , which accepts all words that have both an even number of total a's and an
even number of total b's (EVEN-EVEN)
Proof – Rule 2
• We shall show how to design a machine that accepts both sets.
• That is, we shall build a machine that accepts all words that either have an or are in EVEN-EVEN and
rejects all strings with neither characteristic.
• The language the new machine accepts will be the union of these two languages.
• We shall call the states in this new machine , and so on, for as many as we need.
• We shall define this machine by its transition table.

• Our guiding principle is this:


• The new machine will simultaneously keep track of where the input would be if it were running on alone
and where the input would be if it were running on alone.
Proof – Rule 2
• First of all, we need a start state. This state must combine , the start state for and , the start
state for
• We call it . If the string were running on , it would start in and if on , in
• What new states can occur if the input letter a is read?
• If the string were being run on the first machine, it would put the machine into state
• If the string were running on the second machine, it would put the machine into state
• Therefore, on our new machine an “” puts us into state , which means either or , in the same way that
means either or
• Because is a final state for , is also a final state in the sense that any word whose path ends there on the
z-machine would be accepted by
Proof – Rule 2
• If we are in state and we read the letter b, then being in on and reading , we return to
whereas being in on and reading send us to

• The beginning of our transition table for is


Proof – Rule 2
• If in state , we read
• If we were in , we would now go to state , which is a final state.
• If we were in , we would now go back to which is also a final state.
• We will call this state , meaning either or
• Because this string could now be accepted on one of these two machines, is a final state for
• As it turns out, in this example the word is accepted by both machines at once, but this is not necessary.
• Acceptance by either machine or is enough for acceptance by
• Membership in either language is enough to guarantee membership in the union.

• If in state , we read
• In , we are back to
• In , we are in
• Call this new state = state or
Proof – Rule 2
• State and read
• In , we move to
• In , we move to
• Call it state .
• State and read
• In , we move to
• In , we move to
• This means that if we are in and we read , we return to state
Proof – Rule 2
• State and read
• In , we move to
• In , we move to
• Call it state .
• State and read
• In , we move to
• In , we move to
• Call it state
• Both of these are final states because
• is a final state for
Proof – Rule 2
• In , if we read , we go to or , which we shall call
• In , if we read , we go to or , which we shall call

• In , if we read , we go to or , which is our old state


• In , if we read , we go to or , which is our old state

• In , if we read , we go to or , which is our old state


• In , if we read , we go to or , which we shall call
Proof – Rule 2
• In , if we read , we go to or , which is our old state
• In , if we read , we go to or , which is our old state

• In , if we read , we go to or , which is our old state


• In , if we read , we go to or , which is our old state

• In , if we read , we go to or , which we shall call


• In , if we read , we go to or , which is our old state
Proof – Rule 2
• In , if we read , we go to or , which is our old state
• In , if we read , we go to or , which is our old state

• In , if we read , we go to or , which is our old state


• In , if we read , we go to or , which is our old state
Proof – Rule 2
• The full transition table is
Proof – Rule 2
• Here is what may look like
Proof – Rule 2 – Algorithm
• Starting with two machines, with states and with states , build a new machine with
states , where each is of the form “ or ”
• The combination state or is the – state of the new FA.
• If either the x part or the y part is a final state, then the corresponding z is a final state.
• To go from one z to another by reading a letter from the input string, we see what happens to the x part
and the y part and go to the new z accordingly. We could write this as a formula:

after letter p after letter p on or after letter p on

• Because there are only finitely many x's and y's, there can be only finitely many possible z’s.
• Not all of them will necessarily be used in if no input string beginning at – can get to them.
Thank You 
Any Questions?

You might also like