CSCI-2400 Models of Computation
CSCI-2400 Models of Computation
Models of Computation
1
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
Automaton
temporary memory
Automaton
input memory
CPU
output memory
Program memory
8
Different Kinds of Automata
Automata are distinguished by the temporary memory
9
Finite Automaton
temporary memory
input memory
Finite
Automaton
output memory
input memory
Pushdown
Automaton
output memory
input memory
Turing
Machine
output memory
14
A language is a set of strings
15
Alphabets and Strings
We will use small alphabets: a, b
Strings
a
ab u ab
abba v bbbaaa
baba w abba
aaabbbaabab
16
String Operations
w a1a2 an abba
v b1b2 bm bbbaaa
Concatenation
17
w a1a2 an ababaaabbb
Reverse
R
w an a2a1 bbbaaababa
18
String Length
w a1a2 an
Length: w n
Examples: abba 4
aa 2
a 1
19
Length of Concatenation
uv u v
Example: u aab, u 3
v abaab, v 5
uv aababaab 8
uv u v 3 5 8
20
Empty String
A string with no letters:
Observations: 0
w w w
String Substring
abbab ab
abbab abba
abbab b
abbab bbab
22
Prefix and Suffix
abbab
Prefixes Suffixes
abbab w uv
a bbab
prefix
ab bab
suffix
abb ab
abba b
abbab
23
Another Operation
n
w ww w
n
0
Definition: w
abba
0
24
The * Operation
* : the set of all possible strings from
alphabet
a, b
* , a, b, aa, ab, ba, bb, aaa, aab,
25
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,
26
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}
27
Note that:
Sets { } {}
Set size {} 0
n n
An infinite language L {a b : n 0}
ab
L abb L
aabb
aaaaabbbbb
29
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}
31
Concatenation
32
Another Operation
Definition: n
L LL L
n
a, b a, b a, b a, b
3
a , bba , aaa 0
33
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
34
Star-Closure (Kleene *)
0 1 2
Definition: L* L L L
Example:
,
a, bb,
a, bb *
aa , abb, bba , bbbb,
aaa, aabb, abba, abbbb,
35
Positive Closure
1 2
Definition: L L L
L *
a, bb,
a, bb aa, abb, bba, bbbb,
aaa, aabb, abba, abbbb,
36