Bit-reversal and preprocessing invariant #
Bit-reversal permutation lemmas and preprocessing_establishes_inv, split out from
OuterLoopHelpersForward to keep per-file elaboration memory bounded.
Bit-reversal helper lemmas #
The invariant maintained by bitRevLoop: after step iterations starting from the
identity (with the i counter at step and the bit-reversed counter at bitRev n step),
position p holds either v0[bitRev n p] (when p or its mirror has been processed)
or v0[p] (when neither has been processed).
Equations
Instances For
theorem
preprocessing_establishes_inv
{m : ℕ}
(n : ℕ)
(hm_eq : m = 2 ^ n)
(h_dvd : m ∣ mod64.toNat - 1)
(v : Vector UInt32 m)
(hv_bound : (v.all fun (x : UInt32) => decide (x < mod32)) = true)
(roots : Vector UInt32 m)
(_hroots : ntt_roots_correct m roots)
:
have a1 := bitRevLoop (m - 1) 0 (Vector.map toMont v) 0;
have parity := nttInplace.go 64 m 0 &&& 1 != 0;
have a_in := if parity = true then radix2Pass (m / 2) 0 a1 else a1;
have start_q := if parity = true then 1 else 0;
∃ (hle : start_q ≤ n), outerLoop_inv n start_q hle hm_eq v a_in