Repository navigation
feat(ternary): spec-first ternary XOR — a 2-layer net computes what a single neuron cannot - #1770
Merged
Merged
Conversation
…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>
Contributor
|
📓 NotebookLM Notebook linked to this PR
This notebook contains session context, decisions, and artifacts for this work. |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: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
typecheck0 err;icarus-simulate4/4 test blocks;seal3 backends MATCH.tests/ternary_xor.rsdrives 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