Skip to content

feat(B-0623): PR1 — Cayley-Dickson doubling primitive (foundation of the imaginary stack)#4587

Merged
AceHack merged 2 commits into
mainfrom
feat/b0623-pr1-cayley-dickson-doubling-2026-05-21
May 22, 2026
Merged

feat(B-0623): PR1 — Cayley-Dickson doubling primitive (foundation of the imaginary stack)#4587
AceHack merged 2 commits into
mainfrom
feat/b0623-pr1-cayley-dickson-doubling-2026-05-21

Conversation

@AceHack
Copy link
Copy Markdown
Member

@AceHack AceHack commented May 21, 2026

Summary

  • First constructive-proof slice for B-0623 acceptance bullet Round 27 — plugin API + governance split + memory-in-repo #3 (Lean/F#/TS prototype) — F# chosen per the acceptance bullet's escape clause and composes with existing src/Core/Algebra.fs
  • Implements the structural primitive underlying the imaginary stack — generic Cayley-Dickson doubling that lifts any algebra with addition, negation, multiplication, conjugation to its doubled algebra
  • Aaron 2026-05-21 named the imaginary stack as the deeper concern relative to Adinkras themselves; this PR ships the substrate so subsequent PRs can decorate it with Adinkra ECC structure

What'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 lift IAlgebra<'A> → IAlgebra<Doubled<'A>> is directly expressible
  • Doubled<'A> — record type with Real + Imag fields
  • Doubled.algebra — the Cayley-Dickson construction itself (one function, ~20 lines)
  • Real.algebra — base case
  • Type aliases Complex = Doubled<float>, Quaternion = Doubled<Complex>, Octonion = Doubled<Quaternion>, Sedenion = Doubled<Octonion> — imaginary-stack stratification readable at the type level
  • ImaginaryStack module with pre-computed algebra instances at each level

tests/Tests.FSharp/Algebra/CayleyDickson.Tests.fs (+172 LOC, 12 tests):

  • Complex: i² = −1; addition + multiplication commutative; conjugation flips imaginary sign
  • Quaternion: multiplication LOSES commutativity (i·j ≠ j·i — the classical loss point); 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

Test plan

  • dotnet build src/Core/Core.fsproj -c Release → 0 warnings, 0 errors
  • dotnet test CayleyDicksonTests filter → 12 passed, 0 failed
  • Canary clean (HEAD ls-tree=54, HEAD~1=54, +2 files)
  • Reviewer verifies the dictionary-interface choice vs SRTPs is the right call for the structural lift

Trajectory (subsequent PRs)

  • 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 (constructive proof, not crypto-secure)
  • PR4 — Composition with retractable Z-state primitive (z⁻¹/D/I) — verify algebraic laws survive composition

Composes with

Note 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

…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>
Copilot AI review requested due to automatic review settings May 21, 2026 22:36
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.fs with IAlgebra<'A>, Doubled<'A>, the doubling lift, and precomputed stack instances.
  • Adds tests/Tests.FSharp/Algebra/CayleyDickson.Tests.fs covering commutativity/associativity loss points and structural identities across levels.
  • Wires both new files into their respective .fsproj compile 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 }

Comment thread src/Core/CayleyDickson.fs
Comment thread tests/Tests.FSharp/Algebra/CayleyDickson.Tests.fs Outdated
@AceHack AceHack enabled auto-merge (squash) May 21, 2026 22:43
@AceHack
Copy link
Copy Markdown
Member Author

AceHack commented May 22, 2026

Forward-signal: 2 unresolved threads investigated + verified (Otto-CLI cold-boot 2026-05-22T00:11Z)

Tick fired under dotgit-saturated tier (384 stuck git pack-objects/maintenance/repack procs; 327 worktrees registered; 13 peer Claude-Code PIDs) — no in-repo commits this tick per refresh-world-model-poll-pr-gate.md. PR #4587 gate state checks the BLOCKED-with-green-CI pattern: required-checks ok=7/7, autoMerge armed, 2 unresolved threads.

Both threads verified against PR head c3e0761bbba2b03222c60bb981daf5ae244c13c5 via gh api .../contents/<path>?ref=$PR_HEAD (per blocked-green-ci-investigate-threads.md verify-before-fix discipline). Both are real findings, neither is a known-FP class.

Thread 1 — PRRT_kwDOSF9kNM6D9DXa (Copilot P1, codebase-conventions)

src/Core/CayleyDickson.fs docstring line 4 carries named attribution:

/// Cayley–Dickson doubling — the structural primitive underlying the
/// "imaginary stack" Aaron + Mika named in the 2026-05-18 boot-sequence
/// design conversation. ...

Recommended fix: scrub to role-ref or remove. Per project CLAUDE.md "Don't reference the current task, fix, or callers ... since those belong in the PR description and rot as the codebase evolves." The Copilot finding also notes "another name mention later in this file in the type-alias comment block" — gh api .../contents read of lines 25-32 didn't surface a clear second match, but worth double-checking the full docstring block by line.

Thread 2 — PRRT_kwDOSF9kNM6D9DXj (Copilot, typo)

tests/Tests.FSharp/Algebra/CayleyDickson.Tests.fs line 149:

[<Fact>]
let ``Octonion: exhibits non-associativity for a specific triple`` () =
    // Famous example: take three orthogonal imaginary units in ℕ that
    // form an "associative triple" in ℍ but NOT in 𝕆. Here we use a
    // simpler approach — pick three octonions and show (a·b)·c ≠ a·(b·c)

(naturals) → 𝕆 (octonions). The rest of the sentence references ℍ and 𝕆 correctly; this is the typo Copilot flagged.

Net diff

~4-6 lines total (the named-attribution scrub of CayleyDickson.fs lines 3-32 + the single-character 𝕆 swap on Tests line 149). Bounded, substantive, low-risk; lands cleanly once dotgit-saturation clears OR via a fresh-checkout peer session.

Why this is a forward signal, not this-tick execution

Per the dotgit-saturated-tier discipline (operational tiers in refresh-world-model-poll-pr-gate.md) attempting git worktree add or in-place git checkout under 384-stuck-plumbing contention would hang or corrupt. The bounded artifact this tick produces IS this comment — counter-reset condition #3 ("real decomposition work — concrete artifact") satisfied per holding-without-named-dependency-is-standing-by-failure.md.

Co-Authored-By: Claude noreply@anthropic.com

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>
@AceHack AceHack merged commit 29152c1 into main May 22, 2026
31 checks passed
@AceHack AceHack deleted the feat/b0623-pr1-cayley-dickson-doubling-2026-05-21 branch May 22, 2026 00:24
AceHack added a commit that referenced this pull request May 22, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants