Documentation

CslibFrontier.Foundations.Data.BitString.WeightInterval

Strings of a given weight below or above a string #

In the pointwise order on ι → Bool, the strings x ≤ y of weight a are the indicators of the a-element subsets of the support of y, so there are C(|y|, a) of them (Cslib.BitString.card_filter_le_and_weight_eq). Complementing every bit reverses the order, so the strings y ≥ x of weight b ≤ |ι| number C(|ι| - |x|, |ι| - b) (Cslib.BitString.card_filter_ge_and_weight_eq). These count the partners in the containment relation between two weight layers that adversary arguments use.

Main results #

theorem Cslib.BitString.card_filter_le_and_weight_eq {ι : Type u_1} [Fintype ι] [DecidableEq ι] (y : ι → Bool) (a : ℕ) :
{x : ι → Bool | x ≤ y ∧ weight x = a}.card = (weight y).choose a

The strings of weight a below y are the indicators of the a-element subsets of the support of y: there are C(|y|, a) of them.

theorem Cslib.BitString.card_filter_ge_and_weight_eq {ι : Type u_1} [Fintype ι] [DecidableEq ι] (x : ι → Bool) {b : ℕ} (hb : b ≤ Fintype.card ι) :
{y : ι → Bool | x ≤ y ∧ weight y = b}.card = (Fintype.card ι - weight x).choose (Fintype.card ι - b)

The strings of weight b ≤ |ι| above x are the complements of the strings of weight |ι| - b below the complement of x: there are C(|ι| - |x|, |ι| - b) of them.