other models
TRANSCRIPT
-
8/9/2019 Other Models
1/72
1
Other Models of
Computation
-
8/9/2019 Other Models
2/72
2
Models of computation:
Turing Machines
Recursive Functions
Post SystemsRewriting Systems
-
8/9/2019 Other Models
3/72
3
Churchs Thesis:
All models of computation are equivalent
Turings Thesis:
A computation is mechanical if and only ifit can be performed by a Turing Machine
-
8/9/2019 Other Models
4/72
4
Churchs and Turings Thesis are similar:
Church-Turing Thesis
-
8/9/2019 Other Models
5/72
5
Recursive Functions
An example function:
1)( 2 ! nnfDomain Range
3 1010)3( !f
-
8/9/2019 Other Models
6/72
6
We need a way to define functions
We need a set of basic functions
-
8/9/2019 Other Models
7/72
7
Zero function: 0)( !xz
Successor function: 1)( ! xxs
Projection functions: 1211 ),( xxxp !
2212 ),( xxxp !
Basic Primitive Recursive Functions
-
8/9/2019 Other Models
8/72
8
Building complicated functions:
Composition: )),(),,((),( 21 yxgyxghyxf !
Primitive Recursion:
)),(),,(()1,( 2 yxfyxghyxf !
)()0,( 1 xgxf !
-
8/9/2019 Other Models
9/72
9
Any function built from
the basic primitive recursive functions
is called:
Primitive Recursive Function
-
8/9/2019 Other Models
10/72
10
A Primitive Recursive Function: ),( yxadd
xxadd !)0,( (projection)
)),(()1,( yxaddsyxadd !
(successor function)
-
8/9/2019 Other Models
11/72
11
5
)4())3((
)))0,3(((
))1,3(()2,3(
!
!
!
!
!
sss
addss
addsadd
-
8/9/2019 Other Models
12/72
12
),( yxmult
0)0,( !xmult
)),(,()1,( yxmultxaddyxmult !
Another Primitive Recursive Function:
-
8/9/2019 Other Models
13/72
13
Theorem:
The set of primitive recursive functions
is countable
Proof:
Each primitive recursive function
can be encoded as a string
Enumerate all strings in proper order
Check if a string is a function
-
8/9/2019 Other Models
14/72
14
Theorem
there is a function that
is not primitive recursive
Proof:
Enumerate the primitive recursive functions
-,,, 321 fff
-
8/9/2019 Other Models
15/72
15
Define function 1)()( ! ifig i
g differs from every if
g is not primitive recursive
END OF PROOF
-
8/9/2019 Other Models
16/72
16
A specific function that is not
Primitive Recursive:
Ackermanns function:
)),(,1()1,(
)1,1()0,(1),0(
yxAxAyxA
xAxAyyA
!
!
!
Grows very fast,
faster than any primitive recursive function
-
8/9/2019 Other Models
17/72
17
Q Recursive Functions
0),(such thatsmallest)),(( !! yxgyyxgyQ
Accermans function is a
Q Recursive Function
-
8/9/2019 Other Models
18/72
18
Primitive recursive functions
Q Recursive Functions
-
8/9/2019 Other Models
19/72
19
Post Systems
Have Axioms
Have Productions
Very similar with unrestricted grammars
-
8/9/2019 Other Models
20/72
20
Example: Unary Addition
Axiom: 1111 !
Productions:
11
11
321321
321321
VVVVVV
VVVVVV
!p!
!p!
-
8/9/2019 Other Models
21/72
21
111111111111111111 !!!
11 321321 VVVVVV !p!
11 321321 VVVVVV !p!
A production:
-
8/9/2019 Other Models
22/72
22
Post systems are good for
proving mathematical statements
from a set of Axioms
-
8/9/2019 Other Models
23/72
23
Theorem:
A language is recursively enumerableif and only if
a Post system generates it
-
8/9/2019 Other Models
24/72
24
Rewriting Systems
Matrix Grammars
Markov Algorithms
Lindenmayer-Systems
They convert one string to another
Very similar to unrestricted grammars
-
8/9/2019 Other Models
25/72
25
Matrix Grammars
Example:
PP pp
ppp
213
22112211
,:
,::
SSP
cbSSaSSPSSSP
A set of productions is applied simultaneously
Derivation:
aabbccccbbSaaScbSaSSSS 212121
-
8/9/2019 Other Models
26/72
26
PP pp
pp
p
21322112
211
,:,:
:
SScbSSaSS
SSS
}0:{ u! ncbaL nnn
Theorem:A language is recursively enumerable
if and only if
a Matrix grammar generates it
-
8/9/2019 Other Models
27/72
27
Markov Algorithms
Grammars that produce
P
Example:
P.p
p
p
S
SaSb
Sab
Derivation:
P SaSbaaSbbaaabbb
-
8/9/2019 Other Models
28/72
28
P.p
p
p
S
SaSb
Sab
}0:{u!
nbaL
nn
-
8/9/2019 Other Models
29/72
29
In general: }:{*P! wwL
Theorem:
A language is recursively enumerable
if and only ifa Markov algorithm generates it
-
8/9/2019 Other Models
30/72
30
Lindenmayer-Systems
They are parallel rewriting systems
Example: aaap
aaaaaaaaaaaaaaa Derivation:
}0:{ 2 u! naLn
-
8/9/2019 Other Models
31/72
31
Lindenmayer-Systems are not general
As recursively enumerable languages
Extended Lindenmayer-Systems: uyax p),,(
Theorem:
A language is recursively enumerableif and only if an
Extended Lindenmayer-System generates it
context
-
8/9/2019 Other Models
32/72
32
Computational Complexity
-
8/9/2019 Other Models
33/72
33
Time Complexity:
Space Complexity:
The number of steps
during a computation
Space used
during a computation
-
8/9/2019 Other Models
34/72
34
Time Complexity
We use a multitape Turing machine
We count the number of steps until
a string is accepted
We use the O(k) notation
-
8/9/2019 Other Models
35/72
35
Example: }0:{ u! nbaL nn
Algorithm to accept a string :w
Use a two-tape Turing machine
Copy the on the second tape
Compare the and
a
a b
-
8/9/2019 Other Models
36/72
36
|)(|wOCopy the on the second tape
Compare the and
a
a b
Time needed:
|)(| wO
Total time: |)(| wO
}0:{ u! nbaLnn
-
8/9/2019 Other Models
37/72
37
For string of length
time needed for acceptance:
}0:{ u! nbaLnn
n
)(nO
-
8/9/2019 Other Models
38/72
38
Language class: )(nDTIME
A Deterministic Turing Machineaccepts each string of length
in time
)(nDTIME
1L
2L 3L
)(nO
n
-
8/9/2019 Other Models
39/72
39
)(nDTIME
}0:{ unba nn
}{ww
-
8/9/2019 Other Models
40/72
40
In a similar way we define the class
))(( nTDTIME
)(nTfor any time function:
Examples: ),...(),( 32 nInI
-
8/9/2019 Other Models
41/72
41
Example: The membership problem
for context free languages
}grammarbygeneratedis:{ GwwL !
)( 3nDTIMEL (CYK - algorithm)
Polynomial time
-
8/9/2019 Other Models
42/72
42
Theorem:
)( knI
)( 1knI
)()( 1 kk nInI
-
8/9/2019 Other Models
43/72
43
Polynomial time algorithms: )( knI
Represent tractable algorithms:
For small we can compute the
result fast
k
-
8/9/2019 Other Models
44/72
44
)( knIP ! for all k
The class P
All tractable problems
Polynomial time
-
8/9/2019 Other Models
45/72
45
P
CYK-algorithm}{ nnba
- }{ww
-
8/9/2019 Other Models
46/72
46
Exponential time algorithms: )2( nDTIME
Represent intractable algorithms:
Some problem instances
may take centuries to solve
-
8/9/2019 Other Models
47/72
47
Example: the Traveling Salesperson Problem
Question: what is the shortest route that
connects all cities?
5 3
21
8 10
24
3
6
-
8/9/2019 Other Models
48/72
48
Question: what is the shortest route that
connects all cities?
5 3
21
8 10
24
3
6
-
8/9/2019 Other Models
49/72
49
)2()!( nDTIMEnDTIMEL }
Exponential time
Intractable problem
A solution: search exhuastively all
hamiltonian paths
L = {shortest hamiltonian paths}
-
8/9/2019 Other Models
50/72
50
Example: The Satisfiability Problem
Boolean expressions in
Conjunctive Normal Form:
ktttt .321
pi xxxxt ! .321
Variables
Question: is expression satisfiable?
-
8/9/2019 Other Models
51/72
51
)()( 3121 xxxx
Satisfiable: 1,1,0 321 !!! xxx
1)()( 3121 ! xxxx
Example:
-
8/9/2019 Other Models
52/72
52
2121 )( xxxx
Not satisfiable
Example:
-
8/9/2019 Other Models
53/72
53
e}satisfiablisexpression:{ wwL !
)2( nILFor variables:n
Algorithm:search exhaustively all the possible
binary values of the variables
exponential
-
8/9/2019 Other Models
54/72
54
Non-Determinism
Language class: )(nNTIME
A Non-Deterministic Turing Machineaccepts each string of length
in time
)(nNTIME
1L2L
3L
)(nO
n
-
8/9/2019 Other Models
55/72
55
Example: }{wwL !
Non-Deterministic Algorithmto accept a string :ww
Use a two-tape Turing machine
Guess the middle of the string
and copy on the second tape
Compare the two tapes
w
-
8/9/2019 Other Models
56/72
56
|)(| wO
Time needed:
|)(|wO
Total time: |)(|wO
}{wwL !
Use a two-tape Turing machine
Guess the middle of the string
and copy on the second tape
Compare the two tapes
w
-
8/9/2019 Other Models
57/72
57
)(nI
}{wwL !
-
8/9/2019 Other Models
58/72
58
In a similar way we define the class
))(( nTNTIME
)(nTfor any time function:
Examples: ),...(),( 32 nInI
-
8/9/2019 Other Models
59/72
59
Non-Deterministic Polynomial time algorithms:
)( knIL
-
8/9/2019 Other Models
60/72
60
)( knIP ! for all k
The class NP
Non-Deterministic Polynomial time
-
8/9/2019 Other Models
61/72
61
Example: The satisfiability problem
Non-Deterministic algorithm:
Guess an assignment of the variables
e}satisfiablisexpression:{ wwL !
Check if this is a satisfying assignment
-
8/9/2019 Other Models
62/72
62
Time for variables:n
)(nO
e}satis iablisexpression:{ wwL !
Total time:
Guess an assignment of the variables
Check if this is a satisfying assignment )(nO
)(nO
-
8/9/2019 Other Models
63/72
63
e}satisfiablisexpression:{ wwL !
NPL
The satisfiability problem is an - ProblemNP
-
8/9/2019 Other Models
64/72
64
Observation:
NPP
Deterministic
Polynomial
Non-Deterministic
Polynomial
-
8/9/2019 Other Models
65/72
65
Open Problem: ?NPP!
WE DO NOT KNOW THE ANSWER
-
8/9/2019 Other Models
66/72
66
Example: Does the Satisfiability problemhave a polynomial time
deterministic algorithm?
WE DO NOT KNOW THE ANSWER
Open Problem: ?NPP!
NP C l t
-
8/9/2019 Other Models
67/72
67
NP-Completeness
A problem is NP-complete if:
It is in NP
Every NP problem is reduced to it
(in polynomial time)
-
8/9/2019 Other Models
68/72
68
Observation:
If we can solve any NP-complete problemin Deterministic Polynomial Time (P time)
then we know:
NPP!
-
8/9/2019 Other Models
69/72
69
Observation:
If we prove thatwe cannot solve an NP-complete problem
in Deterministic Polynomial Time (P time)
then we know:
NPP{
-
8/9/2019 Other Models
70/72
70
Cooks Theorem:
The satisfiability problem is NP-complete
Proof:
Convert a Non-Deterministic Turing Machine
to a Boolean expression
in conjunctive normal form
-
8/9/2019 Other Models
71/72
71
Other NP-Complete Problems:
The Traveling Salesperson Problem
Vertex cover
Hamiltonian Path
All the above are reduced
to the satisfiability problem
Observations:
-
8/9/2019 Other Models
72/72
Observations:
It is unlikely that NP-completeproblems are in P
The NP-complete problems haveexponential time algorithms
Approximations of these problems
are in P