metadata
license: mit
tags:
- pytorch
- safetensors
- threshold-logic
- neuromorphic
- functionally-complete
threshold-nor3
3-input NOR gate. Fires only when all inputs are silent. The silence detector.
Circuit
a b c
β β β
βββββΌββββ
β
βΌ
ββββββββββββ
βw: -1,-1,-1β
β b: 0 β
ββββββββββββ
β
βΌ
NOR(a,b,c)
The Perfect Silence Test
3-input NOR fires only on complete absence:
| Inputs | Sum | Output |
|---|---|---|
| 000 | 0 | 1 |
| 001 | -1 | 0 |
| 010 | -1 | 0 |
| 011 | -2 | 0 |
| 100 | -1 | 0 |
| 101 | -2 | 0 |
| 110 | -2 | 0 |
| 111 | -3 | 0 |
Any activity silences the gate.
Zero-Budget Design
With bias 0, we start exactly at threshold:
sum = -a - b - c + 0 = -HW
fires when -HW >= 0
fires when HW = 0
No tolerance. The slightest input pushes us below threshold.
Functional Completeness
Like NAND, NOR is universal:
- NOT(x) = NOR(x, x, x)
- OR(x,y,z) = NOR(NOR(x,y,z), NOR(x,y,z), NOR(x,y,z))
- AND(x,y,z) = NOR(NOR(x,x,x), NOR(y,y,y), NOR(z,z,z))
NOR logic powered the Apollo Guidance Computer.
Extension of 2-input NOR
| Gate | Weights | Bias |
|---|---|---|
| NOR(a,b) | [-1, -1] | 0 |
| NOR(a,b,c) | [-1, -1, -1] | 0 |
| NOR(a,b,c,d) | [-1, -1, -1, -1] | 0 |
All have bias 0. Only the number of inputs changes.
Parameters
| Component | Value |
|---|---|
| Weights | [-1, -1, -1] |
| Bias | 0 |
| Total | 4 parameters |
Optimality
Exhaustive enumeration of all 129 weight configurations at magnitudes 0-3 confirms this circuit is already at minimum magnitude (3). There is exactly one valid configuration at magnitude 3, and no valid configurations exist below it.
Usage
from safetensors.torch import load_file
import torch
w = load_file('model.safetensors')
def nor3(a, b, c):
inp = torch.tensor([float(a), float(b), float(c)])
return int((inp * w['weight']).sum() + w['bias'] >= 0)
print(nor3(0, 0, 0)) # 1
print(nor3(0, 0, 1)) # 0
Files
threshold-nor3/
βββ model.safetensors
βββ model.py
βββ config.json
βββ README.md
License
MIT