mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-06 03:05:31 -05:00
refactor: return optional proof, do not store if if -no-check was given
This commit is contained in:
parent
62ea8fd0cb
commit
5865151247
4 changed files with 27 additions and 18 deletions
|
|
@ -107,7 +107,7 @@ let main () =
|
||||||
| Smtlib ->
|
| Smtlib ->
|
||||||
[Sidekick_th_bool.th] (* TODO: more theories *)
|
[Sidekick_th_bool.th] (* TODO: more theories *)
|
||||||
in
|
in
|
||||||
Sidekick_smt.Solver.create ~theories ()
|
Sidekick_smt.Solver.create ~store_proof:!check ~theories ()
|
||||||
in
|
in
|
||||||
let dot_proof = if !p_dot_proof = "" then None else Some !p_dot_proof in
|
let dot_proof = if !p_dot_proof = "" then None else Some !p_dot_proof in
|
||||||
begin match syn with
|
begin match syn with
|
||||||
|
|
|
||||||
|
|
@ -63,10 +63,10 @@ let[@inline] mk_atom_t self ?sign t : Atom.t =
|
||||||
let lit = Lit.atom ?sign t in
|
let lit = Lit.atom ?sign t in
|
||||||
mk_atom_lit self lit
|
mk_atom_lit self lit
|
||||||
|
|
||||||
let create ?size ?(config=Config.empty) ~theories () : t =
|
let create ?size ?(config=Config.empty) ?store_proof ~theories () : t =
|
||||||
let th_combine = Theory_combine.create() in
|
let th_combine = Theory_combine.create() in
|
||||||
let self = {
|
let self = {
|
||||||
solver=Sat_solver.create ?size th_combine;
|
solver=Sat_solver.create ?store_proof ?size th_combine;
|
||||||
stat=Stat.create ();
|
stat=Stat.create ();
|
||||||
config;
|
config;
|
||||||
} in
|
} in
|
||||||
|
|
@ -168,7 +168,7 @@ let pp_model = Model.pp
|
||||||
|
|
||||||
type res =
|
type res =
|
||||||
| Sat of model
|
| Sat of model
|
||||||
| Unsat of Proof.t
|
| Unsat of Proof.t option
|
||||||
| Unknown of unknown
|
| Unknown of unknown
|
||||||
|
|
||||||
(** {2 Main} *)
|
(** {2 Main} *)
|
||||||
|
|
@ -221,7 +221,7 @@ let check_model (_s:t) : unit =
|
||||||
|
|
||||||
(* TODO: main loop with iterative deepening of the unrolling limit
|
(* TODO: main loop with iterative deepening of the unrolling limit
|
||||||
(not the value depth limit) *)
|
(not the value depth limit) *)
|
||||||
let solve ?(on_exit=[]) ?check:(_=true) ~assumptions (self:t) : res =
|
let solve ?(on_exit=[]) ?(check=true) ~assumptions (self:t) : res =
|
||||||
let r = Sat_solver.solve ~assumptions (solver self) in
|
let r = Sat_solver.solve ~assumptions (solver self) in
|
||||||
match r with
|
match r with
|
||||||
| Sat_solver.Sat st ->
|
| Sat_solver.Sat st ->
|
||||||
|
|
@ -237,7 +237,13 @@ let solve ?(on_exit=[]) ?check:(_=true) ~assumptions (self:t) : res =
|
||||||
Unknown U_incomplete (* TODO *)
|
Unknown U_incomplete (* TODO *)
|
||||||
*)
|
*)
|
||||||
| Sat_solver.Unsat us ->
|
| Sat_solver.Unsat us ->
|
||||||
|
let pr =
|
||||||
|
try
|
||||||
let pr = us.get_proof () in
|
let pr = us.get_proof () in
|
||||||
|
if check then Sat_solver.Proof.check pr;
|
||||||
|
Some pr
|
||||||
|
with Msat.Solver_intf.No_proof -> None
|
||||||
|
in
|
||||||
do_on_exit ~on_exit;
|
do_on_exit ~on_exit;
|
||||||
Unsat pr
|
Unsat pr
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ type unknown =
|
||||||
|
|
||||||
type res =
|
type res =
|
||||||
| Sat of Model.t
|
| Sat of Model.t
|
||||||
| Unsat of Proof.t
|
| Unsat of Proof.t option
|
||||||
| Unknown of unknown
|
| Unknown of unknown
|
||||||
|
|
||||||
(** {2 Main} *)
|
(** {2 Main} *)
|
||||||
|
|
@ -41,6 +41,7 @@ type t
|
||||||
val create :
|
val create :
|
||||||
?size:[`Big | `Tiny | `Small] ->
|
?size:[`Big | `Tiny | `Small] ->
|
||||||
?config:Config.t ->
|
?config:Config.t ->
|
||||||
|
?store_proof:bool ->
|
||||||
theories:Theory.t list ->
|
theories:Theory.t list ->
|
||||||
unit -> t
|
unit -> t
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -287,9 +287,12 @@ let solve
|
||||||
);
|
);
|
||||||
let t3 = Sys.time () -. t2 in
|
let t3 = Sys.time () -. t2 in
|
||||||
Format.printf "Sat (%.3f/%.3f/%.3f)@." t1 (t2-.t1) t3;
|
Format.printf "Sat (%.3f/%.3f/%.3f)@." t1 (t2-.t1) t3;
|
||||||
| Solver.Unsat p ->
|
| Solver.Unsat None ->
|
||||||
|
Format.printf "Unsat (%.3f/%.3f/-)@." t1 (t2-.t1);
|
||||||
|
| Solver.Unsat (Some p) ->
|
||||||
if check then (
|
if check then (
|
||||||
Solver.Proof.check p;
|
Solver.Proof.check p;
|
||||||
|
);
|
||||||
begin match dot_proof with
|
begin match dot_proof with
|
||||||
| None -> ()
|
| None -> ()
|
||||||
| Some file ->
|
| Some file ->
|
||||||
|
|
@ -299,8 +302,7 @@ let solve
|
||||||
let fmt = Format.formatter_of_out_channel oc in
|
let fmt = Format.formatter_of_out_channel oc in
|
||||||
Dot.pp fmt p;
|
Dot.pp fmt p;
|
||||||
Format.pp_print_flush fmt (); flush oc)
|
Format.pp_print_flush fmt (); flush oc)
|
||||||
end
|
end;
|
||||||
);
|
|
||||||
let t3 = Sys.time () -. t2 in
|
let t3 = Sys.time () -. t2 in
|
||||||
Format.printf "Unsat (%.3f/%.3f/%.3f)@." t1 (t2-.t1) t3;
|
Format.printf "Unsat (%.3f/%.3f/%.3f)@." t1 (t2-.t1) t3;
|
||||||
| Solver.Unknown reas ->
|
| Solver.Unknown reas ->
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue