(* Requires recursive call of generator *)
(* begin good_foo_rec *)
Inductive goodFooRec : nat -> Foo -> Prop :=
| GoodRecBase : forall n, goodFooRec n Foo1
| GoodRec : forall n foo, goodFooRec 0 foo -> goodFooRec n (Foo2 foo).(* Requires recursive call of generator *)
(* begin good_foo_rec *)
Inductive goodFooRec : nat -> Foo -> Prop :=
| GoodRecBase : forall n, goodFooRec n Foo1
| GoodRec : forall n foo, goodFooRec 0 foo -> goodFooRec n (Foo2 foo).(* Requires recursive call of generator *)
(* begin good_foo_rec *)
Inductive goodFooRec : nat -> Foo -> Prop :=
| GoodRecBase : forall n, goodFooRec n Foo1
| GoodRec : forall n foo, goodFooRec 0 foo -> goodFooRec n (Foo2 foo).(* begin gen_good_rec *)
Definition genGoodRec (n : nat) :=
  let fix aux_arb size n : G (option Foo) := 
    match size with 
    | 0 => backtrack [(1, ret (Some Foo1))]
    | S size' => backtrack [ (1, ret (Some Foo1))
                           ; (1, bindGenOpt (aux_arb size' 0) (fun foo => 
                                 ret (Some (Foo2 foo)))) ]
    end
  in fun sz => aux_arb sz n.

(* Specifications: *)
Lemma genGoodRec_equality n : genGoodRec n = @arbitrarySizeST _ (fun foo => goodFooRec n foo) _.