coq: add expr_fv_type

This commit is contained in:
Michael Sippel 2024-09-24 12:08:00 +02:00
parent d050baf88d
commit d31101103f
Signed by: senvas
GPG key ID: F96CF119C34B64A6

View file

@ -187,6 +187,21 @@ Fixpoint expr_fv (e : expr_DeBruijn) {struct e} : atoms :=
| ex_descend τ t' => (expr_fv t') | ex_descend τ t' => (expr_fv t')
end. end.
(* get the list of all free type variables in an expression *)
Fixpoint expr_fv_type (e : expr_DeBruijn) {struct e} : atoms :=
match e with
| ex_fvar n => {}
| ex_bvar y => {}
| ex_ty_abs t' => {}
| ex_ty_app t' σ => (expr_fv_type t') `union` (type_fv σ)
| ex_morph σ t' => (type_fv σ) `union` (expr_fv_type t')
| ex_abs σ t' => (type_fv σ) `union` (expr_fv_type t')
| ex_app t1 t2 => (expr_fv_type t1) `union` (expr_fv_type t2)
| ex_let t1 t2 => (expr_fv_type t1) `union` (expr_fv_type t2)
| ex_ascend τ t' => (expr_fv_type t')
| ex_descend τ t' => (expr_fv_type t')
end.
(* substitute free variable x with expression s in t *) (* substitute free variable x with expression s in t *)
Fixpoint expr_subst (x:atom) (s:expr_DeBruijn) (t:expr_DeBruijn) {struct t} : expr_DeBruijn := Fixpoint expr_subst (x:atom) (s:expr_DeBruijn) (t:expr_DeBruijn) {struct t} : expr_DeBruijn :=
match t with match t with