Library Lambda.Russell.Substitution
Require Import Lambda.Terms.
Require Import Lambda.Reduction.
Require Import Lambda.LiftSubst.
Require Import Lambda.Env.
Require Import Lambda.Russell.Types.
Require Import Lambda.Russell.Thinning.
Implicit Types i k m n p : nat.
Implicit Type s : sort.
Implicit Types A B M N T t u v : term.
Implicit Types e f g : env.
Lemma double_sub_weak : ∀ g (d : term) t, g |-- d : t →
(∀ e u (U : term), e |-- u : U →
∀ f n, sub_in_env d t n e f → wf f → trunc _ n f g →
f |-- (subst_rec d u n) : (subst_rec d U n)) ∧
(∀ e T U s, e |-- T >> U : s→
∀ f n, sub_in_env d t n e f → wf f → trunc _ n f g →
f |-- (subst_rec d T n) >> (subst_rec d U n) : s).
Theorem substitution : ∀ e t u U, (t :: e) |-- u : U →
∀ d, e |-- d : t → e |-- (subst d u) : (subst d U).
Theorem substitution_coerce : ∀ e t T (U : term) s,
(t :: e) |-- T >> U : s →
∀ d, e |-- d : t → e |-- (subst d T) >> (subst d U) : s.
Hint Resolve substitution substitution_coerce : coc.
Theorem substitution_coerce_conv_l : ∀ e t T s,
(t :: e) |-- T : Srt s →
∀ d u, e |-- d : t → e |-- u : t → conv d u →
e |-- (subst d T) >> (subst u T) : s.
Theorem substitution_coerce_conv_l_n : ∀ e t T s,
(t :: e) |-- T : Srt s →
∀ d u, e |-- d : t → e |-- u : t → conv d u →
∀ n, e |-- (subst d T) >> (subst u T) : s.