Skip to content

gatlin/surely

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Surely

An algorithm to find the boolean satisfiability of a formula, Maybe.

(c) 2012-2025 Gatlin Johnson gatlin@niltag.net

  1. SAT Solving, briefly

A SAT solver is a program that takes a propositional formula and tries to find a truth value for each of its variables such that the whole proposition is true. Failing that, it declares the proposition unsatisfiable. Either way, you can be Sure of the result.

This problem, the Boolean satisfiability problem, is NP-complete and thus equivalent to all other NP-complete problems. SAT solvers are useful, then, because if a mapping exists from a problem to a SAT instance, a SAT solver can be used to find a solution.

So I decided to make this data-parallel using monad-par. You should compile programs with -threaded if you use this library.

  1. The interface

Surely exports a function, solve, which accepts propositions in Conjunctive Normal Form, as explained below. The output is of type Maybe [Int], which will either be Just a list of literals which are true, or Nothing.

  1. Conjunctive Normal Form

Most SAT solving algorithms take the input argument in Conjunctive Normal Form, or CNF. Any proposition can be rewritten in CNF. A CNF proposition is a conjunction of disjunctions of literals.

Concretely,

(p OR q OR -r) AND (-q OR s) AND (-q)

is in CNF, because a series of disjunctions are combined in a conjunction.

For notational simplicity, a proposition in CNF for our purposes is of type [[Int]]. Variables are just unique integers, and truth is determined by the polarity (minus sign or not). It is up to your application to perform the conversion.

  1. Goals

The goal of Surely is to provide an elegant, efficient, and extensible SAT solving algorithm (in that order).

  1. TODO

  • Backjumping
  • Conflict-driven learning
  • I can probably choose an alternative to list with better memory guarantees
  • SMT support (ie, you provide a test function when calling solve)

About

An Haskell library to solve SAT problems, Maybe

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published