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

Commit 302eab4

Browse files
committed
chore(data/finset/lattice): Protect ambiguous lemmas (#17938)
Protect a few `finset` lemmas that conflict with root ones when `finset` is open.
1 parent e3a8dff commit 302eab4

File tree

6 files changed

+37
-45
lines changed

6 files changed

+37
-45
lines changed

src/data/finset/lattice.lean

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ begin
7272
exact ⟨λ k b hb, k _ _ hb rfl, λ k a' b hb h, h ▸ k _ hb⟩,
7373
end
7474

75+
alias finset.sup_le_iff ↔ _ sup_le
76+
77+
attribute [protected] sup_le
78+
79+
lemma le_sup {b : β} (hb : b ∈ s) : f b ≤ s.sup f := finset.sup_le_iff.1 le_rfl _ hb
80+
7581
@[simp] lemma sup_bUnion [decidable_eq β] (s : finset γ) (t : γ → finset β) :
7682
(s.bUnion t).sup f = s.sup (λ x, (t x).sup f) :=
7783
eq_of_forall_ge_iff $ λ c, by simp [@forall_swap _ β]
@@ -91,19 +97,12 @@ lemma sup_ite (p : β → Prop) [decidable_pred p] :
9197
(s.filter p).sup f ⊔ (s.filter (λ i, ¬ p i)).sup g :=
9298
fold_ite _
9399

94-
lemma sup_le {a : α} : (∀ b ∈ s, f b ≤ a) → s.sup f ≤ a :=
95-
finset.sup_le_iff.2
96-
97-
lemma le_sup {b : β} (hb : b ∈ s) : f b ≤ s.sup f :=
98-
finset.sup_le_iff.1 le_rfl _ hb
99-
100100
lemma sup_mono_fun {g : β → α} (h : ∀ b ∈ s, f b ≤ g b) : s.sup f ≤ s.sup g :=
101-
sup_le (λ b hb, le_trans (h b hb) (le_sup hb))
101+
finset.sup_le (λ b hb, le_trans (h b hb) (le_sup hb))
102102

103-
lemma sup_mono (h : s₁ ⊆ s₂) : s₁.sup f ≤ s₂.sup f :=
104-
sup_le $ assume b hb, le_sup (h hb)
103+
lemma sup_mono (h : s₁ ⊆ s₂) : s₁.sup f ≤ s₂.sup f := finset.sup_le $ λ b hb, le_sup $ h hb
105104

106-
lemma sup_comm (s : finset β) (t : finset γ) (f : β → γ → α) :
105+
protected lemma sup_comm (s : finset β) (t : finset γ) (f : β → γ → α) :
107106
s.sup (λ b, t.sup (f b)) = t.sup (λ c, s.sup (λ b, f b c)) :=
108107
begin
109108
refine eq_of_forall_ge_iff (λ a, _),
@@ -118,17 +117,13 @@ end
118117
lemma sup_product_left (s : finset β) (t : finset γ) (f : β × γ → α) :
119118
(s ×ˢ t).sup f = s.sup (λ i, t.sup $ λ i', f ⟨i, i'⟩) :=
120119
begin
121-
refine le_antisymm _ (sup_le (λ i hi, sup_le $ λ i' hi', le_sup $ mem_product.2 ⟨hi, hi'⟩)),
122-
refine sup_le _,
123-
rintro ⟨i, i'⟩ hi,
124-
rw mem_product at hi,
125-
refine le_trans _ (le_sup hi.1),
126-
convert le_sup hi.2,
120+
simp only [le_antisymm_iff, finset.sup_le_iff, mem_product, and_imp, prod.forall],
121+
exact ⟨λ b c hb hc, (le_sup hb).trans' $ le_sup hc, λ b hb c hc, le_sup $ mem_product.2 ⟨hb, hc⟩⟩,
127122
end
128123

129124
lemma sup_product_right (s : finset β) (t : finset γ) (f : β × γ → α) :
130125
(s ×ˢ t).sup f = t.sup (λ i', s.sup $ λ i, f ⟨i, i'⟩) :=
131-
by rw [sup_product_left, sup_comm]
126+
by rw [sup_product_left, finset.sup_comm]
132127

133128
@[simp] lemma sup_erase_bot [decidable_eq α] (s : finset α) : (s.erase ⊥).sup id = s.sup id :=
134129
begin
@@ -299,27 +294,26 @@ lemma inf_const {s : finset β} (h : s.nonempty) (c : α) : s.inf (λ _, c) = c
299294

300295
@[simp] lemma inf_top (s : finset β) : s.inf (λ _, ⊤) = (⊤ : α) := @sup_bot αᵒᵈ _ _ _ _
301296

302-
lemma le_inf_iff {a : α} : a ≤ s.inf f ↔ ∀ b ∈ s, a ≤ f b :=
297+
protected lemma le_inf_iff {a : α} : a ≤ s.inf f ↔ ∀ b ∈ s, a ≤ f b :=
303298
@finset.sup_le_iff αᵒᵈ _ _ _ _ _ _
304299

305-
lemma inf_le {b : β} (hb : b ∈ s) : s.inf f ≤ f b :=
306-
le_inf_iff.1 le_rfl _ hb
300+
alias finset.le_inf_iff ↔ _ le_inf
301+
302+
attribute [protected] le_inf
307303

308-
lemma le_inf {a : α} : (∀ b ∈ s, a ≤ f b) → a ≤ s.inf f :=
309-
le_inf_iff.2
304+
lemma inf_le {b : β} (hb : b ∈ s) : s.inf f ≤ f b := finset.le_inf_iff.1 le_rfl _ hb
310305

311306
lemma inf_mono_fun {g : β → α} (h : ∀ b ∈ s, f b ≤ g b) : s.inf f ≤ s.inf g :=
312-
le_inf (λ b hb, le_trans (inf_le hb) (h b hb))
307+
finset.le_inf (λ b hb, le_trans (inf_le hb) (h b hb))
313308

314-
lemma inf_mono (h : s₁ ⊆ s₂) : s₂.inf f ≤ s₁.inf f :=
315-
le_inf $ assume b hb, inf_le (h hb)
309+
lemma inf_mono (h : s₁ ⊆ s₂) : s₂.inf f ≤ s₁.inf f := finset.le_inf $ λ b hb, inf_le $h hb
316310

317311
lemma inf_attach (s : finset β) (f : β → α) : s.attach.inf (λ x, f x) = s.inf f :=
318312
@sup_attach αᵒᵈ _ _ _ _ _
319313

320-
lemma inf_comm (s : finset β) (t : finset γ) (f : β → γ → α) :
314+
protected lemma inf_comm (s : finset β) (t : finset γ) (f : β → γ → α) :
321315
s.inf (λ b, t.inf (f b)) = t.inf (λ c, s.inf (λ b, f b c)) :=
322-
@sup_comm αᵒᵈ _ _ _ _ _ _ _
316+
@finset.sup_comm αᵒᵈ _ _ _ _ _ _ _
323317

324318
lemma inf_product_left (s : finset β) (t : finset γ) (f : β × γ → α) :
325319
(s ×ˢ t).inf f = s.inf (λ i, t.inf $ λ i', f ⟨i, i'⟩) :=
@@ -535,7 +529,8 @@ by { rw ←with_bot.coe_eq_coe, simp only [coe_sup', sup_insert, with_bot.coe_su
535529
({b} : finset β).sup' h f = f b := rfl
536530

537531
lemma sup'_le {a : α} (hs : ∀ b ∈ s, f b ≤ a) : s.sup' H f ≤ a :=
538-
by { rw [←with_bot.coe_le_coe, coe_sup'], exact sup_le (λ b h, with_bot.coe_le_coe.2 $ hs b h), }
532+
by { rw [←with_bot.coe_le_coe, coe_sup'],
533+
exact finset.sup_le (λ b h, with_bot.coe_le_coe.2 $ hs b h) }
539534

540535
lemma le_sup' {b : β} (h : b ∈ s) : f b ≤ s.sup' ⟨b, h⟩ f :=
541536
by { rw [←with_bot.coe_le_coe, coe_sup'], exact le_sup h, }
@@ -673,7 +668,7 @@ section sup
673668
variables [semilattice_sup α] [order_bot α]
674669

675670
lemma sup'_eq_sup {s : finset β} (H : s.nonempty) (f : β → α) : s.sup' H f = s.sup f :=
676-
le_antisymm (sup'_le H f (λ b, le_sup)) (sup_le (λ b, le_sup' f))
671+
le_antisymm (sup'_le H f (λ b, le_sup)) (finset.sup_le (λ b, le_sup' f))
677672

678673
lemma sup_closed_of_sup_closed {s : set α} (t : finset α) (htne : t.nonempty) (h_subset : ↑t ⊆ s)
679674
(h : ∀ a b ∈ s, a ⊔ b ∈ s) : t.sup id ∈ s :=
@@ -860,9 +855,9 @@ finset.not_mem_of_max_lt_coe $ h₂.trans_lt $ with_bot.coe_lt_coe.mpr h₁
860855
lemma max_mono {s t : finset α} (st : s ⊆ t) : s.max ≤ t.max :=
861856
sup_mono st
862857

863-
lemma max_le {M : with_bot α} {s : finset α} (st : ∀ a : α, a ∈ s (a : with_bot α) ≤ M) :
858+
protected lemma max_le {M : with_bot α} {s : finset α} (st : ∀ a ∈ s, (a : with_bot α) ≤ M) :
864859
s.max ≤ M :=
865-
sup_le st
860+
finset.sup_le st
866861

867862
/-- Let `s` be a finset in a linear order. Then `s.min` is the minimum of `s` if `s` is not empty,
868863
and `⊤` otherwise. It belongs to `with_top α`. If you want to get an element of `α`, see
@@ -910,9 +905,9 @@ finset.not_mem_of_coe_lt_min $ (with_top.coe_lt_coe.mpr h₁).trans_eq h₂.symm
910905
lemma min_mono {s t : finset α} (st : s ⊆ t) : t.min ≤ s.min :=
911906
inf_mono st
912907

913-
lemma le_min {m : with_top α} {s : finset α} (st : ∀ a : α, a ∈ s → m ≤ a) :
908+
protected lemma le_min {m : with_top α} {s : finset α} (st : ∀ a : α, a ∈ s → m ≤ a) :
914909
m ≤ s.min :=
915-
le_inf st
910+
finset.le_inf st
916911

917912
/-- Given a nonempty finset `s` in a linear order `α`, then `s.min' h` is its minimum, as an
918913
element of `α`, where `h` is a proof of nonemptiness. Without this assumption, use instead `s.min`,

src/data/finset/sigma.lean

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,8 @@ variables (s t) (f : (Σ i, α i) → β)
7777
lemma sup_sigma [semilattice_sup β] [order_bot β] :
7878
(s.sigma t).sup f = s.sup (λ i, (t i).sup $ λ b, f ⟨i, b⟩) :=
7979
begin
80-
refine (sup_le _).antisymm (sup_le $ λ i hi, sup_le $ λ b hb, le_sup $ mem_sigma.2 ⟨hi, hb⟩),
81-
rintro ⟨i, b⟩ hb,
82-
rw mem_sigma at hb,
83-
refine le_trans _ (le_sup hb.1),
84-
convert le_sup hb.2,
80+
simp only [le_antisymm_iff, finset.sup_le_iff, mem_sigma, and_imp, sigma.forall],
81+
exact ⟨λ i a hi ha, (le_sup hi).trans' $ le_sup ha, λ i hi a ha, le_sup $ mem_sigma.2 ⟨hi, ha⟩⟩,
8582
end
8683

8784
lemma inf_sigma [semilattice_inf β] [order_top β] :

src/data/polynomial/degree/lemmas.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ else with_bot.coe_le_coe.1 $
3333
calc ↑(nat_degree (p.comp q)) = degree (p.comp q) : (degree_eq_nat_degree h0).symm
3434
... = _ : congr_arg degree comp_eq_sum_left
3535
... ≤ _ : degree_sum_le _ _
36-
... ≤ _ : sup_le (λ n hn,
36+
... ≤ _ : finset.sup_le (λ n hn,
3737
calc degree (C (coeff p n) * q ^ n)
3838
≤ degree (C (coeff p n)) + degree (q ^ n) : degree_mul_le _ _
3939
... ≤ nat_degree (C (coeff p n)) + n • (degree q) :

src/data/polynomial/degree/trailing_degree.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ end
273273

274274
lemma le_trailing_degree_mul : p.trailing_degree + q.trailing_degree ≤ (p * q).trailing_degree :=
275275
begin
276-
refine le_min (λ n hn, _),
276+
refine finset.le_min (λ n hn, _),
277277
rw [mem_support_iff, coeff_mul] at hn,
278278
obtain ⟨⟨i, j⟩, hij, hpq⟩ := exists_ne_zero_of_sum_ne_zero hn,
279279
refine (add_le_add (min_le (mem_support_iff.mpr (left_ne_zero_of_mul hpq)))

src/data/polynomial/derivative.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ begin
292292
simp [hp] },
293293
apply le_antisymm,
294294
{ rw derivative_apply,
295-
apply le_trans (degree_sum_le _ _) (sup_le (λ n hn, _)),
295+
apply le_trans (degree_sum_le _ _) (finset.sup_le (λ n hn, _)),
296296
apply le_trans (degree_C_mul_X_pow_le _ _) (with_bot.coe_le_coe.2 (tsub_le_tsub_right _ _)),
297297
apply le_nat_degree_of_mem_supp _ hn },
298298
{ refine le_sup _,

src/data/polynomial/unit_trinomial.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ by rw [trinomial_def, coeff_add, coeff_add, coeff_C_mul_X_pow, coeff_C_mul_X_pow
5656
lemma trinomial_nat_degree (hkm : k < m) (hmn : m < n) (hw : w ≠ 0) :
5757
(trinomial k m n u v w).nat_degree = n :=
5858
begin
59-
refine nat_degree_eq_of_degree_eq_some (le_antisymm (sup_le (λ i h, _))
60-
(le_degree_of_ne_zero (by rwa trinomial_leading_coeff' hkm hmn))),
59+
refine nat_degree_eq_of_degree_eq_some ((finset.sup_le $ λ i h, _).antisymm $
60+
le_degree_of_ne_zero $ by rwa trinomial_leading_coeff' hkm hmn),
6161
replace h := support_trinomial' k m n u v w h,
6262
rw [mem_insert, mem_insert, mem_singleton] at h,
6363
rcases h with rfl | rfl | rfl,
@@ -69,8 +69,8 @@ end
6969
lemma trinomial_nat_trailing_degree (hkm : k < m) (hmn : m < n) (hu : u ≠ 0) :
7070
(trinomial k m n u v w).nat_trailing_degree = k :=
7171
begin
72-
refine nat_trailing_degree_eq_of_trailing_degree_eq_some (le_antisymm (le_inf (λ i h, _))
73-
(le_trailing_degree_of_ne_zero (by rwa trinomial_trailing_coeff' hkm hmn))).symm,
72+
refine nat_trailing_degree_eq_of_trailing_degree_eq_some ((finset.le_inf $ λ i h, _).antisymm $
73+
le_trailing_degree_of_ne_zero $ by rwa trinomial_trailing_coeff' hkm hmn).symm,
7474
replace h := support_trinomial' k m n u v w h,
7575
rw [mem_insert, mem_insert, mem_singleton] at h,
7676
rcases h with rfl | rfl | rfl,

0 commit comments

Comments
 (0)