Zulip Chat Archive

Stream: mathlib4

Topic: int.coe_nat_inj


Yaël Dillies (Jul 16 2023 at 16:57):

docs3#int.coe_nat_inj was wrongfully aligned to Int.ofNat.inj. I know coe is supposed to be see-through now, but clearly it's not transparent enough:

import Mathlib.Init.Data.Int.Basic

example (m n : ) : ((m - n) : ) = m - n := by
  rw [Int.ofNat_sub]
  sorry

example (m n : ) : Int.ofNat (m - n) = m - n := by
  rw [Int.ofNat_sub]
  sorry
/-
tactic 'rewrite' failed, did not find instance of the pattern in the target expression
  ↑(?m.419 - ?m.418)
mn: ℕ
⊢ Int.ofNat (m - n) = ↑m - ↑n
-/

Eric Wieser (Jul 16 2023 at 17:00):

I think the problem is that those are not the same coe

Eric Wieser (Jul 16 2023 at 17:01):

The first one is OfNat.ofNat

Eric Wieser (Jul 16 2023 at 17:01):

By making coe's see-through, lemmas about coe now have to match syntactically rather than just by defeq

Yaël Dillies (Jul 16 2023 at 17:02):

So we should burn any use of Int.ofNat? The port hasn't done so at all, removing lemmas about coe in favor of Int.ofNat lemmas.

Mario Carneiro (Jul 16 2023 at 17:03):

not for lemmas with ofNat in the name...

Yaël Dillies (Jul 16 2023 at 17:04):

Sure. Replace "use" by "mathlib use" in my previous message.

Mario Carneiro (Jul 16 2023 at 17:05):

I think this is a remnant of the ad hoc port

Mario Carneiro (Jul 16 2023 at 17:05):

originally ofNat was the coercion

Eric Wieser (Jul 16 2023 at 17:05):

Yeah, that file has no porting header

Yaël Dillies (Jul 16 2023 at 17:43):

Mario Carneiro said:

not for lemmas with ofNat in the name...

Lemmas with ofNat in their name are usually about OfNat.ofNat, not Int.ofNat.

Mario Carneiro (Jul 16 2023 at 17:45):

*lemmas in the Int namespace with ofNat in the name

Yaël Dillies (Jul 16 2023 at 17:46):

I maintain:

Lemmas in the Int namespace with ofNat in their name are usually about OfNat.ofNat, not Int.ofNat.

Yaël Dillies (Jul 16 2023 at 17:46):

I agree it's bad, but that's how it is right now.

Mario Carneiro (Jul 16 2023 at 17:51):

this is empirically false, can you give an example?

Yaël Dillies (Jul 16 2023 at 17:53):

Most things that are aligned in Data.Int.Basic, eg docs#Int.ofNat_sub


Last updated: Dec 20 2023 at 11:08 UTC