Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/core/Core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -800,3 +800,20 @@ let trace_diseq : goal = fun st ->
Format.printf "%a\n%!" Disequality.pp (State.constraints st) ;
success st

IFDEF NON_ABSTRACT_GOAL THEN
let reify_in_state st reifier x =
let env = State.env st in
let subst = State.subst st in
reifier (State.env st) (Subst.reify env subst x |> Obj.magic)

let is_ground v st cb =
let ans = Subst.reify (State.env st) (State.subst st) v in
cb (not(Term.is_var ans))

let is_ground_bool
: bool ilogic -> State.t -> onvar:(unit->unit) -> on_ground:(bool -> unit) -> unit =
fun v st ~onvar ~on_ground ->
let ans = Subst.reify (State.env st) (State.subst st) (Obj.magic v) in
if (Term.is_var ans) then onvar()
else on_ground (Obj.magic ans : bool)
END
9 changes: 9 additions & 0 deletions src/core/Core.mli
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,12 @@ end
val reify_in_empty: ('a, 'b) Reifier.t -> 'a -> 'b

val trace_diseq: goal

IFDEF NON_ABSTRACT_GOAL THEN
val reify_in_state: State.t -> ('a, 'b) Reifier.t -> 'a -> 'b

val is_ground : 'a ilogic -> State.t -> (bool -> unit) -> unit

val is_ground_bool : bool ilogic -> State.t -> onvar:(unit->unit) -> on_ground:(bool -> unit) -> unit

END
6 changes: 6 additions & 0 deletions src/core/Term.ml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ let is_box t =
t <= Obj.last_non_constant_constructor_tag &&
t >= Obj.first_non_constant_constructor_tag

let is_var x =
let x = Obj.repr x in
let tx = Obj.tag x in
is_box tx && Var.has_var_structure tx (Obj.size x) x
;;

let is_int = (=) Obj.int_tag
let is_str = (=) Obj.string_tag
let is_dbl = (=) Obj.double_tag
Expand Down
2 changes: 2 additions & 0 deletions src/core/Term.mli
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ val pp : Format.formatter -> t -> unit
(* [var x] if [x] is logic variable returns it, otherwise returns [None] *)
val var : 'a -> Var.t option

val is_var: 'a -> bool

(* [map ~fvar ~fval x] map over OCaml's value extended with logic variables;
* handles primitive types with the help of [fval] and logic variables with the help of [fvar]
*)
Expand Down