Upstream candidates: small Set.ncard lemmas #
The Lean namespace is the upstream one (Set), so promotion to mathlib is a
copy-paste. See DESIGN.md "Mirror directory".
Contents (target file: Mathlib/Data/Set/Card.lean) #
Set.ncard_pair_le—({a, b} : Set α).ncard ≤ 2. Unconditional companion toSet.ncard_pair(which gives= 2undera ≠ b); collapses thencard_insert_le+ncard_singletonboilerplate when bounding the cardinality of a literal pair without first ruling out collisions.Set.ncard_triple_le—({a, b, c} : Set α).ncard ≤ 3. Same pattern, one level deeper.Set.ncard_eq_card_coe—s.ncard = Fintype.card sunder[Fintype s]. BridgesSet.ncardto theFintype.card-based dimension lemmas (Module.finrank_pi,LinearMap.toMatrix) without theSet.ncard_eq_toFinset_card'/Set.toFinset_cardtwo-step rewrite.Set.exists_injective_fin_of_le_ncard— fromn ≤ s.ncard, indexndistinct elements ofsbyFin n. Companion toSet.exists_subset_card_eq(which returns the subset); collapses theexists_subset_card_eq→Set.Finite.fintype→Set.ncard_eq_toFinset_card'/Set.toFinset_card→Fintype.equivFinOfCardEqchain.Set.ncard_union_range_of_injective— addingknew elements, listed injectively byFin k, addskto the cardinality:(s ∪ range z).ncard = s.ncard + k. FusesSet.ncard_union_eq, the disjointness ofsandrange z,Set.ncard_range_of_injectiveandNat.card_fin. The combinatorial-rigidity project uses it to count the bodies of an ear or of a chain of bridges inMolecular/Molecule/Pencil/MainComponent/(Cut.lean,Ear.lean,Short.lean,Orbit.lean,SplitOff.lean).
An unconditional bound for the cardinality of a literal pair: it is at most 2
regardless of whether a = b. The companion Set.ncard_pair gives the exact = 2
under a ≠ b.
A direct bridge between Set.ncard and Fintype.card: s.ncard = Fintype.card ↥s
under [Fintype s]. The Set.ncard_eq_toFinset_card' (s.ncard = s.toFinset.card) +
Set.toFinset_card (s.toFinset.card = Fintype.card s) two-step rewrite collapses to
this one lemma.
From n ≤ s.ncard, index n distinct elements of s by Fin n. Companion to
Set.exists_subset_card_eq: that lemma returns the size-n subset; this one returns
the Fin n-indexing of its elements.
Adding k new elements, listed injectively by Fin k, to a finite set adds k to its
cardinality: s and range z are disjoint, and range z has k elements.