Documentation

HexPolyFast.Plan

theorem Hex.DensePoly.size_le_of_coeff_zero_above {R : Type u} [DecidableEq R] [Lean.Grind.CommRing R] {p : DensePoly R} {n : Nat} (hzero : ∀ (i : Nat), n ≤ i → p.coeff i = 0) :
p.size ≤ n

A polynomial whose coefficients vanish from n onward has size at most n.

Addition cannot increase size beyond the larger operand.

Subtraction cannot increase size beyond the larger operand.

A proof-carrying implementation of full, square, and clipped dense polynomial multiplication. slice lo len a b stores coefficients beginning at degree lo, shifted down to degree zero.

Instances For
    noncomputable def Hex.DensePoly.schoolbookSlice {R : Type u} [DecidableEq R] [Lean.Grind.CommRing R] (lo len : Nat) (a b : DensePoly R) :

    Kernel-facing clipped schoolbook product. The definition is phrased by the semantic product so its coefficient law is immediate; compiled code uses schoolbookSliceImpl, which evaluates the requested schoolbook coefficient folds directly and never materializes the full product.

    Equations
    Instances For
      theorem Hex.DensePoly.coeff_schoolbookSlice {R : Type u} [DecidableEq R] [Lean.Grind.CommRing R] (lo len : Nat) (a b : DensePoly R) (i : Nat) :
      (schoolbookSlice lo len a b).coeff i = if i < len then (a * b).coeff (lo + i) else 0

      Coefficient law for a clipped schoolbook product.

      Fold one product diagonal. The left operand is the loop driver; callers put the shorter operand there. Indices outside the valid convolution diagonal perform no coefficient operation.

      Equations
      Instances For

        The direct diagonal kernel agrees with the schoolbook product fold.

        Allocation-conscious runtime implementation of schoolbookSlice. Requests beyond the product support are discarded before entering the coefficient folds, and the shorter operand drives each diagonal fold.

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

          The bounded coefficient-fold implementation agrees with the semantic clipped product.

          @[csimp]

          Compiled clipped schoolbook products use direct coefficient folds.

          The reference plan backed by the existing allocation-conscious schoolbook multiplication.

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

            Multiply using an explicit plan.

            Equations
            Instances For
              @[inline]

              Square using an explicit plan.

              Equations
              Instances For
                @[inline]
                def Hex.DensePoly.mulLow {R : Type u} [DecidableEq R] [Lean.Grind.CommRing R] (plan : MulPlan R) (len : Nat) (a b : DensePoly R) :

                Keep the first len coefficients of a planned product.

                Equations
                Instances For
                  @[inline]
                  def Hex.DensePoly.mulSlice {R : Type u} [DecidableEq R] [Lean.Grind.CommRing R] (plan : MulPlan R) (lo len : Nat) (a b : DensePoly R) :

                  Keep len coefficients beginning at product degree lo.

                  Equations
                  Instances For
                    @[inline]
                    def Hex.DensePoly.mulMiddle {R : Type u} [DecidableEq R] [Lean.Grind.CommRing R] (plan : MulPlan R) (a b : DensePoly R) (_hsize : b.size ≤ a.size) (_hpos : 0 < b.size) :

                    The standard middle product for operands of sizes m ≥ n > 0. The result contains product degrees n - 1 through m - 1, shifted down.

                    Equations
                    Instances For

                      Checked middle product. Operands are ordered by size; an empty operand has zero middle product.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        theorem Hex.DensePoly.mulWith_eq {R : Type u} [DecidableEq R] [Lean.Grind.CommRing R] (plan : MulPlan R) (a b : DensePoly R) :
                        mulWith plan a b = a * b

                        Planned multiplication has the existing dense-polynomial semantics.

                        theorem Hex.DensePoly.squareWith_eq {R : Type u} [DecidableEq R] [Lean.Grind.CommRing R] (plan : MulPlan R) (a : DensePoly R) :
                        squareWith plan a = a * a

                        Planned squaring has the existing dense-polynomial semantics.

                        theorem Hex.DensePoly.coeff_mulLow {R : Type u} [DecidableEq R] [Lean.Grind.CommRing R] (plan : MulPlan R) (len i : Nat) (a b : DensePoly R) :
                        (mulLow plan len a b).coeff i = if i < len then (a * b).coeff i else 0

                        Coefficient law for a planned low product.

                        theorem Hex.DensePoly.coeff_mulSlice {R : Type u} [DecidableEq R] [Lean.Grind.CommRing R] (plan : MulPlan R) (lo len i : Nat) (a b : DensePoly R) :
                        (mulSlice plan lo len a b).coeff i = if i < len then (a * b).coeff (lo + i) else 0

                        Coefficient law for an arbitrary planned slice.

                        theorem Hex.DensePoly.coeff_mulMiddle {R : Type u} [DecidableEq R] [Lean.Grind.CommRing R] (plan : MulPlan R) (a b : DensePoly R) (hsize : b.size ≤ a.size) (hpos : 0 < b.size) (i : Nat) :
                        (mulMiddle plan a b hsize hpos).coeff i = if i < a.size - b.size + 1 then (a * b).coeff (b.size - 1 + i) else 0

                        Coefficient law for the standard proof-taking middle product.