SAT - PowerPoint PPT Presentation

1 / 76
About This Presentation
Title:

SAT

Description:

KNOWLEDGE REPRESENTATION & REASONING - SAT. 1 ... Given a propositional formula in Conjunctive Normal Form (CNF), find an ... Tableau (NTAB), POSIT, 2cl, CSAT ... – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 77
Provided by: vsi42
Category:
Tags: sat | posit

less

Transcript and Presenter's Notes

Title: SAT


1
  • SAT
  • Problem Definition
  • KR with SAT
  • Tractable Subclasses
  • DPLL Search Algorithm
  • Slides by Florent Madelaine
  • Roberto Sebastiani
  • Edmund Clarke
  • Sharad Malik
  • Toby Walsh
  • Kostas Stergiou

2
Material of lectures on SAT
  • SAT definitions
  • Tractable subclasses
  • Horn-SAT
  • 2-SAT
  • CNF
  • Algorithms for SAT
  • DPLL-based
  • Basic chronological backtracking algorithm
  • Branching heuristics
  • Look-ahead (propagation)
  • Backjumping and learning
  • Local Search
  • GSAT
  • WalkSAT
  • Other enhancements
  • Application of SAT
  • Planning as satisfiability
  • Hardware verification

3
What is SAT?
Given a propositional formula in Conjunctive
Normal Form (CNF), find an assignment to Boolean
variables that makes the formula true
c1 (x2 ? x3) c2 (?x1 ? ?x4) c3 (?x2 ?
x4) A x10, x21, x30, x41
SATisfying assignment!
4
Why do we study SAT?
  • Fundamental problem from theoretical point of
    view
  • NP-completeness
  • First problem to be proved NP-complete (Cooks
    theorem)
  • Reduction to SAT often used to prove
    NP-completeness for other problems
  • Studies on tractability
  • Numerous applications
  • CAD, VLSI
  • Combinatorial Optimization
  • Bounded Model Checking and other type of formal
    software and hardware verification
  • AI, planning, automated deduction

5
Representing knowledge using SAT
  • Embassy ball (a diplomatic problem)
  • King wants to invite PERU or exclude QATAR
  • Queen wants to invite QATAR or ROMANIA
  • King wants to exclude ROMANIA or PERU
  • Who can we invite?

6
Representing knowledge using SAT
  • Embassy ball (a diplomatic problem)
  • King wants to invite PERU or exclude QATAR
  • Queen wants to invite QATAR or ROMANIA
  • King wants to exclude ROMANIA or PERU
  • (P ? ?Q) ? (Q ? R) ? (?R ? ?P)
  • is satisfied by Ptrue, Qtrue, Rfalse
  • and by Pfalse, Qfalse, Rtrue

7
Other applications of SAT
  • Hardware verification

S Cin ? (P ? Q),
8
Formulation of a famous problem as SAT
k-Coloring
The K-Coloring problem Given an undirected graph
G(V,E) and a natural number k, is there an
assignment color
9
Formulation of a famous problem as SAT
k-Coloring
xi,j node i is assigned the color j (1 ? i ?
n, 1 ? j ? k) Constraints
10
SAT Notation
  • Boolean Formula
  • T and F are formulas
  • A propositional atom (variable) is a formula
  • If f1 and f2 are formulas then ?f1, f1?f2,
    f1?f2, f1?f2, f1?f2 are formulas
  • Atoms(f) the set of atoms appearing in f
  • Literal either an atom p (positive literal) or
    its negation ?p (negative literal)
  • p and ?p are complementary literals
  • Clause a disjunction L1 ? ? Ln, n ? 0 of
    literals.
  • Empty clause when n 0 (the empty clause is
    false in every interpretation).
  • Unit clause when n 1.

11
SAT Notation
  • Total truth assignment µ for f
  • µ Atoms(f) ?,F
  • Partial Truth assignment µ for f
  • µ A ?,F, A ? Atoms(f)
  • Set and formula representation of an assignment
  • µ can be represented as a set of literals
  • E.g. µ(?1) ? , µ(?2) F gt A1 , ?A2
  • µ can be represented as a formula
  • E.g. µ(?1) ? , µ(?2) F gt A1 ? ?A2
  • both representations used for sets of clauses
    (formulas)

12
SAT Notation
  • µ f (µ satisfies f)
  • µ Ai ? µ(Ai) T
  • µ ?f ? not µ f
  • µ f1 ? f2 ? µ f1 ? µ f2
  • ...
  • f is satisfiable iff µ f for some µ
  • f1 f2 (f1 entails f2)
  • iff for every µ, µ f1 gt µ f2
  • f (f is valid)
  • iff for every µ, µ f
  • what does this mean for ?f ?

13
SAT Notation
  • f1 and f2 are equivalent iff
  • for every µ, µ f1 iff µ f2
  • f1 and f2 are equisatisfiable iff
  • exists µ1 s.t. µ1 f1 iff exists µ2 s.t. µ2
    f2
  • If f1 and f2 are equivalent then they are also
    equisatisfiable
  • but the opposite does not hold
  • Example
  • f1 ? f2 and (f1 ? ?l) ? (l ? f2), where l not in
    f1 ? f2, are equisatisfiable but not equivalent

14
Conjunctive Normal Form (CNF)
  • A formula A is in conjunctive normal form, or
    simply CNF, if it is
  • either T, or F, or a conjunction of disjunctions
    of literals
  • (That is, a conjunction of clauses.)
  • A formula B is called a conjunctive normal form
    of a formula A if B is equivalent to A and B is
    in conjunctive normal form.

15
Conjunctive Normal Form
  • Every sentence in propositional logic can be
    transformed into conjunctive normal form
  • i.e. a conjunction of disjunctions
  • Simple Algorithm
  • Eliminate ? using the rule that (p ?q) is
    equivalent to (?p ? q)
  • Use de Morgans laws so that negation applies to
    literals only
  • Distribute ? and ? to write the result as a
    conjunction of disjunctions

16
Conjunctive Normal Form - Example
  • ?(p ?q) ? (r ?p)
  • Eliminate implication signs
  • ?(?p ? q) ? (?r ? p)
  • Apply de Morgans laws
  • (p ? ?q) ? (?r ? p)
  • Apply associative and distributive laws
  • (p ? ?r ? p) ? (?q ? ?r ? p)
  • (p ? ?r) ? (?q ? ?r ? p)

17
Tractable Subclasses
  • SAT is NP-complete
  • therefore it generally is hard to solve!
  • Question
  • In what ways can we restrict the expressiveness
    of SAT in order to achieve tractability?
  • Answer
  • Horn-SAT
  • 2-SAT

18
Algorithms for SAT
  • The study of algorithms for SAT dates back to
    1960!
  • one of the most widely studied NP-complete
    problems
  • There are five general approaches to SAT solving
  • Resolution-based (DP)
  • Complete Search (DPLL)
  • Decision Diagrams
  • Incomplete Local Search
  • Stalmärcks algorithm (breadth-first search)

most widely used in practice and the ones we will
study
19
Algorithms for SAT
  • How do we test if a problem is SAT or not?
  • Complete methods
  • Return Yes if SATisfiable
  • Return No if UNSATisfiable
  • Incomplete methods
  • If return Yes, problem is SATisfiable
  • Otherwise timeout/run forever, problem can be SAT
    or UNSAT

20
Algorithms for SAT
  • The first algorithm was based on resolution
    (Davis Putnam, 1960)
  • exponential space complexity ? memory explosion!
  • The second algorithm was based on search (Davis,
    Logemann, Loveland, 1962)
  • usually referred to as DPLL (although Putnam was
    not involved)
  • still the basis of most modern complete SAT
    solvers
  • Some early DPLL-based SAT solvers
  • Tableau (NTAB), POSIT, 2cl, CSAT
  • not used any more (many orders of magnitude
    slower than modern solvers)

21
Davis-Putnam Algorithm
  • Existential abstraction using resolution
  • Iteratively select a variable for resolution
    till no more variables are left.
  • (a ? b ? c) (b ? -c ? f) (-b ? e) (a ? b) (a ?
    -b) (-a ? c) (-a ? -c)
  • ?b (a ? c ? e) (-c ? e ? f) ?b (a) (-a ? c)
    (-a ? -c)
  • ?bc (a ? e ? f) ?ba (c) (-c)
  • ?bcaef T ?bac ( )
  • SAT UNSAT

22
Algorithms for SAT
  • The first algorithm was based on resolution
    (Davis Putnam, 1960)
  • exponential space complexity ? memory explosion!
  • The second algorithm was based on search (Davis,
    Logemann, Loveland, 1962)
  • usually referred to as DPLL (although Putnam was
    not involved)
  • still the basis of most modern complete SAT
    solvers
  • Some early DPLL-based SAT solvers
  • Tableau (NTAB), POSIT, 2cl, CSAT
  • not used any more (many orders of magnitude
    slower than modern solvers)

23
DPLL Solvers
  • DPLL-based solvers are relatively small pieces of
    software
  • a few thousand lines of code
  • but they involve quite complex algorithms and
    heuristics
  • The evolution of SAT solvers into the modern
    ultra-fast tools that can tackle large (and huge)
    real problems is based on the following
    enhancements of DPLL
  • preprocessing
  • advanced propagation/deduction techniques for
    look-ahead and preprocessing
  • sophisticated branching heuristics
  • very detailed and fast implementations smart
    memory management
  • backjumping and learning methods

increasing order of importance?
24
DPLL
preprocessing
  • status preprocess()
  • if (status!UNKNOWN) return status
  • while (1)
  • decide_next_branch()
  • while (true)
  • status deduce()
  • if (status CONFLICT)
  • blevel analyze_conflict()
  • if (blevel 0)
  • return UNSATISFIABLE
  • else backtrack(blevel)
  • else if (status SATISFIABLE)
  • return SATISFIABLE
  • else break

branching heuristics
propagation/deduction
backjumping/learning
  • DPLL is traditionally described in a recursive
    way
  • We will use this modern iterative description due
    to Zhang and Malik

25
Unit Propagation
  • Unit propagation (UP) is the core deduction
    method used by all DPLL-based solvers
  • a clause is called unit if all but one of its
    literals have been assigned to false (i.e. it
    consists of a single literal)
  • UP repeatedly applies unit resolution (i.e. it
    resolves unit clauses)
  • Let us look at an example

most of the time is spent on doing UP!!!
The efficient implementation of UP is of primary
importance in a SAT solver
26
DPLL examples
more examples
  • Given ? in CNF (x,y,z),(-x,y),(-y,z),(-x,-y,-z)

Decide()
Deduce()
Analyze_Conflict()
27
DPLL
preprocessing
  • status preprocess()
  • if (status!UNKNOWN) return status
  • while (1)
  • decide_next_branch()
  • while (true)
  • status deduce()
  • if (status CONFLICT)
  • blevel analyze_conflict()
  • if (blevel 0)
  • return UNSATISFIABLE
  • else backtrack(blevel)
  • else if (status SATISFIABLE)
  • return SATISFIABLE
  • else break

branching heuristics
UP
backjumping/learning
28
Propagation / Deduction
  • Apart from UP several other deduction methods
    have been proposed and used during preprocessing
    (mainly) and search (less frequently)
  • Pure Literal rule
  • Binary Clause reasoning
  • Hyper Resolution
  • Failed Literal Detection
  • Equality Reduction
  • Krom Subsumption Resolution
  • Generalized Subsumption Resolution

most of them are only used for preprocessing the
formula because they are expensive
One notable exception is the pure literal rule
29
Pure Literal Rule
  • The pure literal rule (Davis, Logemann, Loveland,
    1962) states the following
  • if a variable occurs only positively then it can
    be assigned to true
  • if a variable occurs only positively then it can
    be assigned to false
  • Example
  • Given ? in CNF (x,y,z),(-x,y),(y,-w),(-x,y,-z)
  • y is a pure literal ? it can be assigned true
  • w is a pure literal ? it can be assigned false
  • Clauses with pure literals or tautologies can be
    removed!
  • a tautology is a clause of the form x ? x ? y
  • The pure literal rule is expensive to apply
    during search

30
Pure Literal Rule
  • The pure literal rule can be sequentially applied
  • Consider the formula
  • (u ? w ? x), (-w ? x ? y), (-u ? -x), (v ? w ?
    -y)
  • v is a pure literal ? it can be assigned true
  • The formula becomes
  • (u ? w ? x), (-w ? x ? y), (-u ? -x)
  • y is a pure literal ? it can be assigned true
  • The formula becomes
  • (u ? w ? x), (-u ? -x)
  • w is a pure literal ? it can be assigned true
  • The formula becomes
  • (-u ? -x)
  • both u and x are pure literals ? they can be
    assigned false

31
Other Deduction Methods
  • Weaker versions of UP
  • Binary UP resolves only unit and binary clauses
  • Can be used to solve a 2-SAT problem in quadratic
    time
  • Fixed-depth UP applies UP only up to a certain
    depth
  • Variants of Binary Resolution
  • BinRes, Equality Reduction, HyperBinRes
  • Failed Literal Detection
  • Hyper-Resolution
  • Krom Subsumption Resolution
  • Generalized Subsumption Resolution
  • Equivalence Reasoning
  • Etc.

preprocessing
propagation/deduction
32
Failed Literal Detection
  • Failed literal detection (Freeman, 1995) is a
    one-step lookahead with UP.
  • Say we force (assign) literal l and then perform
    UP. If this process yields a contradiction (empty
    literal) then we know that ?l is entailed by the
    current input and we can force it (and then
    perform UP).
  • DPLL solvers often perform failed literal
    detection on a set of likely, heuristically
    selected, literals at each node.
  • The SATZ system (Li Anbulagan, 1997) was the
    first to show that very aggressive failed literal
    detection can pay off.
  • but doing it on all literals is too expensive

33
Binary Resolution
  • One cheap form of binary resolution consists of
    performing all possible resolutions of pairs of
    binary clauses
  • Such resolutions yield only new binary clauses
    or new unit clauses
  • BinRes (Bacchus, 2002) repeatedly
  • (a) adds to the formula all new binary or unit
    clauses producible by resolving pairs of binary
    clauses, and
  • (b) performs UP on any new unit clauses that
    appear (which in turn might produce more binary
    clauses causing another iteration of (a)),
  • until either a contradiction is achieved, or
    nothing new can be added by a step of (a) or (b).
  • BinRes ((a,b),(?a,c),(?b,c)) produces the new
    binary clauses (b,c), (a,c), and (c). Then unit
    propagation yields the final reduction.

34
Hyper Resolution
  • A hyper resolution rule resolves more than two
    clauses at the same time
  • HypBinRes is a rule of inference involving
    hyper-resolution It takes as input a single
    n-ary clause (n ? 2) (l1, l2, ..., ln) and n-1
    binary clauses each of the form (?li,l) (i 1, .
    . . , n-1). It produces as output the new binary
    clause (l, ln).
  • For example, using HypBinRes hyperresolution on
    the inputs (a, b, c, d), (h, ?a), (h, ?c), and
    (h, ? d), produces the new binary clause (h, b)
  • HypBinRes is equivalent to a sequence of
    ordinary resolution steps (i.e., resolution steps
    involving only two clauses). However, such a
    sequence would generate clauses of intermediate
    length while HypBinRes only generates the final
    binary clause

35
Krom Subsumption
  • Krom-subsumption resolution (van Gelder and Y.
    Tsuji, 1996) takes as input two clauses of the
    form x ? y and x ? y ? Z and generates the
    clause y ? Z
  • where Z is a clause of arbitrary length
  • y ? Z subsumes (entails) x ? y ? Z, therefore
    x ? y ? Z can be deleted
  • Generalized Subsumption resolution takes two
    clauses x ? Y and x ? Y ? Z and generatesY ? Z
  • We can derive propagation methods derived by
    repeatedly applying either form of resolution

36
Equality Reduction
  • If a formula F contains (?a,b) as well as (a,?b),
    then we can form a new formula EqReduce(F) by
    equality reduction.
  • Equality reduction (Bacchus, 2002) involves
  • (a) replacing all instances of b in F by a (or
    vice versa),
  • (b) removing all clauses which now contain both
    a and ?a,
  • (c) removing all duplicate instances of a (or
    ?a) from all clauses.
  • This process might generate new binary clauses
  • For example, EqReduce((a,?b),(?a,b),(a,?b,c),(b,?d
    ), (a,b,d)) ((a, d),(a,?d))
  • EqReduce(F) has a satisfying truth assignment iff
    F does.
  • And any truth assignment for EqReduce(F) can be
    extended to one for F by assigning b the same
    value as a.

37
DPLL
HyperRes, BinRes, EqRed etc.
  • status preprocess()
  • if (status!UNKNOWN) return status
  • while (1)
  • decide_next_branch()
  • while (true)
  • status deduce()
  • if (status CONFLICT)
  • blevel analyze_conflict()
  • if (blevel 0)
  • return UNSATISFIABLE
  • else backtrack(blevel)
  • else if (status SATISFIABLE)
  • return SATISFIABLE
  • else break

branching heuristics
UP
backjumping/learning
38
Decision heuristics
  • DLIS (Dynamic Largest Individual Sum)
  • For a given variable x
  • Cx,p unresolved clauses in which x appears
    positively
  • Cx,n - unresolved clauses in which x appears
    negatively
  • Let x be the literal for which Cx,p is maximal
  • Let y be the literal for which Cy,n is maximal
  • If Cx,p gt Cy,n choose x and assign it TRUE
  • Otherwise choose y and assign it FALSE
  • Requires l (literals) queries for each decision.
  • (Implemented in some solvers e.g. Grasp)

39
Decision heuristics
  • DLCS (Dynamic Largest Combined Sum)
  • For a given variable x
  • Cx,p unresolved clauses in which x appears
    positively
  • Cx,n - unresolved clauses in which x appears
    negatively
  • Let x be the literal for which Cx,p Cx,n is
    maximal
  • If Cx,p gt Cx,n and assign x to TRUE
  • Otherwise assign x to FALSE
  • Requires l (literals) queries for each decision.
  • (Implemented in some solvers e.g. Grasp)

40
Decision heuristics
  • Bohms Heuristic
  • At each step of the backtrack search algorithm,
    the BOHM heuristic selects a variable with the
    maximal vector (H1(x),H2(x),,Hn(x)) in
    lexicographic order. Each Hi(x) is computed as
    follows
  • Hi(x) a max(hi(x), hi(?x)) b min(hi(x),
    hi(?x))
  • where hi(x) is the number of unresolved clauses
    with i literals that contain literal x. Hence,
    each selected literal gives preference to
    satisfying small clauses (when assigned value
    true) or to further reducing the size of small
    clauses (when assigned value false).
  • The values of a and are b chosen heuristically.

41
Jeroslow-Wang method
Decision heuristics
  • Compute for every clause w and every literal l
  • J(l)
  • One-sided JW Choose a literal l that maximizes
    J(l)
  • Two-sided JW Choose a variable x that maximizes
    J(x) J(?x)
  • Assign it to true if J(x) ? J(?x) and false
    otherwise
  • This gives an exponentially higher weight to
    literals in shorter clauses.

42
MOM (Maximum Occurrence of clauses of Minimum
size).
Decision heuristics
  • Let f(x) be the of unresolved smallest clauses
    containing x. Choose x that maximizes
  • ((f(x) f(?x)) 2k f(x) f(?x)
  • k is chosen heuristically.
  •  
  • The idea
  • Give preference to satisfying small clauses.
  • Among those, give preference to balanced
    variables (e.g. f(x) 3, f(? x) 3 is better
    than f(x) 1, f(?x) 5).

43
Decision heuristics
VSIDS (Variable State Independent Decaying Sum)
1. Each variable in each polarity has a counter
initialized to 0.
2. When a clause is added, the counters are
updated.
3. The unassigned variable with the highest
counter is chosen.
4. Periodically, all the counters are divided by
a constant.
(Implemented in Chaff)
44
Decision heuristics
  • VSIDS (contd)
  • Chaff holds a list of unassigned variables
    sorted by the counter value.
  • Updates are needed only when adding conflict
    clauses.
  • Thus - decision is made in constant time.

45
Decision heuristics
VSIDS is a quasi-static strategy - static
because it doesnt depend on current
assignment - dynamic because it gradually
changes. Variables that appear in recent
conflicts have higher priority.
This strategy is a conflict-driven decision
strategy.
..employing this strategy dramatically (i.e. an
order of magnitude) improved performance ...
46
DPLL
HyperRes, BinRes, EqRed etc.
  • status preprocess()
  • if (status!UNKNOWN) return status
  • while (1)
  • decide_next_branch()
  • while (true)
  • status deduce()
  • if (status CONFLICT)
  • blevel analyze_conflict()
  • if (blevel 0)
  • return UNSATISFIABLE
  • else backtrack(blevel)
  • else if (status SATISFIABLE)
  • return SATISFIABLE
  • else break

branching heuristics
UP
backjumping/learning
47
Conflict Analysis, Learning, Backjumping
  • When a conflicting clause is derived (i.e. a
    clause with all its literals 0), the solver must
    backtrack
  • conflict analysis finds the reason for a
    conflict and tries to resolve it
  • The DPLL algorithm uses chronological
    backtracking
  • it backtracks to the most recent decision point
    where a variable has not both of values its
    tried, and flips the current assignment
  • Example
  • Modern SAT solvers employ more advanced conflict
    analysis techniques to identify the actual
    reasons for the conflict
  • in this way they can achieve non-chronological
    backjumping

48
Conflict Analysis, Learning, Backjumping
  • Suppose the conflicting clause ? (?a ? x ? ?c)
    has been derived
  • i.e. a1, x0, c1
  • A set R of value assignments to variables in the
    problem is called a conflict assignment if after
    making these assignments and running UP, clause ?
    becomes unsatisfiable
  • assignment a1, x0, c1 is a trivial conflict
    assignment
  • But it is not of much use
  • Question how can we derive more interesting
    conflict assignments?
  • Answer determine why and at what decision level
    a1, x0, c1
  • Suppose we find that Rx0, y1, z1 is also a
    conflict assignment for clause ?
  • the implied clause (x ? ?y ? ?z) which records
    the conflict assignment R is called a conflict
    clause

49
Conflict Analysis, Learning, Backjumping
  • Suppose that assignment x0 of Rx0, y1, z1
    is chosen (or implied) at the current decision
    level v
  • assume that y1 and z1 are deduced at nodes v
    and v respectively
  • suppose that vgtvgtv (i.e. v is closest to
    the root)
  • After adding conflict clause (x ? ?y ? ?z) to the
    problem, we can backjump from v to v (skipping
    the nodes in between)
  • because whatever assignments we make there, the
    conflict at node v will still exist!
  • After we make the backjump, we can deduce x1.
    Why?
  • because the added clause (x ? ?y ? ?z) will be a
    unit clause, forcing x1
  • without learning this clause, this deduction
    would not be possible
  • now we can avoid needless search and save time!

50
Conflict Analysis, Learning, Backjumping
  • During the conflict analysis information about
    conflicts is usually recorded and added to the
    problem as new (learned) clauses
  • these conflict clauses are redundant but they
    often help prune the search space in the future
  • this mechanism is called conflict-directed
    learning
  • Non-chronological backtracking is also called
    conflict-directed backjumping
  • originally proposed for CSPs (Prosser, 1993)
  • then incorporated in SAT solvers like GRASP
    (Silva and Sakallah, 1996) and rel_sat (Bayardo
    and Schrag, 1997)
  • Learning and conflict-directed backjumping can be
    analyzed using implication graphs or they can be
    viewed as a resolution process

51
Implication graphs and learning
  • DPLL solvers organize the search in the form of a
    decision tree
  • Each node corresponds to a decision
  • Depth of the node in the decision tree ? decision
    level
  • Notation xv_at_d v ?0,1 is assigned to x at
    decision level d

52
Implication graphs and learning
?1 (x2 ? x3) ?2 (?x1 ? ?x4) ?3 (?x2 ? x4)
x1 1_at_1
? x4 0_at_1
? x2 0_at_1
? x3 1_at_1
? x3 1_at_2
(x1,1), (x2,0), (x3,1) , (x4,0)
(x1,0), (x2,0), (x3,1)
No backtrack in this example!
53
Implication graphs and learning
Lets add a clause
?1 (x2 ? x3) ?2 (?x1 ? ?x4) ?3 (?x2 ?
x4) ?4 (?x1 ? x2 ? ?x3)
? x4 0_at_1
? x2 0_at_1
? x3 1_at_1
conflict
54
Implication graphs and learning
Current truth assignment x90 ,x100, x110,
x121, x131 Current decision assignment
x11_at_6
x100
c1 (?x1 ? x2) c2 (?x1 ? x3 ? x9) c3 (?x2 ?
?x3 ? x4) c4 (?x4 ? x5 ? x10) c5 (?x4 ? x6 ?
x11) c6 (?x5 ? ? x6) c7 (x1 ? x7 ? ?x12) c8
(x1? x8) c9 (?x7 ? ?x8 ? ? x13)
x11_at_6
x90
x110
We learn the conflict clause c10 ?(x1 ? ?x9 ?
?x11 ? ?x10) ? (?x1 ? x9 ? x11 ? x10)
55
Implication graph, flipped assignment
Current truth assignment x90 ,x100, x110,
x121, x131 Current decision assignment x10
c1 (?x1 ? x2) c2 (?x1 ? x3 ? x9) c3 (?x2 ?
?x3 ? x4) c4 (?x4 ? x5 ? x10) c5 (?x4 ? x6 ?
x11) c6 (?x5 ? ? x6) c7 (x1 ? x7 ? ?x12) c8
(x1? x8) c9 (?x7 ? ?x8 ? ? x13) c10 (?x1 ? x9
? x11 ? x10)
x90
c10
x100
x10_at_6
c10
c10
x110
Due to the conflict clause
56
Conflict-directed backjumping

Decision level
  • Which assignments caused
  • the conflicts ?
  • x9 0
  • x10 0
  • x11 0
  • x12 1
  • x13 1
  • If the deepest was done at level 3
  • Backtrack to decision level 3

3
These assignments are sufficient for causing a
conflict.

4

5
x1
6


?
?
Non-chronological backtracking
57
Resolution and learning
  • Learned clauses can be generated by resolution
  • as we know, resolution takes two clauses (C1,a),
    (?a,C2) where C1 and C2 are disjunctions of
    literals and generates clause (C1,C2).
  • the resulting clause is redundant. Therefore, we
    can apply resolution and add new clauses to the
    clause knowledge base without changing the
    problems satisfiability
  • Why would we want to do this?
  • Conflict-driven learning uses resolution to
    generate new clauses that can help us achieve
    conflict-directed backjumping and prune the
    search space in the future
  • as usual we assume that UP is the only deduction
    method applied

58
Resolution and learning
  • analyze_conflict
  • cl find_conflicting_clause()
  • while (!stop_criterion_met(c1))
  • lit choose_literal(c1)
  • var variable_of_literal(lit)
  • ante antecedent(var)
  • cl resolve(c1,ante,var)
  • add_clause_to_knowledge_base(c1)
  • back_dl clause_asserting_level(c1)
  • return back_dl

Choose a literal from the conflicting clause
Find the unit clause which implies var
Return a clause that contains all literals in c1
and ante except the literals of var
  • Every implied variable has an antecedent
  • Decision variables dont

59
Resolution and learning
  • The loop stops when some predefined stop
    criterion is met
  • usually the stop criterion is that an asserting
    clause has been derived
  • A clause is asserting if all literals it contains
    have value 0 and only one of them (l) is assigned
    at the current decision level
  • the decision level of the literal with the
    second highest decision level in an asserting
    clause is the asserting level of the clause
  • After backtracking to the asserting level, the
    asserting clause will become unit and force l to
    take its opposite value
  • thus a new are in the search space will be
    explored
  • It is easy to meet the stop criterion if
    choose_literal(c1) chooses literal in reverse
    chronological order of their assignment

?xample from BerkMin paper
60
Resolution and learning
  • As new learned clauses are added two problems may
    appear
  • The system slows down because it has to process
    a larger number of clauses
  • The memory requirements increase
  • To solve these problems, SAT solvers delete some
    learned clauses periodically
  • this does not affect correctness since these
    clauses are redundant
  • the less useful ones and the ones that have many
    literals are preferred for deletion
  • usefulness is measured according to various
    heuristics
  • e.g. most recent ones are kept, older ones are
    deleted

61
DPLL
HyperRes, BinRes, EqRed etc.
  • status preprocess()
  • if (status!UNKNOWN) return status
  • while (1)
  • decide_next_branch()
  • while (true)
  • status deduce()
  • if (status CONFLICT)
  • blevel analyze_conflict()
  • if (blevel 0)
  • return UNSATISFIABLE
  • else backtrack(blevel)
  • else if (status SATISFIABLE)
  • return SATISFIABLE
  • else break

branching heuristics
UP
backjumping/learning
62
Random Restarts
  • The variable order during search plays a very
    significant role in the runtime
  • two problems that are identical except for the
    variable order may take totally different times
    to solve
  • a given variable order can make the algorithm
    focus on certain parts of the search tree (that
    may not be fruitful)
  • One way to solve this problem is through random
    restarts
  • search process is initiated from scratch at
    certain points
  • Random restarts may force the algorithm to
    consider diverse areas in the search tree in two
    ways
  • by keeping some information after a restart
    (learned clauses)
  • by incorporating some degree of randomness in
    the branching heuristic

63
Engineering Aspects of SAT Solvers
  • Storage of Clause Knowledge Base
  • many real problems currently solved by SAT
    solvers are very large
  • circuit verification problems may contain
    millions of variables and clauses
  • also, during search learned clauses are added to
    the clause KB
  • Efficient ways to store the clauses are needed!
  • usually clauses are stored in a linear way
    (sparse matrix representation)
  • each clause has its own space and no overlap
    exists
  • early SAT solvers used complex pointer-heavy
    data structures
  • convenient for clause manipulation
    (additions/deletions)
  • but not memory efficient (access locality not
    preserved ? many cache misses)

64
Engineering Aspects of SAT Solvers
  • Storage of Clause Knowledge Base
  • Chaff (Moskewicz, Madigan, Zhao, Zhang, Malic,
    2001) stores all clauses in a large array
  • less flexible in clause manipulation than linked
    lists
  • but increased access locality offers significant
    speed-ups
  • Another approach to the storing problem proposes
    the use of tries to store clauses (Zhang
    Stickel, 1994)
  • a trie is a ternary tree
  • each internal node is a variable index
  • the three children of each node are labeled Pos,
    Neg, DC (Dont Care)
  • a leaf node is either true or false
  • a path to a true leaf node represents a clause

65
Tries for clause storage
  • Apart from saving space,
  • the ordered trie structure has the nice property
    of being able to detect tail subsumed clauses of
    a database quickly.
  • A clause is said to be tail subsumed by another
    clause if its first portion of the literals is
    also a clause in the clause database. For
    example, (a? b?c) is tail subsumed by (a?b)

A trie data structure representing clauses
(V1?V2),(?V1 ? V3),(?V1 ? ?V3),(?V2 ? ?V3)
66
More engineering aspects of SAT solvers
  • Observation More than 90 of the time SAT
    solvers perform
  • Deduction().
  • i.e. UP

Deduction() creates new implied variables and
conflicts. How can this be done efficiently ?
67
Grasp implements Deduction() with counters
Hold 2 counters for each clause ? val1(?) -
of negative literals assigned 0 in ?
of positive literals assigned 1 in ?. val0(?)
- of negative literals assigned 1 in ?
of positive literals assigned 0 in ?.
Each variable x has two lists that contain
list1(x) all clauses where x appears
positively list2(x) all clauses where x
appears negatively
68
Grasp implements Deduction() with counters
Every assignment to a variable x results in
updating the counters for all the clauses that
contain x.
? is satisfied iff val1(?) gt 0
? is unsatisfied iff val0(?) ?
? is unit iff val1(?) 0 ? val0(?) ? - 1
? is unresolved iff val1(?) 0 ? val0(?) lt ?
- 1
Backtracking Same complexity as variable
assignment
This is the main problem with counters!
69
SATO implements Deduction() with head/tail
pointers
  • In SATO each clause has two pointers associated
    with it, called the head and tail pointer
    respectively. A clause stores all its literals in
    an array. Initially, the head pointer points to
    the first literal of the clause and the tail
    pointer points to the last literal of the clause.
  • Each variable keeps four linked lists that
    contain pointers to clauses. The linked lists for
    the variable v are clause_of_pos_head(v),
    clause_of_neg_head(v), clause_of_pos_tail(v) and
    clause_of_neg_tail(v).
  • If v is assigned with the value 1,
    clause_of_pos_head(v) and clause_of_pos_tail(v)
    will be ignored. For each clause C in
    clause_of_neg_head(v), the solver will search for
    a literal that does not evaluate to 1 from the
    position of the head literal of C to the position
    of the tail literal of C.

70
SATO implements Deduction() with head/tail
pointers
  • During this search process, four cases may occur
  • If during the search we first encounter a literal
    that evaluates to 1, then the clause is
    satisfied, we need to do nothing.
  • If during the search we first encounter a literal
    l that is free and l is not the tail literal,
    then we remove C from clause_of_neg_head(v) and
    add C to head list of the variable corresponding
    to l. In essence the head pointer is moved from
    its original position to the position of l.
  • If all literals in between these two pointers are
    assigned value 0, but the tail literal is
    unassigned, then the clause is a unit clause, and
    the tail literal is the unit literal for this
    clause.
  • If all literals in between these two pointers and
    the tail literal are assigned value 0, then the
    clause is a conflicting clause.
  • Similar actions are performed for
    clause_of_neg_tail(v), only the search is in the
    reverse direction (i.e. from tail to head).

71
Chaff implements Deduction() with a pair of
watched literals
  • Observation during Deduction(), we are only
    interested in newly implied variables and
    conflicts.
  • These occur only when the number of literals in ?
    with value false is greater than ? - 2
  • Conclusion no need to visit a clause unless
    (val0(?) gt ? - 2)
  • How can this be implemented ?

72
Chaff implements Deduction() with a pair of
watched literals
  • Define two watched literals w1(?), w2(?).
  • w1(?) and w2(?) point to two distinct literals
    in ? which are not false
  • Each variable x has two lists containing pointers
    to all the watched literals corresponding to it
    (in either polarity)
  • pos_watched(x) and neg_watched(x)
  • When a variable x is assigned value 0 (1), for
    each literal p pointed to by a pointer in the
    list of pos_watched(x) (neg_watched(x) - notice p
    must be a negative literal of x in this case),
    the solver will search for a literal l in the
    clause containing p that is not set to 0.
  • In this way we visit clause ? only if w1(?) or
    w2(?) become false.


73
Chaff implements Deduction() with a pair of
watched literals
  • the solver will search for a literal l in the
    clause containing p that is not set to 0. There
    are four cases that may occur during search
  • If there exists such a literal l and it is not
    the other watched literal, then we remove pointer
    to p from neg_watched(x), and add pointer to l to
    the watched list of the variable corresponding to
    l.
  • We refer to this operation as moving the watched
    literal, because one of w1(?) and w2(?) is moved
    from its original position to the position of l.
  • If the only such l is the other watched literal
    and it is free, then the clause is a unit clause,
    with the other watched literal being the unit
    literal.
  • If the only such l is the other watched literal
    and it evaluates to 1, then we need to do
    nothing.
  • If all literals in the clause are assigned value
    0 and no such l exists, then the clause is a
    conflicting clause.

74
Chaff implements Deduction() with a pair of
watched literals
Both watched literals of an implied clause are on
the highest decision level present in the clause.
Therefore, backtracking will un-assign them
first. Conclusion when backtracking, watched
literals stay in place.
Backtracking No updating. Complexity constant.
75
Chaff implements Deduction() with a pair of
watched literals
The choice of watched literals is important.
Best strategy is - the least frequently updated
variables.
The watched literals method has a learning curve
in this respect 1. The initial watched literals
are chosen arbitrarily.
2. The process shifts the watched literals away
from variables that were recently updated (these
variables will most probably be reassigned in a
short time).
76
head/tail pointers vs. watched
literals
Write a Comment
User Comments (0)
About PowerShow.com