Documentation

Mathlib.Algebra.Order.Antidiag.Prod

Antidiagonal with values in general types #

We define a type class Finset.HasAntidiagonal A which contains a function antidiagonal : A → Finset (A × A) such that antidiagonal n is the finset of all pairs adding to n, as witnessed by mem_antidiagonal.

Analogously, the type class Finset.HasMulAntidiagonal A contains a function mulAntidiagonal : A → Finset (A × A) such that mulAntidiagonal n is the finset of all pairs multiplying to n, as witnessed by mem_mulAntidiagonal.

When A is a canonically ordered additive monoid with locally finite order this typeclass can be instantiated with Finset.antidiagonalOfLocallyFinite. This applies in particular when A is , more generally or σ →₀ ℕ, or even ι →₀ A under the additional assumption OrderedSub A that make it a canonically ordered additive monoid. (In fact, we would just need an AddMonoid with a compatible order, finite Iic, such that if a + b = n, then a, b ≤ n, and any finiteness condition would be OK.)

For computational reasons it is better to manually provide instances for and σ →₀ ℕ, to avoid quadratic runtime performance. These instances are provided as Finset.Nat.instHasAntidiagonal and Finsupp.instHasAntidiagonal. This is why Finset.mulAntidiagonalOfLocallyFinite is an abbrev and not an instance.

This definition does not exactly match with that of Multiset.antidiagonal defined in Mathlib/Data/Multiset/Antidiagonal.lean, because of the multiplicities. Indeed, by counting multiplicities, Multiset α is equivalent to α →₀ ℕ, but Finset.antidiagonal and Multiset.antidiagonal will return different objects. For example, for s : Multiset ℕ := {0,0,0}, Multiset.antidiagonal s has 8 elements but Finset.antidiagonal s has only 4.

def s : Multiset ℕ := {0, 0, 0}
#eval (Finset.antidiagonal s).card -- 4
#eval Multiset.card (Multiset.antidiagonal s) -- 8

TODO #

class Finset.HasAntidiagonal (A : Type u_1) [AddMonoid A] :
Type u_1

The class of additive monoids with an antidiagonal.

  • antidiagonal : AFinset (A × A)

    The antidiagonal of an element n is the finset of pairs (i, j) such that i + j = n.

  • mem_antidiagonal {n : A} {a : A × A} : a antidiagonal n a.1 + a.2 = n

    A pair belongs to antidiagonal n iff the sum of its components is equal to n.

Instances
    class Finset.HasMulAntidiagonal (A : Type u_1) [Monoid A] :
    Type u_1

    The class of (multiplicative) monoids with a mulAntidiagonal.

    • mulAntidiagonal : AFinset (A × A)

      The mulAntidiagonal of an element n is the finset of pairs (i, j) such that i * j = n.

    • mem_mulAntidiagonal {n : A} {a : A × A} : a mulAntidiagonal n a.1 * a.2 = n

      A pair belongs to mulAntidiagonal n iff the product of its components is equal to n.

    Instances
      @[simp]
      theorem Finset.HasMulAntidiagonal.mulAntidiagonal_congr {A : Type u_1} [CancelMonoid A] [HasMulAntidiagonal A] {p q : A × A} {n : A} (hp : p mulAntidiagonal n) (hq : q mulAntidiagonal n) :
      p = q p.1 = q.1

      A point in the mulAntidiagonal is determined by its first coordinate.

      See also Finset.mulAntidiagonal_congr'.

      theorem Finset.HasAntidiagonal.antidiagonal_congr {A : Type u_1} [AddCancelMonoid A] [HasAntidiagonal A] {p q : A × A} {n : A} (hp : p antidiagonal n) (hq : q antidiagonal n) :
      p = q p.1 = q.1

      A point in the antidiagonal is determined by its first coordinate.

      See also Finset.antidiagonal_congr'.

      theorem Finset.HasMulAntidiagonal.mulAntidiagonal_subtype_ext {A : Type u_1} [CancelMonoid A] [HasMulAntidiagonal A] {n : A} {p q : (mulAntidiagonal n)} (h : (↑p).1 = (↑q).1) :
      p = q

      A point in the mulAntidiagonal is determined by its first co-ordinate (subtype version of Finset.mulAntidiagonal_congr). This lemma is used by the ext tactic.

      theorem Finset.HasAntidiagonal.antidiagonal_subtype_ext {A : Type u_1} [AddCancelMonoid A] [HasAntidiagonal A] {n : A} {p q : (antidiagonal n)} (h : (↑p).1 = (↑q).1) :
      p = q

      A point in the antidiagonal is determined by its first co-ordinate (subtype version of Finset.antidiagonal_congr). This lemma is used by the ext tactic.

      theorem Finset.HasMulAntidiagonal.mulAntidiagonal_subtype_ext_iff {A : Type u_1} [CancelMonoid A] [HasMulAntidiagonal A] {n : A} {p q : (mulAntidiagonal n)} :
      p = q (↑p).1 = (↑q).1
      theorem Finset.HasAntidiagonal.antidiagonal_subtype_ext_iff {A : Type u_1} [AddCancelMonoid A] [HasAntidiagonal A] {n : A} {p q : (antidiagonal n)} :
      p = q (↑p).1 = (↑q).1
      theorem Finset.HasMulAntidiagonal.mulAntidiagonal_congr' {A : Type u_1} [CancelCommMonoid A] [HasMulAntidiagonal A] {p q : A × A} {n : A} (hp : p mulAntidiagonal n) (hq : q mulAntidiagonal n) :
      p = q p.2 = q.2

      A point in the mulAntidiagonal is determined by its second coordinate.

      See also Finset.mulAntidiagonal_congr.

      theorem Finset.HasAntidiagonal.antidiagonal_congr' {A : Type u_1} [AddCancelCommMonoid A] [HasAntidiagonal A] {p q : A × A} {n : A} (hp : p antidiagonal n) (hq : q antidiagonal n) :
      p = q p.2 = q.2

      A point in the antidiagonal is determined by its second coordinate.

      See also Finset.antidiagonal_congr.

      The disjoint union of mulAntidiagonals Σ (n : A), mulAntidiagonal n is equivalent to the product A × A. This is such an equivalence, obtained by mapping (n, (k, l)) to (k, l).

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

        The disjoint union of antidiagonals Σ (n : A), antidiagonal n is equivalent to the product A × A. This is such an equivalence, obtained by mapping (n, (k, l)) to (k, l).

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          @[reducible, inline]

          In a canonically ordered multiplicative monoid, the mulAntidiagonal can be constructed by filtering.

          Note that this is not an instance, as for sometimes a more efficient algorithm is available.

          Equations
          Instances For
            @[reducible, inline]

            In a canonically ordered additive monoid, the antidiagonal can be construct by filtering.

            Note that this is not an instance, as for some times a more efficient algorithm is available.

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