File size: 2,289 Bytes
f1c4e16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44209e4
 
 
 
f1c4e16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---

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


# threshold-and3

3-input AND gate. Fires when all three inputs are active. The 3-of-3 threshold gate.

## Circuit

```

    a   b   c

    β”‚   β”‚   β”‚

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

        β”‚

        β–Ό

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

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

   β”‚ b:  -3  β”‚

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

        β”‚

        β–Ό

   AND(a,b,c)

```

## The Unanimity Requirement

3-input AND is the smallest non-trivial unanimity gate:

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

Only when all three contribute does the sum reach the threshold.

## Generalization from 2-input AND

| Gate | Weights | Bias | Threshold |
|------|---------|------|-----------|
| AND(a,b) | [1, 1] | -2 | 2 votes needed |
| **AND(a,b,c)** | [1, 1, 1] | -3 | 3 votes needed |
| AND(a,b,c,d) | [1, 1, 1, 1] | -4 | 4 votes needed |

The pattern: n inputs, all weight +1, bias -n.

## Single Point of Veto

Any single 0 input blocks the gate:

- a=0: max sum = 0 + 1 + 1 - 3 = -1 < 0
- b=0: max sum = 1 + 0 + 1 - 3 = -1 < 0
- c=0: max sum = 1 + 1 + 0 - 3 = -1 < 0

Each input has veto power. This is unanimous consent.

## Parameters

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

## Optimality

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

## Usage

```python

from safetensors.torch import load_file

import torch



w = load_file('model.safetensors')



def and3(a, b, c):

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

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



print(and3(1, 1, 1))  # 1

print(and3(1, 1, 0))  # 0

```

## Files

```

threshold-and3/

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

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

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

└── README.md

```

## License

MIT