Discrete subprobability monad #
SubProbability expected-bind: integrate F against μ >>= k by integrating
(k ·).expected F against μ.
Stateful programs #
Equations
Instances For
Instances For
Postcondition combinators for wp #
Basic monotonicity, the 0-postcondition, the constant-postcondition bound
(from sub-probability mass), linearity, and constant scaling. These are
pure consequences of wp = lintegral against the SubProb measure.
wp of the constant 0 postcondition is 0.
wp of the constant c postcondition is at most c, since the underlying
measure is a sub-probability (total mass ≤ 1).
For tailrecursive programs (in particular while-loops), we can write
the wp iteration function (argument to recursion_wp[_simple]) as
tailrec_wp something. In this case, we'll have some nicer properties.
(See while_wp_unfold below for example.)
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Mass-1 (full probability) lemmas #
A program p has mass 1 at state σ iff p.wp (fun _ => 1) σ = 1, i.e.,
the total sub-probability mass produced by p at σ equals 1. This holds for
every "real" probabilistic operation in the language (pure, get, set, uniform,
…), and is preserved by >>=. The lemmas below let proofs about
identical-until-bad analyses and similar mass-conservation arguments compose
mass-1 facts cleanly.
ProgramDenotation.uniformOfFinset has mass 1.
Mass-1 composes through >>=: if p and every k a have mass 1, then
so does p >>= k. The workhorse for chaining mass-conservation facts
through composite programs.
Getter/setter, zoom, and procedure-wrapper rules #
The wp rules for the remaining ProgramDenotation primitives (generic getters and setters,
zoom), and for running procedures (procWrap): together they let a game's wp be pushed
through its whole call structure.
procedureDenotation of a plain procedure is procWrap of its body (the closed-procedure
sibling of procedureDenotation_eq_procWrap_gen).
Structure-eta for procedures, as a simp lemma: instantiation (and the call' denotation)
decompose a procedure into its fields; this resurfaces the named procedure.
Generic program/wp toolkit (re-homed from ProgramRange.lean) #
Range-free material: the deterministic-update embedding liftF, wp extensionality,
the bounded-loop combinator loop_n with its mass/linear-bound lemmas, value-marginal
bridges, IgnoresLens, the up-to-bad lemma, and the lens lift/factor constructions.
None of it mentions DetermFootprint/inRange; footprint-hypothesis variants live in
ProgramRange.lean (legacy) and ProbProgramRange.lean (current).
Lift a deterministic state update f : s → s to a ProgramDenotation s Unit.
Instances For
Programs equal at all postconditions of their wp are equal.
Bounded-loop combinator #
A generic n-fold iterator and its basic invariance/bound theorems.
Run body exactly n times. Generic bounded loop combinator.
Equations
- GaudisCrypt.loop_n 0 body = pure ()
- GaudisCrypt.loop_n n_2.succ body = do body GaudisCrypt.loop_n n_2 body
Instances For
Linear bump bound for loop_n with respect to a state-projected potential.
If body bumps f by ≤ c per iteration, then loop_n n body bumps f by ≤ n*c.
wp of a value-only post = expected value under the value-marginal. For
any G : α → ENNReal, p.wp (fun aσ => G aσ.1) σ equals the expected
value of G under the marginal distribution p σ >>= fun aσ => pure aσ.1.
Marginal-equality lifts to wp-equality for value-only posts. If two
programs agree on the value-marginal distribution at every starting state,
they agree on the wp of any post of the form fun aσ => G aσ.1. This is
the generic bridge from a SubProb-level transfer theorem to a wp-level
one — used by cr_transfer_wp_of_bit, ow_transfer_wp_of_bit, etc.
A post F ignores lens L if it doesn't depend on L-content of
its state argument: setting L to any value leaves F unchanged.
Instances For
Identical-until-bad #
The "fundamental lemma of game-playing" (Bellare-Rogaway, one-sided form):
if two programs p and q agree on every postcondition that vanishes on
"bad" outcomes, then p.wp G σ ≤ q.wp G σ + p.wp (G restricted to bad).
In our applications, bad is a state predicate (e.g., "the adversary
queried chal_x"), p is the original game, q is the simplified
"branch-eliminated" game, and G is the win indicator. We get
P[p wins] ≤ P[q wins] + P[p triggered bad].
Up-to-bad (wp form). If p and q agree on the restriction of any
post to ¬ bad, then p.wp G σ ≤ q.wp G σ + p.wp (G | bad) σ.
Lift an "inner" program along a lens: L.lift P runs P on the
L-content of state and writes the result back, leaving the outside
untouched.
Instances For
Given Adv : ProgramDenotation s a confined to L's range, factor it through an
inner program ProgramDenotation c a. The construction picks an arbitrary state
to "pad" the inner input; factor_of_inRange shows this padding doesn't
matter when Adv.inRange L.range.
Equations
Instances For
SubProbability bind is associative.
ProgramDenotation.uniform commutes with any program. Because ProgramDenotation.uniform
is state-preserving and produces an independent sample, it can be hoisted
out of any preceding bind (and its output passed through to the
continuation). The result of the preceding program is discarded.
Generalises adv_commutes_uniform (formerly in RO.lean) to arbitrary
programs and return types — the proof never used RO-specific facts.
wp of a sampled value (μ.toProgramDenotation = StateT.lift μ): it samples its
return from μ and leaves the state untouched.