Sub-distributions #
This file defines sub-distributions as probability mass functions over Option α.
A sub-distribution can have total mass less than 1, representing computations
that may fail (return none).
Main definitions #
SDistr α- Sub-distribution over typeα, defined asPMF (Option α)SDistr.pure- Point mass distributionSDistr.fail- Failed computation (mass 0 on allsomevalues)SDistr.bind- Monadic bind for sub-distributionsSDistr.uniform- Uniform distribution over a finite type
References #
- SSProve: https://github.com/SSProve/ssprove
- EasyCrypt sub-distributions
Sub-distribution: a distribution that may have total mass < 1.
Represented as a PMF over Option α, where none represents failure.
Equations
- CatCrypt.Prob.SDistr α = PMF (Option α)
Instances For
Basic constructors #
Point mass distribution at a
Equations
Instances For
Failed computation: all mass on none
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Uniform distribution #
Uniform distribution over a finite nonempty type
Equations
Instances For
Measures and mass #
Basic lemmas #
Support lemmas #
Lawful Monad Instance #
SDistr is a lawful monad. The laws follow from pure_bind, bind_pure, bind_assoc.
Support-based congruence (eq_in_dlet in Rocq) #
If functions agree on the support of a distribution, their binds are equal.
This is the Lean equivalent of eq_in_dlet from mathcomp-experimental-reals:
If f and g agree on {a | d (some a) ≠ 0}, then d.bind f = d.bind g.
This is a key lemma for coupling composition proofs.
Uniform distribution lemmas #
Compositional version of uniform_bind_bij: applying a bijection inside
a uniform bind doesn't change the distribution.
(uniform α).bind (fun a => g (σ a)) = (uniform β).bind g for any bijection σ : α ≃ β.
Binding uniform distribution with a constant function gives the constant. This is because averaging a constant gives the constant.
Mathematical Proof:
- LHS = ∑_a (1/|α|) * d = |α| * (1/|α|) * d = d
- The uniform distribution has |α| elements each with probability 1/|α|
- Summing |α| copies of d weighted by 1/|α| gives d
This is a fundamental property needed for the averaging coupling argument in pRHL sampling rules.
Nested uniform sampling equals product uniform sampling #
Nested uniform sampling equals product uniform sampling.
For finite types A and B, sampling a : A and b : B independently and uniformly, then pairing them, gives the uniform distribution over A × B.
Mathematical Proof:
- LHS: Pr[(a₀, b₀)] = Pr[a = a₀] × Pr[b = b₀] = (1/|A|) × (1/|B|) = 1/(|A| × |B|)
- RHS: Pr[(a₀, b₀)] = 1/|A × B| = 1/(|A| × |B|)
These are equal, so the distributions are equal.
This is a key lemma for cryptographic proofs involving uniform sampling over product types.