Hi there,
(this is my first message, please be nice :))
So I'm having trouble with pullbacks in the category Type. Say I have two maps in Type u: m , m ′ : X → Y m, m' : X \to Y m , m ′ : X → Y . Then I can consider their pullback cone via limit.cone (cospan m m')
without any problem. However, when I take m = m ′ m = m' m = m ′ , Lean gives an error "maximum class-instance resolution depth has been reached". I found a workaround, but it's not very pretty and I'd like to understand what's going on (I'm not very familiar with the notation .{u} for the universes and all this stuff). Did I miss something?
Minimal code (lean:3.48.0):
import category_theory.limits.types
import category_theory.functor
import category_theory.limits.shapes.functor_category
open category_theory category_theory.limits functor
universes u
noncomputable theory
-- set_option trace.class_instances true
def one_map_Type { X Y : Type u } ( m : X ⟶ Y ) :=
limit.cone ( cospan m m )
def two_maps_Type { X Y : Type u } ( m m' : X ⟶ Y ) : cone ( cospan m m' ) :=
limit.cone ( cospan m m' )
-- A workaround
def Types_inst := category_theory.types. { u }
def one_map_Type' { X Y : Type u } ( m : X ⟶ Y ) : cone ( cospan m m ) :=
@ limit.cone _ _ _ Types_inst. { u } ( cospan m m ) _
-- A non-workaround
def one_map_Type'' { X Y : Type u } ( m : X ⟶ Y ) : cone ( cospan m m ) :=
@ limit.cone _ _ _ category_theory.types. { u } ( cospan m m ) _
here is a minimal example for anyone reading this:
import category_theory.limits.types
open category_theory category_theory.limits functor
universes u
set_option trace.class_instances true
example { X Y : Type u } ( m : X ⟶ Y ) : has_pullback m m := infer_instance
typeclass inference cannot deduce a has_pullback m m
instance.
this isn't good.
from the class instance trace it seems that lean REALLY wants to show that m
satisfies is_iso
...
And it looks like there is a loop...
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ pushout.map_is_iso ? x_8927 ? x_8928 ? x_8929 ? x_8930 ? x_8931 ? x_8932 ? x_8933 ? x_8934 ? x_8935 ? x_8936 ? x_8937 ? x_8938
? x_8939
? x_8940
? x_8941
? x_8942
? x_8943
? x_8944
? x_8945
? x_8946
? x_8947
? x_8948
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ pullback.map_is_iso ? x_8949 ? x_8950 ? x_8951 ? x_8952 ? x_8953 ? x_8954 ? x_8955 ? x_8956 ? x_8957 ? x_8958 ? x_8959 ? x_8960
? x_8961
? x_8962
? x_8963
? x_8964
? x_8965
? x_8966
? x_8967
? x_8968
? x_8969
? x_8970
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ limits.is_iso_coprod ? x_8971 ? x_8972 ? x_8973 ? x_8974 ? x_8975 ? x_8976 ? x_8977 ? x_8978 ? x_8979 ? x_8980 ? x_8981 ? x_8982
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ limits.is_iso_prod ? x_8983 ? x_8984 ? x_8985 ? x_8986 ? x_8987 ? x_8988 ? x_8989 ? x_8990 ? x_8991 ? x_8992 ? x_8993 ? x_8994
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ bicategory.whisker_right_is_iso ? x_8995 ? x_8996 ? x_8997 ? x_8998 ? x_8999 ? x_9000 ? x_9001 ? x_9002 ? x_9003 ? x_9004
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ bicategory.whisker_left_is_iso ? x_9005 ? x_9006 ? x_9007 ? x_9008 ? x_9009 ? x_9010 ? x_9011 ? x_9012 ? x_9013 ? x_9014
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ limits.is_iso_ι_initial ? x_9015 ? x_9016 ? x_9017 ? x_9018 ? x_9019 ? x_9020 ? x_9021 ? x_9022
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ limits.is_iso_ι_terminal ? x_9023 ? x_9024 ? x_9025 ? x_9026 ? x_9027 ? x_9028 ? x_9029
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ limits.is_iso_π_terminal ? x_9030 ? x_9031 ? x_9032 ? x_9033 ? x_9034 ? x_9035 ? x_9036 ? x_9037
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ limits.is_iso_π_initial ? x_9038 ? x_9039 ? x_9040 ? x_9041 ? x_9042 ? x_9043 ? x_9044
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ coequalizer.π_of_self ? x_9045 ? x_9046 ? x_9047 ? x_9048 ? x_9049
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ equalizer.ι_of_self ? x_9050 ? x_9051 ? x_9052 ? x_9053 ? x_9054
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ arrow.is_iso_right ? x_9055 ? x_9056 ? x_9057 ? x_9058 ? x_9059 ? x_9060
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ arrow.is_iso_left ? x_9061 ? x_9062 ? x_9063 ? x_9064 ? x_9065 ? x_9066
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ functor.corepr_f.category_theory.is_iso ? x_9067 ? x_9068 ? x_9069 ? x_9070
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ functor.repr_f.category_theory.is_iso ? x_9071 ? x_9072 ? x_9073 ? x_9074
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ discrete.category_theory.is_iso ? x_9075 ? x_9076 ? x_9077 ? x_9078
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ eq_to_hom.is_iso ? x_9079 ? x_9080 ? x_9081 ? x_9082 ? x_9083
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ category_theory.is_iso_unop ? x_9084 ? x_9085 ? x_9086 ? x_9087 ? x_9088 ? x_9089
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ category_theory.is_iso_op ? x_9090 ? x_9091 ? x_9092 ? x_9093 ? x_9094 ? x_9095
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ category_theory.is_iso_whisker_right ? x_9096 ? x_9097 ? x_9098 ? x_9099 ? x_9100 ? x_9101 ? x_9102 ? x_9103 ? x_9104 ? x_9105
? x_9106
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ category_theory.is_iso_whisker_left ? x_9107 ? x_9108 ? x_9109 ? x_9110 ? x_9111 ? x_9112 ? x_9113 ? x_9114 ? x_9115 ? x_9116
? x_9117
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ nat_iso.is_iso_app_of_is_iso ? x_9118 ? x_9119 ? x_9120 ? x_9121 ? x_9122 ? x_9123 ? x_9124 ? x_9125 ? x_9126
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ nat_iso.inv_app_is_iso ? x_9127 ? x_9128 ? x_9129 ? x_9130 ? x_9131 ? x_9132 ? x_9133 ? x_9134
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ nat_iso.hom_app_is_iso ? x_9135 ? x_9136 ? x_9137 ? x_9138 ? x_9139 ? x_9140 ? x_9141 ? x_9142
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ functor.map_is_iso ? x_9143 ? x_9144 ? x_9145 ? x_9146 ? x_9147 ? x_9148 ? x_9149 ? x_9150 ? x_9151
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ is_iso.inv_is_iso ? x_9152 ? x_9153 ? x_9154 ? x_9155 ? x_9156 ? x_9157
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ is_iso.of_iso_inv ? x_9158 ? x_9159 ? x_9160 ? x_9161 ? x_9162
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ is_iso.of_iso ? x_9163 ? x_9164 ? x_9165 ? x_9166 ? x_9167
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ is_iso.id ? x_9168 ? x_9169 ? x_9170
failed is_def_eq
[ class_instances ] ( 27 ) ? x_8819 : @ is_iso ( Type u ) category_theory.types X Y m := @ is_iso.comp_is_iso ? x_9171 ? x_9172 ? x_9173 ? x_9174 ? x_9175 ? x_9176 ? x_9177 ? x_9178 ? x_9179
[ class_instances ] ( 28 ) ? x_9179 : @ is_iso ( Type u ) category_theory.types X Y m := @ image.is_iso_precomp_iso ? x_9180 ? x_9181 ? x_9182 ? x_9183 ? x_9184 ? x_9185 ? x_9186 ? x_9187 ? x_9188 ? x_9189
failed is_def_eq
[ class_instances ] ( 28 ) ? x_9179 : @ is_iso ( Type u ) category_theory.types X Y m := @ image.eq_to_hom.category_theory.is_iso ? x_9190 ? x_9191 ? x_9192 ? x_9193 ? x_9194 ? x_9195 ? x_9196 ? x_9197 ? x_9198
failed is_def_eq
[ class_instances ] ( 28 ) ? x_9179 : @ is_iso ( Type u ) category_theory.types X Y m := @ limits.inr_iso_of_epi_eq ? x_9199 ? x_9200 ? x_9201 ? x_9202 ? x_9203 ? x_9204
failed is_def_eq
[ class_instances ] ( 28 ) ? x_9179 : @ is_iso ( Type u ) category_theory.types X Y m := @ limits.inl_iso_of_epi_eq ? x_9205 ? x_9206 ? x_9207 ? x_9208 ? x_9209 ? x_9210
failed is_def_eq
[ class_instances ] ( 28 ) ? x_9179 : @ is_iso ( Type u ) category_theory.types X Y m := @ limits.snd_iso_of_mono_eq ? x_9211 ? x_9212 ? x_9213 ? x_9214 ? x_9215 ? x_9216
failed is_def_eq
[ class_instances ] ( 28 ) ? x_9179 : @ is_iso ( Type u ) category_theory.types X Y m := @ limits.fst_iso_of_mono_eq ? x_9217 ? x_9218 ? x_9219 ? x_9220 ? x_9221 ? x_9222
failed is_def_eq
[ class_instances ] ( 28 ) ? x_9179 : @ is_iso ( Type u ) category_theory.types X Y m := @ limits.pushout_inl_iso_of_left_factors_epi ? x_9223 ? x_9224 ? x_9225 ? x_9226 ? x_9227 ? x_9228 ? x_9229 ? x_9230
failed is_def_eq
[ class_instances ] ( 28 ) ? x_9179 : @ is_iso ( Type u ) category_theory.types X Y m := @ limits.pushout_inl_iso_of_right_iso ? x_9231 ? x_9232 ? x_9233 ? x_9234 ? x_9235 ? x_9236 ? x_9237 ? x_9238
failed is_def_eq
[ class_instances ] ( 28 ) ? x_9179 : @ is_iso ( Type u ) category_theory.types X Y m := @ limits.pushout_inr_iso_of_right_factors_epi ? x_9239 ? x_9240 ? x_9241 ? x_9242 ? x_9243 ? x_9244 ? x_9245 ? x_9246
failed is_def_eq
[ class_instances ] ( 28 ) ? x_9179 : @ is_iso ( Type u ) category_theory.types X Y m := @ limits.pushout_inr_iso_of_left_iso ? x_9247 ? x_9248 ? x_9249 ? x_9250 ? x_9251 ? x_9252 ? x_9253 ? x_9254
failed is_def_eq
[ class_instances ] ( 28 ) ? x_9179 : @ is_iso ( Type u ) category_theory.types X Y m := @ limits.pullback_snd_iso_of_left_factors_mono ? x_9255 ? x_9256 ? x_9257 ? x_9258 ? x_9259 ? x_9260 ? x_9261 ? x_9262
failed is_def_eq
[ class_instances ] ( 28 ) ? x_9179 : @ is_iso ( Type u ) category_theory.types X Y m := @ limits.pullback_snd_iso_of_right_iso ? x_9263 ? x_9264 ? x_9265 ? x_9266 ? x_9267 ? x_9268 ? x_9269 ? x_9270
failed is_def_eq
[ class_instances ] ( 28 ) ? x_9179 : @ is_iso ( Type u ) category_theory.types X Y m := @ limits.pullback_snd_iso_of_right_factors_mono ? x_9271 ? x_9272 ? x_9273 ? x_9274 ? x_9275 ? x_9276 ? x_9277 ? x_9278
failed is_def_eq
[ class_instances ] ( 28 ) ? x_9179 : @ is_iso ( Type u ) category_theory.types X Y m := @ limits.pullback_snd_iso_of_left_iso ? x_9279 ? x_9280 ? x_9281 ? x_9282 ? x_9283 ? x_9284 ? x_9285 ? x_9286
failed is_def_eq
[ class_instances ] ( 28 ) ? x_9179 : @ is_iso ( Type u ) category_theory.types X Y m := @ pushout.map_is_iso ? x_9287 ? x_9288 ? x_9289 ? x_9290 ? x_9291 ? x_9292 ? x_9293 ? x_9294 ? x_9295 ? x_9296 ? x_9297 ? x_9298
? x_9299
? x_9300
? x_9301
? x_9302
? x_9303
? x_9304
? x_9305
? x_9306
? x_9307
? x_9308
failed is_def_eq
[ class_instances ] ( 28 ) ? x_9179 : @ is_iso ( Type u ) category_theory.types X Y m := @ pullback.map_is_iso ? x_9309 ? x_9310 ? x_9311 ? x_9312 ? x_9313 ? x_9314 ? x_9315 ? x_9316 ? x_9317 ? x_9318 ? x_9319 ? x_9320
? x_9321
? x_9322
? x_9323
? x_9324
? x_9325
? x_9326
? x_9327
? x_9328
? x_9329
? x_9330
failed is_def_eq
Just in case it helps diagnosing the issue:
import category_theory.limits.types
open category_theory category_theory.limits functor
universes u
local attribute [ - instance ]
limits.has_kernel_pair_of_mono
limits.has_pullback_of_left_factors_mono
limits.has_pullback_of_right_factors_mono
limits.has_pullback_of_comp_mono
example { X Y : Type u } ( m : X ⟶ Y ) : has_pullback m m := infer_instance
this works fine
I think the situation is kind of like the one mentioned here , where Lean somehow finds (λ x, x) ≫ f
defeq to f
and it then goes in some loop.
yeah you're probably right.
Last updated: Dec 20 2023 at 11:08 UTC