(* Copyright 2012-2015 by Adam Petcher.				* * Use of this source code is governed by the license described	* * in the LICENSE file at the root of the source tree.		*)
(* Rules used to prove facts based on the distribution semantics *)
Set Implicit Arguments.
Local Open Scope rat_scope.
Local Open Scope comp_scope.
Local Open Scope list_scope.
intuition.
unfold evalDist.
eapply eqRat_refl.
Qed.
intros.
specialize (getSupport_correct c1).
specialize (getSupport_correct c2).
intros.
inversion H0; clear H0.
inversion H1; clear H1.
intuition.
apply H3.
intuition.
eapply H4; eauto.
eapply eqRat_trans.
eapply H.
eauto.
eapply H4.
intuition.
eapply H3; eauto.
eapply eqRat_trans.
eapply eqRat_symm.
eapply H.
eauto.
Qed.
intuition.
eapply NoDup_Permutation; intuition.
apply in_map_iff in H3.
destruct H3.
intuition.
subst.
eapply H0.
trivial.
eapply in_map_iff.
econstructor.
split.
2:{
eapply H0.
assert (x = f (f_inv x)).
symmetry.
eapply H.
trivial.
rewrite H4 in H3.
eapply H3.
}
eapply H.
trivial.
Qed.
induction ls; intuition.
simpl in *.
intuition.
eapply H1.
rewrite <- (H a).
rewrite <- (H a0).
f_equal.
trivial.
eapply IHls; eauto.
Qed.
induction ls; intuition; simpl in *.
econstructor.
inversion H0; clear H0; subst.
econstructor; eauto.
intuition.
apply in_map_iff in H0.
destruct H0.
intuition.
assert (x = a).
rewrite <- (H x); intuition.
rewrite <- (H a); intuition.
f_equal.
trivial.
subst.
intuition.
Qed.
intuition.
specialize (getSupport_correct c); intuition.
inversion H.
eauto.
Qed.
induction ls; simpl in *; intuition.
inversion H; clear H; subst.
destruct (P a).
econstructor; eauto.
intuition.
eapply filter_In in H.
intuition.
eapply IHls; eauto.
Qed.
intuition.
eapply NoDup_Permutation.
eapply map_NoDup.
intuition.
eapply getSupport_NoDup.
eapply getSupport_NoDup.
intuition.
apply in_map_iff in H3.
destruct H3.
intuition.
subst.
eapply getSupport_In_evalDist.
intuition.
eapply getSupport_In_evalDist.
eauto.
eapply eqRat_trans.
eapply H1.
trivial.
trivial.
eapply in_map_iff.
econstructor.
split.
eapply H.
trivial.
eapply getSupport_In_evalDist.
intuition.
eapply getSupport_In_evalDist.
eapply H3.
rewrite H2.
trivial.
trivial.
Qed.
intuition.
eapply NoDup_Permutation.
eapply filter_NoDup.
eapply support_NoDup.
eapply filter_NoDup.
eapply support_NoDup.
intuition.
eapply filter_In in H0.
eapply filter_In.
intuition.
eapply getSupport_In_evalDist.
apply getSupport_In_evalDist in H1.
intuition.
apply H1.
eapply eqRat_trans.
eapply H.
trivial.
trivial.
intuition.
eapply filter_In in H0.
eapply filter_In.
intuition.
eapply getSupport_In_evalDist.
apply getSupport_In_evalDist in H1.
intuition.
apply H1.
eapply eqRat_trans.
eapply eqRat_symm.
eapply H.
trivial.
trivial.
Qed.

Lemma evalDist_getSupport_perm_id : forall (A : Set)(c1 c2 : Comp A),
(forall a, eqRat (evalDist c1 a) (evalDist c2 a)) ->
Permutation (getSupport c1) (getSupport c2).