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

Commit b5a6422

Browse files
committed
feat(data/finset): add lemmas (#9209)
* add `finset.image_id'`, a version of `finset.image_id` using `λ x, x` instead of `id`; * add some lemmas about `finset.bUnion`, `finset.sup`, and `finset.sup'`.
1 parent 524ded6 commit b5a6422

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

src/data/finset/basic.lean

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,6 +1949,8 @@ multiset.erase_dup_eq_self.2 (nodup_map_on H s.2)
19491949
theorem image_id [decidable_eq α] : s.image id = s :=
19501950
ext $ λ _, by simp only [mem_image, exists_prop, id, exists_eq_right]
19511951

1952+
@[simp] theorem image_id' [decidable_eq α] : s.image (λ x, x) = s := image_id
1953+
19521954
theorem image_image [decidable_eq γ] {g : β → γ} : (s.image f).image g = s.image (g ∘ f) :=
19531955
eq_of_veq $ by simp only [image_val, erase_dup_map_erase_dup_eq, multiset.map_map]
19541956

@@ -2673,6 +2675,13 @@ lemma erase_bUnion (f : α → finset β) (s : finset α) (b : β) :
26732675
(s.bUnion f).erase b = s.bUnion (λ x, (f x).erase b) :=
26742676
by { ext, simp only [finset.mem_bUnion, iff_self, exists_and_distrib_left, finset.mem_erase] }
26752677

2678+
@[simp] lemma bUnion_nonempty : (s.bUnion t).nonempty ↔ ∃ x ∈ s, (t x).nonempty :=
2679+
by simp [finset.nonempty, ← exists_and_distrib_left, @exists_swap α]
2680+
2681+
lemma nonempty.bUnion (hs : s.nonempty) (ht : ∀ x ∈ s, (t x).nonempty) :
2682+
(s.bUnion t).nonempty :=
2683+
bUnion_nonempty.2 $ hs.imp $ λ x hx, ⟨hx, ht x hx⟩
2684+
26762685
end bUnion
26772686

26782687
/-! ### prod -/

src/data/finset/lattice.lean

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ begin
6262
exact ⟨λ k b hb, k _ _ hb rfl, λ k a' b hb h, h ▸ k _ hb⟩,
6363
end
6464

65+
@[simp] lemma sup_bUnion [decidable_eq β] (s : finset γ) (t : γ → finset β) :
66+
(s.bUnion t).sup f = s.sup (λ x, (t x).sup f) :=
67+
eq_of_forall_ge_iff $ λ c, by simp [@forall_swap _ β]
68+
6569
lemma sup_const {s : finset β} (h : s.nonempty) (c : α) : s.sup (λ _, c) = c :=
6670
eq_of_forall_ge_iff $ λ b, sup_le_iff.trans h.forall_const
6771

@@ -213,6 +217,13 @@ lemma inf_union [decidable_eq β] : (s₁ ∪ s₂).inf f = s₁.inf f ⊓ s₂.
213217
theorem inf_congr {f g : β → α} (hs : s₁ = s₂) (hfg : ∀a∈s₂, f a = g a) : s₁.inf f = s₂.inf g :=
214218
by subst hs; exact finset.fold_congr hfg
215219

220+
@[simp] lemma inf_bUnion [decidable_eq β] (s : finset γ) (t : γ → finset β) :
221+
(s.bUnion t).inf f = s.inf (λ x, (t x).inf f) :=
222+
@sup_bUnion (order_dual α) _ _ _ _ _ _ _
223+
224+
lemma inf_const {s : finset β} (h : s.nonempty) (c : α) : s.inf (λ _, c) = c :=
225+
@sup_const (order_dual α) _ _ _ h _
226+
216227
lemma le_inf_iff {a : α} : a ≤ s.inf f ↔ ∀ b ∈ s, a ≤ f b :=
217228
@sup_le_iff (order_dual α) _ _ _ _ _
218229

@@ -337,6 +348,11 @@ begin
337348
exact bex_congr (λ b hb, with_bot.coe_lt_coe),
338349
end
339350

351+
lemma sup'_bUnion [decidable_eq β] {s : finset γ} (Hs : s.nonempty) {t : γ → finset β}
352+
(Ht : ∀ b, (t b).nonempty) :
353+
(s.bUnion t).sup' (Hs.bUnion (λ b _, Ht b)) f = s.sup' Hs (λ b, (t b).sup' (Ht b) f) :=
354+
eq_of_forall_ge_iff $ λ c, by simp [@forall_swap _ β]
355+
340356
lemma comp_sup'_eq_sup'_comp [semilattice_sup γ] {s : finset β} (H : s.nonempty)
341357
{f : β → α} (g : α → γ) (g_sup : ∀ x y, g (x ⊔ y) = g x ⊔ g y) :
342358
g (s.sup' H f) = s.sup' H (g ∘ f) :=
@@ -384,6 +400,14 @@ lemma sup'_mem
384400
t.sup' H p ∈ s :=
385401
sup'_induction H p w h
386402

403+
@[congr] lemma sup'_congr {t : finset β} {f g : β → α} (h₁ : s = t) (h₂ : ∀ x ∈ s, f x = g x) :
404+
s.sup' H f = t.sup' (h₁ ▸ H) g :=
405+
begin
406+
subst s,
407+
refine eq_of_forall_ge_iff (λ c, _),
408+
simp only [sup'_le_iff, h₂] { contextual := tt }
409+
end
410+
387411
end sup'
388412

389413
section inf'
@@ -436,6 +460,11 @@ lemma inf'_le {b : β} (h : b ∈ s) : s.inf' ⟨b, h⟩ f ≤ f b :=
436460
@[simp] lemma inf'_lt_iff [is_total α (≤)] {a : α} : s.inf' H f < a ↔ (∃ b ∈ s, f b < a) :=
437461
@lt_sup'_iff (order_dual α) _ _ _ H f _ _
438462

463+
lemma inf'_bUnion [decidable_eq β] {s : finset γ} (Hs : s.nonempty) {t : γ → finset β}
464+
(Ht : ∀ b, (t b).nonempty) :
465+
(s.bUnion t).inf' (Hs.bUnion (λ b _, Ht b)) f = s.inf' Hs (λ b, (t b).inf' (Ht b) f) :=
466+
@sup'_bUnion (order_dual α) _ _ _ _ _ _ Hs _ Ht
467+
439468
lemma comp_inf'_eq_inf'_comp [semilattice_inf γ] {s : finset β} (H : s.nonempty)
440469
{f : β → α} (g : α → γ) (g_inf : ∀ x y, g (x ⊓ y) = g x ⊓ g y) :
441470
g (s.inf' H f) = s.inf' H (g ∘ f) :=
@@ -453,6 +482,10 @@ lemma inf'_mem (s : set α) (w : ∀ x y ∈ s, x ⊓ y ∈ s)
453482
t.inf' H p ∈ s :=
454483
inf'_induction H p w h
455484

485+
@[congr] lemma inf'_congr {t : finset β} {f g : β → α} (h₁ : s = t) (h₂ : ∀ x ∈ s, f x = g x) :
486+
s.inf' H f = t.inf' (h₁ ▸ H) g :=
487+
@sup'_congr (order_dual α) _ _ _ H _ _ _ h₁ h₂
488+
456489
end inf'
457490

458491
section sup

0 commit comments

Comments
 (0)