Zulip Chat Archive

Stream: mathlib4

Topic: IsROrC vs Complex


Yaël Dillies (Sep 27 2023 at 19:51):

In case people haven't noticed, the coercion ℝ → ℂ is not syntactically the same as the coercion ℝ → 𝕜 where IsROrC 𝕜 and 𝕜 is . This means that lemma pairs like docs#Complex.ofReal_sum and docs#IsROrC.ofReal_sum are not interchangeable anymore.

Yaël Dillies (Sep 27 2023 at 19:51):

I find that mildly worrying. What about you?

Eric Wieser (Sep 27 2023 at 19:58):

(the extra context here is that the lean 3 coe mechanism meant these were syntactically the same)

Eric Wieser (Sep 27 2023 at 20:00):

I don't think this is any more worrying than having two different .ims

Yaël Dillies (Sep 27 2023 at 20:00):

Really? I had both coercions in the infoview and nothing told they were different until I clicked on them!

Yaël Dillies (Sep 27 2023 at 20:01):

It's pretty easy to fix as well: Just don't define the coercion ℝ→ ℂ, or define it in terms of the IsROrC one.

Eric Wieser (Sep 27 2023 at 20:02):

The same solution could work for .re and .im

Yaël Dillies (Sep 27 2023 at 20:04):

But IsROrC.im is visually different to Complex.im. I don't get your argument...

Yaël Dillies (Sep 27 2023 at 20:04):

Also the same couldn't really work for .re and .im since you'd lose dot notation.

Yaël Dillies (Sep 27 2023 at 20:07):

For context, I just lost 40min debugging a rw call that broke because of that.

Jireh Loreaux (Sep 27 2023 at 20:19):

Sorry, you mean the coercion the other way right? There is no coercion ℂ → ℝ.

Eric Wieser (Sep 27 2023 at 20:24):

Using algebraMap everywhere would solve this I think

Eric Wieser (Sep 27 2023 at 20:25):

I think we started doing that in lean 3, but it got in the way of the port so we reverted it all

Yaël Dillies (Sep 28 2023 at 04:48):

Jireh Loreaux said:

Sorry, you mean the coercion the other way right? There is no coercion ℂ → ℝ.

Uh yeah, of course. Can you tell I'm tired? :grinning:


Last updated: Dec 20 2023 at 11:08 UTC