Introduction

A puzzle: depth CS151 two kinds n of trees Complexity Theory ...... Lecture 4 April 8, 2004 • cover up nodes with c colors • promise: never color “arrow” same as “blank” • determine which kind of tree in poly(n, c) steps?

April 8, 2004 CS151 Lecture 4 2

A puzzle A puzzle

depth depth n n

......

April 8, 2004 CS151 Lecture 4 3 April 8, 2004 CS151 Lecture 4 4

Introduction Outline • Ideas – depth-first-search; stop if see • sparse languages and NP – how many times may we see a given “arrow • nondeterminism applied to space color”? • at most n+1 • reachability – pruning rule? • if see a color > n+1 times, it can’t be an • Savitch’s Theorem arrow node; prune – # nodes visited before know answer? • Immerman/Szelepcsényi Theorem • at most c(n+2)

April 8, 2004 CS151 Lecture 4 5 April 8, 2004 CS151 Lecture 4 6

1 Sparse languages and NP Sparse languages and NP

• We often say NP-compete languages are • : one that contains at “hard” most poly(n) strings of length ≤ n • not very expressive – can we show this cannot be NP-complete (assuming P ≠ • More accurate: NP-complete languages NP) ? are “expressive” – yes: Mahaney ’82 (homework problem) – lots of languages reduce to them • Unary language: subset of 1* (at most n strings of length ≤ n)

April 8, 2004 CS151 Lecture 4 7 April 8, 2004 CS151 Lecture 4 8

Sparse languages and NP Sparse languages and NP

Theorem (Berman ’78): if a unary language – self-reduction tree for : is NP-complete then P = NP. (x1,x2,…,xn)

• Proof: (0,x2,…,xn) (1,x2,…,xn) – let U ⊂ 1* be a unary language and assume . . SAT ≤ U via reduction R . . . . – (x1,x2,…,xn) instance of SAT (0,0,…,0) (1,1,…,1) satisfying assignm ent

April 8, 2004 CS151 Lecture 4 9 April 8, 2004 CS151 Lecture 4 10

Sparse languages and NP Sparse languages and NP

• Applying reduction R: • on input of length ≤ |(x1,x2,…,xn)|, R

R( (x1,x2,…,xn)) produces string of length ≤ p(n) • R’s different outputs are “colors” R( (0,x ,…,x )) R( (1,x ,…,x )) 2 n 2 n – 1 color for strings not in 1* . . – at most p(n) other colors . . . . R( (0,0,…,0)) R( (1,1,…,1)) • puzzle solution Ω can solve SAT in satisfying assignm ent poly(p(n)+1, n+1) = poly(n) time!

April 8, 2004 CS151 Lecture 4 11 April 8, 2004 CS151 Lecture 4 12

2 Nondeterministic space Nondeterministic space

• NSPACE(f(n)) = languages decidable by a • Robust nondeterministic space classes: multi-tape NTM that touches at most f(n) squares of its work tapes along any NL = NSPACE(log n) computation path, where n is the input length, and f :N ä N ∪ k NPSPACE = k NSPACE(n )

April 8, 2004 CS151 Lecture 4 13 April 8, 2004 CS151 Lecture 4 14

Reachability Reachability

• Recall: at most nk configurations of given • Conclude: NL ⊂ P NTM M running in NSPACE(log n). – and NPSPACE ⊂ EXP

• easy to qstartx1x2x3…xn determine if C x∈L x∉L • S-T-Connectivity (STCONN): given yields C’ in one directed graph G = (V, E) and nodes s, t, is step there a path from s to t • configuration graph for M on Theorem: STCONN is NL-complete under input x: logspace reductions. qaccept qreject qaccept qreject

April 8, 2004 CS151 Lecture 4 15 April 8, 2004 CS151 Lecture 4 16

Reachability Two startling theorems

• Proof: • Strongly believe P ≠ NP – in NL: guess path from s to t one node at a • nondeterminism seems to add enormous time power ∈ – given L NL decided by NTM M construct • for space: Savitch ‘70: configuration graph for M on input x (can be done in logspace) NPSPACE = PSPACE

– s = starting configuration; t = qaccept and NL ⊂ SPACE(log2n)

April 8, 2004 CS151 Lecture 4 17 April 8, 2004 CS151 Lecture 4 18

3 Two startling theorems Savitch’s Theorem

• Strongly believe NP ≠ coNP Theorem: STCONN ∈ SPACE(log2 n) • seems impossible to convert existential into universal • Corollary: NL ⊂ SPACE(log2n)

• for space: Immerman/Szelepscényi ’87/’88: • Corollary: NPSPACE = PSPACE

NL = coNL

April 8, 2004 CS151 Lecture 4 19 April 8, 2004 CS151 Lecture 4 20

Proof of Theorem Proof of Theorem

– input: G = (V, E), two nodes s and t – answer to STCONN: PATH(s, t, log n) – recursive algorithm: – space used: • (depth of recursion) x (size of “stack record”) i /* return true iff path from x to y of length at most 2 */ – depth = log n PATH(x, y, i) – claim stack record: “(x, y, i)” sufficient if i = 0 return ( (x, y) ∈ E ) /* base case */ • size O(log n) for z in V if PATH(x, z, i-1) and PATH(z, y, i-1) return(true); – when return from PATH(a, b, i) can figure out return(false); what to do next from record (a, b, i) and end previous record

April 8, 2004 CS151 Lecture 4 21 April 8, 2004 CS151 Lecture 4 22

I-S Theorem I-S Theorem

Theorem: ST-NON-CONN ∈ NL – want nondeterministic procedure using only • Proof: slightly tricky setup: O(log n) space with behavior: – input: G = (V, E), two nodes s, t s s “yes” “no” input input “yes” “no”

qreject qaccept t t

April 8, 2004 CS151 Lecture 4 23 April 8, 2004 CS151 Lecture 4 24

4 I-S Theorem I-S Theorem

– observation: given count of # nodes – every computation path has sequence of reachable from s, can solve problem guesses… • for each v ∈ V, guess if it is reachable – only way computation path can lead to accept: • if yes, guess path from s to v • correctly guessed reachable/unreachable – if guess doesn’t lead to v, reject. for each node v – if v = t, reject. • correctly guessed path from s to v for each – else counter++ reachable node v • if counter = count accept • saw all reachable nodes • t not among reachable nodes

April 8, 2004 CS151 Lecture 4 25 April 8, 2004 CS151 Lecture 4 26

I-S Theorem I-S Theorem

– R(i) = # nodes reachable from s in at most i – Outline: in n phases, compute steps R(1), R(2), R(3), … R(n) – R(0) = 1: node s – only O(log n) bits of storage between phases – in end, lots of computation paths that lead to – we will compute R(i+1) from R(i) using reject O(log n) space and nondeterminism – only computation paths that survive have computed correct value of R(n) – computation paths with “bad guesses” all lead – apply observation. to reject

April 8, 2004 CS151 Lecture 4 27 April 8, 2004 CS151 Lecture 4 28

I-S Theorem I-S Theorem

– computing R(i+1) from R(i): – if “yes”, guess path from s to v of at most i+1 steps. Increment R(i+1) – if “no”, visit R(i) nodes reachable in at most i R(i) = R(2) = 6 steps, check that none is v or adjacent to v • for u ∈ V guess if reachable in ≤ i steps; guess path to u; counter++ – Initialize R(i+1) = 0 • KEY: if counter ≠ R(i), reject – For each v ∈ V, guess if v reachable from s in • at this point: can be sure v not reachable at most i+1 steps

April 8, 2004 CS151 Lecture 4 29 April 8, 2004 CS151 Lecture 4 30

5 I-S Theorem I-S Theorem • (2) might guess v is not reachable in at • correctness of procedure: most i+1 steps when it is • two types of errors we can make – then must not see v or neighbor of v while • (1) might guess v is reachable in at most visiting nodes reachable in i steps. i+1 steps when it is not – but forced to visit R(i) distinct nodes – won’t be able to guess path from s to v of – therefore must try to visit node v that is not correct length, so we will reject. reachable in ≤ i steps – won’t be able to guess path from s to v of “easy” type of error correct length, so we will reject. “easy” type of error April 8, 2004 CS151 Lecture 4 31 April 8, 2004 CS151 Lecture 4 32

Summary Summary

• unary languages not NP-complete unless • Savitch: NPSPACE = PSPACE P = NP – Proof: ST-CONN ∈ SPACE(log2 n) – true for sparse languages as well (homework) – open question: NL = L? • nondeterministic space classes NL and NPSPACE • Immerman/Szelepcsényi : NL = coNL – Proof: ST-NON-CONN ∈ NL • ST-CONN NL-complete

April 8, 2004 CS151 Lecture 4 33 April 8, 2004 CS151 Lecture 4 34

6