Lecture 5
Lecture 5
An informal definition
o A diagram with a finite number of states represented by circles
o An arrow points to one of the states, the unique start state
o Double circles mark any number of the states as accepting states
a
A B A → aB
Deterministic Finite Automaton (DFA)
a
A B A→aB
Start Final
Finite Automaton (FA)
For every state, for every symbol in Σ, there is exactly one arrow
labeled with that symbol going to another state (or back to the
same state).
Given any string over Σ, a DFA can read the string and follow its
state-to-state transitions.
At the end of the string, if it is in an accepting state, we say it
accepts the string. Otherwise it rejects.
The language defined by a DFA is the set of strings in Σ * that it
accepts.
Deterministic Finite Automaton (DFA)
Example1:
This DFA defines {xa | x {a,b}*}
Formally, M = (Q, Σ, , q0, F), where
Q = {q0,q1}
a b
Σ = {a,b} Give the transition table
q0 q1 q0
F = {q1}
q1 q1 q0
Start sate q0
(q0,a) = q1, (q0,b) = q0, (q1,a) = q1, (q1,b) = q0
We could just say M = ({q0, q1}, {a,b}, , q0, {q1})
Deterministic Finite Automaton (DFA)
Example2:
Q = {q0 , q1 ,q2},
Σ = {a,b,c}
Start sate q0
a b c
F = {q2}
q0 q0 q0 q1
q1 q1 q1 q2
q2 q2 q2 q2
Example3:
Example3:
aac
• Ⱶ [q0 , aac]
• Ⱶ [q0 , ac]
• Ⱶ [q0 , c]
• Ⱶ [q1 , λ]
rejected
Example4:
Give finite automata for the set of strings over {a, b, c } which all the a’s precede
the b’s, which in turn precede the c’s. without the null string .
a+b+c+
G: q0 → a q1
q1 → a q1 / b q2
q2 → b q2 / c q3
q3 → c q3 / λ
Deterministic Finite Automaton (DFA)
Example5:
Give finite automata for the set of strings over {a, b,}
i) that contain bb. ii) that contain bbb
Example5:
Deterministic Finite Automaton (DFA)
DFA Applications
We have seen how DFAs can be used to define formal
languages. In addition to this formal use, DFAs have
practical applications. DFA-based pieces of code lie at the
heart of many commonly used computer programs.
Deterministic Finite Automaton (DFA)
DFA Applications
Programming language processing
• Scanning phase: dividing source file into "tokens" (keywords, identifiers, constants, etc.),
skipping whitespace and comments
Signal processing
• Speech processing and other signal processing systems use finite state models to
transform the incoming signal