Documentation

CslibFrontier.Foundations.Data.Polynomial.BinaryDigits

Binary digits as polynomial coefficients #

Polynomial.binaryDigits n has the binary digits of n as its coefficients, starting with the least significant bit. Evaluation at 2 recovers n; evaluation at 1 is at most the binary length n.size. This separates a large integer's magnitude from the sizes of the coefficients used in an exact polynomial computation.

For a polynomial over ℕ, every coefficient is at most its value at 1. Consequently a degree bound and a bound on this value give exact recovery from a list of coefficient residues.

Main definitions #

Main results #

noncomputable def Polynomial.binaryDigits (n : ℕ) :

The polynomial whose coefficients are the binary digits of n, least significant first.

@[simp]

Evaluating the binary-digit polynomial at 2 recovers the natural number.

The sum of the binary digits is at most the binary length.

The binary-digit polynomial has degree at most the binary length less one.

A coefficient of a polynomial over the natural numbers is at most the sum of its coefficients, its value at 1.

theorem Polynomial.ofCoeffList_coeffsBelow_mod {p : Polynomial ℕ} {ℓ M : ℕ} (hdeg : p.natDegree < ℓ) (hM : eval 1 p < M) :
ofCoeffList (List.map (fun (i : ℕ) => p.coeff i % M) (List.range ℓ)) = p

A polynomial over the natural numbers is recovered from the residues of sufficiently many low coefficients when its coefficient sum is below the modulus.