Threshold Logic Circuits
Collection
Boolean gates, voting functions, modular arithmetic, and adders as threshold networks. • 269 items • Updated • 1
Unanimity detector. Fires only when all 8 inputs are set. Equivalent to 8-input AND.
x₀ x₁ x₂ x₃ x₄ x₅ x₆ x₇
│ │ │ │ │ │ │ │
└──┴──┴──┴──┼──┴──┴──┴──┘
▼
┌─────────┐
│ w: all 1│
│ b: -8 │
└─────────┘
│
▼
HW = 8
The strictest threshold in the k-out-of-8 family. No tolerance for missing inputs.
| Circuit | Bias | Fires when |
|---|---|---|
| 1-out-of-8 | -1 | HW ≥ 1 (= 8-input OR) |
| ... | ... | ... |
| 7-out-of-8 | -7 | HW ≥ 7 |
| 8-out-of-8 | -8 | HW = 8 (this = 8-input AND) |
The family spans from OR (bias -1) to AND (bias -8). All use the same weights.
| Weights | [1, 1, 1, 1, 1, 1, 1, 1] |
| Bias | -8 |
| Total | 9 parameters |
from safetensors.torch import load_file
import torch
w = load_file('model.safetensors')
def all_8(bits):
inputs = torch.tensor([float(b) for b in bits])
return int((inputs * w['weight']).sum() + w['bias'] >= 0)
threshold-alloutof8/
├── model.safetensors
├── model.py
├── config.json
└── README.md
MIT