You are on page 1of 43

Theory of Automata

Chapter No.2

• Finite Automata

• Recognizer for “Regular Languages”

• Deterministic Finite Automata (DFA)

• Non-deterministic Finite Automata (NFA)


Finite Automata
Informally, a state machine that
comprehensively captures all possible states
and transitions that a machine can take while
responding to a stream machine can take
while responding to a stream (or sequence) of
input symbols.
Finite Automata
• Start State
A finite set of states, one of which is designated as the
initial state, called the start state ( indicated arrow )
• Accept State or Final State
A finite set of states, some of which is designated as the
accept state, called the accept state ( indicated double
circle).
• Transitions
The arrows going from one state to another are called
transitions.
Formal Definition of a Finite Automation
Describe Formal Definition of Finite Automaton
Concept of Finite Automata
Example

Input Letter
Σ = {a,b}

States
x, y, z where x is an initial state and z is final state.

Transitions
At state x reading a go to state z,
At state x reading b go to state y,
At state y reading a, b go to state y
At state z reading a, b go to state z
Transition Table
These transitions can be expressed by the
following table called transition table

Reading a Reading b

x- z y

y y y

z+ z z
Transition Diagram of FA

It may be noted that the information of an FA, given


in the previous table, can also be depicted by the
following diagram, called the transition diagram, of
the given FA
a,b
y
b

x
a a,b

z
Regular Expression
• It may be noted that this language may be
expressed by the regular expression
a(a + b)*
Part of DFA
Formal Definition of a Deterministic Finite Automaton

A DFA is a five-tuple:

M = (Q, Σ, δ, q0, F)

set
Q A finite set of states
of states
Σ A finite input alphabet
input alphabet
q0 The initial/starting state, q0 is in Q
F A set of final/accepting states, which is a subset of Q
δ A transition function, which is a total function from Q x Σ to Q
transition function
δ: (Q x Σ) –> Q δ is defined for any q in Q and s in Σ, and
δ(q,s) = q’ initial
is equal state
to some state q’ in Q, could be q’=q

Intuitively, δ(q,s) is the state entered by M after reading symbol s while in state q.
set of final states
Example.1 of DFA
Example.1 of DFA
• This DFA accepts { } because it can go from the
initial state to the accepting state (also the
initial state) without reading any symbol of the
alphabet i.e. by reading an empty string . It
accepts nothing else because any non-empty
symbol would take it to state 1, which is not
an accepting state, and it stays there.
Example.2 of DFA
Example.2 of DFA
• This DFA does not accept any string because it
has no accepting state. Thus the language it
accepts is the empty set .
Example.3 of DFA

S0 a S1 b S2

String Accepted by ab
Example.4 of DFA

S0
x S1
y S2
z S3

String Accepted by xyz


Example.3 of DFA
c
S2
b S1

S0

d S3 e
S4

String Accepted by ac+de


Construct DFA to accept (0+1)*

1
Construct DFA to accept (0+1)*(00+01)

1 0

0 0

1 1

0
1
Construct DFA to accept(0+1)*00(0+1)*

1 0

0 0

1
1
Construct DFA to accept 00(0+1)*

0
0 0

1 1
1

0 1
Nondeterministic Finite Automaton

• State has є-transition

• State has more than one edge leaving if for


the same input character
Nondeterministic Finite Automaton
Example.1 of NFA
NFAs represent regular languages, and can be
used to test whether any string is in the
language it represents. Consider the following
regular language over the alphabet  = { a, b }
(represented by the regular expression)
aa*b
Example.1 of NFA
This language can be represented by the
following NFA.
Example.2 of NFA
(a+b)*aa(a+b)*

a,b

a a a,b
Formal Definition of
Nondeterministic Finite
Automaton
Describe the Formal Definition of
Nondeterministic Finite Automaton
Nondeterministic Finite Automaton (NFA)

q0 a
q1

a,b
• L(M) = the set of strings that have at least one accepting
sequence
• In the example above, L(M) = {xa | x  {a,b}*}
• A DFA is a special case of an NFA:
– An NFA that happens to be deterministic: there is
exactly one transition from every state on every symbol
– So there is exactly one possible sequence for every
string
• NFA is not necessarily deterministic
Question No.1

Σ = {0,1}
States: x, y, where x is both initial and final state.
Transitions:
At state x reading 0 or 1 go to state y.
At state y reading 0 or 1 go to state x
Find Transition Table, Transition Diagram and
Regular Expression
Question No.2

Describe Formal Definition of Deterministic


Finite Automaton
Question No.3

Construct DFA to accept (11+00)

Construct NFA to accept (11+00)


Question No.4

Construct DFA to accept (0011)

Construct NFA to accept (0011)


Question No.5
Construct DFA to accept Null String
(Λ).

 (a+b) is a Regular Expression


Construct DFA and NFA
 abcd is a Regular Expression
Construct DFA and NFA

You might also like