Franklin's involution: strict partitions, pentagonal sign, signed counts
DefinitionQseriesFormalization_Chapter05_Franklinchan-invitation-qseriescombinatoricspartitionspentagonal-numbers
This bundle defines strict partitions of as finite sets of positive integers summing to , and their signed count . It defines the pentagonal sign when and otherwise, the length of the top consecutive staircase of a strict partition, and Franklin's involution on finite sets of naturals, which pairs partitions of opposite sign except at pentagonal fixed points. They underlie the combinatorial proof of Euler's pentagonal number theorem.
Definition code
-- Generated by qseries-p2m/p2m/generate.py from QseriesFormalization.Chapter05_Franklin: skeleton subtraction
-- keeps 5 declaration(s); proofs kept; project imports -> Definitions bundles.
import Mathlib.Tactic.Linarith
import Mathlib
namespace QseriesFormalization end QseriesFormalization
namespace QseriesFormalization.PartI end QseriesFormalization.PartI
namespace QseriesFormalization.PartI.Ch04Franklin end QseriesFormalization.PartI.Ch04Franklin
/-!
# Franklin Involution → Euler Pentagonal Number Theorem (Combinatorial)
The final assembly: use the Franklin involution (Ch04Franklin infrastructure) to prove
the combinatorial form of Euler's pentagonal number theorem.
## Strategy
A strict partition of n is a subset S ⊆ {1,...,n} with ∑ S = n.
The signed count is ∑_{S : strict partition of n} (-1)^|S|.
Franklin's involution pairs most S with a partner of opposite sign.
The only unpaired partitions are the pentagonal fixed shapes
{k, k+1, ..., 2k-1} (weight = k(3k-1)/2) and {k+1, k+2, ..., 2k}
(weight = k(3k+1)/2). These contribute (-1)^k each.
Result: ∑ (-1)^|S| = (-1)^k if n = k(3k±1)/2, else 0.
-/
open QseriesFormalization PartI Ch04Franklin
namespace QseriesFormalization.PartI.Ch04Franklin
/-- A strict partition of n as a Finset of positive naturals summing to n. -/
def StrictPartitionSet (n : Nat) : Finset (Finset Nat) :=
((Finset.range (n + 1)).powerset).filter fun S =>
(∀ x ∈ S, 0 < x) ∧ S.sum id = n
/-- The signed count of strict partitions of n. -/
def signedStrictPartitionCount (n : Nat) : Int :=
∑ S ∈ StrictPartitionSet n, (-1 : Int) ^ S.card
/-- The pentagonal sign: (-1)^k when n is the k-th pentagonal number. -/
def pentagonalSign (n : Nat) : Int :=
match (List.range (n + 1)).find? (fun k => n = k * (3 * k - 1) / 2) with
| some k => (-1 : Int) ^ k
| none =>
match (List.range (n + 1)).find? (fun k => 0 < k ∧ n = k * (3 * k + 1) / 2) with
| some k => (-1 : Int) ^ k
| none => 0
-- Sanity: pentagonal numbers are 0, 1, 2, 5, 7, 12, 15, 22, 26, ...
-- Signs: +1, -1, -1, +1, +1, -1, -1, +1, +1, ...
-- Signed strict partition counts
/-! ### Franklin involution on Finset Nat
Standard definition (Andrews, *The Theory of Partitions*):
Given strict partition S = {λ₁ > λ₂ > ... > λₖ} (distinct positive integers):
- σ = S.min' (smallest part)
- t = max{j : S.max', S.max'-1, ..., S.max'-j+1 all ∈ S} (top staircase length)
If σ < t, or σ = t and σ ≤ S.max' - σ (bottom doesn't overlap top after shift):
→ Remove σ; add 1 to each of the top σ parts. (Card decreases by 1.)
If σ > t, or σ = t and σ > S.max' - σ:
→ Subtract 1 from each of the top t parts; add new part t. (Card increases by 1.)
Fixed points: σ = t with specific overlap = pentagonal shapes. -/
/-- Top staircase length: count of consecutive integers down from the maximum in S.
E.g., {7,5,4,3,1} has max=7, and 7∈S but 6∉S, so topStaircase = 1.
{5,4,3,1} has 5,4,3 ∈ S but 2∉S, so topStaircase = 3. -/
def topStaircase (S : Finset Nat) : Nat :=
if h : S.Nonempty then
let m := S.max' h
(List.range (m + 1)).takeWhile (fun i => m - i ∈ S) |>.length
else 0
/-- Franklin's involution. -/
def franklinInv (S : Finset Nat) : Finset Nat :=
if hne : S.Nonempty then
let σ := S.min' hne
let m := S.max' hne
let t := topStaircase S
-- Top t parts: {m, m-1, ..., m-t+1}
let topParts := (Finset.range t).image (m - ·)
-- Remaining parts (not in the top staircase)
let botParts := S \ topParts
if σ ≤ t then
if σ = t ∧ (m - t + 1 = σ ∨ σ ∈ topParts) then S -- fixed point
else
-- Remove σ; add 1 to top σ parts
let topσ := (Finset.range σ).image (m - ·) -- {m, m-1, ..., m-σ+1}
let shifted := topσ.image (· + 1) -- {m+1, m, ..., m-σ+2}
let rest := S \ topσ -- remaining without top σ
(rest.erase σ) ∪ shifted -- remove bottom, extend top
else
-- σ > t: subtract 1 from top t parts, add t as new bottom
-- Fixed if shifted bottom would equal new part: m-t = t (i.e., m = 2t)
if m - t = t ∨ t ∈ (S \ topParts) then S -- fixed point
else
let shifted := topParts.image (· - 1) -- {m-1, m-2, ..., m-t}
let rest := S \ topParts
rest ∪ shifted ∪ {t}
else S
-- Sanity: topStaircase
-- Sanity: franklinInv involution
-- {3, 1} (wt 4): σ=1, t=1, σ≤t. σ=t, σ∈topParts? topParts={3}, 1∉{3}. No.
-- Move bottom to top: result = {4}. Card 2→1.
/-! ### Verified instances of the pentagonal number theorem
While the general proof (via Franklin involution) is developed over multiple
sessions, we verify the theorem for all n ≤ 22 via native_decide. -/
/-! ### Helper lemmas for Franklin involution proofs -/
section Helpers
open Finset
/-! ## takeWhile infrastructure -/
/-! ## topStaircase properties -/
/-! ## Derived topStaircase utilities -/
/-! ## Equational lemmas: fixed-point cases -/
/-! ## Equational lemmas: non-fixed cases -/
end Helpers
/-! ### Key properties of franklinInv -/
section InvolutiveHelpers
open Finset
end InvolutiveHelpers
-- Verified: involution on all strict partitions of weight ≤ 7
/-! ### Fixed-point characterization and pentagonal number helpers -/
section FixedPointCharacterization
open Finset
-- Forward: fixed → Type A or Type B
-- Backward: pentagonal → fixed
end FixedPointCharacterization
/-! ### Pentagonal number arithmetic -/
section PentagonalArithmetic
open Finset
-- Gauss sum helpers
-- Assembly helpers
end PentagonalArithmetic
/-! ### Sign cancellation and final assembly -/
section FinalAssembly
open Finset
end FinalAssembly
end QseriesFormalization.PartI.Ch04Franklin
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 5. Lean source: https://github.com/xiangyazi24/invitation-to-qseries-lean/blob/5df34b280b6a9c4a68ab09105b4e5d3c7bbe88d1/QseriesFormalization/Chapter05_Franklin.lean (definitions of this module that the uploaded theorems need; ported to Lean v4.33.1 / Mathlib 0df444a).