(* Translation from terms to redexes *)

Fixpoint mark (e : lambda) : redexes :=
  match e with
  | Ref n => Var n
  | Abs M => Fun (mark M)
  | App M N => Ap false (mark M) (mark N)
  end.(* Reverse translation : erasing the marks *)

Fixpoint unmark (e : redexes) : lambda :=
  match e with
  | Var n => Ref n
  | Fun U => Abs (unmark U)
  | Ap b U V => App (unmark U) (unmark V)
  end.

Lemma inverse : forall M : lambda, M = unmark (mark M).