Skip to content

feat(ProgramLogic): program logic overhaul — eRHL, simulateQ rules, and ElGamal all-random proof#116

Open
quangvdao wants to merge 13 commits intomasterfrom
quang/more-program-logic
Open

feat(ProgramLogic): program logic overhaul — eRHL, simulateQ rules, and ElGamal all-random proof#116
quangvdao wants to merge 13 commits intomasterfrom
quang/more-program-logic

Conversation

@quangvdao
Copy link
Collaborator

Summary

Adds the core program-logic infrastructure for game-hopping proofs and applies it to advance the ElGamal IND-CPA security proof.

Program Logic (VCVio/ProgramLogic/)

  • Unary/SimulateQ: Oracle-aware weakest-precondition rules (wp_simulateQ_eq, wp_liftComp, wp_simulateQ_run'_eq) that let unary Hoare-logic proofs pass through simulateQ boundaries. All proofs complete (no sorry).
  • Relational/Basic: Relational triple (RelTriple) coupling rules for oracle queries — identity coupling (relTriple_query) and bijection/rnd rule (relTriple_query_bij), plus relTriple_bind, relTriple_refl, postcondition monotonicity, and bridges to evalDist/probOutput. All proofs complete.
  • Relational/SimulateQ: Stateful relational coupling through simulateQ by induction on OracleComp, and the fundamental lemma of game playing (tvDist_simulateQ_le_probEvent_bad) — "identical until bad" with required monotonicity hypotheses. All helper lemmas proven; 1 sorry remains in the final tvDist bound (ENNReal algebra step).
  • Relational/Quantitative: Full eRHL (ℝ≥0∞-valued relational Hoare logic) with pRHL and apRHL as special cases. Structural rules stubbed with sorry (7 sorry's) for parallel proof-filling.
  • Notation: Ergonomic layer — GameEquiv, AdvBound, bridge lemmas from RelTriple to game equivalence. 1 sorry in a convenience bridge.
  • Unary/HoareTriple: wp_ite rule added.

Supporting Library

  • RelationalAlgebra: Two-sided StateT MAlgRelOrdered instance (instStateTBoth) for relational reasoning with independent state on each side.
  • SampleableType: probOutput_map_bijective_uniformSample (bijective map preserves uniform distribution) and probOutput_decide_eq_uniformBool_half (bit-guessing with distribution-independent oracle has probability 1/2).

ElGamal IND-CPA (Examples/HHS_Elgamal.lean)

  • Proven: randomMaskedCipher_dist_indep (left-multiplication bijection), IND_CPA_hybridOracle_allRandom_eqDist (relational coupling via evalDist equality), and IND_CPA_allRandomHalf (the all-random hybrid has success probability exactly 1/2).
  • Stated (sorry): IND_CPA_stepDDH_real_branch_eq and IND_CPA_stepDDH_random_branch_eq — the per-hop DDH reduction correctness lemmas (3 sorry's total in this file).

Sorry inventory

File Sorry count Nature
Relational/Quantitative.lean 7 eRHL structural rules (bind, frame, conseq, etc.)
Relational/SimulateQ.lean 1 Final tvDist bound (ENNReal arithmetic)
Notation.lean 1 Convenience bridge lemma
Examples/HHS_Elgamal.lean 3 DDH step reduction correctness

Test plan

  • lake build passes (all new files compile, sorry's are explicit)
  • No import cycle violations (new files respect module layering DAG)
  • Existing tests/examples unaffected (only additive changes)

Made with Cursor

…ative relational logic, and ElGamal wiring

Add the complete program logic overhaul skeleton:

- Unary/SimulateQ: wp rules for simulateQ, liftComp, stateful oracle impls
- Relational/Quantitative: eRHL (ℝ≥0∞-valued) with pRHL and apRHL as special cases
- Relational/SimulateQ: relational simulateQ coupling and identical-until-bad lemma
- Notation: GameEquiv, AdvBound, game_wp/game_rel tactic macros
- Basic: query coupling rules (identity + bijection/rnd)
- RelationalAlgebra: two-sided StateT instance
- SampleableType: bijective map + uniform bool guessing lemmas
- HoareTriple: wp_ite rule
- ElGamal: helper lemma statements for allRandomHalf and DDH step

All proofs are either completed or sorry'd for parallel proof-filling.

Made-with: Cursor
…l/SimulateQ

Fill in proofs for relational coupling rules and simulateQ theorems:
- Basic.lean: relTriple_query, relTriple_query_bij (bijection/"rnd" rule),
  plus relTriple_refl, relTriple_post_mono, relTriple_bind, and
  evalDist/probOutput equivalence bridges
- SimulateQ.lean: relTriple_simulateQ_run (stateful oracle coupling by
  induction on OracleComp), relTriple_simulateQ_run' (output-only projection),
  and helper relTriple_map

Made-with: Cursor
Unary/SimulateQ: all sorry's resolved — wp_simulateQ_eq, wp_liftComp,
wp_simulateQ_run'_eq now fully proven.

Relational/SimulateQ: fix "identical until bad" theorem signature —
add required monotonicity hypotheses (h_mono₁, h_mono₂) without which
the theorem is false. All helper lemmas fully proven; one sorry remains
in the final tvDist bound (ENNReal algebra).

Made-with: Cursor
Resolve three sorry's in the IND-CPA game-hopping proof:
- randomMaskedCipher_dist_indep: left-multiplication bijection argument
- IND_CPA_hybridOracle_allRandom_eqDist: relational coupling via evalDist equality
- IND_CPA_allRandomHalf: uniform bit guessing reduces to probOutput_decide_eq_uniformBool_half

Also add helper lemmas (evalDist_simulateQ_run_eq_of_impl_evalDist_eq,
hybridChallengeOracle_allRandom_evalDist_eq) used in the coupling proof.

Made-with: Cursor
@github-actions
Copy link

github-actions bot commented Mar 4, 2026

🤖 AI-Generated PR Summary

Files Changed:

  • Examples/HHS_Elgamal.lean
  • ToMathlib/Control/Monad/RelationalAlgebra.lean
  • VCVio.lean
  • VCVio/OracleComp/Constructions/SampleableType.lean
  • VCVio/ProgramLogic/Notation.lean
  • VCVio/ProgramLogic/Relational/Basic.lean
  • VCVio/ProgramLogic/Relational/Quantitative.lean
  • VCVio/ProgramLogic/Relational/SimulateQ.lean
  • VCVio/ProgramLogic/Unary/HoareTriple.lean
  • VCVio/ProgramLogic/Unary/SimulateQ.lean

Overview of Changes:
This diff significantly enhances the formal verification framework for cryptographic proofs by introducing a quantitative relational program logic and applying it to the IND-CPA security proof of ElGamal.

Here is a summary of the key changes:

  • New Quantitative Program Logic Framework (eRHL):

    • A powerful quantitative relational Hoare logic (eRHL) is introduced. This framework allows reasoning not only about program equivalence but also about the statistical distance between program distributions, which is fundamental for computational security proofs.
    • This includes core definitions for quantitative weakest preconditions (eRelWP) and rules for program composition (eRelTriple_bind).
  • High-Level Abstractions for Game-Hopping:

    • The "identical until bad" lemma (tvDist_simulateQ_le_probEvent_bad) is formalized. This is a cornerstone of game-hopping proofs, providing a way to bound the difference between two games by the probability of a "bad" event.
    • New rules (relTriple_simulateQ_run) are added to reason about the relationship between programs that simulate oracle queries differently.
  • Application to ElGamal Security Proof:

    • The new logic is used to complete a key step in the IND-CPA security proof for ElGamal.
    • It formally proves that in the "all-random hybrid" game, the adversary's view is statistically independent of the secret challenge bit. This directly implies that the adversary's advantage in this game is zero (success probability is exactly 1/2).
  • Improved Ergonomics and Helper Lemmas:

    • A new file (Notation.lean) introduces more readable, user-facing notation and tactics to simplify writing proofs.
    • Reusable probability lemmas, such as one for proving a game has a 1/2 success probability (probOutput_decide_eq_uniformBool_half), are added to streamline common proof patterns.

New 'sorry's: 11

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8b32f36d81

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

/-- `game_wp` decomposes unary WP goals by repeatedly applying WP rules. -/
macro "game_wp" : tactic =>
`(tactic| (
simp only [game_rule]

Choose a reason for hiding this comment

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

P2 Badge Replace undefined game_rule references in game tactics

game_wp/game_rel both call simp with game_rule, but there is no game_rule lemma anywhere in the repository (a repo-wide rg "\bgame_rule\b" only finds these macro lines). As a result, the macros elaborate but fail when invoked with an unknown-constant error, so the new user-facing game-hopping tactics are not actually usable.

Useful? React with 👍 / 👎.

…d program logic tactics

Rename `SigmaAlg` → `SigmaProtocol` with security property definitions
(completeness, special soundness, HVZK). Add `game_rule` simp attribute,
extend `game_wp`/`game_rel`/`coupling`/`game_hop` tactics, and wire up
Schnorr sigma protocol and Fiat-Shamir examples.

Made-with: Cursor
…l equivalence

Fill the three Part A sorry's in HHS_Elgamal.lean:
- hybridChallengeOracle_allRandom_evalDist_eq: the challenge oracle
  produces equal distributions for b=true vs b=false when realUntil=0,
  via StateT/liftM unfolding and randomMaskedCipher_dist_indep.
- evalDist_monadLift_self: identity lift simplification using simulateQ_id'.
- Minor SubSpec.lean comment fix.

Made-with: Cursor
…ij, tvDist_simulateQ bound

Fill sorry's in three program logic files:
- wp_uniformSample via μ_bind_eq_tsum decomposition
- relTriple_uniformSample_bij via relWP coupling with bijection
- tvDist_simulateQ_le_probEvent_bad via fundamental lemma of game playing

Made-with: Cursor
… and OptimalCoupling

- Generalize IsQueryBound to arbitrary budget types; recover classical per-index bound as IsPerIndexQueryBound
- Prove Schnorr sigma protocol completeness, special soundness, and HVZK
- Fill eRelTriple_pure, relTriple'_bind, and backward direction of relTriple'_iff_couplingPost
- Add OptimalCoupling.lean with compactness infrastructure for coupling space
- Inline trueProbReal, weaken IND_CPA hybrid theorem hypotheses
- Remove unused DecidableEq constraints from DDH/HHS definitions

Made-with: Cursor
@github-actions
Copy link

github-actions bot commented Mar 6, 2026

🤖 Gemini PR Summary

Comprehensive program logic framework for cryptographic game-hopping proofs, focusing on quantitative relational logic and its application to ElGamal IND-CPA security.

Core Program Logic (eRHL & WP)

  • Quantitative Relational Logic (eRelWP): Introduces an $\mathbb{R}_{\ge 0}^\infty$-valued relational Hoare logic (eRHL) that generalizes pRHL and apRHL.
  • Oracle-Aware Rules: WP rules for simulateQ boundaries (wp_simulateQ_eq, wp_liftComp) and relational coupling rules for oracle queries, including identity and bijective couplings (relTriple_query_bij).
  • Fundamental Lemma of Game Playing: Formalizes the "identical until bad" lemma (tvDist_simulateQ_le_probEvent_bad) providing a bound on total variation distance based on "bad" state probability.
  • Relational Algebra: Implements the MAlgRelOrdered instance for StateT, enabling relational reasoning with independent state on each side.
  • Tactics and Notation: Ergonomic layer for game-hopping including GameEquiv, AdvBound, and automation stubs for weakest-precondition and relational coupling (game_wp, game_rel, game_hop).

Mathematical & Supporting Library

  • Probability Theory: Generalizes total variation distance and uniform sampling lemmas by removing DecidableEq constraints.
  • SampleableType: Adds probOutput_map_bijective_uniformSample (bijective map invariance) and probOutput_decide_eq_uniformBool_half (bit-guessing success).

ElGamal IND-CPA Proof

  • Verifies IND_CPA_allRandomHalf (all-random hybrid success is 1/2).
  • Completes randomMaskedCipher_dist_indep (left-multiplication bijection) and IND_CPA_hybridOracle_allRandom_eqDist (relational coupling).

Critical: Sorry Inventory

CRITICAL: This PR contains several sorry and admit placeholders in foundational and example files:

  • VCVio/ProgramLogic/Relational/Quantitative.lean: 7 sorries (eRHL structural rules: bind, frame, conseq, etc.).
  • Examples/HHS_Elgamal.lean: 3 sorries (DDH step reduction correctness lemmas).
  • VCVio/ProgramLogic/Relational/SimulateQ.lean: 1 sorry (final tvDist bound algebra).
  • VCVio/ProgramLogic/Notation.lean: 1 sorry (bridge lemma).

Note on Discrepancies

There are significant discrepancies between the provided PR body and the draft summary derived from the code changes:

  • Scope: The draft summary identifies formalizations for Σ-protocols (HHS Schnorr), the Probabilistic Forking Lemma, and Fiat-Shamir security, none of which are mentioned in the PR body.
  • Sorries: The draft summary notes additional sorries in VCVio/ProgramLogic/Fork.lean and VCVio/CryptoFoundations/FiatShamir.lean not listed in the PR body's inventory.
  • ElGamal Completion: The PR body explicitly lists 3 sorries in Examples/HHS_Elgamal.lean, while the draft summary claims these were removed to provide a verified security bound.

Statistics

Metric Count
📝 Files Changed 28
Lines Added 3932
Lines Removed 195

Lean Declarations

✏️ **Removed:** 4 declaration(s)
  • theorem wp_bind (oa : OracleComp spec α) (ob : α → OracleComp spec β) in VCVio/ProgramLogic/Unary/HoareTriple.lean
  • lemma IsQueryBound.mono {oa : OracleComp spec α} {qb qb' : ι → ℕ} in VCVio/OracleComp/QueryTracking/QueryBound.lean
  • lemma isQueryBound_bind {oa : OracleComp spec α} {ob : α → OracleComp spec β} in VCVio/OracleComp/QueryTracking/QueryBound.lean
  • theorem wp_query (t : spec.Domain) (post : spec.Range t → ℝ≥0∞) : in VCVio/ProgramLogic/Unary/HoareTriple.lean
✏️ **Added:** 67 declaration(s)
  • theorem euf_cma_bound in VCVio/CryptoFoundations/FiatShamir.lean
  • def SpeciallySoundAt (σ : SigmaProtocol S W PC SC Ω P p) (x : S) : Prop in VCVio/CryptoFoundations/SigmaProtocol.lean
  • theorem relTriple_simulateQ_run' in VCVio/ProgramLogic/Relational/SimulateQ.lean
  • lemma isCompact_couplings_set (p : SubPMF α) (q : SubPMF β) : in ToMathlib/ProbabilityTheory/OptimalCoupling.lean
  • theorem relTriple'_iff_couplingPost in VCVio/ProgramLogic/Relational/Quantitative.lean
  • def eRelTriple (pre : ℝ≥0∞) (oa : OracleComp spec₁ α) (ob : OracleComp spec₂ β) in VCVio/ProgramLogic/Relational/Quantitative.lean
  • lemma probOutput_decide_eq_uniformBool_half in VCVio/OracleComp/Constructions/SampleableType.lean
  • lemma relTriple'_bind in VCVio/ProgramLogic/Relational/Quantitative.lean
  • lemma probOutput_bind_mul_left_uniform {β : Type} (m : P) (f : P → ProbComp β) (z : β) : in Examples/HHS_Elgamal.lean
  • theorem tvDist_simulateQ_le_probEvent_bad in VCVio/ProgramLogic/Relational/SimulateQ.lean
  • theorem eRelTriple_pure (a : α) (b : β) (post : α → β → ℝ≥0∞) : in VCVio/ProgramLogic/Relational/Quantitative.lean
  • lemma probOutput_mul_left_uniform (m x : P) : in Examples/HHS_Elgamal.lean
  • lemma isClosed_couplings_set (p : SubPMF α) (q : SubPMF β) : in ToMathlib/ProbabilityTheory/OptimalCoupling.lean
  • lemma mem_couplings_set_of_isCoupling {p : SubPMF α} {q : SubPMF β} (c : SubPMF (α × β)) in ToMathlib/ProbabilityTheory/OptimalCoupling.lean
  • def PerfectlyComplete (σ : SigmaProtocol S W PC SC Ω P p) : Prop in VCVio/CryptoFoundations/SigmaProtocol.lean
  • def IND_CPA_adversary.MakesAtMostQueries {encAlg : AsymmEncAlg ProbComp M PK SK C} in VCVio/CryptoFoundations/AsymmEncAlg.lean
  • lemma isPerIndexQueryBound_pure (x : α) (qb : ι → ℕ) : in VCVio/OracleComp/QueryTracking/QueryBound.lean
  • def stepDDH_realBranchGame in Examples/HHS_Elgamal.lean
  • theorem eRelTriple_conseq {pre pre' : ℝ≥0∞} in VCVio/ProgramLogic/Relational/Quantitative.lean
  • theorem spmf_tvDist_eq_one_sub_eRelWP_eqRel in VCVio/ProgramLogic/Relational/Quantitative.lean
  • theorem GameEquiv.of_approxRelTriple_zero in VCVio/ProgramLogic/Notation.lean
  • theorem wp_liftComp {ι' : Type*} {superSpec : OracleSpec ι'} in VCVio/ProgramLogic/Unary/SimulateQ.lean
  • theorem schnorrSigma_speciallySound : in Examples/HHS_Schnorr.lean
  • abbrev IsPerIndexQueryBound (oa : OracleComp spec α) (qb : ι → ℕ) : Prop in VCVio/OracleComp/QueryTracking/QueryBound.lean
  • lemma isPerIndexQueryBound_bind {oa : OracleComp spec α} {ob : α → OracleComp spec β} in VCVio/OracleComp/QueryTracking/QueryBound.lean
  • def stepDDH_randBranchCore in Examples/HHS_Elgamal.lean
  • lemma probOutput_map_bijective_uniformSample [Fintype α] in VCVio/OracleComp/Constructions/SampleableType.lean
  • def stepDDH_randBranchGame in Examples/HHS_Elgamal.lean
  • lemma relTriple_query_bij (t : spec₁.Domain) in VCVio/ProgramLogic/Relational/Basic.lean
  • lemma randomMaskedCipher_dist_indep (pk : P × P) (m₁ m₂ : P) : in Examples/HHS_Elgamal.lean
  • theorem perfectlyCorrect (hc : σ.PerfectlyComplete) : in VCVio/CryptoFoundations/FiatShamir.lean
  • theorem GameEquiv.of_relTriple' in VCVio/ProgramLogic/Notation.lean
  • lemma IsPerIndexQueryBound.mono {oa : OracleComp spec α} {qb qb' : ι → ℕ} in VCVio/OracleComp/QueryTracking/QueryBound.lean
  • def SpeciallySound (σ : SigmaProtocol S W PC SC Ω P p) : Prop in VCVio/CryptoFoundations/SigmaProtocol.lean
  • theorem gameEquiv_of_relTriple'_eqRel in VCVio/ProgramLogic/Relational/Quantitative.lean
  • theorem relTriple_simulateQ_run in VCVio/ProgramLogic/Relational/SimulateQ.lean
  • theorem schnorrSigma_hvzk : in Examples/HHS_Schnorr.lean
  • theorem relTriple'_eq_approxRelTriple_zero in VCVio/ProgramLogic/Relational/Quantitative.lean
  • lemma map_fst_eval (c : SubPMF (α × β)) (a : α) : in ToMathlib/ProbabilityTheory/OptimalCoupling.lean
  • theorem triple_fork (post : α × α → ℝ≥0∞) : in VCVio/ProgramLogic/Fork.lean
  • lemma isPerIndexQueryBound_query_bind_iff (t : ι) (mx : spec t → OracleComp spec α) in VCVio/OracleComp/QueryTracking/QueryBound.lean
  • def RelTriple' (oa : OracleComp spec₁ α) (ob : OracleComp spec₂ β) in VCVio/ProgramLogic/Relational/Quantitative.lean
  • lemma isPerIndexQueryBound_map_iff (oa : OracleComp spec α) (f : α → β) (qb : ι → ℕ) : in VCVio/OracleComp/QueryTracking/QueryBound.lean
  • theorem IND_CPA_HybridGame_q_eq_game in Examples/HHS_Elgamal.lean
  • def HVZK (σ : SigmaProtocol S W PC SC Ω P p) in VCVio/CryptoFoundations/SigmaProtocol.lean
  • def couplings_set (p : SubPMF α) (q : SubPMF β) : Set (Option (α × β) → ℝ) in ToMathlib/ProbabilityTheory/OptimalCoupling.lean
  • lemma ddh_decomp_two_games_toReal (real rand : ProbComp Bool) : in Examples/HHS_Elgamal.lean
  • lemma map_snd_eval (c : SubPMF (α × β)) (b : β) : in ToMathlib/ProbabilityTheory/OptimalCoupling.lean
  • theorem relTriple'_iff_relTriple in VCVio/ProgramLogic/Relational/Quantitative.lean
  • theorem wp_simulateQ_run'_eq {σ : Type} in VCVio/ProgramLogic/Unary/SimulateQ.lean
  • lemma isBounded_couplings_set (p : SubPMF α) (q : SubPMF β) : in ToMathlib/ProbabilityTheory/OptimalCoupling.lean
  • lemma isPerIndexQueryBound_query_iff (t : ι) (qb : ι → ℕ) : in VCVio/OracleComp/QueryTracking/QueryBound.lean
  • def schnorrSigma : SigmaProtocol (P × P) G P G Bool G in Examples/HHS_Schnorr.lean
  • def stepDDH_realBranchCore in Examples/HHS_Elgamal.lean
  • lemma SubPMF.exists_max_coupling {p : SubPMF α} {q : SubPMF β} in ToMathlib/ProbabilityTheory/OptimalCoupling.lean
  • lemma relTriple_query (t : spec₁.Domain) : in VCVio/ProgramLogic/Relational/Basic.lean
  • theorem AdvBound.of_tvDist in VCVio/ProgramLogic/Notation.lean
  • def GameEquiv (g₁ g₂ : OracleComp spec₁ α) : Prop in VCVio/ProgramLogic/Notation.lean
  • theorem tvDist_eq_one_sub_eRelWP_eqRel in VCVio/ProgramLogic/Relational/Quantitative.lean
  • lemma probOutput_bind_uniformBool {α : Type} in Examples/HHS_Elgamal.lean
  • theorem wp_simulateQ_eq in VCVio/ProgramLogic/Unary/SimulateQ.lean
  • def AdvBound (game : OracleComp spec₁ Bool) (ε : ℝ) : Prop in VCVio/ProgramLogic/Notation.lean
  • theorem schnorrSigma_complete : in Examples/HHS_Schnorr.lean
  • lemma OracleComp.ProgramLogic.Relational.relTriple_uniformSample_bij in VCVio/ProgramLogic/Relational/Basic.lean
  • theorem eRelTriple_bind in VCVio/ProgramLogic/Relational/Quantitative.lean
  • lemma IND_CPA_hybridOracle_allRandom_eqDist in Examples/HHS_Elgamal.lean
  • def ApproxRelTriple (ε : ℝ≥0∞) (oa : OracleComp spec₁ α) (ob : OracleComp spec₂ β) in VCVio/ProgramLogic/Relational/Quantitative.lean
✏️ **Affected:** 15 declaration(s) (line number changed)
  • def parallelTesting_experiment in VCVio/CryptoFoundations/HardnessAssumptions/HardHomogeneousSpace.lean moved from L56 to L56
  • abbrev ddhExp (adversary : DDHAdversary V P) : ProbComp Bool in VCVio/CryptoFoundations/HardnessAssumptions/DiffieHellman.lean moved from L49 to L49
  • lemma etvDist_map_le (f : α' → β) (p q : PMF α') : in ToMathlib/Probability/ProbabilityMassFunction/TotalVariation.lean moved from L126 to L126
  • lemma tvDist_map_le (f : α' → β) (p q : PMF α') : in ToMathlib/Probability/ProbabilityMassFunction/TotalVariation.lean moved from L141 to L142
  • lemma isQueryBound_query_iff (t : ι) (b : B) in VCVio/OracleComp/QueryTracking/QueryBound.lean moved from L50 to L62
  • theorem ElGamal_IND_CPA_bound_toReal in Examples/HHS_Elgamal.lean moved from L252 to L2073
  • lemma isQueryBound_query_bind_iff (t : ι) (mx : spec t → OracleComp spec α) in VCVio/OracleComp/QueryTracking/QueryBound.lean moved from L44 to L55
  • lemma isQueryBound_map_iff (oa : OracleComp spec α) (f : α → β) (b : B) in VCVio/OracleComp/QueryTracking/QueryBound.lean moved from L118 to L82
  • def IND_CPA_stepDDHReduction in Examples/HHS_Elgamal.lean moved from L213 to L461
  • theorem ElGamal_IND_CPA_le_q_mul_ddh in Examples/HHS_Elgamal.lean moved from L292 to L2121
  • lemma IND_CPA_stepDDH_hopBound in Examples/HHS_Elgamal.lean moved from L235 to L1709
  • lemma isQueryBound_pure (x : α) (b : B) in VCVio/OracleComp/QueryTracking/QueryBound.lean moved from L41 to L51
  • def FiatShamir (sigmaAlg : SigmaProtocol X W PC SC Ω P p) in VCVio/CryptoFoundations/FiatShamir.lean moved from L35 to L35
  • lemma tvDist_map_le [LawfulMonad m] {β : Type u} (f : α → β) (mx my : m α) : in VCVio/EvalDist/TVDist.lean moved from L84 to L84
  • def IsQueryBound (oa : OracleComp spec α) (budget : B) in VCVio/OracleComp/QueryTracking/QueryBound.lean moved from L33 to L42

sorry Tracking

✅ **Removed:** 2 `sorry`(s)
  • lemma IND_CPA_stepDDH_hopBound in Examples/HHS_Elgamal.lean (L242)
  • theorem IND_CPA_allRandomHalf in Examples/HHS_Elgamal.lean (L175)
❌ **Added:** 8 `sorry`(s)
  • theorem euf_cma_bound in VCVio/CryptoFoundations/FiatShamir.lean (L93)
  • theorem euf_cma_bound in VCVio/CryptoFoundations/FiatShamir.lean (L94)
  • theorem eRelTriple_conseq {pre pre' : ℝ≥0∞} in VCVio/ProgramLogic/Relational/Quantitative.lean (L416)
  • theorem spmf_tvDist_eq_one_sub_eRelWP_eqRel in VCVio/ProgramLogic/Relational/Quantitative.lean (L437)
  • theorem tvDist_eq_one_sub_eRelWP_eqRel in VCVio/ProgramLogic/Relational/Quantitative.lean (L444)
  • theorem triple_fork (post : α × α → ℝ≥0∞) : in VCVio/ProgramLogic/Fork.lean (L40)
  • theorem perfectlyCorrect (hc : σ.PerfectlyComplete) : in VCVio/CryptoFoundations/FiatShamir.lean (L84)
  • theorem eRelTriple_bind in VCVio/ProgramLogic/Relational/Quantitative.lean (L427)

📄 **Per-File Summaries**
  • Examples.lean: The update integrates the HHS Schnorr protocol example into the project by adding an import for Examples.HHS_Schnorr. This ensures that the formalizations and proofs related to this protocol are included in the top-level examples list.
  • Examples/HHS_Elgamal.lean: The changes complete the formal proof of IND-CPA security for ElGamal over Hard Homogeneous Spaces by replacing previous sorry placeholders with rigorous proofs and supporting lemmas. Key additions include a detailed hybrid argument, a per-hop DDH reduction bound, and the final security theorem ElGamal_IND_CPA_le_q_mul_ddh. The file now provides a fully verified bound on adversary advantage without any remaining sorry or admit markers.
  • Examples/HHS_Schnorr.lean: This file defines a Schnorr-like Σ-protocol for additive torsors (Hard Homogeneous Spaces) and formalizes its core security properties. It introduces the schnorrSigma protocol definition along with proofs for its perfect completeness, special soundness, and honest-verifier zero-knowledge (HVZK) properties. No sorry or admit placeholders are used.
  • ToMathlib.lean: This change updates the ToMathlib.lean aggregation file to include a new module for optimal couplings in probability theory. No new definitions, theorems, or sorry placeholders are introduced directly in this file.
  • ToMathlib/Control/Monad/RelationalAlgebra.lean: This change introduces a new MAlgRelOrdered instance, instStateTBoth, which enables relational reasoning between two StateT monads carrying distinct state types. It provides the definition and complete proofs for the relational weakest precondition (rwp) and its properties without any sorry placeholders.
  • ToMathlib/Probability/ProbabilityMassFunction/TotalVariation.lean: These changes generalize the etvDist_map_le and tvDist_map_le lemmas by removing the [DecidableEq β] constraint and instead using the classical tactic in their proofs. The modifications allow these theorems for total variation distance to apply to functions targeting types without decidable equality.
  • ToMathlib/ProbabilityTheory/OptimalCoupling.lean: This file establishes the compactness of the space of couplings between two SubPMFs on finite types by embedding them into a real-valued function space. It provides the topological foundations and technical lemmas necessary to prove SubPMF.exists_max_coupling, which shows that linear objective functions (such as expected values) attain their maximum over the set of possible couplings. The file contains no sorry placeholders.
  • VCVio.lean: This change updates the library's top-level imports to include new program logic modules for forking, specialized notation, and quantitative reasoning in relational and unary contexts. It also renames the foundation module for Sigma protocols from SigmaAlg to SigmaProtocol.
  • VCVio/CryptoFoundations/AsymmEncAlg.lean: This PR introduces the IND_CPA_adversary.MakesAtMostQueries definition to formally bound the number of challenge oracle queries an adversary can perform. Additionally, it refactors the hybrid argument lemmas by removing the trueProbReal abbreviation and weakening theorem hypotheses to require only equality of probabilities rather than equality of the underlying games. No sorry or admit placeholders were added.
  • VCVio/CryptoFoundations/FiatShamir.lean: This update refactors the Fiat-Shamir transformation to utilize the SigmaProtocol definition and introduces new theorem statements for its perfect correctness and EUF-CMA security. Both newly added theorems currently use sorry placeholders.
  • VCVio/CryptoFoundations/HardnessAssumptions/DiffieHellman.lean: This change generalizes the Decisional Diffie-Hellman (DDH) experiment and advantage definitions by removing unnecessary DecidableEq V type class constraints. It modifies existing definitions without introducing new theorems or sorry placeholders.
  • VCVio/CryptoFoundations/HardnessAssumptions/HardHomogeneousSpace.lean: The changes remove the unnecessary DecidableEq G typeclass constraint from the parallelTesting_experiment and parallelTestingAdvantage definitions. This modification simplifies the requirements for defining the parallel testing experiment in the context of hard homogeneous spaces.
  • VCVio/CryptoFoundations/SecExp.lean: This change modifies the SecAdv structure to require an IsPerIndexQueryBound property instead of IsQueryBound. This updates the definition of security adversaries to track and enforce query complexity bounds specifically on a per-oracle index basis.
  • VCVio/CryptoFoundations/SigmaAlg.lean: This change deletes the SigmaAlg.lean file, removing the SigmaAlg structure definition for Sigma protocols. The structure had previously defined the core components of these protocols, including commitment generation, response functions, and verification logic.
  • VCVio/CryptoFoundations/SigmaProtocol.lean: This file introduces a new SigmaProtocol structure to formalize cryptographic Σ-protocols, including fields for commitment, response, verification, simulation, and extraction. It also provides definitions for standard security properties: perfect completeness, special soundness, and honest-verifier zero-knowledge (HVZK). No sorry placeholders are used in the new definitions.
  • VCVio/EvalDist/Monad/Basic.lean: This change adds the game_rule attribute to several fundamental lemmas relating evaluation distributions and probability outputs for pure and bind operations. These updates integrate these core monadic properties into the library's automated reasoning framework for game-based proofs without introducing new theorems or sorry placeholders.
  • VCVio/EvalDist/TVDist.lean: This change generalizes the tvDist_map_le lemmas by removing unnecessary DecidableEq constraints on the map's codomain. The modifications update existing proofs to support a broader class of types and do not introduce any sorry placeholders.
  • VCVio/OracleComp/Constructions/SampleableType.lean: This PR introduces two new lemmas concerning probability distributions over uniform samples. Specifically, it adds a lemma for the invariance of uniform distributions under bijective mappings and another proving that guessing a uniform bit has exactly $1/2$ probability of success when the guess distribution is independent of the bit.
  • VCVio/OracleComp/QueryTracking/QueryBound.lean: This Lean file generalizes the IsQueryBound predicate to support arbitrary budget types, query validity checks, and cost functions, while re-implementing the original per-index query tracking as IsPerIndexQueryBound. The change updates existing structural lemmas and the PolyQueries definition to align with this new framework without introducing any sorry placeholders.
  • VCVio/OracleComp/SimSemantics/SimulateQ.lean: This change imports VCVio.Prelude and adds the game_rule attribute to the existing lemmas simulateQ_pure, simulateQ_bind, and simulateQ_query. These modifications integrate simulation semantics for queries with specialized tactics for reasoning about cryptographic games without introducing new theorems or sorry placeholders.
  • VCVio/Prelude.lean: This change introduces the game_rule simplification attribute, which is intended to categorize and collect lemmas for game-hopping proofs involving probability distributions and weakest preconditions. No new theorems, definitions, or sorry placeholders were added.
  • VCVio/ProgramLogic/Fork.lean: This file introduces the triple_fork theorem, which expresses the probabilistic forking lemma as a quantitative Hoare triple within the program logic framework. The theorem's proof currently contains a sorry placeholder.
  • VCVio/ProgramLogic/Notation.lean: This new file establishes a high-level notation and convenience layer for program logic, introducing definitions for game equivalence (GameEquiv) and advantage bounds (AdvBound). It provides several bridge theorems linking relational triples to these predicates and includes specialized tactics (game_wp, game_rel, game_hop) to automate game-hopping proofs; no sorry placeholders are used.
  • VCVio/ProgramLogic/Relational/Basic.lean: This file introduces new theorems establishing relational coupling rules for oracle queries and uniform sampling, including identity and bijection-based couplings (akin to the "rnd" rule in pRHL). These results allow for reasoning about the relationship between two programs' outputs based on transformations of their underlying random choices. The changes include complete proofs for all new lemmas and do not contain any sorry or admit placeholders.
  • VCVio/ProgramLogic/Relational/SimulateQ.lean: This new file establishes relational reasoning rules for simulateQ to support game-hopping proofs in cryptographic formalizations. It introduces theorems for preserving state invariants and output equality during oracle simulation, most notably formalizing the "identical until bad" fundamental lemma by bounding the total variation distance between simulations by the probability of a "bad" state. The file contains no sorry or admit placeholders.
  • VCVio/ProgramLogic/Unary/HoareTriple.lean: This file introduces the wp_uniformSample theorem for reasoning about uniform sampling and a wp_ite lemma for conditional branches within the quantitative Hoare triple framework. It also tags several existing weakest precondition theorems with the game_rule attribute to enhance automation, with no sorry placeholders introduced.
  • VCVio/ProgramLogic/Unary/SimulateQ.lean: This new file introduces theorems and helper lemmas that connect the quantitative weakest precondition (wp) to oracle simulation (simulateQ) and specification lifting (liftComp). It establishes that wp is preserved when simulation or lifting operations maintain the evaluation distribution of the original computation. No sorry or admit placeholders are present.
  • VCVio/ProgramLogic/Relational/Quantitative.lean: This file introduces a quantitative relational program logic (eRHL) for OracleComp by defining eRelWP and eRelTriple with $[0, \infty]$-valued pre- and postconditions. It establishes eRHL as a generalization of existing exact (pRHL) and approximate (apRHL) relational logics and provides foundational theorems, including a proof of equivalence to existing coupling-based definitions. Several structural rules and theorems relating the logic to statistical distance currently contain sorry placeholders.

Last updated: 2026-03-06 23:26 UTC.

…ain)

Define IND_CPA_allRealChallengeOracle / IND_CPA_queryImpl_allReal and the
lemma chain (allReal_eq_hybrid_on_bounded, hybrid_q_probOutput_eq_allReal,
allReal_evalDist_proj_eq_real, hybrid_q_run'_evalDist_eq_real) that proves
IND_CPA_HybridGame_q_eq_game: hybrid game at q equals the real IND-CPA
game when the adversary MakesAtMostQueries q.

Land ElGamal_IND_CPA_le_q_mul_ddh with the locked-in statement using
MakesAtMostQueries. Remove unused ddh_decomp_two_games, inline
trueProbReal, tighten longFile limit.

Four sorry's remain in the allReal simulation lemmas (term-matching
issues, not logical gaps).

Made-with: Cursor
Match upstream mathlib PR #35826 review feedback: remove
[DecidableEq β] from type signatures where it is only needed in
the proof, and use `classical` instead.

Made-with: Cursor
Complete the final allReal and projection lemmas so the HHS ElGamal IND-CPA proof closes without remaining sorries.

Made-with: Cursor
Establish the finite-support projection and coupling reconstruction lemmas so the compactness argument yields an actual maximizing coupling.

Made-with: Cursor
Prove the remaining Wave 1 eRHL bridge lemmas so the quantitative relational logic file builds cleanly except for the intended Wave 2 placeholders.

Made-with: Cursor
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.

1 participant