intuition.
simpl in *.
rewrite (sumList_partition evta).
eapply ratAdd_leRat_compat.
assert ( sumList (getSupport c)
(fun a : A => evalDist c a * Pr  [f a ] * (if evta a then 1 else 0)) <=
sumList (getSupport c)
(fun b : A =>
evalDist c b * (if EqDec_dec bool_EqDec (evta b) true then 1 else 0)) ).
eapply sumList_le; intuition.
destruct (EqDec_dec bool_EqDec (evta a) true ).
rewrite e.
eapply ratMult_leRat_compat; intuition.
eapply leRat_trans.
eapply ratMult_leRat_compat.
eapply leRat_refl.
eapply evalDist_le_1.
rewrite ratMult_1_r.
intuition.
destruct (evta a); intuition.
repeat rewrite ratMult_0_r.
eapply rat0_le_all.
rewrite H1.
eapply H.
assert ( sumList (getSupport c)
(fun a : A => evalDist c a * Pr  [f a ] * (if evta a then 0 else 1)) <=
sumList (getSupport c)
(fun a : A => k2 * (evalDist c a * (if evta a then 0 else 1)))).
eapply sumList_le.
intuition.
case_eq (evta a); intuition.
eapply eqRat_impl_leRat.
repeat rewrite ratMult_0_r.
intuition.
rewrite H0.
eapply eqRat_impl_leRat.
repeat rewrite ratMult_1_r.
eapply ratMult_comm.
trivial.
trivial.
rewrite H1.
rewrite sumList_factor_constant_l.
eapply leRat_trans.
2:{
eapply eqRat_impl_leRat.
eapply ratMult_1_r.
}
eapply ratMult_leRat_compat; intuition.
assert (sumList (getSupport c)
(fun a : A => evalDist c a * (if evta a then 0 else 1)) <=
sumList (getSupport c)
(fun a : A => evalDist c a)).
eapply sumList_le.
intuition.
eapply leRat_trans.
2:{
eapply eqRat_impl_leRat.
eapply ratMult_1_r.
}
eapply ratMult_leRat_compat; intuition.
destruct (evta a); intuition.
eapply rat0_le_all.
rewrite H2.
eapply evalDist_sum_le_1.
Qed.

(* Specifications: *)
Theorem oc_eventProb :
forall (A B C : Set)(c : OracleComp A B C) n,
queries_at_most c n ->
forall
(S : Set)(eqds : EqDec S)(o : S -> A -> Comp (B * S))
(count : S -> nat)(evt : S -> bool)(s : S)(k : nat -> Rat) i,
(forall (n1 n2 : nat), (n1 <= n2)%nat -> (k n1 <= k n2)) ->
evt s = false ->
(forall s a, evt s = false -> Pr[p <-$ o s a; ret (evt (snd p))] <= (k (i + (count s))%nat)) ->
(forall s s' a b, In (b, s') (getSupport (o s a)) ->
count s' <= i + (count s))%nat ->
Pr[p <-$ c _ _ o s; ret (evt (snd p))] <= (n / 1) * (k (i * n + (count s))%nat).