Title: Solving%20Non-clausal%20Formulas%20with%20DPLL%20search
1Solving Non-clausal Formulas with DPLL search
- Christian Thiffault Fahiem Bacchus
- University of Toronto
Toby Walsh UNSW
2CNF
- The classical DPLL algorithm (most modern SAT
solvers) work with Conjunctive Normal Form (CNF) - However, CNF is not the most natural
representation. - Hence, to use modern SAT solver technology
problems must be converted to CNF - In this work we demonstrate that such a
conversion is unnecessary. - For a number of reasons such a conversion is also
undesirable. - We demonstrate that original structure lost in
conversion can be utilized to significantly
improve the performance of SAT solvers.
3Tseitin Encodings
- The most commonly used CNF encoding is the
Tseitin encoding Tseitin 1970. - This encoding converts a propositional formula
recursively by adding a new variable for every
subformula.
4Tseitin Encodings
- A ? (C D)
- V1 (C D)
- (V1, C), (V1, D), (C,D,V1)
(V1, C) (V1, D) (C,D,V1)
5Tseitin Encodings
- A ? (C D)
- V1 (C D)
- (V1, C), (V1, D), (C,D,V1)
- V2 (A ? V1)
- (V2, A,V1), (A,V2), (V1,V2)
(V1, C) (V1, D) (C,D,V1) 4. (V2, A,V1) 5. (A,V2) 6. (V1,V2)
6Tseitin Encodings
- A ? (C D)
- V1 (C D)
- (V1, C), (V1, D), (C,D,V1)
- V2 (A ? V1)
- (V2, A,V1), (A,V2), (V1,V2)
- The formula must be true (V2)
(V1, C) (V1, D) (C,D,V1) 4. (V2, A,V1) 5. (A,V2) 6. (V1,V2) 7. (V2)
7Converting to CNF is Undesirable
- There are two obvious problems arising from this
conversion. - Structural information is lost
- The fact that a particular group of clauses were
generated from the same subformula is lost. - The global interconnections between the various
subformulas are lost. - Additional variables are added. This potentially
increases the size of the DPLL search.
8Structural Information
- Some of this information could be recovered from
the CNF encoding, but not all of it Lang
Marquis, 1989. - There is good empirical evidence that recovering
structural information can yield considerable
benefits in solving performance. EqSatZ, LSAT. - But why lose this information in the first place?
- We will show conversion to CNF is not necessary.
- We also develop techniques which confirm the
benefits of retaining the original structure.
9Extra Variables
- Various works have noted the potential difficulty
of introducing new variables. - Some have suggested restricting the DPLL search
so that it cannot branch on any on the newly
introduced subformula variables. - However, it is not difficult to show that
restricting branching in this manner causes an
exponential slowdown on some problems Jarvisalo
et al. 2004 - Solvers that attempt to restrict their branching
in this manner can perform very poorly on many
problems.
10Extra Variables
- The alternative is unrestricted branching.
- However, with unrestricted branching a CNF solver
can waste a lot of time branching on variables
that have dynamically become irrelevant.
11Irrelevant Variables
AFalse. Formula satisfied
12Irrelevant Variables CNF
- A ? (C D)
- V1 (C D)
- V2 (A ? V1)
Solver must still determine that the remaining
clauses are SAT
(V1, C) (V1, D) (C,D,V1) 4. (V2, A,V1) 5. (A,V2) 6. (V1,V2) 7. (V2) 8. (A)
13Converting to CNF is Unnecessary
- DPLL search can be performed on the original
formula. - This has been noted in previous work on circuit
based solvers Ganai et al. 2002
14DPLL on formulas
- Convert formula to a dag.
- A ? (C D) \/ B ? (C D)
\/
?
?
B
A
C
D
15DPLL on formulas
- Associate a truth value (True/ False/ Unassigned)
with every node of the DAG. - Now perform DPLL search by splitting on the truth
value of an unassigned node. - Use the logic of the boolean operators to
propagate truth values to neighboring nodes. - A solution is found when all nodes have been
labeled with consistent truth values (i.e., the
parent and child values are consistent with the
logic of the parents operator.) - A contradiction occurs when True and False are
propagated to the same node.
16Example
\/
?
?
B
A
C
D
17Example
\/
?
?
B
A
C
D
18Example
\/
?
?
B
A
C
D
19Comparison
- Assigning a truth value to a node in the DAG is
equivalent to assigning a truth value to the
corresponding variable in the CNF encoding. - Propagation in the DAG is equivalent to unit
propagation in the CNF encoding.
20Comparison
- The rule that propagated a truth value can be
recorded. Once a contradiction is detected a
conflict clause can be learned (a set of
impossible node assignments). This clause can be
made equivalent to the 1-UIP clauses learned by
CNF solvers. - The learned clauses can be stored and used to
unit propagate node truth values in the rest of
the search.
21Comparison
- Complex gates, e.g., n-ary XOR can be more
efficiently propagated in the DAG representation
(these gates require a number of clauses
exponential in the number of their inputs).
22Efficient Propagation
- Efficient Unit Propagation via lazy data
structures is a key element of modern SAT
solvers. - One new feature of our circuit based solver over
previous circuit solvers is that it utilizes
similar lazy data structures to make its
propagation as efficient as CNF solvers.
23Efficient Propagation
- E.g., an AND gate becomes true only when all of
its children become true. - Assign one child as a true watch, and dont check
for true propagating to the AND gate node unless
its true watch becomes true. - Some benchmarks have AND gates with thousands of
children. - Previous table-lookup circuit solvers required
some computation each time a child became true. - Using these techniques there is no intrinsic loss
of efficiency in using the DAG over CNF.
24Structure Based Optimizations
- Since no penalty is being paid for using the
original formula, we can turn to exploiting the
extra structural information it provides. - We implemented two structure based optimizations.
- Dont care propagation to deal with irrelevant
variables. - Conflict Clause reduction.
25Dont Care Propagation
- We propagate a third truth value through the
DAG dont cares. - A node C is dont care wrt a particular parent P
- if its truth value can no longer affect the truth
value of P nor any of its P siblings. - or P is dont care.
- A node C is dont care if it is dont care wrt to
all of its parents.
26Dont Care Propagation
- Assign a dont care watch parent for each node.
- C becoming dont care wrt to its watch parent P
can be detected when truth values are propagated
to P. - If C becomes dont care wrt to its dont care
watch we look for another watch. - If we cant find one we know that C has become
dont care. - Finally, we stop the search from branching on
dont care nodes. This eliminates branching of
irrelevant values.
27Conflict Clause Reductions
- If one learns a conflict clause (L1,L2,...) and
one has L1 ? L2, then we can reduce the conflict
clause by a resolution step - (-L1,L2) (L1,L2,...) ? (L2,...)
- The resolvant subsumes the original conflict
clause. - In a CNF encoding one would have to search the
clauses to detect this situationprobably not
going to be effective. - In the DAG one can examine the neighbors of each
node assignment in the conflict clause to see if
any of the other assignments in the clause are
implied by it. - If so we can remove the implying node assignment.
- If this is done with discrimination it can yield
a significant decrease in the size of the learned
clauses with little overhead.
28Empirical Results.
- We compared with Zchaff.
- Tried to make the two solvers as close as
possible, same magic numbers (e.g., clause
database cleanup criteria, restart intervals
etc.), same branching heuristics. - Hence, we tried to isolate the impact of the
non-clausal representation and the structure
based optimizations. - We believe that the same improvements could be
obtained with others CNF solvers via this
technique.
29Empirical Results caveats
- Our experiments were hampered by a lack of
non-clausal benchmarks. - The performance of our solver was also limited by
the fact that the benchmarks we did obtain has
already been transformed into simpler formulas,
e.g., no complex XOR of IFF gates were present in
the benchmarks.
30FVP-UNSAT-2.0 (Velev) Time
31FVP-UNSAT-2.0 Decisions
32FVP-UNSAT-2.0 Dont Cares
33FVP-UNSAT-2.0 Clause Reduction
34Other Series
35Conclusions
- No intrinsic reason to convert to CNF.
- Many other structure based optimizations remain
to be investigated, e.g. - better branching
- non-clausal representation of conflicts
- more complex gates.