Section code_nat_list.
Fixpoint codeList (l : list nat) : nat :=
match l with
| nil => 0
| n :: l' => S (cPair n (codeList l'))
end.
Definition codeNth (n m : nat) : nat.
intros.
assert nat.
induction n as [| n Hrecn].
exact m.
exact (cPairPi2 (pred Hrecn)).
exact (cPairPi1 (pred H)).
Defined.
Let drop (n : nat) : forall (l : list nat), list nat.
induction n as [| n Hrecn].
exact (fun l => l).
intros.
apply Hrecn.
destruct l.
exact (nil (A:=nat)).
exact l.
Defined.

Lemma codeNthCorrect :
forall (n : nat) (l : list nat), codeNth n (codeList l) = nth n l 0.