(* /ADMITTED *)


(*************************************************************)
(** * Size based reasoning                                   *)
(*************************************************************)


(** Some properties about nominal terms require calling the
    induction hypothesis not on a direct subterm, but on one
    that has first had a swapping applied to it.

    However, swapping names does not change the size of terms,
    so that means we can prove such properties by induction on
    that size.  *)

Fixpoint size (t : n_exp) : nat :=
  match t with
  | n_var x => 1
  | n_abs x t => 1 + size t
  | n_app t1 t2 => 1 + size t1 + size t2
  end.

(* Specifications: *)
Lemma swap_size_eq : forall x y t, size (swap x y t) = size t.
Lemma nominal_induction_size : forall n, forall t, size t <= n -> forall P : n_exp -> Type, (forall x, P (n_var x)) -> (forall x t, (forall y, P (swap x y t)) -> P (n_abs x t)) -> (forall t1 t2, P t1 -> P t2 -> P (n_app t1 t2)) -> P t.