(** Apply a function n times *)
Fixpoint appn {A} (f : A -> A) (n : nat) : A ->  A :=
  fun x =>
    match n with
      | 0%nat => x
      | S n' => f (appn f n' x)
    end.Infix "^" := appn (at level 30, right associativity) : fun_scope.(** Instance Hierarchy  

   GenSized 
      |
      |
     Gen   Shrink
       \    /
        \  /
      Arbitrary
*)

(** * Generator-related classes *)

(* begin gen_sized_class *)
  Class GenSized (A : Type) := { arbitrarySized : nat -> G A }.(** Instance Hierarchy  

   GenSized 
      |
      |
     Gen   Shrink
       \    /
        \  /
      Arbitrary
*)

(** * Generator-related classes *)

(* begin gen_sized_class *)
  Class GenSized (A : Type) := { arbitrarySized : nat -> G A }.(* end gen_sized_class *)

(* begin gen_class *)
  Class Gen (A : Type) := { arbitrary : G A }.(* end gen_sized_class *)

(* begin gen_class *)
  Class Gen (A : Type) := { arbitrary : G A }.(* end gen_class *)

(** Shrink class *)
Class Shrink (A : Type) :=
  { shrink : A -> list A }.(* end gen_class *)

(** Shrink class *)
Class Shrink (A : Type) :=
  { shrink : A -> list A }.(** Arbitrary Class *)
Class Arbitrary (A : Type) `{Gen A} `{Shrink A}.(** * Sizes of types *)
  
Class Sized (A : Type) :=
  { size : A -> nat }.(** * Sizes of types *)
  
Class Sized (A : Type) :=
  { size : A -> nat }.

(* Specifications: *)
Lemma size_ind (A : Type) `{Hyp : Sized A} : forall (P : A -> Prop), (forall y, (forall x, size x < size y -> P x) -> P y) -> (forall x, P x).