Tiny Verified Logic Circuits
Collection
Formally verified threshold logic circuits. Compatible with neuromorphic hardware.
•
33 items
•
Updated
Formally verified MOD-8 circuit. Single-layer threshold network computing modulo-8 arithmetic with 100% accuracy.
| Component | Value |
|---|---|
| Inputs | 8 |
| Outputs | 1 (per residue class) |
| Neurons | 8 (one per residue 0-7) |
| Parameters | 72 (8 × 9) |
| Weights | [1, 1, 1, 1, 1, 1, 1, -7] |
| Bias | 0 |
| Activation | Heaviside step |
MOD-8 uses the pattern with reset at position 8:
This creates a cumulative sum that cycles mod 8.
import torch
from safetensors.torch import load_file
weights = load_file('mod8.safetensors')
def mod8_circuit(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 weighted_sum.item()
# Test
print(mod8_circuit([1,1,1,1,1,1,1,1])) # 8 mod 8 = 0
print(mod8_circuit([1,1,1,1,1,1,1,0])) # 7 mod 8 = 7
Coq Theorem:
Theorem mod8_correct_residue_0 : forall x0 x1 x2 x3 x4 x5 x6 x7,
mod8_is_zero [x0; x1; x2; x3; x4; x5; x6; x7] =
Z.eqb ((Z.of_nat (hamming_weight [x0; x1; x2; x3; x4; x5; x6; x7])) mod 8) 0.
Proven axiom-free using algebraic weight patterns.
Full proof: coq-circuits/Modular/Mod8.v
For 8-bit inputs (256 total):
@software{tiny_mod8_verified_2025,
title={tiny-mod8-verified: Formally Verified MOD-8 Circuit},
author={Norton, Charles},
url={https://huggingface.co/phanerozoic/tiny-mod8-verified},
year={2025}
}