Threshold Logic Circuits
Collection
Boolean gates, voting functions, modular arithmetic, and adders as threshold networks.
β’
248 items
β’
Updated
β’
1
Exactly-7-out-of-8 detector. Fires when precisely seven inputs are active. The lone-dissenter detector.
xβ xβ xβ xβ xβ xβ
xβ xβ
β β β β β β β β
ββββ΄βββ΄βββ΄βββΌβββ΄βββ΄βββ΄βββ
β
βββββββββ΄ββββββββ
βΌ βΌ
βββββββββββ βββββββββββ
β β₯ 7 β β β€ 7 β
β b = -7 β β b = +7 β
βββββββββββ βββββββββββ
β β
βββββββββ¬ββββββββ
βΌ
βββββββββββ
β AND β
βββββββββββ
β
βΌ
one dissenter?
This circuit detects the complement of Exactly1: instead of one voice in the wilderness, it's one holdout against consensus.
| Circuit | Pattern | Interpretation |
|---|---|---|
| Exactly1 | 00000001 | Pioneer, outlier |
| Exactly7 | 11111110 | Holdout, veto |
Both fire on exactly 8 input patterns (one for each position).
7/8 = 87.5% - overwhelming but not complete agreement:
The circuit identifies the liminal state between consensus and unanimity.
| Circuit | HW | Count | Interpretation |
|---|---|---|---|
| Exactly1 | 1 | 8 | One active |
| Exactly7 | 7 | 8 | One inactive |
They are perfect duals. Bitwise NOT maps each Exactly1 input to a unique Exactly7 input.
In consensus systems:
| HW | Status | Exactly7 |
|---|---|---|
| 6 | Multiple dissenters | 0 |
| 7 | Single holdout | 1 |
| 8 | Complete consensus | 0 |
Exactly7 identifies the unique scenario: overwhelming support with precisely one objector. This is useful for:
| Component | Weights | Bias |
|---|---|---|
| AtLeast7 | all +1 | -7 |
| AtMost7 | all -1 | +7 |
| AND | [+1, +1] | -2 |
Total: 3 neurons, 21 parameters, 2 layers
from safetensors.torch import load_file
import torch
w = load_file('model.safetensors')
def exactly7(bits):
inp = torch.tensor([float(b) for b in bits])
atleast = int((inp * w['atleast.weight']).sum() + w['atleast.bias'] >= 0)
atmost = int((inp * w['atmost.weight']).sum() + w['atmost.bias'] >= 0)
comb = torch.tensor([float(atleast), float(atmost)])
return int((comb * w['and.weight']).sum() + w['and.bias'] >= 0)
# One holdout at position 3
bits = [1, 1, 1, 0, 1, 1, 1, 1]
print(exactly7(bits)) # 1
# Complete unanimity - no holdout
bits = [1, 1, 1, 1, 1, 1, 1, 1]
print(exactly7(bits)) # 0
| Circuit | Condition | Fires on |
|---|---|---|
| 7-out-of-8 | HW β₯ 7 | HW = 7, 8 (9 patterns) |
| Exactly7 | HW = 7 | HW = 7 only (8 patterns) |
The difference: 7-out-of-8 includes unanimity. Exactly7 excludes it.
threshold-exactly7outof8/
βββ model.safetensors
βββ model.py
βββ config.json
βββ README.md
MIT