phanerozoic commited on
Commit
9f8f827
Β·
verified Β·
1 Parent(s): ffdc23f

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +105 -105
README.md CHANGED
@@ -1,105 +1,105 @@
1
- ---
2
- license: mit
3
- tags:
4
- - formal-verification
5
- - coq
6
- - threshold-logic
7
- - neuromorphic
8
- - multi-layer
9
- - equivalence
10
- ---
11
-
12
- # tiny-BiImplies-verified
13
-
14
- Formally verified biconditional gate (if and only if). Two-layer threshold network computing logical equivalence with 100% accuracy.
15
-
16
- ## Architecture
17
-
18
- | Component | Value |
19
- |-----------|-------|
20
- | Inputs | 2 |
21
- | Outputs | 1 |
22
- | Neurons | 3 (2 hidden, 1 output) |
23
- | Layers | 2 |
24
- | Parameters | 9 |
25
- | **Layer 1, Neuron 1 (NOR)** | |
26
- | Weights | [-1, -1] |
27
- | Bias | 0 |
28
- | **Layer 1, Neuron 2 (AND)** | |
29
- | Weights | [1, 1] |
30
- | Bias | -2 |
31
- | **Layer 2 (OR)** | |
32
- | Weights | [1, 1] |
33
- | Bias | -1 |
34
- | Activation | Heaviside step (all layers) |
35
-
36
- ## Key Properties
37
-
38
- - 100% accuracy (4/4 inputs correct)
39
- - Coq-proven correctness
40
- - Minimal 2-layer architecture
41
- - Integer weights
42
- - Equivalence relation (reflexive, symmetric, transitive)
43
- - Identical to XNOR
44
-
45
- ## Usage
46
-
47
- ```python
48
- import torch
49
- from safetensors.torch import load_file
50
-
51
- weights = load_file('biimplies.safetensors')
52
-
53
- def biimplies_gate(x, y):
54
- inputs = torch.tensor([float(x), float(y)])
55
-
56
- # Layer 1: NOR and AND
57
- nor_sum = (inputs * weights['layer1.neuron1.weight']).sum() + weights['layer1.neuron1.bias']
58
- nor_out = int(nor_sum >= 0)
59
-
60
- and_sum = (inputs * weights['layer1.neuron2.weight']).sum() + weights['layer1.neuron2.bias']
61
- and_out = int(and_sum >= 0)
62
-
63
- # Layer 2: OR
64
- layer1_outs = torch.tensor([float(nor_out), float(and_out)])
65
- or_sum = (layer1_outs * weights['layer2.weight']).sum() + weights['layer2.bias']
66
- return int(or_sum >= 0)
67
-
68
- # Test
69
- print(biimplies_gate(0, 0)) # 1 (both false, equivalent)
70
- print(biimplies_gate(0, 1)) # 0 (different, not equivalent)
71
- print(biimplies_gate(1, 0)) # 0 (different, not equivalent)
72
- print(biimplies_gate(1, 1)) # 1 (both true, equivalent)
73
- ```
74
-
75
- ## Verification
76
-
77
- **Coq Theorem**:
78
- ```coq
79
- Theorem biimplies_correct : forall x y, biimplies_circuit x y = eqb x y.
80
- ```
81
-
82
- Proven axiom-free with properties:
83
- - Reflexivity (x ↔ x)
84
- - Symmetry (x ↔ y β†’ y ↔ x)
85
- - Transitivity (x ↔ y ∧ y ↔ z β†’ x ↔ z)
86
- - Full equivalence relation
87
-
88
- Full proof: [coq-circuits/Boolean/BiImplies.v](https://github.com/CharlesCNorton/coq-circuits)
89
-
90
- ## Circuit Operation
91
-
92
- BiImplies outputs true when inputs are equal.
93
-
94
- BiImplies(x,y) = OR(NOR(x,y), AND(x,y)) = (x ↔ y)
95
-
96
- ## Citation
97
-
98
- ```bibtex
99
- @software{tiny_biimplies_prover_2025,
100
- title={tiny-BiImplies-verified: Formally Verified Biconditional Gate},
101
- author={Norton, Charles},
102
- url={https://huggingface.co/phanerozoic/tiny-BiImplies-verified},
103
- year={2025}
104
- }
105
- ```
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - formal-verification
5
+ - coq
6
+ - threshold-logic
7
+ - neuromorphic
8
+ - multi-layer
9
+ - equivalence
10
+ ---
11
+
12
+ # tiny-BiImplies-verified
13
+
14
+ Formally verified biconditional gate (if and only if). Two-layer threshold network computing logical equivalence with 100% accuracy.
15
+
16
+ ## Architecture
17
+
18
+ | Component | Value |
19
+ |-----------|-------|
20
+ | Inputs | 2 |
21
+ | Outputs | 1 |
22
+ | Neurons | 3 (2 hidden, 1 output) |
23
+ | Layers | 2 |
24
+ | Parameters | 9 |
25
+ | **Layer 1, Neuron 1 (NOR)** | |
26
+ | Weights | [-1, -1] |
27
+ | Bias | 0 |
28
+ | **Layer 1, Neuron 2 (AND)** | |
29
+ | Weights | [1, 1] |
30
+ | Bias | -2 |
31
+ | **Layer 2 (OR)** | |
32
+ | Weights | [1, 1] |
33
+ | Bias | -1 |
34
+ | Activation | Heaviside step (all layers) |
35
+
36
+ ## Key Properties
37
+
38
+ - 100% accuracy (4/4 inputs correct)
39
+ - Coq-proven correctness
40
+ - Minimal 2-layer architecture
41
+ - Integer weights
42
+ - Equivalence relation (reflexive, symmetric, transitive)
43
+ - Identical to XNOR
44
+
45
+ ## Usage
46
+
47
+ ```python
48
+ import torch
49
+ from safetensors.torch import load_file
50
+
51
+ weights = load_file('biimplies.safetensors')
52
+
53
+ def biimplies_gate(x, y):
54
+ inputs = torch.tensor([float(x), float(y)])
55
+
56
+ # Layer 1: NOR and AND
57
+ nor_sum = (inputs * weights['layer1.neuron1.weight']).sum() + weights['layer1.neuron1.bias']
58
+ nor_out = int(nor_sum >= 0)
59
+
60
+ and_sum = (inputs * weights['layer1.neuron2.weight']).sum() + weights['layer1.neuron2.bias']
61
+ and_out = int(and_sum >= 0)
62
+
63
+ # Layer 2: OR
64
+ layer1_outs = torch.tensor([float(nor_out), float(and_out)])
65
+ or_sum = (layer1_outs * weights['layer2.weight']).sum() + weights['layer2.bias']
66
+ return int(or_sum >= 0)
67
+
68
+ # Test
69
+ print(biimplies_gate(0, 0)) # 1 (both false, equivalent)
70
+ print(biimplies_gate(0, 1)) # 0 (different, not equivalent)
71
+ print(biimplies_gate(1, 0)) # 0 (different, not equivalent)
72
+ print(biimplies_gate(1, 1)) # 1 (both true, equivalent)
73
+ ```
74
+
75
+ ## Verification
76
+
77
+ **Coq Theorem**:
78
+ ```coq
79
+ Theorem biimplies_correct : forall x y, biimplies_circuit x y = eqb x y.
80
+ ```
81
+
82
+ Proven axiom-free with properties:
83
+ - Reflexivity (x ↔ x)
84
+ - Symmetry (x ↔ y β†’ y ↔ x)
85
+ - Transitivity (x ↔ y ∧ y ↔ z β†’ x ↔ z)
86
+ - Full equivalence relation
87
+
88
+ Full proof: [coq-circuits/Boolean/BiImplies.v](https://github.com/CharlesCNorton/coq-circuits/blob/main/coq/Boolean/BiImplies.v)
89
+
90
+ ## Circuit Operation
91
+
92
+ BiImplies outputs true when inputs are equal.
93
+
94
+ BiImplies(x,y) = OR(NOR(x,y), AND(x,y)) = (x ↔ y)
95
+
96
+ ## Citation
97
+
98
+ ```bibtex
99
+ @software{tiny_biimplies_prover_2025,
100
+ title={tiny-BiImplies-verified: Formally Verified Biconditional Gate},
101
+ author={Norton, Charles},
102
+ url={https://huggingface.co/phanerozoic/tiny-BiImplies-verified},
103
+ year={2025}
104
+ }
105
+ ```