mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-06 11:15:43 -05:00
feat: embed micro theories in theories, fix th-distinct
This commit is contained in:
parent
14992f07ec
commit
632bec0e66
3 changed files with 18 additions and 6 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue