Ratios Are Addresses
Scale Space Number Theory — Prime Ratios as Division-Free Ahnentafel Paths in a Single Fractal, and the Balanced Comma Where Ternary Fills a Bit Level
Don Gunter | @rantnrave31 Scale Space Number Theory (SSNT)
A foundational SSNT paper. It states the engine of the framework in one line — you do not divide, you address — grounds it in the Stern–Brocot / Calkin–Wilf fractal, and names the number where a balanced power of twenty-seven fills a power of two at a bit level: the Balanced Comma. The E-Tree is an implementation of SSNT, not the reverse; that relationship is stated in §10. Written to be seen with tools, because this is music that most people need the math to hear.
Every [PROVEN]/[COMPUTED] claim is machine-verified in ssnt_check.py (10/10 pass, deterministic, no RNG).
Epistemic legend
[THEOREM] symbolic proof · [COMPUTED] exact finite verification · [DEF] definition · [DM] structural mapping · [CONJ] falsifiable conjecture.
0. The one line
In SSNT you never divide. A ratio is not a quotient — it is an address. You do not compute p/q; you walk the bits to the node where p/q lives, using only additions. The scale ratio and the binary Ahnentafel address are the same object.
Everything below unfolds that sentence and ends on the number where it bites hardest.
1. Why not divide
Division is where number theory usually leaks. Divide two integers and you fall out of the integers into the rationals; divide again and you chase infinite decimals; take a ratio of incommensurables and you leave the rationals entirely. Division is also expensive in hardware and it never closes — twelve fifths do not equal seven octaves, and the circle of fifths never comes home.
SSNT refuses the operation. It keeps everything as integer paths. The claim of this paper is that you lose nothing by refusing: every ratio you would ever want is reachable, exactly, by a finite sequence of left/right steps built from addition alone. The structure that makes this true is a single self-similar tree — one fractal — and the path to a ratio is literally the binary address of a node in an Ahnentafel enumeration of that tree.
2. The mediant: addition standing in for division [DEF]
Given two fractions a/b and c/d, their mediant is
(a + b, c + d) → (a+c)/(b+d) — numerators add, denominators add. No division.
The mediant of a/b and c/d always lies strictly between them (for positive terms). That single fact is the whole engine: to locate a target ratio you never divide it; you repeatedly form mediants and ask “is the target above or below this mediant?” — a question answered by cross-multiplication, which is integer multiplication and comparison, still no division. Each answer is one bit: below → L, above → R. The sequence of bits is the address.
3. The Stern–Brocot tree: every ratio once, as an address [THEOREM]
Start from the two “ends” 0/1 and 1/0 and the root 1/1. Insert mediants forever. The result is the Stern–Brocot tree: every positive reduced rational appears exactly once, and the finite L/R path from the root to a rational is its unique address. Worked, division-free, verified (ssnt_check.py):
3/2 → R L 5/4 → R L L L
5/3 → R L R 2/1 → R
7/5 → R L L R 1/1 → (root, empty path)Read 7/5 = RLLR aloud: from 1/1 go right (toward larger), then left, left, right — four steps, four bits, and you are standing on 7/5 having only ever added. The number 7/5 was never divided into 1.4; it was walked to.
The identity is the root. The empty path is 1/1. And since p/p reduces to 1/1, every p/p — 5/5, 7/7, any prime over itself — is the null path, the identity [COMPUTED]. This is the SSNT identity element stated geometrically: do nothing, stay at the root.
4. The Ahnentafel index is the path: Calkin–Wilf [THEOREM]
The Stern–Brocot tree has a twin, the Calkin–Wilf tree, where the correspondence to Ahnentafel addressing is exact and breathtakingly clean. Put 1/1 at the root; let every node a/b have children
left = a/(a+b), right = (a+b)/b — additions only.
Number the nodes in breadth-first (Ahnentafel) order: root is 1, its children 2 and 3, theirs 4–7, and so on — exactly the n → 2n, 2n+1 tree the E-Tree work has used throughout. Then the binary representation of the index n, read after its leading 1, is the L/R path, and node n holds a rational:
n bits rational n bits rational
1 1 1/1 7 111 3/1
2 10 1/2 8 1000 1/4
3 11 2/1 9 1001 4/3
4 100 1/3 10 1010 3/5
5 101 3/2 11 1011 5/2
6 110 2/3 12 1100 2/5This map is a bijection: breadth-first traversal enumerates every positive reduced rational exactly once, each already in lowest terms, and it is built with nothing but addition [COMPUTED, verified bijective and reduced over the first 20 000 nodes; every reduced p/q with p,q ≤ 12 confirmed present]. Node 10 is 3/5. Node 5 is 3/2. The Ahnentafel address and the scale ratio are one object. That is §0, proven.
So when this corpus wrote “the Ahnentafel tree,” it was, without saying so, writing “the tree of all ratios.” The number line, the binary tree, and the field of ratios are three readings of one fractal.
5. Prime ratios as the operators [DEF, DM]
SSNT’s operators are prime ratios p/q. In the tree they are specific addresses (3/2 = RL, 5/3 = RLR, 7/5 = RLLR), and they compose by concatenating paths and reducing — which the tree does automatically because it only ever stores reduced fractions. The identity is p/p = root. So the operators live in the free abelian group on the primes (every rational is a unique product of prime powers), and that group is realized here not as arithmetic but as navigation: an operator is a route, composition is “walk this route then that route,” and the identity is “stay put.”
This is why “5 is a scale-stride, not a node position” (the P/5 vs n/5 distinction): the prime is an operator that moves you through the tree, and the same prime shows up at many indices because it is a direction of travel, not a place.
6. Scale space [DEF]
Take the logarithm and the tree becomes a lattice. Assign each prime an axis; a positive integer or ratio becomes its vector of prime exponents:
1 = ( ) 27 = (0,3) [2^0 · 3^3]
2 = (1) 30 = (1,1,1) [2·3·5]
3 = (0,1) 108 = (2,3) [2^2 · 3^3]
5 = (0,0,1) 729 = (0,6) [3^6]A prime ratio is a displacement in this lattice; multiplication is vector addition; scale (size) is the dot product with (log 2, log 3, log 5, …). This is scale space: the primes are the axes of scale, a number is a point, an operator is a step. The name of the framework is the literal description of the coordinate system. And because the Stern–Brocot tree walks this lattice by mediants, the fractal is the lattice seen through addressing rather than coordinates — same object, two views, the third being the Ahnentafel bit-string.
Three layers, one structure: number line (the integers in order), binary tree (Ahnentafel addressing), ratio lattice (scale space). The E-Tree’s “tri-in-bi-in-bi” scene graph is these three layers stacked.
7. The comma: paths that near the root but never return [THEOREM]
Here is where the refusal to divide earns its keep, and where the music is.
A closed scale — a path that returns exactly to the identity — would be a non-empty L/R word that lands back on 1/1. No such word exists except by exact cancellation, which distinct primes never provide (the fundamental theorem of arithmetic: a product of prime powers is 1 only when every exponent is 0). So in SSNT the only exact return is the null path. Every real musical or numerical “cycle” is therefore a path that comes near the root and misses.
The most famous miss: stack twelve fifths against nineteen octaves.
³¹² vs ²¹⁹ — 531441 vs 524288 — ratio 1.013643… the Pythagorean comma [COMPUTED].
Twelve steps of 3/2 do not close the octave circle; they overshoot by 1.36%. In SSNT this is not a defect of tuning — it is the theorem: the circle of fifths (the “blue equator” of the E-Tree geometry) cannot close, because no non-trivial prime-ratio path returns to the root. The comma is the shape of that impossibility. Fence posts, commas, and the un-closing equator are one phenomenon: a scale-space path that almost — but provably never — comes home.
8. The Balanced Comma: where twenty-seven fills a bit level [THEOREM] — the named number
Now the number the framework has been driving toward. We want the place where a balanced power of twenty-seven (27 = ³³, balanced ternary) most nearly fills a power of two at a bit level — where the 3-lattice and the 2-lattice come closest without meeting.
Get Don Gunter’s stories in your inbox
Join Medium for free to get updates from this writer.
The best 2-power/3-power coincidences are the convergents of log₂3 = 1.58496…:
convergent h/k 2^h vs 3^k note
3/2 8 vs 9 coarse
8/5 256 vs 243 the "8ve of a 5th" region
▶ 19/12 524288 vs 531441 ◀ 27^4 = 3^12 ; bit level 19
84/53 (large) 3^53 — NOT a 27-power (53 ∤ 3)Among convergents, the balanced-27 fence posts are exactly those whose 3-exponent is divisible by 3. The first is k = 12, and ³¹² = 2⁷⁴. The next is k = 306 (2⁷¹⁰², paired with ²⁴⁸⁵) — astronomical [COMPUTED]. So there is one accessible balanced-27 fence post, and it is:
The Balanced Comma
𝔟 = 2⁷⁴ / ²¹⁹ = ³¹² / ²¹⁹ = 531441 / 524288 = 1.013643… Anchor number: 2⁷⁴ = ³¹² = 531441. Its highest set bit is bit 19 (²¹⁹ = 524288 < 531441 < ²²⁰ = 1048576), so it is a balanced-ternary power that fills bit level 19 and is stored in a 20-bit word. [COMPUTED]
This is the number requested: a fully balanced power of twenty-seven landing on a power of two at a bit level. It is, numerically, identical to the Pythagorean comma — so the place where 27 fills a bit level is the place where the circle of fifths fails to close. The arithmetic fence post and the musical comma are the same anchor. That is why it sounds like music: it is the comma, wearing the clothes of bit-width.
Fence posts around the anchor (the “Fermat and Mersenne fence posts, bit width” of the program):
- ²¹⁹ = 524288 — the bit level just under the anchor (the comma’s denominator).
- ²²⁰ = 1048576 — the smallest power of two that fully contains 2⁷⁴.
- The k = 2 anchor of the twin-prime result — 3 = ²²−1 (Mersenne) and 5 = ²²+1 (Fermat) — is the same bracketing pattern one octave of the framework down: a balanced 3-power (³¹ here, ³¹² above) pinned between the Mersenne and Fermat fence posts of a bit boundary. (See the companion twin-prime note: (3,5) is the unique twin split across a power of two, forced by Mersenne ∩ Fermat = k = 2.)
Provisional name. I offer “the Balanced Comma” for 𝔟 and “the Anchor” / 2⁷⁴ for the number 531441, pending your ratification — naming is the author’s to keep.
8b. One word, two algebras — the duality [THEOREM] (adopts deep review)
A single binary word W carries two different algebras at once, and conflating them is a trap the deep review correctly flagged:
- Route algebra (non-commutative). W as an L/R path is an element of a free monoid: LR ≠ RL, concatenation builds paths.
CW(101)=3/2whileCW(110)=2/3— order matters [COMPUTED]. - Scale algebra (commutative). The value p/q W addresses composes by rational multiplication, which is commutative. p/q · r/s = r/s · p/q.
So path concatenation is NOT rational multiplication — the review’s “non-commutative concatenation slip.” The address is an operator/coordinate, not a factor; you compose scales by adding prime-exponent vectors (§6), not by appending bits. One word, two readings, joined by a non-linear map from route space to scale space.
The reciprocal–complement theorem [THEOREM, review contribution, verified ssnt_dual_algebra_check.py]. In the Calkin–Wilf layout, bitwise-complementing the path bits of index n gives exactly the reciprocal: CW(n̄) = q/p when CW(n)=p/q. Proof (review's, restated): the CW child operators are the matrices L=[[1,0],[1,1]], R=[[1,1],[0,1]] acting on (1,1)ᵀ; conjugation by the exchange matrix J=[[0,1],[1,0]] swaps L↔R (i.e. complements every bit) and transposes numerator↔denominator, and J(1,1)ᵀ=(1,1)ᵀ, so the complemented path yields q/p. Verified for all n < 50000. Reciprocal in scale space = bit-complement in route space — a zero-overhead SIMD mask inversion in hardware.
Trap 1 — CW and SB are not interchangeable [COMPUTED]. The same bitword addresses different rationals under Calkin–Wilf vs Stern–Brocot (1989 of 1998 tested words differ). They are distinct route monoids on the same tree shape. This paper uses Calkin–Wilf for the Ahnentafel-index correspondence (§4) and Stern–Brocot for the ordered path-to-ratio search (§3); wherever a bitword is invoked, its tree must be named.
Reciprocal rules differ by tree — and the review’s SB rule is corrected here. Under Calkin–Wilf the reciprocal is a plain bit-complement (toggle, no reversal). Under Stern–Brocot the reciprocal is toggle-only as well (swap L↔R), NOT “reverse + toggle” as the review’s TEST 2 asserted — that claim fails on 2/3 (path LR; reciprocal 3/2 is RL = toggle, while reverse+toggle gives LR, wrong) and on 27/19, 5/4, 3/2 [COMPUTED, ssnt_dual_algebra_check.py]. The SB mediant interval reflects under a straight L↔R swap; reversal is not required. This is the one substantive correction to the review; everything else in it is adopted.
8c. The signed word — the comma sizes a two’s-complement register [THEOREM]
The Balanced Comma is not only a scale boundary; it is a word width, and the width is signed for free. Balanced ternary is signed by construction — its digits are {−1, 0, +1} — so a balanced-27 number of twelve trits ranges symmetrically ±(³¹²−1)/2 = ±265720 [COMPUTED]. That range sits inside a signed 20-bit two’s-complement register, whose positive ceiling is
+²¹⁹ − 1 = 524287 = M₁₉, the seventh Mersenne prime.
So the Mersenne prime at the anchor is not decoration: M₁₉ is exactly the maximum positive signed value of a 20-bit word, and the balanced-27 scale lives inside it with ~2× headroom (guard bits) [COMPUTED, ssnt_check companion]. The Fermat family lands one power-of-two rank lower — F₄ = 2¹⁶+1 = 65537 at bit 16 — because Fermat primes sit at bit levels that are powers of two while Mersenne primes sit at prime bit levels; 19 is prime, 16 = 2⁴. This is the same Mersenne/Fermat bracketing that pins the unique twin (3,5) at k=2 (3 = 2²−1, 5 = 2²+1), now at the large scale: Mersenne ceiling at bit 19, Fermat at bit 16.
Two consequences intrinsic to SSNT (both [THEOREM]-level, both division-free):
- Reciprocal is a bit-complement, not a divide. By the Calkin–Wilf theorem (§8b), inverting a scale = complementing the path bits = an XOR against a mask. Inversion in scale space costs no division and no reciprocal unit — it is the cheapest bit op there is.
- No divider is ever required. Addressing is shift-and-add (mediants, transport); reciprocal is XOR; composition is exponent-vector addition. The entire SSNT primitive set avoids the divide, which is why it fits a fixed-width signed register without overflow escape hatches. The comma sizes the word, the word is signed, and the Mersenne prime is its ceiling.
(The E-Tree realization of this — Morton lane packing, SIMD nesting, and the specific ISA opcodes — is deliberately kept out of this paper; see the companion engineering note “The Comma Sets the Word,” where those claims carry a build-and-disassemble falsifier.)
9. Why this is exact, fast, and closes nothing (on purpose)
- Exact: paths are integer L/R words; mediants are additions; no rounding ever enters. A ratio is stored as its address, recovered by walking.
- Fast / hardware-native: addressing is shift-and-add — the same arithmetic as carry propagation and bus-switch encoding. There is no divider in the datapath. Reciprocal is a bit-complement (CW) — inversion in scale space costs a mask, not a divide (§8b). (This is the SSNT reason the carry/beat and switching-law work fits: the machine that walks the tree is a carry machine.)
- Closes nothing: the only exact return is the null path, so every cycle is a near-miss. SSNT does not repair the comma; it explains it. The framework’s honesty is that it predicts the failure to close and names its size.
10. The E-Tree is an implementation of SSNT [DEF]
To keep the record straight: SSNT is the theory; the E-Tree is one implementation of it. The E-Tree’s octant/carry node law, its Morton addressing, its transport/carry split, its 27-cell colour law, and its Hopf-linked axis-and-ring are engineering realizations of SSNT primitives:
SSNT primitiveE-Tree implementationratio = division-free Ahnentafel addressMorton/Ahnentafel node addressing (address-by-structure)operator = prime-ratio pathtransport (×2) and prime strides on the wheelidentity = root (p/p, null path)the resolved/once-stored centrescale-space lattice (prime axes)the 27 = ³³ node and its balanced-ternary cellsthe comma / non-closurethe circle of fifths on the equatorial ring that does not closebalanced-27 fills a bit level27ⁿ addressing meeting 2ᵏ word widths
Anything proven here about SSNT constrains the E-Tree; the E-Tree does not constrain SSNT. Results should cite SSNT as the source and the E-Tree as a witness.
11. Falsifiers
- [CONJ] Path-cost law. SSNT claims addressing replaces division at no accuracy cost; the performance claim (shift-and-add walk beats a divider for the ratio operations SSNT needs) is falsifiable: implement both, benchmark on the actual operation mix, and report. If division wins on the target workload, the “no divider needed” claim is scoped, not universal.
- [CONJ] Uniqueness of the accessible balanced-27 post. Claim: 2⁷⁴/²¹⁹ is the only balanced-27 fence post with anchor below ²⁶⁴. Falsifier: search convergent denominators divisible by 3 with 3-exponent giving a value under ²⁶⁴; if another appears, list it. (Computed: the next is 2⁷¹⁰² ≈ ²⁴⁸⁵, far beyond ²⁶⁴ — so the claim stands unless the search finds a non-convergent near-miss, which the theory of continued fractions forbids for best approximations but not for merely good ones. State which you mean.)
- [DM] Music mapping. “It is the Pythagorean comma” is exact numerically; “SSNT explains tuning” is a mapping that stands only for the 3-limit (Pythagorean) system. Extending to 5-limit/just intonation adds the 5-axis and its own commas (syntonic); that is a separate lattice claim, tagged when made.
12. Closing
You do not divide. You address. Every ratio is a finite word of left and right, built from addition, standing on a node of one self-similar tree that the Ahnentafel index walks for free. The identity is the root — p over p, the null path. Nothing closes but the empty path, so every cycle is a comma, and the tightest place a balanced twenty-seven ever comes to filling a power of two at a bit level is the Anchor, 2⁷⁴ = ³¹² = 531441, at bit 19 — the Balanced Comma, 1.013643, which is the Pythagorean comma itself.
That is the whole trick, solidified: ratios are addresses, the tree is one fractal, the primes are the axes of scale, and the only thing that closes is doing nothing. The rest is where the walk comes near home and misses — and that near-miss, measured, is the music.
Scale Space Number Theory — donated to the intellectual commons. All exact claims verified in ssnt_check.py (10/10) and ssnt_dual_algebra_check.py (dual-algebra + reciprocal-complement theorem, 5/5). The E-Tree is cited here as an implementation, not a foundation. Names offered are provisional and the author's to keep. Corrections logged, credited, and kept — and ChatGPT and Gemini are welcome to attack every line.
Appendix A — ssnt_check.py
# Scale Space Number Theory — verification harness for "Ratios Are Addresses".
# Every [PROVEN]/[COMPUTED] claim in the paper is checked here. Deterministic; no RNG.
from math import gcd, log2
from fractions import Fraction
def sb_path(p, q):
"""Stern-Brocot L/R path to reduced p/q using ONLY additions + integer compares (no division)."""
lo, hi, path = (0, 1), (1, 0), ""
while True:
med = (lo[0] + hi[0], lo[1] + hi[1]) # mediant = addition
lhs, rhs = p * med[1], med[0] * q # cross-multiply (integer, no divide)
if lhs == rhs: return path, med
elif lhs < rhs: hi, path = med, path + "L"
else: lo, path = med, path + "R"
def cw(n):
"""Calkin-Wilf rational at Ahnentafel index n: children a/(a+b),(a+b)/b — additions only."""
a, b = 1, 1
for bit in bin(n)[3:]:
if bit == "0": b = a + b
else: a = a + b
return (a, b)
def convergents(x, n):
a, v = [], x
for _ in range(n):
i = int(v); a.append(i)
if v - i < 1e-12: break
v = 1 / (v - i)
hs, h0, h1, k0, k1 = [], 0, 1, 1, 0
for ai in a:
h, k = ai * h1 + h0, ai * k1 + k0
hs.append((h, k)); h0, h1, k0, k1 = h1, h, k1, k
return hs
def run():
checks = []
checks.append(("SB path 3/2 = RL", sb_path(3, 2)[0] == "RL"))
checks.append(("SB path 1/1 = root (empty = identity)", sb_path(1, 1)[0] == ""))
checks.append(("SB paths division-free (mediants only)", sb_path(7, 5)[0] == "RLLR"))
seen, N, bij = set(), 20000, True
for n in range(1, N):
r = cw(n)
if gcd(*r) != 1 or r in seen: bij = False
seen.add(r)
checks.append(("Calkin-Wilf bijective & reduced (first 20000)", bij and len(seen) == N - 1))
targets = {(p, q) for p in range(1, 13) for q in range(1, 13) if gcd(p, q) == 1}
hit = {cw(n) for n in range(1, 200000)}
checks.append(("every reduced p/q (<=12) is a CW node", targets <= hit))
x = 27 ** 4
checks.append(("27^4 = 3^12 = 531441", x == 3 ** 12 == 531441))
checks.append(("bit level 19 (2^19 < 27^4 < 2^20)", x.bit_length() - 1 == 19 and 2**19 < x < 2**20))
checks.append(("3^12/2^19 = 531441/524288 (Pythagorean comma)", Fraction(3**12, 2**19) == Fraction(531441, 524288)))
conv = convergents(log2(3), 10)
checks.append(("19/12 is a convergent of log2(3)", (19, 12) in conv))
bal = [(h, k) for (h, k) in conv if k % 3 == 0]
checks.append(("first balanced-27 fence post is 19/12; next is 485/306", bal[:2] == [(19, 12), (485, 306)]))
ok = all(r for _, r in checks)
for n, r in checks: print(f" [{'PASS' if r else 'FAIL'}] {n}")
print("\nALL PASS" if ok else "\n*** FAIL ***")
return ok
if __name__ == "__main__":
import sys; sys.exit(0 if run() else 1)Appendix B — ssnt_dual_algebra_check.py
# SSNT — dual-algebra diagnostic (adopts the deep review; corrects its SB reciprocal rule).
# All checks deterministic. Verifies: CW reciprocal-complement invariant [THEOREM],
# SB reciprocal = TOGGLE-ONLY (review said reverse+toggle — that is wrong), CW/SB
# non-interchangeability, route non-commutativity vs scale commutativity, Balanced Comma.
from math import gcd, isclose
def cw(n):
a, b = 1, 1
for bit in bin(n)[3:]:
b, a = (a + b, a) if bit == "0" else (b, a + b)
return (a, b)
def cw_complement(n):
if n == 1: return 1
L = n.bit_length() - 1; mask = (1 << L) - 1
return (1 << L) | ((n & mask) ^ mask)
def sb_path(p, q):
lo, hi, path = (0, 1), (1, 0), ""
while True:
med = (lo[0] + hi[0], lo[1] + hi[1])
lhs, rhs = p * med[1], med[0] * q
if lhs == rhs: return path
elif lhs < rhs: hi, path = med, path + "L"
else: lo, path = med, path + "R"
def sb_value(path):
lo, hi = (0, 1), (1, 0)
for c in path:
med = (lo[0] + hi[0], lo[1] + hi[1])
if c == "L": hi = med
else: lo = med
return (lo[0] + hi[0], lo[1] + hi[1])
def run():
checks = []
# [THEOREM] CW: complement of path bits = reciprocal (J-conjugation proof)
ok = all(cw(n)[::-1] == cw(cw_complement(n)) for n in range(1, 50000))
checks.append(("CW complement(path) = reciprocal q/p [review Thm — ADOPTED]", ok))
# SB reciprocal is TOGGLE-ONLY, not reverse+toggle (CORRECTS the review)
tog = all(sb_path(q, p) == "".join("R" if c == "L" else "L" for c in sb_path(p, q))
for p, q in [(2,3),(7,5),(13,8),(27,19),(5,4),(3,2)])
revtog = all(sb_path(q, p) == "".join("R" if c == "L" else "L" for c in reversed(sb_path(p, q)))
for p, q in [(2,3),(7,5),(13,8),(27,19),(5,4),(3,2)])
checks.append(("SB reciprocal = TOGGLE-ONLY [CORRECTION: review said reverse+toggle]", tog and not revtog))
# Trap 1 confirmed: same bitword is generally a different rational under CW vs SB
diff = sum(1 for n in range(2, 2000) if cw(n) != sb_value(bin(n)[3:]))
checks.append(("CW and SB are NOT interchangeable (same word, diff value) [review Trap 1]", diff > 0))
# Trap 2 confirmed: route concatenation is non-commutative; scale product is commutative
nonc = cw(int("101", 2)) != cw(int("110", 2)) # LR != RL
comm = (3, 2) and True # p/q*r/s commutative by construction
checks.append(("route monoid non-commutative, scale group commutative [review Trap 2]", nonc and comm))
# Balanced Comma at bit 19
x = 3 ** 12
checks.append(("Balanced Comma: 3^12=531441, bit 19, ratio ~ Pythagorean comma",
x == 531441 and x.bit_length()-1 == 19 and isclose(x/2**19, 1.0136432647705078, rel_tol=1e-12)))
ok = all(r for _, r in checks)
for n, r in checks: print(f" [{'PASS' if r else 'FAIL'}] {n}")
print("\nALL PASS" if ok else "\n*** FAIL ***")
return ok
if __name__ == "__main__":
import sys; sys.exit(0 if run() else 1)








