Documentation

Complexity.Computability.Circuit.Boolean.Metric

The computational Hamming metric #

Boolean functions on n inputs form a group under the exclusive or, which is the addition of Mathlib's Boolean ring Bool, taken pointwise: (f + g) x = f x ^^ g x. The computational Hamming distance Cslib.Circuits.Boolean.circuitDist f g is 0 when f = g, and otherwise the De Morgan circuit complexity of f + g plus four, the cost of an exclusive or (Cslib.Circuits.Boolean.circuitDist_def). It is the difference distance of Complexity.Computability.Circuit.Metric for the De Morgan interpretation with c = 4, by definition (Cslib.Circuits.Boolean.circuitDist_eq_diffDist), since f - g = f + g and -f = f.

It is a translation-invariant metric: f + h = (f + g) + (g + h) gives the triangle inequality from C(f ⊕ h) ≤ C(f ⊕ g) + C(g ⊕ h) + 4. Circuit complexity is 1-Lipschitz for it, |C(f) - C(g)| ≤ circuitDist f g (Cslib.Circuits.Boolean.dist_complexity_single_le_circuitDist), which is the correction bound |C(f) - C(g)| ≤ C(f ⊕ g) + 4 of Cslib.Circuits.Boolean.dist_complexity_single_le_complexity_xor [Juk12]. Unlike the normalized Hamming distance, it does not separate functions that differ on many inputs but in a simple way: two functions whose exclusive or is a projection are at distance four.

The same quantity is a norm, 0 at 0 and C(f) + 4 otherwise (Cslib.Circuits.Boolean.circuitNorm), and induces the metric (Cslib.Circuits.Boolean.dist_circuitNormedAddCommGroup). The normed group is a definition, not an instance, since BooleanFunction n is a function type. Apart from the zero function and the offset, the minimum circuit size problem asks for membership in balls about zero: C(f) ≤ s exactly when f lies in the closed ball of radius s + 4 about 0 (Cslib.Circuits.Boolean.complexity_single_le_iff_mem_closedBall).

Main definitions #

Main results #

References #

The group operations as circuits #

Adding two inputs, an exclusive or, costs four De Morgan gates.

Negation is the identity on Boolean functions, so it leaves complexity unchanged.

The computational Hamming distance #

noncomputable def Cslib.Circuits.Boolean.circuitDist {n : ℕ} (f g : BooleanFunction n) :

The computational Hamming distance: 0 if f = g, and otherwise the complexity of f + g, the inputs where f and g differ, plus four.

Instances For

    The computational Hamming distance is the difference distance with c = 4.

    theorem Cslib.Circuits.Boolean.circuitDist_of_ne {n : ℕ} {f g : BooleanFunction n} (h : f ≠ g) :
    circuitDist f g = complexity interpretation (single fun (x : Fin n → Bool) => f x ^^ g x) + 4

    Distinct functions are at distance the complexity of their exclusive or plus four.

    The triangle inequality, from the cost of an exclusive or.

    Circuit complexity is 1-Lipschitz for the computational Hamming distance.

    The norm #

    The computational Hamming norm: 0 at 0, and otherwise the complexity plus four.

    Instances For
      @[reducible, inline]

      The normed group of Boolean functions with the computational Hamming norm. This is a definition, not an instance, since BooleanFunction n is a function type.

      Instances For

        The normed group induces the computational Hamming distance.

        Complexity bounds as balls #

        For f ≠ 0, the minimum circuit size problem is membership in a ball about 0.

        For f ≠ 0, the minimum circuit size problem is membership in the closed ball of radius s + 4 about 0 for the computational Hamming norm.