Documentation

CslibFrontier.Foundations.Data.BitString.Balanced

Balanced Boolean vectors #

A Boolean vector x : ι → Bool is balanced when exactly half of its coordinates are true (Cslib.BitString.IsBalanced): 2 · weight x = |ι|. Balanced vectors are the "balanced" side of the Deutsch–Jozsa promise (de Wolf, §2.4.1).

The sum of the signs (-1)^{x_i} of a vector is |ι| - 2 · weight x (Cslib.BitString.sum_signVal_eq_card_sub_two_mul_weight). So it vanishes exactly on the balanced vectors (Cslib.BitString.sum_signVal_eq_zero_iff), and it is ±|ι| on the constant ones. This sum is, up to the factor 2^{-n}, the amplitude of |0ⁿ⟩ in the Deutsch–Jozsa algorithm.

Main definitions #

Main results #

References #

def Cslib.BitString.IsBalanced {ι : Type u_1} [Fintype ι] (x : ι → Bool) :

A Boolean vector is balanced when exactly half of its coordinates are true: 2 · weight x = |ι|.

Instances For
    theorem Cslib.BitString.isBalanced_iff {ι : Type u_1} [Fintype ι] {x : ι → Bool} :
    @[instance_reducible]
    theorem Cslib.BitString.isBalanced_iff_card_filter {ι : Type u_1} [Fintype ι] {x : ι → Bool} :
    IsBalanced x ↔ {i : ι | x i = false}.card = {i : ι | x i = true}.card

    A vector is balanced exactly when it has as many false as true coordinates.

    theorem Cslib.BitString.IsBalanced.even_card {ι : Type u_1} [Fintype ι] {x : ι → Bool} (hx : IsBalanced x) :

    A balanced vector has an even number of coordinates.

    theorem Cslib.BitString.sum_signVal_eq_card_sub_two_mul_weight {ι : Type u_1} [Fintype ι] (x : ι → Bool) :
    ∑ i : ι, signVal (x i) = ↑(Fintype.card ι) - 2 * ↑(weight x)

    The sum of the signs of a Boolean vector: ∑ᵢ (-1)^{x_i} = |ι| - 2 · weight x.

    theorem Cslib.BitString.sum_signVal_eq_zero_iff {ι : Type u_1} [Fintype ι] {x : ι → Bool} :
    ∑ i : ι, signVal (x i) = 0 ↔ IsBalanced x

    The signs of a Boolean vector sum to zero exactly when it is balanced.

    theorem Cslib.BitString.IsBalanced.sum_signVal_eq_zero {ι : Type u_1} [Fintype ι] {x : ι → Bool} (hx : IsBalanced x) :
    ∑ i : ι, signVal (x i) = 0

    The signs of a balanced vector sum to zero.