Zulip Chat Archive

Stream: mathlib4

Topic: Problem with `EuclideanSpace ℂ ι` as `InnerProductSpace ℝ`


Xavier Roblot (May 12 2024 at 13:08):

import Mathlib

variable {ι : Type*} [Fintype ι]

example :
    (InnerProductSpace.complexToReal : InnerProductSpace  (EuclideanSpace  ι))
      = (PiLp.innerProductSpace _ : InnerProductSpace  (EuclideanSpace  ι)) := rfl -- fails

example :
    (InnerProductSpace.complexToReal : InnerProductSpace  (EuclideanSpace  ι))
      = (PiLp.innerProductSpace _ : InnerProductSpace  (EuclideanSpace  ι)) := by
  unfold InnerProductSpace.complexToReal PiLp.innerProductSpace
  congr!
  simp [real_inner_eq_re_inner] -- succeeds

This is causing some problems when trying to work with EuclideanSpace ℂ ι as an InnerProductSpace ℝ. For example, when I try to construct an orthonormal basis of EuclideanSpace ℂ ι using #12242, I get the error message:

synthesized type class instance is not definitionally equal to expression inferred by typing rules, synthesized
  InnerProductSpace.complexToReal
inferred
  PiLp.innerProductSpace fun x  

What is the best way to fix that?
(I guess the best fix would be for the rfl above to work, but I don't know how to do that.)

Yaël Dillies (May 12 2024 at 13:19):

Hmm, that looks bad

Yaël Dillies (May 12 2024 at 13:21):

docs#InnerProductSpace.complexToReal, docs#PiLp.innerProductSpace

Yaël Dillies (May 12 2024 at 13:24):

It boils down to re (sum i, inner (x i) (y i)) = sum i, re (inner (x i) (y i)) not being defeq

Yaël Dillies (May 12 2024 at 13:26):

Can we hope to make re (sum i in s, f i) = sum i in s, re (f i) defeq in general? I doubt so

Xavier Roblot (May 12 2024 at 13:30):

But then it means that docs#InnerProductSpace.complexToReal should not be an instance?

Xavier Roblot (May 12 2024 at 13:49):

#12840 : Change docs#InnerProductSpace.complexToReal to a def and add the instance

instance : InnerProductSpace   := innerProductSpace.complexToReal

Eric Wieser (May 12 2024 at 14:40):

Most of these complexToReal instances are sort of bad, but the convenience usually outweighs this. This seems like an example where it doesn't

Kevin Buzzard (May 12 2024 at 14:42):

Given that mathlib compiles without it, I agree!


Last updated: May 02 2025 at 03:31 UTC