phanerozoic commited on
Commit
5f397e5
·
verified ·
1 Parent(s): 5ec0e6b

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +97 -0
README.md ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - formal-verification
5
+ - coq
6
+ - threshold-logic
7
+ - neuromorphic
8
+ - functionally-complete
9
+ ---
10
+
11
+ # tiny-NOR-prover
12
+
13
+ Formally verified NOR gate. Single threshold neuron computing negated disjunction with 100% accuracy.
14
+
15
+ ## Architecture
16
+
17
+ | Component | Value |
18
+ |-----------|-------|
19
+ | Inputs | 2 |
20
+ | Outputs | 1 |
21
+ | Neurons | 1 |
22
+ | Parameters | 3 |
23
+ | Weights | [-1, -1] |
24
+ | Bias | 0 |
25
+ | Activation | Heaviside step |
26
+
27
+ ## Key Properties
28
+
29
+ - 100% accuracy (4/4 inputs correct)
30
+ - Coq-proven correctness
31
+ - Single threshold neuron
32
+ - Integer weights
33
+ - Commutative: NOR(x,y) = NOR(y,x)
34
+ - Functionally complete (can build any Boolean function)
35
+ - Self-dual: NOR(x,x) = NOT(x)
36
+
37
+ ## Usage
38
+
39
+ ```python
40
+ import torch
41
+ from safetensors.torch import load_file
42
+
43
+ weights = load_file('nor.safetensors')
44
+
45
+ def nor_gate(x, y):
46
+ # Heaviside: weighted_sum + bias >= 0
47
+ inputs = torch.tensor([float(x), float(y)])
48
+ weighted_sum = (inputs * weights['weight']).sum() + weights['bias']
49
+ return int(weighted_sum >= 0)
50
+
51
+ # Test
52
+ print(nor_gate(0, 0)) # 1
53
+ print(nor_gate(0, 1)) # 0
54
+ print(nor_gate(1, 0)) # 0
55
+ print(nor_gate(1, 1)) # 0
56
+ ```
57
+
58
+ ## Verification
59
+
60
+ **Coq Theorem**:
61
+ ```coq
62
+ Theorem nor_correct : forall x y, nor_circuit x y = negb (orb x y).
63
+ ```
64
+
65
+ Proven axiom-free with properties:
66
+ - Commutativity
67
+ - Self-duality (NOR(x,x) = NOT(x))
68
+ - Functional completeness
69
+ - Identity with false gives NOT
70
+ - Absorption with true gives false
71
+
72
+ Full proof: [coq-circuits/Boolean/NOR.v](https://github.com/CharlesCNorton/coq-circuits)
73
+
74
+ ## Circuit Operation
75
+
76
+ Input combination produces weighted sum:
77
+ - (0,0): 0*(-1) + 0*(-1) + 0 = 0 >= 0 → 1
78
+ - (0,1): 0*(-1) + 1*(-1) + 0 = -1 < 0 → 0
79
+ - (1,0): 1*(-1) + 0*(-1) + 0 = -1 < 0 → 0
80
+ - (1,1): 1*(-1) + 1*(-1) + 0 = -2 < 0 → 0
81
+
82
+ Fires only when both inputs are false.
83
+
84
+ ## Functional Completeness
85
+
86
+ NOR is functionally complete - any Boolean function can be built from NOR gates alone. This makes it particularly important for circuit composition.
87
+
88
+ ## Citation
89
+
90
+ ```bibtex
91
+ @software{tiny_nor_prover_2025,
92
+ title={tiny-NOR-prover: Formally Verified NOR Gate},
93
+ author={Norton, Charles},
94
+ url={https://huggingface.co/phanerozoic/tiny-NOR-prover},
95
+ year={2025}
96
+ }
97
+ ```