Finite State Automata
Finite State Automata
Automata
Natalie Parde
UIC CS 421
• Computational models that can generate
regular languages (such as those
specified by a regular expression)
What are • Also used in other NLP applications that
function by transitioning between finite
finite state states
• Dialogue systems
automata? • Morphological parsing
• Singular: Finite State Automaton (FSA)
• Plural: Finite State Automata (FSAs)
b a a !
q0 q1 q2 q3 q4
we know
about this b a a !
FSA? q0 q1 q2 q3 q4
b a a !
q0 q1 q2 q3 q4
a
Natalie Parde - UIC CS 421
Regex that this FSA matches: baa+!
b a a !
q0 q1 q2 q3 q4
a
Test String: baa!
Natalie Parde - UIC CS 421
Regex that this FSA matches: baa+!
b a a !
q0 q1 q2 q3 q4
a
Test String: baa!
Natalie Parde - UIC CS 421
Regex that this FSA matches: baa+!
b a a !
q0 q1 q2 q3 q4
a
Test String: baa!
Natalie Parde - UIC CS 421
Regex that this FSA matches: baa+!
b a a !
q0 q1 q2 q3 q4
a
Test String: baa!
Natalie Parde - UIC CS 421
Regex that this FSA matches: baa+!
b a a !
q0 q1 q2 q3 q4
a
Test String: baa!
Natalie Parde - UIC CS 421
Regex that this FSA matches: baa+!
b a a !
q0 q1 q2 q3 q4
a
Test String: baa!
Natalie Parde - UIC CS 421
Regex that this FSA matches: baa+!
b a a !
q0 q1 q2 q3 q4
a
Test String: baa!
Natalie Parde - UIC CS 421
Regex that this FSA matches: baa+!
b a a !
q0 q1 q2 q3 q4
a
Test String: baabaa!
Natalie Parde - UIC CS 421
Regex that this FSA matches: baa+!
b a a !
q0 q1 q2 q3 q4
a
Test String: baabaa!
Natalie Parde - UIC CS 421
Regex that this FSA matches: baa+!
b a a !
q0 q1 q2 q3 q4
a
Test String: baabaa!
Natalie Parde - UIC CS 421
Regex that this FSA matches: baa+!
b a a !
q0 q1 q2 q3 q4
a
Test String: baabaa!
Natalie Parde - UIC CS 421
Regex that this FSA matches: baa+!
b a a !
q0 q1 q2 q3 q4
a
Test String: baabaa!
Natalie Parde - UIC CS 421
Regex that this FSA matches: baa+!
b a a !
q0 q1 q2 q3 q4
a
Test String: baabaa!
Natalie Parde - UIC CS 421
Regex that this FSA matches: baa+!
b a a !
q0 q1 q2 q3 q4
a
Test String: baabaa!
Natalie Parde - UIC CS 421
Note: More than one FSA can correspond
to the same regular language!
b a a !
Test String: q0 q1 q2 q3 q4
baaa!
a
b a a !
Test String: q0 q1 q2 q3 q4
baaa!
a
Natalie Parde - UIC CS 421
• A finite state automaton can be specified by
enumerating the following properties:
• The set of states, Q
• A finite alphabet, Σ
Formal • A start state, q0
Definition • A set of accept/final states, F⊆Q
• A transition function or transition matrix
between states, δ(q,i)
• δ(q,i): Given a state q∈Q and input i∈Σ,
δ(q,i) returns a new state q’∈Q.
q0 q1 q2 q4 q5 q6 q7
dollars cents
Accept States
Natalie Parde - UIC CS 421
State transitions in FSAs can be
represented using tables.
b a a !
q0 q1 q2 q3 q4
a
Next Item in Sequence
b a ! <end>
Currently in State
q0
q1
q2
q3
q4
Natalie Parde - UIC CS 421
State transitions in FSAs can be
represented using tables.
b a a !
q0 q1 q2 q3 q4
a
Next Item in Sequence
b a ! <end>
Currently in State
q0 q1
q1
q2 Go to State
q3
q4
Natalie Parde - UIC CS 421
State transitions in FSAs can be
represented using tables.
b a a !
q0 q1 q2 q3 q4
a
Next Item in Sequence
b a ! <end>
Currently in State
q0 q1 L L L
q1
q2 Go to State
q3
q4
Natalie Parde - UIC CS 421
State transitions in FSAs can be
represented using tables.
b a a !
q0 q1 q2 q3 q4
a
Next Item in Sequence
b a ! <end>
Currently in State
q0 q1 L L L
q1 L q2
q2 Go to State
q3
q4
Natalie Parde - UIC CS 421
State transitions in FSAs can be
represented using tables.
b a a !
q0 q1 q2 q3 q4
a
Next Item in Sequence
b a ! <end>
Currently in State
q0 q1 L L L
q1 L q2 L L
q2 L q3 Go to State
q3
q4
Natalie Parde - UIC CS 421
State transitions in FSAs can be
represented using tables.
b a a !
q0 q1 q2 q3 q4
a
Next Item in Sequence
b a ! <end>
Currently in State
q0 q1 L L L
q1 L q2 L L
q2 L q3 L L Go to State
q3 L q3
q4
Natalie Parde - UIC CS 421
State transitions in FSAs can be
represented using tables.
b a a !
q0 q1 q2 q3 q4
a
Next Item in Sequence
b a ! <end>
Currently in State
q0 q1 L L L
q1 L q2 L L
q2 L q3 L L Go to State
q3 L q3 q4
q4
Natalie Parde - UIC CS 421
State transitions in FSAs can be
represented using tables.
b a a !
q0 q1 q2 q3 q4
a
Next Item in Sequence
b a ! <end>
Currently in State
q0 q1 L L L
q1 L q2 L L
q2 L q3 L L Accept!
q3 L q3 q4 L
q4 L L L J
Natalie Parde - UIC CS 421
State transition tables simplify the
process of determining whether your input
will be accepted by the FSA.
• For a given sequence of items to match, begin in the start
state with the first item in the sequence
• Consult the table …is a transition to any other state
permissible with the current item?
• If so, move to the state indicated by the table
• If you make it to the end of your sequence and to a final state,
accept
Non-Deterministic
Deterministic FSA: At
FSA: At one or more
each point in processing
points in processing a
a sequence, there is one
sequence, there are
unique thing to do (no
multiple permissible next
choices!)
steps (choices!)
b a a !
q0 q1 q2 q3 q4
a
b a a !
q0 q1 q2 q3 q4
a
Natalie Parde - UIC CS 421
Deterministic or Non-Deterministic?
b a a !
If input is !, do this
Deterministic! q0 q1 q2 q3 q4
If input is a, do this
a
b a a !
q0 q1 q2 q3 q4
a
Natalie Parde - UIC CS 421
Deterministic or Non-Deterministic?
b a a !
If input is !, do this
Deterministic! q0 q1 q2 q3 q4
If input is a, do this
a
b a a !
If input is a, do ?
Non-Deterministic! q0 q1 q2 q3 q4
a
Natalie Parde - UIC CS 421
Every non-
deterministic • This means that both are equally
FSA can be powerful!
converted to a • Deterministic FSAs can accept as many
deterministic languages as non-deterministic ones
FSA.
q0 q1 q2 q3 q4
q0 q1 q2 q3 q4
q0 q1 q2 q3 q4
q0 q1 q2 q3 q4
q0 q1 q2 q3 q4
q0 q1 q2 q3 q4
q0 q1 q2 q3 q4
q0 q1 q2 q3 q4
q0 q1 q2 q3 q4
q0 q1 q2 q3 q4