Efficient memoized sampling #
An association-list cache preserves the efficiency of a closed probabilistic sampler. The certificate charges for comparing complete key encodings, looking up an answer and writing the returned cache. Queries, samplers and initial caches may capture the input.
The proof uses a sample as a fallback for optional lookup, so neither keys nor values need an
inhabitant chosen in advance. Its realizing machine may run and discard the sampler on a hit;
the source program still has exactly the joint result/cache law of memoize.
Main results #
Cslib.Probability.IsPPTOn.memoize: certify a memoized sampler throughfun_prop.Cslib.Probability.memoize_cache_growth_le: bound new storage independently of existing entries.Cslib.Probability.memoize_call_size_le: preserve reply sizes and bound local storage growth.Cslib.Probability.memoize_cache_size_le: bound the encoded cache using external query budgets.
References #
Adapted from Computability/Probabilistic/Memoize.lean on the cslib crypto branch at
5ff69ca93402e7c947208dc56396d6d86203ccd8, reusing the tidy calculus and captured-input rules.
Cache a certified sampler's results using an ordinary list. Runtime query data, captured inputs and the complete returned cache are included in the certificate. No default key or value is required, and repeated keys use their first cached occurrence.
A cached call adds at most one encoded entry, charging the complete key and value and both layers of framing. Existing entries need no size invariant: a cache hit preserves the cache.
A cached call preserves a reply-size invariant and adds at most one encoded entry. The bound charges the complete key and value, including both layers of framing.
Bounds on external calls, encoded keys and replies bound the complete cache of a randomized client. Preassigned entries are included, as are both pair and list framing costs.