Section ENUMERATION.
Context {L : language}.
Let rank : Set := nat.
Fixpoint trm_depth (t : trm L) : rank :=
match t with
| Var_trm x => 0
| Fun_trm f ts => 1 + trms_depth ts
| Con_trm c => 1
end
with trms_depth {n : nat} (ts : trms L n) : rank :=
match ts with
| O_trms => 0
| S_trms n t ts => 1 + max (trm_depth t) (trms_depth ts)
end.

Lemma trm_depth_unfold (t : trm L) :
trm_depth t =
match t with
| Var_trm x => 0
| Fun_trm f ts => 1 + trms_depth ts
| Con_trm c => 1
end.