Fixed-cardinality supports and fixed-weight bit strings #
A subset of range n is represented as its Boolean indicator on Fin n. This identifies the
w-element subsets of range n with the bit strings of length n and weight w.
Main definitions #
Cslib.BitString.indicatorVector: the indicator of a finite set of natural-number positions.Cslib.BitString.natSupport: the natural-number positions set in a bit string.Cslib.BitString.fixedSupportEquiv: the equivalence between fixed-cardinality supports and fixed-weight bit strings.
Main results #
Cslib.BitString.weight_indicatorVector: the indicator has the cardinality of an in-range set.Cslib.BitString.natSupport_indicatorVector,Cslib.BitString.indicatorVector_natSupport: the conversions are inverse on in-range sets.
@[simp]
@[simp]
A coordinate belongs to the natural support exactly when its bit is set.
theorem Cslib.BitString.natSupport_subset_range {n : ℕ} (x : BitString n) :
x.natSupport ⊆ Finset.range n
The natural support of an n-bit string lies in range n.
@[simp]
The natural support has cardinality equal to the Hamming weight.
The indicator of an in-range set has weight equal to the set's cardinality.
@[simp]
theorem Cslib.BitString.natSupport_indicatorVector {n : ℕ} {S : Finset ℕ} (hS : S ⊆ Finset.range n) :
Taking the natural support of an in-range indicator returns the original set.
@[simp]
The indicator of the natural support is the original bit string.
Fixed-cardinality subsets of range n are exactly fixed-weight n-bit strings. Its body is
exposed so downstream proofs can reduce the forward map to indicatorVector.
@[simp]
theorem Cslib.BitString.fixedSupportEquiv_apply (n w : ℕ) (S : ↥(Finset.powersetCard w (Finset.range n))) :