Slides for CIS 675
NP-Complete Problems, Part 2
Jim Royer
DPV Chapter 8
April 15, 2019
Uncredited diagrams are from DPV or homemade. NP-Completeness (DPV Chapter 8) April 15, 2019 1 / 35
Slides for CIS 675 NP-Complete Problems, Part 2 Jim Royer DPV - - PowerPoint PPT Presentation
Slides for CIS 675 NP-Complete Problems, Part 2 Jim Royer DPV Chapter 8 April 15, 2019 Uncredited diagrams are from DPV or homemade. NP-Completeness (DPV Chapter 8) April 15, 2019 1 / 35 The Plan of 8.3 All of NP S AT 3S AT I NDEPENDENT
DPV Chapter 8
Uncredited diagrams are from DPV or homemade. NP-Completeness (DPV Chapter 8) April 15, 2019 1 / 35
NP-Completeness (DPV Chapter 8) April 15, 2019 2 / 35
Given an instance of Rudrata (s, t)-Path, (G, s, t), construct G′ by adding an new vertex x and new edges (x, s) and (x, t). If P is a Rudrata-cyclc in G′, then leaving x, (x, s) and (x, t) out of P gives an (s, t)-Rudrata path in G. If G has a (s, t)-Rudrata path P, then adding (x, s) and (x, t) to P yields a Rudrata cycle in G′.
NP-Completeness (DPV Chapter 8) April 15, 2019 3 / 35
NP-Completeness (DPV Chapter 8) April 15, 2019 4 / 35
NP-Completeness (DPV Chapter 8) April 15, 2019 5 / 35
NP-Completeness (DPV Chapter 8) April 15, 2019 5 / 35
To build a satisfying assignment of an instance of 3SAT, we have to pick out at least one literal per clause to be TRUE — consistently!
NP-Completeness (DPV Chapter 8) April 15, 2019 6 / 35
To build a satisfying assignment of an instance of 3SAT, we have to pick out at least one literal per clause to be TRUE — consistently! Consider: (x ∨ y ∨ z) ∧ (x ∨ y ∨ z) ∧ (x ∨ y ∨ z) ∧ (x ∨ y). y y y x z x z x z x y
NP-Completeness (DPV Chapter 8) April 15, 2019 6 / 35
To build a satisfying assignment of an instance of 3SAT, we have to pick out at least one literal per clause to be TRUE — consistently! Consider: (x ∨ y ∨ z) ∧ (x ∨ y ∨ z) ∧ (x ∨ y ∨ z) ∧ (x ∨ y). A clause (ℓ1 ∨ ℓ2 ∨ ℓ3) is represented by a triangle with verts labeled: ℓ1, ℓ2, & ℓ3. y y y x z x z x z x y
NP-Completeness (DPV Chapter 8) April 15, 2019 6 / 35
To build a satisfying assignment of an instance of 3SAT, we have to pick out at least one literal per clause to be TRUE — consistently! Consider: (x ∨ y ∨ z) ∧ (x ∨ y ∨ z) ∧ (x ∨ y ∨ z) ∧ (x ∨ y). A clause (ℓ1 ∨ ℓ2 ∨ ℓ3) is represented by a triangle with verts labeled: ℓ1, ℓ2, & ℓ3. Idea: If v ∈ U an indep. set and v has label ℓ, then the truth assignment corresponding to U sets ℓ to TRUE. y y y x z x z x z x y
NP-Completeness (DPV Chapter 8) April 15, 2019 6 / 35
To build a satisfying assignment of an instance of 3SAT, we have to pick out at least one literal per clause to be TRUE — consistently! Consider: (x ∨ y ∨ z) ∧ (x ∨ y ∨ z) ∧ (x ∨ y ∨ z) ∧ (x ∨ y). A clause (ℓ1 ∨ ℓ2 ∨ ℓ3) is represented by a triangle with verts labeled: ℓ1, ℓ2, & ℓ3. Idea: If v ∈ U an indep. set and v has label ℓ, then the truth assignment corresponding to U sets ℓ to TRUE. Set g = # of clauses. So any indep. set must have one vertex from each triangle. (Why?) y y y x z x z x z x y
NP-Completeness (DPV Chapter 8) April 15, 2019 6 / 35
To build a satisfying assignment of an instance of 3SAT, we have to pick out at least one literal per clause to be TRUE — consistently! Consider: (x ∨ y ∨ z) ∧ (x ∨ y ∨ z) ∧ (x ∨ y ∨ z) ∧ (x ∨ y). A clause (ℓ1 ∨ ℓ2 ∨ ℓ3) is represented by a triangle with verts labeled: ℓ1, ℓ2, & ℓ3. Idea: If v ∈ U an indep. set and v has label ℓ, then the truth assignment corresponding to U sets ℓ to TRUE. Set g = # of clauses. So any indep. set must have one vertex from each triangle. (Why?) But we have to have consistency checks. We don’t want to set x and x to TRUE. y y y x z x z x z x y
NP-Completeness (DPV Chapter 8) April 15, 2019 6 / 35
To build a satisfying assignment of an instance of 3SAT, we have to pick out at least one literal per clause to be TRUE — consistently! Consider: (x ∨ y ∨ z) ∧ (x ∨ y ∨ z) ∧ (x ∨ y ∨ z) ∧ (x ∨ y). A clause (ℓ1 ∨ ℓ2 ∨ ℓ3) is represented by a triangle with verts labeled: ℓ1, ℓ2, & ℓ3. Idea: If v ∈ U an indep. set and v has label ℓ, then the truth assignment corresponding to U sets ℓ to TRUE. Set g = # of clauses. So any indep. set must have one vertex from each triangle. (Why?) But we have to have consistency checks. We don’t want to set x and x to TRUE. So put an edge between each occurrence of a variable x and each occurrence of x. This enforces consistency. (Why?) y y y x z x z x z x y
NP-Completeness (DPV Chapter 8) April 15, 2019 6 / 35
Construction: 3SAT instance → IS instance Given an instance of 3SAT C1, . . . , Ck. For each clause Ci = (ℓ1, ℓ2, ℓ3), build a triangle with vertices labeled ℓ1, ℓ2, & ℓ3. Add an edge between each literal and all of its opposites. Set g = k. Construction: IS solution → 3SAT solution Given an independent set U: for each v ∈ U with label ℓ, set ℓ to TRUE. For each variable that does not yet have a truth value, set it to TRUE. (x ∨ y ∨ z)∧ (x ∨ y ∨ z)∧ (x ∨ y ∨ z)∧ (x ∨ y)
y y y x z x z x z x y
NP-Completeness (DPV Chapter 8) April 15, 2019 7 / 35
Construction: 3SAT instance → IS instance Given an instance of 3SAT C1, . . . , Ck. For each clause Ci = (ℓ1, ℓ2, ℓ3), build a triangle with vertices labeled ℓ1, ℓ2, & ℓ3. Add an edge between each literal and all of its opposites. Set g = k. Construction: IS solution → 3SAT solution Given an independent set U: for each v ∈ U with label ℓ, set ℓ to TRUE. For each variable that does not yet have a truth value, set it to TRUE. Claim 1: Both constructions are poly-time. Claim 2: Given an indep. set, we can construct a satisfying assignment for C1, . . . , Ck. Claim 3′: If C1, . . . , Ck has an satisfying assignment, then there is size g indep. set. (x ∨ y ∨ z)∧ (x ∨ y ∨ z)∧ (x ∨ y ∨ z)∧ (x ∨ y)
y y y x z x z x z x y
NP-Completeness (DPV Chapter 8) April 15, 2019 7 / 35
NP-Completeness (DPV Chapter 8) April 15, 2019 8 / 35
Take the truth assignment for the 3SAT formula & restrict it to the original vars.
NP-Completeness (DPV Chapter 8) April 15, 2019 9 / 35
Take the truth assignment for the 3SAT formula & restrict it to the original vars.
NP-Completeness (DPV Chapter 8) April 15, 2019 9 / 35
Take the truth assignment for the 3SAT formula & restrict it to the original vars.
NP-Completeness (DPV Chapter 8) April 15, 2019 9 / 35
Take the truth assignment for the 3SAT formula & restrict it to the original vars.
NP-Completeness (DPV Chapter 8) April 15, 2019 9 / 35
NP-Completeness (DPV Chapter 8) April 15, 2019 10 / 35
Suppose G = (V, E) is an undirected graph and S ⊆ V.
(a)
S is independent when for each u, v ∈ S, (u, v) / ∈ E.
(b)
S is a vertex cover when each edge of E has at least one endpoint in S.
− S
Given: G and b. Find: An indep. set for G of size ≥ b.
Given: G and b. Find: A vertex cover for G of size ≤ b. Reduction: f((V, E), b) = ((V, E), |V| − b). h(S) = V − S.
1.
Both constructions are poly-time.
2.
If U is a vertex cover for G with |U| ≤ |V| − b, then V − U is an indep. set with |V − U| ≥ b.
3.
If G has a indep. set of size ≥ b, then G has a vertex cover of size |V| − b.
NP-Completeness (DPV Chapter 8) April 15, 2019 11 / 35
NP-Completeness (DPV Chapter 8) April 15, 2019 12 / 35
(a)
(b)
(c)
NP-Completeness (DPV Chapter 8) April 15, 2019 13 / 35
NP-Completeness (DPV Chapter 8) April 15, 2019 14 / 35
Given: R ⊆ A × B × C where |A| = |B| = |C| = n. Find: A subset M ⊆ R of n many triples such that if (a, b, c) and (a′, b′, c′) are distinct elements of M, then a = a′, b = b′, and c = c′. 2D matching is poly-time (via Ford-Fulkerson). The only known algorithms for 3D Matching are exponential time.
Armadillo Bobcat Carol Beatrice Alice Chet Bob Al Canary
NP-Completeness (DPV Chapter 8) April 15, 2019 15 / 35
◮ (b0, g1, p0), (b1, g0, p2)
can represent True
◮ (b0, g0, p1), (b1, g1, p3)
can represent False
0, bx 1 ∈ B, gx 0, gx 1 ∈ G, and
0, px 1 ∈ P
NP-Completeness (DPV Chapter 8) April 15, 2019 16 / 35
◮ (bc, gc, px
1) (or else (bc, gc, px 3))
(if x is true, then px
1 and px 3 are available)
◮ (bc, gc, py
0) (or else (bc, gc, py 2))
(if y is false, then py
0 and py 2 are available)
◮ (bc, gc, pz
1) (or else (bc, gc, pz 3))
(if z is true, then pz
1 and pz 3 are available)
i ∈ B, g∗ i ∈ G and the set of triples
i , g∗ i , pv j ) : v ∈ V, j = 0, . . . , 3 }. I.e., b∗ i and g∗ i like any P.
NP-Completeness (DPV Chapter 8) April 15, 2019 17 / 35
NP-Completeness (DPV Chapter 8) April 15, 2019 18 / 35
NP-Completeness (DPV Chapter 8) April 15, 2019 19 / 35
Given: R ⊆ U × V × W with |U| = |V| = |W| = m. Find: A size-m subset M ⊆ R such that if (u, v, w) and (u′, v′, w′) are distinct elements
Given: A, an m × n matrix of 0’s and 1’s Find: x, a n-vector of 0’s and 1’s such that A
1.
Armadillo Bobcat Carol Beatrice Alice Chet Bob Al Canary
A = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Construction
NP-Completeness (DPV Chapter 8) April 15, 2019 20 / 35
Given: R ⊆ U × V × W with |U| = |V| = |W| = m. Find: A size-m subset M ⊆ R such that if (u, v, w) and (u′, v′, w′) are distinct elements
Given: A, an m × n matrix of 0’s and 1’s Find: x, a n-vector of 0’s and 1’s such that A
1.
Armadillo Bobcat Carol Beatrice Alice Chet Bob Al Canary
A = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Construction Suppose n = |R|.
NP-Completeness (DPV Chapter 8) April 15, 2019 20 / 35
Given: R ⊆ U × V × W with |U| = |V| = |W| = m. Find: A size-m subset M ⊆ R such that if (u, v, w) and (u′, v′, w′) are distinct elements
Given: A, an m × n matrix of 0’s and 1’s Find: x, a n-vector of 0’s and 1’s such that A
1.
Armadillo Bobcat Carol Beatrice Alice Chet Bob Al Canary
A = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Construction Suppose n = |R|. xj variable for the j-th triple.
NP-Completeness (DPV Chapter 8) April 15, 2019 20 / 35
Given: R ⊆ U × V × W with |U| = |V| = |W| = m. Find: A size-m subset M ⊆ R such that if (u, v, w) and (u′, v′, w′) are distinct elements
Given: A, an m × n matrix of 0’s and 1’s Find: x, a n-vector of 0’s and 1’s such that A
1.
Armadillo Bobcat Carol Beatrice Alice Chet Bob Al Canary
A = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Construction Suppose n = |R|. xj variable for the j-th triple. xj = 1 ⇐ ⇒ j-th triple is used.
NP-Completeness (DPV Chapter 8) April 15, 2019 20 / 35
Given: R ⊆ U × V × W with |U| = |V| = |W| = m. Find: A size-m subset M ⊆ R such that if (u, v, w) and (u′, v′, w′) are distinct elements
Given: A, an m × n matrix of 0’s and 1’s Find: x, a n-vector of 0’s and 1’s such that A
1.
Armadillo Bobcat Carol Beatrice Alice Chet Bob Al Canary
A = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Construction Suppose n = |R|. xj variable for the j-th triple. xj = 1 ⇐ ⇒ j-th triple is used. (Ai,j) is 3m × n
NP-Completeness (DPV Chapter 8) April 15, 2019 20 / 35
Given: R ⊆ U × V × W with |U| = |V| = |W| = m. Find: A size-m subset M ⊆ R such that if (u, v, w) and (u′, v′, w′) are distinct elements
Given: A, an m × n matrix of 0’s and 1’s Find: x, a n-vector of 0’s and 1’s such that A
1.
Armadillo Bobcat Carol Beatrice Alice Chet Bob Al Canary
A = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Construction Suppose n = |R|. xj variable for the j-th triple. xj = 1 ⇐ ⇒ j-th triple is used. (Ai,j) is 3m × n Ai,j = 1 ⇐ ⇒ the j-th elm. of U is used in the i-th triple.
NP-Completeness (DPV Chapter 8) April 15, 2019 20 / 35
Given: R ⊆ U × V × W with |U| = |V| = |W| = m. Find: A size-m subset M ⊆ R such that if (u, v, w) and (u′, v′, w′) are distinct elements
Given: A, an m × n matrix of 0’s and 1’s Find: x, a n-vector of 0’s and 1’s such that A
1.
Armadillo Bobcat Carol Beatrice Alice Chet Bob Al Canary
A = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Construction Suppose n = |R|. xj variable for the j-th triple. xj = 1 ⇐ ⇒ j-th triple is used. (Ai,j) is 3m × n Ai,j = 1 ⇐ ⇒ the j-th elm. of U is used in the i-th triple. Am+i,j = 1 ⇐ ⇒ the i-th elm. of V is used in the j-th triple.
NP-Completeness (DPV Chapter 8) April 15, 2019 20 / 35
Given: R ⊆ U × V × W with |U| = |V| = |W| = m. Find: A size-m subset M ⊆ R such that if (u, v, w) and (u′, v′, w′) are distinct elements
Given: A, an m × n matrix of 0’s and 1’s Find: x, a n-vector of 0’s and 1’s such that A
1.
Armadillo Bobcat Carol Beatrice Alice Chet Bob Al Canary
A = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Construction Suppose n = |R|. xj variable for the j-th triple. xj = 1 ⇐ ⇒ j-th triple is used. (Ai,j) is 3m × n Ai,j = 1 ⇐ ⇒ the j-th elm. of U is used in the i-th triple. Am+i,j = 1 ⇐ ⇒ the i-th elm. of V is used in the j-th triple. A2m+i,j = 1 ⇐ ⇒ the i-th elm. of W is used in the j-th triple.
NP-Completeness (DPV Chapter 8) April 15, 2019 20 / 35
Given: R ⊆ U × V × W with |U| = |V| = |W| = m. Find: A size-m subset M ⊆ R such that if (u, v, w) and (u′, v′, w′) are distinct elements
Given: A, an m × n matrix of 0’s and 1’s Find: x, a n-vector of 0’s and 1’s such that A
1.
Armadillo Bobcat Carol Beatrice Alice Chet Bob Al Canary
A = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Construction Suppose n = |R|. xj variable for the j-th triple. xj = 1 ⇐ ⇒ j-th triple is used. (Ai,j) is 3m × n Ai,j = 1 ⇐ ⇒ the j-th elm. of U is used in the i-th triple. Am+i,j = 1 ⇐ ⇒ the i-th elm. of V is used in the j-th triple. A2m+i,j = 1 ⇐ ⇒ the i-th elm. of W is used in the j-th triple. So A
1 means . . .
NP-Completeness (DPV Chapter 8) April 15, 2019 20 / 35
Given: R ⊆ U × V × W with |U| = |V| = |W| = n. Find: A size-n subset M ⊆ R such that if (u, v, w) and (u′, v′, w′) are distinct elements
Given: A, an m × n matrix of 0’s and 1’s Find: x, a n-vector of 0’s and 1’s such that A
1.
Armadillo Bobcat Carol Beatrice Alice Chet Bob Al Canary
A = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Construction: Example R = { t1, . . . , t5 } where t1 = (Al,Alice,Armadilo) t2 = (Chet,Beatrice,Canary) t3 = (Chet,Carol,Bobcat) t4 = (Bob,Carol,Bobcat) t5 = (Bob,Alice,Armadilo)
t1 t2 t3 t4 t5 Al 1 Bob 1 1 Chet 1 1 Alice 1 1 Beatrice 1 Carol 1 1 Armadilo 1 1 Bobcat 1 1 Canary 1 A × (1, 1, 1, 0, 0) = (1, 0, 2, 1, 1, 1, 1, 1, 1) A × (1, 1, 0, 1, 0) = (1, 1, 1, 1, 1, 1, 1, 1, 1)
NP-Completeness (DPV Chapter 8) April 15, 2019 21 / 35
NP-Completeness (DPV Chapter 8) April 15, 2019 22 / 35
Given: A, an m × n matrix of 0’s and 1’s Find: x, a n-vec. of 0’s and 1’s ∋ A
1.
Given: A multiset M and goal G, all ints. Find: An M′ ⊆ M such that G = ∑x∈M′ x.
NP-Completeness (DPV Chapter 8) April 15, 2019 23 / 35
Given: A, an m × n matrix of 0’s and 1’s Find: x, a n-vec. of 0’s and 1’s ∋ A
1.
Given: constraints A
b Find: A vector of integers x ∋ A
b.
NP-Completeness (DPV Chapter 8) April 15, 2019 24 / 35
NP-Completeness (DPV Chapter 8) April 15, 2019 25 / 35
NP-Completeness (DPV Chapter 8) April 15, 2019 26 / 35
Given: G = (V, E), an undirected graph. Find: A simple cycle that visits each vertex of G.
Given: V′, n vertices; all n·(n−1)
2
Find: π, an ordering of 1, . . . , n, such that ∑n
i=1 dπ(i),π(1+(i mod n)) ≤ b
Construction Pick α ≥ 1. Given (V, E), define V′ = V di,j =
if (i, j) ∈ E; 1 + α,
b = |V| Claim: (V, E) has a R/H cycle ⇐ ⇒ (V′, d) has tour of cost ≤ b. Note: If α = 1: Distances satisfy the triangle inequality: dij + djk ≥ dik. These instance of TSP are approximatable (Chap. 9). Note: If α ≫ 1: Gap: either a solution of cost b,
NP-Completeness (DPV Chapter 8) April 15, 2019 27 / 35
NP-Completeness (DPV Chapter 8) April 15, 2019 28 / 35
Given: A Boolean circuit, a dag with five types of gates
1.
AND gates and OR gates (indegree 2)
2.
NOT gates (indegree 1)
3.
Known input gates (indegree 0) labeled True or False.
4.
Unknown inputs gates (indgree 0) labeled “?”.
5.
An output gate (a particular sink) Find: A truth assignment to the unknown input gates so that the circuit evaluates to True.
true AND NOT AND OR OR ? ?
? AND
NP-Completeness (DPV Chapter 8) April 15, 2019 29 / 35
Given: A Boolean circuit, a dag with five types of gates
1.
AND gates and OR gates (indegree 2)
2.
NOT gates (indegree 1)
3.
Known input gates (indegree 0) labeled True or False.
4.
Unknown inputs gates (indgree 0) labeled “?”.
5.
An output gate (a particular sink) Find: A truth assignment to the unknown input gates so that the circuit evaluates to True.
SAT Circuit SAT
NP-Completeness (DPV Chapter 8) April 15, 2019 30 / 35
Given: A Boolean circuit, a dag with five types of gates
1.
AND gates and OR gates (indegree 2)
2.
NOT gates (indegree 1)
3.
Known input gates (indegree 0) labeled True or False.
4.
Unknown inputs gates (indgree 0) labeled “?”.
5.
An output gate (a particular sink) Find: A truth assignment to the unknown input gates so that the circuit evaluates to True.
Circuit SAT SAT
1
2
Case: g = ? . Translates to: { (g) }. Case: g = true . Translates to: { (g) }. Case: g = false . Translates to: { (g) }.
NP-Completeness (DPV Chapter 8) April 15, 2019 31 / 35
NP-Completeness (DPV Chapter 8) April 15, 2019 32 / 35
Given: A Boolean circuit, a dag with five types of gates
1.
AND gates and OR gates (indegree 2)
2.
NOT gates (indegree 1)
3.
Known input gates (indegree 0) labeled True or False.
4.
Unknown inputs gates (indgree 0) labeled “?”.
5.
An output gate (a particular sink) Find: A truth assignment to the unknown input gates so that the circuit evaluates to True.
NP-Completeness (DPV Chapter 8) April 15, 2019 33 / 35
Given: A Boolean circuit, a dag with five types of gates
1.
AND gates and OR gates (indegree 2)
2.
NOT gates (indegree 1)
3.
Known input gates (indegree 0) labeled True or False.
4.
Unknown inputs gates (indgree 0) labeled “?”.
5.
An output gate (a particular sink) Find: A truth assignment to the unknown input gates so that the circuit evaluates to True.
NP-Completeness (DPV Chapter 8) April 15, 2019 34 / 35
NP-Completeness (DPV Chapter 8) April 15, 2019 35 / 35