metadata
license: mit
tags:
- formal-verification
- coq
- threshold-logic
- neuromorphic
tiny-OR-verified
Formally verified OR gate. Single threshold neuron computing disjunction with 100% accuracy.
Architecture
| Component | Value |
|---|---|
| Inputs | 2 |
| Outputs | 1 |
| Neurons | 1 |
| Parameters | 3 |
| Weights | [1, 1] |
| Bias | -1 |
| Activation | Heaviside step |
Key Properties
- 100% accuracy (4/4 inputs correct)
- Coq-proven correctness
- Single threshold neuron
- Integer weights
- Commutative: OR(x,y) = OR(y,x)
- Associative: OR(x,OR(y,z)) = OR(OR(x,y),z)
- Idempotent: OR(x,x) = x
Usage
import torch
from safetensors.torch import load_file
weights = load_file('or.safetensors')
def or_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(or_gate(0, 0)) # 0
print(or_gate(0, 1)) # 1
print(or_gate(1, 0)) # 1
print(or_gate(1, 1)) # 1
Verification
Coq Theorem:
Theorem or_correct : forall x y, or_circuit x y = orb x y.
Proven axiom-free with properties:
- Commutativity
- Associativity
- Identity (OR with false)
- Absorption (OR with true)
- Idempotence
Full proof: coq-circuits/Boolean/OR.v
Circuit Operation
Input combination produces weighted sum:
- (0,0): 01 + 01 - 1 = -1 < 0 → 0
- (0,1): 01 + 11 - 1 = 0 >= 0 → 1
- (1,0): 11 + 01 - 1 = 0 >= 0 → 1
- (1,1): 11 + 11 - 1 = 1 >= 0 → 1
Requires at least one input to reach threshold.
Citation
@software{tiny_or_prover_2025,
title={tiny-OR-verified: Formally Verified OR Gate},
author={Norton, Charles},
url={https://huggingface.co/phanerozoic/tiny-OR-verified},
year={2025}
}