Deterministic Finite State Automata: Sipser Pages 31-46
Deterministic Finite State Automata: Sipser Pages 31-46
– Q is a set of states
– Σ is the alphabet (of input symbols)
– δ: Q × Σ → Q is the transition function
– q0 ∈ Q -- the start state
– F ⊆ Q -- final states
– Page 35 of Sipser
Example
• In our example,
• Q={q0,q1,q2},
Σ={0,1}, 1 1
q0=q0, q0 0 q1 0 q2 0,1
F={q2},
• and
δ is given by 6 equalities
• δ(q0,0)=q1,
• δ(q0,1)=q0,
• δ(q2,1)=q2
• …
Transition Table
Q0 Q1 Q0
Q1 Q2 Q1
*Q2 Q2 Q2
• δ 2B=2
Definition of Regular Languages
• A language is called regular if some finite
automaton accepts (i.e. a DFA accepts it)
• Page 40 in Sipser
Extension of δ to Strings
• Given a state q and a string w, there is a unique path labeled w
that starts at q (why?). The endpoint of that path is denoted
δ(q,w)
– δ(q,ε)=q
– δ(q,x:xs)= δ(δ(q,x),xs)
q0 0 q1 0 q2 0,1
Implementation and precise arguments need
the formal definition.
More formally
L(A)={w | δ(Start(A),w) ∈ Final(A)}
Example:
Find a DFA whose language is the set of all strings over {a,b,c}
that contain aaa as a substring.
DFA’s as data structures
data DFA q s =
DFA [q] -- states
[s] -- symbols
(q -> s -> q) -- delta
q -- start state
[q] -- accept states
acceptDFA2 dfa w =
elem (deltaBar dfa (start dfa) w)
(accept dfa)
An Example
DFA Q {0, 1, 2}
Sigma {0, 1}
Delta 0 0 -> 0
0 1 -> 1
1 0 -> 2
1 1 -> 0
2 0 -> 1
2 1 -> 2
q0 0
Final {2}
Missing alphabet
• I sometimes draw a state transition diagram
where some nodes do not have an edge
labeled with every letter of the alphabet, by
convention we add a new (dead) state where
all missing edges terminate.
1
A
B
2
Review
• DFAs are a computation mechanism
• They compute whether some string is in some language
• {w | length w = 3 }
• Σ = {m,n,p}
• {w | w represents an integer }
• Σ = {a,b,c,0,2,1}