[sledge] Add Theory.solvables

Reviewed By: jvillard

Differential Revision: D25883730

fbshipit-source-id: 793250146
master
Josh Berdine 4 years ago committed by Facebook GitHub Bot
parent dbfa63feaa
commit 724c1acc22

@ -53,6 +53,25 @@ let classify e =
let is_interpreted e = equal_kind (classify e) InterpApp
let is_uninterpreted e = equal_kind (classify e) UninterpApp
let is_noninterpreted e =
match classify e with
| InterpAtom | InterpApp -> false
| NonInterpAtom | UninterpApp -> true
let rec solvables e =
match classify e with
| InterpAtom -> Iter.empty
| InterpApp -> solvable_trms e
| NonInterpAtom | UninterpApp -> Iter.return e
and solvable_trms e = Iter.flat_map ~f:solvables (Trm.trms e)
let rec map_solvables e ~f =
match classify e with
| InterpAtom -> e
| NonInterpAtom | UninterpApp -> f e
| InterpApp -> Trm.map ~f:(map_solvables ~f) e
(* Solving equations ======================================================*)
(** prefer representative terms that are minimal in the order s.t. Var <
@ -231,6 +250,6 @@ let solve d e s =
*)
(* r = v ==> v ↦ r *)
| Some (rep, var) ->
assert (not (is_interpreted var)) ;
assert (not (is_interpreted rep)) ;
assert (is_noninterpreted var) ;
assert (is_noninterpreted rep) ;
add_solved ~var ~rep s

@ -16,10 +16,30 @@ type t =
val pp : t pp
val solvables : Trm.t -> Trm.t iter
(** The maximal noninterpreted terms (according to {!is_noninterpreted})
occurring in a term. Note that for noninterpreted terms, this is the
single term itself. *)
val solvable_trms : Trm.t -> Trm.t iter
(** The solvables of immediate subterms. That is, maximal noninterpreted
strict subterms. *)
val map_solvables : Trm.t -> f:(Trm.t -> Trm.t) -> Trm.t
(** Map over the {!solvables}. *)
type kind = InterpApp | NonInterpAtom | InterpAtom | UninterpApp
[@@deriving compare, equal]
val classify : Trm.t -> kind
val is_noninterpreted : Trm.t -> bool
(** Test if a term is either a variable ({!Trm.Var}) or an uninterpreted
function symbol application ({!Trm.Apply} or {!Trm.Arith} when
[{!Trm.Arith.classify} a = Uninterpreted]). That is, is not an
interpreted function symbol application (including constants and nullary
applications). *)
val is_interpreted : Trm.t -> bool
val is_uninterpreted : Trm.t -> bool
val prefer : Trm.t -> Trm.t -> int

Loading…
Cancel
Save