View
221
Download
0
Tags:
Embed Size (px)
Citation preview
Cook-Levin Theorem
• Circuit Satisfiability– A “first” NP-complete problem
• Reduction overview
• Example reduction
Circuit Satisfiability
• 5 types of gates– Constant (T/F)– And– Or– Not– Variable
• Input size is total number of gates
• One output• Question
– Is there an assignment of truth values to the variable gates that causes the output of the circuit to be true?
G 5
G 8
G6
G 10
G 9
G7
X1 X2 X3 T
Reduction Overview
• We need to develop a reduction that can be applied to ANY problem in NP
• This leads to two key issues– How do we represent the input for an arbitrary
problem in NP?– What do we know about an arbitrary problem
in NP?
Encoding Inputs
• We assume the input is encoded as a string of 0’s and 1’s
• Example: input is an undirected graph– First specify the number of nodes in binary – Then use an adjacency matrix to represent edges
1
2
3
01010101011
Arbitrary problem in NP
• If Π belongs to NP, then there exists a verification algorithm A along with a set of certificates C
• Given any input x to Π, we construct a circuit to simulate the computation of A on x with the certificate C represented as variable gates
RCircuit representing computation of A on x with certificate C
01010101011
Input x
Example
• We will show an example with the Hamiltonian Path Problem
• Key concept– Representation of computation of A on x as a
sequence of configurations– Configuration: With a configuration and the
code for A, you should be able to complete the computation of A on x
Verification algorithm, certificate for HP
bool HPV(graph G=(V,E), path P) {int i = 1;bool answer = true;bool used[V] = false; /* initialized to all false */1. if i = V goto 6;2. if (used[P[i]] = = true) answer = false; else used[i] = true;3. if (!E(P[i],P[i+1])) answer = false;4. i++;5. goto 1;6. if (used[P[i]] = = true) answer = false;7. return answer;
}Certificate: A path which is a permutation of the V nodes in the graph
Configurations of HPV computationbool HPV(graph G=(V,E), path P) {
int i = 1;bool answer = true;bool used[V] = false; /* initialized to all
false */1. if i = V goto 6;2. if (used[P[i]] = = true) answer =
false; else used[i] = true;3. if (!E(P[i],P[i+1])) answer = false;4. i++;5. goto 1;6. if (used[P[i]] = = true) answer =
false;7. return answer;
}Certificate: A path which is a permutation
of the V nodes in the graph1
2
3
01010101011
• What information should be recorded in a configuration of this program?
• Current instruction (PC)
• value of all variables• Input x• Certificate
PC G=(V,E) Path i answer used
Configuration Description
One computation of HPVbool HPV(graph G=(V,E), path P) {
int i = 1;bool answer = true;bool used[V] = false; /* initialized to all
false */1. if i = V goto 6;2. if (used[P[i]] = = true) answer =
false; else used[i] = true;3. if (!E(P[i],P[i+1])) answer = false;4. i++;5. goto 1;6. if (used[P[i]] = = true) answer =
false;7. return answer;
}Certificate: A path which is a permutation
of the V nodes in the graph1
2
3
01010101011
001 01010101001101101100011
PC G=(V,E) Path i answer used
Path P = 1, 2, 3
010 01010101001101101100011
011 01010101001101101110011
100 01010101001101101110011
101 01010101001101110110011
001 01010101001101110110011
011 01010101001101110111011
010 01010101001101110110011
One computation of HPV cont’dbool HPV(graph G=(V,E), path P) {
int i = 1;bool answer = true;bool used[V] = false; /* initialized to all
false */1. if i = V goto 6;2. if (used[P[i]] = = true) answer =
false; else used[i] = true;3. if (!E(P[i],P[i+1])) answer = false;4. i++;5. goto 1;6. if (used[P[i]] = = true) answer =
false;7. return answer;
}Certificate: A path which is a permutation
of the V nodes in the graph1
2
3
01010101011
PC G=(V,E) Path i answer used
Path P = 1, 2, 3
100 01010101001101110111011
101 01010101001101111111011
011 01010101001101110111011
001 01010101001101111111011
110 01010101001101111111011
111 01010101001101111111011
Second computation of HPVbool HPV(graph G=(V,E), path P) {
int i = 1;bool answer = true;bool used[V] = false; /* initialized to all
false */1. if i = V goto 6;2. if (used[P[i]] = = true) answer =
false; else used[i] = true;3. if (!E(P[i],P[i+1])) answer = false;4. i++;5. goto 1;6. if (used[P[i]] = = true) answer =
false;7. return answer;
}Certificate: A path which is a permutation
of the V nodes in the graph1
2
3
01010101011
001 01010101010110101100011
PC G=(V,E) Path i answer used
Path P = 2, 3, 1
010 01010101010110101100011
011 01010101010110101101011
100 01010101010110101101011
101 01010101010110110101011
001 01010101010110110101011
011 01010101010110110101111
010 01010101010110110101011
Second computation of HPV cont’dbool HPV(graph G=(V,E), path P) {
int i = 1;bool answer = true;bool used[V] = false; /* initialized to all
false */1. if i = V goto 6;2. if (used[P[i]] = = true) answer =
false; else used[i] = true;3. if (!E(P[i],P[i+1])) answer = false;4. i++;5. goto 1;6. if (used[P[i]] = = true) answer =
false;7. return answer;
}Certificate: A path which is a permutation
of the V nodes in the graph1
2
3
01010101011
PC G=(V,E) Path i answer used
Path P = 2, 3, 1
100 01010101001101110001111
101 01010101001101111001111
011 01010101010110110101111
001 01010101001101111001111
110 01010101001101111001111
111 01010101001101111001111
Computation represented as a Boolean Circuitbool HPV(graph G=(V,E), path P) {
int i = 1;bool answer = true;bool used[V] = false; /* initialized to all
false */1. if i = V goto 6;2. if (used[P[i]] = = true) answer =
false; else used[i] = true;3. if (!E(P[i],P[i+1])) answer = false;4. i++;5. goto 1;6. if (used[P[i]] = = true) answer =
false;7. return answer;
}Certificate: A path which is a permutation
of the V nodes in the graph1
2
3
01010101011
001 01010101010110101100011
Path P = 2, 3, 1
010 01010101010110101100011
011 01010101010110101101011
GATES
GATES
GATES
GATES
111 01010101001101111001111
Output of Circuitbool HPV(graph G=(V,E), path P) {
int i = 1;bool answer = true;bool used[V] = false; /* initialized to all
false */1. if i = V goto 6;2. if (used[P[i]] = = true) answer =
false; else used[i] = true;3. if (!E(P[i],P[i+1])) answer = false;4. i++;5. goto 1;6. if (used[P[i]] = = true) answer =
false;7. return answer;
}Certificate: A path which is a permutation
of the V nodes in the graph1
2
3
01010101011
001 01010101010110101100011
Path P = 2, 3, 1
010 01010101010110101100011
GATES
GATES
011 01010101010110101101011
GATES
GATES
111 01010101001101111001111
Constant Input Gatesbool HPV(graph G=(V,E), path P) {
int i = 1;bool answer = true;bool used[V] = false; /* initialized to all
false */1. if i = V goto 6;2. if (used[P[i]] = = true) answer =
false; else used[i] = true;3. if (!E(P[i],P[i+1])) answer = false;4. i++;5. goto 1;6. if (used[P[i]] = = true) answer =
false;7. return answer;
}Certificate: A path which is a permutation
of the V nodes in the graph1
2
3
01010101011
101101011000001 01010101011
Path P = 2, 3, 1
010 01010101010110101100011
GATES
GATES
011 01010101010110101101011
GATES
GATES
111 01010101001101111001111
Variable Input Gatesbool HPV(graph G=(V,E), path P) {
int i = 1;bool answer = true;bool used[V] = false; /* initialized to all
false */1. if i = V goto 6;2. if (used[P[i]] = = true) answer =
false; else used[i] = true;3. if (!E(P[i],P[i+1])) answer = false;4. i++;5. goto 1;6. if (used[P[i]] = = true) answer =
false;7. return answer;
}Certificate: A path which is a permutation
of the V nodes in the graph1
2
3
01010101011
? ? ? ? ? ?011000001 01010101011
010 010101010 ? ? ? ? ? ?01100011
GATES
GATES
011 010101010 ? ? ? ? ? ?01101011
GATES
GATES
111 010101010 ? ? ? ? ? ? 11001111
Answer-Preserving Nature
• The HP input below has an HP if and only if there exists an assignment of PATH variables in red such that the CIRCUIT will output 1.
? ? ? ? ? ?011000001 01010101011
GATES
GATES
111 010101010 ? ? ? ? ? ? 1111
1
2
3
01010101011
Polynomial Time• The number of “rows” is
polynomial in the input size since A is assumed to be a polynomial time verification algorithm
• The number of columns is polynomial in the input size since the certificate must have polynomial size and the variables used must be polynomial in number
• GATES is essentially constant-sized as GATES is essentially independent of the input; GATES depends mostly on the verification algorithm
? ? ? ? ? ?011000001 01010101011
GATES
GATES
111 010101010 ? ? ? ? ? ? 111101010101011
1
2
3
Different sized inputs
• There is a minor issue with size
• The number of columns does change depending on the size of the input
? ? ? ? ? ?011000001 010101010110101010101112
3
? ? ? ? ? ?011000001 011101110110111011101112
3
? ? ? ? ? ? 0 11 000001
010 101 0100012
34
1 0 1 00100
? ? 0 0010 101 010001 0 1 00100
General Case
• In the general case, the input represented as a string of bits is transformed in an answer-preserving fashion into a polynomial-sized Boolean circuit.
? ? ? ? ? ?001 01010101011
GATES
GATES
010101010 ? ? ? ? ? ?11
01010101011
PC Input Cert. Vars
Based on Verification Algorithm