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.
induction ls; destruct n; intuition; simpl in *.
omega.
omega.
inversion H0.
eapply IHls; eauto.
omega.
Qed.
induction sigma; intuition; simpl in *.
case_eq (nth_error ls a); intuition.
simpl.
f_equal.
eapply IHsigma; intuition.
exfalso.
eapply nth_error_not_None.
eapply H.
intuition.
trivial.
Qed.
intuition.
unfold shuffle in *.
repeat simp_in_support.
destruct x.
eapply rndListElem_support in H0.
eapply getAllPermutations_perms.
trivial.
eapply rndListElem_support_None in H0.
exfalso.
eapply getAllPermutations_not_nil.
eauto.
Qed.
intuition.
unfold shuffle.
wftac.
eapply rndListElem_wf.
Qed.
End ShuffleList.
Definition RndPerm(n : nat) :=
shuffle _ (allNatsLt n).
intuition.
eapply list_pred_impl.
eapply list_pred_map_both.
eauto.
intuition.
destruct H0.
destruct H0.
intuition; subst.
trivial.
Qed.

Theorem addInAllLocations_pred :
forall (A B : Set) (R : A -> B -> Prop) (a : list A) (b : list B),
list_pred R a b ->
forall a1 a2,
R a1 a2 ->
list_pred (list_pred R) (addInAllLocations a1 a) (addInAllLocations a2 b).