Skip to content

feat(ternary): spec-first ternary XOR — a 2-layer net computes what a single neuron cannot - #1770

Merged
gHashTag merged 1 commit into
masterfrom
feat/spec-first-ternary-xor
Aug 6, 2026
Merged

gHashTag merged 1 commit into
masterfrom
feat/spec-first-ternary-xor

Conversation

@gHashTag

@gHashTag gHashTag commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

specs/ternary/ternary_xor.t27: ternary_xor(a, b) — the canonical not-linearly-separable function. A single linear neuron cannot compute XOR; this is a genuine 2-layer ternary network:

h1  = sign(a + b - 1)        # AND-like (bias -1)
h2  = sign(a + b + 1)        # OR-like  (bias +1)
out = sign(h2 + (-h1) - 1)   # h2 AND NOT h1

The bias is the neuron's threshold offset — what a trained network learns alongside the weights. On binary-embedded inputs {N=-1, P=+1} the output is exact XOR (P if the inputs differ, N if they match).

Closes #1769

Verification

  • typecheck 0 err; icarus-simulate 4/4 test blocks; seal 3 backends MATCH.
  • New tests/ternary_xor.rs drives all 3^2 = 9 input combinations vs an independent 2-layer reference, and asserts the four binary cases equal true XOR = ALL_PASS 9.

A recognizable ML result — the perceptron→MLP story — computed by the spec-first ternary stack. Also refined #1764 (Phase-2 must go through the HIR path: the direct interface has no data ports).

🤖 Generated with Claude Code

…on cannot)

specs/ternary/ternary_xor.t27: ternary_xor(a,b) -- the canonical
not-linearly-separable function. A single linear neuron cannot compute XOR;
this is a genuine 2-layer network with biases: h1=sign(a+b-1) (AND-like),
h2=sign(a+b+1) (OR-like), out=sign(h2-h1-1) (h2 AND NOT h1). The bias is the
neuron's threshold offset -- what a trained net learns with the weights.

Verified: typecheck 0 err; icarus-simulate 4/4; seal MATCH; new
tests/ternary_xor.rs drives all 9 combos vs an independent 2-layer reference +
asserts the 4 binary cases equal true XOR = ALL_PASS 9. No compiler change.

Closes #1769

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-08-06 10:08:10 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 0
PRs with All Checks Green 50
READY 0
FAILING 0
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=9393a1c6258f != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

@gHashTag
gHashTag merged commit 96cecac into master Aug 6, 2026
18 checks passed
@gHashTag
gHashTag deleted the feat/spec-first-ternary-xor branch August 6, 2026 10:09
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.

feat: spec-first ternary XOR — a 2-layer net computes what a single neuron cannot

1 participant