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
17
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Collection including phanerozoic/threshold-exactly5outof8