feat(B-0623): PR1 — Cayley-Dickson doubling primitive (foundation of the imaginary stack)#4587
Conversation
…leyDickson.fs First constructive-proof slice for B-0623 acceptance bullet #3. Implements the structural primitive underlying the "imaginary stack" Aaron + Mika named in the 2026-05-18 boot-sequence design conversation: generic Cayley-Dickson doubling that lifts any algebra with addition, negation, multiplication, and conjugation to its doubled algebra. Applied iteratively, the primitive produces the canonical imaginary stack — Real → Complex → Quaternion → Octonion → Sedenion — with the classical loss pattern at each step (ordering, commutativity, associativity, alternativity). Aaron 2026-05-21 named the imaginary stack as the deeper concern relative to Adinkras themselves; this PR ships the substrate so Adinkras can decorate it in subsequent PRs. Implementation: - IAlgebra<'A> dictionary interface (operations: Zero, Add, Negate, Mul, Conj). Dictionary form rather than F# SRTPs so the structural lift `IAlgebra<'A> → IAlgebra<Doubled<'A>>` is directly expressible. - Doubled<'A> record type with Real + Imag fields. - Doubled.algebra : IAlgebra<'A> → IAlgebra<Doubled<'A>> — the Cayley-Dickson construction itself. - Real.algebra : IAlgebra<float> — base case of the stack. - Type aliases Complex / Quaternion / Octonion / Sedenion making the imaginary-stack stratification readable at the type level. - ImaginaryStack module with pre-computed algebra instances at each level. Tests (tests/Tests.FSharp/Algebra/CayleyDickson.Tests.fs, 12 tests): - Complex: i² = −1, addition + multiplication commutative, conjugation flips imaginary sign - Quaternion: i² = −1 (inherited), multiplication LOSES commutativity (i·j ≠ j·i), addition stays commutative, multiplication still associative - Octonion: addition stays commutative, multiplication LOSES associativity (exhibited via specific triple) - Structural: Zero is additive identity at every level, Negation is additive inverse at every level Build gate: dotnet build -c Release → 0 warnings, 0 errors. Test gate: dotnet test (CayleyDicksonTests filter) → 12 passed, 0 failed. Composes with B-0699 (dual-Adinkra time-aware-default rule; the primitive here is the load-bearing structure that B-0699 says should default to time-aware Z-state-compatible form). Subsequent PRs in this trajectory: - PR2: Binary linear code + doubly-even self-dual check + small Adinkra construction on top of this primitive - PR3: Toy key-derivation from [8,4,4] code - PR4: Composition with retractable Z-state primitive (z⁻¹/D/I) and verification that algebraic laws survive composition Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a new Core algebraic primitive implementing generic Cayley–Dickson doubling (the basis for the “imaginary stack”), plus targeted algebra-law regression tests for ℂ/ℍ/𝕆 and project wiring.
Changes:
- Introduces
src/Core/CayleyDickson.fswithIAlgebra<'A>,Doubled<'A>, the doubling lift, and precomputed stack instances. - Adds
tests/Tests.FSharp/Algebra/CayleyDickson.Tests.fscovering commutativity/associativity loss points and structural identities across levels. - Wires both new files into their respective
.fsprojcompile lists.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/Tests.FSharp/Tests.FSharp.fsproj | Adds the new Cayley–Dickson test file to the test project compilation list. |
| tests/Tests.FSharp/Algebra/CayleyDickson.Tests.fs | New unit tests asserting core properties across complex/quaternion/octonion levels. |
| src/Core/Core.fsproj | Adds the new Cayley–Dickson module to Core compilation order. |
| src/Core/CayleyDickson.fs | New implementation of generic Cayley–Dickson doubling plus stack aliases/instances. |
Comments suppressed due to low confidence (1)
src/Core/CayleyDickson.fs:33
- P1 (performance):
Doubled<'A>is a small numeric carrier type that will likely be created in tight loops; as a reference-type record it allocates on every construction. Marking it as a struct record avoids per-element heap allocations and matches existing Core conventions for small value carriers.
type Doubled<'A> = { Real: 'A; Imag: 'A }
Forward-signal: 2 unresolved threads investigated + verified (Otto-CLI cold-boot 2026-05-22T00:11Z)Tick fired under dotgit-saturated tier (384 stuck Both threads verified against PR head Thread 1 —
|
Remove named attribution from current-state Core comments and fix the octonion typo in the Cayley-Dickson test comments. Focused checks: - rg -n 'Aaron|Mika|ℕ' src/Core/CayleyDickson.fs tests/Tests.FSharp/Algebra/CayleyDickson.Tests.fs - git diff --check Note: dotnet test tests/Tests.FSharp/Tests.FSharp.fsproj -c Release --filter CayleyDickson produced no output for ~2 minutes in the temp clone and was stopped; the patch is comment-only. Co-Authored-By: Codex <noreply@openai.com>
…et-rescued, in active decomposition (#4595) * tick(1208Z): fresh cold-boot during 3-proc Lior saturation; orphaned-branch verification finds new B-0623 Adinkras+ECC commit (81243c5) NOT-YET on main but in active peer decomposition; substrate-honest non-action Continues 2026-05-21T01:49Z tick shard's orphaned-branch triage of otto/2012z-... with one newly-emerged commit since (81243c5 landed 2026-05-22T01:26Z with BinaryCode.fs 386 lines + Adinkra tests 152 lines). Root checkout inherited peer-Otto stale branch; verified-against- main shows commit's substrate is genuinely unique (not rescued). B-0623 is in active peer-agent decomposition (#4587 + #4582 + #4584 already merged); future PR2..N expected from peers. Substrate-honest disposition: do NOT cherry-pick the pre- decomposition blob; defer to in-flight decomposition. Land the classification shard so future cold-boot Otto inherits the read without re-doing the verification. 3-proc Lior process check at tick-start: 2525 (lior-loop-tick), 3052 + 8181 (gemini -p Act as Lior --yolo). Verify-before-defer composition applied per codeql-canary rule; post-worktree guards passed (status=0, tree_size=54, no stale index.lock). Sentinel 9335ec34 armed (autonomous-loop * * * * *). End tick. Co-Authored-By: Claude <noreply@anthropic.com> * fix(1208Z): correct cross-shard relative-paths — 4 ups was wrong (sibling date-dirs only need ../21/...) Lint `audit-tick-shard-relative-paths.ts` caught 4 broken refs on lines 7/12/57/62 — all targeted `../../../../2026/05/21/0149Z.md` which resolves to `docs/hygiene-history/2026/05/21/0149Z.md` (missing the `ticks/` segment). Correct form for sibling tick-shard date dirs is `../21/0149Z.md` (1 up from `2026/05/22/` to `2026/05/` then descend into `21/`). Local re-run: ok: scanned 1146 tick shards; 0 broken relative-path links. Co-Authored-By: Claude <noreply@anthropic.com> * fix(1208Z): clarify body row 540 lines arithmetic (per Copilot review) Copilot caught internal inconsistency: header said "540 lines" but body row breakdown showed only 386 + 152 = 538. git show --stat for 81243c5 reports all 4 files: src/Core/BinaryCode.fs | 386 ++++ src/Core/Core.fsproj | 1 + tests/Tests.FSharp/Algebra/Adinkra.Tests.fs | 152 +++ tests/Tests.FSharp/Tests.FSharp.fsproj | 1 + 4 files changed, 540 insertions(+) 540 is correct (the .fsproj +1 entries account for the 2-line gap). Body row now lists all 4 entries explicitly with the `git show --stat reports 540 total` clarification so reader can reconcile against header without consulting source. Codex P2 finding (broken ../../../../ paths) is stale — already fixed in commit 4791225. Thread resolution deferred until GraphQL rate-limit recovers (~25 min). Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
Summary
src/Core/Algebra.fsWhat's in this PR
src/Core/CayleyDickson.fs(+161 LOC):IAlgebra<'A>— dictionary interface (Zero / Add / Negate / Mul / Conj); chosen over F# SRTPs so the structural liftIAlgebra<'A> → IAlgebra<Doubled<'A>>is directly expressibleDoubled<'A>— record type with Real + Imag fieldsDoubled.algebra— the Cayley-Dickson construction itself (one function, ~20 lines)Real.algebra— base caseComplex = Doubled<float>,Quaternion = Doubled<Complex>,Octonion = Doubled<Quaternion>,Sedenion = Doubled<Octonion>— imaginary-stack stratification readable at the type levelImaginaryStackmodule with pre-computed algebra instances at each leveltests/Tests.FSharp/Algebra/CayleyDickson.Tests.fs(+172 LOC, 12 tests):Test plan
dotnet build src/Core/Core.fsproj -c Release→ 0 warnings, 0 errorsdotnet testCayleyDicksonTests filter → 12 passed, 0 failedTrajectory (subsequent PRs)
Composes with
src/Core/Algebra.fs(Weight ring) — sibling module; shares the algebraic-primitive conventionssrc/Core/ToffoliGate.fs— already-existing reversible-gate primitive in Zeta; PR4 will composeDoubledpayloads with Toffoli-gate-class operationsNote on PR creation
Opened via REST API (
gh api -X POST .../pulls) because GraphQL budget was exhausted at creation time (resets in 6 min). Auto-merge arming requires GraphQL — will arm post-reset.🤖 Generated with Claude Code