phanerozoic commited on
Commit
ee5608e
·
verified ·
1 Parent(s): 795c251

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +87 -87
README.md CHANGED
@@ -1,87 +1,87 @@
1
- ---
2
- license: mit
3
- tags:
4
- - formal-verification
5
- - coq
6
- - threshold-logic
7
- - neuromorphic
8
- ---
9
-
10
- # tiny-5OutOf8-verified
11
-
12
- Formally verified 5-out-of-8 threshold gate (majority). Single threshold neuron with 100% accuracy.
13
-
14
- ## Architecture
15
-
16
- | Component | Value |
17
- |-----------|-------|
18
- | Inputs | 8 |
19
- | Outputs | 1 |
20
- | Neurons | 1 |
21
- | Parameters | 9 |
22
- | Weights | [1, 1, 1, 1, 1, 1, 1, 1] |
23
- | Bias | -5 |
24
- | Activation | Heaviside step |
25
-
26
- ## Key Properties
27
-
28
- - 100% accuracy (256/256 inputs correct)
29
- - Coq-proven correctness
30
- - Single threshold neuron
31
- - Integer weights
32
- - Fires when at least 5 of 8 inputs are true
33
- - **Note**: Equivalent to Majority gate.
34
-
35
- ## Usage
36
-
37
- ```python
38
- import torch
39
- from safetensors.torch import load_file
40
-
41
- weights = load_file('fiveoutof8.safetensors')
42
-
43
- def fiveoutof8_gate(bits):
44
- # bits: list of 8 binary values
45
- inputs = torch.tensor([float(b) for b in bits])
46
- weighted_sum = (inputs * weights['weight']).sum() + weights['bias']
47
- return int(weighted_sum >= 0)
48
-
49
- # Test
50
- print({func}_gate([0,0,0,0,0,0,0,0])) # 0 (0/5, below threshold)
51
- print({func}_gate([1,1,1,1,0,0,0,0])) # 0 (4/8, below threshold)
52
- print({func}_gate([1,1,1,1,1,0,0,0])) # 1 (5/8, at threshold)
53
- print(fiveoutof8_gate([1,1,1,1,1,1,1,1])) # 1 (8/8, above threshold)
54
- ```
55
-
56
- ## Verification
57
-
58
- **Coq Theorem**:
59
- ```coq
60
- Theorem fiveout_eight_correct : forall x0 x1 x2 x3 x4 x5 x6 x7,
61
- fiveout_eight_circuit [x0; x1; x2; x3; x4; x5; x6; x7] =
62
- fiveout_eight_spec [x0; x1; x2; x3; x4; x5; x6; x7].
63
- ```
64
-
65
- Proven axiom-free via:
66
- 1. **Exhaustive**: All 256 inputs verified
67
- 2. **Universal**: Quantified proof over boolean combinations
68
- 3. **Algebraic**: Hamming weight ≥ 5
69
-
70
- Full proof: [coq-circuits/Threshold/FiveOutOfEight.v](https://github.com/CharlesCNorton/coq-circuits)
71
-
72
- ## Circuit Operation
73
-
74
- Input with h true bits (Hamming weight h):
75
- - Weighted sum: h - 5
76
- - Output: 1 if h ≥ 5, else 0
77
-
78
- ## Citation
79
-
80
- ```bibtex
81
- @software{tiny_5outof8_prover_2025,
82
- title={tiny-5OutOf8-verified: Formally Verified 5-out-of-8 threshold gate (majority)},
83
- author={Norton, Charles},
84
- url={https://huggingface.co/phanerozoic/tiny-5OutOf8-verified},
85
- year={2025}
86
- }
87
- ```
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - formal-verification
5
+ - coq
6
+ - threshold-logic
7
+ - neuromorphic
8
+ ---
9
+
10
+ # tiny-5OutOf8-verified
11
+
12
+ Formally verified 5-out-of-8 threshold gate (majority). Single threshold neuron with 100% accuracy.
13
+
14
+ ## Architecture
15
+
16
+ | Component | Value |
17
+ |-----------|-------|
18
+ | Inputs | 8 |
19
+ | Outputs | 1 |
20
+ | Neurons | 1 |
21
+ | Parameters | 9 |
22
+ | Weights | [1, 1, 1, 1, 1, 1, 1, 1] |
23
+ | Bias | -5 |
24
+ | Activation | Heaviside step |
25
+
26
+ ## Key Properties
27
+
28
+ - 100% accuracy (256/256 inputs correct)
29
+ - Coq-proven correctness
30
+ - Single threshold neuron
31
+ - Integer weights
32
+ - Fires when at least 5 of 8 inputs are true
33
+ - **Note**: Equivalent to Majority gate.
34
+
35
+ ## Usage
36
+
37
+ ```python
38
+ import torch
39
+ from safetensors.torch import load_file
40
+
41
+ weights = load_file('fiveoutof8.safetensors')
42
+
43
+ def fiveoutof8_gate(bits):
44
+ # bits: list of 8 binary values
45
+ inputs = torch.tensor([float(b) for b in bits])
46
+ weighted_sum = (inputs * weights['weight']).sum() + weights['bias']
47
+ return int(weighted_sum >= 0)
48
+
49
+ # Test
50
+ print({func}_gate([0,0,0,0,0,0,0,0])) # 0 (0/5, below threshold)
51
+ print({func}_gate([1,1,1,1,0,0,0,0])) # 0 (4/8, below threshold)
52
+ print({func}_gate([1,1,1,1,1,0,0,0])) # 1 (5/8, at threshold)
53
+ print(fiveoutof8_gate([1,1,1,1,1,1,1,1])) # 1 (8/8, above threshold)
54
+ ```
55
+
56
+ ## Verification
57
+
58
+ **Coq Theorem**:
59
+ ```coq
60
+ Theorem fiveout_eight_correct : forall x0 x1 x2 x3 x4 x5 x6 x7,
61
+ fiveout_eight_circuit [x0; x1; x2; x3; x4; x5; x6; x7] =
62
+ fiveout_eight_spec [x0; x1; x2; x3; x4; x5; x6; x7].
63
+ ```
64
+
65
+ Proven axiom-free via:
66
+ 1. **Exhaustive**: All 256 inputs verified
67
+ 2. **Universal**: Quantified proof over boolean combinations
68
+ 3. **Algebraic**: Hamming weight ≥ 5
69
+
70
+ Full proof: [coq-circuits/Threshold/FiveOutOfEight.v](https://github.com/CharlesCNorton/coq-circuits/blob/main/coq/Threshold/FiveOutOfEight.v)
71
+
72
+ ## Circuit Operation
73
+
74
+ Input with h true bits (Hamming weight h):
75
+ - Weighted sum: h - 5
76
+ - Output: 1 if h ≥ 5, else 0
77
+
78
+ ## Citation
79
+
80
+ ```bibtex
81
+ @software{tiny_5outof8_prover_2025,
82
+ title={tiny-5OutOf8-verified: Formally Verified 5-out-of-8 threshold gate (majority)},
83
+ author={Norton, Charles},
84
+ url={https://huggingface.co/phanerozoic/tiny-5OutOf8-verified},
85
+ year={2025}
86
+ }
87
+ ```