Lec#09 Kleene's Theorem NFA
Lec#09 Kleene's Theorem NFA
Kleene’s Theorem
• Unification
3
Theorem 6
4
Kleene’s Theorem
• Recall that
– To prove A = B, we need to prove (i) A B, and (ii) B A.
5
Kleene’s Theorem
6
Proof of Part 1
7
Proof of Part 2: Turning TGs into Regular Expressions
• Consider an abstract transition graph T that may have many start states.
• We can simplify T so that it has only one unique start state that has no
incoming edges.
• We do this by introducing a new start state that we label with the minus
sign, and that we connect to all the previous start states by edges labeled
with Λ. We then drop the minus signs from the previous start states.
9
• Consider a fragment of T:
10
Creating a Unique Final State
11
becomes
12
• We shall require that the unique final state be a different
state from the unique start state. If an old state used to have
±, then both signs are removed from the old state to newly
created states, using the processes described above.
13
Combining Edges
• If T has some internal state x (not the - or the + state) that has
more than one loop circling back to itself:
14
Combining Edges
15
Bypass and State Elimination
16
Bypass and State Elimination
17
Bypass and State Elimination
18
Special Cases
19
Combining Edges
• We can then combine the edges from the above picture one
more to produce
21
Example
22
• This TG has only one start state with no
incoming edges, but has two final states. So,
we must introduce a new unique final state:
23
• Now we build regular expressions piece by
piece:
24
• Eliminate state 2:
25
Eliminate state 1:
26
Eliminate state 3:
27
• Hence, this TG defines the same language as the regular
expression
(aa + bb)(a + b)*(aa) + (aa + bb)(a + b)*(bb)
• or equivalently
(aa + bb)(a + b)*(aa + bb)
• Step 2: One by one, in any order, bypass and eliminate all the non-minus
or non-plus 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.
• Step 3: When two states are joined by more than one edge going in the
same direction, unify them by adding their labels.
• Step 4: 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 TG.
29