KomaEc / sat

A simple CDCL sat solver

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A Simple CDCL SAT Solver

Simplesat is a conflict driven clause learning SAT solver. It features the two watched literals optimization scheme. It can solve some SAT problems with tens of thousands of variables (data/QG/qg5-13.cnf, data/Beijing/ewddr2-10-by-5-8.cnf). It is property-based tested.

TODO

  • Decision Heuristic (EVSIDS). A variable is bumped when it appears in the antecedant clauses of the learned clause.

    Using naive decision:

    > cargo run --release data/QG/qg5-13.cnf
    > Solving SAT instance with 2197 variables and 125464 clauses
    > UNSAT
    > finished in time 30.773019922s

    Using EVSIDS:

    > cargo run --release data/QG/qg5-13.cnf
    > Solving SAT instance with 2197 variables and 125464 clauses
    > UNSAT
    > finished in time 2.553388132s
  • Database Reduction Strategy (LBD).

Discussion

Problems I met when implementing this algorithm

Termination Property

The termination property of the CDCL algorithm is not that obvious (at least to me). It is hypothetical that some paths may be repeatedly reached, since the backjump mechanism does not systematically explore the search space.

To prove termination, we aim at the following theorem.

It is never the case that the solver enters decision level dl again with the same state.

At first glance, it seems that learned clauses may help. Indeed, a learned clause prevent the solver from entering the path that results in a backjump and generating itself. However, realistic solver appeals to forget learned clauses at certain points. Keeping all learned clauses not only leads to high time consumption of the propagation process, but also makes computer memory explode: in worst case, the number of learned clauses can reach O(2^n).

In fact, the solver terminates even if we do not keep learned clauses at all! The reason lies in the immediate implication of the learned asserting clause. Suppose the solver is currently at decision level dl, and will return back to dl again. Assume dl' is the lowest level the solver should reach in this period. Of course, dl' <= dl. Since dl' is the lowest, the solver can only backjump to this level. Each time the solver reaches dl', a literal is immediately asserted by the learned clause at level dl'. So even if learned clauses are discarded right away, when the solver returns back to dl, it is with a different partial assignment.

Reference

I find these books, slides and codes very useful.

About

A simple CDCL sat solver

License:Mozilla Public License 2.0


Languages

Language:Rust 100.0%