Recovering a finite set and its weights from a tally #
An exact count rules out missing elements in a subset. If the observed weights dominate the expected weights pointwise, an exact sum then rules out any overestimate.
theorem Finset.eq_and_eqOn_of_card_eq_of_sum_eq {α : Type u_1} {M : Type u_2} [AddCommMonoid M] [PartialOrder M] [IsOrderedCancelAddMonoid M] {s t : Finset α} {f g : α → M} (hsub : s ⊆ t) (hle : ∀ a ∈ s, g a ≤ f a) (hcard : s.card = t.card) (hsum : ∑ a ∈ s, f a = ∑ a ∈ t, g a) :
A subset with the expected cardinality and total weight has exactly the expected elements and weights, provided every observed weight is at least its expected weight.