Documentation

CslibFrontier.Foundations.Data.Polynomial.RingLagrange

Lagrange interpolation over a commutative ring #

Mathlib's Lagrange.interpolate works over a field. Over a commutative ring R, interpolation at nodes v i, i ∈ s, still works when the nodes have unit differences: every v i - v j with i ≠ j is a unit. Galois rings such as (ℤ / 2 ^ p)[U] / (f) are the motivating example; they are not domains, but lifts of distinct residue-field elements differ by units.

The Lagrange basis polynomial at i is ∏_{j ∈ s, j ≠ i} (X - v j) / (v i - v j), where the division is multiplication by Ring.inverse (v i - v j) (Lagrange.ringBasis). It is one at v i and zero at the other nodes, so Lagrange.ringInterpolate s v r = ∑ i ∈ s, r i • basis i takes the value r i at v i. A polynomial of degree less than #s that vanishes at all nodes is zero, because the factors X - v i are pairwise coprime; hence every polynomial of degree less than #s is the interpolant of its values (Lagrange.eq_ringInterpolate). Over a field these are Mathlib's Lagrange.basis and Lagrange.interpolate (Lagrange.ringInterpolate_eq_interpolate).

Main definitions #

Main results #

noncomputable def Lagrange.ringBasis {R : Type u_1} [CommRing R] {ι : Type u_2} [DecidableEq ι] (s : Finset ι) (v : ι → R) (i : ι) :

The Lagrange basis polynomial ∏_{j ∈ s, j ≠ i} (X - v j) / (v i - v j) over a commutative ring, where division by v i - v j is multiplication by Ring.inverse (v i - v j). When the nodes have unit differences it is one at v i and zero at the other nodes.

noncomputable def Lagrange.ringInterpolate {R : Type u_1} [CommRing R] {ι : Type u_2} [DecidableEq ι] (s : Finset ι) (v : ι → R) :
(ι → R) →ₗ[R] Polynomial R

Lagrange interpolation over a commutative ring: ∑ i ∈ s, r i • ringBasis s v i. At nodes with unit differences, it is the unique polynomial of degree less than #s taking the value r i at v i.

theorem Lagrange.ringInterpolate_apply {R : Type u_1} [CommRing R] {ι : Type u_2} [DecidableEq ι] (s : Finset ι) (v r : ι → R) :
(ringInterpolate s v) r = ∑ i ∈ s, Polynomial.C (r i) * ringBasis s v i
theorem Lagrange.eval_ringBasis_self {R : Type u_1} [CommRing R] {ι : Type u_2} [DecidableEq ι] {s : Finset ι} {v : ι → R} {i : ι} (hvs : (↑s).Pairwise fun (i j : ι) => IsUnit (v i - v j)) (hi : i ∈ s) :
Polynomial.eval (v i) (ringBasis s v i) = 1

The basis polynomial at i is one at its own node.

theorem Lagrange.eval_ringBasis_of_ne {R : Type u_1} [CommRing R] {ι : Type u_2} [DecidableEq ι] {s : Finset ι} {v : ι → R} {i j : ι} (hij : i ≠ j) (hj : j ∈ s) :
Polynomial.eval (v j) (ringBasis s v i) = 0

The basis polynomial at i vanishes at every other node.

theorem Lagrange.natDegree_ringBasis_le {R : Type u_1} [CommRing R] {ι : Type u_2} [DecidableEq ι] (s : Finset ι) (v : ι → R) (i : ι) :
theorem Lagrange.degree_ringBasis_lt {R : Type u_1} [CommRing R] {ι : Type u_2} [DecidableEq ι] {s : Finset ι} {v : ι → R} {i : ι} (hi : i ∈ s) :
(ringBasis s v i).degree < ↑s.card

The basis polynomial at a node has degree less than the number of nodes.

theorem Lagrange.degree_ringInterpolate_lt {R : Type u_1} [CommRing R] {ι : Type u_2} [DecidableEq ι] {s : Finset ι} {v : ι → R} (r : ι → R) :
((ringInterpolate s v) r).degree < ↑s.card

The interpolant has degree less than the number of nodes.

theorem Lagrange.eval_ringInterpolate_at_node {R : Type u_1} [CommRing R] {ι : Type u_2} [DecidableEq ι] {s : Finset ι} {v : ι → R} {i : ι} (hvs : (↑s).Pairwise fun (i j : ι) => IsUnit (v i - v j)) (r : ι → R) (hi : i ∈ s) :
Polynomial.eval (v i) ((ringInterpolate s v) r) = r i

The interpolant takes the prescribed values at nodes with unit differences.

theorem Lagrange.eq_zero_of_degree_lt_of_eval_eq_zero {R : Type u_1} [CommRing R] {ι : Type u_2} {s : Finset ι} {v : ι → R} (hvs : (↑s).Pairwise fun (i j : ι) => IsUnit (v i - v j)) {f : Polynomial R} (hf : f.degree < ↑s.card) (h0 : ∀ i ∈ s, Polynomial.eval (v i) f = 0) :
f = 0

Uniqueness of interpolation over a commutative ring. A polynomial of degree less than #s that vanishes at nodes with unit differences is zero: the factors X - v i are pairwise coprime, so their product, of degree #s, divides it.

theorem Lagrange.eq_ringInterpolate {R : Type u_1} [CommRing R] {ι : Type u_2} [DecidableEq ι] {s : Finset ι} {v : ι → R} (hvs : (↑s).Pairwise fun (i j : ι) => IsUnit (v i - v j)) {f : Polynomial R} (hf : f.degree < ↑s.card) :
f = (ringInterpolate s v) fun (i : ι) => Polynomial.eval (v i) f

Every polynomial of degree less than #s is the interpolant of its values at nodes with unit differences.

theorem Lagrange.ringBasis_eq_basis {ι : Type u_2} [DecidableEq ι] {F : Type u_3} [Field F] (s : Finset ι) (v : ι → F) (i : ι) :

Over a field, ringBasis is Mathlib's Lagrange.basis.

theorem Lagrange.ringInterpolate_eq_interpolate {ι : Type u_2} [DecidableEq ι] {F : Type u_3} [Field F] (s : Finset ι) (v : ι → F) :

Over a field, ringInterpolate is Mathlib's Lagrange.interpolate.