[Merged by Bors] - feat: port CategoryTheory.Monad.Basic#2969
[Merged by Bors] - feat: port CategoryTheory.Monad.Basic#2969Parcly-Taxel wants to merge 11 commits intomasterfrom
Conversation
Parcly-Taxel
commented
Mar 18, 2023
Mathbin -> Mathlib fix certain import statements move "by" to end of line add import to Mathlib.lean
| /-- Porting note: removed @[simp] as the linter complains of the LHS being reducible to | ||
| (comonadToFunctor _).mapIso (Iso.mk (MonadHom.mk f.hom) (MonadHom.mk f.inv)) | ||
| which does not even compile | ||
| -/ |
There was a problem hiding this comment.
That doesn't sound very promising. If you have set_option pp.all true, does it reduce to something that typechecks? Should we have a new simp-lemma for that LHS, so that the total behaviour of the simp-set doesn't change?
There was a problem hiding this comment.
OK, consider monadToFunctor_mapIso_monad_iso_mk first. simpNF says the LHS is reducible to
CategoryTheory.Functor.mapIso (CategoryTheory.monadToFunctor C)
(CategoryTheory.Iso.mk (CategoryTheory.MonadHom.mk f.hom) (CategoryTheory.MonadHom.mk f.inv))But when I make a new theorem with this simplification
theorem monadToFunctor_mapIso_monad_iso_mk' {M N : Monad C} (f : (M : C ⥤ C) ≅ N) :
CategoryTheory.Functor.mapIso (CategoryTheory.monadToFunctor C)
(CategoryTheory.Iso.mk (CategoryTheory.MonadHom.mk f.hom) (CategoryTheory.MonadHom.mk f.inv)) = f :=
by aesop_catit is not the body of the proof that throws an error, but MonadHom.mk f.hom and MonadHom.mk f.inv in the "simplified" LHS itself!
tactic 'aesop' failed, failed to prove the goal after exhaustive search.
T: Monad C
G: Comonad C
MN: Monad C
f: M.toFunctor ≅ N.toFunctor
⊢ ∀ (X : C), (Monad.η M).app X ≫ f.hom.app X = (Monad.η N).app X
Basic.lean:327:28
tactic 'aesop' failed, failed to prove the goal after exhaustive search.
T: Monad C
G: Comonad C
MN: Monad C
f: M.toFunctor ≅ N.toFunctor
⊢ ∀ (X : C),
(Monad.μ M).app X ≫ f.hom.app X = (M.toFunctor.map (f.hom.app X) ≫ f.hom.app (N.toFunctor.obj X)) ≫ (Monad.μ N).app X
Basic.lean:327:63
tactic 'aesop' failed, failed to prove the goal after exhaustive search.
T: Monad C
G: Comonad C
MN: Monad C
f: M.toFunctor ≅ N.toFunctor
⊢ ∀ (X : C), (Monad.η N).app X ≫ f.inv.app X = (Monad.η M).app X
Basic.lean:327:63
tactic 'aesop' failed, failed to prove the goal after exhaustive search.
T: Monad C
G: Comonad C
MN: Monad C
f: M.toFunctor ≅ N.toFunctor
⊢ ∀ (X : C),
(Monad.μ N).app X ≫ f.inv.app X = (N.toFunctor.map (f.inv.app X) ≫ f.inv.app (M.toFunctor.obj X)) ≫ (Monad.μ M).app X
So perhaps aesop is being run when it shouldn't be run.
There was a problem hiding this comment.
I suggest you inspect the statement with pp.all enabled. That way you'll have @s all over the place, but it will also make clear what is actually going on.
There was a problem hiding this comment.
Yeah, I can't make sense of all this:
tactic 'aesop' failed, failed to prove the goal after exhaustive search.
T: @CategoryTheory.Monad.{v₁, u₁} C inst
G: @CategoryTheory.Comonad.{v₁, u₁} C inst
MN: @CategoryTheory.Monad.{v₁, u₁} C inst
f: @CategoryTheory.Iso.{max u₁ v₁, max u₁ v₁} (@CategoryTheory.Functor.{v₁, v₁, u₁, u₁} C inst C inst)
(@CategoryTheory.Functor.category.{v₁, v₁, u₁, u₁} C inst C inst) (@CategoryTheory.Monad.toFunctor.{v₁, u₁} C inst M)
(@CategoryTheory.Monad.toFunctor.{v₁, u₁} C inst N)
⊢ ∀ (X : C),
@Eq.{v₁ + 1}
(@Quiver.Hom.{v₁ + 1, u₁} C
(@CategoryTheory.CategoryStruct.toQuiver.{v₁, u₁} C (@CategoryTheory.Category.toCategoryStruct.{v₁, u₁} C inst))
(@Prefunctor.obj.{v₁ + 1, v₁ + 1, u₁, u₁} C
(@CategoryTheory.CategoryStruct.toQuiver.{v₁, u₁} C (@CategoryTheory.Category.toCategoryStruct.{v₁, u₁} C inst))
C
(@CategoryTheory.CategoryStruct.toQuiver.{v₁, u₁} C (@CategoryTheory.Category.toCategoryStruct.{v₁, u₁} C inst))
(@CategoryTheory.Functor.toPrefunctor.{v₁, v₁, u₁, u₁} C inst C inst
(@CategoryTheory.Functor.id.{v₁, u₁} C inst))
X)
(@Prefunctor.obj.{v₁ + 1, v₁ + 1, u₁, u₁} C
(@CategoryTheory.CategoryStruct.toQuiver.{v₁, u₁} C (@CategoryTheory.Category.toCategoryStruct.{v₁, u₁} C inst))
C
(@CategoryTheory.CategoryStruct.toQuiver.{v₁, u₁} C (@CategoryTheory.Category.toCategoryStruct.{v₁, u₁} C inst))
(@CategoryTheory.Functor.toPrefunctor.{v₁, v₁, u₁, u₁} C inst C inst
(@CategoryTheory.Monad.toFunctor.{v₁, u₁} C inst N))
X))
(@CategoryTheory.CategoryStruct.comp.{v₁, u₁} C (@CategoryTheory.Category.toCategoryStruct.{v₁, u₁} C inst)
(@Prefunctor.obj.{v₁ + 1, v₁ + 1, u₁, u₁} C
(@CategoryTheory.CategoryStruct.toQuiver.{v₁, u₁} C (@CategoryTheory.Category.toCategoryStruct.{v₁, u₁} C inst))
C
(@CategoryTheory.CategoryStruct.toQuiver.{v₁, u₁} C (@CategoryTheory.Category.toCategoryStruct.{v₁, u₁} C inst))
(@CategoryTheory.Functor.toPrefunctor.{v₁, v₁, u₁, u₁} C inst C inst
(@CategoryTheory.Functor.id.{v₁, u₁} C inst))
X)
(@Prefunctor.obj.{v₁ + 1, v₁ + 1, u₁, u₁} C
(@CategoryTheory.CategoryStruct.toQuiver.{v₁, u₁} C (@CategoryTheory.Category.toCategoryStruct.{v₁, u₁} C inst))
C
(@CategoryTheory.CategoryStruct.toQuiver.{v₁, u₁} C (@CategoryTheory.Category.toCategoryStruct.{v₁, u₁} C inst))
(@CategoryTheory.Functor.toPrefunctor.{v₁, v₁, u₁, u₁} C inst C inst
(@CategoryTheory.Monad.toFunctor.{v₁, u₁} C inst M))
X)
(@Prefunctor.obj.{v₁ + 1, v₁ + 1, u₁, u₁} C
(@CategoryTheory.CategoryStruct.toQuiver.{v₁, u₁} C (@CategoryTheory.Category.toCategoryStruct.{v₁, u₁} C inst))
C
(@CategoryTheory.CategoryStruct.toQuiver.{v₁, u₁} C (@CategoryTheory.Category.toCategoryStruct.{v₁, u₁} C inst))
(@CategoryTheory.Functor.toPrefunctor.{v₁, v₁, u₁, u₁} C inst C inst
(@CategoryTheory.Monad.toFunctor.{v₁, u₁} C inst N))
X)
(@CategoryTheory.NatTrans.app.{v₁, v₁, u₁, u₁} C inst C inst (@CategoryTheory.Functor.id.{v₁, u₁} C inst)
(@CategoryTheory.Monad.toFunctor.{v₁, u₁} C inst M) (@CategoryTheory.Monad.η.{v₁, u₁} C inst M) X)
(@CategoryTheory.NatTrans.app.{v₁, v₁, u₁, u₁} C inst C inst (@CategoryTheory.Monad.toFunctor.{v₁, u₁} C inst M)
(@CategoryTheory.Monad.toFunctor.{v₁, u₁} C inst N)
(@CategoryTheory.Iso.hom.{max u₁ v₁, max u₁ v₁} (@CategoryTheory.Functor.{v₁, v₁, u₁, u₁} C inst C inst)
(@CategoryTheory.Functor.category.{v₁, v₁, u₁, u₁} C inst C inst)
(@CategoryTheory.Monad.toFunctor.{v₁, u₁} C inst M) (@CategoryTheory.Monad.toFunctor.{v₁, u₁} C inst N) f)
X))
(@CategoryTheory.NatTrans.app.{v₁, v₁, u₁, u₁} C inst C inst (@CategoryTheory.Functor.id.{v₁, u₁} C inst)
(@CategoryTheory.Monad.toFunctor.{v₁, u₁} C inst N) (@CategoryTheory.Monad.η.{v₁, u₁} C inst N) X)
There was a problem hiding this comment.
@jcommelin I've found that exactly four extra arguments – no more, no less – are needed for monadToFunctor_mapIso_monad_iso_mk' to type-check and from there compile:
@[simp]
theorem monadToFunctor_mapIso_monad_iso_mk' {M N : Monad C} (f : (M : C ⥤ C) ≅ N)
(f_η : ∀ (X : C), M.η.app X ≫ f.hom.app X = N.η.app X)
(f_μ : ∀ (X : C), M.μ.app X ≫ f.hom.app X =
(M.map (f.hom.app X) ≫ f.hom.app (N.obj X)) ≫ N.μ.app X)
(f_η' : ∀ (X : C), N.η.app X ≫ f.inv.app X = M.η.app X)
(f_μ' : ∀ (X : C), N.μ.app X ≫ f.inv.app X =
(N.map (f.inv.app X) ≫ f.inv.app (M.obj X)) ≫ M.μ.app X):
(monadToFunctor C).mapIso (Iso.mk (MonadHom.mk f.hom) (MonadHom.mk f.inv)) = f := by
aesop_catBut f_η' and f_μ' are not in the original theorem and I get a new simpNF error:
#check CategoryTheory.monadToFunctor_mapIso_monad_iso_mk' /- Left-hand side does not simplify, when using the simp lemma on itself.
This usually means that it will never apply.
What do I do now?
There was a problem hiding this comment.
Hmm, thanks for debugging. It's really quite annoying that this new statement is now also flagged by the simp linter. I had expected that it would be a good simp lemma.
Please report in the porting note that you made this attempt, but that the simp linter was still not satisfied.
|
bors merge |
Co-authored-by: Parcly Taxel <reddeloostw@gmail.com> Co-authored-by: Joël Riou <joel.riou@universite-paris-saclay.fr>
|
Pull request successfully merged into master. Build succeeded:
|
This is a backport from mathlib4, where the simpNF (correctly) linter disapproves of these lemmas. Mostly this PR exists to verify that these are not needed in the simp set. leanprover-community/mathlib4#2969 Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
The [porting PR](#2969) removed two `@[simp]` that the simpNF linter complained about. Now that I've verified they are not actually needed downstream (see leanprover-community/mathlib3#18727), we may as well remove the comments. Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Chris Hughes <chrishughes24@gmail.com>
The [porting PR](#2969) removed two `@[simp]` that the simpNF linter complained about. Now that I've verified they are not actually needed downstream (see leanprover-community/mathlib3#18727), we may as well remove the comments. Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Chris Hughes <chrishughes24@gmail.com>
The [porting PR](#2969) removed two `@[simp]` that the simpNF linter complained about. Now that I've verified they are not actually needed downstream (see leanprover-community/mathlib3#18727), we may as well remove the comments. Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Chris Hughes <chrishughes24@gmail.com>
The [porting PR](#2969) removed two `@[simp]` that the simpNF linter complained about. Now that I've verified they are not actually needed downstream (see leanprover-community/mathlib3#18727), we may as well remove the comments. Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Chris Hughes <chrishughes24@gmail.com>
The [porting PR](#2969) removed two `@[simp]` that the simpNF linter complained about. Now that I've verified they are not actually needed downstream (see leanprover-community/mathlib3#18727), we may as well remove the comments. Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Chris Hughes <chrishughes24@gmail.com>
The [porting PR](#2969) removed two `@[simp]` that the simpNF linter complained about. Now that I've verified they are not actually needed downstream (see leanprover-community/mathlib3#18727), we may as well remove the comments. Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Chris Hughes <chrishughes24@gmail.com>
This fixes a regression of `@[simps]` to `@[simp]` from #2969, per [zulip](https://leanprover.zulipchat.com/#narrow/stream/144837-PR-reviews/topic/!4.232969.20simps.20bug.3F.20.28Monad.2EBasic.29). There are a few incidental changes to `@[simps]` arguments in this PR, just removing arguments that had no effect on behaviour. Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
This fixes a regression of `@[simps]` to `@[simp]` from #2969, per [zulip](https://leanprover.zulipchat.com/#narrow/stream/144837-PR-reviews/topic/!4.232969.20simps.20bug.3F.20.28Monad.2EBasic.29). There are a few incidental changes to `@[simps]` arguments in this PR, just removing arguments that had no effect on behaviour. Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
This is a backport from mathlib4, where the simpNF (correctly) linter disapproves of these lemmas. Mostly this PR exists to verify that these are not needed in the simp set. leanprover-community/mathlib4#2969 Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
This fixes a regression of `@[simps]` to `@[simp]` from #2969, per [zulip](https://leanprover.zulipchat.com/#narrow/stream/144837-PR-reviews/topic/!4.232969.20simps.20bug.3F.20.28Monad.2EBasic.29). There are a few incidental changes to `@[simps]` arguments in this PR, just removing arguments that had no effect on behaviour. Co-authored-by: Scott Morrison <scott.morrison@gmail.com>