threshold-atmost7outof8

At-most-7-out-of-8 detector. Fires when fewer than all inputs are active. This is 8-input NAND.

Circuit

  xβ‚€ x₁ xβ‚‚ x₃ xβ‚„ xβ‚… x₆ x₇
   β”‚  β”‚  β”‚  β”‚  β”‚  β”‚  β”‚  β”‚
   β””β”€β”€β”΄β”€β”€β”΄β”€β”€β”΄β”€β”€β”Όβ”€β”€β”΄β”€β”€β”΄β”€β”€β”΄β”€β”€β”˜
               β–Ό
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚ w: -1Γ—8 β”‚
          β”‚ b:  +7  β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
               β–Ό
         NOT(all)?

The Unanimity Detector (Inverted)

This circuit is the complement of 8-input AND:

HW AND (all 8) AtMost7 (NAND)
0-7 0 1
8 1 0

It fires on 255 of 256 inputs. Only complete unanimity silences it.

Equivalence to 8-input NAND

Circuit Condition Weights Bias
8-input AND HW = 8 all +1 -8
8-input NAND HW < 8 all -1 +7

They are complements. Both use the same number of parameters but opposite logic.

Functional Completeness

NAND is functionally complete - any Boolean function can be built from NAND alone:

  • NOT(x) = NAND(x, x, x, x, x, x, x, x)
  • But for 2-input NAND we'd need to tie inputs

This 8-input NAND can simulate 2-input NAND by fixing 6 inputs to 1.

The Single Failure Case

Scenario AtMost7
All systems go 0
Any system down 1

If you interpret 1 as "operational," AtMost7 fires whenever there's at least one failure.

Dual of AtLeast1 (OR)

Circuit Condition Fires on
AtLeast1 (OR) HW β‰₯ 1 255 inputs
AtMost7 (NAND) HW ≀ 7 255 inputs

Both fire on almost everything. One misses all-zeros; the other misses all-ones.

Parameters

Component Value
Weights all -1
Bias +7
Total 9 parameters

Usage

from safetensors.torch import load_file
import torch

w = load_file('model.safetensors')

def atmost7(bits):
    """Also known as 8-input NAND"""
    inp = torch.tensor([float(b) for b in bits])
    return int((inp * w['weight']).sum() + w['bias'] >= 0)

# Almost all active
print(atmost7([1,1,1,1,1,1,1,0]))  # 1

# All active (unanimity)
print(atmost7([1,1,1,1,1,1,1,1]))  # 0

Files

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

License

MIT

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

Collection including phanerozoic/threshold-atmost7outof8