Use this theorem
Create a project
lake +leanprover/lean4:v4.35.0 new myproject std.toml cd myprojectStandard template, not
math: themathtemplate adds its own Mathlib requirement pinned to the Lean release tag, not to the Mathlib commit this package is built and tested with, so you would get a second, different Mathlib. Mathlib comes in through this package. Skip this step in an existing project with the same Lean and Mathlib.Add the dependency to
lakefile.toml[[require]] name = "formalizations" git = "https://github.com/karlesmarin/formalizations" rev = "v0.15.0"Import the minimal module
import Formalizations.Reusable.GroupTheoryIn a file of the project, e.g.
Example.lean.Paste the example
open Formalizations.Reusable open Classical in open scoped Pointwise in /-- Counting colourings up to symmetry (all weights `1`): `|G| · #orbits` is the sum over `g` of `|C|` to the number of cycles of `g` on `α`, fixed points included. -/ example {G α C : Type*} [Group G] [Fintype G] [MulAction G α] [Fintype α] [Fintype C] : letI := arrowAction (G := G) (A := α) (B := C) Fintype.card G * Fintype.card (MulAction.orbitRel.Quotient G (α → C)) = ∑ g : G, (Fintype.card C) ^ (Fintype.card (Function.fixedPoints (MulAction.toPerm g : Equiv.Perm α)) + (MulAction.toPerm g : Equiv.Perm α).cycleType.card) := by let _ := arrowAction (G := G) (A := α) (B := C) have h := polya_redfield_card_mul_sum_orbit_weight (G := G) (α := α) (C := C) (R := ℤ) (fun _ => 1) simp only [Finset.prod_const_one, Finset.sum_const, Finset.card_univ, one_pow, nsmul_eq_mul, mul_one, Multiset.map_const', Multiset.prod_replicate] at h rw [← Nat.cast_inj (R := ℤ)] push_cast rw [h] refine Finset.sum_congr rfl fun g _ => ?_ rw [pow_add]Steps 3 and 4 together are a complete Lean file:
FormalizationsTest/ReusableGroupTheoryExample.leanat v0.15.0, compiled by the CI.Fetch and check
lake update lake lean Example.leanlake updatefetches this package and Mathlib, and Mathlib's update hook downloads the compiled Mathlib (lake exe cache get).lake lean Example.leanbuilds the imports of the file (steps 3 and 4) and checks it. If the file belongs to alean_libof your project,lake build <lib>does the same. Avoid a barelake buildin a project from the standard template: its default target is the executable, whose link compiles every imported Mathlib module to native code. Same versions required: Leanv4.35.0, Mathlibf0b4c81.
Alternative: import Formalizations.Reusable imports the whole layer (all areas).
Pólya–Redfield enumeration theorem: for a finite group G acting on a finite set α and colour weights w, |G| · Σ over orbits of colourings of Π_a w(F a) equals Σ_g p₁^(fixed points of g) · Π over the cycles of g of p_length, where p_k = Σ_c w(c)^k.
Lean statement
theorem polya_redfield_card_mul_sum_orbit_weight {G α C R : Type*} [Group G] [Fintype G]
[MulAction G α] [Fintype α] [Fintype C] [CommRing R] (w : C → R) :
letI := arrowAction (G := G) (A := α) (B := C)
(Fintype.card G : R) * ∑ O : MulAction.orbitRel.Quotient G (α → C), ∏ a, w (O.out a) =
∑ g : G, (∑ c, w c) ^ (Fintype.card (Function.fixedPoints (MulAction.toPerm g : Equiv.Perm α))) *
((MulAction.toPerm g : Equiv.Perm α).cycleType.map (fun k => ∑ c, w c ^ k)).prodLinks
Lean docstring
The Pólya–Redfield enumeration theorem (weighted form). A finite group G acting on a finite set α acts on colourings F : α → C by Mathlib's arrowAction, (g • F) a = F (g⁻¹ • a). Give each colour a weight w c in a commutative ring and each colouring the weight W F = ∏ₐ w (F a). Then |G| · Σ_{orbits O} W O = Σ_{g ∈ G} p₁^{fix g} · ∏_{cycles of g of length k ≥ 2} p_k, where p_k = Σ_c (w c)^k: the cycle index of the action evaluated at the power sums of the weights (Mathlib's Equiv.Perm.cycleType lists the cycles of length at least 2; the fixed points are the cycles of length 1). With w = 1 it counts colourings up to symmetry.
- Archive:
PolyaRedfield.card_mul_sum_orbit_weight(Formalizations.GroupTheory.GroupAction.PolyaRedfield, a weighted Burnside lemma plus the factorization of the fixed colourings over the cycles); the module cites no paper DOI of ours. - Classical reference: J. H. Redfield, The theory of group-reduced distributions, Amer. J. Math. 49 (1927) 433–455; G. Pólya, Acta Math. 68 (1937) 145–254.
- Example: the necklaces of
4beads in2colours up to rotation (G = ZMod 4acting on itself) are(2⁴ + 2 + 2² + 2) / 4 = 6.
Upstream
Mathlib has Burnside's lemma (MulAction.sum_card_fixedBy_eq_card_orbits_mul_card_group) and Equiv.Perm.cycleType but not the enumeration theorem
Depends on, in this repository
None besides the archive module (repo_dependencies = []).