Professional Documents
Culture Documents
Fall 2008
Automata theory
and formal languages
Andrej Bogdanov
http://www.cse.cuhk.edu.hk/~andrejb/csc3130
A simple computer
H
ITC
W
S
BATTERY
input: switch
output: light bulb
actions: flip
switch
states: on, of
A simple computer
H
ITC
W
S
f
BATTERY
start
on
of
f
input: switch
output: light bulb
actions: f for flip
switch
states: on, of
Another computer
1
1
start
of
BATTERY
1
of
1
2
of
on
A design problem
1
BATTERY
2
3
A design problem
Such devices are difficult to reason about,
because they can be designed in an infinite
number of ways
By representing them as abstract
computational devices, or automata, we
will learn how to answer such questions
Turing
Machines
time-bounded
Turing
Machines
Push-down automata
These devices are related to grammars, which
describe the structure of programming (and
natural) languages
Xian
Shanghai
Guangzhou
Hong Kong
Problems
Examples of problems we will consider
Strings
A string over alphabet is a finite sequence
of symbols in .
The empty string will be denoted by
Examples
abfbz is a string over 1 = {a, b, c, d, , z}
9021 is a string over 2 = {0, 1, , 9}
ab#bc is a string over 3 = {a, b, , z, #}
))()(() is a string over 4 = {(, )}
Languages
Finite Automata
of
f
Example
0
q0
1
1
q1
0,1
0
q2
states
transition function
alphabet = {0, 1}
start state Q = {q0, q1, q2}
inputs
0 1
initial state q0
q0 q0 q1
accepting states F = {q0, q1}
q1 q2 q1
q2 q2 q2
Language of a DFA
M:
on
of
f
Examples
0
0
1
q0
q1
0
q0
1
1
0
0
q0
q1
1
1
q1
0,1
0
q2
Examples
Construct a DFA that accepts the language
L = {010,
1}
( = {0, 1}
)
Examples
Construct a DFA that accepts the language
( = {0, 1}
)
L = {010,
1}
Answer
0
q0
1
0
q01
q010
1
0, 1
q1
0, 1
qdie
0, 1
Examples
Construct a DFA over alphabet {0, 1} that
accepts all strings that end in 101
Examples
Construct a DFA over alphabet {0, 1} that
accepts all strings that end in 101
Hint: The DFA must remember the last 3
bits of the string it is reading
Examples
Construct a DFA over alphabet {0, 1} that
accepts all strings that end in 101
Sketch of answer:
q
1
1
0
q
q