Documentation

CompPoly.Multivariate.Unlawful

Unlawful multivariate polynomials #

This file defines the Unlawful type, which represents multivariate polynomials as a map from monomials to coefficients. Unlike Lawful, it does not enforce the absence of zero coefficients.

Main definitions #

def CPoly.Unlawful (n : ) (R : Type) :

Polynomial in n variables with coefficients in R. Internally represented as a tree map from monomials to coefficients.

Equations
Instances For
    @[instance 10000, defaultInstance 1000]
    instance CPoly.instGetElemUnlawfulCMvMonomialMem {n : } {R : Type} :
    GetElem (Unlawful n R) (CMvMonomial n) R fun (lp : Unlawful n R) (m : CMvMonomial n) => m lp
    Equations
    • One or more equations did not get rendered due to their size.
    instance CPoly.instGetElem?UnlawfulCMvMonomialMem {n : } {R : Type} :
    GetElem? (Unlawful n R) (CMvMonomial n) R fun (lp : Unlawful n R) (m : CMvMonomial n) => m lp
    Equations
    • One or more equations did not get rendered due to their size.
    theorem CPoly.Unlawful.ext_getElem? {n : } {R : Type} {t₁ t₂ : Unlawful n R} (h : ∀ (k : CMvMonomial n), t₁[k]? = t₂[k]?) :
    t₁ = t₂
    theorem CPoly.Unlawful.ext_getElem?_iff {n : } {R : Type} {t₁ t₂ : Unlawful n R} :
    t₁ = t₂ ∀ (k : CMvMonomial n), t₁[k]? = t₂[k]?
    def CPoly.Unlawful.ofList {n : } {R : Type} (l : List (CMvMonomial n × R)) :

    Construct an Unlawful polynomial from a list of monomial-coefficient pairs.

    Equations
    Instances For
      def CPoly.Unlawful.extend {n : } {R : Type} (n' : ) (p : Unlawful n R) :
      Unlawful (max n n') R

      Extend the number of variables by padding monomials with zeros.

      Equations
      Instances For
        @[reducible, inline]
        abbrev CPoly.Unlawful.isNoZeroCoef {n : } {R : Type} [Zero R] (p : Unlawful n R) :

        Check if the polynomial has no zero coefficients.

        Equations
        Instances For
          Equations
          Instances For
            @[reducible, inline]
            abbrev CPoly.Unlawful.monomials {n : } {R : Type} (p : Unlawful n R) :

            The list of monomials present in the polynomial.

            Equations
            Instances For
              @[simp]
              theorem CPoly.Unlawful.mem_monomials {n : } {R : Type} {m : CMvMonomial n} {up : Unlawful n R} :
              m up.monomials m up
              instance CPoly.Unlawful.instRepr {n : } {R : Type} [Repr R] :
              Equations
              • One or more equations did not get rendered due to their size.
              def CPoly.Unlawful.C {n : } {R : Type} [BEq R] [LawfulBEq R] [Zero R] (c : R) :

              Constant polynomial.

              Equations
              Instances For
                @[simp]
                theorem CPoly.Unlawful.C_zero {n : } {R : Type} [Zero R] [BEq R] [LawfulBEq R] :
                C 0 = 0
                @[simp]
                theorem CPoly.Unlawful.C_zero' {n : } :
                C 0 = 0
                theorem CPoly.Unlawful.zero_eq_empty {n : } {R : Type} [Zero R] [BEq R] [LawfulBEq R] :
                0 =
                @[simp]
                theorem CPoly.Unlawful.not_mem_C_zero {n : } {x : CMvMonomial n} :
                xC 0
                @[simp]
                theorem CPoly.Unlawful.not_mem_zero {n : } {R : Type} [Zero R] {x : CMvMonomial n} [BEq R] [LawfulBEq R] :
                x0
                @[simp]
                def CPoly.Unlawful.add {n : } {R : Type} [Add R] (p₁ p₂ : Unlawful n R) :

                Pointwise addition of coefficients.

                Equations
                Instances For
                  theorem CPoly.Unlawful.grind_add_skip {n : } {R : Type} [Add R] {p₁ p₂ : Unlawful n R} :
                  p₁ + p₂ = Std.ExtTreeMap.mergeWith (fun (x : CMvMonomial n) (c₁ c₂ : R) => c₁ + c₂) p₁ p₂
                  def CPoly.Unlawful.addMonoR {n : } {R : Type} [Add R] (p : Unlawful n R) (term : MonoR n R) :

                  Add a single monomial-coefficient term to a polynomial.

                  Equations
                  Instances For
                    def CPoly.Unlawful.mul₀ {n : } {R : Type} [Mul R] (t : MonoR n R) (p : Unlawful n R) :

                    Multiply a polynomial by a single monomial term.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      @[simp]
                      theorem CPoly.Unlawful.mul₀_zero {n : } {R : Type} [Zero R] [BEq R] [LawfulBEq R] [Mul R] {t : MonoR n R} :
                      mul₀ t 0 = 0
                      def CPoly.Unlawful.mul {n : } {R : Type} [Mul R] [Add R] [Zero R] [BEq R] [LawfulBEq R] (p₁ p₂ : Unlawful n R) :

                      Polynomial multiplication using a nested fold (distributive law).

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        def CPoly.Unlawful.neg {n : } {R : Type} [Neg R] (p : Unlawful n R) :

                        Negation (negates all coefficients).

                        Equations
                        Instances For
                          def CPoly.Unlawful.sub {n : } {R : Type} [Neg R] [Add R] (p₁ p₂ : Unlawful n R) :

                          Subtraction.

                          Equations
                          Instances For
                            def CPoly.Unlawful.leadingTerm? {n : } {R : Type} :
                            Unlawful n ROption (MonoR n R)

                            Return the term with the lexicographically largest monomial.

                            Equations
                            Instances For

                              Return the lexicographically largest monomial.

                              Equations
                              Instances For
                                def CPoly.Unlawful.coeff {R : Type} {n : } [Zero R] (m : CMvMonomial n) (p : Unlawful n R) :
                                R
                                Equations
                                Instances For
                                  @[simp]
                                  theorem CPoly.Unlawful.filter_get {n : } {R : Type} [BEq R] [LawfulBEq R] {v : R} {m : CMvMonomial n} (a : Unlawful n R) :
                                  (Std.ExtTreeMap.filter (fun (x : CMvMonomial n) (c : R) => c != v) a)[m]?.getD v = a[m]?.getD v
                                  theorem CPoly.Unlawful.add_getD? {n : } {R : Type} [CommSemiring R] {m : CMvMonomial n} {p q : Unlawful n R} :
                                  (p.add q)[m]?.getD 0 = p[m]?.getD 0 + q[m]?.getD 0