Escolar Documentos
Profissional Documentos
Cultura Documentos
Computation
1
Models of computation:
•Turing Machines
•Recursive Functions
•Post Systems
•Rewriting Systems
2
Church’s Thesis:
Turing’s Thesis:
3
Church’s and Turing’s Thesis are similar:
Church-Turing Thesis
4
Recursive Functions
An example function:
2
f ( n) n 1
Domain Range
3 f (3) 10 10
5
We need a way to define functions
6
Basic Primitive Recursive Functions
Zero function: z ( x) 0
Successor function: s ( x) x 1
p2 ( x1, x2 ) x2
7
Building complicated functions:
Composition: f ( x, y ) h( g1( x, y ), g 2 ( x, y ))
Primitive Recursion:
f ( x,0) g1( x)
f ( x, y 1) h( g 2 ( x, y ), f ( x, y ))
8
Any function built from
the basic primitive recursive functions
is called:
9
A Primitive Recursive Function: add ( x, y )
add ( x, y 1) s (add ( x, y ))
(successor function)
10
add (3,2) s (add (3,1))
s ( s (add (3,0)))
s ( s (3))
s ( 4)
5
11
Another Primitive Recursive Function:
mult ( x, y )
mult ( x,0) 0
12
Theorem:
The set of primitive recursive functions
is countable
Proof:
Each primitive recursive function
can be encoded as a string
Proof:
Enumerate the primitive recursive functions
f1, f 2 , f3 ,
14
Define function g (i ) fi (i ) 1
END OF PROOF 15
A specific function that is not
Primitive Recursive:
Ackermann’s function:
A(0, y ) y 1
A( x,0) A( x 1,1)
A( x, y 1) A( x 1, A( x, y ))
Accerman’s function is a
Recursive Function
17
Recursive Functions
18
Post Systems
• Have Axioms
• Have Productions
19
Example: Unary Addition
Axiom: 1 1 11
Productions:
V1 V2 V3 V11 V2 V31
V1 V2 V3 V1 V21 V31
20
A production:
V1 V2 V3 V11 V2 V31
1 1 11 11 1 111 11 11 1111
V1 V2 V3 V1 V21 V31
21
Post systems are good for
proving mathematical statements
from a set of Axioms
22
Theorem:
A language is recursively enumerable
if and only if
a Post system generates it
23
Rewriting Systems
They convert one string to another
• Matrix Grammars
• Markov Algorithms
• Lindenmayer-Systems
Example: P1 : S S1S2
P2 : S1 aS1, S2 bS2c
P3 : S1 , S2
Derivation:
n n n
L {a b c : n 0}
Theorem:
A language is recursively enumerable
if and only if
a Matrix grammar generates it 26
Markov Algorithms
Example: ab S
aSb S
S .
Derivation:
n n
L {a b : n 0}
28
*
In general: L {w : w }
Theorem:
29
Lindenmayer-Systems
Example: a aa
n
2
L {a : n 0}
30
Lindenmayer-Systems are not general
As recursively enumerable languages
Extended Lindenmayer-Systems: ( x, a, y ) u
context
Theorem:
A language is recursively enumerable
if and only if an
Extended Lindenmayer-System generates it
31
Computational Complexity
32
Time Complexity: The number of steps
during a computation
33
Time Complexity
a
•Compare the and b
35
n n
L {a b : n 0}
Time needed:
Total time: O (| w |)
36
n n
L {a b : n 0}
37
Language class: DTIME (n)
DTIME (n)
L1 L3
L2
n n
{a b : n 0}
{ww}
39
In a similar way we define the class
DTIME (T (n))
2 3
Examples: DTIME (n ), DTIME (n ),...
40
Example: The membership problem
for context free languages
L {w : w is generated by grammar G}
3
L DTIME (n ) (CYK - algorithm)
Polynomial time
41
k 1 k
Theorem: DTIME (n ) DTIME (n )
k 1
DTIME (n )
k
DTIME (n )
42
k
Polynomial time algorithms: DTIME (n )
43
The class P
k
P DTIME (n ) for all k
•Polynomial time
{ww}
45
n
Exponential time algorithms: DTIME (2 )
46
Example: the Traveling Salesperson Problem
5
3
4 1 2
2
6
10
8
3
4 1 2
2
6
10
8
3
n
L DTIME (n!) DTIME (2 )
Exponential time
Intractable problem
49
Example: The Satisfiability Problem
Boolean expressions in
Conjunctive Normal Form:
t1 t2 t3 tk
ti x1 x2 x3 x p
Variables
Satisfiable: x1 0, x2 1, x3 1
( x1 x2 ) ( x1 x3 ) 1
51
Example: ( x1 x2 ) x1 x2
Not satisfiable
52
L {w : expression w is satisfiable}
n
For n variables: L DTIME (2 )
exponential
Algorithm:
search exhaustively all the possible
binary values of the variables
53
Non-Determinism
Language class: NTIME (n)
NTIME (n)
L1 L3
L2
Non-Deterministic Algorithm
to accept a string ww :
O (| w |)
•Compare the two tapes
Total time: O (| w |)
56
NTIME (n)
L {ww}
57
In a similar way we define the class
NTIME (T (n))
2 3
Examples: NTIME (n ), NTIME (n ),...
58
Non-Deterministic Polynomial time algorithms:
k
L NTIME ( n )
59
The class NP
k
P NTIME (n ) for all k
60
Example: The satisfiability problem
L {w : expression w is satisfiable}
Non-Deterministic algorithm:
•Guess an assignment of the variables
61
L {w : expression w is satisfiable}
L NP
63
Observation:
P NP
Deterministic Non-Deterministic
Polynomial Polynomial
64
Open Problem: P NP ?
65
Open Problem: P NP ?
•It is in NP
67
Observation:
P NP
68
Observation:
If we prove that
we cannot solve an NP-complete problem
in Deterministic Polynomial Time (P time)
then we know:
P NP
69
Cook’s Theorem:
Proof:
Convert a Non-Deterministic Turing Machine
to a Boolean expression
in conjunctive normal form
70
Other NP-Complete Problems:
•Vertex cover
•Hamiltonian Path