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

Commit 442a83d

Browse files
committed
feat(data/finset/lattice): sup'/inf' lemmas (#18989)
Match (most of) the lemmas between `finset.sup`/`finset.inf` and `finset.sup'`/`finset.inf'`. Also golf two proofs using `eq_of_forall_ge_iff` to make sure both APIs prove their lemmas in as closely as possible a way. Also define `finset.nontrivial` to match `set.nontrivial`.
1 parent ffde2d8 commit 442a83d

5 files changed

Lines changed: 140 additions & 60 deletions

File tree

src/data/dfinsupp/multiset.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@ def to_dfinsupp : multiset α →+ Π₀ a : α, ℕ :=
5353
@[simp] lemma to_dfinsupp_apply (s : multiset α) (a : α) :
5454
s.to_dfinsupp a = s.count a := rfl
5555

56-
@[simp] lemma to_dfinsupp_support (s : multiset α) :
57-
s.to_dfinsupp.support = s.to_finset :=
58-
(finset.filter_eq_self _).mpr (λ x hx, count_ne_zero.mpr $ multiset.mem_to_finset.1 hx)
56+
@[simp] lemma to_dfinsupp_support (s : multiset α) : s.to_dfinsupp.support = s.to_finset :=
57+
finset.filter_true_of_mem $ λ x hx, count_ne_zero.mpr $ multiset.mem_to_finset.1 hx
5958

6059
@[simp] lemma to_dfinsupp_replicate (a : α) (n : ℕ) :
6160
to_dfinsupp (multiset.replicate n a) = dfinsupp.single a n :=

src/data/finset/basic.lean

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -536,14 +536,27 @@ by rw [←coe_ssubset, coe_singleton, set.ssubset_singleton_iff, coe_eq_empty]
536536
lemma eq_empty_of_ssubset_singleton {s : finset α} {x : α} (hs : s ⊂ {x}) : s = ∅ :=
537537
ssubset_singleton_iff.1 hs
538538

539-
lemma eq_singleton_or_nontrivial (ha : a ∈ s) : s = {a} ∨ (s : set α).nontrivial :=
539+
/-- A finset is nontrivial if it has at least two elements. -/
540+
@[reducible] protected def nontrivial (s : finset α) : Prop := (s : set α).nontrivial
541+
542+
@[simp] lemma not_nontrivial_empty : ¬ (∅ : finset α).nontrivial := by simp [finset.nontrivial]
543+
544+
@[simp] lemma not_nontrivial_singleton : ¬ ({a} : finset α).nontrivial :=
545+
by simp [finset.nontrivial]
546+
547+
lemma nontrivial.ne_singleton (hs : s.nontrivial) : s ≠ {a} :=
548+
by { rintro rfl, exact not_nontrivial_singleton hs }
549+
550+
lemma eq_singleton_or_nontrivial (ha : a ∈ s) : s = {a} ∨ s.nontrivial :=
540551
by { rw ←coe_eq_singleton, exact set.eq_singleton_or_nontrivial ha }
541552

542-
lemma nonempty.exists_eq_singleton_or_nontrivial :
543-
s.nonempty → (∃ a, s = {a}) ∨ (s : set α).nontrivial :=
553+
lemma nontrivial_iff_ne_singleton (ha : a ∈ s) : s.nontrivial ↔ s ≠ {a} :=
554+
⟨nontrivial.ne_singleton, (eq_singleton_or_nontrivial ha).resolve_left⟩
555+
556+
lemma nonempty.exists_eq_singleton_or_nontrivial : s.nonempty → (∃ a, s = {a}) ∨ s.nontrivial :=
544557
λ ⟨a, ha⟩, (eq_singleton_or_nontrivial ha).imp_left $ exists.intro a
545558

546-
instance [nonempty α] : nontrivial (finset α) :=
559+
instance nontrivial' [nonempty α] : nontrivial (finset α) :=
547560
‹nonempty α›.elim $ λ a, ⟨⟨{a}, ∅, singleton_ne_empty _⟩⟩
548561

549562
instance [is_empty α] : unique (finset α) :=
@@ -577,6 +590,8 @@ lemma forall_of_forall_cons {p : α → Prop} {h : a ∉ s} (H : ∀ x, x ∈ co
577590
@[simp] lemma mk_cons {s : multiset α} (h : (a ::ₘ s).nodup) :
578591
(⟨a ::ₘ s, h⟩ : finset α) = cons a ⟨s, (nodup_cons.1 h).2⟩ (nodup_cons.1 h).1 := rfl
579592

593+
@[simp] lemma cons_empty (a : α) : cons a ∅ (not_mem_empty _) = {a} := rfl
594+
580595
@[simp] lemma nonempty_cons (h : a ∉ s) : (cons a s h).nonempty := ⟨a, mem_cons.2 $ or.inl rfl⟩
581596

582597
@[simp] lemma nonempty_mk {m : multiset α} {hm} : (⟨m, hm⟩ : finset α).nonempty ↔ m ≠ 0 :=
@@ -1379,7 +1394,7 @@ lemma inter_sdiff (s t u : finset α) : s ∩ (t \ u) = s ∩ t \ u := by { ext
13791394

13801395
@[simp] lemma sdiff_inter_self (s₁ s₂ : finset α) : (s₂ \ s₁) ∩ s₁ = ∅ := inf_sdiff_self_left
13811396

1382-
@[simp] lemma sdiff_self (s₁ : finset α) : s₁ \ s₁ = ∅ := sdiff_self
1397+
@[simp] protected lemma sdiff_self (s₁ : finset α) : s₁ \ s₁ = ∅ := sdiff_self
13831398

13841399
lemma sdiff_inter_distrib_right (s t u : finset α) : s \ (t ∩ u) = (s \ t) ∪ (s \ u) := sdiff_inf
13851400

@@ -1531,7 +1546,7 @@ by rw [←sdiff_singleton_eq_erase, sdiff_sdiff_eq_sdiff_union (singleton_subset
15311546
union_comm]
15321547

15331548
lemma sdiff_erase_self (ha : a ∈ s) : s \ s.erase a = {a} :=
1534-
by rw [sdiff_erase ha, sdiff_self, insert_emptyc_eq]
1549+
by rw [sdiff_erase ha, finset.sdiff_self, insert_emptyc_eq]
15351550

15361551
lemma sdiff_sdiff_self_left (s t : finset α) : s \ (s \ t) = s ∩ t := sdiff_sdiff_right_self
15371552

@@ -1588,10 +1603,10 @@ theorem sizeof_lt_sizeof_of_mem [has_sizeof α] {x : α} {s : finset α} (hx : x
15881603

15891604
@[simp] theorem attach_empty : attach (∅ : finset α) = ∅ := rfl
15901605

1591-
@[simp] lemma attach_nonempty_iff (s : finset α) : s.attach.nonempty ↔ s.nonempty :=
1606+
@[simp] lemma attach_nonempty_iff {s : finset α} : s.attach.nonempty ↔ s.nonempty :=
15921607
by simp [finset.nonempty]
15931608

1594-
@[simp] lemma attach_eq_empty_iff (s : finset α) : s.attach = ∅ ↔ s = ∅ :=
1609+
@[simp] lemma attach_eq_empty_iff {s : finset α} : s.attach = ∅ ↔ s = ∅ :=
15951610
by simpa [eq_empty_iff_forall_not_mem]
15961611

15971612
/-! ### piecewise -/
@@ -1747,7 +1762,7 @@ end decidable_pi_exists
17471762

17481763
/-! ### filter -/
17491764
section filter
1750-
variables (p q : α → Prop) [decidable_pred p] [decidable_pred q]
1765+
variables (p q : α → Prop) [decidable_pred p] [decidable_pred q] {s : finset α}
17511766

17521767
/-- `filter p s` is the set of elements of `s` that satisfy `p`. -/
17531768
def filter (s : finset α) : finset α := ⟨_, s.2.filter p⟩
@@ -1772,38 +1787,34 @@ variable (p)
17721787
theorem filter_filter (s : finset α) : (s.filter p).filter q = s.filter (λa, p a ∧ q a) :=
17731788
ext $ assume a, by simp only [mem_filter, and_comm, and.left_comm]
17741789

1775-
lemma filter_true {s : finset α} [h : decidable_pred (λ _, true)] :
1776-
@finset.filter α (λ _, true) h s = s :=
1777-
by ext; simp
1790+
lemma filter_comm (s : finset α) : (s.filter p).filter q = (s.filter q).filter p :=
1791+
by simp_rw [filter_filter, and_comm]
1792+
1793+
/- We can simplify an application of filter where the decidability is inferred in "the wrong way" -/
1794+
@[simp] lemma filter_congr_decidable (s : finset α) (p : α → Prop) (h : decidable_pred p)
1795+
[decidable_pred p] : @filter α p h s = s.filter p :=
1796+
by congr
17781797

1779-
@[simp] theorem filter_false {h} (s : finset α) : @filter α (λa, false) h s = :=
1780-
ext $ assume a, by simp only [mem_filter, and_false]; refl
1798+
lemma filter_true {h} (s : finset α) : @filter α (λ a, true) h s = s := by ext; simp
1799+
lemma filter_false {h} (s : finset α) : @filter α (λ a, false) h s = ∅ := by ext; simp
17811800

17821801
variables {p q}
17831802

1784-
lemma filter_eq_self (s : finset α) :
1785-
s.filter p = s ↔ ∀ x ∈ s, p x :=
1786-
by simp [finset.ext_iff]
1803+
lemma filter_eq_self : s.filter p = s ↔ ∀ ⦃x⦄, x ∈ s → p x := by simp [finset.ext_iff]
1804+
lemma filter_eq_empty_iff : s.filter p = ∅ ↔ ∀ ⦃x⦄, x ∈ s → ¬ p x := by simp [finset.ext_iff]
1805+
1806+
lemma filter_nonempty_iff {s : finset α} : (s.filter p).nonempty ↔ ∃ a ∈ s, p a :=
1807+
by simp only [nonempty_iff_ne_empty, ne.def, filter_eq_empty_iff, not_not, not_forall]
17871808

17881809
/-- If all elements of a `finset` satisfy the predicate `p`, `s.filter p` is `s`. -/
1789-
@[simp] lemma filter_true_of_mem {s : finset α} (h : ∀ x ∈ s, p x) : s.filter p = s :=
1790-
(filter_eq_self s).mpr h
1810+
@[simp] lemma filter_true_of_mem (h : ∀ x ∈ s, p x) : s.filter p = s := filter_eq_self.2 h
17911811

17921812
/-- If all elements of a `finset` fail to satisfy the predicate `p`, `s.filter p` is `∅`. -/
1793-
lemma filter_false_of_mem {s : finset α} (h : ∀ x ∈ s, ¬ p x) : s.filter p = ∅ :=
1794-
eq_empty_of_forall_not_mem (by simpa)
1813+
@[simp] lemma filter_false_of_mem (h : ∀ x ∈ s, ¬ p x) : s.filter p = ∅ := filter_eq_empty_iff.2 h
17951814

1796-
lemma filter_eq_empty_iff (s : finset α) :
1797-
(s.filter p = ∅) ↔ ∀ x ∈ s, ¬ p x :=
1798-
begin
1799-
refine ⟨_, filter_false_of_mem⟩,
1800-
intros hs,
1801-
injection hs with hs',
1802-
rwa filter_eq_nil at hs'
1803-
end
1804-
1805-
lemma filter_nonempty_iff {s : finset α} : (s.filter p).nonempty ↔ ∃ a ∈ s, p a :=
1806-
by simp only [nonempty_iff_ne_empty, ne.def, filter_eq_empty_iff, not_not, not_forall]
1815+
@[simp] lemma filter_const (p : Prop) [decidable p] (s : finset α) :
1816+
s.filter (λ a, p) = if p then s else ∅ :=
1817+
by split_ifs; simp [*]
18071818

18081819
lemma filter_congr {s : finset α} (H : ∀ x ∈ s, p x ↔ q x) : filter p s = filter q s :=
18091820
eq_of_veq $ filter_congr H
@@ -1944,11 +1955,6 @@ begin
19441955
{ intro x, simp, intros hx hx₂, refine ⟨or.resolve_left (h hx) hx₂, hx₂⟩ }
19451956
end
19461957

1947-
/- We can simplify an application of filter where the decidability is inferred in "the wrong way" -/
1948-
@[simp] lemma filter_congr_decidable {α} (s : finset α) (p : α → Prop) (h : decidable_pred p)
1949-
[decidable_pred p] : @filter α p h s = s.filter p :=
1950-
by congr
1951-
19521958
section classical
19531959
open_locale classical
19541960
/-- The following instance allows us to write `{x ∈ s | p x}` for `finset.filter p s`.

src/data/finset/lattice.lean

Lines changed: 91 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ fold_map
5555
@[simp] lemma sup_singleton {b : β} : ({b} : finset β).sup f = f b :=
5656
sup_singleton
5757

58-
lemma sup_union [decidable_eq β] : (s₁ ∪ s₂).sup f = s₁.sup f ⊔ s₂.sup f :=
59-
finset.induction_on s₁ (by rw [empty_union, sup_empty, bot_sup_eq]) $ λ a s has ih,
60-
by rw [insert_union, sup_insert, sup_insert, ih, sup_assoc]
61-
6258
lemma sup_sup : s.sup (f ⊔ g) = s.sup f ⊔ s.sup g :=
6359
begin
6460
refine finset.cons_induction_on s _ (λ b t _ h, _),
@@ -91,6 +87,9 @@ lemma le_sup {b : β} (hb : b ∈ s) : f b ≤ s.sup f := finset.sup_le_iff.1 le
9187

9288
lemma le_sup_of_le {b : β} (hb : b ∈ s) (h : a ≤ f b) : a ≤ s.sup f := h.trans $ le_sup hb
9389

90+
lemma sup_union [decidable_eq β] : (s₁ ∪ s₂).sup f = s₁.sup f ⊔ s₂.sup f :=
91+
eq_of_forall_ge_iff $ λ c, by simp [or_imp_distrib, forall_and_distrib]
92+
9493
@[simp] lemma sup_bUnion [decidable_eq β] (s : finset γ) (t : γ → finset β) :
9594
(s.bUnion t).sup f = s.sup (λ x, (t x).sup f) :=
9695
eq_of_forall_ge_iff $ λ c, by simp [@forall_swap _ β]
@@ -117,22 +116,15 @@ lemma sup_mono (h : s₁ ⊆ s₂) : s₁.sup f ≤ s₂.sup f := finset.sup_le
117116

118117
protected lemma sup_comm (s : finset β) (t : finset γ) (f : β → γ → α) :
119118
s.sup (λ b, t.sup (f b)) = t.sup (λ c, s.sup (λ b, f b c)) :=
120-
begin
121-
refine eq_of_forall_ge_iff (λ a, _),
122-
simp_rw finset.sup_le_iff,
123-
exact ⟨λ h c hc b hb, h b hb c hc, λ h b hb c hc, h c hc b hb⟩,
124-
end
119+
eq_of_forall_ge_iff $ λ a, by simpa using forall₂_swap
125120

126121
@[simp] lemma sup_attach (s : finset β) (f : β → α) : s.attach.sup (λ x, f x) = s.sup f :=
127122
(s.attach.sup_map (function.embedding.subtype _) f).symm.trans $ congr_arg _ attach_map_val
128123

129124
/-- See also `finset.product_bUnion`. -/
130125
lemma sup_product_left (s : finset β) (t : finset γ) (f : β × γ → α) :
131126
(s ×ˢ t).sup f = s.sup (λ i, t.sup $ λ i', f ⟨i, i'⟩) :=
132-
begin
133-
simp only [le_antisymm_iff, finset.sup_le_iff, mem_product, and_imp, prod.forall],
134-
exact ⟨λ b c hb hc, (le_sup hb).trans' $ le_sup hc, λ b hb c hc, le_sup $ mem_product.2 ⟨hb, hc⟩⟩,
135-
end
127+
eq_of_forall_ge_iff $ λ a, by simp [@forall_swap _ γ]
136128

137129
lemma sup_product_right (s : finset β) (t : finset γ) (f : β × γ → α) :
138130
(s ×ˢ t).sup f = t.sup (λ i', s.sup $ λ i, f ⟨i, i'⟩) :=
@@ -288,9 +280,6 @@ fold_map
288280
@[simp] lemma inf_singleton {b : β} : ({b} : finset β).inf f = f b :=
289281
inf_singleton
290282

291-
lemma inf_union [decidable_eq β] : (s₁ ∪ s₂).inf f = s₁.inf f ⊓ s₂.inf f :=
292-
@sup_union αᵒᵈ _ _ _ _ _ _ _
293-
294283
lemma inf_inf : s.inf (f ⊓ g) = s.inf f ⊓ s.inf g :=
295284
@sup_sup αᵒᵈ _ _ _ _ _ _
296285

@@ -301,6 +290,9 @@ by subst hs; exact finset.fold_congr hfg
301290
(f : F) (s : finset ι) (g : ι → α) : f (s.inf g) = s.inf (f ∘ g) :=
302291
finset.cons_induction_on s (map_top f) $ λ i s _ h, by rw [inf_cons, inf_cons, map_inf, h]
303292

293+
lemma inf_union [decidable_eq β] : (s₁ ∪ s₂).inf f = s₁.inf f ⊓ s₂.inf f :=
294+
@sup_union αᵒᵈ _ _ _ _ _ _ _
295+
304296
@[simp] lemma inf_bUnion [decidable_eq β] (s : finset γ) (t : γ → finset β) :
305297
(s.bUnion t).inf f = s.inf (λ x, (t x).inf f) :=
306298
@sup_bUnion αᵒᵈ _ _ _ _ _ _ _ _
@@ -628,11 +620,28 @@ end
628620
@[simp] lemma sup'_le_iff {a : α} : s.sup' H f ≤ a ↔ ∀ b ∈ s, f b ≤ a :=
629621
iff.intro (λ h b hb, trans (le_sup' f hb) h) (sup'_le H f)
630622

623+
lemma sup'_union [decidable_eq β] {s₁ s₂ : finset β} (h₁ : s₁.nonempty) (h₂ : s₂.nonempty)
624+
(f : β → α) :
625+
(s₁ ∪ s₂).sup' (h₁.mono $ subset_union_left _ _) f = s₁.sup' h₁ f ⊔ s₂.sup' h₂ f :=
626+
eq_of_forall_ge_iff $ λ a, by simp [or_imp_distrib, forall_and_distrib]
627+
631628
lemma sup'_bUnion [decidable_eq β] {s : finset γ} (Hs : s.nonempty) {t : γ → finset β}
632629
(Ht : ∀ b, (t b).nonempty) :
633630
(s.bUnion t).sup' (Hs.bUnion (λ b _, Ht b)) f = s.sup' Hs (λ b, (t b).sup' (Ht b) f) :=
634631
eq_of_forall_ge_iff $ λ c, by simp [@forall_swap _ β]
635632

633+
protected lemma sup'_comm {t : finset γ} (hs : s.nonempty) (ht : t.nonempty) (f : β → γ → α) :
634+
s.sup' hs (λ b, t.sup' ht (f b)) = t.sup' ht (λ c, s.sup' hs $ λ b, f b c) :=
635+
eq_of_forall_ge_iff $ λ a, by simpa using forall₂_swap
636+
637+
lemma sup'_product_left {t : finset γ} (hs : s.nonempty) (ht : t.nonempty) (f : β × γ → α) :
638+
(s ×ˢ t).sup' (hs.product ht) f = s.sup' hs (λ i, t.sup' ht $ λ i', f ⟨i, i'⟩) :=
639+
eq_of_forall_ge_iff $ λ a, by simp [@forall_swap _ γ]
640+
641+
lemma sup'_product_right {t : finset γ} (hs : s.nonempty) (ht : t.nonempty) (f : β × γ → α) :
642+
(s ×ˢ t).sup' (hs.product ht) f = t.sup' ht (λ i', s.sup' hs $ λ i, f ⟨i, i'⟩) :=
643+
by rw [sup'_product_left, finset.sup'_comm]
644+
636645
lemma comp_sup'_eq_sup'_comp [semilattice_sup γ] {s : finset β} (H : s.nonempty)
637646
{f : β → α} (g : α → γ) (g_sup : ∀ x y, g (x ⊔ y) = g x ⊔ g y) :
638647
g (s.sup' H f) = s.sup' H (g ∘ f) :=
@@ -675,6 +684,15 @@ begin
675684
simp only [sup'_le_iff, h₂] { contextual := tt }
676685
end
677686

687+
@[simp] lemma _root_.map_finset_sup' [semilattice_sup β] [sup_hom_class F α β] (f : F)
688+
{s : finset ι} (hs) (g : ι → α) : f (s.sup' hs g) = s.sup' hs (f ∘ g) :=
689+
by refine hs.cons_induction _ _; intros; simp [*]
690+
691+
@[simp] lemma sup'_image [decidable_eq β] {s : finset γ} {f : γ → β} (hs : (s.image f).nonempty)
692+
(g : β → α) (hs': s.nonempty := (nonempty.image_iff _).1 hs) :
693+
(s.image f).sup' hs g = s.sup' hs' (g ∘ f) :=
694+
by { rw ←with_bot.coe_eq_coe, simp only [coe_sup', sup_image, with_bot.coe_sup] }
695+
678696
@[simp] lemma sup'_map {s : finset γ} {f : γ ↪ β} (g : β → α) (hs : (s.map f).nonempty)
679697
(hs': s.nonempty := finset.map_nonempty.mp hs) :
680698
(s.map f).sup' hs g = s.sup' hs' (g ∘ f) :=
@@ -719,11 +737,28 @@ lemma inf'_le_of_le (hb : b ∈ s) (h : f b ≤ a) : s.inf' ⟨b, hb⟩ f ≤ a
719737

720738
@[simp] lemma le_inf'_iff : a ≤ s.inf' H f ↔ ∀ b ∈ s, a ≤ f b := @sup'_le_iff αᵒᵈ _ _ _ H f _
721739

740+
lemma inf'_union [decidable_eq β] {s₁ s₂ : finset β} (h₁ : s₁.nonempty) (h₂ : s₂.nonempty)
741+
(f : β → α) :
742+
(s₁ ∪ s₂).inf' (h₁.mono $ subset_union_left _ _) f = s₁.inf' h₁ f ⊓ s₂.inf' h₂ f :=
743+
@sup'_union αᵒᵈ _ _ _ _ _ h₁ h₂ _
744+
722745
lemma inf'_bUnion [decidable_eq β] {s : finset γ} (Hs : s.nonempty) {t : γ → finset β}
723746
(Ht : ∀ b, (t b).nonempty) :
724747
(s.bUnion t).inf' (Hs.bUnion (λ b _, Ht b)) f = s.inf' Hs (λ b, (t b).inf' (Ht b) f) :=
725748
@sup'_bUnion αᵒᵈ _ _ _ _ _ _ Hs _ Ht
726749

750+
protected lemma inf'_comm {t : finset γ} (hs : s.nonempty) (ht : t.nonempty) (f : β → γ → α) :
751+
s.inf' hs (λ b, t.inf' ht (f b)) = t.inf' ht (λ c, s.inf' hs $ λ b, f b c) :=
752+
@finset.sup'_comm αᵒᵈ _ _ _ _ _ hs ht _
753+
754+
lemma inf'_product_left {t : finset γ} (hs : s.nonempty) (ht : t.nonempty) (f : β × γ → α) :
755+
(s ×ˢ t).inf' (hs.product ht) f = s.inf' hs (λ i, t.inf' ht $ λ i', f ⟨i, i'⟩) :=
756+
@sup'_product_left αᵒᵈ _ _ _ _ _ hs ht _
757+
758+
lemma inf'_product_right {t : finset γ} (hs : s.nonempty) (ht : t.nonempty) (f : β × γ → α) :
759+
(s ×ˢ t).inf' (hs.product ht) f = t.inf' ht (λ i', s.inf' hs $ λ i, f ⟨i, i'⟩) :=
760+
@sup'_product_right αᵒᵈ _ _ _ _ _ hs ht _
761+
727762
lemma comp_inf'_eq_inf'_comp [semilattice_inf γ] {s : finset β} (H : s.nonempty)
728763
{f : β → α} (g : α → γ) (g_inf : ∀ x y, g (x ⊓ y) = g x ⊓ g y) :
729764
g (s.inf' H f) = s.inf' H (g ∘ f) :=
@@ -741,6 +776,15 @@ lemma inf'_mem (s : set α) (w : ∀ x y ∈ s, x ⊓ y ∈ s)
741776
s.inf' H f = t.inf' (h₁ ▸ H) g :=
742777
@sup'_congr αᵒᵈ _ _ _ H _ _ _ h₁ h₂
743778

779+
@[simp] lemma _root_.map_finset_inf' [semilattice_inf β] [inf_hom_class F α β] (f : F)
780+
{s : finset ι} (hs) (g : ι → α) : f (s.inf' hs g) = s.inf' hs (f ∘ g) :=
781+
by refine hs.cons_induction _ _; intros; simp [*]
782+
783+
@[simp] lemma inf'_image [decidable_eq β] {s : finset γ} {f : γ → β} (hs : (s.image f).nonempty)
784+
(g : β → α) (hs': s.nonempty := (nonempty.image_iff _).1 hs) :
785+
(s.image f).inf' hs g = s.inf' hs' (g ∘ f) :=
786+
@sup'_image αᵒᵈ _ _ _ _ _ _ hs _ hs'
787+
744788
@[simp] lemma inf'_map {s : finset γ} {f : γ ↪ β} (g : β → α) (hs : (s.map f).nonempty)
745789
(hs': s.nonempty := finset.map_nonempty.mp hs) :
746790
(s.map f).inf' hs g = s.inf' hs' (g ∘ f) :=
@@ -829,6 +873,37 @@ end inf'
829873
@[simp] lemma of_dual_inf' [semilattice_sup α] {s : finset ι} (hs : s.nonempty) (f : ι → αᵒᵈ) :
830874
of_dual (s.inf' hs f) = s.sup' hs (of_dual ∘ f) := rfl
831875

876+
section distrib_lattice
877+
variables [distrib_lattice α] {s : finset ι} {t : finset κ} (hs : s.nonempty) (ht : t.nonempty)
878+
{f : ι → α} {g : κ → α} {a : α}
879+
880+
lemma sup'_inf_distrib_left (f : ι → α) (a : α) : a ⊓ s.sup' hs f = s.sup' hs (λ i, a ⊓ f i) :=
881+
begin
882+
refine hs.cons_induction (λ i, _) (λ i s hi hs ih, _) ,
883+
{ simp },
884+
{ simp_rw [sup'_cons hs, inf_sup_left],
885+
rw ih }
886+
end
887+
888+
lemma sup'_inf_distrib_right (f : ι → α) (a : α) : s.sup' hs f ⊓ a = s.sup' hs (λ i, f i ⊓ a) :=
889+
by { rw [inf_comm, sup'_inf_distrib_left], simp_rw inf_comm }
890+
891+
lemma sup'_inf_sup' (f : ι → α) (g : κ → α) :
892+
s.sup' hs f ⊓ t.sup' ht g = (s ×ˢ t).sup' (hs.product ht) (λ i, f i.1 ⊓ g i.2) :=
893+
by simp_rw [finset.sup'_inf_distrib_right, finset.sup'_inf_distrib_left, sup'_product_left]
894+
895+
lemma inf'_sup_distrib_left (f : ι → α) (a : α) : a ⊔ s.inf' hs f = s.inf' hs (λ i, a ⊔ f i) :=
896+
@sup'_inf_distrib_left αᵒᵈ _ _ _ hs _ _
897+
898+
lemma inf'_sup_distrib_right (f : ι → α) (a : α) : s.inf' hs f ⊔ a = s.inf' hs (λ i, f i ⊔ a) :=
899+
@sup'_inf_distrib_right αᵒᵈ _ _ _ hs _ _
900+
901+
lemma inf'_sup_inf' (f : ι → α) (g : κ → α) :
902+
s.inf' hs f ⊔ t.inf' ht g = (s ×ˢ t).inf' (hs.product ht) (λ i, f i.1 ⊔ g i.2) :=
903+
@sup'_inf_sup' αᵒᵈ _ _ _ _ _ hs ht _ _
904+
905+
end distrib_lattice
906+
832907
section linear_order
833908
variables [linear_order α] {s : finset ι} (H : s.nonempty) {f : ι → α} {a : α}
834909

src/data/finset/locally_finite.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,16 +199,16 @@ end
199199

200200
lemma Icc_filter_lt_of_lt_right {a b c : α} [decidable_pred (< c)] (h : b < c) :
201201
(Icc a b).filter (< c) = Icc a b :=
202-
(finset.filter_eq_self _).2 (λ x hx, lt_of_le_of_lt (mem_Icc.1 hx).2 h)
202+
filter_true_of_mem $ λ x hx, (mem_Icc.1 hx).2.trans_lt h
203203

204204
lemma Ioc_filter_lt_of_lt_right {a b c : α} [decidable_pred (< c)] (h : b < c) :
205205
(Ioc a b).filter (< c) = Ioc a b :=
206-
(finset.filter_eq_self _).2 (λ x hx, lt_of_le_of_lt (mem_Ioc.1 hx).2 h)
206+
filter_true_of_mem $ λ x hx, (mem_Ioc.1 hx).2.trans_lt h
207207

208208
lemma Iic_filter_lt_of_lt_right {α} [preorder α] [locally_finite_order_bot α]
209209
{a c : α} [decidable_pred (< c)] (h : a < c) :
210210
(Iic a).filter (< c) = Iic a :=
211-
(finset.filter_eq_self _).2 (λ x hx, lt_of_le_of_lt (mem_Iic.1 hx) h)
211+
filter_true_of_mem $ λ x hx, (mem_Iic.1 hx).trans_lt h
212212

213213
variables (a b) [fintype α]
214214

src/number_theory/legendre_symbol/gauss_eisenstein_lemmas.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ calc (a ^ (p / 2) * (p / 2)! : zmod p) =
9090
(λ _ _ _ _ _ _, id)
9191
(λ b h _, ⟨b, by simp [-not_le, *] at *⟩)
9292
(by intros; split_ifs at *; simp * at *),
93-
by rw [prod_mul_distrib, this]; simp
93+
by rw [prod_mul_distrib, this, prod_const]
9494
... = (-1)^((Ico 1 (p / 2).succ).filter
9595
(λ x : ℕ, ¬(a * x : zmod p).val ≤ p / 2)).card * (p / 2)! :
9696
by rw [← prod_nat_cast, finset.prod_eq_multiset_prod,

0 commit comments

Comments
 (0)