Title: LING124 Finite state automata
1LING124 Finite state automata
2Class outline
- Finite state automata (FSA)
- Definition
- FSA as an acceptor/recognizer
- Deterministic vs. nondeterministic FSA
- Determinization
- Finite state transducers (FST)
- Weighted finite state machines
- Application in speech technology
- Talk with Dr. Roula Svorou
9/30
3Finite state automata (FSA)
- An FSA is a quintuple ltS, so, F, S, dgt
- S Set of states
- so Initial state
- F Set of final states
- S Alphabet (a set of symbols)
- d Transition relation
- dS x S -gt S
- dS x S U e -gt S, where e is a null symbol, for
(nondeterministic) FSA with epsilon transition
4Representing FSA
5Language
- FSA can function as a string acceptor
- Start from the initial state
- For each symbol of the input string, move to the
state at the other end of the edge which is
labeled by the symbol (transition) - FSA accepts a string if one arrives in a final
state given the last symbol of the input string - The language accepted by an FSA is a set of all
strings that is accepted by the FSA
6Language (2)
- More formally
- An FSA accepts/recognizes a string w if there is
a sequence of transitions from the initial state
(s0) to a final state sF?F where the input
symbols of w appear in the right order
where
7Language Example
What are the strings that the FSA below accepts?
8Deterministic vs. nondeterministic
- Deterministic FSA (DFA)
- A unique transition for a state-symbol pair
- d S x S -gt S is a function rather than a
relation - Nondeterministic FSA (NFA)
- One or more transitions for a state-symbol pair
- d can also be expressed as a function
- d S x S -gt 2S, where 2S is a power set (the set
of all subsets) of S - There is a DFA equivalent to any NFA
- Two FSAs are equivalent if the languages they
accept are the same
9Example
10Another example
11Why interested in DFA?
- A nondeterministic FSA (NFA) typically has less
states and edges than its deterministic
counterpart (DFA) - However, since there can be multiple paths for a
given state-symbol pair in NFA, one must try (in
the worst case) all of the alternatives to see if
NFA does accept the input string -gt Efficiency in
recognition
12Determinization
- Basic idea
- A state-symbol pair is mapped to a subset of
states in NFA (recall d S x S -gt 2S ) - A state-symbol pair is mapped to a state in DFA
(recall d S x S -gt S ) - So we convert each subset of states that is
reachable from the initial state in NFA into a
state in DFA and redefine the transitions
13Determinization algorithm
- Create a queue (Q)
- Create a node labeled s0 and put it in Q
- While Q is not empty, take out its first subset
(Si) - Refer to NFA, and for each symbol, list sets of
states reachable from Si (call this list X) - For each subset (Sj) in X
- Create a node labeled Sj and put it in Q, if it
doesnt already exist - If any member of Sj is a final state in NFA, Sj
becomes a final state - Add transition from Si to Sj
14Determinization (1)
- Create a queue (Q)
- Create a node labeled s0 and put it in Q
15Determinization (2)
- While Q is not empty, take out its first subset
(Si) - Refer to NFA, and for each symbol, list sets of
states reachable from Si (call this list X)
Si 0
X d(0,a) d(0,a) 0,1 d(0,b) d(0,b)
0 d(0,c) d(0,c) 0
16Determinization (3)
- For each subset (Sj) in X
- Create a node labeled Sj and put it in Q, if it
doesnt already exist - If any member of Sj is a final state in NFA, Sj
becomes a final state - Add transition from Si to Sj
X d(0,a) d(0,a) 0,1 d(0,b) d(0,b)
0 d(0,c) d(0,c) 0
Si 0 Sj 0,1
17Determinization (4)
- For each subset (Sj) in X
- Create a node labeled Sj and put it in Q, if it
doesnt already exist - If any member of Sj is a final state in NFA, Sj
becomes a final state - Add transition from Si to Sj
X d(0,a) d(0,a) 0,1 d(0,b) d(0,b)
0 d(0,c) d(0,c) 0
Si 0 Sj 0
18Determinization (5)
- While Q is not empty, take out its first subset
(Si) - Refer to NFA, and for each symbol, list sets of
states reachable from Si (call this list X)
Si 0,1
X d(0,1,a) d(0,a) U d(1,a)
0,1 d(0,1,b) d(0,b) U d(1,b)
0,2 d(0,1,c) d(0,c) U d(1,c) 0
19Determinization (6)
- For each subset (Sj) in X
- Create a node labeled Sj and put it in Q, if it
doesnt already exist - If any member of Sj is a final state in NFA, Sj
becomes a final state - Add transition from Si to Sj
X d(0,1,a) d(0,a) U d(1,a)
0,1 d(0,1,b) d(0,b) U d(1,b)
0,2 d(0,1,c) d(0,c) U d(1,c) 0
Si 0,1 Sj 0,1
20Determinization (7)
- For each subset (Sj) in X
- Create a node labeled Sj and put it in Q, if it
doesnt already exist - If any member of Sj is a final state in NFA, Sj
becomes a final state - Add transition from Si to Sj
X d(0,1,a) d(0,a) U d(1,a)
0,1 d(0,1,b) d(0,b) U d(1,b)
0,2 d(0,1,c) d(0,c) U d(1,c) 0
Si 0,1 Sj 0,2
21Determinization (8)
- For each subset (Sj) in X
- Create a node labeled Sj and put it in Q, if it
doesnt already exist - If any member of Sj is a final state in NFA, Sj
becomes a final state - Add transition from Si to Sj
X d(0,1,a) d(0,a) U d(1,a)
0,1 d(0,1,b) d(0,b) U d(1,b)
0,2 d(0,1,c) d(0,c) U d(1,c) 0
Si 0,1 Sj 0
22Determinization (9)
- While Q is not empty, take out its first subset
(Si) - Refer to NFA, and for each symbol, list sets of
states reachable from Si (call this list X)
Si 0,2
X d(0,2,a) d(0,a) U d(2,a)
0,1 d(0,2,b) d(0,b) U d(2,b)
0 d(0,2,c) d(0,c) U d(2,c) 0,3
23Determinization (10)
- For each subset (Sj) in X
- Create a node labeled Sj and put it in Q, if it
doesnt already exist - If any member of Sj is a final state in NFA, Sj
becomes a final state - Add transition from Si to Sj
X d(0,2,a) d(0,a) U d(2,a)
0,1 d(0,2,b) d(0,b) U d(2,b)
0 d(0,2,c) d(0,c) U d(2,c) 0,3
Si 0,2 Sj 0,1
24Determinization (11)
- For each subset (Sj) in X
- Create a node labeled Sj and put it in Q, if it
doesnt already exist - If any member of Sj is a final state in NFA, Sj
becomes a final state - Add transition from Si to Sj
X d(0,2,a) d(0,a) U d(2,a)
0,1 d(0,2,b) d(0,b) U d(2,b)
0 d(0,2,c) d(0,c) U d(2,c) 0,3
Si 0,2 Sj 0
25Determinization (12)
- For each subset (Sj) in X
- Create a node labeled Sj and put it in Q, if it
doesnt already exist - If any member of Sj is a final state in NFA, Sj
becomes a final state - Add transition from Si to Sj
X d(0,2,a) d(0,a) U d(2,a)
0,1 d(0,2,b) d(0,b) U d(2,b)
0 d(0,2,c) d(0,c) U d(2,c) 0,3
Si 0,2 Sj 0,3
26Determinization (13)
- While Q is not empty, take out its first subset
(Si) - Refer to NFA, and for each symbol, list sets of
states reachable from Si (call this list X)
Si 0,3
X d(0,3,a) d(0,a) U d(3,a)
0,1 d(0,3,b) d(0,b) U d(3,b)
0 d(0,3,c) d(0,c) U d(3,c) 0
27Determinization (14)
- For each subset (Sj) in X
- Create a node labeled Sj and put it in Q, if it
doesnt already exist - If any member of Sj is a final state in NFA, Sj
becomes a final state - Add transition from Si to Sj
X d(0,3,a) d(0,a) U d(3,a)
0,1 d(0,3,b) d(0,b) U d(3,b)
0 d(0,3,c) d(0,c) U d(3,c) 0
Si 0,3 Sj 0,1
28Determinization (15)
- For each subset (Sj) in X
- Create a node labeled Sj and put it in Q, if it
doesnt already exist - If any member of Sj is a final state in NFA, Sj
becomes a final state - Add transition from Si to Sj
X d(0,3,a) d(0,a) U d(3,a)
0,1 d(0,3,b) d(0,b) U d(3,b)
0 d(0,3,c) d(0,c) U d(3,c) 0
Si 0,3 Sj 0
29Good?