Skip to content

feat(framework): deferred-sampling + relational-coupling engine#465

Merged
dtumad merged 6 commits into
Verified-zkEVM:mainfrom
alik-eth:pr/framework
Jul 2, 2026
Merged

feat(framework): deferred-sampling + relational-coupling engine#465
dtumad merged 6 commits into
Verified-zkEVM:mainfrom
alik-eth:pr/framework

Conversation

@alik-eth

@alik-eth alik-eth commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Adds the deferred-sampling and relational-coupling engine that the GPV/#188 and MLDSA/#228 security proofs build on. Purely additive: no existing declaration is changed or removed.

What's included

  • VCVio/OracleComp/QueryTracking/RandomOracle/DeferredSampling.lean — expectation algebra for deferred draws: i.i.d. bind-commutation (evalDist_bind_comm), the ε-multiplicity kernel (tsum_probOutput_fresh_mul_count_le), the Factorizes front-tape predicate with evalDist_step_commute_tape, and the state-relation transfer lemma tsum_probOutput_simulateQ_run_mul_of_rel.
  • VCVio/OracleComp/QueryTracking/RandomOracle/ProbeEps.lean — hidden-target read games: single-target q·ε bound (probEvent_hiddenReadMany_le), i.i.d. multi-key n·q·ε bound (probEvent_hiddenReadList_le), the averaged E[n]·q·ε bridge, single-draw deferral (probEvent_bind_fire_le_of_gen), and the explicit front-block drawList.
  • VCVio/ProgramLogic/Relational/SimulateQ.lean (additions) — relational-triple monotonicity/implication lemmas, the single-world expected-query-slack accumulator (probEvent_bad_simulateQ_run_le_expectedQuerySlack), and the bare-measure averaged-bad primitives (avgBadM, postStepOutM, avgBadM_query_bind_eq_tsum_output, tsum_tsum_postStepOutM_mul) used by the aborting-signer coupling.
  • VCVio/ProgramLogic/Relational/ProgrammingOracle.lean (additions) — TV-distance-to-bad-event bounds for programmed random oracles, including the caching/programming bridge consumed by the GPV reduction.
  • VCVio/EvalDist/Defs/Basic.lean (additions) — the first-moment bound probEvent_le_tsum_probOutput_mul_cost (+ support-restricted variant).

A soundness note for reviewers of the averaged-bad layer: the per-output invariant threading is stated over un-normalized sub-probability state measures (postStepOutM has no output-conditioning division), which is the formulation that avoids the mass-concentration pathology of a per-output conditioned invariant. The packaged PMF-typed telescoping layer that earlier drafts carried was dropped — both downstream consumers telescope directly from the bare-measure primitives, so only the consumed API ships.

Verification

  • lake build of the full CI library set: green.
  • #print axioms on the load-bearing engine lemmas (probEvent_le_of_relTriple_simulateQ_run, probEvent_bad_simulateQ_run_le_expectedQuerySlack, tvDist_simulateQ_randomOracle_withProgramming_le_probEvent_bad, probEvent_hiddenReadList_le, probEvent_bind_fire_le_of_gen, tsum_probOutput_fresh_mul_count_le, evalDist_step_commute_tape, tsum_probOutput_simulateQ_run_mul_of_rel): all [propext, Classical.choice, Quot.sound] — no sorryAx, no custom axioms.
  • New files are clean under -Dweak.linter.mathlibStandardSet=true.

Relation to the other PRs

The GPV/#188+Falcon PR and the MLDSA/#228 PR are stacked on this branch and consume this engine; this PR must merge first.

alik-eth added 4 commits July 2, 2026 15:14
Reusable, scheme-independent additions underpinning the GPV/Verified-zkEVM#188 and MLDSA/Verified-zkEVM#228
EUF-CMA proofs: the deferred-sampling toolbox (DeferredSampling, ProbeEps), the
relational simulateQ coupling engine (Relational/SimulateQ, ProgrammingOracle),
and two cost-bound lemmas (EvalDist/Defs/Basic). Pure additions.

Claude-Session: https://claude.ai/code/session_01C7GAM6ykxZoXwDXmtdLqrA
Remove the memoryless ε-probe layer (`probeStepEps`/`probeManyEps` + their bounds): a
self-contained abstraction with zero references anywhere in the tree. The first-fire theory
that is actually used is the hidden-target `readMany`/`hiddenReadList`/`drawList` layer,
which is retained. Rewrite the module docstring to describe the retained content, fix the two
cross-references that mentioned the removed layer, and drop the now-unused `D` type variable.
No statement or proof of any retained declaration changes (build green).

Claude-Session: https://claude.ai/code/session_01C7GAM6ykxZoXwDXmtdLqrA
… API removal)

Restore `probEvent_le_of_relTriple_simulateQ_run` verbatim alongside the more general
`relTriple_simulateQ_run_mono` / `probEvent_le_of_relTriple_imp` it had been generalized into,
so this PR is purely additive and no external caller of the specialized lemma breaks. Its
proof still goes through the surviving `relTriple_simulateQ_run` + `probEvent_le_of_relTriple`.

Claude-Session: https://claude.ai/code/session_01C7GAM6ykxZoXwDXmtdLqrA
Drop the packaged averaged-state-measure telescopers (avgBadM_le_threaded_linear,
avgBadM_le_of_steps*), the PMF-typed avgBad layer and its mass/pushforward helpers,
and the explicit-list ProbeEps bridges. Downstream proofs telescope directly from
the retained bare-measure primitives (avgBadM, postStepOutM,
avgBadM_query_bind_eq_tsum_output, tsum_tsum_postStepOutM_mul).

Claude-Session: https://claude.ai/code/session_01DaNGD9nDo3Grwk58nsjS77
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

🤖 PR Summary

Failed to generate AI summary. Please check the per-file summaries and statistics below.


Statistics

Metric Count
📝 Files Changed 8
Lines Added 2034
Lines Removed 18

Lean Declarations

✏️ Removed: 1 declaration(s)

VCVio/CryptoFoundations/ReplayFork.lean (1)

  • private lemma tsum_probOutput_map_mul [IsUniformSpec spec] {γ δ : Type} (mn : OracleComp spec γ)
✏️ Added: 60 declaration(s)

VCVio/EvalDist/Defs/Basic.lean (2)

  • lemma probEvent_le_tsum_probOutput_mul_cost (mx : m α) (p : α → Prop) (c : α → ℝ≥0∞)
  • lemma probEvent_le_tsum_probOutput_mul_cost_of_mem_support

VCVio/EvalDist/Monad/Basic.lean (4)

  • lemma tsum_probOutput_bind_mul (mx : m α) (g : α → m β) (f : β → ℝ≥0∞) :
  • lemma tsum_probOutput_map_mul [LawfulMonad m] (mx : m α) (f : α → β) (g : β → ℝ≥0∞) :
  • lemma tsum_probOutput_mul_of_const_on_support [MonadLiftT m SetM] [EvalDistCompatible m]
  • lemma tsum_probOutput_pure_mul (y : α) (f : α → ℝ≥0∞) :

VCVio/OracleComp/QueryTracking/RandomOracle/DeferredSampling.lean (9)

  • def Factorizes {γ τ : Type} (run : ProbComp γ) (tape : ProbComp τ)
  • lemma tsum_count_eq_length {C : Type} [DecidableEq C] (rl : List C) :
  • lemma tsum_probOutput_fresh_mul_count_le {C P : Type} [DecidableEq C]
  • theorem Factorizes.bind {γ τ δ : Type} {run : ProbComp γ} {tape : ProbComp τ}
  • theorem evalDist_bind_comm {α β γ : Type} (oa : ProbComp α) (ob : ProbComp β)
  • theorem evalDist_bind_congr_left {α β : Type} (oa : ProbComp α) (f g : α → ProbComp β)
  • theorem evalDist_bind_const_neverFails {α γ : Type} (od : ProbComp α) (hmass : Pr[⊥ | od] = 0)
  • theorem evalDist_step_commute_tape {γ S Ans τ ρ : Type}
  • theorem tsum_probOutput_simulateQ_run_mul_of_rel

VCVio/OracleComp/QueryTracking/RandomOracle/ProbeEps.lean (17)

  • @[simp] lemma probFailure_drawList (oa : ProbComp R) (n : ℕ) :
  • lemma tsum_probOutput_drawList_eq_one (oa : ProbComp R) (n : ℕ) :
  • noncomputable def drawList (oa : ProbComp R) : ℕ → ProbComp (List R)
  • noncomputable def hiddenReadList (oa : ProbComp R) (q : ℕ) (σ : List Bool → R) :
  • noncomputable def hiddenReadMany (oa : ProbComp R) (q : ℕ) (σ : List Bool → R) : ProbComp Bool
  • noncomputable def readMany (w : R) : ℕ → (List Bool → R) → Bool
  • noncomputable def readManyList (ws : List R) (q : ℕ) (σ : List Bool → R) : Bool
  • theorem probEvent_bind_const_or_pure (q : Bool) (mb : ProbComp Bool) :
  • theorem probEvent_bind_fire_eq_defer {α : Type} (oa : ProbComp R)
  • theorem probEvent_bind_fire_le_of_gen {α : Type} {oa : ProbComp R} {ε : ℝ≥0∞}
  • theorem probEvent_bind_fire_le_of_marginal_eq_readMany {α : Type} {oa : ProbComp R} {ε : ℝ≥0∞}
  • theorem probEvent_bind_hiddenReadList_le {oa : ProbComp R} {ε : ℝ≥0∞}
  • theorem probEvent_hiddenReadList_le {oa : ProbComp R} {ε : ℝ≥0∞} (hε : ∀ r : R, Pr[= r | oa] ≤ ε)
  • theorem probEvent_hiddenReadMany_le {oa : ProbComp R} {ε : ℝ≥0∞}
  • theorem probEvent_le_of_eq_bind_hiddenReadList {β : Type} {run : ProbComp β} {bad : β → Prop}
  • theorem readManyList_true_iff (ws : List R) (q : ℕ) (σ : List Bool → R) :
  • theorem readMany_true_iff (w : R) (q : ℕ) (σ : List Bool → R) :

VCVio/ProgramLogic/Relational/ProgrammingOracle.lean (4)

  • private lemma probOutput_withProgramming_eq_withCachingTrackingPolicy_of_not_bad_output'
  • theorem tvDist_simulateQ_randomOracle_withProgramming_le_probEvent_bad
  • theorem tvDist_simulateQ_withCaching_withProgramming_le_probEvent_bad'
  • theorem tvDist_withProgramming_withCachingTrackingPolicy_run_le_probEvent_bad'

VCVio/ProgramLogic/Relational/SimulateQ.lean (24)

  • lemma avgBadM_eq_tsum_pure
  • lemma avgBadM_pure_state
  • lemma avgBadM_pure
  • lemma avgBadM_query_bind_eq_tsum_output
  • lemma avgBadM_query_bind_eq
  • lemma avgBadM_telescope_eq_tsum_postStep
  • lemma expectedQuerySlack_charged_read_expected_growth_le
  • lemma expectedQuerySlack_expected_resource_le
  • lemma tsum_tsum_postStepOutM_mul
  • noncomputable def avgBadM
  • noncomputable def postStepJointM
  • noncomputable def postStepOutM
  • private lemma probOutput_simulateQ_run_eq_of_not_output_bad'
  • private lemma probOutput_simulateQ_run_eq_zero_of_output_bad'
  • private lemma tsum_probOutput_mul_tvDist_le_const
  • private lemma tsum_prod_right_bool_eq_of_zero {A B : Type} (f : A × B × Bool → ℝ≥0∞)
  • theorem probEvent_bad_simulateQ_run_le_expectedQuerySlack
  • theorem probEvent_dist_simulateQ_mono
  • theorem probEvent_le_of_relTriple_imp
  • theorem probEvent_marginal_simulateQ_mono
  • theorem probEvent_output_bad_eq'
  • theorem relTriple_simulateQ_run_mono
  • theorem tvDist_simulateQ_run_le_probEvent_output_bad
  • theorem tvDist_simulateQ_run_le_queryBoundP_mul

sorry Tracking

  • No sorrys were added, removed, or affected.

Coverage Notes

  • AI file summarization partially analyzed 1 file(s) because their individual diffs exceeded the per-file size budget. Statistics and Lean signal tracking still cover the full PR.
Partially Analyzed Files
  • VCVio/ProgramLogic/Relational/SimulateQ.lean (+1083/-0)

📄 **Per-File Summaries**
  • VCVio.lean: Summary unavailable — error: Error code: 401 - {'error': {'message': 'Missing Authentication header', 'code': 401}}
  • VCVio/CryptoFoundations/ReplayFork.lean: Summary unavailable — error: Error code: 401 - {'error': {'message': 'Missing Authentication header', 'code': 401}}
  • VCVio/EvalDist/Defs/Basic.lean: Summary unavailable — error: Error code: 401 - {'error': {'message': 'Missing Authentication header', 'code': 401}}
  • VCVio/EvalDist/Monad/Basic.lean: Summary unavailable — error: Error code: 401 - {'error': {'message': 'Missing Authentication header', 'code': 401}}
  • VCVio/OracleComp/QueryTracking/RandomOracle/DeferredSampling.lean: Summary unavailable — error: Error code: 401 - {'error': {'message': 'Missing Authentication header', 'code': 401}}
  • VCVio/OracleComp/QueryTracking/RandomOracle/ProbeEps.lean: Summary unavailable — error: Error code: 401 - {'error': {'message': 'Missing Authentication header', 'code': 401}}
  • VCVio/ProgramLogic/Relational/ProgrammingOracle.lean: Summary unavailable — error: Error code: 401 - {'error': {'message': 'Missing Authentication header', 'code': 401}}
  • VCVio/ProgramLogic/Relational/SimulateQ.lean: Summary unavailable — error: Error code: 401 - {'error': {'message': 'Missing Authentication header', 'code': 401}}

Last updated: 2026-07-02 19:09 UTC.

/-! ## Expectation algebra for nonnegative functionals -/

/-- Expectation of a nonnegative functional under a `pure` computation. -/
lemma tsum_probOutput_pure_mul {β : Type} (y : β) (f : β → ℝ≥0∞) :

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add this in VCVio/EvalDist/Monad/* somewhere and state it over a general monad instead? Also I think this could reasonably be simp.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in e110e6e — moved to VCVio/EvalDist/Monad/Basic.lean (new Expectation algebra section), stated over a general monad with [MonadLiftT m SPMF] [LawfulMonadLiftT m SPMF], and tagged @[simp].


/-- Tonelli-style rearrangement: the expectation of a nonnegative functional under a
`bind` is the outer expectation of the inner expectations. -/
lemma tsum_probOutput_bind_mul {α β : Type} (oa : ProbComp α)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These three other tsum lemmas could be generalized too I think.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done — all four now live there. tsum_probOutput_map_mul additionally takes [LawfulMonad m], and tsum_probOutput_mul_of_const_on_support takes [MonadLiftT m SetM] [EvalDistCompatible m] for the support reasoning. The general map lemma also subsumes the private tsum_probOutput_map_mul that ReplayFork.lean was carrying, so that copy is gone too. The two downstream PRs (#466, #467) are rebased onto this.

(`evalDist_bind_const_neverFails`). See
`FiatShamirWithAbort.evalDist_deferredDrawRead_eq_drawList_tapeDrawRead` for a worked
instance. -/
def Factorizes {γ τ : Type} (run : ProbComp γ) (tape : ProbComp τ)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you wanted to try I think this theory could also be abstracted into m with LawfulMonadLiftT m SPMF, but we could leave it at ProbComp for now and generalizing later when there is a consumer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed — leaving the Factorizes theory at ProbComp for now as you suggest. Both current consumers (the GPV tape factorization in #466 and the Fiat–Shamir-with-abort coupling in #467) instantiate at ProbComp, so I'd rather generalize to [LawfulMonadLiftT m SPMF] once a genuinely monad-parametric consumer exists.

…er any monad

Move tsum_probOutput_pure_mul (now simp), tsum_probOutput_bind_mul,
tsum_probOutput_map_mul, and tsum_probOutput_mul_of_const_on_support from
the deferred-sampling module to EvalDist/Monad/Basic, stated over a general
monad with an SPMF lift. The general map lemma subsumes ReplayFork's
private copy. Requested in PR Verified-zkEVM#465 review.

Claude-Session: https://claude.ai/code/session_01DaNGD9nDo3Grwk58nsjS77
@alik-eth

alik-eth commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Review addressed in e110e6e: the four expectation-algebra lemmas now live in VCVio/EvalDist/Monad/Basic.lean, stated over a general monad, with tsum_probOutput_pure_mul tagged @[simp]; the general map lemma also replaces the private copy in ReplayFork.lean. #466 and #467 are rebased on top. Full CI library set builds clean locally with the new @[simp] in place. @dtumad ready for another look.

@dtumad dtumad left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I think this looks good to merge now.

@dtumad
dtumad enabled auto-merge (squash) July 2, 2026 19:17
@dtumad
dtumad merged commit e413cf7 into Verified-zkEVM:main Jul 2, 2026
6 checks passed
alik-eth added a commit to alik-eth/VCV-io that referenced this pull request Jul 12, 2026
…ot lemmas; adapt WithAbort to Lean 4.31

Drop the two private WithAbort copies of the expectation-algebra lemmas that
landed at the EvalDist root in Verified-zkEVM#465 (tsum_probOutput_map_mul et al.) and
re-point their uses. Toolchain adaptation: zero_le' deprecation, simpa
post-simp defeq checks replaced by default-transparency exact/unfold at the
local-spec sites, gcongr reflexive-factor discharge, and a direct
Mathlib.Data.Nat.Choose.Cast import for Nat.cast_choose_two.

Claude-Session: https://claude.ai/code/session_01DaNGD9nDo3Grwk58nsjS77
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants