Round-six lemma `fdiv_recip`
ProvedJ6Seg.JK.fdiv_recipAn auxiliary lemma of the round-six development, published as a separate node because its proof is long or shared.
The following holds (Lean statement, in the scope of module Solutions.J6SegILJKer1):
theorem J6Seg.JK.fdiv_recip (P k : ℕ) (a pv : ℤ) (hpv : 0 < pv) (hN : |2 * (a * 2 ^ P) + pv| < 2 ^ k) :
(2 * (a * 2 ^ P) + pv) * ivOf k pv / 2 ^ k +
corr (2 * (a * 2 ^ P) + pv - (2 * (a * 2 ^ P) + pv) * ivOf k pv / 2 ^ k * (2 * pv))
(2 * pv) = J6Seg.fdiv P a pv
Context. B-line IL, the J kernel (B4), part 1: list model and arithmetic
The J kernel jKer (J6SegSw3) of a padded G-row v is
jKer v = W ++ 0^{G-m}, W_r = dotF (cc_r) ((zext K z).drop r),
z = bwdK bs (fwdK fs (v.take m) []) [] []
for the coefficient streams fs = fsOf …, bs = bsOf …, cc_r = ccL … r. This file gives
- the generic kernel
jKerG P K G m fs bs cc v(any streams) and the step forms offwdK(fA_succ),bwdK(bwdS_succ) anddotFon prefixes (dotF_take_succ); - the arithmetic of the IL:
ediv_of_tdiv(floor division fromtdiv/tmod),rs_eq(rs P x = ⌊(2x + 2^P) / 2^{P+1}⌋) andfdiv_recip: with|2 a 2^P + pv| < 2^kandpv > 0,fdiv P a pvisq₀ + δwhereq₀ = ⌊N iv / 2^k⌋(iv = ivOf k pv = ⌊2^k / 2pv⌋) and the correctionδ ∈ {-1,0,1}is read off the signs ofN - q₀ DandN - q₀ D - D(N = 2 a 2^P + pv,D = 2 pv): two multiplications instead of a long division.
Formalization Note. Part of the Lean formalization of the round-six κ-improvement (integer-multiplication-kappa campaign, target IntMul.Kappa.jain_round6_framework). The statement is copied verbatim from the Lean development; the platform node carries the same declaration name. Definitions it mentions live in the IntMul_Kappa_R6_Defs* bundles (on top of the published κ bundles IntMul_Kappa_K_Defs*).
-- Round-six κ development (integer-multiplication-kappa), generated by skeleton subtraction. import Definitions.Def_IntMul_Kappa_R6_Defs66 set_option autoImplicit false set_option relaxedAutoImplicit false set_option maxHeartbeats 1000000 open J6Seg J6Seg.JK open Finset
theorem J6Seg.JK.fdiv_recip (P k : ℕ) (a pv : ℤ) (hpv : 0 < pv) (hN : |2 * (a * 2 ^ P) + pv| < 2 ^ k) :
(2 * (a * 2 ^ P) + pv) * ivOf k pv / 2 ^ k +
corr (2 * (a * 2 ^ P) + pv - (2 * (a * 2 ^ P) + pv) * ivOf k pv / 2 ^ k * (2 * pv))
(2 * pv) = J6Seg.fdiv P a pv := by sorry