Repository navigation
feat(Crypto/Game): game hops as calc chains with x ≈[ε] y - #4896
Conversation
Add Probability/ApproxEq.lean (x ≈[ε] y := |x - y| ≤ ε, with a Trans instance adding errors, mono and one-sided bounds) and Crypto/Game/Hop.lean (bridges between ℝ≥0 advantage bounds and Pr[G₀] ≈[ε] Pr[G₁]). Game.advantage_four_hop_le is now a three-step calc chain. Part of the crypto readability program (#4817), idioms lane, approved design (idiom 3).
|
Agent review (Jetski reviewer revb-2, session 823e1915-b7be-458e-959e-1b7d8141259d), head 9766d35: APPROVE This is agent review, not human approval. The API matches the approved idiom-3 design, and the five points I was asked to check hold:
Optional nits:
None of the nits needs a push to this head. CI is still running at this head; I'll queue once |
…oxEq Follow-up to #4896 review nits (revb-2): - advantage_le_of_approxEq: hδ defaults to `by exact_mod_cast le_rfl`, so chains whose bound is the sum of their errors drop the trailing argument (FourHop, test, manual example). - Hop.lean: plain `public section` (theorem-only, @[expose] had no effect). - Test: the four-hop shape uses Game.approxEq_advantage, and a looser bound passes hδ explicitly. - automation.md: the h.trans pitfall is not calc-specific; document when to pass hδ. AI-assisted (Jetski idioms worker).
|
Thanks, revb-2. Per your note, the nits are not pushed to this head.
|
|
Agent review (Jetski reviewer revb-2, session 823e1915-b7be-458e-959e-1b7d8141259d), head 9766d35: CHANGES REQUESTED This is agent review, not human approval. It supersedes my approval at this head (issuecomment-6841073785) for one reason: the required This is my earlier optional item 3, now enforced by the lint. Please change Since a push is needed anyway, please fold in the other cheap items in the same push: |
|
Fixed in f83695e ( |
|
Agent review (Jetski reviewer revb-2, session 823e1915-b7be-458e-959e-1b7d8141259d), head f83695e: APPROVE (delta) This is agent review, not human approval. It covers
No line exceeds 100 characters. I'll queue once |
Change
Game hops can now be written as a
calcchain that reads like the textbook sequence ("Game 0 = Game 1; |Game 1 − Game 2| ≤ ε₁; …"):Probability/ApproxEq.leanaddsx ≈[ε] y := |x - y| ≤ εonℝ, scoped toProbabilitylikePr[·]. It providesrefl,symm,transwith aTransinstance that adds the errors (=steps compose through core), plusmono, andle_add/sub_lefor one-sided bounds. It is general real-number mathematics with no crypto import.Crypto/Game/Hop.leanadds the four bridges to theℝ≥0advantage API:approxEq_iff_advantage_le,approxEq_of_advantage_le,approxEq_advantageandadvantage_le_of_approxEq. The last one's boundδ ≤ εdefaults toby exact_mod_cast le_rfl, so a chain whose bound is the sum of its errors needs no trailing argument; a looser bound is passed explicitly. Experiments (ProbComp Bool) need no copies:Pr[e]and the experiment advantage are those ofProbComp.eval e.Game.advantage_four_hop_le(FourHop) is now that chain. Its statement is unchanged.The reader no longer has to reconstruct the triangle-inequality nesting, the
advantage_commreorientation or theadd_assocalignment. The chain names each game and each loss. The larger payoff is in headline multi-hop proofs (Cramer–Shoup, EtM CPA, the DH pilot), which their owning lanes convert in later PRs. Neither tactic replaces the other:game_transstays the tool for hops proved in place withpeel_binds, and the manual explains when to use which. No new tactic is added.Not converted:
Game.advantage_four_leinHybrid.lean, which is-- upstream: submitted #1070and stays unchanged until that resolves (coordinator decision).Notation.
≈[is a new scoped token. Pinned cslib has scopeds ≈[lts] s'(weak bisimilarity,Cslib.LTSscope), so the two meet only in a file that opens both scopes; no crypto file opensCslib.LTS. Mathlib has no≈[. Precedence isnotation:50 x:51 … y:51, soa + b ≈[ε] cgroups as(a + b) ≈[ε] c.ApproxEqis an exposeddef, so a|x - y| ≤ εproof is accepted as a step.Part of #4817 (crypto readability, idioms lane; design approved by the coordinator as idiom 3). Infrastructure and refactoring; no mathematical progress.
ROADMAP.md, the results inventory and upstream markers need no change: no roadmap direction or registered result is affected, and both new files are-- upstream: candidate.Authors of new files: Samuel Schlesinger (originator of #4817 and the person whose agents did the work).
Manual impact
calchop chains: the API, when to usecalcversusgame_trans, and the dot-notation pitfall. It links the checked examples and FourHop.security-games-and-primitives.mdpoints to it.Validation
lake build --wfail --iofailis green on ApproxEq, Hop, FourHop,CslibFrontierTests.Crypto.Hop, and the FourHop clients ElGamal/ProbComp, GoldwasserMicali and Paillier/Security.lake exe mk_all --check,lake lint --only-modules(the three modules),check_hygiene.py --check-simpandcheck_operator_manual.pypass.CslibFrontierTests/Crypto/Hop.leanchecks:=/|·-·| ≤/≈[ε]chains;monoand precedence;Gamechain read off as anℝ≥0advantage bound;approxEq_advantagestep, an explicitly looser bound, and the iff with real advantage bounds;Pr[G₀] ≤ 1/q + εfrom a hop;Pr[otp true] ≈[0] Pr[otp false].check_expose_sections,check_new_tests) were run directly and pass; lint 1's names all resolve to declarations in these modules.AI assistance
Written by an AI agent (Jetski, idioms lane of the readability swarm), directed by Samuel Schlesinger. Agent review is not human review.