Simulate Q triple preserves invariant
OracleComp.ProgramLogic.StdDo.simulateQ_triple_preserves_invariant
Plain-language statement
Generic simulation triple: if every handler call handler t preserves an invariant I on the simulation state, then simulateQ handler oa preserves I for any oa : OracleComp spec α. The invariant-only form (same I as pre- and post-condition, independent of return value) is the most common case; stronger per-call specs can be derived by instantiat...
Exact Lean statement
theorem simulateQ_triple_preserves_invariant {σ α : Type}
(handler : QueryImpl spec (StateT σ (OracleComp spec)))
(I : σ → Prop)
(hhandler : ∀ t : spec.Domain, Std.Do.Triple (handler t)
(spred(fun s => ⌜I s⌝))
(⇓ _ s' => ⌜I s'⌝))
(oa : OracleComp spec α) :
Std.Do.Triple
(simulateQ handler oa : StateT σ (OracleComp spec) α)
(spred(fun s => ⌜I s⌝))
(⇓ _ s' => ⌜I s'⌝)Formal artifact
Lean source
theorem simulateQ_triple_preserves_invariant {σ α : Type} (handler : QueryImpl spec (StateT σ (OracleComp spec))) (I : σ → Prop) (hhandler : ∀ t : spec.Domain, Std.Do.Triple (handler t) (spred(fun s => ⌜I s⌝)) (⇓ _ s' => ⌜I s'⌝)) (oa : OracleComp spec α) : Std.Do.Triple (simulateQ handler oa : StateT σ (OracleComp spec) α) (spred(fun s => ⌜I s⌝)) (⇓ _ s' => ⌜I s'⌝) := by -- A pure `Std.Do`-level proof via `Triple.pure` / `Triple.bind` is the -- structurally right thing, but consistently times out on `isDefEq` in -- the `query_bind` step (verified up to 1M heartbeats with several -- variations: explicit `R`, explicit `Q`, stripping `liftM` via -- `simulateQ_bind` + `simulateQ_query` + `id_map`). The cost appears to -- be in `(wp x).mono` reduction inside `Triple.bind` for the -- `StateT σ (OracleComp spec)` instance; this is plausibly a `Std.Do` -- upstream issue worth reporting. -- -- For now, bail out once to the support layer and induct directly on -- `oa`. Downstream consumers stay in the `Std.Do` world. rw [triple_stateT_iff_forall_support] induction oa using OracleComp.inductionOn with | pure x => intro s hs a s' hmem simp only [simulateQ_pure, StateT.run_pure, support_pure, Set.mem_singleton_iff, Prod.mk.injEq] at hmem obtain ⟨_, hseq⟩ := hmem exact hseq ▸ hs | query_bind t oa ih => intro s hs a s' hmem simp only [simulateQ_query_bind, OracleQuery.input_query, StateT.run_bind, support_bind, Set.mem_iUnion] at hmem obtain ⟨⟨u, s₁⟩, hmem₁, hmem₂⟩ := hmem have hhand := hhandler t rw [triple_stateT_iff_forall_support] at hhand exact ih u s₁ (hhand s hs u s₁ hmem₁) a s' hmem₂- Project
- VCVio
- License
- Apache-2.0
- Commit
- 2ceb2d825ee3
- Source
- VCVio/ProgramLogic/Unary/HandlerSpecs.lean:161-198
Reuse this declaration
Bring the exact result into your workflow
The import identifies the source module. Your project still needs the pinned package dependency shown on this page.
What this badge means
This completion status comes from the project or community source. It has not yet been represented here as an independent rebuild and axiom audit.
Continue in this project
Related declarations
Expected Cost Nat eq sum tail probs of pathwise Cost At Most
AddWriterT.expectedCostNat_eq_sum_tail_probs_of_pathwiseCostAtMost
Plain-language statement
Finite tail-sum formula for natural-valued writer cost under a pathwise upper bound. If every execution path of oa incurs cost at most n, then the tail probabilities vanish above n, so the infinite tail sum truncates to Finset.range n.
Source project: VCVio
Person-level attribution pending.
IND CPA advantage to Real le sum step signed Advantage Real abs
AsymmEncAlg.IND_CPA_advantage_toReal_le_sum_step_signedAdvantageReal_abs
Plain-language statement
Planned generic one-time-to-many-time lift: bounded multi-query IND-CPA advantage is at most the sum of the extracted one-time signed advantages over the first q fresh LR queries.
Source project: VCVio
Person-level attribution pending.
IND CPA LR hybrid Game q eval Dist eq left of Makes At Most Queries
AsymmEncAlg.IND_CPA_LR_hybridGame_q_evalDist_eq_left_of_MakesAtMostQueries
Plain-language statement
If an adversary makes at most q fresh LR queries, then the leftUntil = q LR-hybrid is the all-left endpoint game.
Source project: VCVio
Person-level attribution pending.