fullscreen
timer
qrcode
plickers
selector
edit
reset

intractibility 1 (8)

numerical problems

my hobby

NP-Complete by Randall Munro
NP-Complete by Randall Munro
xkcd ]

subset sum

\(\SubsetSum\): Given natural numbers \(w_1, \ldots, w_n\) and an integer \(W\), is there a subset that adds up to exactly \(W\)?

Ex: \(\{ 215, 215, 275, 275, 355, 355, 420, 420, 580, 655 \}\), \(W=1505\)

Yes: \(215+355+355=1505\)

Remark: With arithmetic problems, input integers are encoded in binary. Poly-time reducion must be polynomial in binary encoding.

subset sum

Theorem: \(\ThreeSat \leq_P \SubsetSum\)

Pf: Given an instance \(\Phi\) of \(\ThreeSat\), we construct an instance of \(\SubsetSum\) that has a solution iff \(\Phi\) is satisfied.

3-sat reduces to subset sum

Construction: Given \(\ThreeSat\) instance \(\Phi\) with \(n\) variables and \(k\) clauses, form \(2n + 2k\) decimal integers, each having \(n+k\) digits:

Key property: No carries possible ⇒ each digit yields one equation.

\[\begin{eqnarray} C_1 & = & \overline{x_1} \vee x_2 \vee x_3 \\ C_2 & = & x_1 \vee \overline{x_2} \vee x_3 \\ C_3 & = & \overline{x_1} \vee \overline{x_2} \vee \overline{x_3} \end{eqnarray}\]

     x1 x2 x3 C1 C2 C3
 x1   1  0  0  0  1  0  100010
-x1   1  0  0  1  0  1  100101
 x2   0  1  0  1  0  0   10100
-x2   0  1  0  0  1  1   10011
 x3   0  0  1  1  1  0    1110
-x3   0  0  1  0  0  1    1001
      0  0  0  1  0  0     100
      0  0  0  2  0  0     200
      0  0  0  0  1  0      10
      0  0  0  0  2  0      20
      0  0  0  0  0  1       1
      0  0  0  0  0  2       2
     --------------------------
 W    1  1  1  4  4  4  111444

3-sat reduces to subset sum

Lemma: \(\Phi\) is satisfiable iff there exists a subset that sums to \(W\)

Pf ⇒:

3-sat reduces to subset sum

Lemma: \(\Phi\) is satisfiable iff there exists a subset that sums to \(W\)

Pf ⇐:

Group: Subset Sum reduces to Knapsack

\(\SubsetSum\): Given a set \(X\), values \(u_i \geq 0\), and an integer \(U\), is there a subset \(S \subseteq X\) whose elements sum to exactly \(U\)?

\(\Knapsack\): Given a set \(X\), weights \(u_i \geq 0\), values \(v_i \geq 0\), a weight limit \(U\), and a target value \(V\), is there a subset \(S \subseteq X\) such that

\[ \sum_{i \in S} u_i \leq U,\quad \sum_{i \in S} v_i \geq V \]

Theorem: \(\SubsetSum \leq_P \Knapsack\)

Pf: Given instance \((w_1,\ldots,w_n,W)\) of \(\SubsetSum\), create \(\Knapsack\) instance...

poly-time reductions

Karp's 21 poly-time reductions from sat

Dick Karp, '85 Turing Award
Dick Karp, '85 Turing Award

quote

If P = NP, then the world would be a profoundly different place than we usually assume it to be. There would be no special value in "creative leaps", no fundamental gap between solving a problem and recognizing the solution once it's found. Everyone who could appreciate a symphony would be Mozart; everyone who could follow a step-by-step argument would be Gauss.
—Scott Aaronson

P vs Np & the computational complexity zoo

×