Professional Documents
Culture Documents
Chapter No.2
• Finite Automata
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
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
S0
d S3 e
S4
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
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