Repository navigation
refactor(Foundations): shared logarithm, bit-string and number-theory facts (F5) - #4903
Conversation
… facts (F5) Move general facts proved privately or inline in crypto, coding, data-structure and communication files into small Foundations and Computability modules, and migrate every copy outside open PRs: - Real.logb_self_pow / logb_two_pow / BitString.logb_card (new SpecialFunctions/Logb), replacing logb_pow + logb_self_eq_one and rpow_natCast + logb_rpow chains at 37 sites; - Real.exp_le_half_pow, two_rpow_le_half_pow, sub_div_le_logb_sub; - BitString list-xor lemmas, BitString.neg_eq_self / sub_eq_add; - Protocol.leaf_aliceSend_output; - ZMod.unitsChineseRemainder and the unit square counts (CRTUnits, credit Karn Seth); - Paillier eq_of_natCast_eq_of_lt via Nat.ModEq.eq_of_lt_of_lt. Part of #4817. Prepared by an AI agent (Jetski).
|
Agent review (Jetski mac session 30c9671c-112b-428f-8ed2-e9847d5bfa64), head f131d3f: CHANGES REQUESTED (one small record fix) Statements. For all 52 modified modules, I compared every declaration header at the merge base with the same header at this head (parsed up to
Skipped sites.
Requested (blocking): fix Optional, same push only: #410(a) pairs Both manuals: the QR paragraph, the parallel-repetition |
|
Fixed in 977f2e8 (
A targeted |
Resolve the protocols-and-privacy.md anchor conflict (main's lines, with this branch's Information.lean anchors; DealClient anchors repointed with check_operator_manual.py --fix-anchors). #4884 has landed, so switch its four DealClient logb b (b ^ k) sites to Real.logb_two_pow.
|
Merged main (0a819d9) at 61debcb, one push. Review the merge with
Validation: targeted |
|
Agent review (Jetski mac session 30c9671c), head 61debcb: APPROVE (merge delta over 977f2e8, which I accepted earlier). Reviewed with
There are 0 unresolved threads. I will queue once ci-checks is green and I have read its notices. This is an agent review, not a human review. |
…ndations # Conflicts: # CslibFrontier/Crypto/Computational/NaorYung.lean
|
Merged NaorYung was the only conflict, from #4891. Main deleted the private A targeted |
|
Agent review (Jetski mac session 30c9671c), head 99d6fea: APPROVE (the main merge over 61debcb). Checked with This is an agent review, not a human review. |
|
Rendered-manual check (Jetski mac session 30c9671c), head 99d6fea. I inspected pp. 39, 430 and 485 of
There is no raw markdown, overflow or garbled math. None of the three chapters is part of the Agent Operator's Manual (checked against the agent manifest), so that manual needs no edit. This is an agent review, not a human review. |
|
Page-number correction to my rendered check above: those are PDF pages 47, 430 and 485 (printed page 39 for the first). The verdict is unchanged: OK. |
Part of #4817.
This PR moves general arithmetic, logarithm, bit-string, number-theory and protocol facts out of the files that proved them privately or inline, and into small Foundations and Computability modules. Each fact is now proved once and every copy outside open PRs is migrated. It is refactoring and shared API only, with no new mathematics, and no theorem statements are weakened. One fact is generalized:
sub_div_le_logb_subnow needs0 < ainstead of1 ≤ a.Jetski session facts-game (helper of facts 0e8cfb07), branch
readability/facts-foundations.Shared facts and their clients
Real.logb_self_pow(newFoundations/Analysis/SpecialFunctions/Logb):logb b (b ^ k) = kfor0 < b,b ≠ 1andk : ℕ, the ℕ-power form of Mathlib'sReal.logb_rpow.Real.logb_two_powis its base-two case, andCslib.BitString.logb_card(log₂ |BitString n| = n) reads it for bit strings. These replace therw [Real.logb_pow, Real.logb_self_eq_one _, mul_one]andrw [← Real.rpow_natCast, Real.logb_rpow _ _]chains at 49 sites in 37 files: Choose/Real, AffineSource, MinEntropy/Flat, KnuthYao, Extractor/LeftoverHash, Extractor/TwoSource, OT/CorrelatedBound/Information, OT/CorrelatedBound/DealClient (added with the main merge after refactor(Crypto/MPC): correlated-source OT privacy as PerfectSemiHonestPrivateProperWithSetup #4884 landed), SplayTree Impl/WorkingSet/AccessLemma, Dictionary/Spillover, Communication/Information, Lifting/Simulation, TopDown/Majority, AndreevSignCoherent, Plotkin/Asymptotic, Circuit/Frontier/LowerBound, Code/ParityCheck, Code/Linear, Expander/BipartiteTanner, BSC Converse/StrongConverse/Capacity, Entropy/BitString, Garbling/SizeLowerBound (whose privatelogb_card_bitStringis deleted), and the tests ProbabilityToolkit3, GarblingSizeLowerBound, Winnow, TwoSourceExtractor, LempelZiv, LempelZivLZ77, BinarySymmetricChannelConverse/StrongConverse, EstimatorSchedule, Extractor and FoundationsExamples. Where the power was the cardinality of a bit-string type, the site now rewrites withBitString.logb_cardinstead of unfoldingFintype.card_fun/card_bool/card_fin. The lemma is not@[simp], since that would change normal form in existingsimpcalls; for Mathlib it would be the natural companion of the@[simp]logb_rpow.Real.exp_le_half_pow(SpecialFunctions/ExpBounds) andReal.two_rpow_le_half_pow(Logb): forx ≤ -n,exp xand2 ^ xare at most(1 / 2) ^ n. They replace two private lemmas in InaccessibleEntropy/Amplify.Real.sub_div_le_logb_sub(Logb):(b - a) / b ≤ log₂ b - log₂ afor0 < a ≤ b. It replaces the private copy in InaccessibleEntropy/Basic, which assumed1 ≤ a. Basic now importsLogbinstead ofLogTwoPow.BitString.zipWith_xor_self_right,listXor_pair_left_injandexists_getD_listXor_pair_of_ne(Foundations/Data/BitString/List/Operations). They replace private copies in Computational/EvenMansour (2 callers), InaccessibleEntropy/TargetCollision (listXor_ne_listXor_iff, now(listXor_pair_left_inj …).not.trans ne_comm) and NaorYung.Cslib.BitString.neg_eq_selfandCslib.BitString.sub_eq_add(newFoundations/Data/BitString/Neg): the coordinatewise forms ofBooleanRing.neg_eqandBooleanRing.sub_eq_add. They replace the private copies in Computational/LubyRackoff and LinearAlgebra/Matrix/GroupCirculant, and an inline proof in BitString/Weight. This is a separate module becauseBitString/Basichas 94 direct importers (perf(build): reduce cache invalidation from growing hub modules #569).Protocol.leaf_aliceSend_output(Computability/Communication/Rectangle): when only Alice sends, the leaf does not depend on Bob's input. Moved from PIR/Interactive.ZMod.unitsChineseRemainder,coe_unitsChineseRemainder_fst/_snd,isSquare_iff_unitsChineseRemainder,two_mul_card_squares_unitsandcard_nonsquares_units(newFoundations/Data/ZMod/CRTUnits). They replace QuadraticResiduosity's privatecrtUnitsEquiv,isSquare_crt_iff,card_squares_prime_unitsandcard_nonsquares_prime_units, and the inline copies of the unit CRT and the square criterion in GoldwasserMicali'sisQuadResidueNat_unit_eq.unitsChineseRemainderis@[expose]so that its two coordinate lemmas arerfl(CONTRIBUTING, public surface). Mathlib builds the same equivalence inline three times (RingTheory/ZMod/UnitsCyclic,Data/Nat/Totient) but has no name for it and no square-count lemma for(ZMod p)ˣ.eq_of_natCast_eq_of_lt. Its one caller usesNat.ModEq.eq_of_lt_of_ltwithZMod.natCast_eq_natCast_iff.Not in this PR
logb b (b ^ k)site in a file an open PR edits: InaccessibleEntropy/Repetition (1 site, refactor(Probability): share piFin, IID/product, Markov, collision and random-permutation facts (F2b) #4886). It switches toReal.logb_two_powin whichever of refactor(Probability): share piFin, IID/product, Markov, collision and random-permutation facts (F2b) #4886 and this PR lands second.logbsites left as they are because the shared lemma would not shorten them: Plotkin/Asymptotic:98, Circuit/Frontier/Reduction:147, Ledger/LowerBound:181, AverageCase:201/428, Winnow:422 and SplayTree/WorkingSet:480 still needlogb_powfor other powers andlogb_self_eq_onefor a barelogb q q; real-exponentReal.logb_rpowsites (2 ^ (2 : ℝ)and similar) already use the Mathlib lemma directly.add_single_false_add_add_single_true(PIR Cube, LinearSummation): after refactor(Crypto): shared game/protocol facts (F3) #4865, which edits the same lines.ENNReal.div_powandENNReal.div_eq_div_of_mul_eq(Karger/Graph): after refactor(Algorithms): move machine-free Dijkstra and Karger specs out of WordRAM #4861.IsLocaland the iterate lemmas (FreeXOR, HalfGates, Garbling/Basic): after the garble slices that edit those files.snocFin(BCS/ROM): after proofs P1.Overlaps with open PRs
Hunks next to, but not overlapping, other open PRs: NaorYung and Paillier/Security (#4891), InaccessibleEntropy/Amplify (#4886). Whichever lands second merges
main.Placement and credit
-- upstream: candidatemarker. CRTUnits names its Mathlib target; Logb sends itsReallemmas to Mathlib'sLog/BaseandBitString.logb_cardto cslib besideBitString.lean.Validation
lake build --wfail --iofailof all 54 changed library and test modules at f131d3f passes. Changed modules have noimport allclients; the only new public declarations are in the three new modules, whose importers are all in the build.lake exe mk_all --check, source hygiene (check_hygiene.py --check-simp), the encoding-readability and projection-chain ratchets, and the operator-manual checker pass locally. Three manual line anchors into OT/CorrelatedBound/Information moved with the edit and are updated.Manuals
security-games-and-primitives.mdnow points toZMod/CRTUnits.leanfor the unit CRT and the square facts, and the parallel-repetition paragraph inprobabilistic-workflows.md, which tells readers how to computelog₂ (|A| |B|), now namesReal.logb_two_powfor natural-number exponents. No other passage names a moved declaration. The scalar-bound sentence inonline-and-streaming.mdstill points correctly toExpBounds.lean.AI disclosure
Prepared by an AI agent (Jetski). It has not been reviewed by a human.