NP Completeness

San Diego State University

- Q is a binary relation on set of problem instances I and a set of problem solutions S

Example - Shortest Path

- Find the shortest path in a graph between two vertices.

- I = { (G, s, e) | G = (V, E) is unweighted undirected graph, s
_{ }V is the start vertex, e_{ }V is the end vertex }

- S = { (G, p) | G = (V, E), p is a path in G }

- Let a =( G, s, e )
_{ }I then

- Usually use Shortest Path instead of Q

- Given a graph G = (V, E) and two vertices s, e
_{ }V does there exist a path in G between s and e whose length is at most k? - I = { (G, s, e, k) | G = (V, E) is unweighted undirected graph, s
_{ }V is the start vertex, e_{ }V is the end vertex, k upper bound on shortest path }

- S = { 0, 1 }

- Let a = ( G, s, e, k )
_{ }I then - Path(a) = 1 if shortest path from s to e has length <= k
- Path(a) = 0 if shortest path from s to e has length > k

Most problems can be restated as a decision problem

Example:

- Let x be an integer, is x even?
- Let I = { binary strings}, S = { 0, 1 }
- Let x
_{ }I then we have - Even(x) = 1
- if x
_{1 }= 1 - Even(x) = 0
- if x
_{0 }= 1

An algorithm solves a concrete problem in time O(T(n)) if

- given a
_{ }I with n = |a| the algorithm finds the solution in at most O( T(n) ) time

- A concrete problem is polynomial-time solvable if there exits an algorithm
to solve it in time O(n
^{k}) for some constant k

- An encoding "e" is a mapping from a set S to binary strings

s a b c d e s 0 1 0 1 0 0 a 1 0 1 0 1 0 b 0 1 0 1 0 1 c 1 0 1 1 0 0 d 0 1 0 1 0 1 e 0 0 1 0 1 0

010100101010010101101100010101001010

Example Is K a prime number?

- Algorithm
- divide K by all integers 2, 3, 4, ..., K -1
- If any integer divides K it is not prime
- Worst case requires K -2 divisions (Use K for simplicity)
**Embedding 1**K -> binary representation of K- Input length is n = lg(K)
- Time Complexity T(n) = K = 2
^{n } **Embedding 2**Place the J'th bit of K in location 2^{J}, fill rest of locations with 0.- Input length is n = K
- Time Complexity T(n) = n

Given set of problem instances I, encodings e

- a
_{ }I -> f_{1}( e_{1}( a ) ) = e_{2}( a ) and f_{2}( e_{2}( a ) ) = e_{1}( a )

Lemma

- Let Q be an abstract decision problem on an instance set I, and let
e
_{1}and e_{2}be encodings polynomially related encodings on I. Then - e
_{1}( Q )_{ }P if and only if e_{2}( Q )_{ }P

- any set of strings made up of symbols from
_{ }

Empty string denoted by

Empty language by

- L = { xy : x
_{ }L_{1}and y_{ }L_{2 }}

_{ }

- Let
_{ }= {0, 1} then set of binary strings =_{ } - Let Q be a decision problem
- L = {x
_{ }: Q(x) = 1 }

Algorithm A

Algorithm A

The language accepted by algorithm A is

- L = { x
_{ }{ 0, 1 }^{* }: A(x) = 1}

A language L is decided by algorithm A if every binary string is either accepted or rejected by algorithm A

A language L is accepted in polynomial time by algorithm A if for any string of length n in L is accepted by A in time O(n

A language L is decided in polynomial time by algorithm A if for any string of length n in { 0, 1 }

We can redefine P as:

P = {

Theorem

- P = { L : L is accepted by a polynomial-time algorithm }

A

Let m = |V|, it takes m! operations to determine if G= (V, E) is a hamiltonian graph

If Mary claims a graph is hamiltonian graph and provides a the vertices in order on the hamiltonian cycle then we can verify his claim in polynomial time

The potential cycle is called the certificate.

A

One argument is an ordinary input string x, the other is the

"A" verifies input x if there exists a certificate such that

A(x, y) = 1

The

L = { x

Theorem

proof:

If L

- That is for any x
_{ }L we can compute B(x) in polynomial time and B(x) = 1 - Now let A( x ,y ) = B( x )
- Then A( x, y ) verifies x in polynomial time

Language L

- f : { 0, 1 }
^{*}-> { 0, 1 }^{*}

- x
_{ }L_{1}if and only if f( x )_{ }L_{2}

We write L

Lemma 36.3 Assume that L

A language

1. L

2. L

Theorem 36.4

- a. If any NP-complete problem is polynomial solvable then
- P = NP.

- b. If any NP-complete problem is not polynomial solvable then all NP-complete problems are not polynomial solvable