Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit eba7871

Browse files
committed
feat(data/finset/pointwise): |s| ∣ |s * t| (#18663)
1 parent f23a09c commit eba7871

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

src/data/finset/basic.lean

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,10 @@ lemma forall_mem_cons (h : a ∉ s) (p : α → Prop) :
570570
(∀ x, x ∈ cons a s h → p x) ↔ p a ∧ ∀ x, x ∈ s → p x :=
571571
by simp only [mem_cons, or_imp_distrib, forall_and_distrib, forall_eq]
572572

573+
/-- Useful in proofs by induction. -/
574+
lemma forall_of_forall_cons {p : α → Prop} {h : a ∉ s} (H : ∀ x, x ∈ cons a s h → p x) (x)
575+
(h : x ∈ s) : p x := H _ $ mem_cons.2 $ or.inr h
576+
573577
@[simp] lemma mk_cons {s : multiset α} (h : (a ::ₘ s).nodup) :
574578
(⟨a ::ₘ s, h⟩ : finset α) = cons a ⟨s, (nodup_cons.1 h).2⟩ (nodup_cons.1 h).1 := rfl
575579

@@ -2084,6 +2088,10 @@ lemma forall_mem_insert [decidable_eq α] (a : α) (s : finset α) (p : α → P
20842088
(∀ x, x ∈ insert a s → p x) ↔ p a ∧ ∀ x, x ∈ s → p x :=
20852089
by simp only [mem_insert, or_imp_distrib, forall_and_distrib, forall_eq]
20862090

2091+
/-- Useful in proofs by induction. -/
2092+
lemma forall_of_forall_insert [decidable_eq α] {p : α → Prop} {a : α} {s : finset α}
2093+
(H : ∀ x, x ∈ insert a s → p x) (x) (h : x ∈ s) : p x := H _ $ mem_insert_of_mem h
2094+
20872095
end finset
20882096

20892097
/-- Equivalence between the set of natural numbers which are `≥ k` and `ℕ`, given by `n → n - k`. -/

src/data/finset/n_ary.lean

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,37 @@ lemma image₂_right_identity {f : γ → β → γ} {b : β} (h : ∀ a, f a b
358358
image₂ f s {b} = s :=
359359
by rw [image₂_singleton_right, funext h, image_id']
360360

361+
/-- If each partial application of `f` is injective, and images of `s` under those partial
362+
applications are disjoint (but not necessarily distinct!), then the size of `t` divides the size of
363+
`finset.image₂ f s t`. -/
364+
lemma card_dvd_card_image₂_right (hf : ∀ a ∈ s, injective (f a))
365+
(hs : ((λ a, t.image $ f a) '' s).pairwise_disjoint id) :
366+
t.card ∣ (image₂ f s t).card :=
367+
begin
368+
classical,
369+
induction s using finset.induction with a s ha ih,
370+
{ simp },
371+
specialize ih (forall_of_forall_insert hf)
372+
(hs.subset $ set.image_subset _ $ coe_subset.2 $ subset_insert _ _),
373+
rw image₂_insert_left,
374+
by_cases h : disjoint (image (f a) t) (image₂ f s t),
375+
{ rw card_union_eq h,
376+
exact (card_image_of_injective _ $ hf _ $ mem_insert_self _ _).symm.dvd.add ih },
377+
simp_rw [←bUnion_image_left, disjoint_bUnion_right, not_forall] at h,
378+
obtain ⟨b, hb, h⟩ := h,
379+
rwa union_eq_right_iff_subset.2,
380+
exact (hs.eq (set.mem_image_of_mem _ $ mem_insert_self _ _)
381+
(set.mem_image_of_mem _ $ mem_insert_of_mem hb) h).trans_subset (image_subset_image₂_right hb),
382+
end
383+
384+
/-- If each partial application of `f` is injective, and images of `t` under those partial
385+
applications are disjoint (but not necessarily distinct!), then the size of `s` divides the size of
386+
`finset.image₂ f s t`. -/
387+
lemma card_dvd_card_image₂_left (hf : ∀ b ∈ t, injective (λ a, f a b))
388+
(ht : ((λ b, s.image $ λ a, f a b) '' t).pairwise_disjoint id) :
389+
s.card ∣ (image₂ f s t).card :=
390+
by { rw ←image₂_swap, exact card_dvd_card_image₂_right hf ht }
391+
361392
variables [decidable_eq α] [decidable_eq β]
362393

363394
lemma image₂_inter_union_subset_union :

src/data/finset/pointwise.lean

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,24 @@ coe_injective $ by { push_cast, exact set.smul_univ hs }
10781078
@[simp, to_additive] lemma card_smul_finset (a : α) (s : finset β) : (a • s).card = s.card :=
10791079
card_image_of_injective _ $ mul_action.injective _
10801080

1081+
/-- If the left cosets of `t` by elements of `s` are disjoint (but not necessarily distinct!), then
1082+
the size of `t` divides the size of `s * t`. -/
1083+
@[to_additive "If the left cosets of `t` by elements of `s` are disjoint (but not necessarily
1084+
distinct!), then the size of `t` divides the size of `s + t`."]
1085+
lemma card_dvd_card_smul_right {s : finset α} :
1086+
((• t) '' (s : set α)).pairwise_disjoint id → t.card ∣ (s • t).card :=
1087+
card_dvd_card_image₂_right (λ _ _, mul_action.injective _)
1088+
1089+
variables [decidable_eq α]
1090+
1091+
/-- If the right cosets of `s` by elements of `t` are disjoint (but not necessarily distinct!), then
1092+
the size of `s` divides the size of `s * t`. -/
1093+
@[to_additive "If the right cosets of `s` by elements of `t` are disjoint (but not necessarily
1094+
distinct!), then the size of `s` divides the size of `s + t`."]
1095+
lemma card_dvd_card_mul_left {s t : finset α} :
1096+
((λ b, s.image $ λ a, a * b) '' (t : set α)).pairwise_disjoint id → s.card ∣ (s * t).card :=
1097+
card_dvd_card_image₂_left (λ _ _, mul_left_injective _)
1098+
10811099
end group
10821100

10831101
section group_with_zero

0 commit comments

Comments
 (0)