Zulip Chat Archive

Stream: general

Topic: Importing Algebra.DirectSum.Ring avoids unrelated timeouts


Yaël Dillies (Apr 06 2025 at 10:00):

Consider the following file

import Mathlib.Algebra.DirectSum.Ring -- TODO: Spooky!
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.PullbackCone

namespace CategoryTheory.Limits
variable {C : Type*} [Category C] {X Y Z : C} {f : X  Y} {g : X  Z}

@[simp]
def pushoutCocone.toBinaryCofan : PushoutCocone f g  BinaryCofan (Under.mk f) (.mk g) where
  obj c := BinaryCofan.mk (Under.homMk (U := Under.mk f) c.inl rfl)
      (Under.homMk (U := Under.mk g) (V := Under.mk (f  c.inl)) c.inr c.condition.symm)
  map {c1 c2} a := {
    hom := Under.homMk a.hom
    w := by rintro (_|_) <;> aesop_cat
  }

end CategoryTheory.Limits

Yaël Dillies (Apr 06 2025 at 10:02):

It compiles. but if you remove the first import (which is not used), then the c.inl in obj does not typecheck anymore!

Yaël Dillies (Apr 06 2025 at 10:02):

You can also replace Mathlib.Algebra.DirectSum.Ring by its imports, and that breaks too

Yaël Dillies (Apr 06 2025 at 10:07):

Looking at the errors, I was expecting this to come from the fact that Algebra.DirectSum.Ring declares unification hints, but it does not.

Yaël Dillies (Apr 06 2025 at 10:07):

I am completely stunned. Any ideas?

Yaël Dillies (Apr 06 2025 at 10:22):

Okay, I have managed to reduce it further:

import Mathlib.CategoryTheory.Limits.Shapes.Pullback.PullbackCone

section
variable {ι : Type*} [Zero ι] (A : ι  Type*)

class GSemiring where natCast :   A 0

-- Comment out the next line and `pushoutCocone.toBinaryCofan` breaks
instance [GSemiring A] : NatCast (A 0) := GSemiring.natCast

end

namespace CategoryTheory.Limits
variable {C : Type*} [Category C] {X Y Z : C} {f : X  Y} {g : X  Z}

@[simp]
def pushoutCocone.toBinaryCofan : PushoutCocone f g  BinaryCofan (Under.mk f) (.mk g) where
  obj c := BinaryCofan.mk (Under.homMk (U := Under.mk f) c.inl rfl)
      (Under.homMk (U := Under.mk g) (V := Under.mk (f  c.inl)) c.inr c.condition.symm)
  map {c1 c2} a := {
    hom := Under.homMk a.hom
    w := by rintro (_|_) <;> aesop_cat
  }

end CategoryTheory.Limits

Yaël Dillies (Apr 06 2025 at 10:23):

@Eric Wieser, you will be glad to discover more weird consequences of your instance docs#DirectSum.instNatCastOfNat :grinning:


Last updated: May 02 2025 at 03:31 UTC