A modular library for CDCL(T) SMT solvers, with [wip] proof generation.
Find a file
2017-12-28 19:43:54 +01:00
articles Documentation update 2016-12-01 15:35:15 +01:00
doc Updated version number 2017-01-25 17:51:15 +01:00
src split some features into minismt lib 2017-12-28 19:43:54 +01:00
tests split some features into minismt lib 2017-12-28 19:43:54 +01:00
.gitignore big refactoring 2017-12-28 15:51:04 +01:00
.header copyright header in .header; authors in opam file 2014-11-04 17:59:58 +01:00
.ocamlinit ocamlinit file 2017-01-26 15:02:38 +01:00
.ocp-indent ocpindent config 2017-12-28 18:55:01 +01:00
.travis.yml travis 2017-12-28 17:33:03 +01:00
CHANGELOG.md prepare for 0.6.1 2017-03-22 15:57:53 +01:00
LICENSE update of license 2014-10-29 13:42:53 +01:00
Makefile makefile 2017-12-28 19:12:32 +01:00
minismt.opam split some features into minismt lib 2017-12-28 19:43:54 +01:00
msat.exe details 2017-12-28 15:55:00 +01:00
msat.opam update opam files 2017-12-28 18:33:52 +01:00
msat_solver.opam update opam files 2017-12-28 18:33:52 +01:00
README.md Typo in README (again...) 2017-07-03 15:32:27 +02:00
TODO.md A bit of restructuring to have cleaner dependencies between fonctors 2015-07-21 19:20:40 +02:00
VERSION Updated version number 2017-01-25 17:51:15 +01:00

MSAT Build Status

MSAT is an OCaml library that features a modular SAT-solver and some extensions (including SMT).

It derives from Alt-Ergo Zero.

This program is distributed under the Apache Software License version 2.0. See the enclosed file LICENSE.

Documentation

See https://gbury.github.io/mSAT/

INSTALLATION

Via opam

Once the package is on opam, just opam install msat. For the development version, use:

opam pin add msat https://github.com/Gbury/mSAT.git

Manual installation

You will need ocamlfind and ocamlbuild. The command is:

make install

USAGE

Generic SAT/SMT Solver

A modular implementation of the SMT algorithm can be found in the Msat.Solver module, as a functor which takes two modules :

  • A representation of formulas (which implements the Formula_intf.S signature)

  • A theory (which implements the Theory_intf.S signature) to check consistence of assertions.

  • A dummy empty module to ensure generativity of the solver (solver modules heavily relies on side effects to their internal state)

Sat Solver

A ready-to-use SAT solver is available in the Sat module. It can be used as shown in the following code :

(* Module initialization *)
module Sat = Msat.Sat.Make()
module E = Msat.Sat.Expr (* expressions *)

(* We create here two distinct atoms *)
let a = E.fresh ()    (* A 'new_atom' is always distinct from any other atom *)
let b = E.make 1      (* Atoms can be created from integers *)

(* We can try and check the satisfiability of some clauses --
   here, the clause [a or b].
   Sat.assume adds a list of clauses to the solver. *)
let() = Sat.assume [[a; b]]
let res = Sat.solve ()        (* Should return (Sat.Sat _) *)

(* The Sat solver has an incremental mutable state, so we still have
   the clause [a or b] in our assumptions.
   We add [not a] and [not b] to the state. *)
let () = Sat.assume [[E.neg a]; [E.neg b]]
let res = Sat.solve ()        (* Should return (Sat.Unsat _) *)

Formulas API

Writing clauses by hand can be tedious and error-prone. The functor Msat.Tseitin.Make proposes a formula AST (parametrized by atoms) and a function to convert these formulas into clauses:

(* Module initialization *)
module Sat = Msat.Sat.Make()
module E = Msat.Sat.Expr (* expressions *)
module F = Msat.Tseitin.Make(E)

(* We create here two distinct atoms *)
let a = E.fresh ()    (* A fresh atom is always distinct from any other atom *)
let b = E.make 1      (* Atoms can be created from integers *)

(* Let's create some formulas *)
let p = F.make_atom a
let q = F.make_atom b
let r = F.make_and [p; q]
let s = F.make_or [F.make_not p; F.make_not q]

(* We can try and check the satisfiability of the given formulas *)
let () = Sat.assume (F.make_cnf r)
let _ = Sat.solve ()        (* Should return (Sat.Sat _) *)

(* The Sat solver has an incremental mutable state, so we still have
 * the formula 'r' in our assumptions *)
let () = Sat.assume (F.make_cnf s)
let _ = Sat.solve ()        (* Should return (Sat.Unsat _) *)