Documentation

CatCryptCore.NonUniform

Non-uniform sampling #

SPComp.sample samples uniformly from a finite nonempty type, which is the only sampling combinator in Core.Code. This tree adds sampleFrom d for an arbitrary SDistr d, together with the pRHL and pHL rules for reasoning about it.

Layout #

The pHL rule transports from the approximants to the limit because pHoare constrains the support, and an outcome of the limit is an outcome of some approximant. rHoare asserts that a coupling exists, so it does not transport that way: couplings obtained for each budget separately need not be comparable, and only a non-decreasing family has a limit that couples the two loops. The family is therefore constructed rather than obtained, by recursion on the budget from one chosen coupling of the two bodies.

sampleFrom (SDistr.uniform α) = SPComp.sample α holds by rfl, and the derived-instance examples in CouplingRules and UnaryRules state the uniform rules verbatim, so the uniform API is untouched.

The one-sided rules rHoare_sampleFrom_l/r carry a SDistr.mass d = 1 hypothesis that the uniform versions rHoare_sample_l/r do not need, because SDistr.mass (SDistr.uniform α) = 1 is automatic. The uniform rules are therefore corollaries, not instances of a strictly weaker statement.