Lazy/eager transfer #
This file is the bridge between the lazy and eager random oracles.
convert— the operation that fills in undefined RO entries with a fresh uniform function. It's the program-level witness that lazy and eager are interchangeable.Convert algebra: how
convertinteracts withwp, withset/geton disjoint variables, and withrandom_oracle_init. Includes theclaim_*family of foundational lazy/eager equations (lazy_init_convert_eq_random_oracle_init,lazy_query_convert_eq_convert_random_oracle_query, etc.).ProgramDenotation.transfer— the lazy/eager transfer relation,transferBy convert(seeGaudisCrypt.Logic.TransferByfor the generic calculus). The closure laws (bind,while_loop, reflexivity on RO-disjoint programs) and the commutation/continuation forms are all instances of the generictransferBy_*lemmas; only the base cases (transfer_lazy_init,transfer_lazy_query) are proved here.wp/marginal bridges —ProgramDenotation.transfer_value_marginaland the enriched RO-invariant variants (transfer_wp_ro_invariant,transfer_marginal_ro_invariant), instantiating the generictransferBybridges withconvert_mass/ RO-invariance.
Convert #
Fill in undefined entries of the random oracle with a fresh uniform
function. The bridge between lazy and eager: applied to a lazy state,
convert produces the same distribution as an eager state.
Equations
- One or more equations did not get rendered due to their size.
Instances For
convert only reads and writes random_oracle_state (probabilistic footprint form;
drives the countability-free transfer-reflexivity).
Convert algebra #
Explicit convert.wp formula derived from the definition.
Foundational lazy/eager equations (the claim_* family) #
lazy_init then convert = random_oracle_init. The eager
initialisation is exactly the lazy initialisation followed by a fresh
uniform sampling that fills the cache.
Sum-over-Function.update reorganization (would-be-generic). Used by
lazy_query_convert_eq_convert_random_oracle_query. Cannot be moved out
of this file as-is because the local sorry'd Fintype (a → b)
instance in Basic.lean shadows Mathlib's Pi.instFintype, causing
type-class instance mismatches at the call site if the lemma is
elaborated in a module that doesn't see the local instance. Move once
the duplicate Fintype instance is removed.
Value-passing lazy/eager bridge for lazy_query: lazy_query followed
by convert (passing the value through) equals convert followed by
random_oracle_query. This is the workhorse equation; the continuation form
lazy_query_convert_cont_eq_convert_random_oracle_query is a corollary.
Continuation-passing variant of lazy_query_convert_eq_convert_random_oracle_query.
Factor convert out of an if: if the then-branch starts with convert
and the else-branch IS convert, we can move convert outside.
convert is absorbed by random_oracle_init: a fresh uniform sample
overwrites any prior RO content.
convert is absorbed by any program that starts with random_oracle_init:
convert >>= (random_oracle_init >>= rest) = random_oracle_init >>= rest.
Used by convert_*_experiment_eager lemmas (where the experiment starts
with random_oracle_init) to absorb a preceding convert step.
Lazy/eager transfer relation: p followed by convert produces the
same joint α × state distribution as convert followed by q.
Captures "convert slides past p, turning lazy operations into eager ones".
The instance of the generic ProgramDenotation.transferBy calculus at
c := convert: closed under bind; reflexive on RO-disjoint programs.
Together with the base cases lazy_init ↦ random_oracle_init
(lazy_init_convert_eq_random_oracle_init) and
lazy_query x ↦ random_oracle_query x
(lazy_query_convert_eq_convert_random_oracle_query), this lets us
transfer any program built from these primitives.
Equations
- ProgramDenotation.transfer p q = convert.transferBy p q
Instances For
Reflexivity on RO-disjoint programs — countability-free (subtask 4). The Footprint
analogue of transfer_refl_of_inRange_compl: a program whose probabilistic footprint avoids the
RO table commutes with convert (via commute_of_disjoint_footprint, no [Countable]), so transfers
to itself. The ᶜ-form makes the disjointness le_refl.
Any program in v.footprint, for a v disjoint from random_oracle_state, transfers to itself
— the countability-free Footprint analogue of transfer_of_inRange_disjoint.
ProgramDenotation.set v x transfers to itself when v is disjoint from random_oracle_state.
Countability-free (subtask 4): via the Footprint transfer-reflexivity.
ProgramDenotation.get v transfers to itself when v is disjoint from random_oracle_state.
Countability-free (subtask 4).
convert commutes with ProgramDenotation.set v x for any v disjoint from
random_oracle_state: the bind form of transfer_set_of_disjoint_ro.
convert commutes with ProgramDenotation.get v for any v disjoint from
random_oracle_state, in continuation-passing form: the continuation form
of transfer_get_of_disjoint_ro.
ProgramDenotation.uniform transfers to itself (it doesn't touch state at all).
Countability-free (subtask 4).
Bind closure: transfer chains under >>=.
lazy_init transfers to random_oracle_init: lazy_init; convert
equals random_oracle_init (the claim), which absorbs a preceding
convert.
lazy_query x transfers to random_oracle_query x. This is lazy_query_convert_eq_convert_random_oracle_query
restated in the transfer language.
Transfer is preserved by while_loop. If the body transfers (lazy
to eager) and the condition is RO-disjoint, then the lazy and eager
while-loops transfer.
Instance of the generic Kleene closure ProgramDenotation.transferBy_while_loop;
the condition's self-transfer comes from its RO-disjointness via the footprint
transfer-reflexivity. Any RO-based while-loop construction inherits
the lazy = eager equivalence by this closure law plus the base-case body
transfer.
Value marginal: SubProb-level statement of the transfer. (For the
wp-level value-only bridge, use ProgramDenotation.transferBy_wp_value
with convert_mass.)
Enriched transfer: RO-invariant projections of state #
The basic transfer_wp_value only delivers wp-equality for posts that
ignore the state. But convert only writes random_oracle_state — so
any projection of state that is invariant under random_oracle_state.set
is automatically preserved by convert. This means we can transfer
postconditions that depend on (value, RO-invariant state projection).
These enriched lemmas recover the full strength of the wrapper-style
oracle_loop_wp_lazy_eq_random_oracle and its marginal/compl/glob
companions, without rebuilding the Kleene argument.
convert preserves any state projection G : state → ENNReal that is
invariant under writes to random_oracle_state. Because convert only
samples a fresh RO function and writes it, an RO-invariant G is constant
along the convert trajectory, and convert's total mass is 1.
Transfer at the wp level for RO-invariant postconditions.
Strict strengthening of transfer_wp_value: instead of requiring the
post to ignore state entirely, only requires it to be invariant under
writes to random_oracle_state.
Captures the wrapper-style oracle_loop_wp_lazy_eq_random_oracle.
Marginal at the (value × RO-invariant projection) level.
Strict strengthening of transfer_value_marginal: instead of projecting
to just the value, we additionally include any RO-invariant projection
h : state → β. Captures the wrapper-style
oracle_loop_marginal_lazy_eq_random_oracle family.