Documentation

Complexitylib.Circuits.Majority

Strict-majority circuits #

This module packages the unary threshold fragment as a typed fan-in-two AND/OR circuit. On n inputs it uses exactly 3 + 2 * n * (n / 2 + 1) gates and returns true exactly when strictly more than half of its inputs are true.

theorem Complexity.CircuitCode.strictMajorityThreshold_le (inputCount : ) [NeZero inputCount] :
strictMajorityThreshold inputCount inputCount

A strict-majority threshold never exceeds a positive input count.

@[simp]

Exact raw gate count for the strict-majority construction.

The raw strict-majority construction is a valid single-output circuit at every positive input arity.

noncomputable def Complexity.Circuit.strictMajority (inputCount : ) [NeZero inputCount] :

Typed fan-in-two strict-majority circuit reconstructed from the verified raw threshold fragment.

Equations
Instances For
    @[simp]
    theorem Complexity.Circuit.size_strictMajority (inputCount : ) [NeZero inputCount] :
    (strictMajority inputCount).size = 3 + 2 * inputCount * CircuitCode.strictMajorityThreshold inputCount

    Exact size of the typed strict-majority circuit.

    theorem Complexity.Circuit.eval_strictMajority (inputCount : ) [NeZero inputCount] (input : BitString inputCount) :

    The typed circuit returns the unary-count strict-majority predicate.