Admitted. (* QuickChick rev_involutive. *)
Inductive prod (X Y : Type) : Type :=
| pair : X -> Y -> prod X Y.
Arguments pair {X} {Y} _ _.
Notation "( x , y )" := (pair x y).
Notation "X * Y" := (prod X Y) : type_scope.
Instance dec_prod' {A} {B} (p q : prod A B)
(DA : forall (x y : A), Dec (x = y))
(DB : forall (x y : B), Dec (x = y)) : Dec (p = q).
Definition option_map {X Y : Type} (f : X -> Y) (xo : option X)
: option Y :=
match xo with
| None => None
| Some x => Some (f x)
end.
Fixpoint fold {X Y:Type} (f: X->Y->Y) (l:list X) (b:Y)
: Y :=
match l with
| nil => b
| h :: t => f h (fold f t b)
end.
Definition constfun {X: Type} (x: X) : nat->X :=
fun (k:nat) => x.
(** **** Exercise: 2 stars (fold_length)  *)
(** Many common functions on lists can be implemented in terms of [fold].  For example, here is an alternative definition of [length]: *)
Definition fold_length {X : Type} (l : list X) : nat :=
fold (fun _ n => S n) l 0.

Theorem fold_length_correct : forall X (l : list X),
fold_length l = length l.