26
Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science University of St Andrews Scotland

Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

Embed Size (px)

Citation preview

Page 1: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

Algorithms and Problemsfor Quantified SAT

Toby Walsh

Department of Computer ScienceUniversity of York

England

Ian P. Gent

School of Computer ScienceUniversity of St Andrews

Scotland

Page 2: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

Algorithms and Problemsfor Quantified SAT

1. Quantified Satisfiability QSAT2. The Evaluate Algorithm3. A New Algorithm 4. Phase Transitions5. Phase Transition in QSAT

Page 3: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

Quantified satisfiability (QSAT)

Existential quantifiersas in propositional SAT

Universal quantifiers"x. $ y. (x v y) & (-x v -y) x=true, then y=false satisfiesx=false, then y=true satisfies

also called quantified Boolean formulae (QBF)

QSAT can be seen as an alternating game between existentials which want to make formula true, and universals which want to make it false

Page 4: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

Complexity of QSATPSPACE-complete

no limit on number of alternating quantifiers

problems needing polynomial space on a Turing machine

k-QSATk alternations, $ innermost Sk P-complete

CNF formulaedoes not change complexity

Page 5: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

Algorithms for QSAT

Recent Algorithms by... Cadoli, Giovanardi & Schaerf, AAAI 98, SAT 2000.simple to avoid

Both based on similar ideaWork `outside in'Set outermost quantifiers first, then next level ...

Both make extensive use of propagation rulesI will present a simplified version of Cadoli's

Page 6: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

Cadoli et al's Evaluate algorithmTwo mutually recursive functions

U-evaluate for universal quantifiers E-evaluate for existential quantifier

Many propagation rules in eache.g. `unit propagation'

If a clause exists with only a single existential literal ... commit to the E-variable having the relevant value

I will not detail propagation rulesFocus on branching nature of search ...... and an unusual preprocessing step

Page 7: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

An unusual preprocessing stepGiven a QSAT formula F Form existential simplification E(F)

Discard universal literals in F

Solve E(F) as SAT problem (not as QSAT)Use classic Davis-Putnam

If DP succeeds, F is soluble as QSATSame values of e-variables works for all values of u-

variables

Page 8: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

Function U-Evaluate(F) If clause set is empty, succeed If there is empty/all universal clause, fail Try Davis-Putnam on Existential Simplification

If this solves all clauses, succeed

Apply Propagation rules If the outermost quantifier is now Existential

Return result of E-evaluate(F)

Choose a U-variable u Fail if U-Evaluate(F u:=true) fails Else return result of U-Evaluate(F u:=false)

Page 9: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

Function E-Evaluate(F) If clause set is empty, succeed If there is empty/all universal clause, fail Try Davis-Putnam on Existential Simplification

If this solves all clauses, succeed

Apply Propagation rules If the outermost quantifier is now Universal

Return result of U-evaluate(F)

Choose a E-variable e Succeed if E-Evaluate(F e:=true) succeeds Else return result of E-Evaluate(F e:=false)

Page 10: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

Thoughts about theAlgorithms Both Rintanen/Cadoli algorithms successful

Cadoli et al on Random Problems Rintanen on `Conditional Planning' Problems

Blind search successfulespecially notable in U-evaluatesimple enumeration of possibilities

SAT preprocessing successful yet work often discarded

New algorithm should: avoid blind search/avoid discarding SAT work

Page 11: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

Failure Driven Search Any partial solution (e.g. from DP) is helpful ...

... as long as it solves all clauses without universals The existential assignment solves many clauses

applies to all universal assignments ... except those invalidating universals in unsat clauses

Future tests need only solve remaining cases Failure-driven rather than blind search Exploits work done by failed calls to DP

Page 12: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

No-commitment Search We can try hard to avoid guessing universals Set them as unknown initially Treat all literals as false if value = unknown

Attempt to solve without choosing value Only forced to choose a value on backtracking for universal values not solved by existentials

Page 13: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

Hard and Soft Clauses Soft Clauses

clauses that can be left unsolved on this attempt have some free universal variables e.g. U or V or W or E if we set E = false, have solution when U/V/W true next test we set U=V=W=false and force new solution

Hard Clauses clauses that must be solved for problem to be soluble i.e. No universal variables, e.g. E

Page 14: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

Revised E-evaluate

Takes hard and soft clauses as input Fails if hard clauses alone are insoluble Succeeds if hard clauses are soluble

solves as many soft clauses as possible can use heuristic method on soft clauses returns list of unsatisfied soft clauses

Calls U-evaluate recursively for hard clauses

Page 15: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

Revised U-evaluate([F]) Uses ToDo list of subproblems

Initially ToDo = [ F ] Succeed when ToDo empty

Removes element G of ToDo list Call E-evaluate(G)

fail if E-evaluate fails if E-evaluate succeeds ...

for each unsat soft clause returned assign universals so as to unsatisfy the soft clause add the resulting simplified problem to ToDo

Return result of U-evaluate on revised ToDo list

Page 16: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

Comments Where did DP go? DP call evaporates!

First step in U-evaluate is to call E-evaluate We are always reasoning on existentials first DP could be used as heuristic on soft clauses As could WalkSAT ...

Where is unknown value set? Unknown value is set implicitly

when U-evaluate calls E-evaluate without setting universal

Page 17: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

Conclusions (Algorithms)

Recent algorithms making QSAT feasible Existing algorithms have possible drawbacks

blind searchwasted work

Can remove these drawbacks Exercises for the interested author...

Correctness proof (except 2-QSAT) Implementation Empirical Evaluation

Page 18: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

Phase transition behaviour

Seen in many NP-hard problemsSAT, CSP, number

partitioning, TSP ...seminal IJCAI-91

paper by Cheeseman, Kanefsky & Taylor

rapid solubility transitionaround <Sol> » 1

Page 19: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

Phase transition behaviourComplexity peak

associated with solubility transition

easy-hard-easyproblems on "knife-

edge"a theory of

constrainednessmodels such behaviourk = 1-log(<Sol>)/n -96, 97, 98AAAI

Page 20: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

Other complexity classesPolynomial problems

enforcing arc-consistency in CSPs [CP-97]

worst-case complexity seen at phase boundary

k useful to predict location of transition

What about higher complexity classes?

Page 21: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

QSAT phase transition

Fixed clause length modelk alternating quantifierseach with n variables l clauses each with h literals

Cadoli et al (AI*IA97, AAAI98)not always an easy-hard-easy

patternsolubility transition at l µÖn

Page 22: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

Flawed problem generation!Propositional satisfiability

may generate unit clauses, x and -x

just as 2 people here are likely to have same birthday

Quantified satisfiabilitymay generate clause with

single existential, x and another with -x

no satisfying assignmentsimple argument gives l µÖn

Two fixes:Model A, discard clauses with one or fewer existentialsModel B, fix number of existentials in each clause

Easy fix:discard unit clauses

Page 23: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

QSAT phase transition

Page 24: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

QSAT phase transition

Easy-hard-easy pattern now clearly visiblephase transition around fixed l/n

2-QSAT, 3-cnf

Page 25: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

QSAT phase transition

Clear complexity "ridge"varying l/n, and proportion of universals larger gap between higher percentiles than in NP?

ãJ. Rintanen

Page 26: Algorithms and Problems for Quantified SAT Toby Walsh Department of Computer Science University of York England Ian P. Gent School of Computer Science

Conclusions (Transitions)

Be careful of "flaws"SAT, CSP, QSAT ...simple to avoid

QSAT phase transitionsimilar to that seen in NPconstrainedness, k useful but less accuate

We predict similar results in other PSPACE problemsgame playing and planning