Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Complexity.PolyTime.Polynomial.Modular

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 #

Main results #

Evaluate a polynomial modulo p by Horner's rule, taking the constant coefficient first. For p = 0 return zero.

Every Horner accumulator is a residue, including the zero-modulus convention.

With a positive modulus, the returned representative is strictly below the modulus.

Modular Horner evaluation agrees with evaluation of the coefficient polynomial in ZMod p.

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)) :
ComputableInPolyTime (fun (x : α) => Polynomial.evalCoeffListMod (p x) (z x) (l x)) enc encNat

Evaluate a polynomial given its binary natural coefficients, point and modulus.

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.