Documentation

CompPoly.Multivariate.CMvPolynomial

Computable multivariate polynomials #

Polynomials of the form α₁ * m₁ + α₂ * m₂ + ... + αₖ * mₖ where αᵢ is any semiring and mᵢ is a CMvMonomial.

This is implemented as a wrapper around CPoly.Lawful, which ensures that all stored coefficients are non-zero.

This file contains the core type definition and basic operations. Higher-level definitions that depend on ring instances (monomial orders, rename, aeval, etc.) are in CMvPolynomial.lean. The CommSemiring and CommRing instances are in MvPolyEquiv.lean.

Main definitions #

@[reducible, inline]
abbrev CPoly.CMvPolynomial (n : ) (R : Type) [Zero R] :

A computable multivariate polynomial in n variables with coefficients in R.

Equations
Instances For
    def CPoly.CMvPolynomial.C {n : } {R : Type} [BEq R] [LawfulBEq R] [Zero R] (c : R) :

    Construct a constant polynomial.

    Equations
    Instances For
      def CPoly.CMvPolynomial.X {n : } {R : Type} [Zero R] [One R] [BEq R] [LawfulBEq R] (i : Fin n) :

      Construct the polynomial $X_i$.

      Equations
      Instances For
        def CPoly.CMvPolynomial.coeff {R : Type} {n : } [Zero R] (m : CMvMonomial n) (p : CMvPolynomial n R) :
        R

        Extract the coefficient of a monomial.

        Equations
        Instances For
          theorem CPoly.CMvPolynomial.ext {R : Type} {n : } [Zero R] (p q : CMvPolynomial n R) (h : ∀ (m : CMvMonomial n), coeff m p = coeff m q) :
          p = q

          Extensionality: two polynomials are equal if all their coefficients are equal.

          theorem CPoly.CMvPolynomial.ext_iff {R : Type} {n : } [Zero R] {p q : CMvPolynomial n R} :
          p = q ∀ (m : CMvMonomial n), coeff m p = coeff m q
          @[simp]
          theorem CPoly.CMvPolynomial.add_getD? {R : Type} [BEq R] [LawfulBEq R] {n : } [CommSemiring R] {m : CMvMonomial n} {p q : CMvPolynomial n R} :
          (↑(p + q))[m]?.getD 0 = (↑p)[m]?.getD 0 + (↑q)[m]?.getD 0
          @[simp]
          theorem CPoly.CMvPolynomial.coeff_add {R : Type} [BEq R] [LawfulBEq R] {n : } [CommSemiring R] {m : CMvMonomial n} {p q : CMvPolynomial n R} :
          coeff m (p + q) = coeff m p + coeff m q
          theorem CPoly.CMvPolynomial.fromUnlawful_fold_eq_fold_fromUnlawful₀ {R : Type} [BEq R] [LawfulBEq R] {n : } [CommSemiring R] {t : List (CMvMonomial n × R)} {f : CMvMonomial nRUnlawful n R} (init : Unlawful n R) :
          Lawful.fromUnlawful (List.foldl (fun (u : Unlawful n R) (term : CMvMonomial n × R) => f term.1 term.2 + u) init t) = List.foldl (fun (l : Lawful n R) (term : CMvMonomial n × R) => Lawful.fromUnlawful (f term.1 term.2) + l) (Lawful.fromUnlawful init) t

          Auxiliary lemma showing that conversion from unlawful polynomials respects the sum fold.

          theorem CPoly.CMvPolynomial.fromUnlawful_fold_eq_fold_fromUnlawful {R : Type} [BEq R] [LawfulBEq R] {n : } [CommSemiring R] {t : Unlawful n R} {f : CMvMonomial nRUnlawful n R} :
          Lawful.fromUnlawful (Std.ExtTreeMap.foldl (fun (u : Unlawful n R) (m : CMvMonomial n) (c : R) => f m c + u) 0 t) = Std.ExtTreeMap.foldl (fun (l : Lawful n R) (m : CMvMonomial n) (c : R) => Lawful.fromUnlawful (f m c) + l) 0 t

          Auxiliary lemma showing that conversion from unlawful polynomials respects the fold over terms.

          def CPoly.CMvPolynomial.eval₂ {R S : Type} {n : } [Semiring R] [CommSemiring S] :
          (R →+* S) → (Fin nS)CMvPolynomial n RS

          Evaluate a polynomial at a point given by a ring homomorphism f and variable assignments vs.

          Equations
          Instances For
            def CPoly.CMvPolynomial.eval {R : Type} {n : } [CommSemiring R] :
            (Fin nR)CMvPolynomial n RR

            Evaluate a polynomial at a given point.

            Equations
            Instances For

              The support of a polynomial (set of monomials with non-zero coefficients), represented as Finsupps.

              Equations
              Instances For

                The total degree of a polynomial (maximum total degree of its monomials).

                Equations
                Instances For
                  def CPoly.CMvPolynomial.degreeOf {R : Type} {n : } [Zero R] (i : Fin n) :

                  The degree of a polynomial in a specific variable.

                  Equations
                  Instances For
                    def CPoly.CMvPolynomial.monomial {n : } {R : Type} [BEq R] [LawfulBEq R] [Zero R] (m : CMvMonomial n) (c : R) :

                    Construct a monomial c * m as a CMvPolynomial n R.

                    Creates a polynomial with a single monomial term. If c = 0, returns the zero polynomial.

                    Equations
                    Instances For

                      Multiset of all variable degrees appearing in the polynomial.

                      Each variable i appears degreeOf i p times in the multiset.

                      Equations
                      Instances For

                        degreeOf is the multiplicity of a variable in degrees.

                        def CPoly.CMvPolynomial.vars {n : } {R : Type} [Zero R] (p : CMvPolynomial n R) :

                        Extract the set of variables that appear in a polynomial.

                        Returns the set of variable indices i : Fin n such that degreeOf i p > 0.

                        Equations
                        Instances For
                          def CPoly.CMvPolynomial.restrictBy {n : } {R : Type} [BEq R] [LawfulBEq R] [Zero R] (keep : CMvMonomial nProp) [DecidablePred keep] (p : CMvPolynomial n R) :

                          Filter a polynomial, keeping only monomials for which keep m is true.

                          Equations
                          Instances For

                            Restrict polynomial to monomials with total degree ≤ d.

                            Filters out all monomials where m.totalDegree > d.

                            Equations
                            Instances For

                              Restrict polynomial to monomials whose degree in each variable is ≤ d.

                              Filters out all monomials where m.degreeOf i > d for some variable i.

                              Equations
                              Instances For