intros.
pose proof (coarbComplete' (coarbitrary max) (funToPosFun f)) as Hyp.
inversion Hyp as [seed HSeed]; clear Hyp.
exists seed.
intros a HLe.
pose proof (HSeed (coarbitrary a)) as HCo; clear HSeed.
apply coarbLePreservesLe in HLe.
apply HCo in HLe; clear HCo.
rewrite HLe; clear HLe.
unfold funToPosFun.
rewrite coarbCorrect.
reflexivity.
Qed.
Instance genFun {A B : Type} `{_ : CoArbitrary A} `{_ : Gen B} : Gen (A -> B) :=
{|
arbitrary :=
reallyUnsafePromote (fun a => variant (posToPath (coarbitrary a)) arbitrary);
|}.
Instance shrinkFunNil {A B : Type} : Shrink (A -> B) :=
{| shrink x := nil |}.
Section arbFun_completeness.
Variables A B : Type.
Hypothesis choice : FunctionalChoice_on A RandomSeed.

(* Specifications: *)
(* begin arbFunCorrect *)
Theorem arbFunComplete `{CoArbitrary A, Arbitrary B} (max:A) (f:A-> B) (s:nat) :
s = Pos.to_nat (coarbitrary max) -> (semGenSize arbitrary s <--> setT) ->
exists seed, forall a, coarbLe a max -> run arbitrary s seed a = f a.