tiny-mod6-verified

Formally verified MOD-6 circuit. Single-layer threshold network computing modulo-6 arithmetic with 100% accuracy.

Architecture

Component Value
Inputs 8
Outputs 1 (per residue class)
Neurons 6 (one per residue 0-5)
Parameters 54 (6 × 9)
Weights [1, 1, 1, 1, 1, -5, 1, 1]
Bias 0
Activation Heaviside step

Key Properties

  • 100% accuracy (256/256 inputs correct)
  • Coq-proven correctness
  • Algebraic weight pattern: resets every 6 positions
  • Computes Hamming weight mod 6
  • Compatible with neuromorphic hardware

Algebraic Pattern

MOD-6 uses the pattern with reset at position 6:

  • Positions 1-5: weight = 1
  • Position 6: weight = 1-6 = -5
  • Positions 7-8: weight = 1

This creates a cumulative sum that cycles mod 6.

Usage

import torch
from safetensors.torch import load_file

weights = load_file('mod6.safetensors')

def mod6_circuit(bits):
    # bits: list of 8 binary values
    inputs = torch.tensor([float(b) for b in bits])
    weighted_sum = (inputs * weights['weight']).sum() + weights['bias']
    return weighted_sum.item()

# Test
print(mod6_circuit([1,1,1,1,1,1,0,0]))  # 6 mod 6 = 0
print(mod6_circuit([1,1,1,1,1,1,1,0]))  # 7 mod 6 = 1

Verification

Coq Theorem:

Theorem mod6_correct_residue_0 : forall x0 x1 x2 x3 x4 x5 x6 x7,
  mod6_is_zero [x0; x1; x2; x3; x4; x5; x6; x7] =
  Z.eqb ((Z.of_nat (hamming_weight [x0; x1; x2; x3; x4; x5; x6; x7])) mod 6) 0.

Proven axiom-free using algebraic weight patterns.

Full proof: coq-circuits/Modular/Mod6.v

Residue Distribution

For 8-bit inputs (256 total):

  • Residue 0: 29 inputs
  • Residue 1: 16 inputs
  • Residue 2: 29 inputs
  • Residue 3: 56 inputs
  • Residue 4: 70 inputs
  • Residue 5: 56 inputs

Citation

@software{tiny_mod6_verified_2025,
  title={tiny-mod6-verified: Formally Verified MOD-6 Circuit},
  author={Norton, Charles},
  url={https://huggingface.co/phanerozoic/tiny-mod6-verified},
  year={2025}
}
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collection including phanerozoic/tiny-mod6-verified