threshold-atmost1outof8

At-most-1-out-of-8 detector. Fires when zero or one inputs are active. The sparsity detector.

Circuit

  xβ‚€ x₁ xβ‚‚ x₃ xβ‚„ xβ‚… x₆ x₇
   β”‚  β”‚  β”‚  β”‚  β”‚  β”‚  β”‚  β”‚
   β””β”€β”€β”΄β”€β”€β”΄β”€β”€β”΄β”€β”€β”Όβ”€β”€β”΄β”€β”€β”΄β”€β”€β”΄β”€β”€β”˜
               β–Ό
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚ w: -1Γ—8 β”‚
          β”‚ b:  +1  β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
               β–Ό
           HW ≀ 1?

A single threshold neuron. The negative weights mean each active input subtracts from the sum.

The Sparsity Bound

This circuit enforces extreme sparsity:

  • HW = 0: Complete silence (allowed)
  • HW = 1: Single signal (allowed)
  • HW β‰₯ 2: Multiple signals (rejected)

It's the upper bound for "at most one thing happening."

Mechanism

sum = -xβ‚€ - x₁ - xβ‚‚ - x₃ - xβ‚„ - xβ‚… - x₆ - x₇ + 1
    = 1 - HW
HW Sum Output
0 +1 1
1 0 1
2 -1 0
3+ < -1 0

The bias of +1 grants a budget of one active input. Any more exceeds the budget.

Dual of AtLeast7

Circuit Condition Fires when
AtLeast7 HW β‰₯ 7 Dense (7-8 active)
AtMost1 HW ≀ 1 Sparse (0-1 active)

Under bitwise NOT, AtMost1 inputs map to AtLeast7 inputs. They detect opposite extremes of the distribution.

Applications

  • Mutex verification: At most one process holds the lock
  • One-hot validation: Valid encoding has exactly 0 or 1 bit set
  • Conflict detection: Multiple requests trigger an error

The AtMost-k Family

Circuit Weights Bias Fires when
AtMost1 all -1 +1 HW ≀ 1
AtMost2 all -1 +2 HW ≀ 2
AtMost3 all -1 +3 HW ≀ 3
... all -1 +k HW ≀ k

All single-layer circuits. The bias determines the threshold.

Parameters

Component Value
Weights [-1, -1, -1, -1, -1, -1, -1, -1]
Bias +1
Total 9 parameters

Single neuron, single layer.

Usage

from safetensors.torch import load_file
import torch

w = load_file('model.safetensors')

def atmost1(bits):
    inp = torch.tensor([float(b) for b in bits])
    return int((inp * w['weight']).sum() + w['bias'] >= 0)

# Empty: allowed
print(atmost1([0,0,0,0,0,0,0,0]))  # 1

# Singleton: allowed
print(atmost1([0,0,0,1,0,0,0,0]))  # 1

# Pair: rejected
print(atmost1([0,1,0,1,0,0,0,0]))  # 0

Files

threshold-atmost1outof8/
β”œβ”€β”€ model.safetensors
β”œβ”€β”€ model.py
β”œβ”€β”€ config.json
└── README.md

License

MIT

Downloads last month
11
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Collection including phanerozoic/threshold-atmost1outof8