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

Commit 5a91d05

Browse files
committed
feat(data/finset/lattice): add sup_image (#7428)
This also renames `finset.map_sup` to `finset.sup_map` to match `finset.sup_insert` and `finset.sup_singleton`. The `inf` versions are added too.
1 parent 3773525 commit 5a91d05

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

src/data/finset/fold.lean

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ begin
7171
{ apply fold_insert h },
7272
end
7373

74+
theorem fold_image_idem [decidable_eq α] {g : γ → α} {s : finset γ}
75+
[hi : is_idempotent β op] :
76+
(image g s).fold op b f = s.fold op b (f ∘ g) :=
77+
begin
78+
induction s using finset.cons_induction with x xs hx ih,
79+
{ rw [fold_empty, image_empty, fold_empty] },
80+
{ haveI := classical.dec_eq γ,
81+
rw [fold_cons, cons_eq_insert, image_insert, fold_insert_idem, ih], }
82+
end
83+
7484
lemma fold_op_rel_iff_and
7585
{r : β → β → Prop} (hr : ∀ {x y z}, r x (op y z) ↔ (r x y ∧ r x z)) {c : β} :
7686
r c (s.fold op b f) ↔ (r c b ∧ ∀ x∈s, r c (f x)) :=

src/data/finset/lattice.lean

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ fold_cons h
3737
@[simp] lemma sup_insert [decidable_eq β] {b : β} : (insert b s : finset β).sup f = f b ⊔ s.sup f :=
3838
fold_insert_idem
3939

40+
lemma sup_image [decidable_eq β] (s : finset γ) (f : γ → β) (g : β → α):
41+
(s.image f).sup g = s.sup (g ∘ f) :=
42+
fold_image_idem
43+
44+
@[simp] lemma sup_map (s : finset γ) (f : γ ↪ β) (g : β → α) :
45+
(s.map f).sup g = s.sup (g ∘ f) :=
46+
fold_map
47+
4048
@[simp] lemma sup_singleton {b : β} : ({b} : finset β).sup f = f b :=
4149
sup_singleton
4250

@@ -63,10 +71,6 @@ sup_le_iff.2
6371
lemma le_sup {b : β} (hb : b ∈ s) : f b ≤ s.sup f :=
6472
sup_le_iff.1 (le_refl _) _ hb
6573

66-
@[simp] lemma map_sup (f : γ ↪ β) (g : β → α) (s : finset γ) :
67-
(s.map f).sup g = s.sup (g ∘ f) :=
68-
by simp [finset.sup]
69-
7074
lemma sup_mono_fun {g : β → α} (h : ∀b∈s, f b ≤ g b) : s.sup f ≤ s.sup g :=
7175
sup_le (λ b hb, le_trans (h b hb) (le_sup hb))
7276

@@ -180,6 +184,14 @@ fold_empty
180184
@[simp] lemma inf_insert [decidable_eq β] {b : β} : (insert b s : finset β).inf f = f b ⊓ s.inf f :=
181185
fold_insert_idem
182186

187+
lemma inf_image [decidable_eq β] (s : finset γ) (f : γ → β) (g : β → α):
188+
(s.image f).inf g = s.inf (g ∘ f) :=
189+
fold_image_idem
190+
191+
@[simp] lemma inf_map (s : finset γ) (f : γ ↪ β) (g : β → α) :
192+
(s.map f).inf g = s.inf (g ∘ f) :=
193+
fold_map
194+
183195
@[simp] lemma inf_singleton {b : β} : ({b} : finset β).inf f = f b :=
184196
inf_singleton
185197

@@ -198,10 +210,6 @@ le_inf_iff.1 (le_refl _) _ hb
198210
lemma le_inf {a : α} : (∀b ∈ s, a ≤ f b) → a ≤ s.inf f :=
199211
le_inf_iff.2
200212

201-
@[simp] lemma map_inf (f : γ ↪ β) (g : β → α) (s : finset γ) :
202-
(s.map f).inf g = s.inf (g ∘ f) :=
203-
by simp [finset.inf]
204-
205213
lemma inf_mono_fun {g : β → α} (h : ∀b∈s, f b ≤ g b) : s.inf f ≤ s.inf g :=
206214
le_inf (λ b hb, le_trans (inf_le hb) (h b hb))
207215

0 commit comments

Comments
 (0)