Skip to content

Commit

Permalink
Expose the map in ModelMap, and add find and fold functions over …
Browse files Browse the repository at this point in the history
…that map
  • Loading branch information
hra687261 committed Oct 9, 2024
1 parent 19879e6 commit 8875768
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/lib/structures/modelMap.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
module X = Shostak.Combine
module Sy = Symbols

module M: Map.S with type key = Expr.t list = Map.Make
(struct
type t = Expr.t list [@@deriving ord]
end)

(* The type of this module represents a model value for a function [f] by a
finite set of constraints of the form:
f(e_1, ..., e_n) = e
Expand All @@ -27,10 +32,6 @@ module Sy = Symbols
As functions in the SMT-LIB standard are total, one of the expressions [e]
above is used as the default value of the function. *)
module Constraints = struct
module M = Map.Make
(struct
type t = Expr.t list [@@deriving ord]
end)

type t = Expr.t M.t

Expand Down Expand Up @@ -137,6 +138,12 @@ let add ((id, arg_tys, _) as sy) arg_vals ret_val { values; suspicious } =
in
{ values; suspicious }

let find k {values; _ } =
P.find k values

let fold f {values;_} acc =
P.fold f values acc

let empty ~suspicious declared_ids =
let values =
List.fold_left
Expand Down
17 changes: 17 additions & 0 deletions src/lib/structures/modelMap.mli
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
(* *)
(**************************************************************************)

module M: Map.S with type key = Expr.t list

type graph =
| Free of Expr.t
(* Represents a graph without any constraint. The expression is
an abstract value. *)

| C of Expr.t M.t

type t
(** Type of model. *)

Expand All @@ -28,6 +37,14 @@ val empty : suspicious:bool -> Id.typed list -> t
model may be wrong as it involves symbols from theories for which the
model generation is known to be incomplete. *)

val find : Id.typed -> t -> graph
(** [find sy mdl] returns the graph associated with the symbol [sy] in the model
[mdl], raises [Not_found] if it doesn't exist. *)

val fold: (Id.typed -> graph -> 'a -> 'a) -> t -> 'a -> 'a
(** [fold f mdl init] folds over the bindings in the model [mdl] with the
function [f] and with [init] as a initial value for the accumulator. *)

val subst : Id.t -> Expr.t -> t -> t
(** [subst id e mdl] substitutes all the occurrences of the identifier [id]
in the model [mdl] by the model term [e].
Expand Down

0 comments on commit 8875768

Please sign in to comment.