Commit 2026-11-17 14:23 fe0ec487

View on Github →

perf(CategoryTheory/Limits): define HasProducts using class (#46107) This PR refactors Limits.HasProducts to be a separate class instead of an abbrev for ∀ J : Type w, HasLimitsOfShape (Discrete J) C. The old definition is problematic when combined with the following instance:

instance hasLimitsOfShape_discrete [HasFiniteProducts C] (ι : Type w) [Finite ι] :
    HasLimitsOfShape (Discrete ι) C

A type class search goal of the form ∀ J : Type w, HasLimitsOfShape (Discrete J) C can turn into a goal of the form ∀ J : Type w, Finite J, which causes a crazy goose chase in type class search. To see this in action, consider the following example, which currently runs into the 20000 heartbeat limit before failing.

import Mathlib
variable (R : Type u) [CommRing R]
set_option trace.Meta.synthInstance true
#synth (LightCondensed.free R).Faithful

The new design matches other classes like HasFiniteProducts, HasConicalProducts and HasLimitsOfSize. We need @[univ_out_params, pp_with_univ] for the same reason as in HasLimitsOfSize, namely that there is a universe level argument that can't be inferred from the other arguments. And we have to add a handful of instances of HasProducts that were previously inferred from existing HasLimitsOfShape instances.

Estimated changes