Chapter 14 definitions: the Andrews--Garvan crank of a partition
DefinitionQseriesFormalization_Chapter14chan-invitation-qseriescrankspartitions
This bundle defines three statistics on a partition of : the number of ones , the number of parts strictly larger than , and the largest part. The crank is then defined as when has a part equal to , and as the largest part otherwise (Andrews--Garvan 1988).
Definition code
-- Generated by qseries-p2m/p2m/generate.py from QseriesFormalization.Chapter14: skeleton subtraction
-- keeps 4 declaration(s); proofs kept; project imports -> Definitions bundles.
import Mathlib
/-!
# Chapter 14 — Dyson-Garvan crank
⚠️ **AUX CHAPTER — chapter-main result OPEN**.
Per `PLAYBOOK_AUDIT.md` (2026-05-22): this file contains the formal
definition of the crank statistic (`crank`, `crankOnes`, `crankMu`,
`crankLargest`) and the trivial-shape calculations:
• `crank_singleton` : the partition `[n]` has crank `n` (n ≥ 2)
• `crank_allOnes` : the partition `[1,1,…,1]` of `n` has crank `-n` (n ≥ 1)
These give two of the five mod-5 residue classes for partitions of 4
(cranks 4 ≡ 4 and -4 ≡ 1 mod 5). The truncations
`crankGenNumeratorTrunc_N`, `crankGenDenominatorTrunc_N`, etc. are
mechanical scaffold.
**Chan's Ch 14 main result — the Dyson-Garvan theorem that the crank
distributes evenly mod 5 / mod 7 / mod 11 over partitions of `5n+4` /
`7n+5` / `11n+6` respectively, thereby explaining the Ramanujan
congruences combinatorially — is NOT formalized here.** Even the n=4
special case (`crankDistMod5OfFour` hits all 5 residues mod 5) is only
asserted at the level of definition, not proved.
-/
namespace QseriesFormalization
namespace PartIII
namespace Ch14
section Field
variable {R : Type*} [Field R]
end Field
/-! ### Crank statistic on partitions (Andrews-Garvan 1988)
The crank `c(λ)` of a partition `λ` is defined as:
- If `1 ∉ parts(λ)`: `c(λ) = largest part of λ`.
- If `1 ∈ parts(λ)`: let `ω(λ) = #{occurrences of 1 in λ}`, and
`μ(λ) = #{parts of λ strictly greater than ω(λ)}`. Then `c(λ) = μ(λ) - ω(λ)`.
Andrews and Garvan showed (1988) that the crank refines the partition function
in such a way that the residue classes modulo 5, 7, 11 explain the
Ramanujan congruences combinatorially.
We work with `Nat.Partition n` from Mathlib (parts is a `Multiset ℕ`). -/
section Crank
open Nat
/-- Number of 1's in a partition: `ω(lam) = (lam.parts).count 1`. -/
def crankOnes {n : Nat} (lam : Nat.Partition n) : Nat :=
lam.parts.count 1
/-- Number of parts of `lam` strictly greater than `ω(lam)`. -/
noncomputable def crankMu {n : Nat} (lam : Nat.Partition n) : Nat :=
(lam.parts.filter (fun x => x > crankOnes lam)).card
/-- Largest part of a partition `lam` (or 0 for the empty partition). -/
noncomputable def crankLargest {n : Nat} (lam : Nat.Partition n) : Nat :=
lam.parts.fold max 0
/-- **The Andrews-Garvan crank** `c(lam) : ℤ`. -/
noncomputable def crank {n : Nat} (lam : Nat.Partition n) : Int :=
if 1 ∈ lam.parts then
(crankMu lam : Int) - (crankOnes lam : Int)
else
(crankLargest lam : Int)
end Crank
end Ch14
end PartIII
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 14. Lean source: https://github.com/xiangyazi24/invitation-to-qseries-lean/blob/5df34b280b6a9c4a68ab09105b4e5d3c7bbe88d1/QseriesFormalization/Chapter14.lean (definitions of this module that the uploaded theorems need; ported to Lean v4.33.1 / Mathlib 0df444a).