Tiny Verified Logic Circuits
Collection
Formally verified threshold logic circuits. Compatible with neuromorphic hardware.
โข
33 items
โข
Updated
Formally verified NAND gate. Single threshold neuron computing negated conjunction with 100% accuracy.
| Component | Value |
|---|---|
| Inputs | 2 |
| Outputs | 1 |
| Neurons | 1 |
| Parameters | 3 |
| Weights | [-1, -1] |
| Bias | 1 |
| Activation | Heaviside step |
import torch
from safetensors.torch import load_file
weights = load_file('nand.safetensors')
def nand_gate(x, y):
# Heaviside: weighted_sum + bias >= 0
inputs = torch.tensor([float(x), float(y)])
weighted_sum = (inputs * weights['weight']).sum() + weights['bias']
return int(weighted_sum >= 0)
# Test
print(nand_gate(0, 0)) # 1
print(nand_gate(0, 1)) # 1
print(nand_gate(1, 0)) # 1
print(nand_gate(1, 1)) # 0
Coq Theorem:
Theorem nand_correct : forall x y, nand_circuit x y = negb (andb x y).
Proven axiom-free with properties:
Full proof: coq-circuits/Boolean/NAND.v
Input combination produces weighted sum:
Fails to fire only when both inputs are true.
NAND is functionally complete - any Boolean function can be built from NAND gates alone. This makes it particularly important for circuit composition.
@software{tiny_nand_prover_2025,
title={tiny-NAND-verified: Formally Verified NAND Gate},
author={Norton, Charles},
url={https://huggingface.co/phanerozoic/tiny-NAND-verified},
year={2025}
}