(***********************************************************************)
(** * Connecting "freshening" *)
(***********************************************************************)
(** The abstract machine uses the nominal [swap] operation to make sure that the variables in abstractions are "fresh".  To be able prove that this machine implements the step relation for LN terms, we need to connect this operation to a LN version of "freshening".  The [swap_spec] lemma below states that connection. If a variable [y] is "fresh", then substituting with it (in the LN representation) is the same as swapping with it (in the nominal representation).  << Lemma swap_spec : forall  n w y, y `notin` fv_exp (nom_to_exp n) -> w <> y -> [w ~> var_f y] (nom_to_exp n) = nom_to_exp (swap w y n). >>  *)
(** *** Exercise [close_exp_wrt_exp_freshen] *)

(** The [swap_spec] proof depends on the following auxiliary lemma about the close operation --- that we can equivalently rename the atom that we are closing with. *)
(* LATER *)
(* SCW: Make LNgen generate this? *)
(* /LATER *)
Lemma close_exp_wrt_exp_freshen : forall x y e,
y `notin` fv_exp e ->
close_exp_wrt_exp x e =
close_exp_wrt_exp y ([x ~> var_f y] e).