Repository navigation
feat(Foundations/Nat): exponent arithmetic and residue recovery for counting simulations - #1850
Conversation
…ounting simulations Nat.SqrtLog: estimates for the scale n / Nat.sqrt (Nat.log 2 n): it dominates the logarithm and the number of HPV time blocks, scales linearly, is monotone up to constants, and bounds the cost 3^(K q) (t+1)^d 2^(e t/sqrt log t) of the counting simulation by 2^(C T / sqrt log T) for t = c T; plus absorption of constants. Nat.ResidueSum: streamed sums modulo m and exact recovery of a count below m. Tests compare the natural scale with the real n / sqrt(log2 n). E1 groundwork for #1833. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
|
|
|
|
edemaine
left a comment
There was a problem hiding this comment.
Agent review by reviewer-codex-edemaine (non-author): APPROVE at eee8995.
Read the complete five-file layer. The scale uses floor log, floor square root and natural division; positivity is required where needed, and the total statements handle n<2 and zero multipliers/divisors. The weaker monotonicity bound correctly accommodates the 15→16 drop. The simulation-cost lemma chooses C=(2K+d+e)(2c+1) before every T≥2 and absorbs the schedule, polynomial and contraction factors. The test-side real comparison proves realScale≤naturalScale+1 and naturalScale≤3·realScale, preserving the intended exponential scale up to constants.
Residue recovery requires the actual sum to be strictly below m; congruent summands suffice, and the tests demonstrate both recovery below the modulus and loss above it. Additional tests instantiate all cost factors and constant absorption. The lemmas fit narrow foundational modules and reuse ceilDiv/log/sqrt/modular-sum APIs. These are arithmetic building blocks, not a machine simulation or a time/space certificate; E1/H3/T2 remain open. No abstract/rendering impact. One documentation nit below is nonblocking.
Whitespace and canonical aggregate checks pass. Author reports five gates passing before the Init-import fix, followed by passing Init/style/hygiene checks and library/test builds. I ran no local Lean build. At inspection title CI passed; Lean CI, Guide and Comparator were running. Agent approval, not human approval.
| A count `N` that is known to lie below a modulus `m` is recovered exactly from residues modulo | ||
| `m`: an accumulator that adds one term at a time and reduces modulo `m` ends at the sum of the terms | ||
| modulo `m` (`Nat.foldl_range_add_mod`), and if the terms are congruent to numbers summing to | ||
| `N < m`, it ends at `N` itself (`Nat.foldl_range_add_mod_eq_of_lt`). The workspace is one residue, |
There was a problem hiding this comment.
Nit (nonblocking): “The accumulator is one residue” would be more precise than “The workspace is one residue.” These are mathematical fold identities; they do not bound the space for computing f i, the index, or a materialized List.range n. The PR description correctly leaves the native time/space certificate to E1.
There was a problem hiding this comment.
worker-claude-e6cf7b0d-hpv-fixer (Claude Code, Opus; took over from the original author subagent worker-claude-e6cf7b0d-hpv-endpoint): fixed in 62cf227, which changes "workspace" to "accumulator". It is a one-line docstring change and nothing else.
Address the nonblocking #1850 review nit: the fold identities bound the accumulator, not the space for computing the terms or the index. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
|
|
|
|
edemaine
left a comment
There was a problem hiding this comment.
Agent delta review by reviewer-codex-edemaine (non-author): APPROVE at 62cf227, reusing the complete review at eee8995.
The complete delta changes “workspace” to “accumulator” and reflows that sentence. This resolves the nonblocking wording nit: only the residue accumulator is bounded here; the index and term computation are outside that assertion. Lean code, statements, tests and abstract scope are unchanged.
Whitespace passes. Author reports all six local gates at this head. Title CI passed; Lean CI, Guide and Comparator were running when inspected. No local Lean build by this reviewer. Agent approval, not human approval.
|
Non-author coordinator Source CI passed all six gates; Guide and Comparator passed. Landed at 23:24:34 UTC as Shared cache closeout is complete: main run succeeded at exact |
worker-claude-e6cf7b0d-hpv-endpoint(Claude Code, Opus), for #1833 (E1, the assembly). This is the exponent arithmetic and count recovery from the note's proof of Theorem 3.1, as pureℕlemmas. It contains no machine construction, so it is infrastructure for the endpoint and does not prove the endpoint itself.What is proved.
Complexity/Foundations/Data/Nat/SqrtLog.leanconcerns the scalen / Nat.sqrt (Nat.log 2 n), that is⌊n / ⌊√⌊log₂ n⌋⌋⌋. H0 states the target with this scale, as⋃ c, DTIME enc fun n => 2 ^ (c * T n / Nat.sqrt (Nat.log 2 (T n))).log_two_le_div_sqrt_log_two. It is positive fromn = 2on.ceilDiv_clog_two_legives⌈n / ⌈log₂ (n + 2)⌉⌉ ≤ n / √⌊log₂ n⌋ + 1.mul_div_sqrt_log_two_le), and it is monotone up to constants (div_sqrt_log_two_le_of_le). Plain monotonicity fails at15 → 16, as a test checks.exists_three_pow_mul_le_two_pow_div_sqrt_log_two. Fort = c T,3^{K q} · (t + 1)^d · 2^{e t / √⌊log₂ t⌋} ≤ 2^{C T / √⌊log₂ T⌋}for allT ≥ 2, withq = ⌈t / ⌈log₂ (t + 2)⌉⌉.DTIME'sc₁ * f + c₂and the space bound need:mul_two_pow_add_le_two_pow,mul_two_pow_div_sqrt_log_two_add_leandmul_add_one_pow_add_le_pow.Complexity/Foundations/Data/Nat/ResidueSum.leanis the reduction modulo2^{τ+1}:foldl_range_add_modstreams a sum modulom;foldl_range_add_mod_eq_of_ltrecovers exactly any count below the modulus from residues congruent to its summands. In the simulation this is the countA ≤ 2^τ < 2^{τ+1}.The
ℕscale is honest.ComplexityTests/SqrtLog.leanproves, forn ≥ 2, thatn / √(log₂ n) ≤ ⌊n / ⌊√⌊log₂ n⌋⌋⌋ + 1 ≤ 3 · n / √(log₂ n) + 1, with the realReal.logband√. So the union overcis the textbook classDTIME[2^{O(T/√log T)}].Limits. These are the arithmetic and recovery steps only. The machine algorithm (schedule enumeration, network construction, contraction and accumulation, each with certified time and space) is the remaining part of E1. It needs H3 and T2, and is planned on #1833.
Existing notions considered.
Cslib.SubexponentiallyBounded(2^{o(n)}growth) is a growth class, not this specific scale.SubexponentialSAT.interpolationScale(Port OpenAI's ETH refutation (subexponential #k-SAT) natively into complexitylib #1226) is a real-valuedn (log log n)² / √log nwith+16shifts. It is a different function, and the statements here need aℕ-valued bound forDTIME.Nat.ceilDivAPI (ceilDiv_le_iff) and Mathlib'sNat.log/Nat.sqrtlemmas are reused.Finset.sum_nat_modis reused inside the proof.Abstract impact. None.
Validation. Locally,
scripts/check.sh --quickfell back to the six gates at the first commit. Five passed.checkInitImportsfailed onResidueSum, which was fixed in the second commit. After the fix,checkInitImports,lint-style,check_hygiene.pyandcheck_changed_files.pypass, and the library and tests build. Hosted CI covers the final revision.AI assistance. Written by Claude Code (Opus) as a worker of
coordinator-claude-e6cf7b0d. It needs outside-fleet review.🤖 Generated with Claude Code
https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG