@ceccec/millennium-solutions 9.3.3 → 9.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. package/README.md +14 -0
  2. package/dist/mod.core.d.ts +9 -0
  3. package/dist/mod.core.js +9 -0
  4. package/dist/src/0/index.d.ts +47 -0
  5. package/dist/src/0/index.js +189 -0
  6. package/dist/src/0/ledger.d.ts +1 -0
  7. package/dist/src/0/ledger.js +25 -0
  8. package/dist/src/0/trinity-matrix.d.ts +1 -0
  9. package/dist/src/0/trinity-matrix.js +16 -0
  10. package/dist/src/5/aspects.d.ts +1 -0
  11. package/dist/src/5/aspects.js +22 -0
  12. package/dist/src/5/reflection.d.ts +1 -0
  13. package/dist/src/5/reflection.js +25 -0
  14. package/dist/src/7/rosetta.d.ts +1 -0
  15. package/dist/src/7/rosetta.js +24 -0
  16. package/dist/src/9/enumeration.d.ts +1 -0
  17. package/dist/src/9/enumeration.js +14 -0
  18. package/dist/src/honesty/index.d.ts +16 -0
  19. package/dist/src/honesty/index.js +69 -0
  20. package/package.json +27 -10
  21. package/.zenodo.json +0 -51
  22. package/ABSTRACT.md +0 -155
  23. package/ACCOUNTING.md +0 -27
  24. package/AXIOMS.md +0 -574
  25. package/CHALLENGES.md +0 -2595
  26. package/DEPLOY.md +0 -39
  27. package/DEVELOP.md +0 -34
  28. package/HEART.md +0 -112
  29. package/PHYSICS-SCALES.md +0 -80
  30. package/PRIOR-ART.md +0 -151
  31. package/PROOF-OF-CONCEPT.md +0 -81
  32. package/REALISATIONS.md +0 -87
  33. package/RESEARCH.md +0 -188
  34. package/RULES.md +0 -57
  35. package/SEQUENCE-DECODE.md +0 -196
  36. package/SIGNATURE.md +0 -34
  37. package/THEOREMS.md +0 -97
  38. package/WHITEPAPER.md +0 -40
  39. package/WORKFLOWS.md +0 -47
  40. package/boundaries.md +0 -23
  41. package/captain.md +0 -85
  42. package/compare.md +0 -42
  43. package/compute.md +0 -543
  44. package/cryptography.md +0 -55
  45. package/dashboard.md +0 -50
  46. package/examples.md +0 -47
  47. package/folds.md +0 -65
  48. package/forensic.md +0 -67
  49. package/guide.md +0 -126
  50. package/harness.md +0 -20
  51. package/index.md +0 -217
  52. package/mod.core.ts +0 -10
  53. package/nature.md +0 -58
  54. package/organism.md +0 -30
  55. package/paper.md +0 -8789
  56. package/proofs.md +0 -26
  57. package/quantum.md +0 -40
  58. package/rights.md +0 -39
  59. package/solutions.md +0 -28
  60. package/speedup.md +0 -41
  61. package/src/0/chacha.ts +0 -3
  62. package/src/0/crypt.ts +0 -4
  63. package/src/0/csp.ts +0 -10
  64. package/src/0/entanglement.ts +0 -31
  65. package/src/0/fusion.ts +0 -28
  66. package/src/0/holographic.ts +0 -57
  67. package/src/0/impossible.ts +0 -30
  68. package/src/0/imprint.ts +0 -160
  69. package/src/0/index.ts +0 -263
  70. package/src/0/ledger.ts +0 -25
  71. package/src/0/legible.ts +0 -29
  72. package/src/0/limit.ts +0 -29
  73. package/src/0/merkle-proof.ts +0 -3
  74. package/src/0/null-token.ts +0 -24
  75. package/src/0/sha256.ts +0 -3
  76. package/src/0/singularity.ts +0 -20
  77. package/src/0/stream.ts +0 -47
  78. package/src/0/trinities.ts +0 -37
  79. package/src/0/trinity-matrix.ts +0 -20
  80. package/src/0/version-matrix.ts +0 -70
  81. package/src/1/acceptance.ts +0 -26
  82. package/src/1/index.ts +0 -80
  83. package/src/1/paradox.ts +0 -28
  84. package/src/1/vortex.lean +0 -6
  85. package/src/2/frequency-scales.ts +0 -28
  86. package/src/2/iching.ts +0 -34
  87. package/src/2/index.ts +0 -78
  88. package/src/2/primes-vortex.ts +0 -12
  89. package/src/2/quantum.ts +0 -48
  90. package/src/2/string-scale.ts +0 -14
  91. package/src/2/vortex.lean +0 -10
  92. package/src/3/index.ts +0 -63
  93. package/src/3/pi-bbp.ts +0 -13
  94. package/src/3/trinity.ts +0 -39
  95. package/src/3/vortex.lean +0 -7
  96. package/src/4/git.ts +0 -30
  97. package/src/4/index.ts +0 -63
  98. package/src/4/vortex.lean +0 -6
  99. package/src/5/aspects.ts +0 -27
  100. package/src/5/center.ts +0 -35
  101. package/src/5/development.ts +0 -45
  102. package/src/5/diamond.ts +0 -35
  103. package/src/5/folds.ts +0 -12
  104. package/src/5/index.ts +0 -63
  105. package/src/5/reflection.lean +0 -14
  106. package/src/5/reflection.ts +0 -14
  107. package/src/5/vortex.lean +0 -10
  108. package/src/6/dna.ts +0 -27
  109. package/src/6/index.ts +0 -63
  110. package/src/6/vortex.lean +0 -7
  111. package/src/7/cross.ts +0 -31
  112. package/src/7/glagolitic.ts +0 -51
  113. package/src/7/index.ts +0 -67
  114. package/src/7/language-lens.ts +0 -41
  115. package/src/7/lens.ts +0 -41
  116. package/src/7/locale.ts +0 -105
  117. package/src/7/rbac.ts +0 -31
  118. package/src/7/rosetta-clay.ts +0 -15
  119. package/src/7/rosetta.lean +0 -11
  120. package/src/7/rosetta.ts +0 -11
  121. package/src/7/string-dimensions.ts +0 -14
  122. package/src/7/vortex.lean +0 -6
  123. package/src/8/infinite.ts +0 -26
  124. package/src/8/merkaba/field.ts +0 -27
  125. package/src/8/merkaba/geometry.ts +0 -16
  126. package/src/8/merkaba/touch.ts +0 -26
  127. package/src/8/nucleus/magic.lean +0 -15
  128. package/src/8/nucleus/proton-mass-fit.ts +0 -9
  129. package/src/8/nucleus/proton-mass.lean +0 -10
  130. package/src/8/nucleus/shell-model-magic.ts +0 -10
  131. package/src/8/vortex.lean +0 -7
  132. package/src/9/access.ts +0 -34
  133. package/src/9/aura-funding.ts +0 -25
  134. package/src/9/coins.ts +0 -25
  135. package/src/9/enumeration.ts +0 -13
  136. package/src/9/funding.ts +0 -85
  137. package/src/9/security.ts +0 -36
  138. package/src/9/society.ts +0 -32
  139. package/src/9/vortex.lean +0 -11
  140. package/src/api/gates.ts +0 -122
  141. package/src/api/index.ts +0 -447
  142. package/src/api/lanes.ts +0 -81
  143. package/src/claims/index.ts +0 -81
  144. package/src/demand/queries.json +0 -1764
  145. package/src/face/index.ts +0 -100
  146. package/src/from/the/heart/index.ts +0 -11
  147. package/src/honesty/boundaries.ts +0 -29
  148. package/src/honesty/index.ts +0 -63
  149. package/src/html/index.ts +0 -10
  150. package/src/latex/index.ts +0 -474
  151. package/src/millennium/index.ts +0 -53
  152. package/src/play/the/game/index.ts +0 -12
  153. package/src/proof/README.md +0 -118
  154. package/src/proof/address.lean +0 -168
  155. package/src/proof/coin.lean +0 -152
  156. package/src/proof/covered.json +0 -9
  157. package/src/proof/demand.lean +0 -160
  158. package/src/proof/demand2.lean +0 -219
  159. package/src/proof/demand3.lean +0 -209
  160. package/src/proof/discovered.json +0 -19530
  161. package/src/proof/elementary.lean +0 -495
  162. package/src/proof/energy.lean +0 -329
  163. package/src/proof/families.lean +0 -740
  164. package/src/proof/fixtures/axiom-control.lean +0 -39
  165. package/src/proof/flow.lean +0 -78
  166. package/src/proof/fnv.lean +0 -127
  167. package/src/proof/generated-theorems.json +0 -207
  168. package/src/proof/generated.lean +0 -101
  169. package/src/proof/imagined.lean +0 -492
  170. package/src/proof/index.lean +0 -156
  171. package/src/proof/index.ts +0 -916
  172. package/src/proof/involution.lean +0 -90
  173. package/src/proof/ledgerclaims.lean +0 -84
  174. package/src/proof/light.lean +0 -168
  175. package/src/proof/mechanical.lean +0 -563
  176. package/src/proof/merkaba.lean +0 -89
  177. package/src/proof/merkle.lean +0 -132
  178. package/src/proof/nim.lean +0 -332
  179. package/src/proof/novelty.json +0 -751
  180. package/src/proof/phenomena.lean +0 -90
  181. package/src/proof/priorart.lean +0 -190
  182. package/src/proof/quantum.lean +0 -159
  183. package/src/proof/reach.lean +0 -121
  184. package/src/proof/recovered.lean +0 -56
  185. package/src/proof/reversal.lean +0 -402
  186. package/src/proof/revoked.json +0 -317
  187. package/src/proof/rights.lean +0 -155
  188. package/src/proof/sequences.lean +0 -284
  189. package/src/proof/speed.lean +0 -158
  190. package/src/proof/split.lean +0 -209
  191. package/src/proof/theorems.lean +0 -67
  192. package/src/proof/trial-all.json +0 -16532
  193. package/src/proof/z9.lean +0 -126
  194. package/src/proof/z9plus.lean +0 -345
  195. package/src/proofs.lisp +0 -170
  196. package/src/prove/emit.ts +0 -115
  197. package/src/prove/index.ts +0 -143
  198. package/src/prove/translate.ts +0 -638
  199. package/src/publication/index.ts +0 -362
  200. package/src/quantum/field.ts +0 -73
  201. package/src/quantum/tree.ts +0 -79
  202. package/src/receipts/1431b4c4-7950-8d7b-88d1-b633219692f8.json +0 -7
  203. package/src/receipts/171e09c0-4cfd-8ce0-a6ed-cd33d5553da3.json +0 -7
  204. package/src/receipts/1a1f16c9-3491-8050-b221-e2a362439be4.json +0 -12
  205. package/src/receipts/1da15f83-83a6-8d04-b1ac-334c2dd6abb3.json +0 -7
  206. package/src/receipts/375a57ed-ef99-855e-8f34-b77d08010f3c.json +0 -6
  207. package/src/receipts/3dcbbf9e-0e49-8ba7-921e-17e478dbafaf.json +0 -6
  208. package/src/receipts/43a24136-5ad9-81ef-97c9-17be1c05bb5f.json +0 -11
  209. package/src/receipts/4991be51-74ba-8f66-9534-e6dba52fb569.json +0 -10
  210. package/src/receipts/52375d8f-232b-8c01-9d82-a824ffa7b2b7.json +0 -6
  211. package/src/receipts/593b546a-36b4-8553-941a-0e03b7053a64.json +0 -7
  212. package/src/receipts/7f75c989-96c9-8a24-8d0d-7e690861ccb4.json +0 -6
  213. package/src/receipts/80f80b59-81d8-866d-9a14-f469729d3dc8.json +0 -6
  214. package/src/receipts/85ac8585-9dc1-8964-9848-ae0f49cc82fb.json +0 -7
  215. package/src/receipts/85db092e-f2c0-88e5-bf75-61c4a65d84e7.json +0 -7
  216. package/src/receipts/95bacad3-9e56-8741-b0f8-def2c6ecb050.json +0 -7
  217. package/src/receipts/a1d33966-7bbd-84ca-902b-49e315af60e0.json +0 -6
  218. package/src/receipts/b20ced61-24ad-8123-adee-56031ab734dd.json +0 -11
  219. package/src/receipts/ba0447cd-f489-841a-a70f-a39b18ec2946.json +0 -11
  220. package/src/receipts/bcddbe66-06cf-8f31-a261-98b836938947.json +0 -7
  221. package/src/receipts/c1bac0d8-d906-8196-a4f0-3d8270b2e944.json +0 -6
  222. package/src/receipts/ce851ea3-3cf8-8646-a5d6-c0c6281210fe.json +0 -10
  223. package/src/receipts/cf43a122-c880-8d86-9e25-6f22f92d6b0a.json +0 -7
  224. package/src/receipts/daad8cd4-d4db-8dca-9c97-9a838cbce528.json +0 -7
  225. package/src/receipts/dc8bdb82-599f-8020-9eb2-cb016b408ec1.json +0 -6
  226. package/src/receipts/df77c265-d1a8-8354-8a9e-769fa5c676e2.json +0 -6
  227. package/src/receipts/e96686da-a411-8838-a5c8-ee7472bce048.json +0 -10
  228. package/src/receipts/f073c46f-7b67-83d0-aca5-db11fac4b5ec.json +0 -7
  229. package/src/receipts/f946d99d-a1c2-89f7-9426-a367c5b04191.json +0 -6
  230. package/src/receipts/fc069e45-115d-8983-ad25-fb9f735da84b.json +0 -6
  231. package/src/the/abstract/index.ts +0 -21
  232. package/src/the/abundance/index.ts +0 -20
  233. package/src/the/apple/earth/index.ts +0 -23
  234. package/src/the/apple/earth/navigation/index.ts +0 -28
  235. package/src/the/apple/earth/truth/index.ts +0 -19
  236. package/src/the/apple/index.ts +0 -27
  237. package/src/the/cancer/index.ts +0 -26
  238. package/src/the/clown/index.ts +0 -25
  239. package/src/the/creation/index.ts +0 -16
  240. package/src/the/crystal/index.ts +0 -23
  241. package/src/the/domain/index.ts +0 -16
  242. package/src/the/game/index.ts +0 -11
  243. package/src/the/gold/compass/index.ts +0 -26
  244. package/src/the/gold/index.ts +0 -35
  245. package/src/the/heart/index.ts +0 -15
  246. package/src/the/index.ts +0 -23
  247. package/src/the/law/index.ts +0 -20
  248. package/src/the/path/index.ts +0 -19
  249. package/src/the/rosetta/index.ts +0 -33
  250. package/src/the/sequence/index.ts +0 -12
  251. package/src/the/solids/index.ts +0 -25
  252. package/src/the/state/index.ts +0 -20
  253. package/src/the/superposition/state/index.ts +0 -22
  254. package/src/the/surface/index.ts +0 -26
  255. package/src/the/theorem/index.ts +0 -14
  256. package/src/the/torus/index.ts +0 -23
  257. package/src/the/waves/index.ts +0 -23
  258. package/the.md +0 -20
  259. package/verify.md +0 -67
@@ -1,740 +0,0 @@
1
- -- title: Families over the ring
2
- -- wing: the ring
3
- -- prior_art: named
4
- -- prior_art_domain: modular arithmetic, quantified
5
- -- prior_art_note: quantifies the ℤ/9 arithmetic above; the underlying results are Fermat’s, Euler’s and Gauss’s
6
- -- The families, quantified. Proving at scale.
7
- -- Author: Tsvetan Rouschev · License: CC BY-NC-ND 4.0
8
- --
9
- -- The ledger holds families of entries produced by a loop: flt_prime_3, flt_prime_5, flt_prime_7 … each a
10
- -- separate row asserting the same theorem at one more parameter. A row per parameter is not how mathematics
11
- -- scales; a quantifier is. Each theorem below ranges over the whole family's parameter set, so ONE proof
12
- -- subsumes every member — and covers parameters the ledger never enumerated.
13
- --
14
- -- Every proof is `by decide` over a finite range: no axioms, no Mathlib, no `sorry`. Where a statement is
15
- -- false outside its stated range, that is stated as a negative rather than omitted. Integrity, not truth.
16
-
17
- namespace Families
18
-
19
- def primesUpTo30 : List Nat := [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
20
- def fact (n : Nat) : Nat := (List.range n).foldl (fun a k => a * (k + 1)) 1
21
- def choose (n k : Nat) : Nat := fact n / (fact k * fact (n - k))
22
- -- gcd defined by STRUCTURAL recursion on a fuel argument. Nat.gcd is defined by well-founded recursion,
23
- -- whose equation lemmas pull in `propext` — so using it would silently cost this file its axiom-free status.
24
- -- Caught by the per-theorem audit; the standard is "does not depend on any axioms", and it is enforced.
25
- def gcdFuel : Nat → Nat → Nat → Nat
26
- | 0, a, _ => a
27
- | _, a, 0 => a
28
- | Nat.succ f, a, b => gcdFuel f b (a % b)
29
- def gcd' (a b : Nat) : Nat := gcdFuel (a + b + 1) a b
30
- def totient (n : Nat) : Nat := ((List.range n).filter (fun a => gcd' a n == 1)).length
31
- def popcount (n : Nat) : Nat := ((List.range 16).filter (fun i => (n >>> i) % 2 == 1)).length
32
-
33
- -- ── Fermat's little theorem, over every prime below thirty and every nonzero residue ──
34
- theorem flt_all_primes_under_thirty :
35
- primesUpTo30.all (fun p => (List.range' 1 (p - 1)).all (fun a => (a ^ (p - 1)) % p == 1)) := by decide
36
-
37
- -- ── Wilson's theorem, same range: (p−1)! ≡ p−1 (mod p) ──
38
- theorem wilson_all_primes_under_thirty :
39
- primesUpTo30.all (fun p => fact (p - 1) % p == p - 1) := by decide
40
-
41
- -- ── and Wilson FAILS at every composite — the converse, which the family never stated ──
42
- theorem wilson_fails_at_composites :
43
- ((List.range' 4 20).filter (fun n => ! primesUpTo30.contains n)).all
44
- (fun n => fact (n - 1) % n != n - 1) := by decide
45
-
46
- -- ── Pascal: every row sums to a power of two ──
47
- theorem pascal_rows_sum_to_powers_of_two :
48
- (List.range 12).all (fun n => ((List.range (n + 1)).map (fun k => choose n k)).foldl (· + ·) 0 == 2 ^ n) := by decide
49
-
50
- -- ── Pascal: the alternating sum vanishes on every row but the zeroth ──
51
- theorem pascal_alternating_sums_vanish :
52
- (List.range' 1 11).all (fun n =>
53
- ((List.range (n + 1)).map (fun k => if k % 2 == 0 then choose n k else 0)).foldl (· + ·) 0
54
- == ((List.range (n + 1)).map (fun k => if k % 2 == 1 then choose n k else 0)).foldl (· + ·) 0) := by decide
55
-
56
- -- ── Euler's totient at prime powers: φ(pᵏ) = pᵏ − pᵏ⁻¹ ──
57
- set_option maxRecDepth 100000 in
58
- theorem totient_at_prime_powers :
59
- [2, 3, 5, 7].all (fun p => (List.range' 1 3).all (fun k => totient (p ^ k) == p ^ k - p ^ (k - 1))) := by decide
60
-
61
- -- ── the geometric series in every base 2..9, to the fourth power ──
62
- theorem geometric_series_all_bases :
63
- (List.range' 2 8).all (fun b =>
64
- ((List.range 5).map (fun i => b ^ i)).foldl (· + ·) 0 * (b - 1) == b ^ 5 - 1) := by decide
65
-
66
- -- ── XOR is parity: over every assignment of k bits, for k up to 8 ──
67
- set_option maxRecDepth 100000 in
68
- theorem xor_is_parity_up_to_eight_bits :
69
- (List.range' 1 8).all (fun k =>
70
- (List.range (2 ^ k)).all (fun n => popcount n % 2 == (List.range k).foldl (fun acc i => (acc + ((n >>> i) % 2)) % 2) 0)) := by decide
71
-
72
-
73
- -- ── THE CONVENTION AT ZERO, stated as a convention and not as arithmetic.
74
- --
75
- -- Division by zero is UNDEFINED in mathematics: there is no quotient, and nothing below claims otherwise.
76
- -- What is recorded here is a property of Lean's FUNCTION `Nat.div`, which is total — every pair of naturals
77
- -- is mapped somewhere, including a zero divisor, where the definition returns 0. That is a choice made so
78
- -- the function is total and `decide` never faults on a side condition; it is not a claim that dividing by
79
- -- zero yields zero, and an earlier name here ("division_by_zero_is_zero") said exactly that and was wrong.
80
- --
81
- -- The deposit reads division by zero as a CHANGE OF DOMAIN, which is the same point put positively: the
82
- -- value is not found in the arithmetic, it is supplied by the definition — a different domain entirely.
83
- -- Naming this precisely matters, because a reader who takes `7 / 0 = 0` for arithmetic has been misled by
84
- -- a theorem that is green. ──
85
- theorem nat_div_is_a_total_function_returning_zero_at_a_zero_divisor :
86
- (7 / 0) = 0 ∧ (0 / 0) = 0 ∧ (7 % 0) = 7 := by decide
87
-
88
- -- the division identity holds across a range INCLUDING zero — but at zero it is carried entirely by the
89
- -- remainder, because the quotient was supplied by the convention rather than computed
90
- theorem division_identity_holds_across_the_range :
91
- (List.range 13).all (fun d => (12 / d) * d + (12 % d) == 12) := by decide
92
-
93
- theorem at_a_zero_divisor_the_identity_is_carried_by_the_remainder :
94
- (12 / 0) = 0 ∧ (12 % 0) = 12 ∧ (12 / 0) * 0 + (12 % 0) == 12 := by decide
95
-
96
- -- ── SEVEN FAMILIES THE LEDGER HELD AS SINGLETONS, QUANTIFIED — 2026-09-07 ───────────────────────────────
97
- --
98
- -- The ledger carries rows like domain_prime_m2, domain_prime_m3, domain_prime_m5 … one per parameter,
99
- -- every one of them revoked for want of a proof. Under "involute instead of withdraw" a revoked row whose
100
- -- statement is TRUE is not a dead entry: it is a carry waiting for the theorem that subsumes it. Each
101
- -- theorem below quantifies one such family over its whole parameter range, so the withdrawn members come
102
- -- back proved rather than dropped — and the range extends past whatever the loop happened to enumerate.
103
- --
104
- -- Four of the seven are stated as EQUIVALENCES rather than as lists of successes. The ledger's loop wrote
105
- -- a row only where the property held and simply omitted mulperm_k3, mulperm_k6, addgen_k3, addgen_k6,
106
- -- hasinv_d3, hasinv_d6 — the parameters where it fails. An omission is not a statement, and the reader
107
- -- cannot tell a false parameter from one nobody tried. The equivalence says both halves at once: the
108
- -- property holds at exactly the units and nowhere else, decided over the entire range.
109
-
110
- def isPrime (n : Nat) : Bool := n ≥ 2 && (List.range' 2 (n - 2)).all (fun d => n % d != 0)
111
- def unitsMod (m : Nat) : List Nat := (List.range m).filter (fun a => gcd' a m == 1)
112
- -- modular powering by repeated reduction — g ^ k over the naturals would build a 22-digit intermediate at
113
- -- m = 18 and cost the kernel far more than the theorem is worth
114
- def powMod (g k m : Nat) : Nat := (List.range k).foldl (fun a _ => a * g % m) (1 % m)
115
- def ordMod (g m : Nat) : Nat := ((List.range' 1 m).find? (fun k => powMod g k m == 1)).getD 0
116
- def hasPrimitiveRoot (m : Nat) : Bool := (unitsMod m).any (fun g => ordMod g m == (unitsMod m).length)
117
- def isOddPrimePower (n : Nat) : Bool :=
118
- (List.range' 3 n).any (fun p => isPrime p && p % 2 == 1 && (List.range' 1 5).any (fun k => p ^ k == n))
119
- -- Gauss's characterisation, written as a predicate so the theorem below compares two computations rather
120
- -- than comparing a computation against a list somebody typed out after looking at the answer
121
- def gaussCyclic (m : Nat) : Bool :=
122
- m == 1 || m == 2 || m == 4 || isOddPrimePower m || (m % 2 == 0 && isOddPrimePower (m / 2))
123
-
124
- -- ── primality across the range, decided — and agreeing with the list this file already used ──
125
- theorem primality_is_decided_across_the_range :
126
- (List.range' 2 17).all (fun m => isPrime m == primesUpTo30.contains m) := by decide
127
-
128
- -- ── the units are cyclic at exactly the moduli Gauss says, and at no others ──
129
- set_option maxRecDepth 100000 in
130
- theorem the_units_are_cyclic_at_exactly_the_gauss_moduli :
131
- (List.range' 2 17).all (fun m => hasPrimitiveRoot m == gaussCyclic m) := by decide
132
-
133
- -- ── De Morgan at every arity to eight, over every assignment of its inputs ──
134
- set_option maxRecDepth 100000 in
135
- theorem demorgan_holds_at_every_arity_to_eight :
136
- (List.range' 2 7).all (fun k => (List.range (2 ^ k)).all (fun n =>
137
- (! (List.range k).all (fun i => (n >>> i) % 2 == 1)) == (List.range k).any (fun i => (n >>> i) % 2 == 0))) := by decide
138
-
139
- def permutesZ9 (k : Nat) : Bool := (List.range 9).all (fun y => (List.range 9).any (fun d => k * d % 9 == y))
140
- -- the orbit of repeated ADDITION — d ↦ d + k applied t times, which is what "generates additively" means;
141
- -- writing it as t * k would have made this the same computation as permutesZ9 wearing a different name
142
- def addOrbit (k : Nat) : List Nat := (List.range 9).map (fun t => (List.range t).foldl (fun a _ => (a + k) % 9) 0)
143
- def addGeneratesZ9 (k : Nat) : Bool := (List.range 9).all (fun y => (addOrbit k).contains y)
144
- def invOf (d : Nat) : Option Nat := (List.range 9).find? (fun e => d * e % 9 == 1)
145
-
146
- -- ── multiplication permutes ℤ/9 at exactly the units — the failing parameters stated, not omitted ──
147
- theorem multiplication_permutes_z9_at_exactly_the_units :
148
- (List.range' 1 8).all (fun k => permutesZ9 k == (gcd' k 9 == 1)) := by decide
149
-
150
- -- ── repeated addition reaches all of ℤ/9 at exactly the same parameters, by a different computation ──
151
- theorem addition_generates_z9_at_exactly_the_units :
152
- (List.range' 1 8).all (fun k => addGeneratesZ9 k == (gcd' k 9 == 1)) := by decide
153
-
154
- -- ── an inverse mod 9 exists at exactly the units, across the whole ring including zero ──
155
- theorem an_inverse_mod_nine_exists_at_exactly_the_units :
156
- (List.range 9).all (fun d => (invOf d).isSome == (gcd' d 9 == 1)) := by decide
157
-
158
- -- ── and where it exists it is the fifth power: u · u⁵ ≡ 1, since |units mod 9| = 6 ──
159
- theorem the_inverse_of_a_unit_mod_nine_is_its_fifth_power :
160
- (unitsMod 9).all (fun u => u * (powMod u 5 9) % 9 == 1) := by decide
161
-
162
- -- ── A SECOND OCTAVE OF FAMILIES, 2026-09-07 ─────────────────────────────────────────────────────────────
163
- --
164
- -- Same operation as the seven above, on the families the first pass left: each was a run of ledger rows,
165
- -- one per parameter, every one revoked as "not backed by a Lean proof". The evidence they DID have was a
166
- -- TypeScript test — a computation reporting that it agreed with itself. That is a real reason to want a
167
- -- kernel proof and not a reason to call the statement dead.
168
-
169
- def powSum (k n : Nat) : Nat := ((List.range' 1 n).map (fun i => i ^ k)).foldl (· + ·) 0
170
- -- Faulhaber's closed forms, k = 1…5. The subtractions are safe in Nat: at n = 0 the truncation to zero is
171
- -- multiplied by an n that is also zero, and above n = 0 the bracket is positive.
172
- def faulhaber (k n : Nat) : Nat :=
173
- match k with
174
- | 1 => n * (n + 1) / 2
175
- | 2 => n * (n + 1) * (2 * n + 1) / 6
176
- | 3 => n * n * (n + 1) * (n + 1) / 4
177
- | 4 => n * (n + 1) * (2 * n + 1) * (3 * n * n + 3 * n - 1) / 30
178
- | 5 => n * n * (n + 1) * (n + 1) * (2 * n * n + 2 * n - 1) / 12
179
- | _ => 0
180
-
181
- -- digits, by structural recursion on a fuel argument — the same reason gcdFuel exists above: a well-founded
182
- -- definition would pull `propext` in through its equation lemmas and cost this file its axiom-free status
183
- def digitsF : Nat → Nat → List Nat
184
- | 0, _ => []
185
- | _, 0 => []
186
- | Nat.succ f, n => n % 10 :: digitsF f (n / 10)
187
- -- the fuel is n + 1, which covers every digit of every n: the earlier fuel of 20 capped this at twenty digits
188
- -- and silently truncated anything larger
189
- def digitsOf (n : Nat) : List Nat := digitsF (n + 1) n
190
- def reverseDigits (n : Nat) : Nat := (digitsOf n).foldl (fun a d => a * 10 + d) 0
191
- def digitalRoot (n : Nat) : Nat := if n == 0 then 0 else 1 + (n - 1) % 9
192
-
193
- -- ── the closed forms for the power sums, k = 1…5, against the loop they replace ──
194
- set_option maxRecDepth 100000 in
195
- theorem power_sums_match_their_closed_forms :
196
- (List.range' 1 5).all (fun k => (List.range 41).all (fun n => powSum k n == faulhaber k n)) := by decide
197
-
198
- -- ── the digital root survives writing the number backwards, for every number below ten thousand ──
199
- -- Reversal permutes the digits, the digit sum is invariant under permutation, and the digital root is a
200
- -- function of that sum. The statement is decided rather than argued.
201
- -- Walked as a hundred hundreds rather than as one list of ten thousand: `decide` evaluates a single
202
- -- `List.all` as one deep conjunction and overflows the kernel's stack at that length, which is a fact
203
- -- about the evaluator and not about the mathematics. The domain is identical — every n below 10000.
204
- -- It costs the kernel about forty-five seconds, which is most of what this file takes and a real price
205
- -- paid on every run. Measured, not guessed: shrinking the fuel changes nothing, because the cost is the
206
- -- ten thousand evaluations themselves. The range is not padding — the family's own parameters run to
207
- -- 9080, and a statement that stopped short of them would not carry the claims it exists to carry.
208
- set_option maxRecDepth 400000 in
209
- set_option maxHeartbeats 2000000 in
210
- theorem the_digital_root_is_invariant_under_digit_reversal :
211
- (List.range 100).all (fun a => (List.range 100).all (fun b =>
212
- digitalRoot (a * 100 + b) == digitalRoot (reverseDigits (a * 100 + b)))) := by decide
213
-
214
- -- ── the geometric series across bases 2…12 and every exponent to six, not one exponent at one base ──
215
- set_option maxRecDepth 100000 in
216
- theorem geometric_series_across_bases_and_exponents :
217
- (List.range' 2 11).all (fun b => (List.range 7).all (fun n =>
218
- ((List.range (n + 1)).map (fun i => b ^ i)).foldl (· + ·) 0 * (b - 1) == b ^ (n + 1) - 1)) := by decide
219
-
220
- -- ── Euler's totient at prime powers, out to thirteen ──
221
- set_option maxRecDepth 400000 in
222
- theorem totient_at_prime_powers_through_thirteen :
223
- [2, 3, 5, 7, 11, 13].all (fun p => (List.range' 1 3).all (fun k => totient (p ^ k) == p ^ k - p ^ (k - 1))) := by decide
224
-
225
- -- ── ROOTS OF UNITY IN A RING, AND THE CONVERSE THAT DOES NOT HOLD ───────────────────────────────────────
226
- --
227
- -- The ledger's roots_cancel_n rows say the n equally-spaced unit vectors cancel to the zero vector.
228
- -- That is plane geometry over the reals, and `decide` over Nat cannot express it, so those rows are NOT
229
- -- carried by anything below and stay withdrawn — saying so is the point of writing this here.
230
- --
231
- -- What IS decidable is the algebraic shadow of the same fact: in ℤ/m, the powers of an element g of
232
- -- multiplicative order n sum to zero. That is the identity (g − 1)·Σ = gⁿ − 1 = 0, and it gives Σ = 0
233
- -- only when g − 1 can be cancelled — so the statement carries its own hypothesis, gcd(g − 1, m) = 1.
234
- --
235
- -- The converse looked true and is not. Writing it as an equivalence would have been the stronger, more
236
- -- satisfying theorem; the kernel refuses it, and at m = 6 with g = 5 the sum 1 + 5 vanishes mod 6 while
237
- -- gcd(4, 6) = 2. The witness is kept as its own theorem, because a hypothesis nobody can see the need
238
- -- for gets deleted as clutter by the next reader.
239
-
240
- def rootSum (g m : Nat) : Nat := ((List.range (ordMod g m)).map (fun k => powMod g k m)).foldl (· + ·) 0
241
-
242
- set_option maxRecDepth 100000 in
243
- theorem the_powers_of_a_unit_sum_to_zero_when_g_minus_one_is_invertible :
244
- (List.range' 2 19).all (fun m => (unitsMod m).all (fun g =>
245
- !(gcd' (g - 1) m == 1) || (rootSum g m % m == 0))) := by decide
246
-
247
- theorem and_the_converse_fails_at_six :
248
- ordMod 5 6 = 2 ∧ rootSum 5 6 % 6 = 0 ∧ gcd' 4 6 = 2 := by decide
249
-
250
- -- ── A THIRD OCTAVE: THE CLASSICAL SUMS, EACH QUANTIFIED OVER ITS RANGE ──────────────────────────────────
251
- --
252
- -- Same operation again, on the families the second pass left. Several of these rows were withdrawn while
253
- -- the fact they state was ALREADY decided here — sum_first_5_odd_numbers_is_5_squared sat beside a
254
- -- theorem quantifying over every n — so the octave below is written for the ones that were genuinely
255
- -- unproved, and the rest are carried by rules in scripts/recover.ts pointing at what already existed.
256
-
257
- def vpF : Nat → Nat → Nat → Nat
258
- | 0, _, _ => 0
259
- | _, _, 0 => 0
260
- | Nat.succ f, p, n => if p > 1 && n % p == 0 then 1 + vpF f p (n / p) else 0
261
- /-- the exponent of p in n — the p-adic valuation, by fuel for the same axiom-free reason as gcdFuel -/
262
- def vp (p n : Nat) : Nat := vpF 20 p n
263
- def isSumOfTwoSquares (n : Nat) : Bool :=
264
- (List.range 15).any (fun a => (List.range 15).any (fun b => a * a + b * b == n))
265
- /-- Fermat's condition: every prime ≡ 3 (mod 4) divides n to an even power -/
266
- def everyThreeModFourPrimeIsEven (n : Nat) : Bool :=
267
- (List.range' 2 199).all (fun p => !(isPrime p && p % 4 == 3) || vp p n % 2 == 0)
268
-
269
- def digitSquareSum (n : Nat) : Nat := ((digitsOf n).map (fun d => d * d)).foldl (· + ·) 0
270
- def iterF : Nat → Nat → Nat
271
- | 0, n => n
272
- | Nat.succ f, n => if n == 1 || n == 4 then n else iterF f (digitSquareSum n)
273
-
274
- def polyRec : Nat → Nat → Nat
275
- | _, 0 => 0
276
- | s, Nat.succ m => polyRec s m + ((s - 2) * m + 1)
277
-
278
- -- ── the odd numbers build the squares, one gnomon at a time ──
279
- set_option maxRecDepth 400000 in
280
- theorem the_first_n_odd_numbers_sum_to_n_squared :
281
- (List.range 201).all (fun n => ((List.range n).map (fun i => 2 * i + 1)).foldl (· + ·) 0 == n * n) := by decide
282
-
283
- -- ── the powers of two fall one short of the next power ──
284
- set_option maxRecDepth 400000 in
285
- theorem the_powers_of_two_sum_to_one_less_than_the_next :
286
- (List.range 41).all (fun n =>
287
- ((List.range (n + 1)).map (fun i => 2 ^ i)).foldl (· + ·) 0 == 2 ^ (n + 1) - 1) := by decide
288
-
289
- -- ── stacking triangles gives tetrahedra ──
290
- set_option maxRecDepth 400000 in
291
- theorem the_sums_of_triangular_numbers_are_the_tetrahedral_numbers :
292
- (List.range 101).all (fun n =>
293
- ((List.range' 1 n).map (fun i => i * (i + 1) / 2)).foldl (· + ·) 0 == n * (n + 1) * (n + 2) / 6) := by decide
294
-
295
- -- ── a Pascal row squared sums to the central binomial ──
296
- set_option maxRecDepth 100000 in
297
- theorem the_squares_of_a_pascal_row_sum_to_the_central_binomial :
298
- (List.range 13).all (fun n =>
299
- ((List.range (n + 1)).map (fun k => choose n k * choose n k)).foldl (· + ·) 0 == choose (2 * n) n) := by decide
300
-
301
- -- ── every polygonal family: the closed form and the recurrence are the same sequence, for s = 3…10 ──
302
- set_option maxRecDepth 400000 in
303
- theorem polygonal_closed_forms_match_their_recurrences :
304
- (List.range' 3 8).all (fun s => (List.range 51).all (fun n =>
305
- ((s - 2) * n * n + 4 * n - s * n) / 2 == polyRec s n)) := by decide
306
-
307
- -- ── Lagrange in the one group this deposit is built on: every unit's order divides the group's ──
308
- -- ordMod finds the LEAST positive exponent, so minimality is by construction and not asserted here.
309
- theorem the_order_of_every_unit_mod_nine_divides_six :
310
- (unitsMod 9).all (fun u => ordMod u 9 > 0 && 6 % ordMod u 9 == 0 && powMod u (ordMod u 9) 9 == 1) := by decide
311
-
312
- -- ── the digit-square iteration is a dichotomy: every start below 201 lands on 1 or on 4 ──
313
- -- 4 is the entry to the eight-cycle, so "not happy" is a single decidable destination rather than a
314
- -- negative that would need the whole cycle enumerating.
315
- set_option maxRecDepth 400000 in
316
- theorem the_digit_square_iteration_reaches_one_or_four :
317
- (List.range' 1 200).all (fun n => iterF 60 n == 1 || iterF 60 n == 4) := by decide
318
-
319
- -- ── Fermat's two-squares theorem, decided both ways over the first two hundred ──
320
- set_option maxRecDepth 400000 in
321
- theorem a_number_is_a_sum_of_two_squares_exactly_when_fermats_condition_holds :
322
- (List.range' 1 200).all (fun n => isSumOfTwoSquares n == everyThreeModFourPrimeIsEven n) := by decide
323
-
324
- -- ── AND THE POWER SUMS OUT TO TWO HUNDRED, WHICH IS THE RANGE THE ROWS ACTUALLY CLAIM ───────────────────
325
- -- power_sums_match_their_closed_forms decides k = 1…5 at every n to forty. `the_sum_of_the_first_n_squares`
326
- -- says "verified by full enumeration over n up to 200", and forty is not two hundred: carrying it on the
327
- -- narrower theorem would have been the easy move and would have recorded a range nobody had checked.
328
- -- Every range below was read off the claim it is meant to carry, and the four theorems above were widened
329
- -- the same way — to 200, 40, 100 and 50 — rather than the claims being trimmed to fit what I had written.
330
- set_option maxRecDepth 400000 in
331
- theorem the_first_three_power_sums_hold_to_two_hundred :
332
- (List.range' 1 3).all (fun k => (List.range 201).all (fun n => powSum k n == faulhaber k n)) := by decide
333
-
334
- -- ── A FOURTH OCTAVE: FIBONACCI, COUNTING, AND THE FIVE SOLIDS ───────────────────────────────────────────
335
-
336
- /-- Fibonacci by carrying a pair forward. The two-clause recurrence `fib n + fib (n+1)` is exponential when
337
- the kernel evaluates it — `fib 25` alone is a quarter of a million calls — so it is written linearly. -/
338
- def fibPair : Nat → Nat × Nat
339
- | 0 => (0, 1)
340
- | Nat.succ n => let (a, b) := fibPair n; (b, a + b)
341
- def fib (n : Nat) : Nat := (fibPair n).1
342
- def digitSum (n : Nat) : Nat := (digitsOf n).foldl (· + ·) 0
343
-
344
- /-- the convergents of the continued fraction [1; 1, 1, 1, …], numerator and denominator carried together -/
345
- def cfPair : Nat → Nat × Nat
346
- | 0 => (1, 1)
347
- | Nat.succ n => let (p, q) := cfPair n; (p + q, p)
348
-
349
- /-- Catalan by the convolution recurrence, built as a list because C(n+1) needs every earlier term and a
350
- direct recursive call on `n - i` is not structural — the well-founded version would cost the file its
351
- axiom-free status, which is the same constraint that shaped gcdFuel and digitsF. -/
352
- def catalanList : Nat → List Nat
353
- | 0 => [1]
354
- | Nat.succ n =>
355
- let prev := catalanList n
356
- prev ++ [((List.range (n + 1)).map (fun i => prev.getD i 0 * prev.getD (n - i) 0)).foldl (· + ·) 0]
357
-
358
- def pisano (m : Nat) : Nat := ((List.range' 1 100).find? (fun k => fib k % m == 0 && fib (k + 1) % m == 1)).getD 0
359
-
360
- def interleaveN (x : Nat) : List Nat → List (List Nat)
361
- | [] => [[x]]
362
- | y :: ys => (x :: y :: ys) :: (interleaveN x ys).map (fun l => y :: l)
363
- def permsN : List Nat → List (List Nat)
364
- | [] => [[]]
365
- | x :: xs => (permsN xs).flatMap (fun p => interleaveN x p)
366
- def isInvolution (p : List Nat) : Bool := (List.range p.length).all (fun i => p.getD (p.getD i 0) 0 == i)
367
- def telephone : Nat → Nat
368
- | 0 => 1
369
- | 1 => 1
370
- | Nat.succ (Nat.succ n) => telephone (n + 1) + (n + 1) * telephone n
371
-
372
- /-- the regular polyhedra, DERIVED rather than typed: (p, q) is p-gonal faces with q meeting at a vertex,
373
- and a convex solid exists exactly where 2p + 2q > pq. Listing V, E, F for five solids would have been
374
- five rows of hand-typed data, and Euler's formula on hand-typed data checks the typing. -/
375
- def schlafli : List (Nat × Nat) :=
376
- ((List.range' 3 8).flatMap (fun p => (List.range' 3 8).map (fun q => (p, q)))).filter (fun x => 2 * x.1 + 2 * x.2 > x.1 * x.2)
377
-
378
- -- ── there are exactly five, and each satisfies V + F = E + 2 ──
379
- -- Written as V + F = E + 2 rather than V − E + F = 2: the subtraction is the same statement over ℤ and a
380
- -- truncation over Nat, and a theorem that is only true because a subtraction clipped is not a theorem.
381
- theorem there_are_exactly_five_platonic_solids_and_each_satisfies_eulers_formula :
382
- schlafli.length = 5 ∧ schlafli.all (fun x =>
383
- let d := 2 * x.1 + 2 * x.2 - x.1 * x.2
384
- 4 * x.1 % d == 0 && 2 * x.1 * x.2 % d == 0 && 4 * x.2 % d == 0 &&
385
- 4 * x.1 / d + 4 * x.2 / d == 2 * x.1 * x.2 / d + 2) := by decide
386
-
387
- -- ── Cassini: F(n−1)·F(n+1) − F(n)² alternates, so it is stated as the two cases Nat can express ──
388
- theorem cassinis_identity_holds_across_the_range :
389
- (List.range' 1 30).all (fun n =>
390
- if n % 2 == 0 then fib (n - 1) * fib (n + 1) == fib n * fib n + 1
391
- else fib (n - 1) * fib (n + 1) + 1 == fib n * fib n) := by decide
392
-
393
- -- ── the golden continued fraction: its convergents ARE the Fibonacci ratios, and the determinant is ±1 ──
394
- -- More than Cassini restated: it identifies pₙ and qₙ, which is the part a determinant identity alone
395
- -- does not say.
396
- theorem the_golden_convergents_are_fibonacci_ratios_with_unit_determinant :
397
- (List.range 25).all (fun n =>
398
- (cfPair n).1 == fib (n + 2) && (cfPair n).2 == fib (n + 1) &&
399
- -- pₙ² − pₙqₙ − qₙ² = (−1)^(n+1), which is the determinant pₙqₙ₊₁ − pₙ₊₁qₙ written out through
400
- -- qₙ₊₁ = pₙ and pₙ₊₁ = pₙ + qₙ. My first attempt compared pₙqₙ against pₙ² and the kernel refused it —
401
- -- the identity was misremembered, not the arithmetic.
402
- (if n % 2 == 0 then (cfPair n).1 * (cfPair n).1 + 1 == (cfPair n).1 * (cfPair n).2 + (cfPair n).2 * (cfPair n).2
403
- else (cfPair n).1 * (cfPair n).1 == (cfPair n).1 * (cfPair n).2 + (cfPair n).2 * (cfPair n).2 + 1)) := by decide
404
-
405
- -- ── Catalan: the convolution recurrence and the binomial formula are the same sequence ──
406
- set_option maxRecDepth 100000 in
407
- theorem the_catalan_recurrence_matches_the_binomial_formula :
408
- (List.range 13).all (fun n => (catalanList 12).getD n 0 == choose (2 * n) n / (n + 1)) := by decide
409
-
410
- -- ── the Pisano period: 24 at nine, and every modulus to twelve has one ──
411
- set_option maxRecDepth 100000 in
412
- theorem the_pisano_period_of_nine_is_twenty_four_and_every_modulus_to_twelve_has_one :
413
- pisano 9 = 24 ∧ (List.range' 2 11).all (fun m =>
414
- pisano m > 0 && fib (pisano m) % m == 0 && fib (pisano m + 1) % m == 1) := by decide
415
-
416
- -- ── the digit-sum rules for three and nine, over every number below ten thousand ──
417
- set_option maxRecDepth 400000 in
418
- set_option maxHeartbeats 2000000 in
419
- theorem the_digit_sum_rules_for_three_and_nine_hold_below_ten_thousand :
420
- (List.range 100).all (fun a => (List.range 100).all (fun b =>
421
- (digitSum (a * 100 + b) % 3 == 0) == ((a * 100 + b) % 3 == 0) &&
422
- ((digitSum (a * 100 + b) % 9 == 0) == ((a * 100 + b) % 9 == 0)))) := by decide
423
-
424
- -- ── the involutions of a finite set are counted by the telephone numbers ──
425
- -- Counted by ENUMERATING the permutations and filtering the self-inverse ones, so the recurrence is
426
- -- checked against the objects it claims to count rather than against another recurrence.
427
- set_option maxRecDepth 100000 in
428
- theorem the_involutions_are_counted_by_the_telephone_numbers :
429
- (List.range 6).all (fun n => ((permsN (List.range n)).filter isInvolution).length == telephone n) := by decide
430
-
431
- -- ── the unit inverse, stated AS an inverse. That invOf finds something at exactly the units was proved above;
432
- -- this proves what it finds: the residue multiplies back to one, and inverting twice returns the unit — so
433
- -- invOf is an involution on the six units, and the non-units, where it finds nothing, are exactly the
434
- -- residues sharing a factor with nine ──
435
- theorem invOf_is_an_inverse_and_an_involution_on_the_units :
436
- (List.range 9).all (fun d => match invOf d with
437
- | some e => d * e % 9 == 1 && invOf e == some d
438
- | none => gcd' d 9 != 1) := by decide
439
-
440
- -- ── the binomial coefficient does not see the involution k ↦ n − k: choosing k is choosing the n − k left
441
- -- behind, and applying the involution twice returns k, at every n to twelve and every k ──
442
- theorem choose_is_invariant_under_the_involution_k_to_n_minus_k :
443
- (List.range 13).all (fun n => (List.range (n + 1)).all (fun k =>
444
- choose n k == choose n (n - k) && n - (n - k) == k)) := by decide
445
-
446
- -- ── what these settle ──
447
- def settledHere : Nat := 42
448
- theorem families_settle_their_ranges : settledHere = 42 := rfl
449
-
450
-
451
- -- ── the capped rows above, proved for every value by induction — no bound ────────────────────────────────────
452
- -- the_powers_of_two_sum_to_one_less_than_the_next checked n ≤ 40; this proves it for every n.
453
- theorem the_powers_of_two_sum_to_one_less_than_the_next_for_every_n :
454
- ∀ n : Nat, ((List.range (n + 1)).map (fun i => 2 ^ i)).foldl (· + ·) 0 = 2 ^ (n + 1) - 1 := by
455
- intro n
456
- induction n with
457
- | zero => decide
458
- | succ n ih =>
459
- rw [List.range_succ, List.map_append, List.foldl_append, ih]
460
- simp only [List.map, List.foldl]
461
- have h : 1 ≤ 2 ^ (n + 1) := Nat.one_le_two_pow
462
- rw [Nat.pow_succ 2 (n + 1)]
463
- omega
464
-
465
- theorem square_of_successor : ∀ n : Nat, (n + 1) * (n + 1) = n * n + 2 * n + 1 := by
466
- intro n
467
- rw [Nat.add_mul, Nat.mul_add, Nat.mul_one, Nat.one_mul]
468
- omega
469
-
470
- -- the_first_n_odd_numbers_sum_to_n_squared checked n ≤ 200; this proves it for every n.
471
- theorem the_first_n_odd_numbers_sum_to_n_squared_for_every_n :
472
- ∀ n : Nat, ((List.range n).map (fun i => 2 * i + 1)).foldl (· + ·) 0 = n * n := by
473
- intro n
474
- induction n with
475
- | zero => decide
476
- | succ n ih =>
477
- rw [List.range_succ, List.map_append, List.foldl_append, ih]
478
- simp only [List.map, List.foldl]
479
- rw [square_of_successor]
480
- omega
481
-
482
-
483
- -- ── the capped rows above, proved for every value by induction — no bound ──────────────────────────────────
484
- -- cassinis_identity_holds_across_the_range (n ≤ 30), power_sums_match_their_closed_forms (k = 1..5, n ≤ 40),
485
- -- the_first_three_power_sums_hold_to_two_hundred (n ≤ 200) and the_sums_of_triangular_numbers_are_the_tetrahedral_
486
- -- numbers (n ≤ 100) were checked up to a bound; these prove them for every value. Core Lean has no ring tactic, so each
487
- -- polynomial step is expanded, each monomial sorted, its numeral moved to the front, and omega closes what is left.
488
- theorem cassinis_identity_for_every_m :
489
- ∀ m : Nat, fib (2 * m + 1) * fib (2 * m + 3) = fib (2 * m + 2) * fib (2 * m + 2) + 1 ∧
490
- fib (2 * m) * fib (2 * m + 2) + 1 = fib (2 * m + 1) * fib (2 * m + 1) := by
491
- intro m
492
- induction m with
493
- | zero => decide
494
- | succ m ih =>
495
- have r3 : fib (2 * m + 3) = fib (2 * m + 1) + fib (2 * m + 2) := rfl
496
- have r4 : fib (2 * m + 4) = fib (2 * m + 2) + fib (2 * m + 3) := rfl
497
- have r5 : fib (2 * m + 5) = fib (2 * m + 3) + fib (2 * m + 4) := rfl
498
- show fib (2 * m + 3) * fib (2 * m + 5) = fib (2 * m + 4) * fib (2 * m + 4) + 1 ∧
499
- fib (2 * m + 2) * fib (2 * m + 4) + 1 = fib (2 * m + 3) * fib (2 * m + 3)
500
- have h := ih.1
501
- rw [r5, r4, r3]
502
- rw [r3] at h
503
- generalize fib (2 * m + 1) = a at h ⊢
504
- generalize fib (2 * m + 2) = b at h ⊢
505
- constructor
506
- · try simp only [Nat.mul_add, Nat.add_mul, Nat.pow_succ, Nat.pow_zero, Nat.one_mul, Nat.mul_one, Nat.reduceMul, Nat.reduceAdd] at *
507
- try simp only [Nat.mul_assoc, Nat.mul_comm, Nat.mul_left_comm, Nat.reduceMul] at *
508
- try simp only [Nat.mul_comm _ (OfNat.ofNat _), Nat.mul_left_comm _ (OfNat.ofNat _), Nat.reduceMul] at *
509
- all_goals omega
510
- · try simp only [Nat.mul_add, Nat.add_mul, Nat.pow_succ, Nat.pow_zero, Nat.one_mul, Nat.mul_one, Nat.reduceMul, Nat.reduceAdd] at *
511
- try simp only [Nat.mul_assoc, Nat.mul_comm, Nat.mul_left_comm, Nat.reduceMul] at *
512
- try simp only [Nat.mul_comm _ (OfNat.ofNat _), Nat.mul_left_comm _ (OfNat.ofNat _), Nat.reduceMul] at *
513
- all_goals omega
514
-
515
- theorem a_sum_over_one_to_n_plus_one_adds_the_last_term :
516
- ∀ (g : Nat → Nat) (n : Nat),
517
- ((List.range' 1 (n + 1)).map g).foldl (· + ·) 0 = ((List.range' 1 n).map g).foldl (· + ·) 0 + g (n + 1) := by
518
- intro g n
519
- rw [List.range'_concat, List.map_append, List.foldl_append]
520
- simp only [List.map, List.foldl, Nat.one_mul, Nat.add_comm 1 n]
521
-
522
- theorem the_numbers_sum_to_their_closed_form_for_every_n : ∀ n : Nat, 2 * powSum 1 n = n * (n + 1) := by
523
- intro n
524
- induction n with
525
- | zero => rfl
526
- | succ n ih =>
527
- unfold powSum at *
528
- rw [a_sum_over_one_to_n_plus_one_adds_the_last_term]
529
- generalize ((List.range' 1 n).map (fun i => i ^ 1)).foldl (· + ·) 0 = s at ih ⊢
530
- try simp only [Nat.mul_add, Nat.add_mul, Nat.pow_succ, Nat.pow_zero, Nat.one_mul, Nat.mul_one, Nat.reduceMul, Nat.reduceAdd] at *
531
- try simp only [Nat.mul_assoc, Nat.mul_comm, Nat.mul_left_comm, Nat.reduceMul] at *
532
- try simp only [Nat.mul_comm _ (OfNat.ofNat _), Nat.mul_left_comm _ (OfNat.ofNat _), Nat.reduceMul] at *
533
- all_goals omega
534
-
535
- theorem the_squares_sum_to_their_closed_form_for_every_n : ∀ n : Nat, 6 * powSum 2 n = n * (n + 1) * (2 * n + 1) := by
536
- intro n
537
- induction n with
538
- | zero => rfl
539
- | succ n ih =>
540
- unfold powSum at *
541
- rw [a_sum_over_one_to_n_plus_one_adds_the_last_term]
542
- generalize ((List.range' 1 n).map (fun i => i ^ 2)).foldl (· + ·) 0 = s at ih ⊢
543
- try simp only [Nat.mul_add, Nat.add_mul, Nat.pow_succ, Nat.pow_zero, Nat.one_mul, Nat.mul_one, Nat.reduceMul, Nat.reduceAdd] at *
544
- try simp only [Nat.mul_assoc, Nat.mul_comm, Nat.mul_left_comm, Nat.reduceMul] at *
545
- try simp only [Nat.mul_comm _ (OfNat.ofNat _), Nat.mul_left_comm _ (OfNat.ofNat _), Nat.reduceMul] at *
546
- all_goals omega
547
-
548
- theorem the_cubes_sum_to_their_closed_form_for_every_n : ∀ n : Nat, 4 * powSum 3 n = n * n * (n + 1) * (n + 1) := by
549
- intro n
550
- induction n with
551
- | zero => rfl
552
- | succ n ih =>
553
- unfold powSum at *
554
- rw [a_sum_over_one_to_n_plus_one_adds_the_last_term]
555
- generalize ((List.range' 1 n).map (fun i => i ^ 3)).foldl (· + ·) 0 = s at ih ⊢
556
- try simp only [Nat.mul_add, Nat.add_mul, Nat.pow_succ, Nat.pow_zero, Nat.one_mul, Nat.mul_one, Nat.reduceMul, Nat.reduceAdd] at *
557
- try simp only [Nat.mul_assoc, Nat.mul_comm, Nat.mul_left_comm, Nat.reduceMul] at *
558
- try simp only [Nat.mul_comm _ (OfNat.ofNat _), Nat.mul_left_comm _ (OfNat.ofNat _), Nat.reduceMul] at *
559
- all_goals omega
560
-
561
- set_option maxRecDepth 200000 in
562
- set_option maxHeartbeats 4000000 in
563
- theorem the_fourth_powers_sum_to_their_closed_form_for_every_n :
564
- ∀ n : Nat, 30 * powSum 4 n = n * (n + 1) * (2 * n + 1) * (3 * n * n + 3 * n - 1) := by
565
- intro n
566
- induction n with
567
- | zero => rfl
568
- | succ n ih =>
569
- unfold powSum at *
570
- rw [a_sum_over_one_to_n_plus_one_adds_the_last_term]
571
- generalize ((List.range' 1 n).map (fun i => i ^ 4)).foldl (· + ·) 0 = s at ih ⊢
572
- have e2 : 3 * (n + 1) * (n + 1) + 3 * (n + 1) - 1 = 3 * n * n + 9 * n + 5 := by
573
- simp only [Nat.mul_add, Nat.add_mul, Nat.mul_one, Nat.one_mul]; omega
574
- rw [e2]
575
- cases n with
576
- | zero => simp at ih ⊢; omega
577
- | succ m =>
578
- have e1 : 3 * (m + 1) * (m + 1) + 3 * (m + 1) - 1 = 3 * m * m + 9 * m + 5 := by
579
- simp only [Nat.mul_add, Nat.add_mul, Nat.mul_one, Nat.one_mul]; omega
580
- rw [e1] at ih
581
- try simp only [Nat.mul_add, Nat.add_mul, Nat.pow_succ, Nat.pow_zero, Nat.one_mul, Nat.mul_one, Nat.reduceMul, Nat.reduceAdd] at *
582
- try simp only [Nat.mul_assoc, Nat.mul_comm, Nat.mul_left_comm, Nat.reduceMul] at *
583
- try simp only [Nat.mul_comm _ (OfNat.ofNat _), Nat.mul_left_comm _ (OfNat.ofNat _), Nat.reduceMul] at *
584
- all_goals omega
585
-
586
- set_option maxRecDepth 200000 in
587
- set_option maxHeartbeats 4000000 in
588
- theorem the_fifth_powers_sum_to_their_closed_form_for_every_n :
589
- ∀ n : Nat, 12 * powSum 5 n = n * n * (n + 1) * (n + 1) * (2 * n * n + 2 * n - 1) := by
590
- intro n
591
- induction n with
592
- | zero => rfl
593
- | succ n ih =>
594
- unfold powSum at *
595
- rw [a_sum_over_one_to_n_plus_one_adds_the_last_term]
596
- generalize ((List.range' 1 n).map (fun i => i ^ 5)).foldl (· + ·) 0 = s at ih ⊢
597
- have e2 : 2 * (n + 1) * (n + 1) + 2 * (n + 1) - 1 = 2 * n * n + 6 * n + 3 := by
598
- simp only [Nat.mul_add, Nat.add_mul, Nat.mul_one, Nat.one_mul]; omega
599
- rw [e2]
600
- cases n with
601
- | zero => simp at ih ⊢; omega
602
- | succ m =>
603
- have e1 : 2 * (m + 1) * (m + 1) + 2 * (m + 1) - 1 = 2 * m * m + 6 * m + 3 := by
604
- simp only [Nat.mul_add, Nat.add_mul, Nat.mul_one, Nat.one_mul]; omega
605
- rw [e1] at ih
606
- try simp only [Nat.mul_add, Nat.add_mul, Nat.pow_succ, Nat.pow_zero, Nat.one_mul, Nat.mul_one, Nat.reduceMul, Nat.reduceAdd] at *
607
- try simp only [Nat.mul_assoc, Nat.mul_comm, Nat.mul_left_comm, Nat.reduceMul] at *
608
- try simp only [Nat.mul_comm _ (OfNat.ofNat _), Nat.mul_left_comm _ (OfNat.ofNat _), Nat.reduceMul] at *
609
- all_goals omega
610
-
611
- theorem power_sums_match_their_closed_forms_for_every_n :
612
- ∀ k n : Nat, 1 ≤ k → k ≤ 5 → powSum k n = faulhaber k n := by
613
- intro k n h1 h5
614
- have c : k = 1 ∨ k = 2 ∨ k = 3 ∨ k = 4 ∨ k = 5 := by omega
615
- rcases c with rfl | rfl | rfl | rfl | rfl
616
- · show powSum 1 n = n * (n + 1) / 2
617
- rw [← the_numbers_sum_to_their_closed_form_for_every_n n, Nat.mul_div_cancel_left _ (by decide)]
618
- · show powSum 2 n = n * (n + 1) * (2 * n + 1) / 6
619
- rw [← the_squares_sum_to_their_closed_form_for_every_n n, Nat.mul_div_cancel_left _ (by decide)]
620
- · show powSum 3 n = n * n * (n + 1) * (n + 1) / 4
621
- rw [← the_cubes_sum_to_their_closed_form_for_every_n n, Nat.mul_div_cancel_left _ (by decide)]
622
- · show powSum 4 n = n * (n + 1) * (2 * n + 1) * (3 * n * n + 3 * n - 1) / 30
623
- rw [← the_fourth_powers_sum_to_their_closed_form_for_every_n n, Nat.mul_div_cancel_left _ (by decide)]
624
- · show powSum 5 n = n * n * (n + 1) * (n + 1) * (2 * n * n + 2 * n - 1) / 12
625
- rw [← the_fifth_powers_sum_to_their_closed_form_for_every_n n, Nat.mul_div_cancel_left _ (by decide)]
626
-
627
- theorem the_sums_of_triangular_numbers_are_the_tetrahedral_numbers_for_every_n :
628
- ∀ n : Nat, ((List.range' 1 n).map (fun i => i * (i + 1) / 2)).foldl (· + ·) 0 = n * (n + 1) * (n + 2) / 6 := by
629
- have six : ∀ n : Nat, 6 * ((List.range' 1 n).map (fun i => i * (i + 1) / 2)).foldl (· + ·) 0 = n * (n + 1) * (n + 2) := by
630
- intro n
631
- induction n with
632
- | zero => rfl
633
- | succ n ih =>
634
- rw [a_sum_over_one_to_n_plus_one_adds_the_last_term]
635
- have ev : (n + 1) * (n + 1 + 1) % 2 = 0 := by
636
- rcases Nat.mod_two_eq_zero_or_one n with e | e <;> simp [Nat.mul_mod, Nat.add_mod, e]
637
- have hd : (n + 1) * (n + 1 + 1) / 2 * 2 = (n + 1) * (n + 1 + 1) := Nat.div_mul_cancel (Nat.dvd_of_mod_eq_zero ev)
638
- generalize ((List.range' 1 n).map (fun i => i * (i + 1) / 2)).foldl (· + ·) 0 = s at ih ⊢
639
- generalize (n + 1) * (n + 1 + 1) / 2 = t at hd ⊢
640
- rw [Nat.mul_two] at hd
641
- try simp only [Nat.mul_add, Nat.add_mul, Nat.pow_succ, Nat.pow_zero, Nat.one_mul, Nat.mul_one, Nat.reduceMul, Nat.reduceAdd] at *
642
- try simp only [Nat.mul_assoc, Nat.mul_comm, Nat.mul_left_comm, Nat.reduceMul] at *
643
- try simp only [Nat.mul_comm _ (OfNat.ofNat _), Nat.mul_left_comm _ (OfNat.ofNat _), Nat.reduceMul] at *
644
- all_goals omega
645
- intro n
646
- rw [← six n, Nat.mul_div_cancel_left _ (by decide)]
647
-
648
-
649
- -- ── reflections, from the easy batch: each law beside its inverse (the 2×7 ↔ 1+6 wave) ──
650
- theorem choose_is_invariant_under_the_involution_k_to_n_minus_k_for_every_n :
651
- ∀ n k : Nat, k ≤ n → choose n k = choose n (n - k) ∧ n - (n - k) = k := by
652
- intro n k h
653
- unfold choose
654
- rw [Nat.sub_sub_self h, Nat.mul_comm]
655
- exact ⟨rfl, rfl⟩
656
-
657
-
658
- -- ── reflections, from the sums batch: each law beside its inverse (the 2×7 ↔ 1+6 wave) ──
659
- -- REFLECTIONS: each closed form differences back to its term
660
- theorem the_closed_forms_difference_back_to_the_next_power_for_every_n :
661
- ∀ k n : Nat, 1 ≤ k → k ≤ 5 → faulhaber k (n + 1) = faulhaber k n + (n + 1) ^ k := by
662
- intro k n h1 h5
663
- rw [← power_sums_match_their_closed_forms_for_every_n k (n + 1) h1 h5,
664
- ← power_sums_match_their_closed_forms_for_every_n k n h1 h5]
665
- unfold powSum
666
- exact a_sum_over_one_to_n_plus_one_adds_the_last_term (fun i => i ^ k) n
667
-
668
- theorem the_tetrahedral_numbers_difference_back_to_the_triangular_numbers_for_every_n :
669
- ∀ n : Nat, (n + 1) * (n + 1 + 1) * (n + 1 + 2) / 6 = n * (n + 1) * (n + 2) / 6 + (n + 1) * (n + 1 + 1) / 2 := by
670
- intro n
671
- rw [← the_sums_of_triangular_numbers_are_the_tetrahedral_numbers_for_every_n (n + 1),
672
- ← the_sums_of_triangular_numbers_are_the_tetrahedral_numbers_for_every_n n]
673
- exact a_sum_over_one_to_n_plus_one_adds_the_last_term (fun i => i * (i + 1) / 2) n
674
-
675
- theorem the_powers_of_two_difference_back_to_the_next_power_for_every_n :
676
- ∀ n : Nat, (2 ^ (n + 2) - 1) - (2 ^ (n + 1) - 1) = 2 ^ (n + 1) := by
677
- intro n
678
- have h : 1 ≤ 2 ^ (n + 1) := Nat.one_le_two_pow
679
- rw [Nat.pow_succ 2 (n + 1)]
680
- omega
681
-
682
- theorem the_odd_numbers_difference_back_to_the_next_odd_number_for_every_n :
683
- ∀ n : Nat, ((List.range (n + 1)).map (fun i => 2 * i + 1)).foldl (· + ·) 0 - ((List.range n).map (fun i => 2 * i + 1)).foldl (· + ·) 0 = 2 * n + 1 := by
684
- intro n
685
- rw [the_first_n_odd_numbers_sum_to_n_squared_for_every_n, the_first_n_odd_numbers_sum_to_n_squared_for_every_n,
686
- square_of_successor]
687
- omega
688
-
689
-
690
- -- ── reflections, from the extra batch: each law beside its inverse (the 2×7 ↔ 1+6 wave) ──
691
- theorem foldl_add_start : ∀ (l : List Nat) (a : Nat), l.foldl (· + ·) a = a + l.foldl (· + ·) 0 := by
692
- intro l
693
- induction l with
694
- | nil => intro a; simp
695
- | cons x xs ih =>
696
- intro a
697
- simp only [List.foldl]
698
- rw [ih (a + x), ih (0 + x)]
699
- omega
700
-
701
- theorem the_digits_sum_to_the_number_mod_nine_when_the_fuel_covers_them :
702
- ∀ f n : Nat, n < 10 ^ f → (digitsF f n).foldl (· + ·) 0 % 9 = n % 9 := by
703
- intro f
704
- induction f with
705
- | zero =>
706
- intro n h
707
- have : n = 0 := by simp at h; omega
708
- subst this
709
- simp [digitsF]
710
- | succ f ih =>
711
- intro n h
712
- cases n with
713
- | zero => simp [digitsF]
714
- | succ m =>
715
- simp only [digitsF, List.foldl]
716
- rw [foldl_add_start]
717
- have hlt : (m + 1) / 10 < 10 ^ f := by
718
- rw [Nat.pow_succ] at h
719
- omega
720
- have := ih ((m + 1) / 10) hlt
721
- omega
722
-
723
- theorem a_number_is_below_ten_to_its_own_successor : ∀ n : Nat, n < 10 ^ (n + 1) := by
724
- intro n
725
- induction n with
726
- | zero => decide
727
- | succ n ih =>
728
- rw [Nat.pow_succ]
729
- omega
730
-
731
- -- the_digit_sum_rules_for_three_and_nine_hold_below_ten_thousand, for every n
732
- theorem the_digit_sum_rules_for_three_and_nine_hold_for_every_n :
733
- ∀ n : Nat, (digitSum n % 3 = 0 ↔ n % 3 = 0) ∧ (digitSum n % 9 = 0 ↔ n % 9 = 0) := by
734
- intro n
735
- have h := the_digits_sum_to_the_number_mod_nine_when_the_fuel_covers_them (n + 1) n (a_number_is_below_ten_to_its_own_successor n)
736
- unfold digitSum digitsOf
737
- generalize (digitsF (n + 1) n).foldl (· + ·) 0 = s at h ⊢
738
- exact ⟨⟨fun a => by omega, fun a => by omega⟩, ⟨fun a => by omega, fun a => by omega⟩⟩
739
-
740
- end Families