<<

Computational complexity

Plan

Complexity of a computation. Complexity classes DTIME(T (n)). . . Relations between complexity classes. Complete problems. Domino problems. NP-completeness. Complete problems for other classes Alternating machines.

. – p.1/17 Complexity of a computation

A machine M is T (n) time bounded if for every n and word w of size n, every computation of M has length at most T (n). A machine M is S(n) space bounded if for every n and word w of size n, every computation of M uses at most S(n) cells of the working tape. Fact: If M is time or space bounded then (M) is recursive. If L is recursive then there is a time and space bounded machine recognizing L.

DTIME(T (n)) = {L(M) : M is det. and T (n) time bounded}

NTIME(T (n)) = {L(M) : M is T (n) time bounded}

DSPACE(S(n)) = {L(M) : M is det. and S(n) space bounded}

NSPACE(S(n)) = {L(M) : M is S(n) space bounded}

. – p.2/17 Hierarchy theorems

A function S(n) is space constructible iff there is S(n)-bounded machine that given w writes aS(|w|) on the tape and stops. A function T (n) is time constructible iff there is a machine that on a word of size n makes exactly T (n) steps.

Thm: Let S2(n) be a space-constructible function and let S1(n) ≥ log(n). If S1(n) lim infn→∞ = 0 S2(n) then DSPACE(S2(n)) − DSPACE(S1(n)) is nonempty.

Thm: Let T2(n) be a time-constructible function and let T1(n) log(T1(n)) lim infn→∞ = 0 T2(n) then DTIME(T2(n)) − DTIME(T1(n)) is nonempty.

. – p.3/17 Relations between complexity classes

Thm: 1. DTIME(T (n)) ⊆ NTIME(T (n)) 2. NTIME(T (n)) ⊆ DSPACE(T (n)) 3. DSPACE(S(n)) ⊆ NSPACE(S(n)) cS(n) 4. DSPACE(S(n)) ⊆ Sc>0 DTIME(2 ), for S(n) ≥ log(n). cS(n) 5. NSPACE(S(n)) ⊆ Sc>0 DTIME(2 ), for S(n) ≥ log(n) which is space constructible.

Thm[Sawitch]: If S(n) ≥ log(n) is space constructible then 2 NSPACE(S(n)) ⊆ DSPACE(S(n) ).

Thm[Immerman, Szelepcsenyi]: If S(n) ≥ log(n) is space constructible then NSPACE(S(n)) is closed under complementation.

. – p.4/17 Some standard complexity classes

LOGSPACE = DSPACE(log(n)) NLOGSPACE = NSPACE(log(n)) c P = PTIME = Sc∈ DTIME(n ) c NP = Sc∈ NTIME(n ) c c

PSPACE = Sc∈ DSPACE(n ) = Sc∈ NSPACE(n ) EXPTIME = Sc∈ DTIME(2 ) nc NEXPTIME = Sc∈ NTIME(2 ) nc nc EXPSPACE = Sc∈ DSPACE(2 ) = Sc∈ NSPACE(2 )

LOGSPACE ⊆ NLOGSPACE ⊆ P ⊆ NP ⊆ PSPACE ⊆ ⊆ EXPTIME ⊆ NEXPTIME ⊆ EXPSPACE

NLOGSPACE =6 PSPACE =6 EXPSPACE P =6 EXPTIME NP =6 NEXPTIME

. – p.5/17 Reductions, complete problems

∗ ∗ We say that L1 ⊆ Σ1 is poly-time reducible to L2 ⊆ Σ2 ∗ ∗ (L1 ≤P L2) if there is a function f : Σ1 → Σ2 computable in PTIME such that w ∈ L1 iff ϕ(w) ∈ L2 Similarly for log-space reducible. Language L hard for a class K if for every L0 ∈ K there is poly-time reducible to L. Language L is complete for a class K if L ∈ K and L is hard for K.

Fact: 0 0 If L ≤P L and L ∈ P then L ∈ P. If there exists NP-complete language L such that L ∈ P then P = NP. 0 0 If L is NP-complete and L ≤p L then L is NP-hard.

. – p.6/17 Domino problems

Let C ba a countable set of colours. A domino type is a quadruple d = (l, , u, d) of colours.

D1: Given a finite set T of domino types, number n (in unary) and two domino types dl, du, decide if a grid n × n can be tiled with dominoes of types from T that the bottom leftmost tile is of type dl and top leftmost tile is of type du. D2: The same but now we need to find m such that there is a tiling of n × m. D3: The same but now we need to find both m and n. D4: Given d and T is there a tiling of a quarter of the plane N × N with leftmost bottom tile of type d.

. – p.7/17 Domino problems cont.

D1: Given a finite set T of domino types, number n (in unary) and two domino types dl, du, decide if a grid n × n can be tiled with dominoes of types from T so that the bottom leftmost tile is of type dl and top leftmost tile is of type du. D2: The same but now we need to find m such that there is a tiling of n × m. D3: The same but now we need to find both m and n. D4: Given d and T is there a tiling of a quarter of the plane N × N with leftmost bottom tile of type d.

Thm: Problem D1 is NP-complete. Problem D2 is PSPACE-complete. Problem D3 is r.. but not recursive. Problem 0 D4 is Π1 in the arithmetic hierarchy.

. – p.8/17 Problem D1

Take M = hQ, Σ, Γ, q0, B, δ, A, Ri. Let p(n) be the polynomial time bound for M.

For every word w ∈ Σ∗ we construct a set of tile types T (w) of size |T (w)| = O(p(|w|), and two types dl and dr so that w ∈ L(M) iff problem D1 has a solution for (T (w), dl, dr, p(|w|)).

. – p.9/17 Tiles

|L qw0 w1 wn 0 0 1 1 2 n n + 1 Initial tiles: |L ⊥ ⊥ . . . ⊥ . . . B B |R n + 1 n + 2 p(n) − 1 p(n) p(n) ¡ ⊥ . . . ⊥ |R a |L |R ¡ B B B B a Copy tiles: for a ∈ Σ |L |R b q0c B q0R q0R B qa c Transition tiles: if (q, a, q0, b, +1) ∈ δ q0c b B q0L q0L B c qa if (q, a, q0, b, −1) ∈ δ . – p.10/17 SAT problem is NP complete

Reduction of D1 to SAT.

Let n, T = {d1, . . . , dk} and dl, du be given. Consider the formulas: n n k Vi=1 Vj=1(Wm=1 LRUDi,j = dm) n n Vi=1 Vj=1(RIGHTi,j = LEFTi+1,j ∧ UPi,j = DOWNi,j+1)

LRUD1,1 = dl, LRUD1,n = du

The conjunction of these formulas is satisfiable iff (T, dl, dr, n) has a solution.

. – p.11/17 Other NP-complete problems

3-SAT is NP-complete: (α11 ∨ α12 ∨ α13) ∧ · · · ∧ (αn1 ∨ αn2 ∨ αn3).

Graph coloring is NP-complete: (G, k).

Clique problem is NP-complete: (G, k).

Hamilton cycle problem is NP complete: G.

Knapsack problem is NP complete: i1, . . . , ik, min, max ∈ N, check existence of A ⊆ {1, . . . , k} such that min ≤ Pj∈A ij ≤ max.

. – p.12/17 Class CONP

∗ L ∈ CONP iff Σ − L ∈ NP. Fact: If L is NP-complete and L ∈ CONP then NP = CONP. Fact: {α : α is a true propositional formula} is CONP complete. ∗ PRIMES = {w ∈ {0, 1} : w is a binary repr. of a prime number} PRIMES ∈ CONP PRIMES ∈ NP. Thm[Agrawal, Kayal, Saxena, 2002]: PRIMES ∈ P.

Parity game: a finite game with a Mostowski winning condition and fixed initial vertex. PG = {G : player 0 has a winning strategy in the parity game G} PG ∈ NP ∩ CONP Open: Is PG ∈ P?

. – p.13/17 PSPACE

Quantified Boolean Formulas (QBF): ∃x1.∀x2. . . . .∃xn.α where x1, . . . , xn are propositional variables and α a propositional formula.

Thm: The set {β : β is a true QBF formula} is PSPACE-complete.

. – p.14/17 Alternating Turing Machines

M = hQ∃, Q∀, Σ, Γ, q0, B, δ, A, Ri

Such a machine accepts iff player ∃ has a winning strategy in the associated game.

We can define ATIME(T (n)) and ASPACE(S(n)) as a maximal time and space used in any possible computation. P Σi = {L(M) : M is a ATIME(p(n)) machine with (i − 1) alternations and starting in ∃ state} P Πi = {L(M) : M is a ATIME(p(n)) machine with (i − 1) alternations and starting in ∀ state} P P Σ1 = NP, Π1 = CONP.

. – p.15/17 ATIME and ASPACE

Thm: If S(n) ≥ log(n) then 2 2 NSPACE(S(n)) ⊆ ATIME(S(n) ) ⊆ DSPACE(S(n) ).

cS(n) Thm: If S(n) ≥ log(n) then ASPACE(S(n)) = Sc∈ DTIME(2 ).

. – p.16/17 Exercises

2 What is the relation between classes DSPACE(n ) and 3 DSPACE(S(n)) where S(n) = n for n even and S(n) = n for n odd. n n What is the relation between NSPACE(2 ) and DSPACE(5 ).

Show that if there is a PSPACE-hard language L such that L ∈ P then PSPACE = P. L ∈ NP iff there is a polynomial p(n) and a language R ∈ P such that L = {x : ∃y. |y| = p(|x|) and (x, y) ∈ R}.

Show that if there is a NP-complete language over singleton alphabet then P = NP.

. – p.17/17