Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
173 commits
Select commit Hold shift + click to select a range
6094ec9
feat(exactTriangle): relate lopsided queries and matrix products
edemaine Oct 28, 2026
dec963a
feat(exactTriangle): prove modular counts and the selected-prime bound
edemaine Oct 28, 2026
0d8da3e
doc(threeSum): cite the lopsided triangle paper and clarify adaptatio…
edemaine Oct 28, 2026
8d80ecc
doc(bibliography): sort the new paper entry
edemaine Oct 28, 2026
fd69be7
fix(exactTriangle): repair the prime-window header and hashing docume…
edemaine Oct 28, 2026
ce646c7
feat(exactTriangle): split modular queries and recover witnesses
edemaine Oct 28, 2026
2cae26c
doc(threeSum): record finite splitting and recovery milestone
edemaine Oct 28, 2026
dc4206a
refactor(exactTriangle): reuse the natural residue bound and clarify …
edemaine Oct 28, 2026
2434f47
feat(matrix): prove the tensor recursion and pruned evaluation core
edemaine Oct 28, 2026
62dc601
doc(matrix): clarify the overlapping contributing leaf
edemaine Oct 28, 2026
4f3226c
doc(matrix): make tensor and pruning explanations standalone
edemaine Oct 28, 2026
19ee942
feat(wordram): count Chan–He collisions with native histograms
edemaine Oct 28, 2026
a712205
fix(wordram): preserve collision-counting parameters explicitly
edemaine Oct 28, 2026
844522a
feat(matrix): prove finite thin-product correctness and sparse bounds
edemaine Oct 28, 2026
5cbb93d
feat(wordram): compute Chan–He parameters from native input
edemaine Oct 28, 2026
b4936ce
doc(matrix): explain finite thin-product guarantees in the Lean API
edemaine Oct 28, 2026
0505439
fix(wordram): repair parameter proof hygiene and ceiling-log docs
edemaine Oct 28, 2026
ad3e097
feat(wordram): implement shared tensor encodings
edemaine Oct 28, 2026
3b9234d
test(wordram): connect encoder witnesses to charged runs
edemaine Oct 28, 2026
46e9e72
feat(wordram): checkpoint native pruned-query controller proofs
edemaine Oct 28, 2026
68bbe40
refactor(schonhage): reuse binomial bounds and sharpen signed tests
edemaine Oct 28, 2026
cb261f6
feat(WordRAM): prepare and encode every shared matrix band
edemaine Oct 28, 2026
87ff44c
feat(wordram): checkpoint native pruned accumulation and frame transi…
edemaine Oct 28, 2026
b3b8047
feat(wordram): checkpoint actual pruned-query root-frame stores
edemaine Oct 28, 2026
6603615
fix(nat): reuse existing tuple digit identity in band preparation
edemaine Oct 28, 2026
79c9407
feat(wordram): checkpoint complete native pruned-controller phases
edemaine Oct 28, 2026
99b8a1b
doc(matrix): replace copied source prose with API descriptions
edemaine Oct 28, 2026
12abeee
refactor(finset): use order-embedding names in OrderGlue
edemaine Oct 28, 2026
829613f
feat(WordRAM): prove all-depth pruned controller execution
edemaine Oct 28, 2026
a93c021
style(WordRAM): normalize native proof file modes
edemaine Oct 28, 2026
0c2e0eb
feat(wordram): complete initialized sparse pruned-query execution
edemaine Oct 28, 2026
60bec64
chore(wordram): combine band and query evaluator prerequisites
edemaine Oct 29, 2026
06b3563
feat(wordram): checkpoint computed wanted-query routing
edemaine Oct 29, 2026
7772a34
feat(wordram): checkpoint wanted count-pass proofs
edemaine Oct 29, 2026
702c14b
doc(finset): restore ordered-gluing source credit
SamuelSchlesinger Oct 29, 2026
ce77926
fix(wordram): address pruned-query review findings
edemaine Oct 29, 2026
48a0fa3
chore(exactTriangle): merge current main for sibling integration
codex Oct 29, 2026
3fb98bd
chore(exactTriangle): join reviewed query splitting and counting layers
codex Oct 29, 2026
0b5cfe4
chore(wordram): retain reviewed pruned-query parent repair
edemaine Oct 29, 2026
d1bc583
chore(exactTriangle): reconcile modular-hashing integration documenta…
SamuelSchlesinger Oct 29, 2026
c0b0511
chore(exactTriangle): carry hashing integration through query splitting
SamuelSchlesinger Oct 29, 2026
a76a7d3
chore(exactTriangle): carry documentation integration through native …
SamuelSchlesinger Oct 29, 2026
4f6de79
fix(imports): deduplicate aggregate after counting integration
SamuelSchlesinger Oct 29, 2026
02f1b49
fix(imports): deduplicate aggregate after query-splitting integration
SamuelSchlesinger Oct 29, 2026
60dfe9a
Merge commit '02f1b495322d8cfee81969186795670e3574defa' into coordina…
SamuelSchlesinger Oct 29, 2026
6f48d5c
Merge remote-tracking branch 'origin/main' into coordinator/integrate…
SamuelSchlesinger Oct 29, 2026
b17ece3
Merge commit '4f6de797203eb5dac02b2cadd9e8fa33e7427d57' into coordina…
SamuelSchlesinger Oct 29, 2026
e031b72
Merge remote-tracking branch 'origin/main' into coordinator/integrate…
SamuelSchlesinger Oct 29, 2026
b79ae8e
fix(imports): regenerate aggregate after Chan-He parameter integration
SamuelSchlesinger Oct 29, 2026
3187bca
chore(wordram): retain reviewed sibling source-credit fix
edemaine Oct 29, 2026
a6e4005
feat(wordram): route and group wanted thin-product queries
edemaine Oct 29, 2026
249f960
Merge commit '6f48d5c0efdfea1984c4accf368de9eaa9716b95' into coordina…
SamuelSchlesinger Oct 29, 2026
08a0415
Merge remote-tracking branch 'origin/main' into coordinator/integrate…
SamuelSchlesinger Oct 29, 2026
b0fa45b
Merge commit '08a0415413677534785113b7cf643b1ba9a6ee78' into coordina…
SamuelSchlesinger Oct 29, 2026
bd9bd2b
fix(imports): regenerate aggregate after shared-encoder integration
SamuelSchlesinger Oct 29, 2026
ab3e96c
chore(integration): reconcile splitting layer with landed hashing parent
SamuelSchlesinger Oct 29, 2026
9c8b9fc
perf(wordram): reduce native parameter proof heartbeat budget
SamuelSchlesinger Oct 29, 2026
0c9b346
Merge remote-tracking branch 'github/main' into coordinator-heartbeat…
SamuelSchlesinger Oct 29, 2026
da6a301
chore(integration): adopt splitting layer after its parent landed
SamuelSchlesinger Oct 29, 2026
452924e
chore(wordram): scope measured parameter proof budget to reduction task
SamuelSchlesinger Oct 29, 2026
6aaf569
Merge commit 'da6a301aca1e0c03e6953b3329474b2236f0fac8' into coordina…
SamuelSchlesinger Oct 29, 2026
5f6aad5
chore(integration): refresh tensor recursion supplier after hashing l…
SamuelSchlesinger Oct 29, 2026
d91296f
perf(schonhage): focus cell arithmetic and use the default heartbeat …
SamuelSchlesinger Oct 29, 2026
d8f4162
fix(doc): restore unrelated upstream coordination records
SamuelSchlesinger Oct 29, 2026
a63864f
chore(three-sum): merge corrected supplier preserving scope and sourc…
SamuelSchlesinger Oct 29, 2026
781297c
chore(three-sum): merge refreshed thin-product supplier preserving en…
SamuelSchlesinger Oct 29, 2026
1f2cfc4
Merge commit '781297cef838ef99c33e4036195e58b06ca46779' into coordina…
SamuelSchlesinger Oct 29, 2026
b4aa7b5
Merge remote-tracking branch 'origin/main' into coordinator/integrate…
SamuelSchlesinger Oct 29, 2026
780531b
fix(imports): regenerate band-preparation aggregate from merged inven…
SamuelSchlesinger Oct 29, 2026
04349d4
Merge commit '780531b426051080bb274a0511f49142af03557c' into coordina…
SamuelSchlesinger Oct 29, 2026
5bf1f0e
doc(order-glue): preserve reviewed source credit through supplier merge
SamuelSchlesinger Oct 29, 2026
ec46a4f
chore(schonhage): integrate reviewed query and band suppliers
SamuelSchlesinger Oct 29, 2026
a9d3fb9
chore(schonhage): integrate wanted routing with refreshed query supplier
SamuelSchlesinger Oct 29, 2026
91f485e
chore(schonhage): adopt actual reviewed naming-refactor supplier
SamuelSchlesinger Oct 29, 2026
a677276
Merge remote-tracking branch 'origin/main' into coordinator/refresh-1…
SamuelSchlesinger Oct 29, 2026
8a81617
Merge remote-tracking branch 'github/main' into coordinator-refresh-1…
SamuelSchlesinger Oct 29, 2026
9e9cb10
Merge commit 'a67727699b41ff9fa7d7227964d67c26699ab7f6' into coordina…
SamuelSchlesinger Oct 29, 2026
c3e1bcd
doc(order-glue): restore paper citation and finite scope
SamuelSchlesinger Oct 29, 2026
606fd61
Merge commit 'c3e1bcd3c8d9bb1dc4819d1b0a994bf52119731b' into coordina…
SamuelSchlesinger Oct 29, 2026
59c6f80
feat(wordram): checkpoint native queried-product construction (#1581)
edemaine Oct 29, 2026
9d33c95
Merge commit '606fd614454016f738d69d2cd768cb4d9a9ad795' into coordina…
SamuelSchlesinger Oct 29, 2026
936457e
Merge commit '9d33c950c695a353b20fe43fd7524f25663a4bce' into coordina…
SamuelSchlesinger Oct 29, 2026
4b2d75c
Merge remote-tracking branch 'github/main' into coordinator-queue-146…
SamuelSchlesinger Oct 29, 2026
ea38fc5
Merge remote-tracking branch 'origin/main' into coordinator/refresh-1…
SamuelSchlesinger Oct 29, 2026
6a86e25
fix(imports): regenerate thin-product aggregate after main integration
SamuelSchlesinger Oct 29, 2026
6dbd0cc
Merge commit '6a86e258db83b7724f5bd93c43c0cbc4221a992f' into coordina…
SamuelSchlesinger Oct 29, 2026
c94a52f
Merge commit '4b2d75ce50dbca1101868ed3726170770d0a3e77' into coordina…
SamuelSchlesinger Oct 29, 2026
d072322
Merge remote-tracking branch 'origin/main' into coordinator/repair-15…
SamuelSchlesinger Oct 29, 2026
61e7fe7
doc(wordram): separate shared-encoder integration records
SamuelSchlesinger Oct 29, 2026
e21cbd0
chore(integration): preserve local band-refresh preparation
SamuelSchlesinger Oct 29, 2026
d2e8386
Merge commit '38f32f97e76ad36666b99d1f0d39a64fc0ef3306' into coordina…
SamuelSchlesinger Oct 29, 2026
f55b418
Merge commit 'd2e8386e3352241f97fc1c3faa3da53c1fbb1f68' into coordina…
SamuelSchlesinger Oct 29, 2026
8f25b31
Merge commit 'f04ad02616791b3fa37ff236ac27b0a8690ca985' into coordina…
SamuelSchlesinger Oct 29, 2026
debd649
doc(matrix): keep progress links out of shared reference append block
SamuelSchlesinger Oct 29, 2026
af20863
feat(wordram): checkpoint complete queried-product source before supp…
edemaine Oct 29, 2026
cf25502
chore(wordram): merge actual reviewed queried-product supplier
edemaine Oct 29, 2026
ff31104
feat(wordram): execute queried thin-matrix products (#1581)
edemaine Oct 29, 2026
9a57e13
style(Schonhage): remove trailing space in queried products
edemaine Oct 29, 2026
37306ef
doc(Schonhage): retain band catalogue encoding contract
edemaine Oct 29, 2026
b71ae0e
Merge commit 'cf63e382d02ba396b4f8d460958d70b15735f23e' into coordina…
SamuelSchlesinger Oct 29, 2026
8527c1f
Merge commit 'cf63e382d02ba396b4f8d460958d70b15735f23e' into coordina…
SamuelSchlesinger Oct 29, 2026
82f86fe
Merge commit '8527c1f4d25246fee901303e7c0f1310d30306c0' into coordina…
SamuelSchlesinger Oct 29, 2026
d429833
Merge commit '82f86fec9b93d546f96542987255aa9f16377b3b' into coordina…
SamuelSchlesinger Oct 29, 2026
f43c26e
Merge commit '82f86fec9b93d546f96542987255aa9f16377b3b' into coordina…
SamuelSchlesinger Oct 29, 2026
168a8be
Merge commit 'f43c26edef5bc586602e0678be9f8a59759bd5f2' into coordina…
SamuelSchlesinger Oct 29, 2026
7d82da6
Merge commit 'd429833391f88fe96223bef8124be7e6b21a117f' into coordina…
SamuelSchlesinger Oct 29, 2026
70898da
fix(imports): regenerate wanted-routing aggregate from actual inventory
SamuelSchlesinger Oct 29, 2026
a8cb7c9
chore(schonhage): refresh queried products onto actual wanted parent
SamuelSchlesinger Oct 29, 2026
7cb7ade
wip(wordram): checkpoint callable thin-product source
edemaine Oct 29, 2026
904c620
chore(wordram): merge reviewed queried-product parent into callable c…
edemaine Oct 29, 2026
f5e6949
feat(WordRAM): run queried thin products in caller-owned memory
edemaine Oct 29, 2026
fd1f2fc
chore(WordRAM): merge pinned landed main into callable product child
edemaine Oct 29, 2026
ce10624
refactor(WordRAM): align ArrayNormalize module name and admission prose
edemaine Oct 29, 2026
8f46341
feat(ExactTriangle): checkpoint actual record product composition
edemaine Oct 29, 2026
8612aff
chore(ExactTriangle): merge pinned main into record product child
edemaine Oct 29, 2026
96842bb
feat(ExactTriangle): validate initialized record product adapter
edemaine Oct 29, 2026
0e10700
feat(ExactTriangle): checkpoint native candidate-verification source
edemaine Oct 29, 2026
b461744
feat(ExactTriangle): compose initialized per-record native witness re…
edemaine Oct 29, 2026
c02ed27
chore(ExactTriangle): merge pinned main for witness validation
edemaine Oct 29, 2026
888918d
chore(deps): track CSLib main and Lean rc2
SamuelSchlesinger Oct 29, 2026
9a1b754
refactor(probability): use generic infinite-sum lemmas
SamuelSchlesinger Oct 29, 2026
d7dcd79
fix(build): adapt proofs to the rc2 Mathlib API
SamuelSchlesinger Oct 29, 2026
7925011
Merge remote-tracking branch 'origin/main' into work/cslib-rc2-sync-1…
SamuelSchlesinger Oct 29, 2026
f5a70cb
test(quantum): qualify the protected matrix lemma
SamuelSchlesinger Oct 29, 2026
bb3e910
fix(build): normalize goals before proof automation
SamuelSchlesinger Oct 29, 2026
d4b0493
chore(WordRAM): finalize native record witness validation
edemaine Oct 29, 2026
0d38523
Merge commit '96fd02a85579bbbce97c02110ed80da02684cb2e' into work/csl…
SamuelSchlesinger Oct 29, 2026
2e388dc
doc(ExactTriangle): state native code bound inclusively
edemaine Oct 29, 2026
9ed4900
feat(ExactTriangle): execute the native fixed-prime catalogue
edemaine Oct 29, 2026
0749a5b
chore(ExactTriangle): merge pinned rc2 prerequisites for validation
edemaine Oct 29, 2026
b6519e9
doc(ExactTriangle): merge the exact reviewed supplier bound wording
edemaine Oct 29, 2026
0edd088
Merge commit '0d38523e96f8b431aeadc86c548c9994714f9b00' into coordina…
edemaine Oct 29, 2026
52b94d0
chore(ExactTriangle): validate fixed-prime native solver on supported…
edemaine Oct 30, 2026
741051c
Merge commit '0ba8b2e59d4d7009c814096d8bbb4a9823d06963' into coordina…
edemaine Oct 30, 2026
3cda568
chore(ExactTriangle): align fixed-prime stack with supported rc2 parent
edemaine Oct 30, 2026
14e4ba5
feat(WordRAM): implement native cyclic coefficient multiplication
edemaine Oct 30, 2026
ffa8337
feat(ExactTriangle): implement concrete cyclic Strassen counter code
edemaine Oct 30, 2026
77b8c71
chore(ExactTriangle): normalize own counter source file modes
edemaine Oct 30, 2026
c0cf4a4
feat(WordRAM): prove native Strassen forms and counter preparation st…
edemaine Oct 30, 2026
0aa2272
feat(WordRAM): prove Strassen phase bounds and native traversal base …
edemaine Oct 30, 2026
19859fe
feat(WordRAM): bound the Strassen proof recurrence by seven to the depth
edemaine Oct 30, 2026
100826d
feat(WordRAM): prove native Strassen child preparation and return stages
edemaine Oct 30, 2026
30f3af5
feat(WordRAM): prove complete native cyclic-coefficient Strassen exec…
edemaine Oct 30, 2026
bfa3de1
feat(WordRAM): prove concrete CountPrime multiplication and metadata …
edemaine Oct 30, 2026
18ea336
feat(WordRAM): prove the complete native CountPrime matrix-building loop
edemaine Oct 30, 2026
4419dca
feat(WordRAM): identify computed CountPrime matrices with existing co…
edemaine Oct 30, 2026
e1ba17a
chore(ExactTriangle): align resumed counter with pinned landed kernel
edemaine Oct 31, 2026
35a8294
fix(ExactTriangle): finish coefficient merge after UTF-8 read failure
edemaine Oct 31, 2026
f9bee16
feat(WordRAM): checkpoint native prime-selection controller code
edemaine Oct 31, 2026
165ec7e
feat(WordRAM): prove native prime-selector update and register contracts
edemaine Oct 31, 2026
3c119cc
feat(ExactTriangle): prove actual selected-coefficient counter scan
edemaine Oct 31, 2026
2c3657a
feat(ExactTriangle): compose complete native modular counter caller
edemaine Oct 31, 2026
6b4068c
feat(WordRAM): compose the complete native prime-selector loop
edemaine Oct 31, 2026
61c82f6
feat(ExactTriangle): finish initialized subcubic native modular counter
edemaine Oct 31, 2026
016471a
Merge source-complete native counter prerequisite for prime selection
edemaine Oct 31, 2026
21f64f1
feat(WordRAM): checkpoint concrete counter integration for prime sele…
edemaine Oct 31, 2026
7bc9b1c
chore(ExactTriangle): register complete native modular counter
edemaine Oct 31, 2026
02a7822
doc(Strassen): correct pinned recurrence and identity locators
edemaine Oct 31, 2026
4027bd9
Merge main into native modular counter PR #2109
edemaine Oct 31, 2026
12e121e
Merge reviewed counter PR prerequisite for native prime selection
edemaine Nov 1, 2026
1c290ca
feat(ExactTriangle): finish concrete initialized minimum-count prime …
edemaine Nov 1, 2026
f92e5c6
feat(ExactTriangle): compute compatible native dyadic parameters
edemaine Nov 1, 2026
37de625
feat(ExactTriangle): implement dirty-memory fixed-prime caller
edemaine Nov 1, 2026
69495f2
feat(ExactTriangle): complete callable fixed-prime execution and bounds
edemaine Nov 1, 2026
61fec43
chore(ExactTriangle): normalize initialized caller file mode
edemaine Nov 1, 2026
8362058
Merge commit 'b4678e2063c4de73cd39b02d1af26045e5ac6289' into work/thr…
edemaine Nov 1, 2026
dc92727
feat(ExactTriangle): finalize callable fixed-prime imports and valida…
edemaine Nov 1, 2026
4e48de9
feat(ExactTriangle): bound computed native component costs
edemaine Nov 1, 2026
97fbc0f
feat(ExactTriangle): derive uniform subcubic component budgets
edemaine Nov 1, 2026
22f07e4
Merge reviewed callable fixed-prime prerequisite for cost composition
edemaine Nov 1, 2026
d8f759b
feat(ExactTriangle): expose the checked natural fast-ledger bound
edemaine Nov 1, 2026
c7b9fcf
feat(ExactTriangle): bound actual dyadic execution by uniform natural…
edemaine Nov 1, 2026
b31a393
chore(ExactTriangle): refresh natural runtime bounds onto landed parents
SamuelSchlesinger Nov 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Complexity.lean
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public import Complexity.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime.Ada
public import Complexity.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime.Admission
public import Complexity.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime.Copy
public import Complexity.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime.Core
public import Complexity.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime.DyadicCost
public import Complexity.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime.DyadicExecution
public import Complexity.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime.Exec
public import Complexity.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime.Flat
public import Complexity.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime.Header
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
/-
Copyright (c) 2026 Erik Demaine. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Erik Demaine
-/

module
-- upstream: candidate

public import Complexity.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime.SourceBounds
public import Complexity.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime.TimeBound
public import Complexity.Algorithms.WordRAM.ExactTriangle.DyadicCost.Asymptotics
public import Complexity.Algorithms.WordRAM.ExactTriangle.DyadicParameters.Exec
import Mathlib.Analysis.SpecialFunctions.Log.Base
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.Positivity
import Mathlib.Tactic.Ring

/-!
# A content-independent natural allowance for callable dyadic solving

The natural function depends only on original dimension n and original weight bound F. A
selected-prime logarithmic estimate and the actual wrapper charges bound the real parameter,
selector and callable ledger, including header/halt reserve. This is a mathematical time bound;
the program does not compute it or receive a time certificate. Small-branch execution and
actual program assembly remain separate.

## Main definitions

* `dyadicTime`: natural allowance for the complete fast ledger, independent of input contents,
reference memory, layout and physical width.

## Main results

* `timeBound_le_dyadicTime`: the actual charged fast ledger is bounded at every selected prime.
* `exists_dyadicTime_subcubic_bound`: uniform strict-subcubic growth for polynomial original F.
-/

public section

namespace Cslib.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime

open Filter Cslib.WordRAM Cslib.Matrix Cslib.Algorithms.ExactTriangle
open Cslib.Algorithms.MatrixMultiplication.Schonhage
open ParameterChoice

private noncomputable def weightExponent (n F : ℕ) : ℝ :=
1 + Real.logb n (F + 1)

private def setupLog (n F : ℕ) : ℕ :=
Nat.clog 2 (4 * n + 3 * (n * n) * (2 * F + 1) + 4)

private noncomputable def upperTime (n F : ℕ) : ℝ :=
3 * DyadicCost.costCoefficient (weightExponent n F) n * ((n : ℝ) ^ 3 / groups n) +
24 * (n : ℝ) ^ 2 + 24669 * (setupLog n F : ℝ) + 497

/-- Natural fast-ledger allowance from original n and F only. The ceiling is descriptive
metadata, not an executed instruction or an oracle supplied to the native solver. The final
sixteen reserve the assembled initialized header and halt. -/
noncomputable def dyadicTime (n F : ℕ) : ℕ := ⌈upperTime n F⌉₊ + 16

private theorem one_le_weightExponent {n : ℕ} (hn : 2 ≤ n) (F : ℕ) :
1 ≤ weightExponent n F := by
have hlog : 0 < Real.log (n : ℝ) := Real.log_pos (by exact_mod_cast hn)
have hF : 0 ≤ Real.log (F + 1 : ℝ) :=
Real.log_nonneg (by exact_mod_cast (by omega : 1 ≤ F + 1))
have hdiv := div_nonneg hF hlog.le
unfold weightExponent Real.logb
linarith only [hdiv]

private theorem bound_le_rpow_weightExponent {n : ℕ} (hn : 2 ≤ n) (F : ℕ) :
(F : ℝ) ≤ (n : ℝ) ^ weightExponent n F := by
have hn0 : (0 : ℝ) < n := by exact_mod_cast (by omega : 0 < n)
have hn1 : (n : ℝ) ≠ 1 := by exact_mod_cast (by omega : n ≠ 1)
rw [weightExponent, Real.rpow_add hn0, Real.rpow_one,
Real.rpow_logb hn0 hn1 (by positivity)]
have hnR : (1 : ℝ) ≤ n := by exact_mod_cast (by omega : 1 ≤ n)
nlinarith

private theorem original_weights {n F : ℕ} (values : List ℤ)
(hlen : values.length = 3 * (n * n)) (hv : ∀ z ∈ values, z.natAbs ≤ F) :
WeightsBoundedBy
(fun u v : Fin n => values.getD (pairIndex (u, v)) 0)
(fun u v => values.getD (n * n + pairIndex (u, v)) 0)
(fun u v => values.getD (2 * (n * n) + pairIndex (u, v)) 0) (F : ℝ) := by
have hlookup (q : ℕ) : (values.getD q 0).natAbs ≤ F := by
by_cases hq : q < 3 * (n * n)
· exact RecordWitness.original_magnitude values hlen hv hq
· rw [List.getD_eq_default values 0 (by omega : values.length ≤ q), Int.natAbs_zero]
exact Nat.zero_le F
have hw (q : ℕ) : ((|values.getD q 0| : ℤ) : ℝ) ≤ F := by
rw [← Int.natCast_natAbs, Int.cast_natCast]
exact_mod_cast hlookup q
exact ⟨fun _ _ => hw _, fun _ _ => hw _, fun _ _ => hw _⟩

private theorem scalar_bounds {n p : ℕ} (hn : 0 < n)
(hp : p ∈ Nat.sqrtPrimeWindow (window n)) :
window n ≤ n ∧ groups n ≤ n ∧ p ≤ n := by
have hd := window_le hn
have hsq := (Nat.mem_sqrtPrimeWindow_iff_sq.mp hp).2.2
exact ⟨hd, (groups_le_window n).trans hd,
(Nat.le_self_pow (by decide : 2 ≠ 0) p).trans (hsq.le.trans hd)⟩

/-- Bound the actual fast initialized ledger, including all copies, setup, dispatch/restore,
header and halt. All original matrices bounded by F share this same natural function. The
prime is actually selected; no layout, execution or time law is a premise. -/
theorem timeBound_le_dyadicTime {n F p : ℕ} (hf : 0 < blocks n) (values : List ℤ)
(hlen : values.length = 3 * (n * n)) (hv : ∀ z ∈ values, z.natAbs ≤ F)
(hp : IsSelectedPrime
(fun u v : Fin n => values.getD (pairIndex (u, v)) 0)
(fun u v => values.getD (n * n + pairIndex (u, v)) 0)
(fun u v => values.getD (2 * (n * n) + pairIndex (u, v)) 0) (window n) p)
(mem : ℕ → ℕ) :
DyadicParameters.timeBound n + PrimeSelection.timeBound n (window n) +
timeBound (m := level n) (pos_of_blocks_pos hf) (groups n) p values mem + 42 ≤
dyadicTime n F := by
have hn := pos_of_blocks_pos hf
obtain ⟨hd, hg, hpN⟩ := scalar_bounds hn hp.1
have hn2 : 2 ≤ n := by have h := (window_ge_sixteen hf).trans hd; omega
have hexp := bound_le_rpow_weightExponent hn2 F
obtain ⟨hab, hbc, hac⟩ := original_weights values hlen hv
have hv' : WeightsBoundedBy
(fun u v : Fin n => values.getD (pairIndex (u, v)) 0)
(fun u v => values.getD (n * n + pairIndex (u, v)) 0)
(fun u v => values.getD (2 * (n * n) + pairIndex (u, v)) 0)
((n : ℝ) ^ weightExponent n F) :=
⟨fun _ _ => (hab _ _).trans hexp, fun _ _ => (hbc _ _).trans hexp,
fun _ _ => (hac _ _).trans hexp⟩
have hc := DyadicCost.components_timeBound_le hf (one_le_weightExponent hn2 F) values mem hv' hp
change (_ : ℝ) ≤ DyadicCost.costCoefficient (weightExponent n F) n *
((n : ℝ) ^ 3 / groups n) at hc
have hraw := rawTotal_le values hlen hv
have hlog : Nat.clog 2 (n + window n + groups n + p + rawTotal n values + 4) ≤ setupLog n F :=
Nat.clog_mono_right 2 (by omega)
have hparam := DyadicParameters.timeBound_le n
have hnat : DyadicParameters.timeBound n + PrimeSelection.timeBound n (window n) +
timeBound (m := level n) hn (groups n) p values mem + 42 ≤
3 * (12 * Nat.log 2 n + 36 + (PrimeSelection.timeBound n (window n) + 16) +
FixedPrime.timeBound (m := level n) hn (groups n) p values mem) +
24 * (n * n) + 24669 * setupLog n F + 497 + 16 := by
unfold timeBound
dsimp only [D, window] at *
nlinarith only [hlog, hparam]
have hreal := (Nat.cast_le (α := ℝ)).mpr hnat
have hceil : upperTime n F ≤ (⌈upperTime n F⌉₊ : ℝ) := Nat.le_ceil _
apply (Nat.cast_le (α := ℝ)).mp
unfold dyadicTime
push_cast at hreal hc ⊢
unfold upperTime at hceil ⊢
nlinarith only [hreal, hc, hceil]

private theorem setupLog_le_log {n F κ : ℕ} (hF : F ≤ (n + 2) ^ κ) :
setupLog n F ≤ (κ + 7) * Nat.clog 2 (n + 2) := by
let B := n + 2
have hb : 2 ≤ B := by dsimp only [B]; omega
have hb1 : 1 ≤ B := by omega
have hnB : n ≤ B := by dsimp only [B]; omega
have hn2 : n * n ≤ B ^ 2 := (Nat.mul_le_mul hnB hnB).trans_eq (by ring)
have hunit : 1 ≤ B ^ κ := Nat.one_le_pow _ _ hb1
have hcoef : 2 * F + 1 ≤ 3 * B ^ κ := by
have : F ≤ B ^ κ := hF
omega
have hterm : 3 * (n * n) * (2 * F + 1) ≤ 9 * B ^ (κ + 2) := by
calc
_ ≤ (3 * B ^ 2) * (3 * B ^ κ) :=
Nat.mul_le_mul (Nat.mul_le_mul_left 3 hn2) hcoef
_ = _ := by rw [pow_add]; ring
have hB : B ≤ B ^ (κ + 2) := Nat.le_self_pow (by omega) _
have hlinear : 4 * n + 4 ≤ 8 * B ^ (κ + 2) := by nlinarith only [hnB, hb1, hB]
have hsum : 4 * n + 3 * (n * n) * (2 * F + 1) + 4 ≤ 17 * B ^ (κ + 2) := by
omega
have h17 : 17 ≤ B ^ 5 := (by decide : 17 ≤ (2 : ℕ) ^ 5).trans
(Nat.pow_le_pow_left hb 5)
have hpoly : 4 * n + 3 * (n * n) * (2 * F + 1) + 4 ≤ B ^ (κ + 7) := by
calc
_ ≤ 17 * B ^ (κ + 2) := hsum
_ ≤ B ^ 5 * B ^ (κ + 2) := Nat.mul_le_mul_right _ h17
_ = _ := by rw [← pow_add]; congr 1; omega
have h := hpoly.trans (Nat.pow_le_pow_left
(Nat.le_pow_clog (by decide : 1 < (2 : ℕ)) B) (κ + 7))
rw [← pow_mul, Nat.mul_comm (Nat.clog 2 B) (κ + 7)] at h
exact Nat.clog_le_of_le_pow h

private theorem weightExponent_le {n F κ : ℕ} (hn : 2 ≤ n) (hF : F ≤ (n + 2) ^ κ) :
weightExponent n F ≤ (2 * κ + 2 : ℕ) := by
have hpow : F ≤ n ^ (2 * κ) :=
hF.trans ((Nat.pow_le_pow_left (by nlinarith : n + 2 ≤ n ^ 2) κ).trans_eq
(by rw [← pow_mul]))
have hunit : 1 ≤ n ^ (2 * κ) := Nat.one_le_pow _ _ (by omega)
have hF1 : F + 1 ≤ n ^ (2 * κ + 1) := by
rw [pow_succ]
nlinarith only [hpow, hunit, hn]
have hF1R : (F + 1 : ℝ) ≤ (n : ℝ) ^ ((2 * κ + 1 : ℕ) : ℝ) := by
rw [Real.rpow_natCast]
exact_mod_cast hF1
have hnR : (1 : ℝ) < n := by exact_mod_cast hn
have hlog := (Real.logb_le_iff_le_rpow hnR (by positivity : (0 : ℝ) < F + 1)).mpr hF1R
unfold weightExponent
push_cast at hlog ⊢
linarith only [hlog]

private theorem upperTime_nonneg {n : ℕ} (hn : 2 ≤ n) (F : ℕ) : 0 ≤ upperTime n F := by
have hC : 0 ≤ falsePositiveConst := (by norm_num : (0 : ℝ) ≤ 1).trans one_le_falsePositiveConst
have hlog : 0 ≤ Real.log (n : ℝ) := Real.log_nonneg (by exact_mod_cast (by omega : 1 ≤ n))
have hexp : 0 ≤ weightExponent n F := (by norm_num : (0 : ℝ) ≤ 1).trans
(one_le_weightExponent hn F)
unfold upperTime DyadicCost.costCoefficient
positivity

-- Only the original fixed fast-threshold numeral is normalized during filter transport.
set_option exponentiation.threshold 1296 in
/-- One positive coefficient and threshold per weight exponent control the natural time
function uniformly over all original bounds F≤(n+2)^κ. This is an estimate of the bound
function itself, usable by the actual Callee contract. No contents/layout/width occurs in it. -/
theorem exists_dyadicTime_subcubic_bound {κ : ℕ} (hκ : 1 ≤ κ) :
∃ C : ℝ, 0 < C ∧ ∃ N : ℕ, 2 ^ 1296 ≤ N ∧
∀ n ≥ N, ∀ F ≤ (n + 2) ^ κ,
(dyadicTime n F : ℝ) ≤ C * (n : ℝ) ^ (3 - 1 / 1296 : ℝ) := by
let C : ℝ := (49338 * (κ + 7) + 550 : ℕ)
have hcκ : (1 : ℝ) ≤ (2 * κ + 2 : ℕ) := by exact_mod_cast (by omega : 1 ≤ 2 * κ + 2)
have hevent := DyadicCost.costCoefficient_eventually_le_rpow hcκ
(by norm_num : (0 : ℝ) < 1 / 1296)
have hfinal : ∀ᶠ n : ℕ in atTop, ∀ F ≤ (n + 2) ^ κ,
(dyadicTime n F : ℝ) ≤ C * (n : ℝ) ^ (3 - 1 / 1296 : ℝ) := by
filter_upwards [hevent, eventually_ge_atTop (16 : ℕ)] with n hc hn
intro F hF
have hn2 : 2 ≤ n := by omega
have hn1 : 1 ≤ n := by omega
have hcoeff := (DyadicCost.costCoefficient_mono hn1 (weightExponent_le hn2 hF)).trans hc
have hmain : 3 * DyadicCost.costCoefficient (weightExponent n F) n *
((n : ℝ) ^ 3 / groups n) ≤ 12 * (n : ℝ) ^ (3 - 1 / 1296 : ℝ) := by
calc
_ ≤ 3 * (n : ℝ) ^ (1 / 1296 : ℝ) * ((n : ℝ) ^ 3 / groups n) := by gcongr
_ ≤ 3 * (n : ℝ) ^ (1 / 1296 : ℝ) *
(4 * (n : ℝ) ^ (3 - 1 / 648 : ℝ)) := by
exact mul_le_mul_of_nonneg_left (cubic_div_groups_le (by omega)) (by positivity)
_ = _ := by
rw [mul_assoc, mul_left_comm ((n : ℝ) ^ (1 / 1296 : ℝ)) 4,
← mul_assoc, ← Real.rpow_add (by exact_mod_cast (by omega : 0 < n))]
norm_num
have hlog := setupLog_le_log hF
have hclog : Nat.clog 2 (n + 2) ≤ n + 2 :=
Nat.clog_le_of_le_pow (show n + 2 ≤ 2 ^ (n + 2) from Nat.lt_two_pow_self.le)
have hn2' : n + 2 ≤ 2 * (n * n) := by nlinarith
have hsetup := hlog.trans (Nat.mul_le_mul_left (κ + 7) (hclog.trans hn2'))
have hsmallNat : 24 * (n * n) + 24669 * setupLog n F + 514 ≤
(49338 * (κ + 7) + 538) * (n * n) := by
have hunit : 1 ≤ n * n := by nlinarith
nlinarith only [hsetup, hunit]
have hsmallR := (Nat.cast_le (α := ℝ)).mpr hsmallNat
have hpow : (n : ℝ) ^ 2 ≤ (n : ℝ) ^ (3 - 1 / 1296 : ℝ) := by
rw [← Real.rpow_natCast]
exact Real.rpow_le_rpow_of_exponent_le (by exact_mod_cast hn1) (by norm_num)
have hscaled := mul_le_mul_of_nonneg_left hpow
(show (0 : ℝ) ≤ (49338 * (κ + 7) + 538 : ℕ) by positivity)
have hceil := (Nat.ceil_lt_add_one (upperTime_nonneg hn2 F)).le
unfold dyadicTime C
push_cast at hsmallR hscaled ⊢
unfold upperTime at hceil ⊢
nlinarith only [hmain, hsmallR, hscaled, hceil]
obtain ⟨N, hN⟩ := eventually_atTop.mp hfinal
refine ⟨C, by dsimp only [C]; positivity, max N (2 ^ 1296), le_max_right _ _, ?_⟩
intro n hn
exact hN n ((le_max_left _ _).trans hn)

end Cslib.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/-
Copyright (c) 2026 Erik Demaine. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Erik Demaine
-/

module
-- upstream: candidate

public import Complexity.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime.DyadicCost

/-!
# Selected-prime initialized executions with a strict-subcubic charge

The existing real callable program supplies original signed verdicts and witnesses. Its actual
initialized prefix and halt are bounded by the natural dyadic time function, which is uniformly
strict-subcubic for polynomial original weights. The sufficient physical width is derived from
the original inputs. Runtime p is still a selected prime supplied in the input; parameter/prime
execution and final 3SUM composition remain separate.

## Main results

* `exists_dyadic_runs_threshold`: a shared coefficient and threshold per weight exponent, with
actual same-state prefix/halt, natural time allowance, exact verdict/witness and input frame.
-/

public section

namespace Cslib.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime

open Cslib.WordRAM Cslib.Matrix Cslib.Algorithms.ExactTriangle
open Cslib.Algorithms.MatrixMultiplication.Schonhage
open ParameterChoice

-- Only the existing fixed fast-threshold numeral is normalized during proof transport.
set_option exponentiation.threshold 1296 in
/-- Actual initialized computation, not a supplied run law. The positive coefficient and
threshold are chosen before every original input, prime and width. Selected-prime membership
is a performance hypothesis on runtime p; no layout, clock or execution certificate is supplied.
The allowance conservatively includes parameter/selector work not executed by this subroutine. -/
theorem exists_dyadic_runs_threshold {κ : ℕ} (hκ : 1 ≤ κ) :
∃ C : ℝ, 0 < C ∧ ∃ N : ℕ, 2 ^ 1296 ≤ N ∧
∀ n ≥ N, ∀ (F : ℕ) (values : List ℤ) (p W : ℕ),
values.length = 3 * (n * n) → (∀ z ∈ values, z.natAbs ≤ F) → F ≤ (n + 2) ^ κ →
IsSelectedPrime
(fun u v : Fin n => values.getD (pairIndex (u, v)) 0)
(fun u v => values.getD (n * n + pairIndex (u, v)) 0)
(fun u v => values.getD (2 * (n * n) + pairIndex (u, v)) 0) (window n) p →
(24664 * (κ + 9) + 19) * Nat.clog 2 (n + 2) ≤ W →
InputFits W (PreparationInput.input n (window n) (groups n) p values) ∧
∃ y t,
Runs W (entryProgram.program Reg.found)
(State.init (PreparationInput.input n (window n) (groups n) p values))
⟨entryProgram.size, y⟩ t ∧
Executes W (entryProgram.program Reg.found)
(State.init (PreparationInput.input n (window n) (groups n) p values))
(y.regs Reg.found) (t + 1) ∧
t + 1 ≤ dyadicTime n F ∧
(dyadicTime n F : ℝ) ≤ C * (n : ℝ) ^ (3 - 1 / 1296 : ℝ) ∧
y.Bounded W ∧ (y.regs Reg.found = 0 ∨ y.regs Reg.found = 1) ∧
(y.regs Reg.found = 1 ↔ HasZeroTriangle
(fun u v : Fin n => values.getD (pairIndex (u, v)) 0)
(fun u v => values.getD (n * n + pairIndex (u, v)) 0)
(fun u v => values.getD (2 * (n * n) + pairIndex (u, v)) 0)) ∧
(y.regs Reg.found = 1 → ∃ u v c : Fin n,
y.regs Reg.witnessA = u.val ∧ y.regs Reg.witnessB = v.val ∧
y.regs Reg.witnessC = c.val ∧
weightSum (fun a b => values.getD (pairIndex (a, b)) 0)
(fun a b => values.getD (n * n + pairIndex (a, b)) 0)
(fun a b => values.getD (2 * (n * n) + pairIndex (a, b)) 0) u v c = 0) ∧
∀ q < workspaceBase n, y.mem q =
(Data.init (PreparationInput.input n (window n) (groups n) p values) :
Data 640).mem q := by
obtain ⟨C, hC, N, hN, hc⟩ := exists_dyadicTime_subcubic_bound hκ
refine ⟨C, hC, N, hN, ?_⟩
intro n hnN F values p W hlen hv hF hp hW
have hn : 0 < n := (Nat.two_pow_pos 1296).trans_le (hN.trans hnN)
have hf := (blocks_pos_iff n).mpr (hN.trans hnN)
have hd := window_le hn
have hg := (groups_le_window n).trans hd
have hpN : p ≤ n := (Nat.le_self_pow (by decide : 2 ≠ 0) p).trans
((Nat.mem_sqrtPrimeWindow_iff_sq.mp hp.1).2.2.le.trans hd)
have hw : inputWidth n (window n) (groups n) p values ≤ W :=
(inputWidth_le_log values hlen hv hd hg hpN hF).trans hW
obtain ⟨hi, a, hout, y, t, ht, hr, he, hbound, hflag, hscan, hiff, hwitness, hframe, hregs⟩ :=
runs_input (m := level n) values hlen (window_ge_sixteen hf)
(one_le_groups n) hp.1 (geometry hn) hw
have hb := timeBound_le_dyadicTime hf values hlen hv hp a.mem
have ht' : t + 1 ≤ dyadicTime n F := by omega
exact ⟨hi, y, t, hr, he, ht', hc n hnN F hF, hbound, hflag, hiff, hwitness,
fun q hq => hframe q (Or.inl hq)⟩

end Cslib.Algorithms.WordRAM.ExactTriangle.CallableFixedPrime
Loading
Loading