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

Commit 3669cb3

Browse files
committed
feat(data/real/ennreal): add ennreal.prod_lt_top (#5602)
Also add `with_top.can_lift`, `with_top.mul_lt_top`, and `with_top.prod_lt_top`.
1 parent 4150136 commit 3669cb3

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

src/algebra/big_operators/order.lean

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,14 +319,18 @@ end finset
319319

320320
namespace with_top
321321
open finset
322-
open_locale classical
322+
323+
/-- A product of finite numbers is still finite -/
324+
lemma prod_lt_top [canonically_ordered_comm_semiring β] [nontrivial β] [decidable_eq β]
325+
{s : finset α} {f : α → with_top β} :
326+
(∀a∈s, f a < ⊤) → (∏ x in s, f x) < ⊤ :=
327+
λ h, prod_induction f (λ a, a < ⊤) (λ a b, mul_lt_top) (coe_lt_top 1) h
323328

324329
/-- A sum of finite numbers is still finite -/
325330
lemma sum_lt_top [ordered_add_comm_monoid β] {s : finset α} {f : α → with_top β} :
326331
(∀a∈s, f a < ⊤) → (∑ x in s, f x) < ⊤ :=
327332
λ h, sum_induction f (λ a, a < ⊤) (by { simp_rw add_lt_top, tauto }) zero_lt_top h
328333

329-
330334
/-- A sum of finite numbers is still finite -/
331335
lemma sum_lt_top_iff [canonically_ordered_add_monoid β] {s : finset α} {f : α → with_top β} :
332336
(∑ x in s, f x) < ⊤ ↔ (∀a∈s, f a < ⊤) :=

src/algebra/ordered_ring.lean

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,4 +1043,11 @@ instance [nontrivial α] : canonically_ordered_comm_semiring (with_top α) :=
10431043
.. with_top.canonically_ordered_add_monoid,
10441044
.. with_top.no_zero_divisors, .. with_top.nontrivial }
10451045

1046+
lemma mul_lt_top [nontrivial α] {a b : with_top α} (ha : a < ⊤) (hb : b < ⊤) : a * b < ⊤ :=
1047+
begin
1048+
lift a to α using ne_top_of_lt ha,
1049+
lift b to α using ne_top_of_lt hb,
1050+
simp only [← coe_mul, coe_lt_top]
1051+
end
1052+
10461053
end with_top

src/data/real/ennreal.lean

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,11 @@ nat.le_induction (pow_one _) (λ m hm hm', by rw [pow_succ, hm', top_mul_top])
299299
lemma mul_eq_top : a * b = ∞ ↔ (a ≠ 0 ∧ b = ∞) ∨ (a = ∞ ∧ b ≠ 0) :=
300300
with_top.mul_eq_top_iff
301301

302-
lemma mul_ne_top : a ≠ ∞ → b ≠ ∞ → a * b ≠ ∞ :=
303-
by simp [(≠), mul_eq_top] {contextual := tt}
304-
305302
lemma mul_lt_top : a < ∞ → b < ∞ → a * b < ∞ :=
306-
by simpa only [ennreal.lt_top_iff_ne_top] using mul_ne_top
303+
with_top.mul_lt_top
304+
305+
lemma mul_ne_top : a ≠ ∞ → b ≠ ∞ → a * b ≠ ∞ :=
306+
by simpa only [lt_top_iff_ne_top] using mul_lt_top
307307

308308
lemma ne_top_of_mul_ne_top_left (h : a * b ≠ ∞) (hb : b ≠ 0) : a ≠ ∞ :=
309309
by { simp [mul_eq_top, hb, not_or_distrib] at h ⊢, exact h.2 }
@@ -748,6 +748,10 @@ section sum
748748

749749
open finset
750750

751+
/-- A product of finite numbers is still finite -/
752+
lemma prod_lt_top {s : finset α} {f : α → ennreal} (h : ∀a∈s, f a < ∞) : (∏ a in s, f a) < ∞ :=
753+
with_top.prod_lt_top h
754+
751755
/-- A sum of finite numbers is still finite -/
752756
lemma sum_lt_top {s : finset α} {f : α → ennreal} :
753757
(∀a∈s, f a < ∞) → ∑ a in s, f a < ∞ :=

src/order/bounded_lattice.lean

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,11 @@ by simp [(≤)]
651651
@has_lt.lt (with_top α) _ (some a) none :=
652652
by simp [(<)]; existsi a; refl
653653

654+
instance : can_lift (with_top α) α :=
655+
{ coe := coe,
656+
cond := λ r, r ≠ ⊤,
657+
prf := λ x hx, ⟨option.get $ option.ne_none_iff_is_some.1 hx, option.some_get _⟩ }
658+
654659
instance [preorder α] : preorder (with_top α) :=
655660
{ le := λ o₁ o₂ : option α, ∀ a ∈ o₂, ∃ b ∈ o₁, b ≤ a,
656661
lt := (<),

0 commit comments

Comments
 (0)