threshold-exactly5outof8

Exactly-5-out-of-8 detector. Fires when precisely five inputs are active. The minimal majority detector.

Circuit

  x₀ x₁ x₂ x₃ x₄ x₅ x₆ x₇
   │  │  │  │  │  │  │  │
   └──┴──┴──┴──┼──┴──┴──┴──┘
               │
       ┌───────┴───────┐
       ▼               ▼
  ┌─────────┐     ┌─────────┐
  │  ≥ 5    │     │  ≤ 5    │
  │ b = -5  │     │ b = +5  │
  └─────────┘     └─────────┘
       │               │
       └───────┬───────┘
               ▼
          ┌─────────┐
          │   AND   │
          └─────────┘
               │
               ▼
     bare majority?

The Threshold of Majority

Five is the smallest strict majority of eight:

  • 5/8 = 62.5% - just past the halfway mark
  • Margin of 1: 5 vs 3 (with 0 abstentions) is the closest possible win
  • No cushion: lose one vote and you're back to a tie

This is the knife-edge of democratic decision-making.

Exactly5 vs Majority

Circuit Condition Fires on HW
Majority HW ≥ 5 5, 6, 7, 8
Exactly5 HW = 5 5 only

Majority fires on 93 inputs. Exactly5 fires on 56 - only those with no margin to spare.

Dual of Exactly3

Circuit HW Count Bit-flip image
Exactly3 3 56 Exactly5
Exactly5 5 56 Exactly3

Flipping all 8 bits transforms HW=5 into HW=3. These circuits are duals under bitwise NOT.

The Razor-Thin Win

Consider a voting scenario with 8 voters:

HW Meaning This circuit
0-3 Opposition wins 0
4 Tie (no decision) 0
5 Minimal majority 1
6-8 Comfortable majority 0

Exactly5 detects the precarious victory - where a single defection would flip the outcome.

Parameters

Component Weights Bias
AtLeast5 all +1 -5
AtMost5 all -1 +5
AND [+1, +1] -2

Total: 3 neurons, 21 parameters, 2 layers

Usage

from safetensors.torch import load_file
import torch

w = load_file('model.safetensors')

def exactly5(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)

# Bare majority: 5 votes
bits = [1, 1, 1, 1, 1, 0, 0, 0]
print(exactly5(bits))  # 1

# Comfortable majority: 6 votes
bits = [1, 1, 1, 1, 1, 1, 0, 0]
print(exactly5(bits))  # 0

Files

threshold-exactly5outof8/
├── model.safetensors
├── model.py
├── config.json
└── README.md

License

MIT

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collection including phanerozoic/threshold-exactly5outof8

Free AI Image Generator No sign-up. Instant results. Open Now