Output Distribution of Computations #
This file defines the MonadLiftT-based probability and support semantics for OracleComp.
A per-query distribution on an OracleSpec. Each query index t : ι is
assigned a PMF (spec t) for its responses. This is the abstract data needed
to lift OracleComp spec into PMF; uniformity is not assumed — see
IsUniformSpec for the uniform-sampling specialization.
Specs that should opt into uniform sampling are best registered via
IsUniformSpec, which extends this class and additionally carries
Fintype / Inhabited on each range plus a propositional witness that
toPMF is the canonical uniform distribution.
- toPMF (t : ι) : PMF (spec t)
The distribution of responses to query
t.
Instances
An OracleSpec whose responses are uniformly sampled from finite, inhabited
ranges. Bundles spec.Fintype, spec.Inhabited, and IsProbabilitySpec spec
together with a Prop witness that the per-query distribution agrees with
PMF.uniformOfFintype. Use this as the canonical input to lemmas that
mention Fintype.card (spec.Range _) or PMF.uniformOfFintype in their
statements.
- fintype : spec.Fintype
Every response set is finite.
- inhabited : spec.Inhabited
Every response set is inhabited.
The per-query distribution is the uniform distribution on the response set.
Instances
Bridge from [spec.Fintype] [spec.Inhabited] to IsUniformSpec spec.
Deliberately not an instance — IsUniformSpec must be opted into per
spec so that uniform-sampling semantics never attach silently to a spec
whose author didn't intend a probabilistic interpretation. Use this
helper when declaring IsUniformSpec for a concrete spec.
Instances For
Propagate IsUniformSpec through +: each summand's uniformity is
preserved on its branch. IsProbabilitySpec (spec + spec') is derived via
the extends chain.
Successor to the legacy empty marker OracleSpec.IsProbSpec. The replacement
IsUniformSpec bundles Fintype, Inhabited, IsProbabilitySpec, and a uniformity
witness.
Instances For
Embed OracleComp into PMF by interpreting each query via the per-query
distribution provided by IsProbabilitySpec.
Direct MonadLiftT (OracleComp spec) SetM: the syntactic / operational
support of mx, computed by folding queries to Set.univ. Independent of any
probability structure on spec — works for arbitrary specs without Fintype
or Inhabited. The bridge to the probability side is EvalDistCompatible
below, supplied only when [IsUniformSpec spec].
Note: This is the only MonadLiftT (OracleComp spec) SetM instance Lean will
find. The generic MonadLiftT SPMF SetM is declared as MonadLiftT (not
MonadLift), so monadLiftTrans cannot chain OracleComp → SPMF → SetM.
Abstract distribution of a single lifted query under IsProbabilitySpec:
the per-query distribution toPMF is pushed forward through the query's
continuation. Uniform-content sibling: evalDist_liftM.
liftM (query t) : OracleComp spec _ evaluates to the per-query distribution
IsProbabilitySpec.toPMF t, lifted to SPMF.
Alias of OracleComp.support_query.
Support-aware bind congruence: if two continuations agree on all elements in the support
of mx, the resulting bind computations are equal.
Finite version of support for when oracles have a finite set of possible outputs.
NOTE: we can't use simulateQ because Finset lacks a Monad instance.
OracleComp spec admits the bridge between its direct support semantics and the
SPMF.support of its evalDist.
An output has non-zero probability in evalDist iff it is in computation support.
Alias of the forward direction of OracleComp.mem_support_evalDist_iff.
An output has non-zero probability in evalDist iff it is in computation support.
Alias of the reverse direction of OracleComp.mem_support_evalDist_iff.
An output has non-zero probability in evalDist iff it is in computation support.
Finite-support variant of mem_support_evalDist_iff.
Alias of the forward direction of OracleComp.mem_support_evalDist_iff'.
Finite-support variant of mem_support_evalDist_iff.
Alias of the reverse direction of OracleComp.mem_support_evalDist_iff'.
Finite-support variant of mem_support_evalDist_iff.
If an oracle implementation preserves the distribution of each source query, then
simulateQ preserves the distribution of every source computation.
The possible outputs of mx when queries can output values in the specified sets.
NOTE: currently proofs using this should reduce to simulateQ. A full API would be better
Instances For
Reachable outputs of a bind are the reachable outputs of the continuation over reachable outputs of the first computation.
Membership form of [OracleComp.supportWhen_bind].
Enlarging the set of possible oracle outputs only enlarges the reachable output set.
The output distribution of mx when queries follow the specified distribution.