Documentation

HexSparsePoly.Euclid

def Hex.SparsePoly.divModMonic {R : Type u} [Zero R] [DecidableEq R] [One R] [Add R] [Sub R] [Mul R] (s t : SparsePoly R) (ht : t.Monic) :

Divide by a monic divisor, through the dense representation: two toDense and two ofDense conversions around DensePoly.divModMonic.

Equations
Instances For
    def Hex.SparsePoly.divMod {R : Type u} [Zero R] [DecidableEq R] [One R] [Add R] [Sub R] [Mul R] [Div R] (s t : SparsePoly R) :

    Field-style division with remainder, through the dense representation.

    Equations
    Instances For
      def Hex.SparsePoly.gcd {R : Type u} [Zero R] [DecidableEq R] [One R] [Add R] [Sub R] [Mul R] [Div R] (s t : SparsePoly R) :

      Euclidean gcd, through the dense representation: the dense cost at the degree, whatever the term count. A caller with a two-term input of degree 10^6 should expect this to cost what a dense gcd at degree 10^6 costs.

      Equations
      Instances For
        def Hex.SparsePoly.divExactMonic? {R : Type u} [Zero R] [DecidableEq R] [One R] [Add R] [Sub R] [Mul R] (s t : SparsePoly R) (ht : t.Monic) :

        Exact division by a monic divisor: divModMonic with a zero-remainder test.

        Equations
        Instances For
          @[instance_reducible]
          instance Hex.SparsePoly.instDivOfOneOfAddOfSubOfMul {R : Type u} [Zero R] [DecidableEq R] [One R] [Add R] [Sub R] [Mul R] [Div R] :
          Equations
          @[instance_reducible]
          Equations

          Divide by the monomial x^e, the one division that stays sparse: none unless every stored exponent is at least e, and otherwise a subtraction on each exponent, O(s) with no filtering.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            Multiplying back by the monomial undoes divMonomial?.

            Divisibility transports back from the dense representation.

            Divisibility transports to the dense representation.

            The degree transports through ofDense.

            The quotient and remainder reconstruct the dividend, transported from DensePoly.DivModLaws.

            The remainder degree drops below a positive divisor degree, transported from DensePoly.DivModLaws.

            The monic division satisfies the division identity. It carries [Div S] and [DivModLaws S] even though divModMonic does not, and that is not an oversight: the dense layer proves the monic identity by routing through divMod, so there is no unconditional dense statement to transport.

            Exact monic division returns exactly the cofactors: the forward direction is the division identity with a zero remainder, the reverse is dense monic cancellation applied to the two reconstructions.

            Exact monic division succeeds exactly on multiples. A monic divisor is nonzero, so no t ≠ 0 side condition is needed.

            The gcd divides the left argument, transported from DensePoly.GcdLaws.

            The gcd divides the right argument.

            theorem Hex.SparsePoly.dvd_gcd {S : Type u} [Lean.Grind.CommRing S] [DecidableEq S] [Div S] [DensePoly.GcdLaws S] {d s t : SparsePoly S} (hs : d s) (ht : d t) :
            d s.gcd t

            Common divisors divide the gcd.