Evaluation Distributions of Computations with Bind #
File for lemmas about evalSPMF and support involving the monadic pure and bind.
Probabilities of pure #
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 #
probOutput_bind_eq_tsum with the sum packaged as an expectedValue, the head gcongr
descends through.
probEvent_bind_eq_tsum with the sum packaged as an expectedValue.
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.
If a continuation event is bounded by ε exactly on a prefix event and is
impossible off that event, then only the prefix mass is charged.
Division-form corollary of probEvent_bind_le_probEvent_mul.
Partition an event pointwise into a main event and an exceptional event.
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]) * ε.
The compatibility adapter satisfies the Giry pure/bind laws for every lawful SPMF
lift, so the 𝒟-level laws (evalDist_pure, evalDist_bind, evalDist_map, …) hold with no
measure specification in scope.
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 #
Pointwise division bounds on bind continuations factor through the bind.
Event form of probOutput_bind_mono_div_const.
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.
Prefix-event split for a bind. Prefix points satisfying p are charged in
full; off-prefix continuations are charged by the uniform tail bound ε.
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
evalSPMF_bind_bind_swap.
Swapping two independent random draws preserves the probability of any fixed output. Corollary
of evalSPMF_bind_bind_swap.
Complement bounds #
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.
A finite sum inside an expectation may be taken outside: linearity of expectation over a
Finset of summands.
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.