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 functionsf : ι → μ
with support contained ins
and such that the sum of its values equalsn : μ
.Finset.finAntidiagonal d n
: Computationally efficient special case ofFinset.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
.
finAntidiagonal d n
is the type of d
-tuples with sum n
.
TODO: deduplicate with the less general Finset.Nat.antidiagonalTuple
.
Equations
- Finset.finAntidiagonal d n = ↑(Finset.finAntidiagonal.aux d n)
Instances For
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
.
Equations
- One or more equations did not get rendered due to their size.
- Finset.finAntidiagonal.aux 0 n = if h : n = 0 then ⟨{0}, ⋯⟩ else ⟨∅, ⋯⟩
Instances For
ι → μ
#
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.
The finset of functions ι → μ
with support contained in s
and sum n
.
Equations
- One or more equations did not get rendered due to their size.