Models of Computation
Computation
CPU memory
2
temporary memory
input memory
CPU
output memory
Program memory
3
3
Example: f ( x) x
temporary memory
input memory
CPU
output memory
Program memory
compute xx
2
compute x x
4
3
f ( x) x
temporary memory
input memory
x2
CPU
output memory
Program memory
compute xx
2
compute x x
5
3
temporary memory f ( x) x
z 2*2 4
f ( x) z * 2 8
input memory
x2
CPU
output memory
Program memory
compute xx
2
compute x x
6
3
temporary memory f ( x) x
z 2*2 4
f ( x) z * 2 8
input memory
x2
CPU
f ( x) 8
Program memory output memory
compute xx
2
compute x x
7
Automata theory
H
I TC
SW
BATTERY
input: switch
output: light bulb
actions: flip switch
states: on, off
A simple “computer”
H
I TC
SW
f
BATTERY
start off on
f
input: switch
bulb is on if and only if
output: light bulb
there was an odd number of
actions: f for “flip switch” flips
states: on, off
Another “computer”
1
1 start off off
1
BATTERY 2 2 2 2
1
2 on
off 1
inputs: switches 1 and 2
bulb is on if and only if
actions: 1 for “flip switch 1”
both switches were flipped
actions: 2 for “flip switch 2” an odd number of times
states: on, off
Automaton
temporary memory
Automaton
input memory
CPU
output memory
Program memory
12
Different Kinds of Automata
Automata are distinguished by the temporary memory
13
Finite Automaton
temporary memory
input memory
Finite
Automaton
output memory
input memory
Pushdown
Automaton
output memory
input memory
Turing
Machine
output memory
18
A language is a set of strings
19
Alphabets and Strings
We will use small alphabets: a, b
Strings
a
ab u ab
abba v bbbaaa
baba w abba
aaabbbaabab
20
String Operations
w a1a2 an abba
v b1b2 bm bbbaaa
Concatenation
21
w a1a2 an ababaaabbb
Reverse
R
w an a2a1 bbbaaababa
22
String Length
w a1a2 an
Length: w n
Examples: abba 4
aa 2
a 1
23
Length of Concatenation
uv u v
Example: u aab, u 3
v abaab, v 5
uv aababaab 8
uv u v 3 5 8
24
Empty String
A string with no letters:
Observations: 0
w w w
String Substring
abbab ab
abbab abba
abbab b
abbab bbab
26
Prefix and Suffix
abbab
Prefixes Suffixes
abbab w uv
a bbab
prefix
ab bab
suffix
abb ab
abba b
abbab
27
Another Operation
n
w ww w
n
0
Definition: w
abba
0
28
The * Operation
* : the set of all possible strings from
alphabet
a, b
* , a, b, aa, ab, ba, bb, aaa, aab,
29
The + Operation
: the set of all possible strings from
alphabet except
a, b
* , a, b, aa, ab, ba, bb, aaa, aab,
*
a, b, aa, ab, ba, bb, aaa, aab,
30
Languages
A language is any subset of *
Example: a, b
* , a, b, aa, ab, ba, bb, aaa,
Languages:
a, aa, aab
{ , abba, baba, aa, ab, aaaaaa}
31
Note that:
Sets { } {}
Set size {} 0
n n
An infinite language L {a b : n 0}
ab
L abb L
aabb
aaaaabbbbb
33
Operations on Languages
The usual set operations
R R
Definition: L {w : w L}
n n
L {a b : n 0}
R n n
L {b a : n 0}
35
Concatenation
36
Another Operation
Definition: n
L LL L
n
a, b a, b a, b a, b
3
a , bba , aaa 0
37
More Examples
n n
L {a b : n 0}
2 n n m m
L {a b a b : n, m 0}
2
aabbaaabbb L
38
Star-Closure (Kleene *)
0 1 2
Definition: L* L L L
Example:
,
a, bb,
a, bb *
aa , abb, bba , bbbb,
aaa, aabb, abba, abbbb,
39
Positive Closure
1 2
Definition: L L L
L *
a, bb,
a, bb aa, abb, bba, bbbb,
aaa, aabb, abba, abbbb,
40