Section SUBST. (* Reference: "https://github.com/princeton-vl/CoqGym/blob/master/coq_projects/goedel/subAll.v" *)
Fixpoint close_from (a : nat) (n : nat) (p : frm L) {struct n} : frm L :=
match n with
| O => p
| S m => All_frm (a + m) (close_from a m p)
end.
#[global]
Add Parametric Morphism
: close_from with signature (eq ==> eq ==> alpha_equiv ==> alpha_equiv)
as close_from_compat_with_alpha.
#[local] Opaque le_lt_dec.
Fixpoint multiple_subst (m : nat) (n : nat) (p : frm L) : frm L :=
match n with
| O => p
| S n' => subst1 n' (Var_trm (m + n')) (multiple_subst m n' p)
end.

Lemma lift_close_from (n : nat) (p : frm L) (m : nat)
(LE : n <= m)
(BOUND : forall z : ivar, is_free_in_frm z p = true -> z < m)
: E.empty \proves Imp_frm (close_from 0 n p) (close_from m n (subst_frm (fun x : ivar => if le_lt_dec n x then Var_trm x else Var_trm (m + x)) p)).