Professional Documents
Culture Documents
and
COMPILER DESIGN
(CC3203 )
Introduction to Automata Theory
His conclusions apply not only to his abstract Turing machines but to today’s
real machines.
Introduction to Automata Theory
Symbol: A symbol (often also called a character) is the smallest building block,
which can be any alphabet, letter, or picture.
Example: a,b,c…..
Alphabets (Σ): Alphabets are a set of symbols, which are always finite.
Σ={a,b}
Σ={0,1}
Introduction to Automata Theory
Representation of Automata
Transition Table
Transition Function
Transition Diagram
Introduction to Automata Theory
Type of Automata
Deterministic Finite Automata (DFA).
Non-Deterministic Finite Automata (NFA or NDFA).
Non-Deterministic Finite Automata with epsilon moves (e-NFA or e-
NDFA).
Non-Deterministic Finite Automata without epsilon moves
Introduction to Automata Theory
Construction Of DFA:
Problems: In this problem, we will discuss the construction of DFA for languages
consisting of strings starting with a particular substring.
Steps To Construct DFA-
The following steps are followed to construct a DFA -
Step-01:
Determine the minimum number of states required in the DFA.
Draw those states.
Use the following rule to determine the minimum number of states-
Calculate the length of the substring.
All strings starting with ‘n’ length substring will always require minimum
(n+2) states in the DFA.
Introduction to Automata Theory
Construction Of DFA:
Step-02:
Decide the strings for which DFA will be constructed.
Step-03:
Construct a DFA for the strings decided in Step-02.
While constructing a DFA,
Always prefer to use the existing path.
Create a new path only when there exists no path to go with.
Step-04:
Send all the left possible combinations to the dead state.
Do not send the left possible combinations over the starting state
Introduction to Automata Theory
Designing of DFA:
Design a DFA that accept string w={a} over the Σ={a}
Design a DFA that accept string w={a} over the Σ={a,b}
Design a DFA that accept string of length |w|=2 over the Σ={a,b}
Design a DFA that accept string of length |w|<=3 over the Σ={a,b}
Design a DFA that accept string of length |w|>=3 over the Σ={a,b}
Design a DFA that accepts an even number of “a” over the Σ={a,b}
Design a DFA that accepts an odd number of “a” over the Σ={a,b}
Introduction to Automata Theory
Designing of DFA :
Design a DFA that accepts an odd number of “a” over the Σ = { a, b}
Design a DFA that accepts an even number of “a” and an even number of
“b” over the Σ={a, b}
Design a DFA that accepts string starting with “a” over the Σ={a, b}
Design a DFA that accepts a string ending with “a” over the Σ={a, b}
Design a DFA that accepts a string starting with “a” ending with “b” over
the Σ={a, b}
Introduction to Automata Theory
Designing of DFA :
Design a DFA that accepts a string starting with “a” ending with “b” over
the Σ={a, b}
Design a DFA that accepts a string starting and ending with the same
symbol over the Σ={a, b}
Design a DFA that accepts a string starting and ending with a different
symbol over the Σ={a, b}
Design a DFA that accepts a string containing “ab” as a sub-string over the
Σ={ a, b}
Design a DFA that accepts a string containing “a” is divisible by 2 over the
Σ={ a, b}
Introduction to Automata Theory
Designing of DFA :
Design a DFA that accepts a string containing “a” is divisible by 2 over the
Σ={ a, b}
Design a DFA that accepts a string containing “a” is divisible by 3 over the
Σ={ a, b}
Design a DFA that accepts binary numbers divisible by 2 over the Σ={ 0, 1}
Design a DFA that accepts a language L={ anbm | m>1, n>2} over the Σ={ a,
b}
Introduction to Automata Theory
Type of Automata
Deterministic Finite Automata (DFA).
Non-Deterministic Finite Automata (NFA or NDFA).
Non-Deterministic Finite Automata with epsilon moves (e-NFA or e-
NDFA).
Non-Deterministic Finite Automata without epsilon moves
Introduction to Automata Theory
Where:
Q: Finite set of states
Σ: Finite set of the input symbol
q0: Initial state
F: Final state
δ: Transition function: Q X Σ -> 2Q
Introduction to Automata Theory
Example 2:
Design an NFA with ∑ = {0, 1} accepts all string ending with 01.
Solution:
Introduction to Automata Theory
State 0 1 State 0 1
Now the δ' transition on each input symbol is obtained as: δ'(q0, b) = ε-closure(δ(δ^(q0, ε),b))
δ'(q0, a) = ε-closure(δ(δ^(q0, ε),a)) = ε-closure(δ(ε-closure(q0),b))
= ε-closure(δ(ε-closure(q0),a)) = ε-closure(δ(q0, b))
= ε-closure(δ(q0, a)) =Ф
= ε-closure(q1)
= {q1, q2}
Introduction to Automata Theory
Eliminating ε Transitions
Example:
Now the δ' transition on q1 is obtained as:
δ'(q1, a) = ε-closure(δ(δ^(q1, ε),a))
= ε-closure(δ(ε-closure(q1),a))
= ε-closure(δ(q1, q2), a)
= ε-closure(δ(q1, a) ∪ δ(q2, a))
= ε-closure(Ф ∪ Ф)
=Ф
Minimization of DFA:
DFA minimization is the process of converting a given DFA to its equivalent
DFA with a minimum number of states.
What is a requirement of DFA Minimization?
Problem: Design a DFA that accepts an odd number of ‘a’ over the ∑={ a, b}.
Introduction to Automata Theory
Minimization of DFA:
Minimization of DFA:
Two states will be equivalent
δ(p,w) ∈ F ⟹ δ(q,w) ∈ F
δ(p,w) ∉ F ⟹ δ(q,w) ∉ F
If p and q are equivalent, then we can combine them into 1 state
Type of equivalence:
If |w|=0, then p and q are said to be 0 equivalence
If |w|=1, then p and q are said to be 1 equivalence
If |w|=2, then p and q are said to be 2 equivalence