Documentation

PolyaEnumerationTheorem.Basic

Pólya's enumeration theorem #

We interpret functions X → Y as colorings of X with colors in Y. The element x : X is colored with color (f x) : Y in the coloring f : X → Y.

We interpret g : G as a transformation that permutes the elements of X into an equivalent configuration. If we color the elements of X with f : X → Y and then permute X with g : G, we obtain an equivalent configuration which now has the coloring x ↦ (f (g⁻¹ • x)). Note that g⁻¹ appears in the definition of the new coloring because the color of the element x in the new permuted configuration must match the color of its preimage g⁻¹ • x in the original configuration. Thus, for any g : G, we consider the colorings f and x ↦ (f (g⁻¹ • x)) to be equivalent.

Given a group action of G on X, we define an instance of group action of G on X → Y, which transforms colorings into equivalent colorings. This group action induces an equivalence relation defined by f₁ ∼ f₂ ↔ ∃ g, f₁ = g • f₂. Two colorings are equivalent when one can be transformed into the other by some element of G. The quotient of X → Y by this relation contains the orbits (equivalence classes) of equivalent colorings. The number of distinct colorings is the cardinality of this set.

We define a notion of cycles for elements in the group G acting on X. Every g : G induces a permutation of X through its action. The cycles of g : G are defined as the equivalence classes of X quotiented by the equivalence relation of being in the same cycle: x₁ ∼ x₂ ↔ ∃ k : ℤ, (permutation of g)ᵏ x₁ = x₂.

We prove Pólya's enumeration theorem and its commonly used variant, in which the sum ranges over the possible numbers of cycles instead of the elements of the group G.

For additional information, refer to https://en.wikipedia.org/wiki/P%C3%B3lya_enumeration_theorem.

instance DistinctColorings.MulActionColorings (X : Type u) (Y : Type v) (G : Type w) [Group G] [MulAction G X] :
MulAction G (XY)

Group action of G on X → Y with g • f ↦ (x ↦ f (g⁻¹ • x)).

Equations

The relation defined by f₁ ∼ f₂ ↔ ∃ g, f₁ = g • f₂ is decidable. This instance enables inference of Fintype (Quotient (MulAction.orbitRel G (X → Y))) and guarantees that the number of distinct colorings can be computed when X, Y and G are finite and X and Y have decidable equalities.

Equations
@[reducible, inline]
abbrev DistinctColorings.numDistinctColorings (X : Type u) (Y : Type v) (G : Type w) [Group G] [MulAction G X] [Fintype (Quotient (MulAction.orbitRel G (XY)))] :

Number of distinct colorings is the cardinality of the quotient of X → Y by the equivalence relation f₁ ∼ f₂ ↔ ∃ g, f₁ = g • f₂.

Equations
Instances For
    @[reducible, inline]
    abbrev CyclesOfGroupElements.CyclesOfGroup (X : Type u) {G : Type v} [Group G] [MulAction G X] (g : G) :

    The cycles of g : G are defined as the quotient of X by the equivalence relation of being in the same cycle of g: x₁ ∼ x₂ ↔ ∃ k : ℤ, (permutation of g)ᵏ x₁ = x₂. Cycles are unordered, and cycles of length 1 are also considered proper cycles. This definition of cycles differs from the standard definition of cycles in Mathlib, because cycles of length 1 are recognized as proper cycles.

    Equations
    Instances For

      Instance of DecidableRel for relation of being in the same cycle. Enables deciding for arbitrary elements of X and arbitrary permutation of X if the elements are in the same cycle of the permutation. This instance enables inference of Fintype and DecidableEq for CyclesOfGroup when X is finite and has decidable equality.

      Equations
      @[reducible, inline]

      The number of cycles in the permutation of g. Cycles with only a single element are also counted (e.g. c[0, 1] : Equiv.Perm (Fin 3) has two cycles).

      Equations
      Instances For
        @[reducible, inline]

        The number of elements in the group G that have exactly i cycles.

        Equations
        Instances For

          The proof of Pólya's enumeration theorem uses the set of fixed points of g, denoted by MulAction.fixedBy (X → Y) g. This set consists of all colorings f : X → Y that are invariant under the action of g, i.e., those satisfying g • f = f.

          theorem Theorem.f_mem_fixedBy_iff_forall_eq_to_eq {X : Type u} {Y : Type v} {G : Type w} [Group G] [MulAction G X] (g : G) (f : XY) :
          f MulAction.fixedBy (XY) g ∀ (a b : X), a = bf a = f b

          For any g : G we have: a coloring f is in fixed points of g if and only if f maps all elements in the same cycle of g to the same color. Only left to right implication of this lemma is used in the proof of Pólya's enumeration theorem.

          def Theorem.cycle_coloring_of_fixedBy_coloring {X : Type u} {Y : Type v} {G : Type w} [Group G] [MulAction G X] (g : G) (f : (MulAction.fixedBy (XY) g)) :

          A function that maps a coloring from fixed points of g to a coloring of cycles. Colorings that are fixed by g map all elements of a cycle of g to the same color by lemma f_mem_fixedBy_iff_forall_eq_to_eq. We can transform each such coloring to a coloring of cycles of g by coloring each cycle with the color of its elements.

          Equations
          Instances For
            def Theorem.fixedBy_coloring_of_cycle_coloring {X : Type u} {Y : Type v} {G : Type w} [Group G] [MulAction G X] (g : G) (f : CyclesOfGroupElements.CyclesOfGroup X gY) :
            (MulAction.fixedBy (XY) g)

            A function that maps a coloring of cycles to a coloring in fixed points of g. We color each element with the color of its cycle. The resulting function is in fixed points of g because g⁻¹ • x and x are in the same cycle of g.

            Equations
            Instances For

              Functions cycle_coloring_of_fixedBy_coloring and fixedBy_coloring_of_cycle_coloring are inverses and form a bijection.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For

                For any g : G we have: the number of colors raised to the power of the number of cycles of g is equal to the number of colorings that are fixed by g. To use this lemma it suffices to have: [Group G] [MulAction G X] [Fintype X] [Fintype Y] [DecidableEq X] [DecidableEq Y].

                A version of Pólya's enumeration theorem where the number of distinct colorings of X with colors in Y, under the group action of G on X, is multiplied by the cardinality of the group G. To use this theorem it suffices to have: [Group G] [MulAction G X] [Fintype X] [Fintype Y] [Fintype G] [DecidableEq X] [DecidableEq Y].

                Pólya's enumeration theorem: Provides a formula for the number of distinct colorings of X with colors in Y, under the group action of G on X. To use this theorem it suffices to have: [Group G] [MulAction G X] [Fintype X] [Fintype Y] [Fintype G] [DecidableEq X] [DecidableEq Y].

                A version of Pólya's enumeration theorem where the sum ranges over the possible numbers of cycles, and the number of distinct colorings of X with colors in Y, under the group action of G on X, is multiplied by the cardinality of the group G. To use this theorem it suffices to have: [Group G] [MulAction G X] [Fintype X] [Fintype Y] [Fintype G] [DecidableEq X] [DecidableEq Y].