Stateful ProbOracleComp identical-until-bad hops and monotone bad-flag combinators #
Cryptographic game hops on stateful oracle handlers typically augment a base state σ to σ × Bool
with a sticky Boolean bad flag (FlagBad), proving that two handlers agree on good transitions and
that dropping the flag recovers the unflagged executions. Meanwhile, adversaries with private
randomness (ProbOracleComp spec) run against OracleComp.sumHandler with stateless uniform coin
draws on the left, which preserve oracle state and never trigger bad events.
This module eliminates both sources of per-proof boilerplate:
- All-events
CloseToandsumHandlerlifting forOracleComp.IdenticalUntilBad:IdenticalUntilBad.closeTo_runupgrades the difference lemma toCloseToon the joint result-and-state distributionPMF (α × σ), andIdenticalUntilBad.sumHandler_lift_leftlifts any externalIdenticalUntilBadacross memoryless left calls. - Monotone Boolean bad-flag combinators (
FlagBad,IsFlagMonotone,IdenticalUntilBad.of_flag,withBadFlag):IsFlagMonotonedischarges absorption once for any handler that keepstruelatched;IdenticalUntilBad.of_flagreducesIdenticalUntilBadto latched;IdenticalUntilBad.of_flagreducesIdenticalUntilBadto agreement on(s, false)transitions into(s', false);run_interpret_map_fst_of_flagdrops a flag whose marginal on(a, s')is independent of the flag bit; andwithBadFlagpackages a per-step(a, (s', b'))kernel into a monotone flagged handler automatically. ProbOracleComp.IdenticalUntilBadandProbOracleComp.runWithbad-event bounds: liftsrun_apply,symm,bind_apply_le,bad_eq,abs_sub_le,closeTo_run,closeTo_bind,runWith_map_fst,toOuterMeasure_bad_le,toOuterMeasure_bad_choose_two_cost_le, andtoOuterMeasure_bad_choose_two_ledirectly toProbOracleComp.runWithunder external query budgets (ProbOracleComp.IsQueryBounded/OracleComp.IsCostBounded), with no manualSum.inlcase splits.
Main definitions #
Cslib.OracleComp.FlagBad: the bad-state predicatest.2 = trueonσ × Bool.Cslib.OracleComp.IsFlagMonotone: Boolean flag monotonicity (truetransitions staytrue).Cslib.OracleComp.withBadFlag: lift a step returning(a, (s', stepBad))into a monotoneStateT (σ × Bool) PMFhandler via||.Cslib.ProbOracleComp.IdenticalUntilBad: identical-until-bad relation lifted toProbOracleComp.runWith.
Main results #
Cslib.OracleComp.IdenticalUntilBad.closeTo_run,Cslib.OracleComp.IdenticalUntilBad.closeTo_bind: all-eventsCloseTodifference lemmas.Cslib.OracleComp.IdenticalUntilBad.sumHandler_lift_left: liftIdenticalUntilBadacross memoryless left calls.Cslib.OracleComp.IsFlagMonotone.absorb,Cslib.OracleComp.IdenticalUntilBad.of_flag,Cslib.OracleComp.run_interpret_map_fst_of_flag: generic monotone-flag constructors and marginal projection.Cslib.OracleComp.withBadFlag_false,Cslib.OracleComp.isFlagMonotone_withBadFlag,Cslib.OracleComp.identicalUntilBad_withBadFlag,Cslib.OracleComp.run_interpret_withBadFlag_map_fst:withBadFlaglaws.Cslib.OracleComp.IdenticalUntilBad.probOracleComp,Cslib.ProbOracleComp.identicalUntilBad_iff,Cslib.ProbOracleComp.IdenticalUntilBad.run_apply,Cslib.ProbOracleComp.IdenticalUntilBad.symm,Cslib.ProbOracleComp.IdenticalUntilBad.bind_apply_le,Cslib.ProbOracleComp.IdenticalUntilBad.bad_eq,Cslib.ProbOracleComp.IdenticalUntilBad.abs_sub_le,Cslib.ProbOracleComp.IdenticalUntilBad.closeTo_run,Cslib.ProbOracleComp.IdenticalUntilBad.closeTo_bind,Cslib.ProbOracleComp.IdenticalUntilBad.of_flag,Cslib.ProbOracleComp.identicalUntilBad_withBadFlag,Cslib.ProbOracleComp.runWith_map_fst,Cslib.ProbOracleComp.runWith_withBadFlag_map_fst:ProbOracleComp.runWithdifference lemmas and flag combinators.Cslib.ProbOracleComp.toOuterMeasure_bad_le,Cslib.ProbOracleComp.toOuterMeasure_bad_choose_two_cost_le,Cslib.ProbOracleComp.toOuterMeasure_bad_choose_two_le: linear and triangular bad-event union bounds forProbOracleComp.runWith.
References #
All-events difference lemma: handlers that agree until bad induce joint output-and-state
distributions within CloseTo error equal to the probability of reaching a bad state.
All-events difference lemma for continuations: postprocessing two identical-until-bad runs
by a shared randomized continuation next preserves CloseTo within the bad-event probability.
Lifting a memoryless handler on the left of sumHandler preserves IdenticalUntilBad on the
right.
Monotone Boolean bad-flag combinators #
Construct IdenticalUntilBad on σ × Bool from flag monotonicity of both handlers and
pointwise agreement on (s, false) transitions that remain at (s', false).
Projecting away the Boolean flag of a handler on σ × Bool recovers an unflagged execution
whenever each step's (a, s') marginal is independent of the input flag.
Lift a step kernel step : (q : ι) → σ → PMF (spec q × (σ × Bool)) returning an answer, next
state, and per-call bad indicator into a stateful handler on σ × Bool that latches the flag via
||.
Starting from b = false, one step of withBadFlag step has the exact law step q s.
Every handler built with withBadFlag has a monotone Boolean bad flag.
Two withBadFlag handlers are IdenticalUntilBad whenever their underlying kernels assign
equal probability to every unflagged outcome (a, (s', false)).
Dropping the Boolean flag after one step of withBadFlag drops the per-step indicator,
independently of the prior flag b.
Dropping the Boolean flag of an adaptive withBadFlag execution recovers the unflagged
execution whenever each step's (a, s') marginal matches unflagged.
Two stateful external handlers agree until bad under ProbOracleComp.runWith: their lifted
sumHandlers with private uniform coin sampling satisfy OracleComp.IdenticalUntilBad.
Lift OracleComp.IdenticalUntilBad on external handlers to ProbOracleComp.IdenticalUntilBad
across private uniform sampling.
Restrict ProbOracleComp.IdenticalUntilBad back to the external handlers.
ProbOracleComp.IdenticalUntilBad holds if and only if the external handlers satisfy
OracleComp.IdenticalUntilBad.
Construct ProbOracleComp.IdenticalUntilBad on State × Bool from monotone Boolean flags on
both external handlers and agreement on (s, false) ↦ (a, (s', false)).
Symmetric relation for ProbOracleComp.IdenticalUntilBad.
Equal outcome probabilities at good final states under ProbOracleComp.runWith.
The difference lemma ([BS23], Theorem 4.7) for ProbOracleComp.runWith.
Both external handlers reach bad with equal probability under ProbOracleComp.runWith.
Two-sided difference lemma ([BS23], Theorem 4.7) for ProbOracleComp.runWith.
All-events CloseTo difference lemma on joint (α × State) outcomes of
ProbOracleComp.runWith.
All-events CloseTo difference lemma across a continuation next after
ProbOracleComp.runWith.
Two external withBadFlag handlers satisfy ProbOracleComp.IdenticalUntilBad whenever their
underlying kernels assign equal mass to unflagged outcomes (a, (s', false)).
Projecting away the Boolean flag of an external handler on State × Bool recovers the unflagged
ProbOracleComp.runWith execution whenever each step's (a, s') marginal is independent of b.
Projecting away the Boolean flag of withBadFlag step under ProbOracleComp.runWith recovers
runWith unflagged whenever each step's (a, s') marginal matches unflagged.
Bad-event union bounds for ProbOracleComp.runWith #
Accumulated probability of a bad state under ProbOracleComp.runWith. Let each external
call q from a good state turn bad with probability at most cost q * budget s and raise budget
by at most δ (while private coin draws cost nothing and leave state unchanged). Then a program
making at most n external queries (program.IsQueryBounded n), whose external calls have cost at
most k, reaches a bad state from s with probability at most k * (budget s + n * δ).
Two-cost triangular bad-state union bound under ProbOracleComp.runWith. When external
calls carry budgets k₁ for cost₁ (charging (cost₁ q * size s + (cost₁ q).choose 2) * δ and
growing size) and k₂ for cost₂ (growing size passively), runWith handler program s
reaches bad with probability at most (k₁ * size s + k₁ * k₂ + k₁.choose 2) * δ. The
(cost₁ q).choose 2 term covers a call that adds several points and may collide among them.
Triangular bad-state union bound under ProbOracleComp.runWith. If each external call from
a good state s turns bad with probability at most size s * δ and increases size by at most
1, then a program making at most n external queries (program.IsQueryBounded n) reaches a bad
state from s with probability at most (n * size s + n.choose 2) * δ.