Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
Advanced Topics in Theoretical Computer Science
Fall 2012
Handout 1: Finite Automata
c Laura Kovács
⃝
1.1 Example. Check if a binary number is divisible by 3. While processing the input, we need to remember
not the entire processed portion x of the input, but only the remainder of x when divided by 3. This
remainder can be updated one input symbol at a time:
x≡0
x≡0
x≡1
x≡1
x≡2
x≡2
mod
mod
mod
mod
mod
mod
→
→
→
→
→
→
3
3
3
3
3
3
x0 ≡ 0
x1 ≡ 1
x0 ≡ 2
x1 ≡ 0
x0 ≡ 1
x1 ≡ 2
mod
mod
mod
mod
mod
mod
3
3
3
3
3
3
We remember “x ≡ 0 mod 3” in state a, and “x ≡ 1 mod 3” in state b, and “x ≡ 2 mod 3” in state c:
1
0
0
1
A
B
1
C
0
1.2 Definition of a finite automaton. A finite automaton M consists of
Q . . . a finite set of states (the state space),
Σ . . . a finite set of input symbols (the input alphabet),
δ: Q × Σ → Q . . . a transition function,
q0 ∈ Q . . . an initial (or start) state,
F ⊆ Q . . . a set of final (or accept) states.
In mathematics, we say that M is the 5-tuple (Q, Σ, δ, q0 , F ). In examples, it is often most intuitive to draw
the state diagram of M , which is a labeled digraph as shown in Example 1.1. For this example:
Q = {a, b, c},
Σ = {0, 1},
δ(a, 0) = a, δ(a, 1) = b, δ(b, 0) = c, etc.,
q0 = a,
F = {a}.
1.3 Language of a finite automaton. A run of M is a sequence
p0
a
→0
p1
a
→1
···
an−1
→
pn
with p0 , . . . , pn ∈ Q and a0 , . . . , an−1 ∈ Σ such that
(1) p0 = q0 ,
(2) pi+1 = δ(pi , ai ) for all i ∈ [0..n − 1].
The run accepts the input word a0 . . . an−1 if
1
(3) pn ∈ F .
The language of M is
L(M ) = {w ∈ Σ∗ | w is accepted by some run of M }.
The language of the automaton from Example 1.1 is the set of binary numbers that are divisible by 3. For
instance, the word 011 is accepted by the following run:
0
a → a
1
1
→ b →
a
By contrast, the word 010 is not accepted by any run; in particular, the run
0
a → a
1
0
→ b →
c
does not end in a final state.
2