Restricting, rescaling and conditioning a sub-distribution #
SDistr α is a probability mass function on Option α, so the mass a
restriction removes has a place to go: none, the failure outcome. restrict d P
sends the mass outside P there, scale d divides the surviving mass by the
total mass, and condition d P is their composite — the distribution of a sample
from d given that the sample satisfies P.
Main definitions #
restrict d P—dwith the mass outsidePsent to failurescale d—drescaled to mass one, andSDistr.failwhendhas mass zerocondition d P—scale (restrict d P)excepted d X—condition d (fun a => !X a)
Main results #
restrict_apply_some,mass_restrict— the weight of the restrictionscale_apply_some,mass_scale— the weight of the rescalingcondition_apply_some— the pointwise weight of the conditional distributionmem_support_condition_iff— the support of the conditional distributioncondition_eq_pure— conditioning on a predicate met by a single point of positive weight is a point mass at that point
Correspondence with EasyCrypt #
The four definitions are the images of drestrict, dscale, dcond and (\)
of EasyCrypt's Distr and Dexcepted theories, whose definitions are
dcond d p = dscale (drestrict d p) and d \ X = dscale (drestrict d (predC X)).
condition_apply_some is the image of dexcepted1E, mem_support_condition_iff
of supp_dexcepted, and mass_condition_of_ne_zero of dexcepted_ll.
The mass of a sub-distribution as a sum #
The mass of a sub-distribution is the total weight it puts on some.
The mass of a sub-distribution is at most one.
A sub-distribution of mass zero puts no weight on any value.
Restriction #
The sub-distribution d with the weight outside the predicate P sent to
failure.
Equations
- CatCrypt.NonUniform.restrict d P = d.bind fun (a : α) => if P a = true then CatCrypt.Prob.SDistr.pure a else CatCrypt.Prob.SDistr.fail
Instances For
Rescaling #
d rescaled to mass one. A sub-distribution of mass zero rescales to
SDistr.fail, which is what EasyCrypt's dscale returns for the null
distribution.
Equations
Instances For
Rescaling divides every weight by the mass.
A rescaled sub-distribution of nonzero mass never fails.
Rescaling a sub-distribution of nonzero mass gives mass one.
Conditioning #
The distribution of a sample from d given that it satisfies P.
Equations
Instances For
The distribution of a sample from d given that it avoids X.
Equations
- CatCrypt.NonUniform.excepted d X = CatCrypt.NonUniform.condition d fun (a : α) => !X a
Instances For
Conditioning on the complement of X is avoiding X.
The weight the conditional distribution puts on a value: its weight under
d when it satisfies the predicate, divided by the total weight of the values
that do.
Sampling from a conditional distribution #
Sampling from a conditional distribution whose predicate admits a single value of positive weight returns that value.