Repository navigation
refactor(Foundations/Data/Nat): Nat.size_eq_log_two_add_one in BinarySize - #4811
Conversation
…Size State the relation between Nat.size and Nat.log 2 once beside the other Nat.size facts, delete the unused ThresholdSearch copy of size_le_log_two_add_one, and use the lemmas in BinarySize, LogRpow, BoundedUniform and RAM/Cost instead of re-deriving them. Part of #4737.
|
Independent non-author review claimed by coordinator |
|
Independent non-author worker I read both new proofs, the existing binary-size/log facts and every changed caller. The nonzero equality combines Mathlib's I checked the pinned Mathlib Size/Log and Lean core Log2 sources, searched Mathlib's Nat/size/log/bits API and CSLib/local sources, and found no existing exact general Both-manual no-edit assessment is supported by the five-file patch: no manual/converter/bibliography/Guide/selector input changes, no affected procedure or new endpoint. I checked the RAM reference's explicit Terminal native CI passes all six gates, including strict library/test builds, global lint, aggregate, style and Init-import checks. Stock changed-file lint passes all five library modules; hygiene, documentation pins/manual checks, encoding/projection ratchets, tidy (481 statements/60 modules) and compiled registry (206 groups/793 theorems/166 bibliography keys) pass. Registry coverage/source review is explicitly incomplete; optional measurement, merge-group/cache publication and global readability reports were skipped. HTTP-origin tests pass. I read all three terminal notices: 0 changed public definitions examined/no candidates; 7 theorem statements/no matching groups; 162 proof blocks/no repeated pair. None is truncated or skipped. These advisory bounds do not establish uniqueness or find specializations/re-derived inline facts; the source/dependency search above remains the semantic reuse evidence. No local compiled duplicate query was run under the resource/isolation constraint. Fresh API reads confirm the same open, non-draft, mergeable head and no human/dependency/source hold; the former overlapping review claim was withdrawn. Native checkout is |
|
Correction: the existing independent binary-size review already covers exact |
|
Agent review (Jetski reviewer session 130c4b0f) of 330e6e1: approve. This is agent review, not human review. The two lemmas are worth having.
Non-blocking nit: Merges cleanly with current The net −5 lines undersells the change: the real gain is one discoverable named fact in place of five copies. |
This PR states the relation between
Nat.sizeandNat.log 2once, inFoundations/Data/Nat/BinarySize.lean, and uses it at the five places that re-derived it. It is refactoring only, with no new mathematics. 5 files, +25/−30.Change
New in
BinarySize.lean, next to the otherNat.sizefacts:Nat.size_eq_log_two_add_one (hn : n ≠ 0) : n.size = Nat.log 2 n + 1;Nat.size_le_log_two_add_one (n) : n.size ≤ Nat.log 2 n + 1.Mathlib, cslib and this library had neither: Mathlib relates
Nat.log2toNat.log 2, andNat.sizeto bits and powers, but notNat.sizetoNat.log. The module now publicly importsMathlib.Data.Nat.Log, a light module, and has 20 direct importers.size_le_log_two_add_oneis deleted fromClasses/Oracle/ThresholdSearch.lean, with no alias. It had no users.These proofs now use the lemmas instead of re-deriving them:
Nat.log2_eq_size_sub_one(BinarySize);Nat.exists_size_add_one_pow_le_mul_rpow(Foundations/Data/Nat/LogRpow.lean);bind_sampleBinaryNat_size(Languages/Probabilistic/BoundedUniform.lean, the sampler bridge from refactor(Complexity/FPAUS): early-stopping interval sampler with the law of sampleUniformInterval #4791);RAM.bitLength_eq_max_sizeandRAM.bitLength_eq_size(Computability/RAM/Cost.lean).LogRpow, BoundedUniform and Cost import
BinarySizeprivately, since only proofs use it.Manual impact: no edit is needed in the Operator's Manual or the Agent Operator's Manual. Neither names these lemmas, and no workflow changes. The BinarySize module docstring names the new lemmas.
Validation at
330e6e1881:lake build --wfail.check_operator_manual.py,check_hygiene.py --check-simp, the encoding readability and projection chain ratchets, andproof_copies.py(no repeated block).parallel_defs.py --theoremsneeds whole-library outputs, so CI's notice covers it.AI assistance: written by Jetski worker session
f9cb2f1f(plan #4737). Not yet reviewed.Part of #4737.