130 likes | 281 Views
Space Complexity. Reminder: P, NP classes. P NP is the class of problems for which: Guessing phase : A polynomial time algorithm generates a plausible solution S Checking phase : A polynomial time algorithm certifies that if S is correct A problem npc is NP-complete if: npc is in NP
E N D
Reminder: P, NP classes • P • NP is the class of problems for which: • Guessing phase: A polynomial time algorithm generates a plausible solution S • Checking phase: A polynomial time algorithm certifies that if S is correct • A problem npc is NP-complete if: • npc is in NP • For every other problem np in NP, there is a polynomial time algorithm that transforms np into npc (polynomial reduction)
P is a subset of NP • If a problem p is in P, there is an algorithm A solving p and A runs in polynomial time • How do we show that it is in NP? • MakeA the generation phase • Construct an algorithm that always returns “true” as the checking phase: check(P,S) return true
A new Problem • WIN: Generate a winning strategy for a 2-person, turn-based, perfect information, deterministic game. Example? • Suppose that the game is finite. Example? • The “n” for making complexity analysis is: • For example: Chess • Winning strategy: “policy” on JuKeCB • Chess, we assume that if it reaches 100 moves then the game ends with a tide The number of moves made during a game
A Solution: Minimax • Concepts: • State: node in search space • Operator: valid move • Terminal test: game over • Utility function: value for outcome of the game • MAX: 1st player, maximizing its own utility • MIN: 2nd player, minimizing Max’s utility
Let us examine the complexity • Is minimax polynomial? • Can we show that it is in NP? (think certification phase) • So is WIN not in NP? No. This requires exploring exponential many branches No. The minimax tree itself is exponential. So certifying it by using the minimax tree will require exponential time • We do not know. Likely it is not in NP • No one has been able to proof that is in NP (or P) • No one has been able to proof that it is not in NP (or P)
PSPACE • PSPACE is the class of all problems that can be solved with algorithms that use a polynomial amount of memory (regardless of the time they take to run) • Examples: • SAT. • ((x y) ¬x) y • We systematically try every combination: • 0010, 0111, 1000, 1101 • 2n possible combinations • But only O(n) space used • Same trick is use to show that NP is a subset of PSPACE: • Systematically generate each potential solution (need polynomial space only to keep track) • Check if it is a solution
PSPACE-complete • A problem psc is PSPACE-complete if: • psc is in PSPACE • For every other problem ps in PSPACE, there is a polynomial time algorithm that transforms ps into psc (polynomial reduction) • Example: • QBF: Satisfaction of quantified Boolean formulas: xy((x y) ¬x) y
QBF: Quantified Boolean Formulas • Qx1Qx2Qx3 …Qxn f(x1, x2, …, xn) • Where • Each xi is a variable • f(x1, x2, …, xn) is a Boolean formula without quantifiers • x1, x2, …, xn are the only variables in f • Qxi can be either xior xi • (QSAT) Decision problem: Given a QBF, is it true? false? • Observation 1: Seems difficult to prove that QSAT is in NP • Observation 2: It is easy to prove that QSAT is in PSPACE
Transforming WIN into QSAT(Example illustrating QSAT PSPACE-completeness) • QBF Formula for indicating if a winning formula exists: • Suppose x1, x2, x3, … xn are variables for 1st, 2nd, 3rd, .. moves by Player 1 • Suppose y1, y2, y3, … yn are variables for 1st, 2nd, 3rd, .. moves by Player 2 • Suppose that winPlayer1(x1, y1, x2, y2,…, yn) indicates that Player 1 wins when the game sequence is x1, y1, x2, y2,…, yn • Under this circumstances a winning strategy for Player 1 can be represented as the QBF Formula: x1 y1 x2 y2 … yn win(x1, y1, …, yn)
EXP-Classes • EXPTIME is the class of problems that can be solved with algorithms that runs in exponential time • Usual definition for EXPTIME-complete • Example: Go • EXPSPACE is the class of all problems that can be solved with algorithms that use an exponential amount of memory • Usual definition for ESPSPACE-complete • Example: HTN Planning with “regularity” • We know: P NP PSPACE EXPTIME EXPSPACE