Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,92 +1,92 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: mit
|
| 3 |
-
tags:
|
| 4 |
-
- formal-verification
|
| 5 |
-
- coq
|
| 6 |
-
- threshold-logic
|
| 7 |
-
- neuromorphic
|
| 8 |
-
---
|
| 9 |
-
|
| 10 |
-
# tiny-OR-verified
|
| 11 |
-
|
| 12 |
-
Formally verified OR gate. Single threshold neuron computing disjunction with 100% accuracy.
|
| 13 |
-
|
| 14 |
-
## Architecture
|
| 15 |
-
|
| 16 |
-
| Component | Value |
|
| 17 |
-
|-----------|-------|
|
| 18 |
-
| Inputs | 2 |
|
| 19 |
-
| Outputs | 1 |
|
| 20 |
-
| Neurons | 1 |
|
| 21 |
-
| Parameters | 3 |
|
| 22 |
-
| Weights | [1, 1] |
|
| 23 |
-
| Bias | -1 |
|
| 24 |
-
| Activation | Heaviside step |
|
| 25 |
-
|
| 26 |
-
## Key Properties
|
| 27 |
-
|
| 28 |
-
- 100% accuracy (4/4 inputs correct)
|
| 29 |
-
- Coq-proven correctness
|
| 30 |
-
- Single threshold neuron
|
| 31 |
-
- Integer weights
|
| 32 |
-
- Commutative: OR(x,y) = OR(y,x)
|
| 33 |
-
- Associative: OR(x,OR(y,z)) = OR(OR(x,y),z)
|
| 34 |
-
- Idempotent: OR(x,x) = x
|
| 35 |
-
|
| 36 |
-
## Usage
|
| 37 |
-
|
| 38 |
-
```python
|
| 39 |
-
import torch
|
| 40 |
-
from safetensors.torch import load_file
|
| 41 |
-
|
| 42 |
-
weights = load_file('or.safetensors')
|
| 43 |
-
|
| 44 |
-
def or_gate(x, y):
|
| 45 |
-
# Heaviside: weighted_sum + bias >= 0
|
| 46 |
-
inputs = torch.tensor([float(x), float(y)])
|
| 47 |
-
weighted_sum = (inputs * weights['weight']).sum() + weights['bias']
|
| 48 |
-
return int(weighted_sum >= 0)
|
| 49 |
-
|
| 50 |
-
# Test
|
| 51 |
-
print(or_gate(0, 0)) # 0
|
| 52 |
-
print(or_gate(0, 1)) # 1
|
| 53 |
-
print(or_gate(1, 0)) # 1
|
| 54 |
-
print(or_gate(1, 1)) # 1
|
| 55 |
-
```
|
| 56 |
-
|
| 57 |
-
## Verification
|
| 58 |
-
|
| 59 |
-
**Coq Theorem**:
|
| 60 |
-
```coq
|
| 61 |
-
Theorem or_correct : forall x y, or_circuit x y = orb x y.
|
| 62 |
-
```
|
| 63 |
-
|
| 64 |
-
Proven axiom-free with properties:
|
| 65 |
-
- Commutativity
|
| 66 |
-
- Associativity
|
| 67 |
-
- Identity (OR with false)
|
| 68 |
-
- Absorption (OR with true)
|
| 69 |
-
- Idempotence
|
| 70 |
-
|
| 71 |
-
Full proof: [coq-circuits/Boolean/OR.v](https://github.com/CharlesCNorton/coq-circuits)
|
| 72 |
-
|
| 73 |
-
## Circuit Operation
|
| 74 |
-
|
| 75 |
-
Input combination produces weighted sum:
|
| 76 |
-
- (0,0): 0*1 + 0*1 - 1 = -1 < 0 → 0
|
| 77 |
-
- (0,1): 0*1 + 1*1 - 1 = 0 >= 0 → 1
|
| 78 |
-
- (1,0): 1*1 + 0*1 - 1 = 0 >= 0 → 1
|
| 79 |
-
- (1,1): 1*1 + 1*1 - 1 = 1 >= 0 → 1
|
| 80 |
-
|
| 81 |
-
Requires at least one input to reach threshold.
|
| 82 |
-
|
| 83 |
-
## Citation
|
| 84 |
-
|
| 85 |
-
```bibtex
|
| 86 |
-
@software{tiny_or_prover_2025,
|
| 87 |
-
title={tiny-OR-verified: Formally Verified OR Gate},
|
| 88 |
-
author={Norton, Charles},
|
| 89 |
-
url={https://huggingface.co/phanerozoic/tiny-OR-verified},
|
| 90 |
-
year={2025}
|
| 91 |
-
}
|
| 92 |
-
```
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- formal-verification
|
| 5 |
+
- coq
|
| 6 |
+
- threshold-logic
|
| 7 |
+
- neuromorphic
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# tiny-OR-verified
|
| 11 |
+
|
| 12 |
+
Formally verified OR gate. Single threshold neuron computing disjunction with 100% accuracy.
|
| 13 |
+
|
| 14 |
+
## Architecture
|
| 15 |
+
|
| 16 |
+
| Component | Value |
|
| 17 |
+
|-----------|-------|
|
| 18 |
+
| Inputs | 2 |
|
| 19 |
+
| Outputs | 1 |
|
| 20 |
+
| Neurons | 1 |
|
| 21 |
+
| Parameters | 3 |
|
| 22 |
+
| Weights | [1, 1] |
|
| 23 |
+
| Bias | -1 |
|
| 24 |
+
| Activation | Heaviside step |
|
| 25 |
+
|
| 26 |
+
## Key Properties
|
| 27 |
+
|
| 28 |
+
- 100% accuracy (4/4 inputs correct)
|
| 29 |
+
- Coq-proven correctness
|
| 30 |
+
- Single threshold neuron
|
| 31 |
+
- Integer weights
|
| 32 |
+
- Commutative: OR(x,y) = OR(y,x)
|
| 33 |
+
- Associative: OR(x,OR(y,z)) = OR(OR(x,y),z)
|
| 34 |
+
- Idempotent: OR(x,x) = x
|
| 35 |
+
|
| 36 |
+
## Usage
|
| 37 |
+
|
| 38 |
+
```python
|
| 39 |
+
import torch
|
| 40 |
+
from safetensors.torch import load_file
|
| 41 |
+
|
| 42 |
+
weights = load_file('or.safetensors')
|
| 43 |
+
|
| 44 |
+
def or_gate(x, y):
|
| 45 |
+
# Heaviside: weighted_sum + bias >= 0
|
| 46 |
+
inputs = torch.tensor([float(x), float(y)])
|
| 47 |
+
weighted_sum = (inputs * weights['weight']).sum() + weights['bias']
|
| 48 |
+
return int(weighted_sum >= 0)
|
| 49 |
+
|
| 50 |
+
# Test
|
| 51 |
+
print(or_gate(0, 0)) # 0
|
| 52 |
+
print(or_gate(0, 1)) # 1
|
| 53 |
+
print(or_gate(1, 0)) # 1
|
| 54 |
+
print(or_gate(1, 1)) # 1
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
## Verification
|
| 58 |
+
|
| 59 |
+
**Coq Theorem**:
|
| 60 |
+
```coq
|
| 61 |
+
Theorem or_correct : forall x y, or_circuit x y = orb x y.
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
Proven axiom-free with properties:
|
| 65 |
+
- Commutativity
|
| 66 |
+
- Associativity
|
| 67 |
+
- Identity (OR with false)
|
| 68 |
+
- Absorption (OR with true)
|
| 69 |
+
- Idempotence
|
| 70 |
+
|
| 71 |
+
Full proof: [coq-circuits/Boolean/OR.v](https://github.com/CharlesCNorton/coq-circuits/blob/main/coq/Boolean/OR.v)
|
| 72 |
+
|
| 73 |
+
## Circuit Operation
|
| 74 |
+
|
| 75 |
+
Input combination produces weighted sum:
|
| 76 |
+
- (0,0): 0*1 + 0*1 - 1 = -1 < 0 → 0
|
| 77 |
+
- (0,1): 0*1 + 1*1 - 1 = 0 >= 0 → 1
|
| 78 |
+
- (1,0): 1*1 + 0*1 - 1 = 0 >= 0 → 1
|
| 79 |
+
- (1,1): 1*1 + 1*1 - 1 = 1 >= 0 → 1
|
| 80 |
+
|
| 81 |
+
Requires at least one input to reach threshold.
|
| 82 |
+
|
| 83 |
+
## Citation
|
| 84 |
+
|
| 85 |
+
```bibtex
|
| 86 |
+
@software{tiny_or_prover_2025,
|
| 87 |
+
title={tiny-OR-verified: Formally Verified OR Gate},
|
| 88 |
+
author={Norton, Charles},
|
| 89 |
+
url={https://huggingface.co/phanerozoic/tiny-OR-verified},
|
| 90 |
+
year={2025}
|
| 91 |
+
}
|
| 92 |
+
```
|