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): define unbundled ConcreteCategory class #20810

Closed
wants to merge 6 commits into from

Conversation

Vierkantor
Copy link
Contributor

@Vierkantor Vierkantor commented Jan 17, 2025

This is a step towards a concrete category redesign, as outlined in this Zulip post: https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Concrete.20category.20class.20redesign/near/493903980

This PR defines a new class ConcreteCategory that unbundles the coercion of morphisms to functions and objects to types, in order to allow ConcreteCategory to coexist alongisde existing coercions to functions/sorts. No instances are included yet, since those can be declared in parallel. See e.g. CommRingCat on the redesign-ConcreteCategory branch for examples of what a concrete category instance will end up looking like.


Open in Gitpod

@Vierkantor Vierkantor added the t-category-theory Category theory label Jan 17, 2025
Copy link

github-actions bot commented Jan 17, 2025

PR summary 5f65e81a6b

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ ConcreteCategory.forget_map_eq_coe
+ HasForget.toConcreteCategory
+ HasForget.toFunLike
+ ToHom
+ ToType
+ Types.instConcreteCategory
+ Types.instFunLike
+ coe_ext
+ congr_arg
+ congr_fun
+ ext
+ ext_apply
+ forget_eq_ConcreteCategory_hom
+ forget_obj
+ homEquiv
+ hom_bijective
+ hom_comp
+ hom_id
+ hom_injective
+ instance {X Y : C} : CoeFun (X ⟶ Y) (fun _ ↦ ToType X → ToType Y)
+ toHasForget

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

They are specified that order, to avoid unnecessary universe annotations.
-/
class ConcreteCategory (C : Type u) [Category.{v} C]
(FC : outParam <| C → C → Type*) {CC : outParam <| C → Type w}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed that CC can always be inferred through unification in the FunLike instance. So for conciseness I made it implicit. I was not expecting that to be possible!

Comment on lines 273 to 285
/-- `ToType X` converts the object `X` of the concrete category `C` to a type.
This is an `abbrev` so that instances on `X` (e.g. `Ring`) do not need to be redeclared.
-/
abbrev ToType [ConcreteCategory C FC] := CC

/-- `ToHom X Y` is the type of (bundled) functions between objects `X Y : C`.
This is an `abbrev` so that instances (e.g. `RingHomClass`) do not need to be redeclared.
-/
abbrev ToHom [ConcreteCategory C FC] := FC
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could also leave out ToType and ToHom and write CC/FC everywhere. I think this is neater, making things look like coercions. By defining this as abbrev, we don't commit (on the elaboration/tactic side) to a specific notation.

hom_bijective.injective

/-- In any concrete category, we can test equality of morphisms by pointwise evaluations. -/
@[ext] lemma ext {X Y : C} {f g : X ⟶ Y} (h : hom f = hom g) : f = g :=
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a replacement for hom_ext, that currently is defined in terms of HasForget. (Similarly for congr_fun, congr_arg, hom_id and hom_comp below.) Since we have no ConcreteCategory instances yet, we'll unfortunately need to keep both spellings for a while. At some point we'll also have to decide which name is nicer :)

@mathlib4-dependent-issues-bot mathlib4-dependent-issues-bot added blocked-by-other-PR This PR depends on another PR to Mathlib (this label is automatically managed by a bot) and removed blocked-by-other-PR This PR depends on another PR to Mathlib (this label is automatically managed by a bot) labels Jan 17, 2025
@mathlib4-dependent-issues-bot
Copy link
Collaborator

This PR/issue depends on:

This is a step towards a concrete category redesign, as outlined in this Zulip post: https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Concrete.20category.20class.20redesign/near/493903980

This PR defines a new class `ConcreteCategory` that unbundles the coercion of morphisms to functions and objects to types, in order to allow `ConcreteCategory` to coexist alongisde existing coercions to functions/sorts. No instances are included yet, since those can be declared in parallel. See e.g. `CommRingCat` on the `redesign-ConcreteCategory` branch for examples of what a concrete category instance will end up looking like.
@Vierkantor Vierkantor force-pushed the redefine-ConcreteCategory branch from 7b4be55 to dff99eb Compare January 17, 2025 14:27
@mattrobball
Copy link
Collaborator

bors merge

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the ready-to-merge This PR has been sent to bors. label Jan 17, 2025
mathlib-bors bot pushed a commit that referenced this pull request Jan 17, 2025
This is a step towards a concrete category redesign, as outlined in this Zulip post: https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Concrete.20category.20class.20redesign/near/493903980

This PR defines a new class `ConcreteCategory` that unbundles the coercion of morphisms to functions and objects to types, in order to allow `ConcreteCategory` to coexist alongisde existing coercions to functions/sorts. No instances are included yet, since those can be declared in parallel. See e.g. `CommRingCat` on the `redesign-ConcreteCategory` branch for examples of what a concrete category instance will end up looking like.



Co-authored-by: Anne Baanen <[email protected]>
@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Jan 17, 2025

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat(CategoryTheory): define unbundled ConcreteCategory class [Merged by Bors] - feat(CategoryTheory): define unbundled ConcreteCategory class Jan 17, 2025
@mathlib-bors mathlib-bors bot closed this Jan 17, 2025
@mathlib-bors mathlib-bors bot deleted the redefine-ConcreteCategory branch January 17, 2025 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

4 participants