phanerozoic commited on
Commit
3dd8e84
·
verified ·
1 Parent(s): 8aaaa46

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +103 -103
README.md CHANGED
@@ -1,103 +1,103 @@
1
- ---
2
- license: mit
3
- tags:
4
- - formal-verification
5
- - coq
6
- - threshold-logic
7
- - neuromorphic
8
- - minority
9
- ---
10
-
11
- # tiny-Minority-verified
12
-
13
- Formally verified minority gate for 8-bit inputs. Single threshold neuron computing minority function with 100% accuracy.
14
-
15
- ## Architecture
16
-
17
- | Component | Value |
18
- |-----------|-------|
19
- | Inputs | 8 |
20
- | Outputs | 1 |
21
- | Neurons | 1 |
22
- | Parameters | 9 |
23
- | Weights | [-1, -1, -1, -1, -1, -1, -1, -1] |
24
- | Bias | 3 |
25
- | Activation | Heaviside step |
26
-
27
- ## Key Properties
28
-
29
- - 100% accuracy (256/256 inputs correct)
30
- - Coq-proven correctness
31
- - Single threshold neuron
32
- - Integer weights
33
- - Fires when ≤3 of 8 inputs are true
34
- - Complement of majority (inverted weights)
35
-
36
- ## Usage
37
-
38
- ```python
39
- import torch
40
- from safetensors.torch import load_file
41
-
42
- weights = load_file('minority.safetensors')
43
-
44
- def minority_gate(bits):
45
- # bits: list of 8 binary values
46
- inputs = torch.tensor([float(b) for b in bits])
47
- weighted_sum = (inputs * weights['weight']).sum() + weights['bias']
48
- return int(weighted_sum >= 0)
49
-
50
- # Test
51
- print(minority_gate([0,0,0,0,0,0,0,0])) # 1 (minority)
52
- print(minority_gate([1,1,1,0,0,0,0,0])) # 1 (3/8, minority)
53
- print(minority_gate([1,1,1,1,0,0,0,0])) # 0 (4/8, not minority)
54
- print(minority_gate([1,1,1,1,1,1,1,1])) # 0 (no minority)
55
- ```
56
-
57
- ## Verification
58
-
59
- **Coq Theorem**:
60
- ```coq
61
- Theorem minority_correct : forall x0 x1 x2 x3 x4 x5 x6 x7,
62
- minority_circuit [x0; x1; x2; x3; x4; x5; x6; x7] =
63
- minority_spec [x0; x1; x2; x3; x4; x5; x6; x7].
64
- ```
65
-
66
- Proven axiom-free via three methods:
67
- 1. **Exhaustive**: Verified on all 256 inputs
68
- 2. **Universal**: Quantified proof over all boolean combinations
69
- 3. **Algebraic**: Characterized via hamming weight ≤ 3
70
-
71
- **Algebraic characterization**:
72
- ```coq
73
- Theorem minority_hamming_weight (xs : list bool) :
74
- length xs = 8 ->
75
- minority_circuit xs = true <-> hamming_weight xs <= 3.
76
- ```
77
-
78
- Full proof: [coq-circuits/Threshold/Minority.v](https://github.com/CharlesCNorton/coq-circuits)
79
-
80
- ## Circuit Operation
81
-
82
- Input with k true bits produces weighted sum: -k + 3
83
-
84
- - k ≤ 3: weighted_sum ≥ 0 → output 1 (minority)
85
- - k > 3: weighted_sum < 0 → output 0 (not minority)
86
-
87
- ## Applications
88
-
89
- - Inverted voting systems
90
- - Fault detection (low activation)
91
- - Sparse pattern detection
92
- - Neuromorphic hardware
93
-
94
- ## Citation
95
-
96
- ```bibtex
97
- @software{tiny_minority_prover_2025,
98
- title={tiny-Minority-verified: Formally Verified Minority Gate},
99
- author={Norton, Charles},
100
- url={https://huggingface.co/phanerozoic/tiny-Minority-verified},
101
- year={2025}
102
- }
103
- ```
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - formal-verification
5
+ - coq
6
+ - threshold-logic
7
+ - neuromorphic
8
+ - minority
9
+ ---
10
+
11
+ # tiny-Minority-verified
12
+
13
+ Formally verified minority gate for 8-bit inputs. Single threshold neuron computing minority function with 100% accuracy.
14
+
15
+ ## Architecture
16
+
17
+ | Component | Value |
18
+ |-----------|-------|
19
+ | Inputs | 8 |
20
+ | Outputs | 1 |
21
+ | Neurons | 1 |
22
+ | Parameters | 9 |
23
+ | Weights | [-1, -1, -1, -1, -1, -1, -1, -1] |
24
+ | Bias | 3 |
25
+ | Activation | Heaviside step |
26
+
27
+ ## Key Properties
28
+
29
+ - 100% accuracy (256/256 inputs correct)
30
+ - Coq-proven correctness
31
+ - Single threshold neuron
32
+ - Integer weights
33
+ - Fires when ≤3 of 8 inputs are true
34
+ - Complement of majority (inverted weights)
35
+
36
+ ## Usage
37
+
38
+ ```python
39
+ import torch
40
+ from safetensors.torch import load_file
41
+
42
+ weights = load_file('minority.safetensors')
43
+
44
+ def minority_gate(bits):
45
+ # bits: list of 8 binary values
46
+ inputs = torch.tensor([float(b) for b in bits])
47
+ weighted_sum = (inputs * weights['weight']).sum() + weights['bias']
48
+ return int(weighted_sum >= 0)
49
+
50
+ # Test
51
+ print(minority_gate([0,0,0,0,0,0,0,0])) # 1 (minority)
52
+ print(minority_gate([1,1,1,0,0,0,0,0])) # 1 (3/8, minority)
53
+ print(minority_gate([1,1,1,1,0,0,0,0])) # 0 (4/8, not minority)
54
+ print(minority_gate([1,1,1,1,1,1,1,1])) # 0 (no minority)
55
+ ```
56
+
57
+ ## Verification
58
+
59
+ **Coq Theorem**:
60
+ ```coq
61
+ Theorem minority_correct : forall x0 x1 x2 x3 x4 x5 x6 x7,
62
+ minority_circuit [x0; x1; x2; x3; x4; x5; x6; x7] =
63
+ minority_spec [x0; x1; x2; x3; x4; x5; x6; x7].
64
+ ```
65
+
66
+ Proven axiom-free via three methods:
67
+ 1. **Exhaustive**: Verified on all 256 inputs
68
+ 2. **Universal**: Quantified proof over all boolean combinations
69
+ 3. **Algebraic**: Characterized via hamming weight ≤ 3
70
+
71
+ **Algebraic characterization**:
72
+ ```coq
73
+ Theorem minority_hamming_weight (xs : list bool) :
74
+ length xs = 8 ->
75
+ minority_circuit xs = true <-> hamming_weight xs <= 3.
76
+ ```
77
+
78
+ Full proof: [coq-circuits/Threshold/Minority.v](https://github.com/CharlesCNorton/coq-circuits/blob/main/coq/Threshold/Minority.v)
79
+
80
+ ## Circuit Operation
81
+
82
+ Input with k true bits produces weighted sum: -k + 3
83
+
84
+ - k ≤ 3: weighted_sum ≥ 0 → output 1 (minority)
85
+ - k > 3: weighted_sum < 0 → output 0 (not minority)
86
+
87
+ ## Applications
88
+
89
+ - Inverted voting systems
90
+ - Fault detection (low activation)
91
+ - Sparse pattern detection
92
+ - Neuromorphic hardware
93
+
94
+ ## Citation
95
+
96
+ ```bibtex
97
+ @software{tiny_minority_prover_2025,
98
+ title={tiny-Minority-verified: Formally Verified Minority Gate},
99
+ author={Norton, Charles},
100
+ url={https://huggingface.co/phanerozoic/tiny-Minority-verified},
101
+ year={2025}
102
+ }
103
+ ```