Documentation

CompPoly.Multivariate.Lawful

'Lawful' finite supports #

This file defines the Lawful subtype, which consists of Unlawful polynomials where all stored coefficients are guaranteed to be non-zero. This provides a canonical representation (similar to Finsupp) and is the primary representation used for computable multivariate polynomials.

Main definitions #

def CPoly.Lawful (n : ) (R : Type) [Zero R] :

The subtype of polynomials with no zero coefficients.

Equations
Instances For
    instance CPoly.instEmptyCol {n : } {R : Type} [Zero R] :
    Equations
    instance CPoly.instGetElemLawfulCMvMonomialMemUnlawfulValIsNoZeroCoef {n : } {R : Type} [Zero R] :
    GetElem (Lawful n R) (CMvMonomial n) R fun (lp : Lawful n R) (m : CMvMonomial n) => m lp
    Equations
    instance CPoly.instGetElem?LawfulCMvMonomialMemUnlawfulValIsNoZeroCoef {n : } {R : Type} [Zero R] :
    GetElem? (Lawful n R) (CMvMonomial n) R fun (lp : Lawful n R) (m : CMvMonomial n) => m lp
    Equations
    • One or more equations did not get rendered due to their size.
    instance CPoly.instLawfulGetElemLawfulCMvMonomialMem {n : } {R : Type} [Zero R] :
    LawfulGetElem (Lawful n R) (CMvMonomial n) R fun (lp : Lawful n R) (m : CMvMonomial n) => m lp
    @[simp]
    theorem CPoly.Lawful.getElem?_eq_val_getElem? {n : } {R : Type} [Zero R] {p : Lawful n R} {m : CMvMonomial n} :
    p[m]? = (↑p)[m]?
    @[simp]
    theorem CPoly.Lawful.mem_iff_cast {n : } {R : Type} [Zero R] {p : Lawful n R} {x : CMvMonomial n} :
    x p x p
    theorem CPoly.Lawful.mem_iff {n : } {R : Type} [Zero R] {p : Lawful n R} {x : CMvMonomial n} :
    x p ∃ (v : R), v 0 p[x]? = some v
    @[simp]
    theorem CPoly.Lawful.getElem?_ne_some_zero {n : } {R : Type} [Zero R] {p : Lawful n R} {m : CMvMonomial n} :
    theorem CPoly.Lawful.getD_getElem?_ne_zero_of_mem {n : } {R : Type} [Zero R] {p : Lawful n R} {m : CMvMonomial n} (h : m p) :
    p[m]?.getD 0 0
    @[simp]
    theorem CPoly.Lawful.getElem_eq_getElem {n : } {R : Type} [Zero R] {p : Lawful n R} {m : CMvMonomial n} (h : m p) :
    p[m] = (↑p)[m]
    def CPoly.Lawful.fromUnlawful {n : } {R : Type} [Zero R] [BEq R] [LawfulBEq R] (p : Unlawful n R) :
    Lawful n R

    Convert an Unlawful polynomial to a Lawful one by filtering out zero coefficients.

    Equations
    Instances For
      theorem CPoly.Lawful.grind_fromUnlawful_congr {n : } {R : Type} [Zero R] [BEq R] [LawfulBEq R] {p₁ p₂ : Unlawful n R} (h : p₁ = p₂) :
      def CPoly.Lawful.C {n : } {R : Type} [Zero R] [BEq R] [LawfulBEq R] (c : R) :
      Lawful n R

      Construct a constant polynomial.

      Equations
      Instances For
        theorem CPoly.Lawful.zero_def {n : } {R : Type} [Zero R] [BEq R] [LawfulBEq R] :
        instance CPoly.Lawful.instOfNat {n : } {R : Type} [Zero R] [BEq R] [LawfulBEq R] {m : } [NeZero m] [NatCast R] :
        OfNat (Lawful n R) m
        Equations
        @[simp]
        theorem CPoly.Lawful.C_zero {n : } {R : Type} [Zero R] [BEq R] [LawfulBEq R] :
        C 0 = 0
        @[simp]
        theorem CPoly.Lawful.C_zero' {n : } :
        C 0 = 0
        theorem CPoly.Lawful.zero_eq_zero {n : } {R : Type} [Zero R] [BEq R] [LawfulBEq R] :
        0 = 0,
        theorem CPoly.Lawful.zero_eq_empty {n : } {R : Type} [Zero R] [BEq R] [LawfulBEq R] :
        0 =
        @[simp]
        theorem CPoly.Lawful.not_mem_C_zero {n : } {x : CMvMonomial n} :
        xC 0
        @[simp]
        theorem CPoly.Lawful.not_mem_zero {n : } {R : Type} [Zero R] {x : CMvMonomial n} [BEq R] [LawfulBEq R] :
        x0
        @[simp]
        theorem CPoly.Lawful.cast_fromUnlawful {n : } {R : Type} [Zero R] {p : Lawful n R} [BEq R] [LawfulBEq R] :
        (fromUnlawful p) = p
        def CPoly.Lawful.extend {n : } {R : Type} [Zero R] [BEq R] [LawfulBEq R] (n' : ) (p : Lawful n R) :
        Lawful (max n n') R

        Extend the number of variables in a polynomial.

        Equations
        Instances For
          def CPoly.Lawful.add {n : } {R : Type} [Zero R] [BEq R] [LawfulBEq R] [Add R] (p₁ p₂ : Lawful n R) :
          Lawful n R

          Addition of polynomials (results in a lawful polynomial).

          Equations
          Instances For
            instance CPoly.Lawful.instAdd {n : } {R : Type} [Zero R] [BEq R] [LawfulBEq R] [Add R] :
            Add (Lawful n R)
            Equations
            theorem CPoly.Lawful.grind_add_skip {n : } {R : Type} [Zero R] [BEq R] [LawfulBEq R] [Add R] {p₁ p₂ : Lawful n R} :
            p₁ + p₂ = fromUnlawful ((↑p₁).add p₂)
            theorem CPoly.Lawful.grind_add_skip_aggressive {n : } {R : Type} [Zero R] [BEq R] [LawfulBEq R] [Add R] {p₁ p₂ : Lawful n R} :
            p₁ + p₂ = fromUnlawful (Std.ExtTreeMap.mergeWith (fun (x : CMvMonomial n) (c₁ c₂ : R) => c₁ + c₂) p₁ p₂)

            Note to self: This goes too far.

            def CPoly.Lawful.mul {n : } {R : Type} [Zero R] [BEq R] [LawfulBEq R] [Mul R] [Add R] (p₁ p₂ : Lawful n R) :
            Lawful n R

            Multiplication of polynomials (results in a lawful polynomial).

            Equations
            Instances For
              instance CPoly.Lawful.instMulOfAdd {n : } {R : Type} [BEq R] [LawfulBEq R] [Mul R] [Add R] [Zero R] :
              Mul (Lawful n R)
              Equations
              def CPoly.Lawful.npow {n : } {R : Type} [Zero R] [BEq R] [LawfulBEq R] [NatCast R] [Add R] [Mul R] :
              Lawful n RLawful n R

              Polynomial exponentiation.

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

                The list of monomials in a polynomial.

                Equations
                Instances For
                  def CPoly.Lawful.NZConst {n : } {R : Type} [Zero R] (p : Lawful n R) :

                  Check if a polynomial is a non-zero constant.

                  Equations
                  Instances For
                    @[simp]
                    theorem CPoly.Lawful.mem_monomials_iff {n : } {R : Type} [Zero R] {p : Lawful n R} {w : CMvMonomial n} :
                    @[simp]
                    theorem CPoly.Lawful.fromUnlawful_cast {n : } {R : Type} [Zero R] [BEq R] [LawfulBEq R] {p : Lawful n R} :
                    def CPoly.Lawful.neg {n : } {R : Type} [Zero R] [BEq R] [LawfulBEq R] [Neg R] (p : Lawful n R) :
                    Lawful n R

                    Negation of a polynomial.

                    Equations
                    Instances For
                      instance CPoly.Lawful.instNeg {n : } {R : Type} [Zero R] [BEq R] [LawfulBEq R] [Neg R] :
                      Neg (Lawful n R)
                      Equations
                      def CPoly.Lawful.sub {n : } {R : Type} [Zero R] [BEq R] [LawfulBEq R] [Add R] [Neg R] (p₁ p₂ : Lawful n R) :
                      Lawful n R

                      Subtraction of polynomials.

                      Equations
                      Instances For
                        Equations
                        def CPoly.Lawful.X (i : ) :
                        Lawful (i + 1)

                        The $i$-th variable as a polynomial.

                        Equations
                        Instances For
                          def CPoly.Lawful.align {R : Type} [Zero R] [BEq R] [LawfulBEq R] {n₁ n₂ : } (p₁ : Lawful n₁ R) (p₂ : Lawful n₂ R) :
                          Lawful (max n₁ n₂) R × Lawful (max n₁ n₂) R

                          Align two polynomials by extending them to have the same number of variables.

                          Equations
                          Instances For
                            def CPoly.Lawful.liftPoly {R : Type} [Zero R] [BEq R] [LawfulBEq R] {n₁ n₂ : } (f : Lawful (max n₁ n₂) RLawful (max n₁ n₂) RLawful (max n₁ n₂) R) (p₁ : Lawful n₁ R) (p₂ : Lawful n₂ R) :
                            Lawful (max n₁ n₂) R

                            Lift a binary polynomial operation to handle polynomials with different numbers of variables.

                            Equations
                            Instances For
                              def CPoly.Lawful.polyCoe {n : } {R : Type} [Zero R] [BEq R] [LawfulBEq R] (p : Lawful n R) :
                              Lawful (n + 1) R
                              Equations
                              Instances For
                                @[instance 100]
                                instance CPoly.Lawful.instHAddMaxNatOfAdd {R : Type} [Zero R] [BEq R] [LawfulBEq R] {n₁ n₂ : } [Add R] :
                                HAdd (Lawful n₁ R) (Lawful n₂ R) (Lawful (max n₁ n₂) R)
                                Equations
                                @[instance 100]
                                instance CPoly.Lawful.instHSubMaxNatOfAddOfNeg {R : Type} [Zero R] [BEq R] [LawfulBEq R] {n₁ n₂ : } [Add R] [Neg R] :
                                HSub (Lawful n₁ R) (Lawful n₂ R) (Lawful (max n₁ n₂) R)
                                Equations
                                • One or more equations did not get rendered due to their size.
                                @[instance 100]
                                instance CPoly.Lawful.instHMulMaxNatOfAddOfMul {R : Type} [Zero R] [BEq R] [LawfulBEq R] {n₁ n₂ : } [Add R] [Mul R] :
                                HMul (Lawful n₁ R) (Lawful n₂ R) (Lawful (max n₁ n₂) R)
                                Equations
                                • One or more equations did not get rendered due to their size.