250 likes | 353 Views
CSci 4011. INHERENT LIMITATIONS OF COMPUTER PROGRAMS. QUIZ 6. B is NP-Complete if:. (a) B ∈ NP. (b) ∀ A ∈ NP, A ≤ P B. Reduction from HAMPATH to KPATH:. ƒ (〈 G,s,t 〉) = 〈 G,s,t,|V |-1〉. n ifty proof that 〈[ 14, 24, 13, 5, 1, 23, 29, 11], 42〉 ∈ SSUM:.
E N D
CSci 4011 INHERENT LIMITATIONS OF COMPUTER PROGRAMS
QUIZ 6 B is NP-Complete if: (a) B ∈ NP (b) ∀ A ∈ NP, A ≤P B Reduction from HAMPATH to KPATH: ƒ(〈G,s,t〉) = 〈G,s,t,|V|-1〉 nifty proof that 〈[14, 24, 13, 5, 1, 23, 29, 11], 42〉 ∈ SSUM: Many, e.g. 14+23+5 = 42; 13+29 = 42 Nifty Proof that 〈G〉 ∈ 3COLOR:
Definition: Let M be a deterministic TM that halts on all inputs. The space complexity of M is the function f : N N, where f(n) is the rightmost tape position that M reaches on any input of length n. { L | L is a language decided by a O(t(n)) space deterministic Turing Machine } Definition: SPACE(t(n)) =
PSPACE = SPACE(nk) k N 3SAT PSPACE PSPACE = NPSPACE P NP PSPACE EXPTIME
HARDEST PROBLEMS IN PSPACE Definition: Language B is PSPACE-complete if: 1. B PSPACE 2. Every A in PSPACE is poly-time reducible to B (i.e. B is PSPACE-hard)
QUANTIFIED BOOLEAN FORMULAS xy [ x y ] x [ x x ] x [ x ] xy [ (x y) (x y) ]
Definition: A fully quantified Boolean formula (or a sentence) is a Boolean formula in which every variable is quantified xy [ x y ] x [ x x ] x [ x ] xy [ (x y) (x y) ]
TQBF = { | is a true fully quantified Boolean formula} Theorem: TQBF is PSPACE-complete
TQBF PSPACE is_true(): 1. If contains no quantifiers, then it is an expression with only constants, so simply evaluate 2. If = x , recursively call isTrue on , first with x = 0 and then with x = 1. Accept if either one of them is true. 3. If = x , recursively call isTrue on , first with x = 0 and then with x = 1. Accept if both of them are true.
Claim: Every language A in PSPACE is polynomial time reducible to TQBF We build a poly-time reduction from A to TQBF Let M be a deterministic TM that decides A in space nk The reduction turns a string w into a fully quantified Boolean formula that is true iff M has an accepting computation on w.
We let = c , c , h, where h = 2nk+1 start accept We now design so that a satisfying assignment to the variables corresponds to M accepting w Given two collections of variables denoted c and d representing two configurations of M and a number t > 0, we construct a formula c,d,t If we assign c and d to actual configurations, c,d,t will be true if and only if M can go from c to d in t steps
If t = 1, we can easily construct c,d,t: c,d,t = “c equals d” or “d follows from c in a single step of M” “c equals d” says that each for each i, ci = di. “d follows from c in a single step of M” can be expressed as we did with SAT
If t > 1, we can build c,d,trecursively: c,d,t = m [c,m,t/2 m,d,t/2 ] m1m2 … 9ml O(t) = 2O(nk) How long is this formula? Since O(t) is too long, we modify the formula to be: c,d,t = ma,b[ [(a,b)=(c,m) (a,b)=(m,d)] [ a,b,t/2 ] ]
PSPACE is frequently called the class of games because many popular games are PSPACE-Complete
THE FORMULA GAME …is played between two players, E and A Given a fully quantified Boolean formula yx [ (x y) (x y) ] E chooses values for variables quantified by A chooses values for variables quantified by Start at the leftmost quantifier E wins if the resulting formula is true A wins otherwise
xy [ x y ] xy [ (x y) (x y) ] FG = { | Player E can force a win in } Theorem: FG is PSPACE-Complete Proof: FG = TQBF
GEOGRAPHY Two players take turns naming cities from anywhere in the world Each city chosen must begin with the same letter that the previous city ended with Cities cannot be repeated Austin Nashua Albany York Whoever cannot name any more cities loses
e f b g a i d h c GENERALIZED GEOGRAPHY
GG = { 〈G,b〉 | Player I has a winning strategy for the generalized geography game played on graph G starting at node b } Theorem: GG is PSPACE-Complete
GG PSPACE def current_player_wins(G, s): False if neighbors(s,G) = Ø: return G’ = remove_node(s,G) for t ∈ neighbors(s,G): return True. if not(current_player_wins(G’,t)): else: return False Maximum recursion depth: |G| Space complexity: O(|G|²)
GG IS PSPACE-HARD We show that FG P GG We convert a formula into 〈G,b〉 such that: Player E has winning strategy in if and onlyif Player I has winning strategy in 〈G,b〉 For simplicity we assume is of the form: = x1x2x3…xk [] where is in cnf
(x1 x1 x2) (x1 x2 x2) … c2 cn c1 x1 x1 x2 b x2 x1 x2 c TRUE FALSE x1 x2 xk
c1 x1 x1 x1 b c x1 [ (x1 x1 x1) ] TRUE FALSE x1
Question: Is Chess PSPACE complete? No, because determining whether Player I has a winning strategy takes constant time and space n x n GO, chess and checkers can be shown to be PSPACE-hard