Section ShuffleList.
Variable A : Set.
Hypothesis A_EqDec : EqDec A.
Definition shuffle(ls : list A) :=
o <-$ rndListElem _ (getAllPermutations ls);
ret
match o with
| None => nil
| Some x => x
end.
intuition.
unfold shuffle in *.
repeat simp_in_support.
destruct x.
eapply Permutation_sym.
eapply getAllPermutations_perms.
apply rndListElem_support in H0.
trivial.
apply rndListElem_support_None in H0.
exfalso.
eapply getAllPermutations_not_nil.
eauto.
Qed.
Fixpoint permute(ls : list A)(sigma : list nat) : list A :=
match sigma with
| nil => nil
| n :: sigma' =>
match (nth_error ls n) with
| None => nil
| Some a => a :: (permute ls sigma')
end
end.

Theorem nth_error_not_None :
forall (ls : list A)(n : nat),
n < length ls ->
nth_error ls n = None ->
False.