Support subsets of list-represented bit strings #
Views word : List Bool as its support subset {i : Fin n | ofList n word i = true} via
Cslib.BitString.ofList, padding short lists with false and ignoring indices ≥ n.
Conversely, Cslib.BitString.indicatorList is the word of n bits that sets bit i exactly
when i ∈ S; on words of length n the two conversions are inverse.
Main definitions #
Cslib.BitString.supportOfList: support subset{i : Fin n | ofList n word i = true}.Cslib.BitString.indicatorList: the indicator word of a subset ofFin n.
Main results #
Cslib.BitString.mem_supportOfList,Cslib.BitString.supportOfList_ofFn_decide,Cslib.BitString.ofFn_decide_mem_supportOfList,Cslib.BitString.supportOfList_injective_of_length,Cslib.BitString.card_supportOfList_of_length: membership, round-trips, injectivity, and card.Cslib.BitString.supportOfList_indicatorList,Cslib.BitString.indicatorList_supportOfList,Cslib.BitString.indicatorList_injective,Cslib.BitString.count_true_indicatorList: the same facts for the indicator word.Cslib.BitString.indicatorList_insert,Cslib.BitString.indicatorList_erase: adding or removing an element sets or clears its bit.
@[simp]
Coordinate i : Fin n lies in supportOfList n word iff word.getD i.val false = true.
theorem Cslib.BitString.ofFn_decide_mem_supportOfList {n : ℕ} {word : List Bool} (hw : word.length = n) :
On words of length n, List.ofFn (fun i => decide (i ∈ supportOfList n word)) is word.
theorem Cslib.BitString.supportOfList_injective_of_length {n : ℕ} {w₁ w₂ : List Bool} (hw₁ : w₁.length = n) (hw₂ : w₂.length = n) (heq : supportOfList n w₁ = supportOfList n w₂) :
w₁ = w₂
On words of exact length n, supportOfList n is injective.
Indicator words #
@[simp]
@[simp]
@[simp]
Adding an element sets its bit.
Removing an element clears its bit.
@[simp]
The indicator word of {i} is the zero word with bit i set.