Module Process.Solver

module T : Sidekick_core.TERM with type Term.t = Sidekick_base.Term.t and type Term.store = Sidekick_base.Term.store and type Ty.t = Sidekick_base.Ty.t and type Ty.store = Sidekick_base.Ty.store
module P : Sidekick_core.PROOF with type term = T.Term.t
module Lit : Sidekick_core.LIT with module T = T
module Solver_internal : Sidekick_core.SOLVER_INTERNAL with module T = T and module P = P and module Lit = Lit

Internal solver, available to theories.

type t

The solver's state.

type solver = t
type term = T.Term.t
type ty = T.Ty.t
type lit = Lit.t
type proof = P.t
module type THEORY = sig ... end
type theory = (module THEORY)

A theory that can be used for this particular solver.

type 'a theory_p = (module THEORY with type t = 'a)

A theory that can be used for this particular solver, with state of type 'a.

val mk_theory : name:string -> create_and_setup:(Solver_internal.t -> 'th) -> ?⁠push_level:('th -> unit) -> ?⁠pop_levels:('th -> int -> unit) -> unit -> theory

Helper to create a theory.

module Atom : sig ... end
module Model : sig ... end

Models

module Unknown : sig ... end

Main API

val stats : t -> Sidekick_util.Stat.t
val tst : t -> T.Term.store
val ty_st : t -> T.Ty.store
val create : ?⁠stat:Sidekick_util.Stat.t -> ?⁠size:[ `Big | `Tiny | `Small ] -> ?⁠store_proof:bool -> theories:theory list -> T.Term.store -> T.Ty.store -> unit -> t

Create a new solver.

It needs a term state and a type state to manipulate terms and types. All terms and types interacting with this solver will need to come from these exact states.

parameter store_proof

if true, proofs from the SAT solver and theories are retained and potentially accessible after solve returns UNSAT.

parameter size

influences the size of initial allocations.

parameter theories

theories to load from the start. Other theories can be added using add_theory.

val add_theory : t -> theory -> unit

Add a theory to the solver. This should be called before any call to solve or to add_clause and the likes (otherwise the theory will have a partial view of the problem).

val add_theory_p : t -> 'a theory_p -> 'a

Add the given theory and obtain its state

val add_theory_l : t -> theory list -> unit
val mk_atom_lit : t -> lit -> Atom.t * P.t

mk_atom_lit _ lit returns atom, pr where atom is an internal atom for the solver, and pr is a proof of |- lit = atom

val mk_atom_lit' : t -> lit -> Atom.t

Like mk_atom_t but skips the proof

val mk_atom_t : t -> ?⁠sign:bool -> term -> Atom.t * P.t

mk_atom_t _ ~sign t returns atom, pr where atom is an internal representation of ± t, and pr is a proof of |- atom = (± t)

val mk_atom_t' : t -> ?⁠sign:bool -> term -> Atom.t

Like mk_atom_t but skips the proof

val add_clause : t -> Atom.t Sidekick_util.IArray.t -> P.t -> unit

add_clause solver cs adds a boolean clause to the solver. Subsequent calls to solve will need to satisfy this clause.

val add_clause_l : t -> Atom.t list -> P.t -> unit

Add a clause to the solver, given as a list.

val assert_terms : t -> term list -> unit

Helper that turns each term into an atom, before adding the result to the solver as an assertion

val assert_term : t -> term -> unit

Helper that turns the term into an atom, before adding the result to the solver as a unit clause assertion

module Pre_proof : sig ... end
type res =
| Sat of Model.t

Satisfiable

| Unsat of {
proof : Pre_proof.t option lazy_t;

proof of unsat

unsat_core : Atom.t list lazy_t;

subset of assumptions responsible for unsat

}

Unsatisfiable

| Unknown of Unknown.t

Unknown, obtained after a timeout, memory limit, etc.

Result of solving for the current set of clauses

val solve : ?⁠on_exit:(unit -> unit) list -> ?⁠check:bool -> ?⁠on_progress:(t -> unit) -> assumptions:Atom.t list -> t -> res

solve s checks the satisfiability of the clauses added so far to s.

parameter check

if true, the model is checked before returning.

parameter on_progress

called regularly during solving.

parameter assumptions

a set of atoms held to be true. The unsat core, if any, will be a subset of assumptions.

parameter on_exit

functions to be run before this returns

val pp_stats : t CCFormat.printer

Print some statistics. What it prints exactly is unspecified.