Definition App : term := .\"s","t"; .\"v","a","l"; "a" "s" "t".
Definition Lam : term := .\"s";     .\"v","a","l"; "l" "s".

(* Specifications: *)
Lemma Var_correct n : Var (enc n) ≡ tenc (n).
Lemma App_correct s t : App (tenc s) (tenc t) ≡ tenc (s t).
Lemma Lam_correct s : Lam (tenc s) ≡ tenc (lambda s).
Definition N := rho ( .\"N", "n"; "n"
!(tenc Zero)
(.\"n"; !Lam (!Lam (!App !(tenc 0) ("N" "n"))))).
Lemma N_correct n : N (enc n) ≡ tenc(enc n).
Definition Q := Eval cbn in rho ( .\"Q", "s"; "s"
(.\"n";     !Lam (!Lam (!Lam (!App !(tenc 2) (!N "n")))))
(.\"s","t"; !Lam (!Lam (!Lam (!App (!App !(tenc 1) ("Q" "s")) ("Q" "t")))))
(.\"s";     !Lam (!Lam (!Lam (!App !(tenc 0) ("Q" "s"))))) ).
Lemma Q_correct s : Q (tenc s) ≡ tenc(tenc s).
Definition benc (b:bool) : term := if b then T else F.