Documentation

CompPoly.Bivariate.ToPoly

Equivalence with Mathlib Bivariate Polynomials #

This file establishes the conversion from CBivariate R to Mathlib's R[X][Y] (Polynomial (Polynomial R)).

Main definitions:

Main results:

Core conversion lemmas between CBivariate R and R[X][Y].

noncomputable def CompPoly.CBivariate.toPoly {R : Type u_1} [BEq R] [LawfulBEq R] [Semiring R] (p : CBivariate R) :

Convert CBivariate R to Mathlib's bivariate polynomial R[X][Y].

Maps each Y-coefficient through CPolynomial.toPoly, then builds Polynomial (Polynomial R) as the sum of monomials.

Instances For

    Convert Mathlib's R[X][Y] to CBivariate R (inverse of toPoly).

    Extracts each Y-coefficient via p.coeff, converts to CPolynomial R via toImpl and trimming, then builds the canonical bivariate sum.

    Instances For
      theorem CompPoly.CBivariate.toPoly_add {R : Type u_1} [BEq R] [LawfulBEq R] [Nontrivial R] [Semiring R] (p q : CBivariate R) :
      (p + q).toPoly = p.toPoly + q.toPoly

      toPoly preserves addition.

      toPoly sends a Y-monomial to the corresponding monomial in R[X][Y].

      ofPoly sends a Y-monomial in R[X][Y] to a bivariate monomial.

      theorem CompPoly.CBivariate.toImpl_add {R : Type u_1} [BEq R] [LawfulBEq R] [Semiring R] (p q : Polynomial R) :
      p.toImpl + q.toImpl = (p + q).toImpl

      Polynomial.toImpl preserves addition, accounting for trimming in the raw representation.

      ofPoly preserves addition in R[X][Y].

      The outer coefficient of ofPoly p converts back to the corresponding R[X] coefficient.

      The outer coefficient of toPoly p is CPolynomial.coeff p n converted to R[X].

      toPoly is the map of the outer polynomial via CPolynomial.ringEquiv.

      theorem CompPoly.CBivariate.toPoly_mul {R : Type u_1} [BEq R] [LawfulBEq R] [Nontrivial R] [Semiring R] (p q : CBivariate R) :
      (p * q).toPoly = p.toPoly * q.toPoly

      toPoly preserves multiplication.

      Ring equivalence between bivariate representations.

      Round-trip from Mathlib: converting a polynomial to CBivariate and back is the identity.

      Round-trip from CBivariate: converting to Mathlib and back is the identity.

      Ring equivalence between CBivariate R and Mathlib's R[X][Y].

      Instances For

        toPoly preserves 1.

        ofPoly preserves 1.

        toPoly maps the zero bivariate polynomial to 0.

        ofPoly maps 0 in R[X][Y] to the zero bivariate polynomial.

        Ring hom from computable bivariates to Mathlib bivariates.

        Instances For

          Ring hom from Mathlib bivariates to computable bivariates.

          Instances For

            ofPoly preserves multiplication.

            Shared helper: deferred-trim Horner foldr commutes with toPoly #

            evalY and (transitively) evalEval fold the Y-coefficients of f : CBivariate R with a raw Horner pattern (smulRight a then addRaw) and trim once at the end. The helper below bridges that raw fold's toPoly image with the Finset.sum form of the polynomial evaluation.

            Correctness lemmas for evaluation, coefficients, support, and degrees.

            evalY a corresponds to outer evaluation at Polynomial.C a.

            Horner evaluation in Y agrees with the deferred-trim sum-of-powers evaluator.

            Both evalYHorner and the new evalY reduce to the same Polynomial under toPoly, and toPoly is injective on canonical polynomials, so the two canonical results coincide.

            Y-then-X Horner full evaluation agrees with the existing evaluator.

            toPoly preserves full evaluation: evalEval x y f = (toPoly f).evalEval x y.

            theorem CompPoly.CBivariate.coeff_toPoly {R : Type u_1} [BEq R] [LawfulBEq R] [Nontrivial R] [Semiring R] (f : CBivariate R) (i j : ) :
            (f.toPoly.coeff j).coeff i = f.coeff i j

            toPoly preserves coefficients: coefficient of X^i Y^j matches.

            The outer support of toPoly f equals the Y-support of f.

            theorem CompPoly.CBivariate.coeff_toPoly_Y {R : Type u_1} [BEq R] [LawfulBEq R] [Nontrivial R] [Semiring R] (f : CBivariate R) (j : ) :
            f.toPoly.coeff j = ((↑f).coeff j).toPoly

            The outer Y-coefficient formula used for X-degree transport.

            toPoly preserves X-degree (max over Y-coefficients of their degree in X).

            CC corresponds to the nested constant polynomial in R[X][Y].

            X (inner variable) corresponds to Polynomial.C Polynomial.X in R[X][Y].

            Y (outer variable) corresponds to Polynomial.X in R[X][Y].

            monomialXY n m c corresponds to Y^m with inner coefficient X^n * c.

            supportX corresponds to the union of inner supports of outer coefficients.

            totalDegree corresponds to the supremum over j of natDegree ((toPoly f).coeff j) + j.

            evalX a evaluates each inner coefficient at a.

            evalX is compatible with full bivariate evaluation when a and y commute.

            evalX_toPoly_eval_commute specialized to commutative rings.

            X-then-Y Horner full evaluation agrees with the existing evaluator over commutative coefficient semirings.

            The Commute hypothesis in evalX_toPoly_eval_commute is necessary: if the identity holds for every bivariate polynomial then a and y commute.

            Computable analogue of Polynomial.Bivariate.eval_comm: evaluating Y at a and then X at x agrees with first applying the X = x evaluation through the inner coefficients and then evaluating Y at a.

            leadingCoeffY corresponds to the leading coefficient in the outer variable.

            swap exchanges X- and Y-exponents.

            leadingCoeffX is the Y-leading coefficient of the swapped polynomial.