Native binary modulus switching #
The source and target moduli use binary encNat; representatives and rounded integers use
signed binary encIntBin. The certificates charge the complete input bit length and reuse
native signed multiplication, division and remainder. No rational-arithmetic machine or
unary expansion of the moduli is needed.
Main results #
Turing.MultiTapeTM.ComputableInPolyTime.intBin_roundScale: exact rationally specified nearest-integer scaling, realized by integer arithmetic.Turing.MultiTapeTM.ComputableInPolyTime.modulusSwitchResidue: the canonical-residue implementation, with both moduli supplied at runtime.
Scale a signed binary integer by the ratio of two binary naturals and round exactly. At source modulus zero, the rational specification and the implementation both return zero.
Compute the integer implementation of modulus switching on binary parameters and a signed binary representative, returning a binary natural residue. The implementation is total.