(** ** Challenge Exercise [subst]  Use the definitions above to prove the following results about the nominal substitution function.  *)

(* Specifications: *)
Lemma subst_eq_var : forall u x,
subst u x (n_var x) = u.
Lemma subst_neq_var : forall u x y,
x <> y ->
subst u x (n_var y) = n_var y.
Lemma subst_app : forall u x t1 t2,
subst u x (n_app t1 t2) = n_app (subst u x t1) (subst u x t2).
Lemma subst_abs : forall u x y t1,
subst u x (n_abs y t1) =
if (x == y) then (n_abs y t1)
else let (z,_) := atom_fresh (fv_nom u \u fv_nom (n_abs y t1)) in
n_abs z (subst u x (swap y z t1)).