Skip to content

[Merged by Bors] - feat: port CategoryTheory.Monad.Basic - #2969

Closed
Parcly-Taxel wants to merge 11 commits into
masterfrom
port/CategoryTheory.Monad.Basic
Closed

Parcly-Taxel wants to merge 11 commits into
masterfrom
port/CategoryTheory.Monad.Basic

Conversation

@Parcly-Taxel

Copy link
Copy Markdown
Collaborator

Open in Gitpod

Mathbin -> Mathlib
fix certain import statements
move "by" to end of line
add import to Mathlib.lean
@Parcly-Taxel Parcly-Taxel added help-wanted The author needs attention to resolve issues WIP Work in progress mathlib-port This is a port of a theory file from mathlib. labels Mar 18, 2023
@Parcly-Taxel Parcly-Taxel added awaiting-review and removed help-wanted The author needs attention to resolve issues WIP Work in progress labels Mar 19, 2023
Comment thread Mathlib/CategoryTheory/Monad/Basic.lean Resolved
Comment thread Mathlib/CategoryTheory/Monad/Basic.lean Outdated
Comment on lines +312 to +315
/-- 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
-/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@Parcly-Taxel Parcly-Taxel Mar 22, 2023 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_cat

it 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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_cat

But 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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@ChrisHughes24

Copy link
Copy Markdown
Member

bors merge

@github-actions github-actions Bot added ready-to-merge This PR has been sent to bors. and removed awaiting-review labels Mar 24, 2023
bors Bot pushed a commit that referenced this pull request Mar 24, 2023
Co-authored-by: Parcly Taxel <[email protected]>
Co-authored-by: Joël Riou <[email protected]>
@bors

bors Bot commented Mar 24, 2023

Copy link
Copy Markdown

Pull request successfully merged into master.

Build succeeded:

@bors bors Bot changed the title feat: port CategoryTheory.Monad.Basic [Merged by Bors] - feat: port CategoryTheory.Monad.Basic Mar 24, 2023
@bors bors Bot closed this Mar 24, 2023
@bors
bors Bot deleted the port/CategoryTheory.Monad.Basic branch March 24, 2023 15:22
bors Bot pushed a commit to leanprover-community/mathlib3 that referenced this pull request Apr 5, 2023
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 <[email protected]>
bors Bot pushed a commit that referenced this pull request Apr 6, 2023
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 <[email protected]>
Co-authored-by: Chris Hughes <[email protected]>
bors Bot pushed a commit that referenced this pull request Apr 6, 2023
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 <[email protected]>
Co-authored-by: Chris Hughes <[email protected]>
bors Bot pushed a commit that referenced this pull request Apr 6, 2023
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 <[email protected]>
Co-authored-by: Chris Hughes <[email protected]>
bors Bot pushed a commit that referenced this pull request Apr 6, 2023
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 <[email protected]>
Co-authored-by: Chris Hughes <[email protected]>
MonadMaverick pushed a commit that referenced this pull request Apr 9, 2023
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 <[email protected]>
Co-authored-by: Chris Hughes <[email protected]>
MonadMaverick pushed a commit that referenced this pull request Apr 9, 2023
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 <[email protected]>
Co-authored-by: Chris Hughes <[email protected]>
bors Bot pushed a commit that referenced this pull request Apr 20, 2023
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 <[email protected]>
kbuzzard pushed a commit that referenced this pull request Apr 22, 2023
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 <[email protected]>
xroblot pushed a commit to leanprover-community/mathlib3 that referenced this pull request Apr 23, 2023
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 <[email protected]>
kim-em added a commit that referenced this pull request May 10, 2023
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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mathlib-port This is a port of a theory file from mathlib. ready-to-merge This PR has been sent to bors.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants