[sledge] Add the embedding of arithmetic into terms to the arithmetic interface

Summary:
The implementation of Arithmetic relies on the partial projection from
terms to polynomials. This diff enables it to also embed polynomials
back into terms.

Reviewed By: jvillard

Differential Revision: D24746223

fbshipit-source-id: b6010e7b7
master
Josh Berdine 4 years ago committed by Facebook GitHub Bot
parent 14b32f1727
commit 6f4dcfbdd9

@ -93,18 +93,20 @@ module type INDETERMINATE = sig
val vars : trm -> var iter val vars : trm -> var iter
end end
(** An embedding of arithmetic terms [t] into indeterminates [trm], (** An embedding of arithmetic terms [t] into indeterminates [trm]. *)
expressed as a partial projection from [trm] to [t]. The inverse
embedding function is generally internal to the client. *)
module type EMBEDDING = sig module type EMBEDDING = sig
type trm type trm
type t type t
val to_trm : t -> trm
(** Embedding from [t] to [trm]: [to_trm a] is arithmetic term [a]
embedded in an indeterminate term. *)
val get_arith : trm -> t option val get_arith : trm -> t option
(** [get_arith x] should be [Some a] if indeterminate [x] is equivalent to (** Partial projection from [trm] to [t]: [get_arith x] is [Some a] if
[a] embedded into an indeterminate term. This is used to flatten [x = to_trm a]. This is used to flatten indeterminates that are
indeterminates that are actually arithmetic for the client, thereby actually arithmetic for the client, thereby enabling arithmetic
enabling arithmetic operations to be interpreted more often. *) operations to be interpreted more often. *)
end end
(** A type [t] representing arithmetic terms over indeterminates [trm] (** A type [t] representing arithmetic terms over indeterminates [trm]

@ -56,6 +56,8 @@ and Arith :
include Arith0 include Arith0
include Make (struct include Make (struct
let to_trm = Trm._Arith
let get_arith (e : Trm.t) = let get_arith (e : Trm.t) =
match e with match e with
| Z z -> Some (Arith.const (Q.of_z z)) | Z z -> Some (Arith.const (Q.of_z z))

Loading…
Cancel
Save