File size: 2,175 Bytes
d6b2eab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
---
license: mit
tags:
- formal-verification
- coq
- threshold-logic
- neuromorphic
---

# tiny-AllOutOf8-verified

Formally verified 8-out-of-8 threshold gate (all). Single threshold neuron with 100% accuracy.

## Architecture

| Component | Value |
|-----------|-------|
| Inputs | 8 |
| Outputs | 1 |
| Neurons | 1 |
| Parameters | 9 |
| Weights | [1, 1, 1, 1, 1, 1, 1, 1] |
| Bias | -8 |
| Activation | Heaviside step |

## Key Properties

- 100% accuracy (256/256 inputs correct)
- Coq-proven correctness
- Single threshold neuron
- Integer weights
- Fires when all 8 inputs are true
- **Note**: Fires only when all inputs are true (8-input AND).

## Usage

```python
import torch
from safetensors.torch import load_file

weights = load_file('alloutof8.safetensors')

def alloutof8_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({func}_gate([0,0,0,0,0,0,0,0]))  # 0 (0/8, below threshold)
print({func}_gate([1,1,1,1,1,1,1,0]))  # 0 (7/8, below threshold)
print({func}_gate([1,1,1,1,1,1,1,1]))  # 1 (8/8, at threshold)
print(alloutof8_gate([1,1,1,1,1,1,1,1]))  # 1 (8/8, all true)
```

## Verification

**Coq Theorem**:
```coq
Theorem allout_eight_correct : forall x0 x1 x2 x3 x4 x5 x6 x7,
  allout_eight_circuit [x0; x1; x2; x3; x4; x5; x6; x7] =
  allout_eight_spec [x0; x1; x2; x3; x4; x5; x6; x7].
```

Proven axiom-free via:
1. **Exhaustive**: All 256 inputs verified
2. **Universal**: Quantified proof over boolean combinations
3. **Algebraic**: Hamming weight ≥ 8

Full proof: [coq-circuits/Threshold/AllOutOfEight.v](https://github.com/CharlesCNorton/coq-circuits/blob/main/coq/Threshold/AllOutOfEight.v)

## Circuit Operation

Input with h true bits (Hamming weight h):
- Weighted sum: h - 8
- Output: 1 if h ≥ 8, else 0

## Citation

```bibtex
@software{tiny_alloutof8_prover_2025,
  title={tiny-AllOutOf8-verified: Formally Verified 8-out-of-8 threshold gate (all)},
  author={Norton, Charles},
  url={https://huggingface.co/phanerozoic/tiny-AllOutOf8-verified},
  year={2025}
}
```