Documentation

CompPoly.Univariate.NTT.Transform

Shared radix-2 NTT transform #

This file provides the root-parametric bit-reversal and butterfly machinery used by forward and inverse radix-2 NTTs.

Reverse the lowest bits bits of i.

Instances For
    theorem CompPoly.CPolynomial.NTT.Transform.bitRevNat_odd_or (bits b : ) :
    bitRevNat (bits + 1) (2 * b + 1) = 1 <<< bits ||| bitRevNat bits b
    theorem CompPoly.CPolynomial.NTT.Transform.bitRevNat_odd (bits b : ) :
    bitRevNat (bits + 1) (2 * b + 1) = 2 ^ bits + bitRevNat bits b

    Apply bit-reversal permutation to an evaluation array.

    Instances For
      def CompPoly.CPolynomial.NTT.Transform.butterflyInnerStep {R : Type u_1} [Field R] (blockSize half : ) (wm : R) (block j : ) (st : Array R × R) :
      Array R × R
      Instances For
        def CompPoly.CPolynomial.NTT.Transform.butterflyBlockStep {R : Type u_1} [Field R] (blockSize half : ) (wm : R) (block : ) (acc : Array R) :
        Instances For
          def CompPoly.CPolynomial.NTT.Transform.butterflyStage {R : Type u_1} [Field R] (D : Domain R) (stage : ) (a : Array R) :

          One butterfly stage of the iterative radix-2 transform.

          Instances For

            Pure structural-recursive specification of one butterfly stage.

            This matches the imperative control flow of butterflyStage, but replaces the for loops with explicit Nat.rec recursors.

            Instances For

              The imperative butterfly loop agrees with the pure pointwise butterfly stage specification.

              This is where the local set! bookkeeping for one stage belongs.

              @[simp]
              theorem CompPoly.CPolynomial.NTT.Transform.size_butterflyInnerStep {R : Type u_1} [Field R] (blockSize half : ) (wm : R) (block j : ) (st : Array R × R) :
              (butterflyInnerStep blockSize half wm block j st).1.size = st.1.size
              @[simp]
              theorem CompPoly.CPolynomial.NTT.Transform.size_butterflyBlockStep {R : Type u_1} [Field R] (blockSize half : ) (wm : R) (block : ) (acc : Array R) :
              (butterflyBlockStep blockSize half wm block acc).size = acc.size
              theorem CompPoly.CPolynomial.NTT.Transform.size_butterflyStage {R : Type u_1} [Field R] (D : Domain R) (stage : ) (a : Array R) :
              (butterflyStage D stage a).size = a.size

              Run all radix-2 butterfly stages (complexity: O(n log n)).

              Instances For
                theorem CompPoly.CPolynomial.NTT.Transform.runStages_eq_rec {R : Type u_1} [Field R] (D : Domain R) (a : Array R) :
                runStages D a = Nat.rec a (fun (stage : ) (acc : Array R) => butterflyStage D stage acc) D.logN

                The imperative stage loop agrees with the corresponding Nat.rec.