Documentation

CslibFrontier.Algorithms.Lean.SubproductTree

Subproduct Trees and Remainder-Tree Multipoint Evaluation over Commutative Rings #

Balanced subproduct trees, top-down monic remainder-tree evaluation, and bivariate difference products over an arbitrary commutative ring R. The balanced tree construction (buildSubproductTree) and top-down remainder traversal (remainderTreeEval / fastMultipointEval) follow the supermoduli construction and top-down remainder recursion of [BM74] (§5, Lemma on pp. 372–373 and Algorithm Modular Form on pp. 373–374) and [vzGG13] (§10.1, p. 295), generalized here from a Euclidean domain with power-of-two size to an arbitrary commutative ring R and arbitrary list length (reducing p modulo the current node's polynomial on entry to each internal node rather than pre-reducing by each child modulus before recursing). fastBivariateDiffProd is an algebraic application computing the bivariate pairwise difference product via buildSubproductTree and fastMultipointEval.

Because every internal polynomial stored in a multiplicative subproduct tree is monic, Euclidean division with remainder by monic polynomials (Polynomial.modByMonic, written %ₘ) is exact over any commutative ring R without requiring R to be a field, an integral domain, or even nontrivial. In particular, all algebraic identities apply directly to composite residue rings such as ZMod 6 and quotient algebras AdjoinRoot h for reducible monic polynomials h.

Scope and model boundaries #

The polynomial-valued and evaluation definitions (SubproductTree.rootPoly, SubproductTree.map, buildSubproductTree, remainderTreeEval, fastMultipointEval, and fastBivariateDiffProd) are noncomputable, using Mathlib's abstract polynomial operations and Polynomial.modByMonic. The results proved here are:

Multiplication and division costs are unmodeled; in particular, this module does not formalize the arithmetic-operation bounds derived from fast polynomial multiplication and division in [BM74] (Theorem 1, p. 372; Corollary 2, p. 375) or [vzGG13] (§10.1, p. 295).

Main definitions #

Main results #

References #

Binary tree storing monic subproduct polynomials over a commutative ring R: empty represents the empty point list with polynomial 1, leaf a represents a singleton point [a] with linear polynomial X - C a, and node poly left right caches the product polynomial poly above two subtrees left and right.

Instances For
    @[instance_reducible]

    Canonical inhabited instance for SubproductTree R given by SubproductTree.empty.

    Root polynomial associated with a SubproductTree R: 1 on empty, X - C a on leaf a, and the stored polynomial p on node p l r.

    Ordered list of evaluation points stored at the leaves of a SubproductTree R.

    Node height of a SubproductTree R: 0 on empty, 1 on leaf a, and max l.depth r.depth + 1 on node p l r.

    Multiplicative consistency predicate on SubproductTree R: every internal node stores the exact product l.rootPoly * r.rootPoly of its left and right subtree root polynomials.

    noncomputable def Cslib.Algorithms.Lean.SubproductTree.map {R : Type u_1} {S : Type u_2} [CommRing R] [CommRing S] (f : R →+* S) :

    Pushforward of a SubproductTree R along a ring homomorphism f : R →+* S.

    @[simp]
    @[simp]
    theorem Cslib.Algorithms.Lean.SubproductTree.map_leaf {R : Type u_1} {S : Type u_2} [CommRing R] [CommRing S] (f : R →+* S) (a : R) :
    map f (leaf a) = leaf (f a)
    @[simp]
    theorem Cslib.Algorithms.Lean.SubproductTree.map_node {R : Type u_1} {S : Type u_2} [CommRing R] [CommRing S] (f : R →+* S) (p : Polynomial R) (l r : SubproductTree R) :
    map f (node p l r) = node (Polynomial.map f p) (map f l) (map f r)
    @[simp]
    theorem Cslib.Algorithms.Lean.SubproductTree.points_map {R : Type u_1} {S : Type u_2} [CommRing R] [CommRing S] (f : R →+* S) (t : SubproductTree R) :
    (map f t).points = List.map (⇑f) t.points
    @[simp]
    theorem Cslib.Algorithms.Lean.SubproductTree.depth_map {R : Type u_1} {S : Type u_2} [CommRing R] [CommRing S] (f : R →+* S) (t : SubproductTree R) :
    (map f t).depth = t.depth

    Every multiplicative subproduct tree over a commutative ring has a monic root polynomial.

    The root polynomial of any multiplicative subproduct tree equals the ordered product ∏_{a ∈ t.points} (X - C a).

    Over a nontrivial commutative ring, the root polynomial of any multiplicative subproduct tree has natDegree equal to t.points.length.

    Pushing a multiplicative subproduct tree forward along a ring homomorphism preserves multiplicativity.

    @[irreducible]

    Balanced binary divide-and-conquer construction of the subproduct tree over a point list pts : List R, splitting lists of length at least 2 at pts.length / 2.

    theorem Cslib.Algorithms.Lean.buildSubproductTree_of_two_le_length {R : Type u_1} [CommRing R] (pts : List R) (h : 2 ≤ pts.length) :
    buildSubproductTree pts = have m := pts.length / 2; have tl := buildSubproductTree (List.take m pts); have tr := buildSubproductTree (List.drop m pts); SubproductTree.node (tl.rootPoly * tr.rootPoly) tl tr

    Recursive split equation for buildSubproductTree on any list of length at least 2.

    @[simp]

    buildSubproductTree pts recovers the exact input point list pts in order.

    The root polynomial of buildSubproductTree pts is monic over any commutative ring R.

    The root polynomial of buildSubproductTree pts equals ∏_{a ∈ pts} (X - C a).

    Over any nontrivial commutative ring R, (buildSubproductTree pts).rootPoly has degree pts.length.

    buildSubproductTree commutes with every ring homomorphism f : R →+* S.

    Top-down monic remainder-tree evaluation of p : R[X] across a SubproductTree R.

    Pre-reducing p modulo t.rootPoly leaves remainderTreeEval t unchanged on any multiplicative subproduct tree.

    On any multiplicative subproduct tree t, top-down remainder-tree traversal computes the exact list of polynomial evaluations t.points.map p.eval over any commutative ring R.

    noncomputable def Cslib.Algorithms.Lean.fastMultipointEval {R : Type u_1} [CommRing R] (pts : List R) (p : Polynomial R) :

    Remainder-tree multipoint evaluation of p : R[X] at pts : List R via balanced subproduct tree construction followed by top-down monic remainder traversal (noncomputable; arithmetic costs unmodeled).

    @[simp]
    theorem Cslib.Algorithms.Lean.fastMultipointEval_eq_map_eval {R : Type u_1} [CommRing R] (pts : List R) (p : Polynomial R) :
    fastMultipointEval pts p = List.map (fun (x : R) => Polynomial.eval x p) pts

    fastMultipointEval pts p agrees identically with pts.map p.eval over every commutative ring R.

    theorem Cslib.Algorithms.Lean.map_fastMultipointEval {R : Type u_1} {S : Type u_2} [CommRing R] [CommRing S] (f : R →+* S) (pts : List R) (p : Polynomial R) :

    fastMultipointEval commutes with every ring homomorphism f : R →+* S.

    noncomputable def Cslib.Algorithms.Lean.fastBivariateDiffProd {R : Type u_1} [CommRing R] (sPts tPts : List R) :
    R

    Bivariate pairwise difference product ∏_{s ∈ sPts} ∏_{t ∈ tPts} (s - t) over a commutative ring R, computed by evaluating (buildSubproductTree tPts).rootPoly at sPts via fastMultipointEval and multiplying the resulting values (noncomputable; arithmetic costs unmodeled).

    @[simp]
    theorem Cslib.Algorithms.Lean.eval_rootPoly_buildSubproductTree {R : Type u_1} [CommRing R] (tPts : List R) (s : R) :
    Polynomial.eval s (buildSubproductTree tPts).rootPoly = (List.map (fun (t : R) => s - t) tPts).prod

    Evaluating (buildSubproductTree tPts).rootPoly at s : R yields ∏_{t ∈ tPts} (s - t).

    theorem Cslib.Algorithms.Lean.fastBivariateDiffProd_eq_prod {R : Type u_1} [CommRing R] (sPts tPts : List R) :
    fastBivariateDiffProd sPts tPts = (List.map (fun (s : R) => (List.map (fun (t : R) => s - t) tPts).prod) sPts).prod

    fastBivariateDiffProd sPts tPts equals the exact iterated product ∏_{s ∈ sPts} ∏_{t ∈ tPts} (s - t) over every commutative ring R.

    Multiplicativity of fastBivariateDiffProd in its left point list.

    Multiplicativity of fastBivariateDiffProd in its right point list.

    theorem Cslib.Algorithms.Lean.fastBivariateDiffProd_eq_zero_of_mem {R : Type u_1} [CommRing R] {sPts tPts : List R} {x : R} (hs : x ∈ sPts) (ht : x ∈ tPts) :

    Over any commutative ring R, a shared element x ∈ sPts and x ∈ tPts forces fastBivariateDiffProd sPts tPts = 0.

    theorem Cslib.Algorithms.Lean.fastBivariateDiffProd_eq_zero_iff {R : Type u_1} [CommRing R] [IsDomain R] (sPts tPts : List R) :
    fastBivariateDiffProd sPts tPts = 0 ↔ ∃ x ∈ sPts, x ∈ tPts

    Over an integral domain R, fastBivariateDiffProd sPts tPts = 0 if and only if sPts and tPts share a common element.

    The depth of buildSubproductTree pts is at most ⌈log₂ |pts|⌉ + 1.

    When pts.length = 2 ^ k, buildSubproductTree pts has exact depth k + 1, demonstrating sharpness of the + 1 term in depth_buildSubproductTree_le.

    Total degree weight of internal nodes across a SubproductTree R, summing l.points.length + r.points.length over all internal .nodes (node-weight sum only; arithmetic multiplication and division costs are unmodeled).

    Sharp bound on the total internal degree weight (buildSubproductTree pts).degSum: at most |pts| * ⌈log₂ |pts|⌉.

    When pts.length = 2 ^ k, the total internal degree weight (buildSubproductTree pts).degSum equals k * 2 ^ k identically, showing tightness of degSum_buildSubproductTree_le_mul_clog.