Zulip Chat Archive

Stream: Is there code for X?

Topic: sum of nonneg terms is zero iff terms are zero


Michael Stoll (Dec 21 2023 at 19:47):

I'm having problems finding the following:

import Mathlib

example {α : Type*} {f : α  } (hf : Summable f) (hf₀ :  n, 0  f n) :
    tsum f = 0   n, f n = 0 := by sorry

There is docs#tsum_eq_zero_iff, which looks close, but needs a docs#CanonicallyOrderedAddCommMonoid as the target type.

Michael Stoll (Dec 21 2023 at 19:57):

My attempt:

import Mathlib

lemma tsum_eq_zero_iff_of_summable_of_nonneg {α M : Type*} [OrderedAddCommMonoid M]
    [TopologicalSpace M] [OrderClosedTopology M] {f : α  M} (hf : Summable f)
    (hf₀ :  n, 0  f n) : tsum f = 0   n, f n = 0 := by
  refine fun H  ?_, fun H  ?_
  · contrapose! H
    obtain n, hn := H
    replace hn := lt_of_le_of_ne (hf₀ n) hn.symm
    exact (ne_of_lt <| hn.trans_le <| le_tsum hf n fun m _  hf₀ m).symm
  · convert tsum_zero with n
    exact H n

But it feels like this is missing from Mathlib...

Terence Tao (Dec 21 2023 at 20:02):

One could convert to an integral and use docs#MeasureTheory.integral_eq_zero_iff_of_nonneg , or convert to ENNReal and use docs#ENNReal.tsum_eq_zero

Adam Topaz (Dec 21 2023 at 20:02):

Yeah I was going to suggest to use docs#tsum_eq_zero_iff and to convert to NNReal

Adam Topaz (Dec 21 2023 at 20:02):

I think NNReal should satisfy all the assumptions of that lemma.

Michael Stoll (Dec 21 2023 at 20:03):

Does this give a nicer proof?

Patrick Massot (Dec 21 2023 at 20:06):

I can see you are attracted to the golfing side of Mathlib. Don't resist, do it for real:

  · contrapose! H
    exact (H.2.symm.lt_of_le (hf₀ _) |>.trans_le <| le_tsum hf _ fun m _  hf₀ m).ne'

Terence Tao (Dec 21 2023 at 20:10):

I'm not such a golf pro but here is my attempt:

import Mathlib

example {α : Type*} {f : α  } (hf : Summable f) (hf₀ :  n, 0  f n) : tsum f = 0   n, f n = 0 := by
  constructor
  . intro hsum
    have := (ENNReal.ofReal_tsum_of_nonneg hf₀ hf).symm
    rw [hsum] at this; simp at this
    intro n; linarith [this n, hf₀ n]
  intro h0
  rw [tsum_congr h0]
  simp

Michael Stoll (Dec 21 2023 at 20:11):

But my version is more general :smile:

Michael Stoll (Dec 21 2023 at 20:12):

Slightly more golfed:

lemma tsum_eq_zero_iff_of_summable_of_nonneg {α M : Type*} [OrderedAddCommMonoid M]
    [TopologicalSpace M] [OrderClosedTopology M] {f : α  M} (hf : Summable f)
    (hf₀ :  n, 0  f n) : tsum f = 0   n, f n = 0 := by
  refine fun H  ?_, fun H  by convert tsum_zero; exact H _
  contrapose! H
  obtain n, hn := H
  exact (lt_of_le_of_ne (hf₀ n) hn.symm |>.trans_le <| le_tsum hf n fun m _  hf₀ m).ne'

Last updated: May 02 2025 at 03:31 UTC