The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V03. Sets, finite structures and big operators

Mathlib.Algebra.Order.Antidiag.Pi

19 declarations and 1 deprecated aliases. Mathlib docs · Source

Antidiagonal of functions as finsets

This file provides the finset of functions summing to a specific value on a finset. Such finsets should be thought of as the "antidiagonals" in the space of functions.

Precisely, for a commutative monoid μ with antidiagonals (see Finset.HasAntidiagonal), Finset.piAntidiag s n is the finset of all functions f : ι → μ with support contained in s and such that the sum of its values equals n : μ.

We define it recursively on s using Finset.HasAntidiagonal.antidiagonal : μ → Finset (μ × μ). Technically, we non-canonically identify s with Fin n where n = s.card, recurse on n using that (Fin (n + 1) → μ) ≃ (Fin n → μ) × μ, and show the end result doesn't depend on our identification. See Finset.finAntidiag for the details.

Main declarations

  • Finset.piAntidiag s n: Finset of all functions f : ι → μ with support contained in s and such that the sum of its values equals n : μ.
  • Finset.finAntidiagonal d n: Computationally efficient special case of Finset.piAntidiag when ι := Fin d.

TODO

Finset.finAntidiagonal is strictly more general than Finset.Nat.antidiagonalTuple. Deduplicate.

See also

Finset.finsuppAntidiag for the Finset (ι →₀ μ)-valued version of Finset.piAntidiag.

Fin d → μ

In this section, we define the antidiagonals in Fin d → μ by recursion on d. Note that this is computationally efficient, although probably not as efficient as Finset.Nat.antidiagonalTuple.

ι → μ

In this section, we transfer the antidiagonals in Fin s.card → μ to antidiagonals in ι → s by choosing an identification s ≃ Fin s.card and proving that the end result does not depend on that choice.

def Finset.finAntidiagonal.aux E1 #

{μ : Type u_2} →
  [inst : AddCommMonoid μ] →
    [Finset.HasAntidiagonal μ] → [DecidableEq μ] → (d : ℕ) → (n : μ) → { s // ∀ (f : Fin d → μ), f ∈ s ↔ ∑ i, f i = n }

Auxiliary construction for finAntidiagonal that bundles a proof of lawfulness (mem_finAntidiagonal), as this is needed to invoke disjiUnion. Using Finset.disjiUnion makes this computationally much more efficient than using Finset.biUnion.

def Finset.finAntidiagonal E1 #

{μ : Type u_2} →
  [inst : AddCommMonoid μ] → [Finset.HasAntidiagonal μ] → [DecidableEq μ] → (d : ℕ) → μ → Finset (Fin d → μ)

finAntidiagonal d n is the type of d-tuples with sum n.

TODO: deduplicate with the less general Finset.Nat.antidiagonalTuple.

theorem Finset.mem_finAntidiagonal E0 #

∀ {μ : Type u_2} [inst : AddCommMonoid μ] [inst_1 : Finset.HasAntidiagonal μ] [inst_2 : DecidableEq μ] {n : μ} {d : ℕ}
  {f : Fin d → μ}, f ∈ Finset.finAntidiagonal d n ↔ ∑ i, f i = n

def Finset.piAntidiag E3 #

{ι : Type u_1} →
  {μ : Type u_2} →
    [DecidableEq ι] →
      [inst : AddCommMonoid μ] → [Finset.HasAntidiagonal μ] → [DecidableEq μ] → Finset ι → μ → Finset (ι → μ)

The finset of functions ι → μ with support contained in s and sum n.

theorem Finset.mem_piAntidiag E0 #

∀ {ι : Type u_1} {μ : Type u_2} [inst : DecidableEq ι] [inst_1 : AddCommMonoid μ] [inst_2 : Finset.HasAntidiagonal μ]
  [inst_3 : DecidableEq μ] {s : Finset ι} {n : μ} {f : ι → μ},
  f ∈ s.piAntidiag n ↔ s.sum f = n ∧ ∀ (i : ι), f i ≠ 0 → i ∈ s

theorem Finset.piAntidiag_empty_zero E0 #

∀ {ι : Type u_1} {μ : Type u_2} [inst : DecidableEq ι] [inst_1 : AddCommMonoid μ] [inst_2 : Finset.HasAntidiagonal μ]
  [inst_3 : DecidableEq μ], ∅.piAntidiag 0 = {0}

theorem Finset.piAntidiag_empty_of_ne_zero E0 #

∀ {ι : Type u_1} {μ : Type u_2} [inst : DecidableEq ι] [inst_1 : AddCommMonoid μ] [inst_2 : Finset.HasAntidiagonal μ]
  [inst_3 : DecidableEq μ] {n : μ}, n ≠ 0 → ∅.piAntidiag n = ∅

theorem Finset.piAntidiag_empty E1 #

∀ {ι : Type u_1} {μ : Type u_2} [inst : DecidableEq ι] [inst_1 : AddCommMonoid μ] [inst_2 : Finset.HasAntidiagonal μ]
  [inst_3 : DecidableEq μ] (n : μ), ∅.piAntidiag n = if n = 0 then {0} else ∅

theorem Finset.finset_congr_piAntidiag_eq_antidiag E1 #

∀ {μ : Type u_2} [inst : AddCommMonoid μ] [inst_1 : Finset.HasAntidiagonal μ] [inst_2 : DecidableEq μ] (n : μ),
  (Equiv.boolArrowEquivProd μ).finsetCongr (Finset.univ.piAntidiag n) = Finset.HasAntidiagonal.antidiagonal n

theorem Finset.pairwiseDisjoint_piAntidiag_map_addRightEmbedding E1 #

∀ {ι : Type u_1} {μ : Type u_2} [inst : DecidableEq ι] [inst_1 : AddCancelCommMonoid μ]
  [inst_2 : Finset.HasAntidiagonal μ] [inst_3 : DecidableEq μ] {i : ι} {s : Finset ι},
  i ∉ s →
    ∀ (n : μ),
      (↑(Finset.HasAntidiagonal.antidiagonal n)).PairwiseDisjoint fun p ↦
        Finset.map (addRightEmbedding fun j ↦ if j = i then p.1 else 0) (s.piAntidiag p.2)

theorem Finset.piAntidiag_cons E1 #

∀ {ι : Type u_1} {μ : Type u_2} [inst : DecidableEq ι] [inst_1 : AddCancelCommMonoid μ]
  [inst_2 : Finset.HasAntidiagonal μ] [inst_3 : DecidableEq μ] {i : ι} {s : Finset ι} (hi : i ∉ s) (n : μ),
  (Finset.cons i s hi).piAntidiag n =
    (Finset.HasAntidiagonal.antidiagonal n).disjiUnion
      (fun p ↦ Finset.map (addRightEmbedding fun t ↦ if t = i then p.1 else 0) (s.piAntidiag p.2)) ⋯

theorem Finset.piAntidiag_insert E1 #

∀ {ι : Type u_1} {μ : Type u_2} [inst : DecidableEq ι] [inst_1 : AddCancelCommMonoid μ]
  [inst_2 : Finset.HasAntidiagonal μ] [inst_3 : DecidableEq μ] {i : ι} {s : Finset ι} [inst_4 : DecidableEq (ι → μ)],
  i ∉ s →
    ∀ (n : μ),
      (insert i s).piAntidiag n =
        (Finset.HasAntidiagonal.antidiagonal n).biUnion fun p ↦
          Finset.image (fun f j ↦ f j + if j = i then p.1 else 0) (s.piAntidiag p.2)

theorem Finset.piAntidiag_zero E0 #

∀ {ι : Type u_1} {μ : Type u_2} [inst : DecidableEq ι] [inst_1 : AddCommMonoid μ] [inst_2 : PartialOrder μ]
  [CanonicallyOrderedAdd μ] [inst_4 : Finset.HasAntidiagonal μ] [inst_5 : DecidableEq μ] (s : Finset ι),
  s.piAntidiag 0 = {0}

theorem Finset.piAntidiag_univ_fin_eq_antidiagonalTuple E1 #

∀ (n k : ℕ), Finset.univ.piAntidiag n = Finset.Nat.antidiagonalTuple k n

theorem Finset.nsmul_piAntidiag E1 #

∀ {ι : Type u_1} [inst : DecidableEq ι] [inst_1 : DecidableEq (ι → ℕ)] (s : Finset ι) (m : ℕ) {n : ℕ},
  n ≠ 0 → n • s.piAntidiag m = {f ∈ s.piAntidiag (n * m) | ∀ i ∈ s, n ∣ f i}

theorem Finset.map_nsmul_piAntidiag E0 #

∀ {ι : Type u_1} [inst : DecidableEq ι] (s : Finset ι) (m : ℕ) {n : ℕ} (hn : n ≠ 0),
  Finset.map { toFun := fun x ↦ n • x, inj' := ⋯ } (s.piAntidiag m) = {f ∈ s.piAntidiag (n * m) | ∀ i ∈ s, n ∣ f i}

theorem Finset.nsmul_piAntidiag_univ E1 #

∀ {ι : Type u_1} [inst : DecidableEq ι] [inst_1 : Fintype ι] (m : ℕ) {n : ℕ},
  n ≠ 0 → n • Finset.univ.piAntidiag m = {f ∈ Finset.univ.piAntidiag (n * m) | ∀ (i : ι), n ∣ f i}

theorem Finset.map_nsmul_piAntidiag_univ E0 #

∀ {ι : Type u_1} [inst : DecidableEq ι] [inst_1 : Fintype ι] (m : ℕ) {n : ℕ} (hn : n ≠ 0),
  Finset.map { toFun := fun x ↦ n • x, inj' := ⋯ } (Finset.univ.piAntidiag m) =
    {f ∈ Finset.univ.piAntidiag (n * m) | ∀ (i : ι), n ∣ f i}

theorem Finset.map_sym_eq_piAntidiag E0 #

∀ {ι : Type u_1} [inst : DecidableEq ι] (s : Finset ι) (n : ℕ),
  Finset.map { toFun := fun m a ↦ Multiset.count a ↑m, inj' := ⋯ } (s.sym n) = s.piAntidiag n

Deprecated aliases

NameNew nameSince
Finset.finsetCongr_piAntidiag_eq_antidiagFinset.finset_congr_piAntidiag_eq_antidiag2026-08-11