mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-06 11:15:43 -05:00
expose {push,pop} in main solver
This commit is contained in:
parent
be929d056a
commit
2caf53c24f
3 changed files with 44 additions and 6 deletions
|
|
@ -115,6 +115,10 @@ module Make
|
||||||
mutable learntsize_factor : float;
|
mutable learntsize_factor : float;
|
||||||
(* initial limit for the number of learnt clauses, 1/3 of initial
|
(* initial limit for the number of learnt clauses, 1/3 of initial
|
||||||
number of clauses by default *)
|
number of clauses by default *)
|
||||||
|
|
||||||
|
mutable dirty: bool;
|
||||||
|
(* is there a [pop()] on top of the stack for examining
|
||||||
|
current model/proof? *)
|
||||||
}
|
}
|
||||||
|
|
||||||
(* Starting environment. *)
|
(* Starting environment. *)
|
||||||
|
|
@ -146,6 +150,7 @@ module Make
|
||||||
restart_first = 100;
|
restart_first = 100;
|
||||||
|
|
||||||
learntsize_factor = 1. /. 3. ;
|
learntsize_factor = 1. /. 3. ;
|
||||||
|
dirty=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let create ?(size=`Big) ?st () : t =
|
let create ?(size=`Big) ?st () : t =
|
||||||
|
|
|
||||||
|
|
@ -79,21 +79,41 @@ module Make
|
||||||
in
|
in
|
||||||
{ unsat_conflict; get_proof; }
|
{ unsat_conflict; get_proof; }
|
||||||
|
|
||||||
(* Wrappers around internal functions*)
|
(* clean local state *)
|
||||||
let assume = S.assume
|
let[@inline] cleanup_ (st:t) : unit =
|
||||||
|
if st.S.dirty then (
|
||||||
|
S.pop st; (* reset *)
|
||||||
|
st.S.dirty <- false;
|
||||||
|
)
|
||||||
|
|
||||||
let add_clause = S.add_clause
|
(* Wrappers around internal functions*)
|
||||||
|
let[@inline] assume st ?tag cls : unit =
|
||||||
|
cleanup_ st;
|
||||||
|
S.assume st ?tag cls
|
||||||
|
|
||||||
|
let[@inline] add_clause st c : unit =
|
||||||
|
cleanup_ st;
|
||||||
|
S.add_clause st c
|
||||||
|
|
||||||
let solve (st:t) ?(assumptions=[]) () =
|
let solve (st:t) ?(assumptions=[]) () =
|
||||||
|
cleanup_ st;
|
||||||
try
|
try
|
||||||
S.pop st; (* FIXME: what?! *)
|
|
||||||
S.push st;
|
S.push st;
|
||||||
|
st.S.dirty <- true; (* to call [pop] before any other action *)
|
||||||
S.local st assumptions;
|
S.local st assumptions;
|
||||||
S.solve st;
|
S.solve st;
|
||||||
Sat (mk_sat st)
|
Sat (mk_sat st)
|
||||||
with S.Unsat ->
|
with S.Unsat ->
|
||||||
Unsat (mk_unsat st)
|
Unsat (mk_unsat st)
|
||||||
|
|
||||||
|
let[@inline] push st =
|
||||||
|
cleanup_ st;
|
||||||
|
S.push st
|
||||||
|
|
||||||
|
let[@inline] pop st =
|
||||||
|
cleanup_ st;
|
||||||
|
S.pop st
|
||||||
|
|
||||||
let unsat_core = S.Proof.unsat_core
|
let unsat_core = S.Proof.unsat_core
|
||||||
|
|
||||||
let true_at_level0 st a =
|
let true_at_level0 st a =
|
||||||
|
|
@ -104,8 +124,13 @@ module Make
|
||||||
|
|
||||||
let get_tag cl = St.(cl.tag)
|
let get_tag cl = St.(cl.tag)
|
||||||
|
|
||||||
let new_lit = S.new_lit
|
let[@inline] new_lit st t =
|
||||||
let new_atom = S.new_atom
|
cleanup_ st;
|
||||||
|
S.new_lit st t
|
||||||
|
|
||||||
|
let[@inline] new_atom st a =
|
||||||
|
cleanup_ st;
|
||||||
|
S.new_atom st a
|
||||||
|
|
||||||
let export (st:t) : St.clause export =
|
let export (st:t) : St.clause export =
|
||||||
let hyps = S.hyps st in
|
let hyps = S.hyps st in
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,14 @@ module type S = sig
|
||||||
val get_tag : clause -> int option
|
val get_tag : clause -> int option
|
||||||
(** Recover tag from a clause, if any *)
|
(** Recover tag from a clause, if any *)
|
||||||
|
|
||||||
|
val push : t -> unit
|
||||||
|
(** Push a new save point *)
|
||||||
|
|
||||||
|
val pop : t -> unit
|
||||||
|
(** Return to last save point *)
|
||||||
|
|
||||||
|
val pop : t -> unit
|
||||||
|
|
||||||
val export : t -> clause export
|
val export : t -> clause export
|
||||||
|
|
||||||
(** {2 Re-export some functions} *)
|
(** {2 Re-export some functions} *)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue