Skip to content

Commit a4bf45d

Browse files
cjrlghseeli
andcommitted
feat(Data/Fintype/Card): existsUnique_notMem_image_of_injective_of_card_succ (#37720)
This pull requests adds a small theorem `existsUnique_notMem_image_of_injective_of_card_succ` to `Mathlib/Data/Fintype/Card` that says given an injective map f : α → β such that β has cardinality one more than α, there exists a unique element of β not in the image of f. This can be viewed as going in the opposite direction of `card_lt_of_injective_of_notMem`. This little fact is needed for our Latin Square PR #36698. Co-authored-by: Christopher J. R. Lloyd <cjl8zf@virginia.edu> Co-authored-by: George H. Seelinger <ghseeli@gmail.com>
1 parent 35fc736 commit a4bf45d

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

Mathlib/Data/Finset/Card.lean

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,9 @@ theorem card_eq_one : #s = 1 ↔ ∃ a, s = {a} := by
680680
cases s
681681
simp only [Multiset.card_eq_one, Finset.card, ← val_inj, singleton_val]
682682

683+
theorem card_eq_one_iff_existsUnique : #s = 1 ↔ ∃! a, a ∈ s := by
684+
simp [card_eq_one, Finset.singleton_iff_unique_mem]
685+
683686
theorem exists_eq_insert_iff [DecidableEq α] :
684687
(∃ a ∉ s, insert a s = t) ↔ s ⊆ t ∧ #s + 1 = #t := by
685688
constructor
@@ -738,6 +741,16 @@ theorem one_lt_card_iff_nontrivial : 1 < #s ↔ s.Nontrivial := by
738741
rw [← not_iff_not, not_lt, Finset.Nontrivial, ← Set.nontrivial_coe_sort,
739742
not_nontrivial_iff_subsingleton, card_le_one_iff_subsingleton_coe, coe_sort_coe]
740743

744+
/-- Given an injective map `f : α → β` for finite sets `s ⊂ α` and `t ⊂ β` such that `t` has
745+
cardinality one more than `s`, there exists a unique element of `t` not in `f(s)`. -/
746+
theorem existsUnique_notMem_image_of_injOn_of_card_eq_add_one
747+
{t : Finset β} [DecidableEq β]
748+
(hf : Set.InjOn f s) (hf' : Set.MapsTo f s t) (h : #t = #s + 1) :
749+
∃! x, x ∈ t ∧ x ∉ s.image f := by
750+
have : #(t \ s.image f) = 1 := by
751+
grind [card_sdiff_of_subset hf'.finsetImage_subset, card_image_of_injOn hf]
752+
simpa [card_eq_one_iff_existsUnique] using this
753+
741754
/-- If a Finset in a Pi type is nontrivial (has at least two elements), then
742755
its projection to some factor is nontrivial, and the fibers of the projection
743756
are proper subsets. -/

Mathlib/Data/Fintype/Card.lean

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,13 @@ theorem card_lt_of_injective_of_notMem (f : α → β) (h : Function.Injective f
255255
Finset.card_lt_univ_of_notMem (x := b) <| by
256256
rwa [← mem_coe, coe_map, coe_univ, Set.image_univ]
257257

258+
/-- Given an injective map `f : α → β` such that `β` has cardinality one more
259+
than `α`, there exists a unique element of `β` not in the image of `f`. -/
260+
theorem existsUnique_notMem_image_of_injective_of_card_eq_add_one [DecidableEq β]
261+
(f : α → β) (hf : f.Injective) (h : card β = card α + 1) : ∃! x, x ∉ univ.image f := by
262+
simpa using existsUnique_notMem_image_of_injOn_of_card_eq_add_one
263+
(s := .univ) (t := .univ) (Set.injOn_of_injective hf) (by simp) (by simpa)
264+
258265
theorem card_lt_of_injective_not_surjective (f : α → β) (h : Function.Injective f)
259266
(h' : ¬Function.Surjective f) : card α < card β :=
260267
let ⟨_y, hy⟩ := not_forall.1 h'

0 commit comments

Comments
 (0)