0art0 / Saturn

Experiments with SAT solvers with proofs in Lean 4

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SATurn : SAT Solver-prover in lean 4

SATurn is a SAT solver-prover in lean 4 based on the DPLL algorithm. Given a SAT problem, we get either a solution or a resolution tree showing why there is no solution. Being written in Lean 4 gives the following attractive features:

  • The program generates proofs in the foundations of the lean prover, so these are independently checked (both for existence and non-existence of solutions).
  • The program itself is checked by lean, so guaranteed to terminate and give a correct answer.

Proofs can be obtained by using the methods solve and proveOrDisprove in the file DPLL.lean. The former gives an object in a type representing either verified solutions or resolution trees. The latter gives a proof of existence or non-existence verified by the lean prover.

More details can be found in the related blog post.

Exploring and running

The file Examples.lean illustrates, for some basic examples, both obtaining structured proofs and proofs or disproofs of propositions. However as this runs in interpreted mode, the examples are very simple.

One can run a compiled version in a command line. This solves the basic examples in the file Examples.lean and also the N-Queens problem (if one chooses) for specified N. To run this assuming leanpkg is installed, one can do the following (in linux) for example:

$ leanpkg build bin
$ build/bin/Saturn 7

The above commands run the basic examples and the 7-queens problem. Without an argument (such as 7 in the above example) just the basic examples are run.

Note that the performance is slow, to a large extent because the underlying collections used are not optimized for performance.

About

Experiments with SAT solvers with proofs in Lean 4

License:MIT License


Languages

Language:Lean 100.0%