Skip to content

Commit 392e014

Browse files
committed
feat(Pointwise): cardinality of product set in GroupWithZero (#24578)
This PR: * generalises the assumptions to `card_le_card_image₂_left` and `card_le_card_image₂_right` and golf these: they previously required injectivity everywhere despite using it in only one place. (These lemmas were also used in exactly one place each in mathlib) * adds `card_le_card_mul_left_of_injective` and `card_le_card_mul_right_of_injective` which generalise the typeclass assumptions on the existing `card_le_card_mul_left` and `card_le_card_mul_right` * uses the above to add versions of `card_le_card_mul_left` and `card_le_card_mul_right` in groups with zero. This is useful for applying the pointwise constructions to fields In fact, the first versions of all the above lemmas were written in this generality, but that was seemingly lost during an upstream.
1 parent 957cb8b commit 392e014

File tree

3 files changed

+54
-16
lines changed

3 files changed

+54
-16
lines changed

Mathlib/Algebra/Group/Pointwise/Finset/Basic.lean

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,28 @@ lemma inf_mul_right {β} [SemilatticeInf β] [OrderTop β] (s t : Finset α) (f
489489
inf (s * t) f = inf t fun y ↦ inf s (f <| · * y) :=
490490
inf_image₂_right ..
491491

492+
/--
493+
See `card_le_card_mul_left` for a more convenient but less general version for types with a
494+
left-cancellative multiplication.
495+
-/
496+
@[to_additive
497+
"See `card_le_card_add_left` for a more convenient but less general version for types with a
498+
left-cancellative addition."]
499+
lemma card_le_card_mul_left_of_injective (has : a ∈ s) (ha : Function.Injective (a * ·)) :
500+
#t ≤ #(s * t) :=
501+
card_le_card_image₂_left _ has ha
502+
503+
/--
504+
See `card_le_card_mul_right` for a more convenient but less general version for types with a
505+
right-cancellative multiplication.
506+
-/
507+
@[to_additive
508+
"See `card_le_card_add_right` for a more convenient but less general version for types with a
509+
right-cancellative addition."]
510+
lemma card_le_card_mul_right_of_injective (hat : a ∈ t) (ha : Function.Injective (· * a)) :
511+
#s ≤ #(s * t) :=
512+
card_le_card_image₂_right _ hat ha
513+
492514
end Mul
493515

494516
/-! ### Finset subtraction/division -/
@@ -1154,7 +1176,7 @@ theorem singleton_mul_inter (a : α) (s t : Finset α) : {a} * (s ∩ t) = {a} *
11541176

11551177
@[to_additive]
11561178
theorem card_le_card_mul_left {s : Finset α} (hs : s.Nonempty) : #t ≤ #(s * t) :=
1157-
card_le_card_image₂_left _ hs mul_right_injective
1179+
have ⟨_, ha⟩ := hs; card_le_card_mul_left_of_injective ha (mul_right_injective _)
11581180

11591181
/--
11601182
The size of `s * s` is at least the size of `s`, version with left-cancellative multiplication.
@@ -1187,7 +1209,7 @@ theorem inter_mul_singleton (s t : Finset α) (a : α) : s ∩ t * {a} = s * {a}
11871209

11881210
@[to_additive]
11891211
theorem card_le_card_mul_right (ht : t.Nonempty) : #s ≤ #(s * t) :=
1190-
card_le_card_image₂_right _ ht mul_left_injective
1212+
have ⟨_, ha⟩ := ht; card_le_card_mul_right_of_injective ha (mul_left_injective _)
11911213

11921214
/--
11931215
The size of `s * s` is at least the size of `s`, version with right-cancellative multiplication.
@@ -1231,10 +1253,10 @@ section Group
12311253
variable [Group α] [DecidableEq α] {s t : Finset α}
12321254

12331255
@[to_additive] lemma card_le_card_div_left (hs : s.Nonempty) : #t ≤ #(s / t) :=
1234-
card_le_card_image₂_left _ hs fun _ div_right_injective
1256+
have ⟨_, ha⟩ := hs; card_le_card_image₂_left _ ha div_right_injective
12351257

12361258
@[to_additive] lemma card_le_card_div_right (ht : t.Nonempty) : #s ≤ #(s / t) :=
1237-
card_le_card_image₂_right _ ht fun _ div_left_injective
1259+
have ⟨_, ha⟩ := ht; card_le_card_image₂_right _ ha div_left_injective
12381260

12391261
@[to_additive] lemma card_le_card_div_self : #s ≤ #(s / s) := by
12401262
cases s.eq_empty_or_nonempty <;> simp [card_le_card_div_left, *]

Mathlib/Algebra/GroupWithZero/Pointwise/Finset.lean

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,27 @@ assert_not_exists MulAction Ring
1717
open scoped Pointwise
1818

1919
namespace Finset
20-
variable {α β : Type*} [DecidableEq β]
20+
variable {α : Type*}
21+
22+
section Mul
23+
24+
variable [Mul α] [Zero α] [DecidableEq α] {s t : Finset α} {a : α}
25+
26+
lemma card_le_card_mul_left₀ [IsLeftCancelMulZero α] (has : a ∈ s) (ha : a ≠ 0) : #t ≤ #(s * t) :=
27+
card_le_card_mul_left_of_injective has (mul_right_injective₀ ha)
28+
29+
lemma card_le_card_mul_right₀ [IsRightCancelMulZero α] (hat : a ∈ t) (ha : a ≠ 0) : #s ≤ #(s * t) :=
30+
card_le_card_mul_right_of_injective hat (mul_left_injective₀ ha)
31+
32+
lemma card_le_card_mul_self₀ [IsLeftCancelMulZero α] : #s ≤ #(s * s) := by
33+
obtain hs | hs := (s.erase 0).eq_empty_or_nonempty
34+
· rw [erase_eq_empty_iff] at hs
35+
obtain rfl | rfl := hs <;> simp
36+
obtain ⟨a, ha⟩ := hs
37+
simp only [mem_erase, ne_eq] at ha
38+
exact card_le_card_mul_left₀ ha.2 ha.1
39+
40+
end Mul
2141

2242
section MulZeroClass
2343
variable [DecidableEq α] [MulZeroClass α] {s : Finset α}

Mathlib/Data/Finset/NAry.lean

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -217,17 +217,13 @@ theorem image₂_inter_singleton [DecidableEq α] (s₁ s₂ : Finset α) (hf :
217217
image₂ f (s₁ ∩ s₂) {b} = image₂ f s₁ {b} ∩ image₂ f s₂ {b} := by
218218
simp_rw [image₂_singleton_right, image_inter _ _ hf]
219219

220-
theorem card_le_card_image₂_left {s : Finset α} (hs : s.Nonempty) (hf : ∀ a, Injective (f a)) :
221-
#t ≤ #(image₂ f s t) := by
222-
obtain ⟨a, ha⟩ := hs
223-
rw [← card_image₂_singleton_left _ (hf a)]
224-
exact card_le_card (image₂_subset_right <| singleton_subset_iff.2 ha)
225-
226-
theorem card_le_card_image₂_right {t : Finset β} (ht : t.Nonempty)
227-
(hf : ∀ b, Injective fun a => f a b) : #s ≤ #(image₂ f s t) := by
228-
obtain ⟨b, hb⟩ := ht
229-
rw [← card_image₂_singleton_right _ (hf b)]
230-
exact card_le_card (image₂_subset_left <| singleton_subset_iff.2 hb)
220+
theorem card_le_card_image₂_left {s : Finset α} (ha : a ∈ s) (hf : Injective (f a)) :
221+
#t ≤ #(image₂ f s t) :=
222+
card_le_card_of_injOn (f a) (fun _ hb ↦ mem_image₂_of_mem ha hb) hf.injOn
223+
224+
theorem card_le_card_image₂_right {t : Finset β} (hb : b ∈ t) (hf : Injective (f · b)) :
225+
#s ≤ #(image₂ f s t) :=
226+
card_le_card_of_injOn (f · b) (fun _ ha ↦ mem_image₂_of_mem ha hb) hf.injOn
231227

232228
variable {s t}
233229

0 commit comments

Comments
 (0)