0% found this document useful (0 votes)
97 views

Lecture 04 - Transition Graphs, FA & Regular Expression-2024

The document discusses the conversion of regular expressions (RE) to finite automata (FA) and vice versa. It provides basics on transition graphs and outlines rules for converting RE to FA and FA to RE through examples. The key steps in converting a FA to a RE are to: 1) ensure the initial state has no incoming edges and final states have no outgoing edges, 2) reduce multiple final states to one, and 3) iteratively remove non-initial/final states to obtain the equivalent RE. Kleen's theorem states that any language defined by a RE, FA, or transition graph can be defined by the other two methods as well.

Uploaded by

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

Lecture 04 - Transition Graphs, FA & Regular Expression-2024

The document discusses the conversion of regular expressions (RE) to finite automata (FA) and vice versa. It provides basics on transition graphs and outlines rules for converting RE to FA and FA to RE through examples. The key steps in converting a FA to a RE are to: 1) ensure the initial state has no incoming edges and final states have no outgoing edges, 2) reduce multiple final states to one, and 3) iteratively remove non-initial/final states to obtain the equivalent RE. Kleen's theorem states that any language defined by a RE, FA, or transition graph can be defined by the other two methods as well.

Uploaded by

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

Lecture 04 –Regular Expression & Transition Graphs

(Dr. Nida Aslam)


• Basics of TG
• Basics for conversion of FA → RE
• Rules for conversion of FA → RE
• Kleen’s Theorem
• Examples
2/9/2024
Conversion of RE→ FA
 Automata: It’s an abstract machine, that will accept RE

 Finite Automata: Finite number of states, exactly one of them will be the initial state, zero
or more will be final state.

 For every RE there exist at least one FA and for every FA there exist at least one RE.

 So, they are interchangeable

 Now we will see how to construct FA for a given RE.

Dr. Irfan 2/9/2024 2


Conversion of RE → FA
 Basics for conversion of RE→ FA

1. Ф

2. a a

3. a + b a,b

4. a . b a b

Dr. Irfan 2/11/2024 3


Conversion of RE → FA
 Basics for conversion of RE → FA
a
5. a*
b
a
6. ab*
a

7. (ab)* b
a

b
8. (ab + ba)* b a

Dr. Irfan 2/11/2024 4


Transition Graphs (TGs)
 It is the most generalized automata to describe a RE

 It may have a complete RE or its subset at transition

 Very easy to construct and used to convert FA to RE.

 Definition: A transition graph, abbreviated TG, is a collection of three things:

1. A finite set of states at least one of which is designated as the start state (→) and some (maybe

none) of which are designated as final states (*).

2. An alphabet ∑ of possible input letters from which input strings are formed.

3. A finite set of transitions that show how to go from one state to another based on reading

specified substrings of input letters (possibly even the null string л ).

Dr. Irfan 2/11/2024 5


Examples

Dr. Irfan 2/11/2024 6


Examples
a,b
a,b
a a

a,b

a
a

b
b

a,b

Dr. Irfan 2/11/2024 7


Kleen’s Theorem
 Any language that can be defined by
 regular expression
 or finite automaton
 or transition graph

 can be defined by all three methods.

 This theorem is the most important and fundamental result in the Theory of Finite
Automata.

 Every FA is a TG by default while every TG may or may not be an FA.

 Now we will go for conversion from FA to TG to RE.

Dr. Irfan 2/11/2024 8


FA to RE
 The proof of this part will be by a constructive algorithm.

 This means that we present a procedure that starts out with an FA, transition graph and
ends up with a regular expression that defines the same language.

 TG is an intermediate state when we convert FA to RE.

 Because during conversion, FA becomes TG and is no more an FA.


 For instance, we can have more than one initial state.
 A string can be used as a transition etc.

 So, instead of calling it FA, we call it TG.


 Means a graph for the transition from FA to RE.

Dr. Irfan 2/11/2024 9


Rule for FA to RE
 Rules for conversion of FA → RE

1. The initial state should not have incoming edges/arrows

є
Converted to

2. The final state should have no outgoing edges/arrows

Converted to
є

Dr. Irfan 2/11/2024 10


Rule for FA to RE
 Rules for conversion of FA → RE

3. The final state should be one (if there’s exist more than one final state, should be reduced to
one)

+ є

Converted to
є +
+
є
+

Dr. Irfan 2/11/2024 11


Rule for FA→ RE
 Rules for conversion of FA→ RE

State Elimination: Remove states 1 by 1 (other than the initial and final state) and you will
get target RE.
Example:
a,b,c
+

OR RE = a + b + c
a+b+c
+

Example:

ab
+ RE = ab

Dr. Irfan 2/11/2024 12


Example
State Elimination: Remove states 1 by 1 (other than the initial and final state) and you will get
target RE.
Example:

Dr. Irfan 2/11/2024 13


Conversion of FA→ RE
Example: Convert the FA in the below Figure into RE?

Removing “B” the path must be the same

ab*c
+

Regular Expression will be

RE = ab*c

Dr. Irfan 2/11/2024 14


Conversion of FA→ RE
Example: Convert the FA in the below Figure into RE?

= 𝑟1 𝑟2∗ 𝑟3 + 𝑟1 𝑟2∗ 𝑟4 + 𝑟1 𝑟2∗ 𝑟5


= ∗
𝑟1 𝑟2 (𝑟3 + 𝑟4 + 𝑟5 )
Dr. Irfan 2/11/2024 15
Examples
Example: Convert the FA in the below Figure into RE?

= 𝒂𝒃𝒂∗ ba+ 𝒂𝒃𝒂∗ b+ 𝒃𝒃𝒃𝒂∗ b+ 𝒃𝒃𝒃𝒂∗ ba


= 𝒂𝒃𝒂∗ (ba+ b) + 𝒃𝒃𝒃𝒂∗ (b+ ba)

Dr. Irfan 2/11/2024 16


Example
Example: Convert the FA in the below Figure into RE?

Dr. Irfan 2/11/2024 17


Example

Dr. Irfan 2/11/2024 18


Example

Dr. Irfan 2/11/2024 19


Example
Example: Convert the FA in the below Figure into RE?

Dr. Irfan 2/11/2024 20


Example

Dr. Irfan 2/11/2024 21


Example

Dr. Irfan 2/11/2024 22


Example

= [ 𝐚𝐚 + 𝐛𝐛 + (𝐚𝐛 + 𝐛𝐚)(𝒂𝒂 + 𝒃𝒃)∗ (𝒂𝒃 + 𝒃𝒂)]∗

Dr. Irfan 2/11/2024 23


Conversion of FA→ RE
Example: Example:
+
0 b
a c
A B +
1 d
+

Dr. Irfan 2/11/2024 24


Conversion of FA→ RE
Example: c
b
d +
A B C
C
a

Dr. Irfan 2/11/2024 25


Conversion of FA→ RE
Example: c d
a
A B
b

Dr. Irfan 2/11/2024 26


Conversion of FA → RE
Example: 0 0
1
A B
1

Dr. Irfan 2/11/2024 27


Conversion of FA → RE
Example:
0 0
0
1 1
A B C

Dr. Irfan 2/11/2024 28


Conversion of FA → RE
 Define RE for FA = b
b
a
A B
a

Dr. Irfan 2/11/2024 29


Conversion of FA → RE
 Define RE for FA = b Accept EVEN
b numbers of a’s
a
A B
a

Dr. Irfan 2/11/2024 30


Conversion of FA → RE
 Define RE for FA = b should be END
b with a.
a
b B

Dr. Irfan 2/11/2024 31


Convert FA to RE (Solve)

Dr. Irfan 2/11/2024 32


End of Lecture - 04
Any questions?

2/9/2024 33

You might also like