diff --git a/src/smt/Solver_types.ml b/src/smt/Solver_types.ml index 0afa1614..de0b3d71 100644 --- a/src/smt/Solver_types.ml +++ b/src/smt/Solver_types.ml @@ -197,7 +197,7 @@ let rec pp_ty out t = match t.ty_view with Fmt.fprintf out "(@[%a@ %a@])" ID.pp id (Util.pp_list pp_ty) args | Ty_atomic {def=Ty_def def; args; _} -> def.pp pp_ty out args -let pp_term_view ~pp_id ~pp_t out = function +let pp_term_view_gen ~pp_id ~pp_t out = function | Bool true -> Fmt.string out "true" | Bool false -> Fmt.string out "false" | App_cst ({cst_view=Cst_def {pp=Some pp_custom;_};_},l) -> pp_custom pp_t out l @@ -212,12 +212,12 @@ let pp_term_top ~ids out t = let rec pp out t = pp_rec out t; (* FIXME if Config.pp_hashcons then Format.fprintf out "/%d" t.term_id; *) - and pp_rec out t = pp_term_view ~pp_id ~pp_t:pp_rec out t.term_view + and pp_rec out t = pp_term_view_gen ~pp_id ~pp_t:pp_rec out t.term_view and pp_id = if ids then ID.pp else ID.pp_name in pp out t let pp_term = pp_term_top ~ids:false -let pp_term_view = pp_term_view ~pp_id:ID.pp_name ~pp_t:pp_term +let pp_term_view = pp_term_view_gen ~pp_id:ID.pp_name ~pp_t:pp_term let pp_lit out l = if l.lit_sign then pp_term out l.lit_term diff --git a/src/smt/Term.ml b/src/smt/Term.ml index 3ae323d8..16d2cedc 100644 --- a/src/smt/Term.ml +++ b/src/smt/Term.ml @@ -20,6 +20,9 @@ let equal = term_equal_ let hash = term_hash_ let compare a b = CCInt.compare a.term_id b.term_id +(* TODO: when GC is implemented, add a field for recycling IDs + that have been free'd, so we can keep the ID space dense. *) + type state = { tbl : term Term_cell.Tbl.t; mutable n: int; diff --git a/src/smt/Term_cell.ml b/src/smt/Term_cell.ml index e3ee145b..560fd229 100644 --- a/src/smt/Term_cell.ml +++ b/src/smt/Term_cell.ml @@ -14,6 +14,7 @@ module type ARG = sig type t val hash : t -> int val equal : t -> t -> bool + val pp : t Fmt.printer end module Make_eq(A : ARG) = struct @@ -35,12 +36,15 @@ module Make_eq(A : ARG) = struct sub_eq a1 a2 && sub_eq b1 b2 && sub_eq c1 c2 | Bool _, _ | App_cst _, _ | If _, _ -> false + + let pp = Solver_types.pp_term_view_gen ~pp_id:ID.pp_name ~pp_t:A.pp end[@@inline] include Make_eq(struct type t = term let equal (t1:t) t2 = t1==t2 let hash (t:term): int = t.term_id + let pp = pp_term end) let true_ = Bool true @@ -53,8 +57,6 @@ let if_ a b c = assert (Ty.equal b.term_ty c.term_ty); If (a,b,c) -let pp = pp_term_view - let ty (t:t): Ty.t = match t with | Bool _ -> Ty.prop | App_cst (f, args) -> diff --git a/src/smt/Term_cell.mli b/src/smt/Term_cell.mli index 0ef8bb07..303d0680 100644 --- a/src/smt/Term_cell.mli +++ b/src/smt/Term_cell.mli @@ -28,9 +28,11 @@ module type ARG = sig type t val hash : t -> int val equal : t -> t -> bool + val pp : t Fmt.printer end module Make_eq(X : ARG) : sig val equal : X.t view -> X.t view -> bool val hash : X.t view -> int + val pp : X.t view Fmt.printer end