Tiny Verified Logic Circuits
Collection
Formally verified threshold logic circuits. Compatible with neuromorphic hardware.
•
33 items
•
Updated
Formally verified minority gate for 8-bit inputs. Single threshold neuron computing minority function with 100% accuracy.
| Component | Value |
|---|---|
| Inputs | 8 |
| Outputs | 1 |
| Neurons | 1 |
| Parameters | 9 |
| Weights | [-1, -1, -1, -1, -1, -1, -1, -1] |
| Bias | 3 |
| Activation | Heaviside step |
import torch
from safetensors.torch import load_file
weights = load_file('minority.safetensors')
def minority_gate(bits):
# bits: list of 8 binary values
inputs = torch.tensor([float(b) for b in bits])
weighted_sum = (inputs * weights['weight']).sum() + weights['bias']
return int(weighted_sum >= 0)
# Test
print(minority_gate([0,0,0,0,0,0,0,0])) # 1 (minority)
print(minority_gate([1,1,1,0,0,0,0,0])) # 1 (3/8, minority)
print(minority_gate([1,1,1,1,0,0,0,0])) # 0 (4/8, not minority)
print(minority_gate([1,1,1,1,1,1,1,1])) # 0 (no minority)
Coq Theorem:
Theorem minority_correct : forall x0 x1 x2 x3 x4 x5 x6 x7,
minority_circuit [x0; x1; x2; x3; x4; x5; x6; x7] =
minority_spec [x0; x1; x2; x3; x4; x5; x6; x7].
Proven axiom-free via three methods:
Algebraic characterization:
Theorem minority_hamming_weight (xs : list bool) :
length xs = 8 ->
minority_circuit xs = true <-> hamming_weight xs <= 3.
Full proof: coq-circuits/Threshold/Minority.v
Input with k true bits produces weighted sum: -k + 3
@software{tiny_minority_prover_2025,
title={tiny-Minority-verified: Formally Verified Minority Gate},
author={Norton, Charles},
url={https://huggingface.co/phanerozoic/tiny-Minority-verified},
year={2025}
}