-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenesis.py
More file actions
executable file
·436 lines (374 loc) · 19.7 KB
/
Copy pathgenesis.py
File metadata and controls
executable file
·436 lines (374 loc) · 19.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
#!/usr/bin/env python3
"""
genesis.py — ZFA landscape spectrum explorer
Starts from the first distinction (one signed generator pair, the minimal
+g/-g), builds the closure census, treats cycle-order as a frequency octave
hierarchy, and measures the fractal structure of closures at each frequency.
It computes REAL combinatorics and reports MEASURED exponents. It does not
prove physics. Every printed result carries an epistemic tag:
[EXACT] exact integer/limit combinatorics, machine-checkable
[MEASURED] an empirical exponent fitted from the instrument (can vary)
[STRUCTURAL] an identification / reading, not derived here
[LEAN] machine-checked in the Lean layer (module named)
[OPEN] conjecture or pending check, stated at full weight
Two DISTINCT fractal signatures are measured and kept separate:
* spectral (census) exponent -> counts conjugate pairs p, slope -p/2
* swap-graph growth exponent -> effective spatial dimension (#62 probe)
Conflating them would be an error; they answer different questions.
Pure standard library (math, cmath, fractions, collections). No network.
Run: python3 genesis.py
"""
from __future__ import annotations
import math, cmath
from collections import deque
from functools import lru_cache
# ----------------------------------------------------------------------
# helpers: least-squares slope, tagged printing
# ----------------------------------------------------------------------
def slope(xs, ys):
"""Least-squares slope of ys vs xs."""
n = len(xs)
mx = sum(xs) / n
my = sum(ys) / n
num = sum((x - mx) * (y - my) for x, y in zip(xs, ys))
den = sum((x - mx) ** 2 for x in xs)
return num / den if den else float("nan")
def rule(title):
print("\n" + "=" * 70)
print(title)
print("=" * 70)
# ----------------------------------------------------------------------
# 1. THE FIRST DISTINCTION -> the binary closure census
# One conjugate pair (+g, -g). A length-2n word over {+g,-g} closes
# iff it is balanced (net-zero ledger). Generated = 4^n, realized =
# C(2n,n). This is the firebreak census; its 1/sqrt(pi n) tail is the
# census->pi anchor that feeds alpha.
# ----------------------------------------------------------------------
def binary_census(n: int):
total = 4 ** n # 2^(2n) sequences of +/- steps
realized = math.comb(2 * n, n) # balanced (closed) ones
return total, realized, realized / total
# ----------------------------------------------------------------------
# 2. MULTI-PAIR CENSUS -> p independent conjugate pairs (candidate axes)
# A length-L=2m word over 2p generators closes iff every pair balances:
# a closed L-step walk on the p-dimensional integer lattice.
# closed_walks(p,m) = C(2m,m) * c_p(m),
# c_p(m) = sum_{j1+..+jp=m} multinomial(m;j)^2,
# via c_p(m) = sum_k C(m,k)^2 * c_{p-1}(m-k), c_1 = 1. Exact integers.
# ratio ~ C * m^{-p/2}: the spectral exponent encodes the pair count.
# ----------------------------------------------------------------------
@lru_cache(maxsize=None)
def c_pair(p: int, m: int) -> int:
if p == 1:
return 1
return sum(math.comb(m, k) ** 2 * c_pair(p - 1, m - k) for k in range(m + 1))
def multipair_census(p: int, m: int):
total = (2 * p) ** (2 * m)
realized = math.comb(2 * m, m) * c_pair(p, m)
return total, realized, realized / total
def spectral_exponent(p: int, m_lo: int, m_hi: int):
"""Fit log(ratio) vs log(m) -> slope ~ -p/2 [MEASURED, converges to EXACT]."""
ms = list(range(m_lo, m_hi + 1))
logm = [math.log(m) for m in ms]
logr = [math.log(multipair_census(p, m)[2]) for m in ms]
return slope(logm, logr)
# ----------------------------------------------------------------------
# 3. FREQUENCY-OCTAVE HIERARCHY -> the closure spectrum
# Octave j has order n = 2^j. Closure entropy = log2(#closures) = bits.
# Energy per closure = log 2 (dF = -log 2). Equal contribution per
# octave (constant increment) is the self-similar / scale-invariant
# signature; a log-periodic residual would signal discrete scale
# invariance. We measure both and report honestly.
# ----------------------------------------------------------------------
def octave_spectrum(j_max: int, p: int = 1):
rows = []
for j in range(0, j_max + 1):
n = 2 ** j
if p == 1:
_, realized, ratio = binary_census(n)
else:
_, realized, ratio = multipair_census(p, n)
bits = math.log2(realized)
rows.append((j, n, bits, ratio))
return rows
def self_similarity(rows):
"""Increment of closure-bits per octave; constant => scale invariant."""
incr = [rows[k + 1][2] - rows[k][2] for k in range(len(rows) - 1)]
ratios = [incr[k + 1] / incr[k] for k in range(len(incr) - 1) if incr[k]]
return incr, ratios
def dft_logperiodic(p: int, n_max: int):
"""
Remove the smooth Stirling trend from census-bits and DFT the residual
against index to look for discrete-scale-invariance (log-periodic) power.
For the pure binary census the residual is tiny; we report the dominant
non-DC power so 'no signal' is stated rather than assumed.
"""
ns = list(range(2, n_max + 1))
resid = []
for n in ns:
if p == 1:
realized = math.comb(2 * n, n)
smooth = 2 * n - 0.5 * math.log2(math.pi * n) # C(2n,n) ~ 4^n/sqrt(pi n)
else:
realized = multipair_census(p, n)[1]
smooth = math.log2((2 * p) ** (2 * n)) - (p / 2) * math.log2(math.pi * n)
resid.append(math.log2(realized) - smooth)
# de-mean, then O(N^2) DFT magnitude
mean = sum(resid) / len(resid)
r = [x - mean for x in resid]
N = len(r)
mags = []
for kf in range(1, N // 2 + 1):
acc = sum(r[t] * cmath.exp(-2j * math.pi * kf * t / N) for t in range(N))
mags.append(abs(acc) / N)
peak = max(mags) if mags else 0.0
rms = math.sqrt(sum(x * x for x in r) / N)
return peak, rms
# ----------------------------------------------------------------------
# 4. SWAP-GRAPH GROWTH -> the #62 "sees 3D" dimension probe
# Nodes = arrangements of a multiset (closure-neutral composites).
# Edge = one adjacent transposition (a pointer swap; ledger-preserving).
# Ball growth |{v : swap-dist <= r}| ~ r^D gives the effective spatial
# dimension D. Whether the 6+2 -> 3-axis structure yields D~3 is the
# OPEN #62 question; this measures D, it does not assume it.
# ----------------------------------------------------------------------
def multiset_arrangement_count(counts):
total = sum(counts)
denom = 1
for c in counts:
denom *= math.factorial(c)
return math.factorial(total) // denom
def swap_neighbors(state):
out = []
s = list(state)
for i in range(len(s) - 1):
if s[i] != s[i + 1]:
s[i], s[i + 1] = s[i + 1], s[i]
out.append(tuple(s))
s[i], s[i + 1] = s[i + 1], s[i]
return out
def swap_growth_exponent(counts, cap=60000):
"""
BFS from the sorted arrangement; fit log(cumulative ball) vs log(radius)
over the interior range. Returns (exponent, n_nodes, diameter) or None
if the configuration space exceeds `cap` nodes.
"""
n_nodes = multiset_arrangement_count(counts)
if n_nodes > cap:
return None
# sorted start state, e.g. counts=(2,3) -> (0,0,1,1,1)
start = tuple(sym for sym, c in enumerate(counts) for _ in range(c))
seen = {start: 0}
frontier = deque([start])
level_sizes = {0: 1}
while frontier:
v = frontier.popleft()
d = seen[v]
for w in swap_neighbors(v):
if w not in seen:
seen[w] = d + 1
level_sizes[d + 1] = level_sizes.get(d + 1, 0) + 1
frontier.append(w)
diameter = max(level_sizes)
# cumulative ball sizes
radii, balls, run = [], [], 0
for r in range(0, diameter + 1):
run += level_sizes.get(r, 0)
radii.append(r)
balls.append(run)
# fit interior 20%-80% of the radius range (avoid origin/saturation)
lo = max(1, int(0.2 * diameter))
hi = max(lo + 1, int(0.8 * diameter))
xs = [math.log(r) for r in radii[lo:hi + 1] if r > 0]
ys = [math.log(b) for r, b in zip(radii, balls)][lo:hi + 1]
if len(xs) < 2:
return None
return slope(xs, ys), n_nodes, diameter
def swap_dimension_ladder(half_counts, cap=200_000):
"""
Finite-size ladder for the binary (k,k) swap-graph: measure the ball-growth
exponent D(k) as the system grows, and test whether it converges.
Returns (rows, delta_D, lin_slope) where
rows = [(k, nodes, diameter, D), ...]
delta_D = successive increments D(k+1)-D(k) [~constant => linear => diverges]
lin_slope = least-squares slope of D vs k [>0 and steady => no finite limit]
The extrapolation, NOT any single finite D, is what bears on #62 -- and here it
shows the naive ball-growth diverges, so this instrument does not support D=3.
"""
rows = []
for k in half_counts:
res = swap_growth_exponent((k, k), cap=cap)
if res is None:
continue
D, nn, diam = res
rows.append((k, nn, diam, D))
ks = [r[0] for r in rows]
Ds = [r[3] for r in rows]
delta_D = [Ds[i + 1] - Ds[i] for i in range(len(Ds) - 1)]
lin_slope = slope(ks, Ds) if len(ks) >= 2 else float("nan")
return rows, delta_D, lin_slope
# ----------------------------------------------------------------------
# 5. CONSTANTS SECTOR -> where census combinatorics meets physics
# census -> pi (Wallis; pi ~ 1/(n*ratio^2)), and alpha^-1 = 128 + d^2.
# pi convergence is [EXACT] in the limit; the alpha identification is
# [STRUCTURAL] (derived in QLF_FineStructureSubstrate / rigidity module),
# and the 0.036 residual is [OPEN].
# ----------------------------------------------------------------------
def pi_from_census(n_values):
out = []
for n in n_values:
ratio = math.comb(2 * n, n) / 4 ** n
out.append((n, 1.0 / (n * ratio * ratio))) # -> pi as n grows
return out
def alpha_table(d_values):
out = []
for d in d_values:
inv = 128 + d * d
out.append((d, inv, is_prime(inv)))
return out
def is_prime(k: int) -> bool:
if k < 2:
return False
i = 2
while i * i <= k:
if k % i == 0:
return False
i += 1
return True
# ----------------------------------------------------------------------
# 6. PARTICLE MAP -> internal structure -> quantum numbers -> mass/m_e
# Since m = 1/R = frequency (QLF_HiggsMechanism), the frequency hierarchy
# (sec 3) IS the mass spectrum. Internal dimensions (sec 4, D>3) are
# gauge/color, not 3D space. Every mass is a ratio to the electron. The
# proton & pion ratios reuse THIS run's pi (sec 5 census) and 137 (128+d^2);
# all values are reused from the cited verified Lean modules, not new fits.
# ----------------------------------------------------------------------
def particle_map():
pi5 = math.pi ** 5 # pi from the closure census (sec 5)
inv_alpha = 128 + 3 * 3 # 137, from 128 + d^2 at d=3 (sec 5)
# name, internal structure, quantum numbers, m/m_e (QLF), measured, tag
return [
("electron", "min chiral loop", "L q=-1 gen1", 1.0, 1.0, "[ref]"),
("muon", "gen-2 lepton", "L q=-1 gen2", 206.77, 206.768, "[depth]"),
("tau", "3-phase Koide", "L q=-1 gen3", 3477.4, 3477.23, "[Derived]"),
("proton", "3 colors |S3|=6", "B=+1 q=+1", 6 * pi5, 1836.153, "[Derived]"),
("pion+-", "2 quarks |S2|=2", "B=0 q=+-1", 2 * inv_alpha, 273.132, "[Derived]"),
]
# ----------------------------------------------------------------------
# report
# ----------------------------------------------------------------------
def main():
print(__doc__.strip())
rule("1. THE FIRST DISTINCTION (binary closure census)")
print(f"{'n':>3} {'generated 4^n':>16} {'realized C(2n,n)':>18} {'ratio':>12}")
for n in [1, 2, 3, 4, 6, 8, 12, 16]:
t, r, q = binary_census(n)
print(f"{n:>3} {t:>16} {r:>18} {q:>12.6f}")
print("\n[EXACT] ratio = C(2n,n)/4^n -> 1/sqrt(pi n). The first distinction's")
print(" closure fraction already carries pi; this is the alpha anchor.")
rule("2. MULTI-PAIR CENSUS (spectral exponent counts conjugate pairs)")
print(f"{'p (pairs)':>10} {'fitted slope':>14} {'expected -p/2':>16}")
for p in [1, 2, 3, 4]:
s = spectral_exponent(p, 6, 40)
print(f"{p:>10} {s:>14.4f} {(-p/2):>16.4f}")
print("\n[EXACT] slope -> -p/2: the census fractal exponent IS the pair count.")
print("[STRUCTURAL] 3 spatial pairs -> slope -3/2 ; the 8-twist/4-pair -> -2.")
print("[LEAN] anchored at low orders (QLF_CensusWalk): p=1 = the closure census;")
print(" p=2 = C(2m,m)^2 = the machine-checked pi return density (sumChooseSq_eq_central,")
print(" census_p2_is_return_density). General-p + the -p/2 asymptotic = Wallis residual.")
rule("3. FREQUENCY-OCTAVE HIERARCHY (closure spectrum, p=1)")
rows = octave_spectrum(6, p=1)
print(f"{'octave j':>9} {'n=2^j':>7} {'closure-bits':>14} {'ratio':>12}")
for j, n, bits, q in rows:
print(f"{j:>9} {n:>7} {bits:>14.4f} {q:>12.3e}")
incr, iratios = self_similarity(rows)
print(f"\nbits increment per octave : {[round(x,3) for x in incr]}")
print(f"successive increment ratio: {[round(x,4) for x in iratios]}")
print("[MEASURED] increment ratio -> 2 (each octave doubles n, ~doubles the")
print(" extensive 2n term): self-similar cascade across frequency.")
print("[STRUCTURAL] m = 1/R = frequency (QLF_HiggsMechanism, mass_is_gauge_fold_delay):")
print(" this frequency hierarchy IS the mass spectrum -- frequency determines")
print(" mass. The particle assignments referenced to m_e are in sec 6.")
peak, rms = dft_logperiodic(1, 40)
print(f"\nlog-periodic residual: peak power={peak:.3e}, rms={rms:.3e}")
verdict = "no significant" if peak < 3 * rms / math.sqrt(38) else "a candidate"
print(f"[MEASURED] {verdict} discrete-scale-invariance signal in the binary")
print(" sector. If DSI exists it lives in multi-pair / swap sectors.")
rule("4. SWAP-GRAPH GROWTH (#62 dimension probe: measured, not assumed)")
print(f"{'multiset':>16} {'#nodes':>9} {'diam':>6} {'growth exponent D':>18}")
configs = [(6, 6), (8, 8), (10, 10), # binary balanced
(3, 3, 3), (4, 4, 4), # 3 symbol types
(2, 2, 2, 2), (3, 3, 3, 3), # 4 symbol types
(6, 2), (4, 2, 2)] # 6+2 flavours
for cfg in configs:
res = swap_growth_exponent(cfg)
if res is None:
print(f"{str(cfg):>16} {'(too big)':>9}")
continue
D, nn, diam = res
print(f"{str(cfg):>16} {nn:>9} {diam:>6} {D:>18.3f}")
print("\n[MEASURED] growth exponent D of the pointer-swap configuration space.")
print("[STRUCTURAL] D>3 = INTERNAL (gauge/color) dimensions, not 3D space (Jim's reading):")
print(" the EXTERNAL 3D is the receipt quotient (#62, pointer_swap_fuzz.py ~2.94);")
print(" the excess beyond 3 is the internal color DOF = stronger forces (sec 6).")
rule("4b. SWAP-GRAPH EXTRAPOLATION (does D converge? finite-size ladder)")
rows, dD, lin = swap_dimension_ladder(range(4, 11))
print(f"{'k (=(k,k))':>10} {'#nodes':>9} {'diam':>6} {'D(k)':>8}")
for k, nn, diam, D in rows:
cross = " > 3" if D > 3 else ""
print(f"{k:>10} {nn:>9} {diam:>6} {D:>8.4f}{cross}")
print(f"\nD increments D(k+1)-D(k): {[round(x,3) for x in dD]}")
print(f"linear slope of D vs k : {lin:.4f} (steady & positive)")
print("[MEASURED] D does NOT converge -- it climbs past 3 and keeps rising")
print(" (~ k*log2/log k -> infinity). The '~3 at moderate size' is a CROSSING.")
print("[STRUCTURAL] NOT a failed 3D probe (Jim's reading): the external 3D is the")
print(" receipt-quotient (~2.94, pointer_swap_fuzz.py); the growth beyond 3 is")
print(" the INTERNAL gauge/color structure -- more internal DOF = stronger")
print(" forces / more binding = heavier (frequency=mass, sec 6).")
rule("5. CONSTANTS SECTOR (census meets physics; tagged)")
print("census -> pi (pi ~ 1/(n*ratio^2)):")
for n, est in pi_from_census([10, 100, 1000, 10000, 100000]):
print(f" n={n:>7} pi ~ {est:.6f} (err {abs(est-math.pi):.2e})")
print("[EXACT] converges to pi in the limit (Wallis / Stirling).")
print("\nalpha^-1 = 128 + d^2:")
for d, inv, pr in alpha_table([1, 2, 3, 4, 5]):
mark = " <- 137, prime, elementary" if inv == 137 else ""
print(f" d={d} -> {inv:>4} {'prime' if pr else 'composite'}{mark}")
print("[STRUCTURAL] d=3 substrate-derived (6+2 split); 128=2^7 selectivity.")
print("[EXACT] the joint holds at exactly d=3 (cross-sector; see rigidity module).")
print("[OPEN] the 0.036 residual (QED running) is NOT here; census-derivation open.")
rule("6. PARTICLE MAP (frequency=mass; internal structure -> quantum #s -> m/m_e)")
print("m = 1/R = frequency (QLF_HiggsMechanism): the sec-3 frequency hierarchy IS the")
print("mass ladder. Internal dims (sec 4, D>3) = gauge/color, not 3D space. Every mass")
print("is a ratio to the electron; proton & pion reuse THIS run's pi and 137 (sec 5).\n")
print(f"{'particle':>9} {'internal':>16} {'quantum #s':>13} {'m/m_e QLF':>11} {'measured':>10} {'tag':>10}")
for name, intern, qn, qlf, meas, tag in particle_map():
print(f"{name:>9} {intern:>16} {qn:>13} {qlf:>11.2f} {meas:>10.2f} {tag:>10}")
print("\n[Derived] proton 6*pi^5 = |S3|*pi^5 (3-colour permutation x internal angular,")
print(" QLF_LenzMassRatio, 0.002%); pion 2/alpha = |S2|/alpha (2 quarks x exposed")
print(" chirality, QLF_PionMassRatio); tau via Koide Q=2/3 given m_e,m_mu (QLF_Koide).")
print("[STRUCTURAL] internal dimension = colour charge (Borromean 3, QLF_QuarkStructure);")
print(" charge in thirds from 3 colours; generations = 3 axis-pairs (= sec-2 p=3).")
print("[Hypothesis] deeper internal (higher-D) structure = stronger colour binding = heavier;")
print(" swap-graph symbol-count <-> quark/colour content (falsifiable, untested).")
print("[DEFEATER] every row shows the measured value; any mismatch falsifies that assignment.")
rule("WHAT THIS COMPUTES vs CLAIMS (misses at full weight)")
for line in [
"COMPUTES [EXACT] : the closure census, the -p/2 spectral exponent,",
" census->pi convergence, the 128+d^2 joint at d=3.",
"READS : frequency=mass (m=1/R), so the octave hierarchy IS the",
" mass spectrum; D>3 = internal gauge/color (external 3D =",
" receipt quotient); particle map to m_e (sec 6).",
"DERIVED (reused) : proton 6*pi^5, pion 2/alpha, tau Koide -- ratios to m_e,",
" verified in QLF_LenzMassRatio/PionMassRatio/Koide.",
"HYPOTHESIS : swap-graph symbol-count <-> quark/color content; deeper",
" internal structure = stronger binding = heavier (untested).",
"STILL OPEN : DSI (none in binary sector); the alpha 0.036 residual; the",
" ABSOLUTE mass scale (needs closure depth + QCD, not census).",
"NOT A PROOF : an exploratory instrument. The Lean layer, not this,",
" is where the verified ratios live.",
]:
print(" " + line)
print()
if __name__ == "__main__":
main()