--- license: mit tags: - formal-verification - coq - threshold-logic - neuromorphic - majority --- # tiny-Majority-verified Formally verified majority gate for 8-bit inputs. Single threshold neuron computing majority function with 100% accuracy. ## Architecture | Component | Value | |-----------|-------| | Inputs | 8 | | Outputs | 1 | | Neurons | 1 | | Parameters | 9 | | Weights | [1, 1, 1, 1, 1, 1, 1, 1] | | Bias | -5 | | Activation | Heaviside step | ## Key Properties - 100% accuracy (256/256 inputs correct) - Coq-proven correctness - Single threshold neuron - Integer weights - Fires when ≥5 of 8 inputs are true - Equivalent to 5-out-of-8 threshold ## Usage ```python import torch from safetensors.torch import load_file weights = load_file('majority.safetensors') def majority_gate(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 int(weighted_sum >= 0) # Test print(majority_gate([0,0,0,0,0,0,0,0])) # 0 (no majority) print(majority_gate([1,1,1,1,0,0,0,0])) # 0 (4/8, not majority) print(majority_gate([1,1,1,1,1,0,0,0])) # 1 (5/8, majority!) print(majority_gate([1,1,1,1,1,1,1,1])) # 1 (8/8, majority) ``` ## Verification **Coq Theorem**: ```coq Theorem majority_correct : forall x0 x1 x2 x3 x4 x5 x6 x7, majority_circuit [x0; x1; x2; x3; x4; x5; x6; x7] = majority_spec [x0; x1; x2; x3; x4; x5; x6; x7]. ``` Proven axiom-free via three methods: 1. **Exhaustive**: Verified on all 256 inputs 2. **Universal**: Quantified proof over all boolean combinations 3. **Algebraic**: Characterized via hamming weight ≥ 5 **Algebraic characterization**: ```coq Theorem majority_hamming_weight (xs : list bool) : length xs = 8 -> majority_circuit xs = true <-> hamming_weight xs >= 5. ``` Full proof: [coq-circuits/Threshold/Majority.v](https://github.com/CharlesCNorton/coq-circuits/blob/main/coq/Threshold/Majority.v) ## Circuit Operation Input with k true bits produces weighted sum: k*1 - 5 = k - 5 - k < 5: weighted_sum < 0 → output 0 (no majority) - k ≥ 5: weighted_sum ≥ 0 → output 1 (majority) ## Applications - Voting systems - Fault-tolerant computing - Consensus protocols - Error correction (majority voting) ## Citation ```bibtex @software{tiny_majority_prover_2025, title={tiny-Majority-verified: Formally Verified Majority Gate}, author={Norton, Charles}, url={https://huggingface.co/phanerozoic/tiny-Majority-verified}, year={2025} } ```