threshold-implies / README.md
CharlesCNorton
Add optimality note: exhaustive enumeration confirms magnitude 2 is minimum
bef90df
---
license: mit
tags:
- pytorch
- safetensors
- threshold-logic
- neuromorphic
---
# threshold-implies
Material implication: x β†’ y. The only two-input Boolean function with asymmetric weights.
## Circuit
```
x y
β”‚ β”‚
β””β”€β”¬β”€β”˜
β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”
β”‚w: -1,1β”‚
β”‚ b: 0 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β–Ό
x β†’ y
```
## Mechanism
The antecedent x has weight -1 (inhibitory), the consequent y has weight +1 (excitatory):
| x | y | sum | output | meaning |
|---|---|-----|--------|---------|
| 0 | 0 | 0 | 1 | false β†’ false |
| 0 | 1 | +1 | 1 | false β†’ true |
| 1 | 0 | -1 | 0 | true β†’ false βœ— |
| 1 | 1 | 0 | 1 | true β†’ true |
The only failure: asserting a true antecedent with a false consequent. This is the only thing implication forbids.
## Equivalent Forms
- x β†’ y = Β¬x ∨ y
- x β†’ y = Β¬(x ∧ Β¬y)
The weights [-1, +1] directly implement Β¬x + y.
## Parameters
| | |
|---|---|
| Weights | [-1, +1] |
| Bias | 0 |
| Total | 3 parameters |
## Optimality
Exhaustive enumeration of all 25 weight configurations at magnitudes 0-2 confirms this circuit is **already at minimum magnitude (2)**. There is exactly one valid configuration at magnitude 2, and no valid configurations exist below it.
## Properties
- Linearly separable (unlike XOR)
- Not commutative: (x β†’ y) β‰  (y β†’ x)
- Reflexive: x β†’ x = 1
- Ex falso quodlibet: 0 β†’ y = 1
## Usage
```python
from safetensors.torch import load_file
import torch
w = load_file('model.safetensors')
def implies_gate(x, y):
inputs = torch.tensor([float(x), float(y)])
return int((inputs * w['weight']).sum() + w['bias'] >= 0)
```
## Files
```
threshold-implies/
β”œβ”€β”€ model.safetensors
β”œβ”€β”€ model.py
β”œβ”€β”€ config.json
└── README.md
```
## License
MIT