Finite-set infrastructure #
Finset.exists_nat_prod_ltbounds both coordinates of a finite set of pairs of natural numbers.Finset.exists_perm_eqOn_le_applygives a permutation ofℕfixing one finite set pointwise and carrying a disjoint one past any bound.TauCeti.product_union_eq_union_productrearranges a union of products of finsets.TauCeti.card_nonempty_finsetcounts the nonempty finsets of a finite type.TauCeti.card_even_card_finsetandTauCeti.card_odd_card_finsetcount the finsets of a nonempty finite type by the parity of their cardinality: each parity accounts for exactly half of them.Finset.sum_powerset_neg_one_pow_card_of_ringevaluates the alternating sum over the subsets of a finset in an arbitrary ring.Finset.sum_powerset_neg_one_pow_mul_eq_zeropairs subsets that differ by one element to cancel a signed sum.Finset.sum_Icc_neg_one_pow_card_sub_card_leftandFinset.sum_Icc_neg_one_pow_card_sub_card_rightcompute the Möbius function of the Boolean lattice of finsets: the signed sum over an interval[s, t]is1ifs = tand0otherwise.Finset.card_symmDiff_add_two_mul_card_interandFinset.even_card_symmDiff_iffcompare the cardinality of a symmetric difference with the cardinalities of its two arguments: exactly, and modulo two.Finset.map_swap_pair,Finset.map_swap_pair_rightandFinset.map_swap_eq_self_iffdescribe how a transposition moves a finset around, andFinset.mem_map_swap_symmDiff_pair_iff,Finset.involutive_map_swap_symmDiff_pairandFinset.map_swap_symmDiff_pair_eq_self_iffdo the same for a transposition composed with the toggle of the two transposed points.Finset.sum_filter_le_sum_filter_lereindexes a double sum over chains in a finite type with a≤relation.Finset.sum_eq_twoandFinset.sum_eq_fourreduce a sum over a finite type, and a double sum over a pair of finite types, to the values of its summand at the two points where it is supported, and at the four cells of a rectangle.TauCeti.sum_piecewise_eq_sum_update_of_card_eq_succreindexes a sum ofFinset.piecewiseterms over the subsets of size one less thancard ιas a sum ofFunction.updateterms overι. It is what turns a formula indexed by "all but one point" into one indexed by the omitted point, as in the change-origin and derivative computations for multilinear series.
A union of two products of finsets can be rearranged by distributing each product over its union coordinate.
The number of nonempty subsets of a finite type is 2ⁿ - 1. The 2ⁿ subsets of an
n-element type are the nonempty ones together with the empty set, so the nonempty ones number
2ⁿ - 1.
The subsets of even cardinality of a finite type number 2 ^ (n - 1). On a nonempty type
that is half of all 2 ^ n subsets: deleting a fixed point from the subsets that contain it, and
adjoining it to those that do not, is an involution of the subsets of ι reversing the parity of
the cardinality, so the two parities are equinumerous and together exhaust the 2 ^ n subsets. The
empty type is the exception to that halving, and is covered separately: it has no fixed point to
flip, and its lone subset ∅ is even with no odd subset to pair it with, so the two parities are
not equinumerous there — but 2 ^ (0 - 1) = 1 counts that one even subset all the same, which is
why the statement needs no nonemptiness hypothesis. (Its odd counterpart
TauCeti.card_odd_card_finset does need one: the empty type has no subset of odd cardinality.)
The symmetric difference and the intersection account for both cardinalities. The symmetric difference is the union minus the intersection, and the union and the intersection together have the two cardinalities as their total.
A transposition fixes the pair it transposes.
A transposition moves a pair along its first index, provided the second index is fixed.
A transposition fixes a finset exactly when the two transposed points have the same membership.
Membership in a transposed finset with the two transposed points toggled.
Transposing two points of a finset and toggling both is an involution.
Transposing two points of a finset and toggling both fixes it exactly when the two points have opposite membership.
A double sum over a chain a ≤ b ≤ c, summed first over b and then over c, can instead
be summed first over c and then over the interval of possible b.
The alternating sum over the subsets of a finset is 1 for the empty finset and 0
otherwise, in an arbitrary ring. Mathlib's Finset.sum_powerset_neg_one_pow_card is the case of
the integers.
A telescoping signed sum over the subsets of P vanishes. If, for each i ∈ P, the
summand g i changes by h i when i is adjoined to a set not containing it, then
∑_{T ⊆ P} (-1)^{|T|} (∑_{i ∈ P} g i T + ∑_{i ∈ T} h i T) = 0: for fixed i, the sets T ∌ i
and T ∪ {i} cancel in pairs.
The Möbius function of the Boolean lattice, measured from the bottom. The sets between s
and t are s ∪ u for u ⊆ t \ s, so the signed sum ∑_{s ⊆ u ⊆ t} (-1)^{|u| - |s|} is the
alternating sum over the subsets of t \ s: it is 1 if s = t and 0 otherwise.
The Möbius function of the Boolean lattice, measured from the top. The signed sum
∑_{s ⊆ u ⊆ t} (-1)^{|t| - |u|} is 1 if s = t and 0 otherwise: its terms differ from those
of Finset.sum_Icc_neg_one_pow_card_sub_card_left by the common sign (-1)^{|t| - |s|}.
The sum over a finite type of a function that vanishes away from two distinct points is the sum of its values at those two points.
The double sum over a pair of finite types of a function that vanishes outside the four cells
of the rectangle i, i' by j, j' is the sum of its four values there.
Summing over the subsets of size one less than card ι is summing over the points. Such a
subset is the complement of a singleton, and Finset.piecewise against such a complement is
Function.update at the missing point, so a sum of F over those subsets is a sum over ι.
Use it to turn a formula indexed by the subsets that omit a single point into one indexed by the omitted point.