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 #

@[reducible, inline]
abbrev CPoly.Unlawful (n : ) (R : Type u_1) :
Type u_1

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

Instances For
    @[instance_reducible]
    @[instance_reducible]
    instance CPoly.instSingletonMonoRUnlawful {n : } {R : Type u_1} :
    @[instance_reducible]
    instance CPoly.instInsertMonoRUnlawful {n : } {R : Type u_1} :
    Insert (MonoR n R) (Unlawful n R)
    @[instance_reducible]
    @[instance_reducible, instance 10000, defaultInstance 1000]
    instance CPoly.instGetElemUnlawfulCMvMonomialMem {n : } {R : Type u_1} :
    GetElem (Unlawful n R) (CMvMonomial n) R fun (lp : Unlawful n R) (m : CMvMonomial n) => m lp
    @[instance_reducible]
    instance CPoly.instGetElem?UnlawfulCMvMonomialMem {n : } {R : Type u_1} :
    GetElem? (Unlawful n R) (CMvMonomial n) R fun (lp : Unlawful n R) (m : CMvMonomial n) => m lp
    instance CPoly.instLawfulGetElemUnlawfulCMvMonomialMem {n : } {R : Type u_1} :
    LawfulGetElem (Unlawful n R) (CMvMonomial n) R fun (lp : Unlawful n R) (m : CMvMonomial n) => m lp
    theorem CPoly.Unlawful.ext_getElem? {n : } {R : Type u_1} {t₁ t₂ : Unlawful n R} (h : ∀ (k : CMvMonomial n), t₁[k]? = t₂[k]?) :
    t₁ = t₂
    theorem CPoly.Unlawful.ext_getElem?_iff {n : } {R : Type u_1} {t₁ t₂ : Unlawful n R} :
    t₁ = t₂ ∀ (k : CMvMonomial n), t₁[k]? = t₂[k]?
    def CPoly.Unlawful.ofList {n : } {R : Type u_1} (l : List (CMvMonomial n × R)) :

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

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

      Extend the number of variables by padding monomials with zeros.

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

        Check if the polynomial has no zero coefficients.

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

            The list of monomials present in the polynomial.

            Instances For
              @[simp]
              theorem CPoly.Unlawful.mem_monomials {n : } {R : Type u_1} {m : CMvMonomial n} {up : Unlawful n R} :
              m up.monomials m up
              @[instance_reducible]
              instance CPoly.Unlawful.instRepr {n : } {R : Type u_1} [Repr R] :
              def CPoly.Unlawful.C {n : } {R : Type u_1} [BEq R] [LawfulBEq R] [Zero R] (c : R) :

              Constant polynomial.

              Instances For
                @[instance_reducible]
                instance CPoly.Unlawful.instOfNatOfNatNat {n : } {R : Type u_1} [Zero R] [BEq R] [LawfulBEq R] :
                OfNat (Unlawful n R) 0
                @[instance_reducible]
                instance CPoly.Unlawful.instOfNatOfNatCastOfNeZeroNat {n : } {R : Type u_1} {m : } [Zero R] [BEq R] [LawfulBEq R] [NatCast R] [NeZero m] :
                OfNat (Unlawful n R) m
                @[simp]
                theorem CPoly.Unlawful.C_zero {n : } {R : Type u_1} [Zero R] [BEq R] [LawfulBEq R] :
                C 0 = 0
                @[simp]
                theorem CPoly.Unlawful.C_zero' {n : } :
                C 0 = 0
                @[simp]
                theorem CPoly.Unlawful.zero_eq_empty {n : } {R : Type u_1} [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 u_1} [Zero R] {x : CMvMonomial n} [BEq R] [LawfulBEq R] :
                x0
                @[simp]
                theorem CPoly.Unlawful.isNoZeroCoef_zero {n : } {R : Type u_1} [Zero R] [BEq R] [LawfulBEq R] :
                def CPoly.Unlawful.add {n : } {R : Type u_1} [Add R] (p₁ p₂ : Unlawful n R) :

                Pointwise addition of coefficients.

                Instances For
                  @[instance_reducible]
                  instance CPoly.Unlawful.instAdd {n : } {R : Type u_1} [Add R] :
                  theorem CPoly.Unlawful.grind_add_skip {n : } {R : Type u_1} [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 u_1} [Add R] (p : Unlawful n R) (term : MonoR n R) :

                  Add a single monomial-coefficient term to a polynomial.

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

                    Multiply a polynomial by a single monomial term.

                    Instances For
                      @[simp]
                      theorem CPoly.Unlawful.mul₀_zero {n : } {R : Type u_1} [Zero R] [BEq R] [LawfulBEq R] [Mul R] {t : MonoR n R} :
                      mul₀ t 0 = 0
                      def CPoly.Unlawful.mul {n : } {R : Type u_1} [Mul R] [Add R] [Zero R] [BEq R] [LawfulBEq R] (p₁ p₂ : Unlawful n R) :

                      Polynomial multiplication using a nested fold (distributive law).

                      Instances For
                        @[instance_reducible]
                        instance CPoly.Unlawful.instMulOfLawfulBEqOfAddOfZero {n : } {R : Type u_1} [BEq R] [LawfulBEq R] [Mul R] [Add R] [Zero R] :
                        def CPoly.Unlawful.neg {n : } {R : Type u_1} [Neg R] (p : Unlawful n R) :

                        Negation (negates all coefficients).

                        Instances For
                          @[instance_reducible]
                          instance CPoly.Unlawful.instNeg {n : } {R : Type u_1} [Neg R] :
                          def CPoly.Unlawful.sub {n : } {R : Type u_1} [Neg R] [Add R] (p₁ p₂ : Unlawful n R) :

                          Subtraction.

                          Instances For
                            @[instance_reducible]
                            instance CPoly.Unlawful.instSubOfAdd {n : } {R : Type u_1} [Neg R] [Add R] :
                            def CPoly.Unlawful.leadingTerm? {n : } {R : Type u_1} :
                            Unlawful n ROption (MonoR n R)

                            Return the term with the lexicographically largest monomial.

                            Instances For

                              Return the lexicographically largest monomial.

                              Instances For
                                @[instance_reducible]
                                def CPoly.Unlawful.coeff {R : Type u_2} {n : } [Zero R] (m : CMvMonomial n) (p : Unlawful n R) :
                                R
                                Instances For
                                  @[simp]
                                  theorem CPoly.Unlawful.filter_get {n : } {R : Type u_2} [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 u_1} [AddZeroClass R] {m : CMvMonomial n} {p q : Unlawful n R} :
                                  (p.add q)[m]?.getD 0 = p[m]?.getD 0 + q[m]?.getD 0