(* Use of this source code is governed by the license described	* * in the LICENSE file at the root of the source tree.		*)
(* Some initial work on sigma protocols.  The goal is to prove that any sigma protocol is a proof of knowledge.  There is some interesting theory in here (e.g. the "emergency break" theorem), but it is far form complete.   *)
Set Implicit Arguments.
intuition.
destruct ls.
unfold sumList.
simpl.
rewrite ratAdd_0_r.
eapply ratAdd_eqRat_compat.
specialize (H0 false).
simpl in H0.
intuition.
specialize (H0 true).
simpl in H0.
intuition.
inversion H; clear H; subst.
destruct b;
rewrite sumList_cons.
rewrite ratAdd_comm.
eapply ratAdd_eqRat_compat; intuition.
destruct ls.
unfold sumList. simpl.
specialize (H0 false); intuition.
simpl in H3, H; intuition.
discriminate.
inversion H4; clear H4; subst.
destruct b.
simpl in H3.
intuition.
rewrite sumList_cons.
destruct ls.
unfold sumList; simpl.
rewrite <- ratAdd_0_r.
intuition.
destruct b; simpl in *; intuition.
eapply ratAdd_eqRat_compat.
intuition.
destruct ls.
unfold sumList.
simpl.
specialize (H0 true).
simpl in *.
intuition.
discriminate.
inversion H4; clear H4; subst.
destruct b.
rewrite sumList_cons.
destruct ls.
unfold sumList. simpl.
rewrite <- ratAdd_0_r.
intuition.
destruct b; simpl in *; intuition.
simpl in *; intuition.
Qed.
intuition.
destruct (in_dec (comp_eq_dec c) a (getSupport c)); intuition.
right.
eapply getSupport_not_In_evalDist; intuition.
Qed.

Lemma commandTwice : forall (c1 c2 : Comp bool),
Pr [
b1 <-$ c1;
b2 <-$ c2;
ret (b1 && b2)] == (Pr [c1] * Pr[c2])%rat.