NP, NP-Completeness, Reductions




CS255

Chris Pollett

Apr 17, 2019

Outline

Introduction to NP-Completeness

Abstract Problems

Encodings

Formal Languages

More on Languages

Polynomial-Time Verification

The complexity class NP

In-Class Exercise

Let `EXP` be the class of languages decided by deterministic algorithms on inputs of length `n` in time `O(2^{n^k})` for some fixed constant `k > 0`.

Prove `NP subseteq EXP`. Argue there is a language not in `EXP`, but which can be solved in time `O(2^{2^n})`.

Post your solution to the Apr 17 In-Class Exercise Thread.

Polynomial-Time Reducibility

Lemma. If `L_1`, `L_2` are languages such that `L_1 le_P L_2` and `L_2` is in `P`, then `L_1` is in `P`.

Proof. Let `A(y)` decide `L_2` in time `O(p(|y|))`. Let `f(x)` be a `O(q(|x|))`-time reduction from `L_1` to `L_2`. Here `p` and `q` are polynomials. Then `B(x)` which first computes `f(x)` then runs `A(f(x))`, runs in `O(p(q(|x|))`-time and decides `L_1`. So `B` runs in polynomial time.

NP-completeness

Theorem. If any `NP`-complete language is in `P`, then `P=NP`.

Proof. This follows from the lemma on the last slide.

A First NP-complete problem

Let CIRCUIT-SAT be the language:
`{langle C rangle | C` is an AND, OR, NOT circuit computing a 0-1 function which on some truth assignment to its input variables outputs 1`}`

Theorem. CIRCUIT-SAT is in NP.

Proof. Consider the following algorithm `A(langle C rangle, langle a rangle)`. First, `A` checks if `langle C rangle` is in the format of a circuit and `langle a rangle` is in the format for an assignment; if not, it rejects `A`. Otherwise, it then labels each of the inputs to `langle C rangle` with their value according to their values in `langle a rangle`. Then it loops over the combinational elements in `langle C rangle`, until there is no change doing the following:

  1. Check if the current element is not assigned a value, but its children have been assigned a value.
  2. Calculate the value of the node based on its gate type and its children.

By the `i`th iteration the nodes of depth `i` will have values. Each iteration involves less than quadratic work. So in `O((|langle C rangle|)^3)` this algorithm labels the root of the circuit with its output value on this assignment. Finally, CIRCUIT-SAT is the language `{langle C rangle in {0,1}^star : exists langle a rangle, |langle a rangle| le |langle C rangle| mbox( and ) A(langle C rangle, langle a rangle) = 1}`.

Cook's Theorem

Theorem. CIRCUIT-SAT is NP-hard.

Proof. Let `L` be a language in `NP`, let `A(x,y)` verify the language in time `O(|x|^c)`. The algorithm `A` runs on some kind of computational hardware. If that hardware is in a given configuration `c_i` then its control determines in the next time step what its next configuration `c_(i+1)` will be. We assume that this mapping can be computed by some AND, OR, NOT circuit `M` implementing the computer hardware. Using this circuit `M`, we build an AND, OR, NOT circuit `langle C(y) rangle` which is split into main layers which have the properties:

  1. The output of `C` at main layer 1 codes, `c_0` , a configuration of `M` at the start of the computation of `A(x,y)`. Here the values of `x` are hard-coded based on the instance `x` which we are trying to check is in `L`. `y` is not hard-coded and boolean variables are used to represent it.
  2. For each `i`, the output of `C` at main layer `i + 1`, corresponds to the configuration obtained from main layer `i` by computing according to `M`.
  3. The output of `C` is the value extracted from the final configuration of `A` after `O(|x|^c)` steps.

Since there are polynomially many main layers each separated by polynomial-sized circuits, this whole circuit will be polynomial-size. If there is some setting of the boolean variables for `y` which makes the circuit true, then `A(x,y)` holds and `x` will be in `L` as desired.

NP-completeness Proofs

Lemma. If some `NP`-complete language reduces to a language `L`, then `L` is `NP`-hard. If `L` is further in `NP` then `L` will be NP-complete.

Proof. Just compose the reductions.

Some NP-complete Problems

Theorem. Both SAT and 3SAT are `NP`-complete.

Proof. First both languages are in `NP` by the same argument that showed CIRCUIT-SAT in `NP`. Given an instance `langle C rangle` of CIRCUIT-SAT, let gate `i` be coded as `langle i, type, j, k rangle`. Here type is AND, OR, NOT, or input, and `j, k < i` are gates which are inputs to this gate. A `0` for `j` or `k` means that argument is not used. Let `c_i`'s be new variables other than the input variables `x_j`. Recall the symbol `<=>` is true if both its boolean inputs have the same value. For each gate we create a boolean formula either of the form `c_i <=> (c_j mbox( type ) c_k)`, where type is replaced with AND or OR; or of the form `c_i <=> (mbox( type ) c_j)` in the case of NOT or an input (in the input case type is nothing). The SAT formula we output on input `langle C rangle` is the conjunction of all such defining formulas conjuncted with `c_w`, where `w` is the last gate in the formula. The idea is if `c_w` is true, then its defining equation `c_w <=>...` must be true and this propagates back to some setting of the leaves which will make the circuit true. By rewriting each `c_i <=> (c_j mbox( type ) c_k)` formulas in 3CNF we can make this whole formula into 3CNF. We can pad clauses with less than 3 literals with dummy variables to make all clauses the same size.