Professional Documents
Culture Documents
RE to ԑ-NFA
FA to RE - State Elimination
Course Instructors:
Div 1: Praveen Pawar (Div 1)
Div 2: Jibi Abraham (Div 2)
1
Theorem
Languages
Generated by Regular
Regular Expressions Languages
Languages
Regular
Generated by
Languages
Regular Expressions
Languages
Regular
Generated by
Languages
Regular Expressions 2
Regular Language Representations
3
Equivalence of FA and RE
Finite Automata and Regular Expressions are
equivalent. To show this:
Show a DFA can be expressed as an equivalent
RE
Show a RE can be expressed as an ε-NFA
Since the ε-NFA can be converted to a DFA and
the DFA to an NFA, then RE will be equivalent to
all the automata
Proof - Part 1
Languages
Generated by Regular
Regular Expressions Languages
RE
For any regular expression r
the language L(r) is regular ε-NFA DFA
NFA
Proof by induction on the size of r
5
Induction Basis
Primitive Regular Expressions:
Corresponding NFAs
regular
languages
6
RE to ε-NFA: Basis
a
Symbol a:
ε: ε
∅:
7
Inductive Hypothesis
Suppose that for regular expressions r1, r2,
L(r1) and L(r2) are regular languages
L r1 r2
L r1 *
L r1 8
RE to ε-NFA: Union
L r1 r2 L r1 L r2
For r1
For r2
9
RE to ε-NFA: Union
L r1 r2 L r1 L r2
For r1
ε ε
ε ε
For r2
10
RE to ε-NFA: Concatenation
L r1 r2 L r1 L r2
ε
For r1 For r2
11
RE to ε-NFA: Closure
L r * L r *
ε
ε ε
For r
12
Example-1
Convert R= (ab+a)* to an ε-NFA
a
a
b
b
ab a ε b
Example-1
R= (ab+a)*
ab+a
a ε b
ε ε
a
ε ε
(ab+a)* ε
a ε b
ε ε
ε
ε
a
ε ε
ε
Example - 2
Find ε-NFA for a+(bc)*
15
DFA to Regular Expression Conversion
DFA to RE
Methods
16
State Elimination Method
This method involves the following steps in finding the regular
expression for any given DFA.
Step-01:
1. The initial state of the DFA must not have any incoming edge.
2. If there exists any incoming edge to the initial state, then create a new
initial state having no incoming edge to it.
17
State Elimination Method
Step-02:
There must exist only one final state in the DFA.
If there is multiple final states in the DFA, then convert all the final
states into non-final states and create a new single final state.
18
State Elimination Method
Step-03:
The final state of the DFA must not have any outgoing edge.
If there exists any outgoing edge from the final state, then create a new
final state having no outgoing edge from it.
19
State Elimination Method
Step-04:
Eliminate all the intermediate states one by one.
These states may be eliminated in any order.
In the end,
Only an initial state going to the final state will be left.
The cost of this transition is the required regular expression.
20
Example - 1
Find regular expression for the following DFA.
21
Example-1: Solution
Step-01:
Initial state A has an incoming edge.
So, we create a new initial state qi.
The resulting DFA is-
Step-02:
Final state B has an outgoing edge.
So, we create a new final state qf.
The resulting DFA is-
22
Example-1: Solution
Step-03:
Start eliminating the intermediate states.
First eliminate state A
There is a path going from state qi to state B via state A.
So, after eliminating state A, put a direct path from state
qi to state B having cost .0 = 0
There is a loop on state B using state A.
So, after eliminating state A, we put a direct loop on state B
having cost 1.0 = 10.
Eliminating state A, we get-
23
Example-1: Solution
Step-04:
Eliminate state B.
There is a path going from state qi to state qf via state B.
So, after eliminating state B, put a direct path from state
qi to state qf having cost 0.(10)*. = 0(10)*
Eliminating state B, we get-