Output Distribution of Computations #
This file defines the MonadLiftT-based probability and support semantics for OracleComp.
A per-query distribution on an OracleSpec, definitionally the generic
probability specification on its underlying polynomial functor.
Instances For
The distribution of responses to query t.
Instances For
An OracleSpec whose responses are uniformly sampled from finite, inhabited
ranges. Bundles finiteness and inhabitedness of every response type with
IsProbabilitySpec spec and 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.
- toPMF : Handler PMF spec.toPFunctor
Every response set is finite.
Every response set is inhabited.
- toPMF_eq_uniform (t : spec.toPFunctor.A) : PFunctor.IsProbabilitySpec.toPMF t = PMF.uniformOfFintype (spec.Range t)
The per-query distribution is the uniform distribution on the response set.
Instances
Bridge from finite, inhabited response types 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.
Package uniform oracle semantics as generic uniform semantics on the
underlying polynomial functor. This is an explicit conversion rather than an
instance so it cannot participate in overly broad toPFunctor unification.
Instances For
Oracle-facing semantics #
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: evalSPMF_liftM.
liftM (query t) : OracleComp spec _ evaluates to the per-query distribution
IsProbabilitySpec.toPMF t, lifted to SPMF.
An event selecting at most one response to a uniform oracle query has probability at most the inverse response-space cardinality.
OracleComp spec admits the bridge between its direct support semantics and the
SPMF.support of its evalSPMF.
The reachable outputs of oa are exactly the outputs its distribution semantics gives
nonzero probability. This is EvalDistCompatible.support_eq_SPMF_support specialized to the
oracle façade, and it is the named bridge to reach for when a proof needs to move between the
two semantics without unfolding either into its SetM / SPMF interpreter.
An output has non-zero probability in evalSPMF iff it is in computation support.
Alias of the reverse direction of OracleComp.mem_support_evalSPMF_iff.
An output has non-zero probability in evalSPMF iff it is in computation support.
Alias of the forward direction of OracleComp.mem_support_evalSPMF_iff.
An output has non-zero probability in evalSPMF iff it is in computation support.
Finite-support variant of mem_support_evalSPMF_iff.
Alias of the reverse direction of OracleComp.mem_support_evalSPMF_iff'.
Finite-support variant of mem_support_evalSPMF_iff.
Alias of the forward direction of OracleComp.mem_support_evalSPMF_iff'.
Finite-support variant of mem_support_evalSPMF_iff.
Two events have equal probabilities when their predicates agree on the support of the first computation and the two computations share an evaluation distribution.
For any PUnit-valued computation in an arbitrary monad with an SPMF denotation, the
probability of returning () is the complementary mass of its failure probability.
The OracleComp instance of probOutput_punit_eq_sub_probFailure: for a PUnit-valued
oracle computation, the probability of returning () is the complementary mass of its failure
probability.
Guarding a computation oa by a decidable predicate p and asking for the probability of a
successful () output recovers exactly the event probability Pr[p | oa]: the failure mass of the
guard removes precisely the outputs falsifying p. Public guard-section API used by failure-based
security experiments.
Probabilities of orElse (<|>) #
oa <|> oa' runs oa, falling back to oa' only when oa returns none. The base OracleComp
never fails, so the two failure events are independent: oa <|> oa' fails exactly when both do, and
an output comes either from oa or — on oa's failure mass — from oa'. (support_orElse is left
as a future addition; it follows from probOutput_orElse via the support↔probability bridge.)
If an oracle implementation preserves the distribution of each source query, then
simulateQ preserves the distribution of every source computation.
The output distribution of mx when queries follow the specified distribution.
Instances For
obtain-friendly bind support peeler at the bare OracleComp level. Unlike rw [mem_support_bind_iff], applying this lemma to a hypothesis uses definitional unification to
match mx >>= f, so it engages through the Monad/MonadLift instance-tree mismatches that block
the syntactic rw (the elaborated OracleComp.instMonad/Bind.bind spelling produced by
unfolding nested protocol definitions differs syntactically from the canonical >>=).
obtain-friendly pure support resolver at the bare OracleComp level: y ∈ support (pure a) forces y = a, matched by definitional unification (so it engages on the
PFunctor.FreeM.pure spelling that the syntactic support_pure rw rejects).
obtain-friendly <$> (map) support peeler at the bare OracleComp level: y ∈ support (g <$> mx) yields a preimage a ∈ support mx with y = g a, matched by definitional unification
(so it engages on the elaborated Functor.map/OracleComp.instMonad spelling that the syntactic
support_map rw rejects).
Probability of an event after mapping a raw polynomial free program,
viewed through the OracleComp semantic bridge.
Probability of an event for a raw polynomial pure, viewed through
OracleComp.
Bind decomposition for a raw polynomial free program, viewed through
OracleComp.
Support-level peeler for an OptionT-monadic bind, stated at the underlying
OracleComp-level .run: every element y of the support of the run of mx >>= f factors
through an intermediate some a in mx's run support and a y in the run support of f a,
unless mx's run can produce none (in which case y may be that none). Companion to
OptionT.mem_support_bind_mk for the case where the OptionT.run has already been stripped to
the bare underlying computation.
Applies to a hypothesis y ∈ support oa whenever oa is definitionally (mx >>= f).run
(the OptionT.run is identity), so callers need not respell the full bind term.
OptionT.lift-headed specialization of mem_support_run_bind: a lifted (hence
never-failing) first computation oa peels cleanly, with the intermediate value living in
support oa directly (no none branch).