Modular Horner evaluation on binary and unary inputs #
Reducing each intermediate value modulo the input modulus bounds the accumulator throughout the fold. The binary machine certificate also handles unary input and output by changing encodings and using the unary modulus as a bound for the returned value.
Main definitions #
Polynomial.evalCoeffListModevaluates a list of natural coefficients modulo a given modulus.
Main results #
Polynomial.natCast_evalCoeffListModinterprets the returned residue as a polynomial value.Turing.MultiTapeTM.ComputableInPolyTime.evalCoeffListModandTuring.MultiTapeTM.ComputableInPolyTime.evalCoeffListMod_unarygive the machine certificates.
Every Horner accumulator is a residue, including the zero-modulus convention.
theorem Polynomial.evalCoeffListMod_lt_modulus {p : ℕ} [NeZero p] (z : ℕ) (l : List ℕ) :
evalCoeffListMod p z l < p
With a positive modulus, the returned representative is strictly below the modulus.
theorem Turing.MultiTapeTM.ComputableInPolyTime.evalCoeffListMod {α : Type} {enc : α ↪ List Bool} {p z : α → ℕ} {l : α → List ℕ} (hp : ComputableInPolyTime p enc encNat) (hz : ComputableInPolyTime z enc encNat) (hl : ComputableInPolyTime l enc (encList encNat)) :
Evaluate a polynomial given its binary natural coefficients, point and modulus.
theorem Turing.MultiTapeTM.ComputableInPolyTime.evalCoeffListMod_unary {α : Type} {enc : α ↪ List Bool} {p z : α → ℕ} {l : α → List ℕ} (hp : ComputableInPolyTime p enc encUnary) (hz : ComputableInPolyTime z enc encUnary) (hl : ComputableInPolyTime l enc (encList encUnary)) :
Modular evaluation of unary coefficients, point and modulus, returning the residue in unary. The modulus bounds the conversion of the binary result back to unary.