Lean4
/-- The constructed pullback cone is indeed the limit. -/
def pullbackConeIsLimit {A B C : CommRingCat.{u}} (f : A ⟶ C) (g : B ⟶ C) : IsLimit (pullbackCone f g) :=
by
fapply PullbackCone.IsLimit.mk
· intro s
refine ofHom ((s.fst.hom.prod s.snd.hom).codRestrict _ ?_)
intro x
exact congr_arg (fun f : s.pt →+* C => f x) (congrArg Hom.hom s.condition)
· intro s
ext x
rfl
· intro s
ext x
rfl
· intro s m e₁ e₂
refine hom_ext <| RingHom.ext fun (x : s.pt) => Subtype.ext ?_
change (m x).1 = (_, _)
have eq1 := (congr_arg (fun f : s.pt →+* A => f x) (congrArg Hom.hom e₁) :)
have eq2 := (congr_arg (fun f : s.pt →+* B => f x) (congrArg Hom.hom e₂) :)
rw [← eq1, ← eq2]
rfl