Skip to content

fix: mathlib4 monoidal structure on presheaves of modules, from nightly-2026-09-05 - #49

Closed
Kha wants to merge 1 commit into
masterfrom
push-uqsykvpuzzqv
Closed

fix: mathlib4 monoidal structure on presheaves of modules, from nightly-2026-09-05#49
Kha wants to merge 1 commit into
masterfrom
push-uqsykvpuzzqv

Conversation

@Kha

@Kha Kha commented Sep 6, 2026

Copy link
Copy Markdown
Member

master is red on nightly-2026-09-05 (run
34006523467
). Today's
downstream: update repo mathlib4 (87765e8b) brought in a second, independent mathlib4
failure that the rwa parse error of #48 had been masking — here and in
mathlib4-nightly-testing, whose own CI stops at that same parse error, so it is not visible
upstream either. This PR fixes that one failure; master also needs #48 and the verso
blocker below, so it will not by itself make the run green.

mathlib4MonoidalCategory fields can no longer infer C through PresheafOfModulesOfCommRing

mathlib master refactored Mathlib/Algebra/Category/ModuleCat/Presheaf/Monoidal.lean onto the
PresheafOfModulesOfCommRing R abbreviation (mathlib4 7974e751, merged into nightly-testing
an hour before the run). Its obj X is a ModuleCat (R.obj X), while the underlying
PresheafOfModules.Hom.app X still lands in ModuleCat ((R ⋙ forget₂ CommRingCat RingCat).obj X)
— the same ring bundled twice. Since lean4#14624 an instance is only assigned when its type
matches the expected one at .instances transparency, and seeing that those two agree requires
unfolding , which is @[implicit_reducible]. That is exactly the gap the file's own
#adaptation_note — written when mathlib adapted to that very PR — describes.

So apply could no longer pick C itself in six fields of the monoidalCategory instance:

error: Mathlib/Algebra/Category/ModuleCat/Presheaf/Monoidal.lean:153:47: Tactic `apply` failed:
could not unify the conclusion of `@tensorHom_comp_tensorHom`
  (?f₁ ⊗ₘ ?f₂) ≫ (?g₁ ⊗ₘ ?g₂) = ?f₁ ≫ ?g₁ ⊗ₘ ?f₂ ≫ ?g₂
with the goal
  ((x✝³ ⊗ₘ x✝²) ≫ (x✝¹ ⊗ₘ x✝)).app X✝ = (x✝³ ≫ x✝¹ ⊗ₘ x✝² ≫ x✝).app X✝

and the resulting instance-with-metavariables took symmetricCategory, the braiding_*_app
lemmas and the two PreservesColimitsOfSize instances with it — 18 errors from the one cause.

C is now passed explicitly, exactly as the same instance already does for whiskerLeft_id and
id_whiskerRight, which upstream needed for the same reason on the release toolchain. The
attribution was checked rather than guessed: set_option backward.isDefEq.respectTransparency.instanceSearchTypes false alone (the flag lean4#14624 added)
makes the unmodified file compile, while backward.isDefEq.respectTransparency and
backward.isDefEq.respectTransparency.types do not.

Expect more of these: mathlib master builds on a release toolchain (v4.34.0-rc2), so new master
code that trips instanceSearchTypes is invisible upstream until it reaches a nightly here.

Verified

With #48's four files applied locally, since mathlib4 does not build at all without them:

repo build test lint
mathlib4 ✅ 9019 jobs (--wfail) ✅ 9293 jobs (--iofail)
cslib ✅ 3211 jobs (--wfail --iofail) ✅ 9091 jobs (--wfail --iofail)
repl ✅ 71 tests, incl. test/Mathlib no driver

Not fixed here

  • fix: mathlib4 and cslib breakage from nightly-2026-09-04 #48 is still needed and unchanged: the rwa parse error in
    Mathlib.Tactic.TacticAnalysis.Declarations and the cslib rwa suggestion. It still applies
    to master byte-for-byte. This PR is independent of it — different files, no conflict — but CI
    on this branch alone will still show that parse error.
  • verso, and verso-slides, verso-web-components and the critical reference-manual
    skipped behind it, are red on the unchanged .downstream/ blocker, fifth day:
    Updater.fixup_subrepo_dependencies writes the in-tree subverso into the
    .lake/package-overrides.json of verso's nested test projects, which pin
    leanprover/lean4:v4.31.0 and therefore rewrite subverso/.lake/build mid-build.
    fixup_subrepo_toolchain, one function above, has the content guard this one lacks. Unattended
    runs may not touch .downstream/. fix: restore subverso definition sites, unbreaking verso-slides #41 fixes the subverso half of that story.

🤖 Generated with Claude Code

`downstream: update repo mathlib4` brought in mathlib master's refactor of
`Mathlib/Algebra/Category/ModuleCat/Presheaf/Monoidal.lean` onto the
`PresheafOfModulesOfCommRing R` abbreviation, whose `obj X` is a
`ModuleCat (R.obj X)` while the underlying `PresheafOfModules.Hom.app X` still
lands in `ModuleCat ((R ⋙ forget₂ CommRingCat RingCat).obj X)` — the same ring
bundled twice. Since `lean4#14624` an instance is only assigned when its type
matches the expected one at `.instances` transparency, and seeing that those two
agree needs `⋙` unfolded, which is `@[implicit_reducible]`; that is the gap the
file's own `#adaptation_note` already describes. So `apply` could no longer infer
`C` in six fields of the `monoidalCategory` instance:

    error: Tactic `apply` failed: could not unify the conclusion of
    `@tensorHom_comp_tensorHom`
      (?f₁ ⊗ₘ ?f₂) ≫ (?g₁ ⊗ₘ ?g₂) = ?f₁ ≫ ?g₁ ⊗ₘ ?f₂ ≫ ?g₂
    with the goal
      ((x✝³ ⊗ₘ x✝²) ≫ (x✝¹ ⊗ₘ x✝)).app X✝ = (x✝³ ≫ x✝¹ ⊗ₘ x✝² ≫ x✝).app X✝

and the resulting instance-with-metavariables took `symmetricCategory`, the
`braiding_*_app` lemmas and the two `PreservesColimitsOfSize` instances with it.

Pass `C` explicitly, as the same instance already does for `whiskerLeft_id` and
`id_whiskerRight`, which upstream needed for the same reason. Attribution
checked, not guessed: `set_option
backward.isDefEq.respectTransparency.instanceSearchTypes false` alone makes the
unmodified file compile, while `backward.isDefEq.respectTransparency` and
`backward.isDefEq.respectTransparency.types` do not.

Verified: `lake build Mathlib Archive Counterexamples Wanted --wfail`,
`lake test --iofail` and `lake lint`.
@downstream-lean4

Copy link
Copy Markdown
Contributor

Build report for fix: mathlib4 monoidal structure on presheaves of modules

Stayed red
Repo Critical Build Test Lint
mathlib4 🟥 in 4s ⏭️ ⏭️
reference-manual ⏭️ ⏭️ ⏭️
cslib ⏭️ ⏭️ ⏭️
repl ✅ in 1s 🟥 in 27s ⏭️
verso 🟥 in 64s ⏭️ ⏭️
verso-slides ⏭️ ⏭️ ⏭️
verso-web-components ⏭️ ⏭️ ⏭️
Stayed green
Repo Critical Build Test Lint
aesop ✅ in 7s ✅ in 4s ⏭️
batteries ✅ in 4s ✅ in 4s ✅ in 2s
import-graph ✅ in 2s ✅ in 3s ⏭️
lean4-cli ✅ in 1s ✅ in 0s ⏭️
plausible ✅ in 1s ✅ in 2s ⏭️
ProofWidgets4 ✅ in 3s ✅ in 1s ⏭️
quote4 ✅ in 2s ✅ in 1s ⏭️
BibtexQuery ✅ in 3s ⏭️ ⏭️
comparator ✅ in 2s ⏭️ ⏭️
doc-gen4 ✅ in 9s ⏭️ ⏭️
illuminate ✅ in 3s ✅ in 10s ⏭️
lean4-unicode-basic ✅ in 2s ⏭️ ⏭️
lean4export ✅ in 0s ✅ in 7s ⏭️
LeanSearchClient ✅ in 1s ✅ in 0s ⏭️
leansqlite ✅ in 7s ✅ in 19s ⏭️
nerodia ✅ in 2s ✅ in 21s ⏭️
subverso ✅ in 6s ⏭️ ⏭️

View run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant