Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Negacyclic multiplication via one product modulo 2^{nP}+1

Definition
IntMul_HvdH_Fermat

by xuanji · Oct 12, 2026 · Mathlib 0df444a (Lean v4.33.1)

Definition code
import Definitions.Def_IntMul_HvdH_KronMul

/-! Negacyclic multiplication through one multiplication modulo a Fermat-type number
`F = 2^{nP} + 1`: evaluate at `y = 2^P` (so `y^n ≡ -1`), multiply modulo `F`, take the balanced
residue and read `n` balanced base-`2^P` digits. -/

namespace IntMul.HvdH

/-- The residue of `x` modulo `F` in `(-F/2, F/2]`. -/
def balMod (F x : ℤ) : ℤ :=
  let c := x % F
  if F < 2 * c then c - F else c

/-- Negacyclic product of two length-`n` coefficient lists via one product modulo `2^{nP} + 1`.
The middle step `(A * B) % F` with `0 ≤ A, B < F` is the Fermat-ring multiplication. -/
def fermatNegaMul (P n : ℕ) (u v : List ℤ) : List ℤ :=
  let B : ℤ := 2 ^ P
  let F : ℤ := B ^ n + 1
  kunpack B n (balMod F ((kpack B u % F) * (kpack B v % F) % F))

end IntMul.HvdH

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me