threshold-nor / README.md
CharlesCNorton
Add optimality note: exhaustive enumeration confirms magnitude 2 is minimum
8080444
metadata
license: mit
tags:
  - pytorch
  - safetensors
  - threshold-logic
  - neuromorphic
  - functionally-complete

threshold-nor

The silence detector. Fires only when both inputs are quiet.

Circuit

    x   y
    β”‚   β”‚
    β””β”€β”¬β”€β”˜
      β–Ό
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚w: -1,-1β”‚
  β”‚ b:  0  β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      β”‚
      β–Ό
   NOR(x,y)

Mechanism

With bias 0, we start exactly at threshold. Any input subtracts, pushing us below:

x y sum output
0 0 0 1
0 1 -1 0
1 0 -1 0
1 1 -2 0

NOR is OR with inverted output. It's also NOT extended to two inputs: NOR(x,x) = NOT(x).

Parameters

Weights [-1, -1]
Bias 0
Total 3 parameters

Optimality

Exhaustive enumeration of all 7 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.

Functional Completeness

Like NAND, NOR can build any Boolean function:

  • NOT(x) = NOR(x, x)
  • OR(x,y) = NOT(NOR(x,y)) = NOR(NOR(x,y), NOR(x,y))
  • AND(x,y) = NOR(NOT(x), NOT(y))

NOR logic was used in the Apollo Guidance Computer.

Usage

from safetensors.torch import load_file
import torch

w = load_file('model.safetensors')

def nor_gate(x, y):
    inputs = torch.tensor([float(x), float(y)])
    return int((inputs * w['weight']).sum() + w['bias'] >= 0)

Files

threshold-nor/
β”œβ”€β”€ model.safetensors
β”œβ”€β”€ model.py
β”œβ”€β”€ config.json
└── README.md

License

MIT