phanerozoic's picture
Upload README.md with huggingface_hub
3dd8e84 verified
---
license: mit
tags:
- formal-verification
- coq
- threshold-logic
- neuromorphic
- minority
---
# tiny-Minority-verified
Formally verified minority gate for 8-bit inputs. Single threshold neuron computing minority function with 100% accuracy.
## Architecture
| Component | Value |
|-----------|-------|
| Inputs | 8 |
| Outputs | 1 |
| Neurons | 1 |
| Parameters | 9 |
| Weights | [-1, -1, -1, -1, -1, -1, -1, -1] |
| Bias | 3 |
| Activation | Heaviside step |
## Key Properties
- 100% accuracy (256/256 inputs correct)
- Coq-proven correctness
- Single threshold neuron
- Integer weights
- Fires when ≤3 of 8 inputs are true
- Complement of majority (inverted weights)
## Usage
```python
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)
```
## Verification
**Coq Theorem**:
```coq
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:
1. **Exhaustive**: Verified on all 256 inputs
2. **Universal**: Quantified proof over all boolean combinations
3. **Algebraic**: Characterized via hamming weight ≤ 3
**Algebraic characterization**:
```coq
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](https://github.com/CharlesCNorton/coq-circuits/blob/main/coq/Threshold/Minority.v)
## Circuit Operation
Input with k true bits produces weighted sum: -k + 3
- k ≤ 3: weighted_sum ≥ 0 → output 1 (minority)
- k > 3: weighted_sum < 0 → output 0 (not minority)
## Applications
- Inverted voting systems
- Fault detection (low activation)
- Sparse pattern detection
- Neuromorphic hardware
## Citation
```bibtex
@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}
}
```