File size: 2,419 Bytes
adc776c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8dd055d
 
 
 
adc776c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
---

license: mit
tags:
- pytorch
- safetensors
- threshold-logic
- neuromorphic
- functionally-complete
---


# threshold-nor3

3-input NOR gate. Fires only when all inputs are silent. The silence detector.

## Circuit

```

    a   b   c

    β”‚   β”‚   β”‚

    β””β”€β”€β”€β”Όβ”€β”€β”€β”˜

        β”‚

        β–Ό

   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”

   β”‚w: -1,-1,-1β”‚

   β”‚ b:   0   β”‚

   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

        β”‚

        β–Ό

   NOR(a,b,c)

```

## The Perfect Silence Test

3-input NOR fires only on complete absence:

| Inputs | Sum | Output |
|--------|-----|--------|
| **000** | **0** | **1** |
| 001 | -1 | 0 |
| 010 | -1 | 0 |
| 011 | -2 | 0 |
| 100 | -1 | 0 |
| 101 | -2 | 0 |
| 110 | -2 | 0 |
| 111 | -3 | 0 |

Any activity silences the gate.

## Zero-Budget Design

With bias 0, we start exactly at threshold:

```

sum = -a - b - c + 0 = -HW

fires when -HW >= 0

fires when HW = 0

```

No tolerance. The slightest input pushes us below threshold.

## Functional Completeness

Like NAND, NOR is universal:

- NOT(x) = NOR(x, x, x)
- OR(x,y,z) = NOR(NOR(x,y,z), NOR(x,y,z), NOR(x,y,z))
- AND(x,y,z) = NOR(NOR(x,x,x), NOR(y,y,y), NOR(z,z,z))

NOR logic powered the Apollo Guidance Computer.

## Extension of 2-input NOR

| Gate | Weights | Bias |
|------|---------|------|
| NOR(a,b) | [-1, -1] | 0 |
| **NOR(a,b,c)** | [-1, -1, -1] | 0 |
| NOR(a,b,c,d) | [-1, -1, -1, -1] | 0 |

All have bias 0. Only the number of inputs changes.

## Parameters

| Component | Value |
|-----------|-------|
| Weights | [-1, -1, -1] |
| Bias | 0 |
| **Total** | **4 parameters** |

## Optimality

Exhaustive enumeration of all 129 weight configurations at magnitudes 0-3 confirms this circuit is **already at minimum magnitude (3)**. There is exactly one valid configuration at magnitude 3, and no valid configurations exist below it.

## Usage

```python

from safetensors.torch import load_file

import torch



w = load_file('model.safetensors')



def nor3(a, b, c):

    inp = torch.tensor([float(a), float(b), float(c)])

    return int((inp * w['weight']).sum() + w['bias'] >= 0)



print(nor3(0, 0, 0))  # 1

print(nor3(0, 0, 1))  # 0

```

## Files

```

threshold-nor3/

β”œβ”€β”€ model.safetensors

β”œβ”€β”€ model.py

β”œβ”€β”€ config.json

└── README.md

```

## License

MIT