Skip to content
Snippets Groups Projects
Commit c039726b authored by Loïc Correnson's avatar Loïc Correnson Committed by Patrick Baudin
Browse files

[qed] introduction of e_open and e_close

parent 015e5c4f
No related branches found
No related tags found
No related merge requests found
...@@ -306,11 +306,12 @@ sig ...@@ -306,11 +306,12 @@ sig
(** Bind the given variable if it appears free in the term, (** Bind the given variable if it appears free in the term,
or return the term unchanged. *) or return the term unchanged. *)
val e_open : var -> term -> term val e_open : ?pool:pool -> ?forall:bool -> ?exists:bool -> ?lambda:bool ->
(** Open the top-most binder with the given variable, or term -> (binder * var) list * term
return the term unchanged. (** Open all the specified binders *)
@raise Invalid_argument if the variable is not free and
has not the right type. *) val e_close : (binder * var) list -> term -> term
(** Closes all specified binders *)
(** {3 Local Caches} *) (** {3 Local Caches} *)
......
...@@ -2285,15 +2285,6 @@ struct ...@@ -2285,15 +2285,6 @@ struct
| _ -> is_eq e | _ -> is_eq e
in ignore(exists_case a); !res in ignore(exists_case a); !res
let e_open x (e : term) =
assert (lc_closed e) ;
match e.repr with
| Bind(_,t,a) ->
if not (Tau.equal t (tau_of_var x) || Vars.mem x e.vars)
then lc_open x a
else raise (Invalid_argument "Qed.e_open")
| _ -> e
let e_bind q x (e : term) = let e_bind q x (e : term) =
assert (lc_closed e) ; assert (lc_closed e) ;
let do_bind = let do_bind =
...@@ -2311,6 +2302,26 @@ struct ...@@ -2311,6 +2302,26 @@ struct
let e_exists = bind_xs Exists let e_exists = bind_xs Exists
let e_lambda = bind_xs Lambda let e_lambda = bind_xs Lambda
let e_open ?pool ?(forall=true) ?(exists=true) ?(lambda=true) a =
match a.repr with
| Bind _ ->
let pool = match pool with Some p -> p | None ->
let p = POOL.create () in
Vars.iter (POOL.add p) a.vars ; p in
let filter = function
| Forall -> forall
| Exists -> exists
| Lambda -> lambda in
let rec walk qs a = match a.repr with
| Bind(q,t,b) when filter q ->
let x = fresh pool t in
walk ((q,x)::qs) (lc_open x b)
| _ -> qs , a
in walk [] a
| _ -> [],a
let e_close qs a = List.fold_left (fun b (q,x) -> e_bind q x b) a qs
(* -------------------------------------------------------------------------- *) (* -------------------------------------------------------------------------- *)
(* --- Iterators --- *) (* --- Iterators --- *)
(* -------------------------------------------------------------------------- *) (* -------------------------------------------------------------------------- *)
......
...@@ -293,6 +293,14 @@ sig ...@@ -293,6 +293,14 @@ sig
val e_fun : Fun.t -> term list -> term val e_fun : Fun.t -> term list -> term
val e_bind : binder -> var -> term -> term val e_bind : binder -> var -> term -> term
val e_open : pool:pool -> ?forall:bool -> ?exists:bool -> ?lambda:bool ->
term -> (binder * var) list * term
(** Open all the specified binders
The pool must contain all free variables of the term. *)
val e_close : (binder * var) list -> term -> term
(** Closes all specified binders *)
(** {3 Predicates} *) (** {3 Predicates} *)
type pred type pred
...@@ -398,7 +406,7 @@ sig ...@@ -398,7 +406,7 @@ sig
(** {3 Binders} *) (** {3 Binders} *)
val lc_closed : term -> bool val lc_closed : term -> bool
val lc_iter : (term -> unit) -> term -> unit val lc_iter : (term -> unit) -> term -> unit (* TODO: to remove *)
(** {3 Utilities} *) (** {3 Utilities} *)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment