restrict what Msat core lib exposes, provide shortcuts

This commit is contained in:
Simon Cruanes 2017-12-28 19:23:36 +01:00
parent 1037c06636
commit d6c84b93bf
11 changed files with 53 additions and 14 deletions

View file

@ -32,7 +32,7 @@ module type S = sig
end
module Make(St : Solver_types.S)(Dummy: sig end) = struct
module Make(St : Solver_types_intf.S)(Dummy: sig end) = struct
(* Dimacs & iCNF export *)
let export_vec name fmt vec =

View file

@ -42,6 +42,6 @@ module type S = sig
end
module Make(St: Solver_types.S)(Dummy: sig end) : S with type clause := St.clause
module Make(St: Solver_types_intf.S)(Dummy: sig end) : S with type clause := St.clause
(** Functor to create a module for exporting probems to the dimacs (& iCNF) formats. *)

39
src/core/Msat.ml Normal file
View file

@ -0,0 +1,39 @@
(** Main API *)
module Formula_intf = Formula_intf
module Plugin_intf = Plugin_intf
module Theory_intf = Theory_intf
module Expr_intf = Expr_intf
module Solver_types_intf = Solver_types_intf
module Res = Res
module type S = Solver_intf.S
type ('term, 'form) sat_state = ('term, 'form) Solver_intf.sat_state = {
eval : 'form -> bool;
eval_level : 'form -> bool * int;
iter_trail : ('form -> unit) -> ('term -> unit) -> unit;
model : unit -> ('term * 'term) list;
}
type ('clause, 'proof) unsat_state = ('clause, 'proof) Solver_intf.unsat_state = {
unsat_conflict : unit -> 'clause;
get_proof : unit -> 'proof;
}
type 'clause export = 'clause Solver_intf.export = {
hyps : 'clause Vec.t;
history : 'clause Vec.t;
local : 'clause Vec.t;
}
module Make_smt_expr(E : Formula_intf.S) = Solver_types.SatMake(E)
module Make_mcsat_expr(E : Expr_intf.S) = Solver_types.McMake(E)
module Make = Solver.Make
(**/**)
module Vec = Vec
module Log = Log
(**/**)

View file

@ -27,7 +27,7 @@ module type S = sig
end
module Make
(S : External.S)
(S : Msat.S)
(T : Msat_solver.Type.S with type atom := S.atom)
: sig
val do_task : Dolmen.Statement.t -> unit
@ -42,7 +42,7 @@ module Make
let l = List.map (function a ->
Log.debugf 99
(fun k -> k "Checking value of %a" S.St.pp_atom (S.St.add_atom a));
state.Solver_intf.eval a) c in
state.Msat.eval a) c in
List.exists (fun x -> x) l
in
let l = List.map check_clause !hyps in
@ -60,7 +60,7 @@ module Make
Format.printf "Sat (%f/%f)@." t t'
| S.Unsat state ->
if !p_check then begin
let p = state.Solver_intf.get_proof () in
let p = state.Msat.get_proof () in
S.Proof.check p;
if !p_dot_proof <> "" then begin
let fmt = Format.formatter_of_out_channel (open_out !p_dot_proof) in

View file

@ -4,15 +4,15 @@ Copyright 2014 Guillaume Bury
Copyright 2014 Simon Cruanes
*)
module type S = Solver_intf.S
module type S = Msat.S
module Make (E : Expr_intf.S)
(Th : Plugin_intf.S with type term = E.Term.t
and type formula = E.Formula.t
and type proof = E.proof)
() =
External.Make
(Solver_types.McMake(E)(struct end))
Msat.Make
(Make_mcsat_expr(E)())
(Th)
()

View file

@ -9,7 +9,7 @@ Copyright 2014 Simon Cruanes
This module provides a functor to create an McSAt solver.
*)
module type S = Solver_intf.S
module type S = Msat.S
(** The interface exposed by the solver. *)
module Make (E : Expr_intf.S)

View file

@ -10,7 +10,7 @@
(* *)
(**************************************************************************)
module type S = Solver_intf.S
module type S = Msat.S
module DummyTheory(F : Formula_intf.S) = struct
(* We don't have anything to do since the SAT Solver already
@ -77,8 +77,8 @@ end
module Make (E : Formula_intf.S)
(Th : Theory_intf.S with type formula = E.t and type proof = E.proof)
() =
External.Make
(Solver_types.SatMake(E)(struct end))
Msat.Make
(Make_smt_expr(E)(struct end))
(Plugin(E)(Th))
()

View file

@ -11,7 +11,7 @@ Copyright 2014 Simon Cruanes
functor in order to create a pure SAT solver.
*)
module type S = Solver_intf.S
module type S = Msat.S
(** The interface of instantiated solvers. *)
module DummyTheory(F : Formula_intf.S) :

View file

@ -51,7 +51,7 @@ let mk_solver (): (module BASIC_SOLVER) =
| Sat _ ->
R_sat
| Unsat us ->
let p = us.Solver_intf.get_proof () in
let p = us.Msat.get_proof () in
Proof.check p;
R_unsat
end