Threshold Logic Circuits
Collection
Boolean gates, voting functions, modular arithmetic, and adders as threshold networks.
β’
269 items
β’
Updated
β’
1
At-most-6-out-of-8 detector. Fires when 6 or fewer inputs are active. The near-unanimity blocker.
xβ xβ xβ xβ xβ xβ
xβ xβ
β β β β β β β β
ββββ΄βββ΄βββ΄βββΌβββ΄βββ΄βββ΄βββ
βΌ
βββββββββββ
β w: -1Γ8 β
β b: +6 β
βββββββββββ
β
βΌ
HW β€ 6?
This circuit fires unless near-unanimity or unanimity is achieved:
| HW | AtMost6 | Status |
|---|---|---|
| 0-6 | 1 | At least 2 dissenters |
| 7 | 0 | Single holdout |
| 8 | 0 | Unanimous |
It identifies states where meaningful opposition exists.
For something to pass AtMost6:
This is the threshold for "blocking minority" in many systems.
Nearly everything passes:
| HW | C(8,k) | AtMost6? |
|---|---|---|
| 0-6 | 247 | Yes |
| 7 | 8 | No |
| 8 | 1 | No |
Total: 247 of 256 inputs (96.5%).
| Circuit | Condition | Fires on |
|---|---|---|
| AtLeast2 | HW β₯ 2 | 247 inputs |
| AtMost6 | HW β€ 6 | 247 inputs |
Both fire on almost everything. AtLeast2 misses empty/singleton; AtMost6 misses near-unanimous/unanimous.
| Component | Value |
|---|---|
| Weights | all -1 |
| Bias | +6 |
| Total | 9 parameters |
from safetensors.torch import load_file
import torch
w = load_file('model.safetensors')
def atmost6(bits):
inp = torch.tensor([float(b) for b in bits])
return int((inp * w['weight']).sum() + w['bias'] >= 0)
# Supermajority with 2 dissenters
print(atmost6([1,1,1,1,1,1,0,0])) # 1
# Single holdout
print(atmost6([1,1,1,1,1,1,1,0])) # 0
threshold-atmost6outof8/
βββ model.safetensors
βββ model.py
βββ config.json
βββ README.md
MIT