diff --git a/src/smt/Theory.ml b/src/smt/Theory.ml index d387e730..3092d738 100644 --- a/src/smt/Theory.ml +++ b/src/smt/Theory.ml @@ -80,6 +80,8 @@ module type S = sig val pop_levels : t -> int -> unit + val cc_th : t -> CC.Theory.t list + (**/**) val check_invariants : t -> unit (**/**) @@ -98,6 +100,7 @@ let make ?(mk_model=fun _ _ m -> m) ?(push_level=fun _ -> ()) ?(pop_levels=fun _ _ -> ()) + ?(cc_th=fun _->[]) ~name ~final_check ~create @@ -114,5 +117,6 @@ let make let check_invariants = check_invariants let push_level = push_level let pop_levels = pop_levels + let cc_th = cc_th end in (module A : S) diff --git a/src/smt/Theory_combine.ml b/src/smt/Theory_combine.ml index cfa77267..a7e741a8 100644 --- a/src/smt/Theory_combine.ml +++ b/src/smt/Theory_combine.ml @@ -154,6 +154,8 @@ let (module Th) = th in Log.debugf 2 (fun k-> k "(@[th_combine.add_th@ :name %S@])" Th.name); let st = Th.create self.tst in + (* add micro theories *) + List.iter (CC.add_th (cc self)) (Th.cc_th st); (* re-pack as a [Theory.t1] *) self.theories <- (Th_state ((module Th),st)) :: self.theories diff --git a/src/th-distinct/Sidekick_th_distinct.ml b/src/th-distinct/Sidekick_th_distinct.ml index f42dbd0f..94aa6343 100644 --- a/src/th-distinct/Sidekick_th_distinct.ml +++ b/src/th-distinct/Sidekick_th_distinct.ml @@ -45,19 +45,19 @@ module Make(A : ARG with type Lit.t = Sidekick_smt.Lit.t type lit = A.Lit.t type data = term IM.t (* "distinct" lit -> term appearing under it*) + let pp_data out m = + Fmt.fprintf out + "{@[%a@]}" Fmt.(seq ~sep:(return ",@ ") @@ pair Lit.pp T.pp) (IM.to_seq m) + let key : (term,lit,data) Sidekick_cc.Key.t = let merge m1 m2 = IM.merge_safe m1 m2 ~f:(fun _ pair -> match pair with | `Left x | `Right x -> Some x | `Both (x,_) -> Some x) - and eq = IM.equal T.equal - and pp out m = - Fmt.fprintf out - "{@[%a@]}" Fmt.(seq ~sep:(return ",@ ") @@ pair Lit.pp T.pp) (IM.to_seq m) - in + and eq = IM.equal T.equal in Sidekick_cc.Key.create - ~pp + ~pp:pp_data ~name:"distinct" ~merge ~eq () @@ -69,6 +69,9 @@ module Make(A : ARG with type Lit.t = Sidekick_smt.Lit.t exception E_exit let on_merge cc n1 m1 n2 m2 expl12 = + Log.debugf 5 + (fun k->k "(@[th_distinct.on_merge@ @[:n1 %a@ :map2 %a@]@ @[:n2 %a@ :map2 %a@]@])" + CC.N.pp n1 pp_data m1 CC.N.pp n2 pp_data m2); try let _i = IM.merge @@ -148,11 +151,14 @@ module Make(A : ARG with type Lit.t = Sidekick_smt.Lit.t | None -> () | Some subs -> process_lit st acts lit t subs) + let cc_th = let module T = Micro(CC) in T.th + let th = Sidekick_smt.Theory.make ~name:"distinct" ~partial_check ~final_check:(fun _ _ _ -> ()) + ~cc_th:(fun _ -> [cc_th]) ~create () end