Evaluation Distributions of Computations with Bind #
File for lemmas about evalDist and support involving the monadic pure and bind.
Probabilities of pure #
obtain-friendly forward direction of mem_support_pure_iff: membership in the support
of a pure forces equality with the pure value.
Boolean monotonicity of pure outcome probability into a disjunction: if win implies
inner ∨ outer, then the probability of outcome true under pure win is bounded by the sum of
the probabilities under pure inner and pure outer.
Boolean monotonicity of pure outcome probability: if b₁ implies b₂, then the probability
of outcome true under pure b₁ is bounded by that under pure b₂.
Fallback when we don't have decidable equality.
Fallback when we don't have decidable equality.
Probabilities of bind #
obtain-friendly forward direction of mem_support_bind_iff: peel an element of the
support of a bind into a witness for the first computation and membership for the second.
Version of probOutput_bind_eq_tsum that sums only over the subtype given by the support
of the first computation. This can be useful to avoid looking at edge cases that can't actually
happen in practice after the first computation. A common example is if the first computation
does some error handling to avoids returning malformed outputs.
If Pr[q | my x] ≤ ε for every x in the support of mx, then the bound also
holds for the bind.
If the continuation can satisfy q only after a support point satisfying p,
then the probability of q after the bind is at most the probability of p in
the prefix computation.
Prefix-event split for a bind. Prefix points satisfying p are charged in
full; off-prefix continuations are charged by the uniform tail bound ε.
Convex prefix-event split for a bind. The off-prefix tail bound ε is charged
only on the mass outside p, giving Pr[p] + (1 - Pr[p]) * ε.
Write the probability of mx >>= my failing given that my has constant failure chance over
the possible outputs in support mx as a fixed expression without any sums.
Version of probFailure_bind_le_of_forall with that allows a manual Pr[⊥ | mx] value.
Version of probFailure_bind_le_of_forall when mx never fails.
Congruence and monotonicity for bind #
Union bound for bind: if Pr[ ¬p | mx] ≤ ε₁ and Pr[ ¬q | my x] ≤ ε₂ for all x satisfying
p, then Pr[ ¬q | mx >>= my] ≤ ε₁ + ε₂. Useful for sequential composition of error bounds.
probEvent version of probEvent_bind_mono with additive error bound.
Swapping independent draws #
Swapping two independent random draws preserves the output distribution: although
mx >>= fun a => my >>= fun b => f a b and my >>= fun b => mx >>= fun a => f a b need not be
equal as m-computations when m is non-commutative, the two draws are independent, so their
output distributions agree. The probEvent/probOutput forms (probEvent_bind_bind_swap,
probOutput_bind_bind_swap) are corollaries.
Swapping two independent random draws preserves probability of any event. Corollary of
evalDist_bind_bind_swap.
Swapping two independent random draws preserves the probability of any fixed output. Corollary
of evalDist_bind_bind_swap.
Complement bounds #
Alias of probEvent_compl_le_of_one_sub_le.
If 1 - ε ≤ Pr[ p | mx] and mx never fails, then Pr[ ¬p | mx] ≤ ε.
Alias of probEvent_one_sub_le_of_compl_le.
If Pr[ ¬p | mx] ≤ ε and mx never fails, then 1 - ε ≤ Pr[ p | mx].
Union bounds #
Union bound for finset-indexed events: the probability that some event in s holds
is at most the sum of the individual event probabilities.
Expectation algebra for nonnegative functionals #
Tonelli-style rearrangement: the expectation of a nonnegative functional under a
bind is the outer expectation of the inner expectations.
Expectation of a nonnegative functional under a Functor.map: the functional is
precomposed with the map.
The expectation of a nonnegative functional F that is constant (equal to c) on the
support of a never-failing (sub)probability computation equals c.