Fixpoint firstIndexOf(A : Set)(eqd : eq_dec A)(ls : list A)(a : A)(def : nat) :=
  match ls with
      | nil => def
      | a' :: ls' =>
        if (eqd a a') then O else (S (firstIndexOf eqd ls' a def))
  end.

Theorem rndListElem_uniform_gen : forall (A B : Set)(eqda : EqDec A)(eqdb : EqDec B)(ls1 : list A)(ls2 : list B)(a1 : A)(a2 : B), NoDup ls1 -> NoDup ls2 -> length ls1 = length ls2 -> In a1 ls1 -> In a2 ls2 -> comp_spec (fun x y => x = Some a1 <-> y = Some a2) (rndListElem _ ls1) (rndListElem _ ls2).