small refactor of CC

This commit is contained in:
Simon Cruanes 2022-08-21 22:01:07 -04:00
parent e34f5a5c3c
commit 30cf71522c
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -261,8 +261,9 @@ let find_common_ancestor self (a : e_node) (b : e_node) : e_node =
| FL_some r1, FL_some r2 -> find2 r1.next r2.next | FL_some r1, FL_some r2 -> find2 r1.next r2.next
| FL_some r, FL_none -> find1 r.next | FL_some r, FL_none -> find1 r.next
| FL_none, FL_some r -> find1 r.next | FL_none, FL_some r -> find1 r.next
| FL_none, FL_none -> assert false | FL_none, FL_none ->
(* no common ancestor *) (* no common ancestor *)
assert false
) )
in in
@ -395,27 +396,28 @@ and explain_expls self (es : explanation list) : Expl_state.t =
and explain_equal_rec_ (cc : t) (st : Expl_state.t) (a : e_node) (b : e_node) : and explain_equal_rec_ (cc : t) (st : Expl_state.t) (a : e_node) (b : e_node) :
unit = unit =
if a != b then (
Log.debugf 5 (fun k -> Log.debugf 5 (fun k ->
k "(@[cc.explain_loop.at@ %a@ =?= %a@])" E_node.pp a E_node.pp b); k "(@[cc.explain_loop.at@ %a@ =?= %a@])" E_node.pp a E_node.pp b);
assert (E_node.equal (find_ a) (find_ b)); assert (E_node.equal (find_ a) (find_ b));
let ancestor = find_common_ancestor cc a b in let ancestor = find_common_ancestor cc a b in
explain_along_path cc st a ancestor; explain_along_path cc st a ancestor;
explain_along_path cc st b ancestor explain_along_path cc st b ancestor
)
(* explain why [a = parent_a], where [a -> ... -> target] in the (* explain why [a = target], where [a -> ... -> target] in the
proof forest *) proof forest *)
and explain_along_path self (st : Expl_state.t) (a : e_node) (target : e_node) : and explain_along_path self (st : Expl_state.t) (a : e_node) (target : e_node) :
unit = unit =
let rec aux n = let rec aux n =
if n == target then if n != target then (
()
else (
match n.n_expl with match n.n_expl with
| FL_none -> assert false | FL_none -> assert false
| FL_some { next = next_n; expl } -> | FL_some { next = next_a; expl } ->
(* prove [a = next_n] *)
explain_decompose_expl self st expl; explain_decompose_expl self st expl;
(* now prove [next_n = target] *) (* now prove [next_a = target] *)
aux next_n aux next_a
) )
in in
aux a aux a
@ -887,12 +889,9 @@ let[@inline] find_t self t : repr =
find_ n find_ n
let pop_acts_ self = let pop_acts_ self =
let rec loop acc = let l = Vec.to_list self.res_acts in
match Vec.pop self.res_acts with Vec.clear self.res_acts;
| None -> acc l
| Some x -> loop (x :: acc)
in
loop []
let check self : Result_action.or_conflict = let check self : Result_action.or_conflict =
Log.debug 5 "(cc.check)"; Log.debug 5 "(cc.check)";