Zulip Chat Archive

Stream: Is there code for X?

Topic: Trace of diagonal


Damiano Testa (Sep 09 2023 at 19:02):

Dear All,

does Mathlib already contain a lemma similar to the one below?

import Mathlib.LinearAlgebra.Matrix.Trace

lemma Matrix.trace_diagonal {R o} [AddCommMonoid R] [Fintype o] [DecidableEq o] (d : o  R) :
    Matrix.trace (Matrix.diagonal d) = (Finset.univ : Finset o).sum d := by
  sorry

Thanks!

Kevin Buzzard (Sep 09 2023 at 19:08):

import Mathlib.LinearAlgebra.Matrix.Trace

lemma Matrix.trace_diagonal {R o} [AddCommMonoid R] [Fintype o] [DecidableEq o] (d : o  R) :
    Matrix.trace (Matrix.diagonal d) = (Finset.univ : Finset o).sum d := by
  simp [Matrix.trace]

Eric Wieser (Sep 09 2023 at 19:08):

I think it's also true by rfl?

Kevin Buzzard (Sep 09 2023 at 19:09):

yeah I tried that first :-)

Kevin Buzzard (Sep 09 2023 at 19:09):

docs#Matrix.diagonal_apply_eq isn't rfl apparently

Kevin Buzzard (Sep 09 2023 at 19:10):

diagonal has an if in its definition.

Damiano Testa (Sep 09 2023 at 19:16):

:face_palm: I did not think of unfolding!

Damiano Testa (Sep 09 2023 at 19:16):

Thanks!

Damiano Testa (Sep 09 2023 at 19:17):

Do you agree that this lemma should be in mathlib?

Kevin Buzzard (Sep 09 2023 at 19:26):

yeah I couldn't find it and the name is pretty obvious

Damiano Testa (Sep 09 2023 at 19:34):

#7061


Last updated: Dec 20 2023 at 11:08 UTC