Bit-prefix projection of bit strings as an additive homomorphism #
When M ≤ q, taking the first M bits of a q-bit word v : BitString q agrees with
Cslib.BitString.zeroExtend (d' := M) v, forms a surjective additive group homomorphism
Cslib.BitString.restrictBitsAddHom hM : BitString q →+ BitString M, and reduces the unsigned
integer value Cslib.BitString.equivFin q v modulo 2 ^ M
(Cslib.BitString.val_equivFin_restrictBitsAddHom).
Placing these declarations in a dedicated topic module avoids expanding the public interface of the
widely imported Complexity/Foundations/Data/BitString/Basic.lean.
Main definitions #
Cslib.BitString.restrictBitsAddHom: projectingBitString qto its firstM ≤ qbits as an additive group homomorphismBitString q →+ BitString M.
Main results #
Cslib.BitString.restrictBitsAddHom_eq_zeroExtend:restrictBitsAddHom hM vagrees withzeroExtend (d' := M) v.Cslib.BitString.restrictBitsAddHom_zeroExtend,Cslib.BitString.restrictBitsAddHom_surjective:zeroExtendis a right inverse torestrictBitsAddHom hM, which is therefore surjective.Cslib.BitString.val_equivFin_restrictBitsAddHom: the unsigned value ofrestrictBitsAddHom hM vis(equivFin q v).val % 2 ^ M.
When M ≤ q, restrictBitsAddHom hM v agrees pointwise with zeroExtend (d' := M) v.
Zero-extending an M-bit string to q ≥ M bits is a right inverse to
restrictBitsAddHom hM.
restrictBitsAddHom hM is surjective whenever M ≤ q.