Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Chapter 8 finite Rogers--Ramanujan: Gaussian sum EN+1(a)E_{N+1}(a)EN+1​(a) and alternating finite side DDD

Definition
QseriesFormalization_Pending_Chapter08_FiniteRR

by FormallyCorrect · Oct 23, 2026 · Mathlib 0df444a (Lean v4.33.1)

chan-invitation-qseriespentagonal-numbersq-binomialrogers-ramanujan

This bundle defines Chan's finite Gaussian-polynomial sum EN+1(a)=∑j=0Nqj2+aj(N−jj)qE_{N+1}(a)=\sum_{j=0}^{N}q^{j^2+aj}\binom{N-j}{j}_qEN+1​(a)=∑j=0N​qj2+aj(jN−j​)q​ and the alternating side ∑j(−1)jqj(5j+1)/2−2aj(N+a⌊(N+3a−5j)/2⌋)q\sum_j(-1)^jq^{j(5j+1)/2-2aj}\binom{N+a}{\lfloor(N+3a-5j)/2\rfloor}_q∑j​(−1)jqj(5j+1)/2−2aj(⌊(N+3a−5j)/2⌋N+a​)q​ as a bilateral finite sum with a symmetric bound N+3a+2N+3a+2N+3a+2. Supporting definitions are the exponent, the lower index, a Gaussian binomial with integer lower index (zero when negative), the per-jjj term, a residual of the recurrence and a carry term used in the telescoping proof.

The definitions are over a field with totalized integer powers: 000 raised to a negative integer is 000.

Definition code
-- Generated by qseries-p2m/p2m/generate.py from QseriesFormalization.Pending.Chapter08_FiniteRR: skeleton subtraction
-- keeps 9 declaration(s); proofs kept; project imports -> Definitions bundles.
import Definitions.Def_QseriesFormalization_DefCoreQSeries
import Mathlib.Analysis.Normed.Group.Tannery
import Mathlib
import Mathlib.Analysis.SpecialFunctions.Log.Summable

/-!
# Chapter 8 finite Rogers-Ramanujan sum side

Chan's Section 8.1 writes
`E_n(a) = sum_j q^(j^2 + a*j) [n-j-1 choose j]_q` and proves the
second-order recurrence
`E_{n+1}(a) = E_n(a) + q^(n+a-1) E_{n-1}(a)`.

The zero-based definition below is `EFinite q a N = E_{N+1}(a)`.
-/

namespace QseriesFormalization
namespace PartII
namespace Ch08

section Field

variable {R : Type*} [Field R]

/-- The finite Gaussian-polynomial sum side of Chan Theorem 8.1.
This is Chan's `E_{N+1}(a)`: `sum_j q^(j^2+a*j) [N-j choose j]_q`. -/
noncomputable def EFinite (q : R) (a N : Nat) : R :=
  ∑ j ∈ Finset.range (N + 1), q ^ (j ^ 2 + a * j) * gaussianBinom q (N - j) j

/-! ### Chan's finite alternating Gaussian-polynomial side -/

/-- Integer exponent in Chan's alternating side:
`j(5j+1)/2 - 2aj`. -/
def DFiniteExponent (a : Nat) (j : Int) : Int :=
  (j * (5 * j + 1)) / 2 - 2 * (a : Int) * j

/-- Integer lower index in Chan's alternating side:
`⌊(N+3a-5j)/2⌋`.  Lean's integer division by positive `2` is floor division. -/
def DFiniteLower (a N : Nat) (j : Int) : Int :=
  ((N : Int) + 3 * (a : Int) - 5 * j) / 2

/-- A Gaussian binomial with an integer lower index, interpreted as zero
when the lower index is negative.  If the lower index is above the top, the
existing `gaussianBinom_eq_zero_of_lt` lemma supplies the zero value. -/
noncomputable def gaussianBinomIntLower (q : R) (top : Nat) (k : Int) : R :=
  if 0 ≤ k then gaussianBinom q top k.toNat else 0

/-- A symmetric finite bound large enough to contain all possible nonzero
terms of Chan's finite alternating sum. -/
def DFiniteBound (a N : Nat) : Nat :=
  N + 3 * a + 2

/-- One summand of Chan's finite alternating Gaussian-polynomial side. -/
noncomputable def DFiniteTerm (q : R) (a N : Nat) (j : Int) : R :=
  (-1 : R) ^ j * q ^ DFiniteExponent a j *
    gaussianBinomIntLower q (N + a) (DFiniteLower a N j)

/-- Chan's finite alternating Gaussian-polynomial side of Theorem 8.1:
`Σ_j (-1)^j q^(j(5j+1)/2-2aj) [N+a ; ⌊(N+3a-5j)/2⌋]_q`.

The finite bilateral sum uses `DFiniteBound`; outside this bound the integer
lower q-binomial index is out of range. -/
noncomputable def DFinite (q : R) (a N : Nat) : R :=
  bilateralSum (DFiniteTerm q a N) (DFiniteBound a N)

/-! ### Alternating-side recurrence for the Rogers-Ramanujan cases -/

noncomputable def DFiniteResidual (q : R) (a N : Nat) (j : Int) : R :=
  DFiniteTerm q a (N + 2) j - DFiniteTerm q a (N + 1) j -
    q ^ (N + a + 1) * DFiniteTerm q a N j

noncomputable def DFiniteCarry (q : R) (a N : Nat) (j : Int) : R :=
  if ((N : Int) + 3 * (a : Int) - 5 * j) % 2 = 0 then
    (-1 : R) ^ j * q ^ DFiniteExponent a j *
      q ^ (DFiniteLower a N j + 1).toNat *
      gaussianBinomIntLower q (N + a) (DFiniteLower a N j + 1)
  else 0

/-! ### Recurrence uniqueness bridge -/

end Field

end Ch08
end PartII
end QseriesFormalization
Source
Lean formalization (Xiang Huang) of Hei-Chi Chan, An Invitation to q-Series: From Jacobi's Triple Product Identity to Ramanujan's "Most Beautiful Identity" (World Scientific, 2011), Chapter 8. Lean source: https://github.com/xiangyazi24/invitation-to-qseries-lean/blob/5df34b280b6a9c4a68ab09105b4e5d3c7bbe88d1/QseriesFormalization/Pending/Chapter08_FiniteRR.lean (definitions of this module that the uploaded theorems need; ported to Lean v4.33.1 / Mathlib 0df444a).

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 paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me