Skip to content

Commit 2305f2d

Browse files
committed
wip
1 parent 7af8545 commit 2305f2d

13 files changed

Lines changed: 3714 additions & 23 deletions

File tree

essays/NAM/CAS.md

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
---
2+
specifies: main.mac
3+
related:
4+
- README.md
5+
---
6+
7+
# CAS Companion Goals: Numbers as Machines (NAM)
8+
9+
This document specifies goals for an agentic coding process tasked with writing a
10+
companion verification/experimentation script for the NAM essay. NAM is an
11+
_architecture_ essay rather than a theorem essay, so the companion's job is to build a
12+
**small, honest reference prototype** of the generator-VM substrate and to use it to
13+
**empirically confirm or falsify** the essay's structural claims.
14+
15+
A CAS (Maxima) is useful for the symbolic/number-theoretic checks (periodicity,
16+
valuations, BBP modular structure, state-dimension recurrences). A systems language
17+
is not required for the prototype — a high-level language with exact bignums
18+
(Python+gmpy2, or Maxima's own Lisp layer) suffices to demonstrate every claim. The
19+
LLVM/ABI claims are validated _structurally_ (state layout, fork cost) rather than by
20+
actually emitting machine code.
21+
22+
---
23+
24+
## 0. Infrastructure / Harness Goals
25+
26+
- **G0.1 — The step primitive.** Implement the core interface
27+
`step : State → (digit, State)` as the single contract every number satisfies.
28+
Provide a driver that pulls N digits and a `take(vm, N)` helper.
29+
- **G0.2 — Fork primitive with cost accounting.** Implement `fork(vm)` and instrument
30+
it to report whether the fork was an O(1) value copy (automaton tier) or required a
31+
deep copy of growing accumulators (series tier). Cost accounting is the point of
32+
the two-tier ABI; make it measurable.
33+
- **G0.3 — Base/codec separation.** Implement `in_base(vm, b)` as a _projection_
34+
wrapper, demonstrating that changing base does not change the underlying generator.
35+
36+
---
37+
38+
## 1. The MUX / Coalgebra Foundation
39+
40+
- **G1.1 — MUX combinator.** Implement `MUX(selector, left, right)` as a generator
41+
over generators and demonstrate it builds: a number (digit function), a vector
42+
(MUX over numbers), and a matrix (MUX over vectors) — the uniform nesting claim.
43+
- **G1.2 — Final-coalgebra sanity.** Demonstrate the digit-stream functor framing by
44+
showing two VMs are bisimilar iff they emit identical streams on a finite prefix
45+
(necessarily prefix-only, since full equality is undecidable — see G7).
46+
47+
---
48+
49+
## 2. Signed-Digit Arithmetic (the carry problem)
50+
51+
- **G2.1 — Carry non-locality demonstration.** Implement _naive_ standard-base addition
52+
and exhibit the failure: show that the first digit of `0.4999... + 0.5000...` cannot
53+
be committed from any finite prefix (the combinator stalls). This is the essay's
54+
motivating pathology; reproduce it concretely.
55+
- **G2.2 — Avizienis signed-digit fix.** Implement signed-digit (redundant)
56+
representation with digits in {−(b−1),...,b−1} and show that addition becomes
57+
digit-local with bounded look-ahead — the same input now commits digits.
58+
- **G2.3 — Streaming arithmetic.** Confirm addition, subtraction, and multiplication
59+
are genuinely streaming (online) under signed digits, with the codec layer
60+
projecting back to a non-redundant alphabet only on emission.
61+
62+
---
63+
64+
## 3. p-Adics as Periodic Automata (the clean case)
65+
66+
- **G3.1 — Periodic generator.** Implement a p-adic rational as a finite-state machine
67+
and verify its digit expansion is ultimately periodic with a finite state orbit.
68+
- **G3.2 — Local digit commitment.** Demonstrate the essay's key contrast: p-adic
69+
digit commitment is _local_ (no tail oracle, no interval refinement) because a term
70+
of valuation v affects only positions ≤ v. Implement `valuation(a_n)` and show
71+
low-order digits computed from a finite term subset.
72+
- **G3.3 — Metric as product automaton.** Implement the p-adic distance
73+
`p^{−v_p(x−y)}` for two periodic generators as a product automaton over their state
74+
spaces, and confirm it is itself a finite periodic machine.
75+
76+
---
77+
78+
## 4. The "Odd Primitives" (series tier)
79+
80+
- **G4.1 — Series stepper + tail-bound oracle.** Implement `series_step` and
81+
`tail_bound` for at least e (Σ1/n!) and one of {π via a known series, log 2}.
82+
Verify the tail bound is rigorous: the emitted digit never gets revised once
83+
committed.
84+
- **G4.2 — Interval refinement engine.** Implement `refine_interval` /
85+
`emit_digit_if_safe` and demonstrate online digit extraction as the interval
86+
collapses.
87+
- **G4.3 — Exact-boundary honesty.** Demonstrate the documented caveat: a value that
88+
is exactly 0.5 in base 10 may _never_ commit a leading digit in finite time. Show
89+
the engine correctly returns "pending" rather than lying — and that the
90+
interval-based predicates (G7) handle it gracefully.
91+
92+
---
93+
94+
## 5. State-Dimension Complexity Tiers (the central conjecture)
95+
96+
The essay's headline table claims minimal VM state dimension grows: rationals (1),
97+
quadratic irrationals (2), classical transcendentals (3–4), higher transcendentals
98+
(4–6+), inaccessible (unbounded).
99+
100+
- **G5.1 — Minimal recurrence orders.** For rationals and quadratic irrationals, build
101+
the minimal-state generator and confirm the logical register count (1 and 2
102+
respectively) and O(log n) bit-width growth. Symbolically derive the order-2
103+
recurrence for √2, φ, √3.
104+
- **G5.2 — Transcendental state tier.** Build generators for π and e and _measure_
105+
live state (number of coupled accumulators + index/error state). Report the observed
106+
dimension. The script should explicitly flag that this is an _upper witness_, not a
107+
proven lower bound (the essay is honest that minimality is an open problem).
108+
- **G5.3 — Non-minimal engine cross-check (ties to PI_RCC).** Implement the x+sin(x)
109+
cubic engine from the PI_RCC companion _as a generator VM_ and confirm it carries
110+
MORE live state than the 3–4 minimal figure for π — directly illustrating the
111+
essay's "the table tracks the floor; specific engines sit on or above it" remark.
112+
This is the key cross-essay consistency check.
113+
- **G5.4 — Inaccessible = O(n).** Demonstrate that a "random"/encrypted stream
114+
generator requires state growing with digits emitted (O(n)), contrasting with the
115+
O(log n) bit-width of accessible numbers.
116+
117+
---
118+
119+
## 6. BBP / Skip-Ahead (automaton-codec resonance)
120+
121+
- **G6.1 — Base-16 π digit extraction.** Implement the BBP formula and a `skip(n)`
122+
primitive that computes the n-th hex digit of π via repeated-squaring modular
123+
exponentiation, _without_ computing predecessors. Verify against a reference π in
124+
base 16.
125+
- **G6.2 — Fast-forward is O(log n).** Confirm skip cost scales as O(log n) (modular
126+
exponentiation), not O(n), by timing/operation-counting against n.
127+
- **G6.3 — Codec dependence.** Demonstrate the essay's "property of the projection, not
128+
the number" claim: show the base-16 generator admits skip while the base-10
129+
generator does not (no _known_ fast-forward). Frame the base-10 absence honestly as
130+
conjectural, per the essay.
131+
- **G6.4 — Genuine periodicity vs fast-forwardable.** Contrast a truly periodic case
132+
(a rational, or a periodic p-adic) where skip is exact finite-orbit jumping, against
133+
π-in-base-16 where skip is the repeated-squaring structure — confirming the essay's
134+
flagged distinction that "periodicity" is shorthand that overstates the symmetry in
135+
the transcendental case.
136+
137+
---
138+
139+
## 7. Equality / Comparison (interval-honest, undecidable)
140+
141+
- **G7.1 — Predicate family.** Implement `definitely_less_than`,
142+
`agrees_with(digits=N)`, and `compare(max_digits=N) → {Less|Greater|Indistinguishable}`.
143+
Show they never claim exact equality.
144+
- **G7.2 — Undecidability witness.** Demonstrate concretely (e.g. two different
145+
generators for the same constant) that `agrees_with` can only ever confirm a finite
146+
prefix, never decide true equality — the Rice's-theorem boundary made operational.
147+
148+
---
149+
150+
## 8. Randomness as Inaccessible Determinism
151+
152+
- **G8.1 — PRNG-as-number.** Wrap a small deterministic PRNG (e.g. a counter through a
153+
hash) as a `step`-conforming generator and show it is a perfectly valid number whose
154+
generator is small but _cryptographically inaccessible_ from the output.
155+
- **G8.2 — Accessibility classification.** Provide a function/report that classifies a
156+
generator as accessible / cryptographically-inaccessible / computably-inaccessible,
157+
and emphasize (per the essay) that the distinction is epistemic, not ontological —
158+
the digit-driver behaves identically for all three.
159+
160+
---
161+
162+
## 9. The Two-Tier ABI (structural validation)
163+
164+
- **G9.1 — Struct-layout mirror.** Mirror the essay's `AutomatonVM` (fixed inline
165+
state[4]) and `SeriesVM` (immutable spec + mutable accumulators) as data structures,
166+
and verify the fork-cost claims structurally: AutomatonVM fork is a pure value copy;
167+
SeriesVM fork must deep-copy the accumulators.
168+
- **G9.2 — Codec-in-payload.** Verify that the base lives in a payload/flag field and
169+
that swapping it does not alter the ABI or the underlying generator (re-confirms
170+
G0.3 at the struct level).
171+
172+
---
173+
174+
## 10. Cross-Essay PNT Consistency
175+
176+
- **G10.1** Confirm the same number-theoretic input `log lcm(1,...,M) = ψ(M) ~ M`
177+
appears in NAM's series-tier bit-width accounting exactly as in the RCC and PI_RCC
178+
companions. Run the shared ψ(M)/M → 1 check and assert the constant is consistent
179+
across all three companion scripts. This is the "load-bearing number-theoretic
180+
input recurs in all three" thread from the trilogy README.
181+
182+
---
183+
184+
## 11. Reporting Contract
185+
186+
Emit a report that, per claim, states: (claim, prototype-verified? yes/no, measured
187+
quantity, honest caveat where the essay flags one). The headline verdicts are:
188+
signed-digit makes addition local (G2.2), p-adic commitment is local (G3.2), the
189+
state-dimension table holds as an _upper-witness_ hierarchy (G5), BBP skip is O(log n)
190+
and codec-dependent (G6), equality is only prefix-decidable (G7.2), and the two-tier
191+
fork-cost split is real (G9.1). Every "open problem" the essay flags (state
192+
minimality, base-10 BBP absence, randomness metaphysics) must be reported as
193+
_probed but not settled_, never as proven.

essays/NAM/README.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -362,13 +362,25 @@ a **reformulation rather than a discovery**.
362362
What the generator-VM model contributes is a _first-class library primitive_ that lifts this phenomenon out of one-off
363363
optimizations and into the ABI:
364364
365-
**A BBP-type formula exists exactly when the generator automaton has a periodic orbit under the chosen codec.**
365+
**A BBP-type formula corresponds to the generator automaton admitting an O(log n) fast-forward under the chosen codec —
366+
in the cleanest cases, a periodic orbit; more generally, a sub-automaton whose n-th state is reachable by repeated
367+
squaring (modular exponentiation) rather than by stepping through all n predecessors.**
368+
369+
The honest form of the claim is a correspondence, not a strict equivalence: the existence of a known BBP-type extraction
370+
formula is what licenses installing a `skip` opcode, and that opcode is implemented by the modular-exponentiation
371+
structure underlying the formula. Calling this "a periodic orbit" is exact only in the genuinely periodic cases
372+
(rationals, periodic p-adics); for π in base 16 the precise mechanism is the repeated-squaring fast-forward of a partial
373+
sum modulo a moving denominator. We use "periodicity" below as a convenient shorthand for this broader fast-forwardable
374+
structure, and flag here that the shorthand overstates the symmetry in the transcendental case.
366375
367376
In base 16, the π-generator VM has a periodic sub-automaton. The codec (base 16) aligns with that periodic structure,
368-
exposing a fast-forward opcode: you can jump ahead in the automaton's orbit in O(log n) time rather than stepping
369-
through all n digits.
377+
exposing a fast-forward opcode: you can jump ahead in the automaton's state in O(log n) time — via repeated squaring of
378+
the relevant modular quantities — rather than stepping through all n digits. (Strictly, this is the fast-forwardable
379+
structure described above, of which a true finite periodic orbit is the special case.)
370380
371381
In base 10, the same automaton has no such periodic orbit under that codec. No fast-forward is possible.
382+
(More carefully: no such O(log n) fast-forward is _known_; the absence of a base-10 BBP formula for π is an empirical
383+
and conjectural state of affairs, not a proven impossibility.)
372384
373385
This is not a property of π. It is a property of the π-generator under a specific projection. The base is a lens on the
374386
automaton's structure. Some lenses expose periodicity; others do not.
@@ -415,7 +427,10 @@ struct size does not grow as you emit more digits.
415427
416428
**Quadratic irrationals** (√2, φ, √3) require two coupled registers — a second-order recurrence. The field count is
417429
fixed; the bit-width grows as O(log n) for the n-th digit. These are algebraic of degree 2, and the generator reflects
418-
that exactly.
430+
that exactly. (Note that the `AutomatonVM` struct over-provisions with `state[4]` so that a single fixed layout covers
431+
algebraic numbers up to degree 4; the _logical_ register count for a degree-d algebraic number is d, even though the
432+
_physical_ struct reserves a uniform four-word slot. The complexity metric below counts logical, minimal registers, not
433+
the padded struct width.)
419434
420435
**Transcendentals** (π, e, log(2), ζ(3)) require more coupled accumulators, error-control state, and index tracking.
421436
Still O(log n) bit-width growth, but with a strictly richer invariant structure — more fields, more intertwined
@@ -441,6 +456,13 @@ ascending sequence of irreducible generator-complexity classes, each requiring g
441456
correctness over an unbounded digit stream. Whether the sequence is strictly ascending in a provable sense is a question
442457
for computable analysis complexity theory; the architecture is committed to making the question well-posed and
443458
instrumentable, not to settling it.
459+
A subtlety worth flagging, since it connects to the companion essays: the state-dimension figures above are claims about
460+
the _minimal_ generator for a constant, not about any particular generator one might choose to run. The x + sin(x) cubic
461+
engine for π analyzed in the companion PI_RCC essay, for instance, carries more live state than the 3–4 register figure
462+
— it maintains a growing rational seed plus Taylor-truncation accumulators — yet it computes the same π. This is not a
463+
contradiction: a constant's complexity class is the infimum of state dimension over all correct generators, and a
464+
deliberately non-minimal engine (chosen for its cubic outer convergence rather than for state economy) sits above that
465+
infimum. The table tracks the floor; specific engines sit on or above it.
444466
445467
---
446468

0 commit comments

Comments
 (0)