mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-10 05:03:59 -05:00
fix(solver): in final-check, fixpoint until CC has no merges
This commit is contained in:
parent
93b993825b
commit
bb449257d8
3 changed files with 25 additions and 6 deletions
|
|
@ -260,6 +260,7 @@ module Make (A: CC_ARG)
|
||||||
mutable on_new_term: ev_on_new_term list;
|
mutable on_new_term: ev_on_new_term list;
|
||||||
mutable on_conflict: ev_on_conflict list;
|
mutable on_conflict: ev_on_conflict list;
|
||||||
mutable on_propagate: ev_on_propagate list;
|
mutable on_propagate: ev_on_propagate list;
|
||||||
|
mutable new_merges: bool;
|
||||||
bitgen: Bits.bitfield_gen;
|
bitgen: Bits.bitfield_gen;
|
||||||
field_marked_explain: Bits.field; (* used to mark traversed nodes when looking for a common ancestor *)
|
field_marked_explain: Bits.field; (* used to mark traversed nodes when looking for a common ancestor *)
|
||||||
true_ : node lazy_t;
|
true_ : node lazy_t;
|
||||||
|
|
@ -618,7 +619,9 @@ module Make (A: CC_ARG)
|
||||||
end
|
end
|
||||||
|
|
||||||
and[@inline] task_combine_ cc acts = function
|
and[@inline] task_combine_ cc acts = function
|
||||||
| CT_merge (a,b,e_ab) -> task_merge_ cc acts a b e_ab
|
| CT_merge (a,b,e_ab) ->
|
||||||
|
cc.new_merges <- true;
|
||||||
|
task_merge_ cc acts a b e_ab
|
||||||
|
|
||||||
(* main CC algo: merge equivalence classes in [st.combine].
|
(* main CC algo: merge equivalence classes in [st.combine].
|
||||||
@raise Exn_unsat if merge fails *)
|
@raise Exn_unsat if merge fails *)
|
||||||
|
|
@ -861,6 +864,7 @@ module Make (A: CC_ARG)
|
||||||
true_;
|
true_;
|
||||||
false_;
|
false_;
|
||||||
stat;
|
stat;
|
||||||
|
new_merges=false;
|
||||||
field_marked_explain;
|
field_marked_explain;
|
||||||
count_conflict=Stat.mk_int stat "cc.conflicts";
|
count_conflict=Stat.mk_int stat "cc.conflicts";
|
||||||
count_props=Stat.mk_int stat "cc.propagations";
|
count_props=Stat.mk_int stat "cc.propagations";
|
||||||
|
|
@ -881,8 +885,11 @@ module Make (A: CC_ARG)
|
||||||
|
|
||||||
let[@inline] check cc acts : unit =
|
let[@inline] check cc acts : unit =
|
||||||
Log.debug 5 "(cc.check)";
|
Log.debug 5 "(cc.check)";
|
||||||
|
cc.new_merges <- false;
|
||||||
update_tasks cc acts
|
update_tasks cc acts
|
||||||
|
|
||||||
|
let new_merges cc = cc.new_merges
|
||||||
|
|
||||||
(* model: return all the classes *)
|
(* model: return all the classes *)
|
||||||
let get_model (cc:t) : repr Iter.t Iter.t =
|
let get_model (cc:t) : repr Iter.t Iter.t =
|
||||||
all_classes cc |> Iter.map N.iter_class
|
all_classes cc |> Iter.map N.iter_class
|
||||||
|
|
|
||||||
|
|
@ -299,6 +299,10 @@ module type CC_S = sig
|
||||||
(** Perform all pending operations done via {!assert_eq}, {!assert_lit}, etc.
|
(** Perform all pending operations done via {!assert_eq}, {!assert_lit}, etc.
|
||||||
Will use the {!actions} to propagate literals, declare conflicts, etc. *)
|
Will use the {!actions} to propagate literals, declare conflicts, etc. *)
|
||||||
|
|
||||||
|
val new_merges : t -> bool
|
||||||
|
(** Called after {!check}, returns [true] if some pairs of classes
|
||||||
|
were merged. *)
|
||||||
|
|
||||||
val push_level : t -> unit
|
val push_level : t -> unit
|
||||||
(** Push backtracking level *)
|
(** Push backtracking level *)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -299,6 +299,8 @@ module Make(A : ARG)
|
||||||
CC.pop_levels (cc self) n;
|
CC.pop_levels (cc self) n;
|
||||||
pop_lvls_ n self.th_states
|
pop_lvls_ n self.th_states
|
||||||
|
|
||||||
|
exception E_loop_exit
|
||||||
|
|
||||||
(* handle a literal assumed by the SAT solver *)
|
(* handle a literal assumed by the SAT solver *)
|
||||||
let assert_lits_ ~final (self:t) (acts:actions) (lits:Lit.t Iter.t) : unit =
|
let assert_lits_ ~final (self:t) (acts:actions) (lits:Lit.t Iter.t) : unit =
|
||||||
Msat.Log.debugf 2
|
Msat.Log.debugf 2
|
||||||
|
|
@ -312,11 +314,17 @@ module Make(A : ARG)
|
||||||
(* transmit to theories. *)
|
(* transmit to theories. *)
|
||||||
CC.check cc acts;
|
CC.check cc acts;
|
||||||
if final then (
|
if final then (
|
||||||
for _i = 0 to 1 do
|
try
|
||||||
List.iter (fun f -> f self acts lits) self.on_final_check;
|
while true do
|
||||||
CC.check cc acts;
|
(* TODO: theory combination *)
|
||||||
done; (* FIXME *)
|
List.iter (fun f -> f self acts lits) self.on_final_check;
|
||||||
(* TODO: theory combination until fixpoint *)
|
CC.check cc acts;
|
||||||
|
if not @@ CC.new_merges cc then (
|
||||||
|
raise_notrace E_loop_exit
|
||||||
|
);
|
||||||
|
done;
|
||||||
|
with E_loop_exit ->
|
||||||
|
()
|
||||||
) else (
|
) else (
|
||||||
List.iter (fun f -> f self acts lits) self.on_partial_check;
|
List.iter (fun f -> f self acts lits) self.on_partial_check;
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue