Lazy sampling of random functions #
RandomOracle.answer samples a response on the first occurrence of a query and reuses it on
later calls. It supports arbitrary query domains, dependent response types, and a separate
distribution for each query. A cache may also contain answers fixed in advance.
On finite domains and finite response types, run_interpret_answer_complete proves the stronger
form of eager/lazy equivalence: completing the cache after an adaptive program has the same
joint law as completing it before the program. interpret_eq_lazy discards the final table, and
uniform_interpret_eq_lazy specializes to a uniformly random function.
memoize supplies an ordinary association-list implementation. run_interpret_memoize relates its
complete executions to the mathematical cache, including on infinite query domains. Its closed
efficiency certificate is in Computability.Probabilistic.Memoize.
memoize_cache_bounds derives cache cardinality and entry provenance from the program's query
bounds; a computational certificate must also account for the encoded sizes of keys and replies.
Main definitions #
RandomOracle.Cache,.answer,.complete: partial tables, consistent replies and completion.RandomOracle.ofList: represent a list cache by its first occurrence at each key.
Main results #
RandomOracle.run_interpret_answer_complete: eager/lazy equivalence of the result and table.RandomOracle.uniform_interpret_eq_lazy: replace a uniformly sampled function by a lazy oracle.RandomOracle.run_interpret_memoize: association-list implementation with joint state semantics.RandomOracle.memoize_cache_bounds: query bounds control cache growth and entry provenance.
References #
- O. Goldreich, S. Goldwasser, S. Micali, How to Construct Random Functions, Section 3.3, uses consistent lazy sampling in the adaptive hybrid argument.
Adapted from Languages/Probabilistic/RandomOracle.lean on the cslib crypto branch at
5ff69ca93402e7c947208dc56396d6d86203ccd8, using OracleComp.interpret and generic
monad morphisms.
Previously assigned responses, indexed by their typed queries.
Instances For
Return a cached answer, or sample and store one fresh answer.
Instances For
A cache hit does not change the cache or draw fresh randomness.
A previously unseen query draws exactly one response from its designated distribution.
A supported memoized call either returns the first cached value unchanged, or samples and prepends exactly one new entry. Initial cached values need not belong to the sampling support.
A memoized sampler preserves any property of its key-value entries and returns a value with that property at the requested key. Cache keys need not be unique.
Query bounds control the number and provenance of all new cache entries. The sampler's own support bound can then bound stored replies, without assuming that each call grows by a constant.
Interpret a finite association list as a partial function. The first occurrence of a key determines its value, so arbitrary initial lists are supported without a uniqueness invariant.
Instances For
Prepending a cache entry updates exactly its key in the represented partial function.
The ordinary list-based memoizer implements the mathematical random oracle, preserving the result and represented final cache for every adaptive program, even on an infinite query domain.
Independently fill all missing entries while retaining the previously assigned answers.
Instances For
A completion agrees with every answer already in the cache.
Fixing one cache entry fixes the corresponding coordinate of its completion.
Answering one query and completing the cache gives the same joint answer and table as completing first and reading the table.
Eager/lazy equivalence including the final complete table, for every adaptive program and every initial cache. Later continuations can inspect both the result and that table.
Lazy evaluation from an empty cache agrees with sampling the entire independent function in advance, even for adaptive programs with repeated queries.
A uniformly sampled function can be replaced by a consistent lazy uniform oracle.
An ordinary list-based cache implements eager independent function sampling.
Implement a finite random function using arbitrary injective key representations and mapped values. The client sees the represented values; it need not know the finite sampling type.
Evaluate memoized closed samplers while retaining the represented final cache.
Memoized closed samplers implement the eager independent random-function experiment.