Fixpoint Zlength_aux (acc:Z) (A:Type) (l:list A) : Z :=
  match l with
    | nil => acc
    | _ :: l => Zlength_aux (Z.succ acc) A l
  end.Definition Zlength := Zlength_aux 0.Implicit Type l : list A.

(* Specifications: *)
Lemma Zlength_correct l : Zlength l = Z.of_nat (length l).
Lemma Zlength_nil : Zlength (A:=A) nil = 0.
Lemma Zlength_cons (x:A) l : Zlength (x :: l) = Z.succ (Zlength l).
Lemma Zlength_nil_inv l : Zlength l = 0 -> l = nil.