Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - feat (CategoryTheory): constructing chosen finite products for the preorder category of a meet-semilattice with a top element #21094

Closed
wants to merge 16 commits into from

Conversation

sinhp
Copy link
Collaborator

@sinhp sinhp commented Jan 26, 2025

The preorder category of a meet-semilattice C with a top element has chosen finite products.

Motivation: I plan to use the induced monoidal structure to show that the preorder category of a distributive lattice is distributive. See this PR on Monoidal and cartesian distributive categories: #20182


Open in Gitpod

@github-actions github-actions bot added the t-category-theory Category theory label Jan 26, 2025
Copy link

github-actions bot commented Jan 26, 2025

PR summary 4f13c899e4

Import changes for modified files

Dependency changes

File Base Count Head Count Change
Mathlib.CategoryTheory.Limits.Shapes.Preorder.Basic 408 413 +5 (+1.23%)
Import changes for all files
Files Import difference
Mathlib.CategoryTheory.Limits.Shapes.Preorder.Basic 5
Mathlib.CategoryTheory.Limits.Preorder (new file) 412
Mathlib.CategoryTheory.ChosenFiniteProducts.InfSemilattice (new file) 578

Declarations diff

+ instance : HasInitial C := hasInitial_of_unique ⊥
+ instance : HasTerminal C := hasTerminal_of_unique ⊤
+ isColimitBinaryCofan
+ isLimitBinaryFan
+ isTerminalTop
+ tensorObj
+ tensorUnit
- instance : HasInitial J := hasInitial_of_unique ⊥
- instance : HasTerminal J := hasTerminal_of_unique ⊤
- isTerminalBot

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@sinhp sinhp added the good first issue Good for newcomers label Jan 26, 2025
end

/-- Chosen finite products for the preorder category of a meet-semilattice with a greatest element-/
noncomputable instance : ChosenFiniteProducts C where
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure we should make this an instance. It may be safer to make it a local or scoped instance.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

made it scoped in the namespace CategoryTheory.SemilatticeInf.

abbrev chosenTerminal : C := ⊤

/-- The chosen terminal object in the preoder category of `C` is terminal. -/
def chosenTerminalIsTerminal : IsTerminal (chosenTerminal C) where
Copy link
Collaborator

Choose a reason for hiding this comment

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

This already appears in the file CategoryTheory.Limits.Shapes.Preorder.Basic since #20335.
I would suggest you create a new file/directory CategoryTheory.Limits.Preorder where you would put results about colimits in a preordered type. There, you could move my definitions isInitialBot, isTerminalTop, HasInitial, HasTerminal (and keep the rest in Shapes.Preorder.Basic which is about the existence of (co)limits indexed by a preordered type).
In CategoryTheory.Limits.Preorder, you could add results about max, min (and more...) as definitions saying that certain (co)cones are (co)limits.
Then, in CategoryTheory.ChosenFiniteProducts.SemiLatticeInf, you could define chosen finite products out of these definitions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sounds like a good idea! just did that.

Comment on lines 51 to 53
def isLimit : IsLimit (BinaryFan.mk (fst X Y) (snd X Y)) where
lift s := homOfLE <| le_inf (leOfHom <| s.π.app <|
⟨WalkingPair.left⟩) (leOfHom <| s.π.app <| ⟨WalkingPair.right⟩)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I do not think we need the separate definitions chosenProd, fst and snd:

def isLimitBinaryFan :
    IsLimit (BinaryFan.mk (P := X ⊓ Y) (homOfLE inf_le_left) (homOfLE inf_le_right)) :=
  BinaryFan.isLimitMk (fun s ↦ homOfLE (le_inf (leOfHom s.fst) (leOfHom s.snd)))
    (by intros; rfl) (by intros; rfl) (by intros; rfl)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I also removed chosenTerminal, etc and imported stuff from Limits.Preorder. All that is left is

noncomputable scoped instance chosenFiniteProducts : ChosenFiniteProducts C where
  terminal := ⟨_, Preorder.isTerminalTop C⟩
  product X Y := ⟨_,  Preorder.isLimitBinaryFan X Y⟩

@joelriou joelriou added the awaiting-author A reviewer has asked the author a question or requested changes label Jan 26, 2025
@sinhp sinhp removed the awaiting-author A reviewer has asked the author a question or requested changes label Jan 27, 2025
@joelriou joelriou added the awaiting-author A reviewer has asked the author a question or requested changes label Jan 28, 2025
@sinhp sinhp removed the awaiting-author A reviewer has asked the author a question or requested changes label Jan 28, 2025
Comment on lines 46 to 48
lemma tensorObj {C : Type u} [Lattice C] [OrderTop C] {X Y : C} : X ⊗ Y = X ⊓ Y := rfl

lemma tensorUnit {C : Type u} [Lattice C] [OrderTop C] :
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do not you want to assume SemilatticeInf instead of Lattice?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

🤦 indeed, thanks for spotting that! just fixed it!

Incidentally, it seems we do not have ChosenFiniteCoProducts in Mathlib, and I was wondering why that is? would it be worth it to add it and then prove join-semilattices have a monoidal structure. This is not directly relevant to the project about distributive categories, but maybe in a separate branch/PR it can be done if you think it'd be useful. If at some point in future one wants to define rig-categories (i.e. distributive bimonoidal) then we need both conoidal structures coming from meet and join to show that distributive lattices are example of rig-categories.

Copy link
Collaborator

Choose a reason for hiding this comment

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

At this stage, I do not think it is necessary to develop ChosenFiniteCoproducts.

Comment on lines 32 to 41
/-- A monoidal structure on the preorder category of a meet-semilattice with a greatest element
is provided by the instance `monoidalOfChosenFiniteProducts`. -/
noncomputable scoped instance monoidalCategory : MonoidalCategory C := by
infer_instance

/-- The symmetric monoidal structure on the preorder category of a
meet-semilattice with a greatest element. -/
noncomputable scoped instance symmetricCategory : SymmetricCategory C := by
infer_instance

Copy link
Collaborator

Choose a reason for hiding this comment

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

There is no need to declare these as they can already be infered automatically. You may add a comment in docstring of the file saying C is automatically endowed with a symmetric category structure.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sounds good. added a sentence in the preamble doc-string.

Comment on lines 42 to 43
namespace Monoidal

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
namespace Monoidal

I am not sure we need to put the two lemmas in a subnamespace.

@joelriou joelriou added the awaiting-author A reviewer has asked the author a question or requested changes label Jan 28, 2025
@sinhp sinhp removed the awaiting-author A reviewer has asked the author a question or requested changes label Jan 28, 2025
@joelriou
Copy link
Collaborator

Thanks!

bors merge

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the ready-to-merge This PR has been sent to bors. label Jan 28, 2025
mathlib-bors bot pushed a commit that referenced this pull request Jan 28, 2025
…eorder category of a meet-semilattice with a top element (#21094)

The preorder category of a meet-semilattice `C` with a top element has chosen finite products. 

Motivation: I plan to use the induced monoidal structure to show that the preorder category of a distributive lattice is distributive. See this PR on Monoidal and cartesian distributive categories: #20182
@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Jan 28, 2025

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat (CategoryTheory): constructing chosen finite products for the preorder category of a meet-semilattice with a top element [Merged by Bors] - feat (CategoryTheory): constructing chosen finite products for the preorder category of a meet-semilattice with a top element Jan 28, 2025
@mathlib-bors mathlib-bors bot closed this Jan 28, 2025
@mathlib-bors mathlib-bors bot deleted the sina-chosen_finite_products_for_meet_semilattices branch January 28, 2025 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers ready-to-merge This PR has been sent to bors. t-category-theory Category theory
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants