Threshold Logic Circuits
Collection
Boolean gates, voting functions, modular arithmetic, and adders as threshold networks.
β’
248 items
β’
Updated
β’
1
3-input AND gate. Fires when all three inputs are active. The 3-of-3 threshold gate.
a b c
β β β
βββββΌββββ
β
βΌ
βββββββββββ
β w: 1,1,1β
β b: -3 β
βββββββββββ
β
βΌ
AND(a,b,c)
3-input AND is the smallest non-trivial unanimity gate:
| Inputs | Sum | Output |
|---|---|---|
| 000 | -3 | 0 |
| 001 | -2 | 0 |
| 010 | -2 | 0 |
| 011 | -1 | 0 |
| 100 | -2 | 0 |
| 101 | -1 | 0 |
| 110 | -1 | 0 |
| 111 | 0 | 1 |
Only when all three contribute does the sum reach the threshold.
| Gate | Weights | Bias | Threshold |
|---|---|---|---|
| AND(a,b) | [1, 1] | -2 | 2 votes needed |
| AND(a,b,c) | [1, 1, 1] | -3 | 3 votes needed |
| AND(a,b,c,d) | [1, 1, 1, 1] | -4 | 4 votes needed |
The pattern: n inputs, all weight +1, bias -n.
Any single 0 input blocks the gate:
Each input has veto power. This is unanimous consent.
| Component | Value |
|---|---|
| Weights | [1, 1, 1] |
| Bias | -3 |
| Total | 4 parameters |
Exhaustive enumeration of all 1,289 weight configurations at magnitudes 0-6 confirms this circuit is already at minimum magnitude (6). There is exactly one valid configuration at magnitude 6, and no valid configurations exist below it.
from safetensors.torch import load_file
import torch
w = load_file('model.safetensors')
def and3(a, b, c):
inp = torch.tensor([float(a), float(b), float(c)])
return int((inp * w['weight']).sum() + w['bias'] >= 0)
print(and3(1, 1, 1)) # 1
print(and3(1, 1, 0)) # 0
threshold-and3/
βββ model.safetensors
βββ model.py
βββ config.json
βββ README.md
MIT