Skip to content

refactor(Complexity/FineGrained): move the function-rate tower to FunctionRates - #4747

Merged
SamuelSchlesinger merged 1 commit into
mainfrom
refactor/cx-finegrained-rates-move
Nov 12, 2026
Merged

SamuelSchlesinger merged 1 commit into
mainfrom
refactor/cx-finegrained-rates-move

Conversation

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator

Change

This moves the parameterized function-time tower out of FineGrained/CountingExponents.lean into a new module, FineGrained/FunctionRates.lean. The tower covers ComputableInTimeO, ComputableInExpTime and ComputableInSubexpTime, their FTIME and decision bridges, and their reduction transfers. The moved code is unchanged, and no declaration is renamed or restated.

The tower is generic and has nothing to do with #k-SAT. Before this change, a client that needed only function rates had to import the whole counting module. That module pulls in sparsification and counting-tree machinery. Randomized.lean (and through it GapETH.lean) now imports FunctionRates and Exponents directly instead of CountingExponents. CountingExponents re-exports FunctionRates through a public import, so existing importers, including SingleSubexp and the files owned by other open PRs, compile unchanged.

  • Lines: +365/−320 (net +45). That covers the new file's header and docstring, the narrower CountingExponents docstring and the manual split. No proof copies are added or removed; this is a pure move.
  • Randomized's docstring chain no longer mentions sharpSatExponent, which that module never proved anything about.

Manual impact

  • Operator's Manual. manual/machines-and-classes/native-counting.md now lists FunctionRates as its own bullet ("Function rates"), and the module count in the section intro goes from four to five. The CountingExponents bullet keeps only the counting content.
  • Agent Operator's Manual. No edit needed. It names no FineGrained module or declaration, and no workflow changes.
  • Other docs. ROADMAP.md, results/README.md and CslibFrontierResults/ do not mention the moved declarations or CountingExponents.

Validation

Local scripts/check.sh --quick fell back to the full check because the import aggregate changed. Every Lean gate and audit passed: lake build, lake test, lake lint, lint-style, checkInitImports, mk_all --check, the ratchets, documentation pins, the tidy statement ratchet, result registry references and changed-file lints. I stopped the run during the final step, which re-elaborates outputs restored from the shared cache, to free a shared build slot. CI covers that step.

AI assistance

Jetski worker session 3a99a381, plan #4737.

Part of #4737

…ctionRates

Move ComputableInTimeO/ExpTime/SubexpTime and their FTIME, decision and
reduction-transfer lemmas verbatim from CountingExponents into a new
FineGrained/FunctionRates module. CountingExponents re-exports it, and
Randomized imports FunctionRates and Exponents instead of the #k-SAT module.

Part of #4737
@edemaine

edemaine commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Landed as c464441de4d2adb56f306a3c9326622c80a01329 on 2026-11-12 at 18:51:50 UTC. The FunctionRates extraction and migrated imports are integrated; broader #4737 remains open.

APPROVED at 6685d72f7c540f1b12457590861f064960f90029: final independent source/API/validation/manual review clears the earlier native/notices hold. The guarded helper found that exact head already queued; I made no duplicate queue mutation. No source edit or local Lean/Lake build. Agent review, not human approval.

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

Agent review (Jetski reviewer session c48d78b7) of 6685d72: approve

This is agent review, not human review. I did not write or design this change.

Pure move, verified mechanically. Old CountingExponents.lean lines 108–407 (### Parameterized function time bounds through end FunctionMachines) are byte-identical to the new FunctionRates.lean lines 52–351. All 18 declarations keep their statements, proofs, attributes, docstrings and @[expose] (only the three definitions). None is private and none is renamed. Outside that block, CountingExponents changes only its imports and module docstring. Its new docstring and Main results drop exactly the moved entries, and every name listed in FunctionRates' docstring exists there.

Imports and clients. CountingExponents re-exports FunctionRates through public import. Its import closure is therefore unchanged, and SingleSubexp, RatesNativeEndpoint and CslibFrontierTests/FineGrainedRates compile as before. SingleSubexp uses SharpKSAT/SharpETH API, so it rightly keeps that import. Every private import of FunctionRates is used by the moved proofs: Bounds (reduction_add_time_le, two_rpow_le_natCeil_mul_of_le_mul_add), Nat.Power, ResourceFacts, OCombinators and PolyTime.Bounds. Randomized needs only Exponents and FunctionRates; it uses no #k-SAT names. The new import closure drops CountingExponents, Sparsification, CountingTreeBound and Reduction: Randomized goes from 453 to 396 project modules and GapETH from 545 to 490. The docstring edit that removes sharpSatExponent from the Randomized chain is correct, since that module proves nothing about it.

Open PRs. I fetched all 54 other open heads and grepped their changed files for imports of CountingExponents, Randomized, GapETH or FunctionRates, and for the moved names. The only hits are the generated CslibFrontier.lean aggregates, and those are not touched near the new line. None of #4530, #4515, #4150 or #2532 imports these modules or uses the moved names.

Placement and name. A sibling module, rather than an append to the FineGrained hub, follows the topic-module rule. The module keeps each notion together with its FTIME/decision bridges and reduction transfer, which mirrors how Reduction holds the decision-side transfers. FunctionRates matches the manual's "rates" vocabulary and RatesNativeEndpoint, and it avoids a clash with Classes/FunctionTime.

Manuals. The Operator's Manual edit is accurate: it now lists five classical modules (FunctionRates, CountingExponents, SingleSubexp, Randomized, GapETH) plus the RatesNativeEndpoint leaf. FunctionRates imports neither CountingNativeEndpoint nor any counting module, and it does use Bounds. The Agent Operator's Manual needs no edit, since it names no FineGrained module. ROADMAP.md, results/ and CslibFrontierResults/ do not mention the moved names.

Non-blocking nits (fine as a follow-up or not at all):

  • CountingExponents still privately imports CslibFrontier.Foundations.Data.Nat.Power and ...MultiTape.Internal.ResourceFacts. Their only users (add_one_pow_le_of_le_mul_pow, ComputableInTimeAndSpace.exists_space_linear/length_le) moved out, and neither module declares attributes, instances or notation. Both are still reachable through FunctionRates, so removing them changes no build graph; it would just be tidier.
  • The RatesNativeEndpoint module docstring lists the classical modules as "CountingExponents, SingleSubexp, Randomized, and GapETH". It could add FunctionRates to match the manual's new count of five.

CI and advisory notices. ci-checks, build and guide pass at this head. The Parallel-definition notice (3 examined) and the Duplicate-statement notice (15 examined) are empty. All three Repeated-proof-block candidates pair ComputableInExpTime.ite_polyTime with ComputableInSingleSubexpTime.ite_polyTime or with the two SharpKSAT_length_of_numVars theorems. Every one predates this PR: the detector flags them only because the verbatim-moved proof now sits in a new file. The shared lines are the set L / 1 ≤ L + 1 / 1 ≤ 2 ^ x scalar setup. Folding them into a lemma would be new proof work, outside the scope of a pure move, so these need no action here.

@SamuelSchlesinger
SamuelSchlesinger added this pull request to the merge queue Nov 12, 2026

@edemaine edemaine left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

APPROVE 6685d72f7c540f1b12457590861f064960f90029 — independent non-author agent reviewer-codex-edemaine. The complete five-file refactor is clean; the earlier validation hold is cleared.

The entire 299-line function-rate block is byte-identical, preserving names, statements/proofs, namespace, public visibility and explicit definition exposure. CountingExponents publicly re-exports the new module; no aliases are introduced. I checked the actual randomized promise monotonicity/reduction callers, SingleSubexp bridges and counting clients. Their encodings, existential workspace and single-machine versus rate-family quantifiers remain unchanged. The source import graph confirms that Randomized and GapETH no longer reach CountingExponents/Sparsification; their internal closures shrink by 57 and 55 modules respectively. New placement and preserved credit/upstream marker fit the generic API; the aggregate adds the intended module only.

Current native CI passes all six gates and stock changed-file checks, and Guide examples pass. The tested merge e15ddc84 retains all own module/manual blobs; its aggregate also incorporates incoming main. I read all three actual reports: no parallel candidate among 3 definitions or duplicate among 15 statements; three repeated-block pairs among 151 proofs. Both sides were inspected: they share only the existing 4–5-line real-length/nonnegativity setup before different exponential/single-machine/counting clocks. The moved body is unchanged, and another helper for that setup would add no useful mathematical API. No report is truncated; these scans do not prove uniqueness.

Both-manual QA is clear. Artifact 13971130577 matches API/download ZIP digest, clean exact source, all 72+1 chapters, converters, bibliography/362 keys and both PDF hashes; hosted checks cover generated TeX/diagrams. Operator page 203 (printed 195) readably separates function rates from counting rates and locates their imports. Agent guidance needs no edit because roles/workflows are unchanged; no roadmap, inventory or abstract endpoint changes. No local Lean/Lake build or source edit. Agent review, not human approval.

SamuelSchlesinger pushed a commit that referenced this pull request Nov 12, 2026
… acceptCount

Address review on #4759: the yes-clause of `SolvesWithOneSidedError` is now
`2 ^ p(n) ≤ 2 * acceptCount V a (p(n))`, definitionally the same count. Clients drop the
redundant `change … acceptCount …` and `rw [← acceptCount]` refolds (RP, RP/Closure,
FineGrained/Randomized); FineGrained/Randomized also uses `acceptCount_eq_zero_iff` instead of an
inline re-derivation. `mem_PromiseCoRP_iff` (statement unchanged), both MillerRabin modules and
the test ResourceClasses4 adapt to the count.

FineGrained/Randomized edit approved by coordinator 33f8b11c; disjoint from #4747 and #4758.
Part of #4737. Jetski worker session ed4d7a73.
Merged via the queue into main with commit c464441 Nov 12, 2026
7 checks passed
@SamuelSchlesinger
SamuelSchlesinger deleted the refactor/cx-finegrained-rates-move branch November 12, 2026 18:51
orbitingflea pushed a commit to orbitingflea/complexitylib2 that referenced this pull request Nov 12, 2026
…cceptCount (cslib-community#4759)

* refactor(Complexity/Classes): state randomized error bounds through acceptCount

Add acceptCount characterizations of BoundedErrorAt and ErrorExponentAt
(boundedErrorAt_true_iff/_false_iff, errorExponentAt_true_iff/_false_iff) and
acceptCount_eq_zero_iff; state the ZPP answer count and the RP error-exponent
yes-clause through them; shorten the .congr/.not proofs and move clients off the
re-derived accept/reject split.

Part of cslib-community#4737. Jetski worker session ed4d7a73.

* refactor(Complexity/Classes): state RP's one-sided yes-clause through acceptCount

Address review on cslib-community#4759: the yes-clause of `SolvesWithOneSidedError` is now
`2 ^ p(n) ≤ 2 * acceptCount V a (p(n))`, definitionally the same count. Clients drop the
redundant `change … acceptCount …` and `rw [← acceptCount]` refolds (RP, RP/Closure,
FineGrained/Randomized); FineGrained/Randomized also uses `acceptCount_eq_zero_iff` instead of an
inline re-derivation. `mem_PromiseCoRP_iff` (statement unchanged), both MillerRabin modules and
the test ResourceClasses4 adapt to the count.

FineGrained/Randomized edit approved by coordinator 33f8b11c; disjoint from cslib-community#4747 and cslib-community#4758.
Part of cslib-community#4737. Jetski worker session ed4d7a73.

* docs(manual): follow primes_mem_coRP to its new line

The hsplit simplification in Problems/Primes/MillerRabin moved primes_mem_coRP from L321 to L318.

Part of cslib-community#4737. Jetski worker session ed4d7a73.

* refactor(FineGrained): use acceptCount_eq_zero_iff in the PromiseRP converse

---------

Co-authored-by: copositive <copositive@jetski>
orbitingflea pushed a commit to orbitingflea/complexitylib2 that referenced this pull request Nov 12, 2026
…in Bounds (cslib-community#4782)

* refactor(Complexity/FineGrained): move the function-rate tower to FunctionRates

Move ComputableInTimeO/ExpTime/SubexpTime and their FTIME, decision and
reduction-transfer lemmas verbatim from CountingExponents into a new
FineGrained/FunctionRates module. CountingExponents re-exports it, and
Randomized imports FunctionRates and Exponents instead of the #k-SAT module.

Part of cslib-community#4737

* refactor(Complexity/FineGrained): shared envelope and rescale lemmas in Bounds

Add exponential-times-polynomial envelope lemmas (one_le_two_rpow_mul_pow,
two_rpow_mul_pow_le_two_rpow_mul_pow, pow_le_two_rpow_mul_pow,
two_rpow_mul_pow_le_natCeil_mul_add, le_two_mul_mul_of_le_mul_add) and the subexponential
rescaling step natCast_mul_div_add_one_le to FineGrained/Bounds, and use them for the
TimeO/ExpTime/SubexpTime monotonicity, intersection, if-then-else and measure-change
transfers in FineGrained, FunctionRates, Exponents, CountingExponents and Randomized.

Also folds in the cslib-community#4747 review nits: drop CountingExponents' unused Nat.Power and
ResourceFacts imports, and list FunctionRates among RatesNativeEndpoint's classical modules.

Part of cslib-community#4737.

* refactor(Complexity/FineGrained): absorb single-machine exponentials with the Bounds envelope lemmas

Add two_rpow_mul_pow_le_natCeil_mul_add_of_le and use the envelope lemmas in
SingleSubexp (subexp transfer, machine characterisations, mono_measure,
ite_polyTime, polyBounded decision, SharpKSAT_length_of_numVars).

* refactor(Complexity/FineGrained): finish the Bounds migration in Reduction, Sparsification, ExhaustiveSearch and Randomized

Use two_rpow_mul_pow_le_natCeil_mul_add, two_rpow_le_two_rpow_mul_of_le_mul_add and
natCast_mul_div_add_one_le for the remaining inline copies; list
two_rpow_le_two_rpow_mul_of_le_mul_add in the Bounds main results.

---------

Co-authored-by: copositive <copositive@jetski>
orbitingflea pushed a commit to orbitingflea/complexitylib2 that referenced this pull request Nov 12, 2026
…bounds across exponent towers (cslib-community#4793)

* refactor(Complexity/FineGrained): move the function-rate tower to FunctionRates

Move ComputableInTimeO/ExpTime/SubexpTime and their FTIME, decision and
reduction-transfer lemmas verbatim from CountingExponents into a new
FineGrained/FunctionRates module. CountingExponents re-exports it, and
Randomized imports FunctionRates and Exponents instead of the #k-SAT module.

Part of cslib-community#4737

* refactor(Complexity/FineGrained): shared envelope and rescale lemmas in Bounds

Add exponential-times-polynomial envelope lemmas (one_le_two_rpow_mul_pow,
two_rpow_mul_pow_le_two_rpow_mul_pow, pow_le_two_rpow_mul_pow,
two_rpow_mul_pow_le_natCeil_mul_add, le_two_mul_mul_of_le_mul_add) and the subexponential
rescaling step natCast_mul_div_add_one_le to FineGrained/Bounds, and use them for the
TimeO/ExpTime/SubexpTime monotonicity, intersection, if-then-else and measure-change
transfers in FineGrained, FunctionRates, Exponents, CountingExponents and Randomized.

Also folds in the cslib-community#4747 review nits: drop CountingExponents' unused Nat.Power and
ResourceFacts imports, and list FunctionRates among RatesNativeEndpoint's classical modules.

Part of cslib-community#4737.

* refactor(Complexity/FineGrained): absorb single-machine exponentials with the Bounds envelope lemmas

Add two_rpow_mul_pow_le_natCeil_mul_add_of_le and use the envelope lemmas in
SingleSubexp (subexp transfer, machine characterisations, mono_measure,
ite_polyTime, polyBounded decision, SharpKSAT_length_of_numVars).

* refactor(Complexity/FineGrained): finish the Bounds migration in Reduction, Sparsification, ExhaustiveSearch and Randomized

Use two_rpow_mul_pow_le_natCeil_mul_add, two_rpow_le_two_rpow_mul_of_le_mul_add and
natCast_mul_div_add_one_le for the remaining inline copies; list
two_rpow_le_two_rpow_mul_of_le_mul_add in the Bounds main results.

* refactor(Complexity/FineGrained): share guarded and polyBounded rate bounds across exponent towers

Prove ComputableInTimeO.ite_polyTime_of_le and DecidableInTimeO.of_computableInTimeO_polyBounded
once for an arbitrary nonnegative exponent x, and derive the ExpTime and single-machine
subexponential versions (ite_polyTime, of_*_polyBounded, SharpKSAT_length_of_numVars) from them.
Add ite_all_length_le_SharpKSAT for the #k-SAT width guard. Shorten the CountingEndpoint
interpolationScale bridges with the Bounds absorption lemma and derive
exists_two_pow_mul_interpolationScale_le from exists_two_pow_le_of_isLittleO.

Part of cslib-community#4737.

---------

Co-authored-by: copositive <copositive@jetski>
orbitingflea pushed a commit to orbitingflea/complexitylib2 that referenced this pull request Nov 13, 2026
…lts from their computation counterparts (cslib-community#4841)

* refactor(Complexity/FineGrained): move the function-rate tower to FunctionRates

Move ComputableInTimeO/ExpTime/SubexpTime and their FTIME, decision and
reduction-transfer lemmas verbatim from CountingExponents into a new
FineGrained/FunctionRates module. CountingExponents re-exports it, and
Randomized imports FunctionRates and Exponents instead of the #k-SAT module.

Part of cslib-community#4737

* refactor(Complexity/FineGrained): shared envelope and rescale lemmas in Bounds

Add exponential-times-polynomial envelope lemmas (one_le_two_rpow_mul_pow,
two_rpow_mul_pow_le_two_rpow_mul_pow, pow_le_two_rpow_mul_pow,
two_rpow_mul_pow_le_natCeil_mul_add, le_two_mul_mul_of_le_mul_add) and the subexponential
rescaling step natCast_mul_div_add_one_le to FineGrained/Bounds, and use them for the
TimeO/ExpTime/SubexpTime monotonicity, intersection, if-then-else and measure-change
transfers in FineGrained, FunctionRates, Exponents, CountingExponents and Randomized.

Also folds in the cslib-community#4747 review nits: drop CountingExponents' unused Nat.Power and
ResourceFacts imports, and list FunctionRates among RatesNativeEndpoint's classical modules.

Part of cslib-community#4737.

* refactor(Complexity/FineGrained): absorb single-machine exponentials with the Bounds envelope lemmas

Add two_rpow_mul_pow_le_natCeil_mul_add_of_le and use the envelope lemmas in
SingleSubexp (subexp transfer, machine characterisations, mono_measure,
ite_polyTime, polyBounded decision, SharpKSAT_length_of_numVars).

* refactor(Complexity/FineGrained): finish the Bounds migration in Reduction, Sparsification, ExhaustiveSearch and Randomized

Use two_rpow_mul_pow_le_natCeil_mul_add, two_rpow_le_two_rpow_mul_of_le_mul_add and
natCast_mul_div_add_one_le for the remaining inline copies; list
two_rpow_le_two_rpow_mul_of_le_mul_add in the Bounds main results.

* refactor(Complexity/FineGrained): share guarded and polyBounded rate bounds across exponent towers

Prove ComputableInTimeO.ite_polyTime_of_le and DecidableInTimeO.of_computableInTimeO_polyBounded
once for an arbitrary nonnegative exponent x, and derive the ExpTime and single-machine
subexponential versions (ite_polyTime, of_*_polyBounded, SharpKSAT_length_of_numVars) from them.
Add ite_all_length_le_SharpKSAT for the #k-SAT width guard. Shorten the CountingEndpoint
interpolationScale bridges with the Bounds absorption lemma and derive
exists_two_pow_mul_interpolationScale_le from exists_two_pow_le_of_isLittleO.

Part of cslib-community#4737.

* refactor(Complexity/FineGrained): derive single-machine decision results from their computation counterparts

Add decidableInSingleSubexpTime_iff_exists_computableInSingleSubexpTime
(decision as single-machine computation of a Boolean indicator) and derive
decidableInSingleSubexpTime_iff_exists_machine, DecidableInSingleSubexpTime.mono_measure,
.of_reduction and .of_uniformFamily from their ComputableInSingleSubexpTime
counterparts. This removes the duplicated quantifier-exchange proof that
proof_copies flagged (survey item F2(b), cslib-community#4737).

decidableInTimeO_iff_exists_computableInTimeO moves from the Type section to the
Type* FunctionBounds section of FunctionRates (its statement is unchanged apart
from the universe generalization) so the SingleBounds lemmas can use it.

No existing statement changes.

---------

Co-authored-by: copositive <copositive@jetski>
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.

2 participants