(* [replicate n a] is a list of [n] elements, all of which are equal to [a]. *)
Fixpoint replicate (A : Type) (n : nat) (a : A) : list A :=
match n with
| 0 =>
@nil _
| S n =>
cons a (replicate n a)
end.
(* The list [replicate n a] has length [n]. *)

(* Specifications: *)
Lemma length_replicate:
forall (A : Type) n (a : A),
length (replicate n a) = n.