Sei sulla pagina 1di 8

Deterministic Finite Automata (DFA)

Deterministic finite-state automaton M = (Q , S , d , q


0
, F)
where
Q is a finite set of states
S is the input alphabet (a finite set of symbols)
d is the transition function
One transition per state-input combination
q
0
is the initial state
F is the set of final states (F Q)

Transition function (mapping) d : Q x S Q
d(q, a) = p in state q with input a, the new state is p

Transition mapping extension d : Q x S
*
Q
d(q, L) = q no change of state, unless reading an input
d(q, wa) = d(d(q,w), a) where w is a string in S
*


Reading wa means first reading w (and going to some state p),
and then reading a (and going to a next state r)

String recognition
A string w is recognized (accepted) by the DFA
if and only if d(q
0
, w) is a state in F

The language accepted by M, denoted L(M), is:
The set of strings recognized by the DFA M, that is
L(M) = { w S
*
| d(q
o
, w) F }


What Language Is Recognized?







M = ( {q
0
, q
1
, q
2
}, {0, 1}, d, q
0
, {q
0
, q
1
} )

Transition function d
d(q
0
, 0) = q
0
d(q
0
, 1) = q
1
d(q
1
, 0) = q
0
q
0
q
2
q
1
1 1
0, 1
0 0
d(q
1
, 1) = q
2
d(q
2
, 0) = q
2
d(q
2
, 1) = q
2
Start
What Language Is Recognized?
q
0
q
2
q
1
1 1
0, 1
0 0
State
Inputs
0 1
q
0
q
0
q
1

q
1
q
0
q
2

q
2
q
2
q
2

Transition table
Start
The language L(M)
accepted by the DFA
is the set of strings with
no two consecutive 1s
MWGC - f

Start
WC - MG

MWC - G

C - MWG

MGC - W

G - MWC

W - MGC

MWG - C

f - MWGC
MG - WC

g g g g
g
g
g
g
m
m
m
m
w
w
w
w
c c
c
c
A man with a wolf, a goat, and a cabbage, wants to cross a river
with a small boat where he can take only one passenger
The inputs: the mans actions
m he sails alone
g he takes the goat
w he takes the wolf
c he takes the cabbage
Deterministic Finite Automata (DFA)
Let M = (Q , S , d , q
0
, F) be a DFA
where
|Q| = N (the number of states is N)
|S| = k (the number of inputs is k)

How many DFA can we build ?
there are N possible initial states q
0

since F can be any subset of Q, there are 2
N
possible Fs
the transition function d: Q x S Q
can have N possible values for each of the Nk arguments
(state , input), that is, there are N x N x x N possibilities,
where the number of factors is Nk

Conclusion: There are N x 2
N
x N
Nk
possible DFA


Examples of DFA
S = { a , b }
Design a DFA that accepts all the words from S
*

Examples of DFA
S = { a , b }
Design a DFA that accepts no words from S
*

(that is, the language accepted by the DFA is an empty set)
the DFA has no final state
there is no path from the start state to any final state

Potrebbero piacerti anche