Documentation

CompPoly.Univariate.NTT.Forward

Forward NTT #

This file provides spec-level forward NTT definitions together with an iterative radix-2 implementation.

@[inline]
def CompPoly.CPolynomial.NTT.Forward.nttAt {R : Type u_1} [Field R] (D : Domain R) (a : Array R) (k : D.Idx) :
R

DFT/NTT formula at one output index.

Instances For
    @[inline]

    Full forward transform specified directly from the NTT formula.

    Instances For
      def CompPoly.CPolynomial.NTT.Forward.forwardStageSpec {R : Type u_1} [Field R] (D : Domain R) (completed : ) (a : Array R) :

      Proof-oriented stagewise specification for the forward transform.

      forwardStageSpec D completed a means: start from the bit-reversed input a, then apply exactly the first completed radix-2 butterfly stages.

      Instances For
        def CompPoly.CPolynomial.NTT.Forward.forwardStagePureSpec {R : Type u_1} [Field R] (D : Domain R) (completed : ) (a : Array R) :

        Stagewise pure specification built from butterflyStageSpec.

        This removes the mutable-array implementation details but still mirrors the radix-2 control flow exactly.

        Instances For
          def CompPoly.CPolynomial.NTT.Forward.forwardMathStageSpec {R : Type u_1} [Field R] (D : Domain R) (completed : ) (a : Array R) :

          Mathematical partial-DFT state after completed radix-2 stages.

          Each contiguous block of size 2^completed has already been transformed, while the remaining D.logN - completed bits are still encoded by bit-reversed block selection.

          Instances For
            @[simp]
            theorem CompPoly.CPolynomial.NTT.Forward.forwardStageSpec_succ {R : Type u_1} [Field R] (D : Domain R) (stage : ) (a : Array R) :
            @[simp]
            theorem CompPoly.CPolynomial.NTT.Forward.size_forwardStageSpec {R : Type u_1} [Field R] (D : Domain R) (completed : ) (a : Array R) :
            (forwardStageSpec D completed a).size = D.n
            @[simp]
            theorem CompPoly.CPolynomial.NTT.Forward.size_forwardStagePureSpec {R : Type u_1} [Field R] (D : Domain R) (completed : ) (a : Array R) :
            (forwardStagePureSpec D completed a).size = D.n
            theorem CompPoly.CPolynomial.NTT.Forward.forwardStageSpec_eq_forwardStagePureSpec {R : Type u_1} [Field R] (D : Domain R) (a : Array R) (completed : ) :
            forwardStageSpec D completed a = forwardStagePureSpec D completed a

            The algorithmic stage recursion agrees with the pure stage recursion.

            This is the global bookkeeping bridge from the recursive algorithmic stages to their pointwise closed-form counterparts.

            Base case of the mathematical stage invariant: before any butterflies, the state is exactly the bit-reversed input.

            theorem CompPoly.CPolynomial.NTT.Forward.forwardStagePureSpec_eq_forwardMathStageSpec {R : Type u_1} [Field R] (D : Domain R) (a : Array R) (completed : ) :
            completed D.logNforwardStagePureSpec D completed a = forwardMathStageSpec D completed a

            The pure stage recursion matches the mathematical partial-DFT state at every stage.

            Algorithmic stages coincide with the proof-oriented stagewise specification.

            This is the loop-invariant bridge: the imperative for stage in [0:D.logN] implementation computes the same intermediate states as forwardStageSpec. Basically, this is recursion vs. for loop bookkeeping.

            Once all logN stages are completed, the stagewise specification matches the direct NTT formula.

            Once all logN stages are completed, the stagewise specification matches the direct NTT formula.

            @[inline]

            Intended fast implementation entry point for NTT.

            Instances For
              @[simp]