Documentation

CslibFrontier.Computability.Circuit.Boolean.IntThreshold

Integer threshold gates in logarithmic depth #

An integer threshold gate (Cslib.Circuits.Boolean.IntThreshold.Op) is true when ∑ uᵢ xᵢ > θ. Reading each input with a negative weight as its negation, the condition becomes T ≤ ∑ |uᵢ| ℓᵢ for the literals ℓᵢ and a target T. With W bits for the sum and the target, the masked words |uᵢ| · ℓᵢ and the offset 2 ^ W - T are summed by a balanced carry-save tree with a logarithmic-depth finishing adder (Cslib.Circuits.Boolean.sumPairs), and bit W of the result decides the gate (Cslib.Circuits.Boolean.IntThreshold.Op.eval_deMorganCircuit). The De Morgan circuit has O(k W²) gates and depth O(log k + log W) for k inputs (Cslib.Circuits.Boolean.IntThreshold.Op.size_deMorganCircuit_le, Cslib.Circuits.Boolean.IntThreshold.Op.depth_deMorganCircuit_le).

Main definitions #

Main results #

References #

An integer threshold gate: k inputs, integer weights and an integer bias.

  • arity : ℕ

    The number of inputs.

  • weight : Fin self.arity → ℤ

    The weight of each input.

  • bias : ℤ

    The bias.

@[reducible, inline]

The signature of integer threshold gates.

An integer threshold gate is true when the weighted sum of its inputs exceeds its bias.

The word width: every literal sum and the target are below 2 ^ width.

The circuit #

The De Morgan circuit of an integer threshold gate: a constant true when the target is at most zero, and otherwise bit width of the sum of the masked words and the offset.

The De Morgan circuit of an integer threshold gate computes it.

Size and depth #

The De Morgan circuit of an integer threshold gate has polynomial size in its arity and width.

The De Morgan circuit of an integer threshold gate has logarithmic depth in its arity and width.

theorem Cslib.Circuits.Boolean.IntThreshold.Op.width_le (op : Op) {B : ℕ} (hw : ∀ (i : Fin op.arity), |op.weight i| ≤ ↑B) (hb : |op.bias| ≤ ↑B) :
op.width ≤ ((2 * op.arity + 2) * (B + 1)).size

With weights and bias bounded by B, the width is at most the bit size of (2 k + 2) (B + 1).