[sledge] Add Term.Map and Var.Map

Reviewed By: ngorogiannis

Differential Revision: D19221871

fbshipit-source-id: bc83a6c8b
master
Josh Berdine 5 years ago committed by Facebook Github Bot
parent 83c59dc795
commit c52b49e6c0

@ -111,7 +111,17 @@ type _t = T0.t
include T include T
let empty_map = Map.empty (module T) module Map = struct
include (
Map :
module type of Map
with type ('key, 'value, 'cmp) t := ('key, 'value, 'cmp) Map.t )
type 'v t = 'v Map.M(T).t [@@deriving compare, equal, sexp]
let empty = empty (module T)
end
let empty_qset = Qset.empty (module T) let empty_qset = Qset.empty (module T)
let fix (f : (t -> 'a as 'f) -> 'f) (bot : 'f) (e : t) : 'a = let fix (f : (t -> 'a as 'f) -> 'f) (bot : 'f) (e : t) : 'a =
@ -294,6 +304,8 @@ module Var = struct
let pp = pp let pp = pp
module Map = Map
module Set = struct module Set = struct
include ( include (
Set : Set :
@ -310,15 +322,6 @@ module Var = struct
let of_vector = Set.of_vector (module T) let of_vector = Set.of_vector (module T)
end end
module Map = struct
include (
Map :
module type of Map
with type ('key, 'value, 'cmp) t := ('key, 'value, 'cmp) Map.t )
type 'v t = 'v Map.M(T).t [@@deriving compare, equal, sexp]
end
let invariant x = let invariant x =
Invariant.invariant [%here] x [%sexp_of: t] Invariant.invariant [%here] x [%sexp_of: t]
@@ fun () -> match x with Var _ -> invariant x | _ -> assert false @@ fun () -> match x with Var _ -> invariant x | _ -> assert false
@ -360,7 +363,7 @@ module Var = struct
Format.fprintf fs "@[%a ↦ %a@]" pp_t k pp_t v )) Format.fprintf fs "@[%a ↦ %a@]" pp_t k pp_t v ))
(Map.to_alist s) (Map.to_alist s)
let empty = empty_map let empty = Map.empty
let is_empty = Map.is_empty let is_empty = Map.is_empty
let freshen vs ~wrt = let freshen vs ~wrt =
@ -1070,7 +1073,7 @@ let solve e f =
| _ -> solve_uninterp e f ) | _ -> solve_uninterp e f )
| _ -> solve_uninterp e f | _ -> solve_uninterp e f
in in
solve_ e f empty_map solve_ e f Map.empty
|> |>
[%Trace.retn fun {pf} -> [%Trace.retn fun {pf} ->
function Some s -> pf "%a" Var.Subst.pp s | None -> pf "false"] function Some s -> pf "%a" Var.Subst.pp s | None -> pf "false"]

@ -109,6 +109,15 @@ module Var : sig
val of_vector : var vector -> t val of_vector : var vector -> t
end end
module Map : sig
type var := t
type 'a t = (var, 'a, comparator_witness) Map.t
[@@deriving compare, equal, sexp]
val empty : 'a t
end
val pp : t pp val pp : t pp
include Invariant.S with type t := t include Invariant.S with type t := t
@ -136,6 +145,15 @@ module Var : sig
end end
end end
module Map : sig
type term := t
type 'a t = (term, 'a, comparator_witness) Map.t
[@@deriving compare, equal, sexp]
val empty : 'a t
end
(** Construct *) (** Construct *)
(* variables *) (* variables *)
@ -225,4 +243,4 @@ val fv : t -> Var.Set.t
val is_true : t -> bool val is_true : t -> bool
val is_false : t -> bool val is_false : t -> bool
val classify : t -> [> `Atomic | `Interpreted | `Simplified | `Uninterpreted] val classify : t -> [> `Atomic | `Interpreted | `Simplified | `Uninterpreted]
val solve : t -> t -> (t, t, comparator_witness) Map.t option val solve : t -> t -> t Map.t option

Loading…
Cancel
Save