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

2-cat of pointed types #1795

Merged
merged 4 commits into from
Dec 29, 2023
Merged

Conversation

Alizter
Copy link
Collaborator

@Alizter Alizter commented Dec 28, 2023

We show the (2,1)-category structure for pointed types. In order to do this easily, we introduce a new tactic called pelim which allows easy path induction on the pointed equation of various pointed structures. This is particularly useful in removing funext from various pType coherences.

Various places seemed to break from these changes, but could easily be fixed by replacing pointed notations with wildcat notations. This perhaps hints at a larger refactoring that should be done.

My motivation for showing these coherences is the need for 1-functoriality of pre/postcomposition for some unrelated work. Therefore it made sense to quickly generalize to the full 2-category while I was at it.

@jdchristensen
Copy link
Collaborator

Nice! I'll take a close look tomorrow. A couple of questions for now. First, how does pelim compare with pointed_reduce and pointed_reduce_pmap? Can we unify them? Second, I'm surprised that just adding the (2,1)-category structure made various pointed notations like <~>* need to be replaced with wildcat notations. Do you have any idea why this happens? One issue with wildcat notations is that you don't always know which wildcat Coq is choosing to interpret your notation with...

@Alizter
Copy link
Collaborator Author

Alizter commented Dec 29, 2023

Nice! I'll take a close look tomorrow. A couple of questions for now. First, how does pelim compare with pointed_reduce and pointed_reduce_pmap? Can we unify them?

I originally tried to modify pointed_reduce to avoid using path_induction and instead use pelim, however it changed too much and pelim is a little slower due to the reduction I needed to do in the tactic.

Also it is not entirely trivial the order in which to do pelim on the hypotheses. If you look at the functoriality of the assocciators in the 2-category definition, you will see that the pelim order for similar proofs vary subtly in their order. I don't think it will be entirely trivial to get tactics to choose this order.

I think having the manual control is a little better. I would however like to improve the performance of pelim before we start using it more widely since it does more unfolding than it probably needs. The main idea comes from recognising that point equations typically have an application on the LHS and when you do a generalize dependent of the pointed structure applied to its basepoint you get a hypothesis that almost always fits paths_ind_r.

Thinking about it, using right-handed path induction consistently should lead to a far superior pointed_elim, therefore it might be worth investigating swapping the regular path induction for the right handed side at some point.

Second, I'm surprised that just adding the (2,1)-category structure made various pointed notations like <~>* need to be replaced with wildcat notations. Do you have any idea why this happens?

I was also surprised, but I think this is because extra groupoid instances throw off Coq's unification. This is apparent in the fact that a few proofs had to be changed from srapply to snrapply followed by exact. I'm not entirely sure this is the full picture however.

One issue with wildcat notations is that you don't always know which wildcat Coq is choosing to interpret your notation with...

Yes that might be true. I think the better option would be to redefine ->* as a specific form of $->, but I haven't checked if this is fully sensible just yet. (Especially if it changes universe numbers).

@Alizter Alizter force-pushed the ps/branch/2_cat_of_pointed_types branch from a867bad to 34c5bf6 Compare December 29, 2023 14:53
@Alizter
Copy link
Collaborator Author

Alizter commented Dec 29, 2023

I've just pushed another commit simplifying a few other proofs, but we can undo those if we don't feel they are necessary.

@jdchristensen
Copy link
Collaborator

Ok, I'm reviewing now, so hold off on pushing anything else for a bit.

theories/Pointed/Core.v Outdated Show resolved Hide resolved
Copy link
Collaborator

@jdchristensen jdchristensen left a comment

Choose a reason for hiding this comment

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

LGTM! Feel free to merge once the minor things I "pointed" out are fixed.

theories/Pointed/Core.v Outdated Show resolved Hide resolved
theories/Pointed/Core.v Outdated Show resolved Hide resolved
theories/Pointed/Core.v Outdated Show resolved Hide resolved
theories/Pointed/Core.v Outdated Show resolved Hide resolved
theories/Pointed/Core.v Outdated Show resolved Hide resolved
@jdchristensen
Copy link
Collaborator

The new pelim works very well! I see that it plays a slightly different role than pointed_reduce. pointed_reduce is more ambitious, trying to replace a pointed function with a strictly pointed function, while pelim is designed to handle things once the functions aren't needed any more, and only pointedness conditions remain. This is why the order of the arguments to pelim is important.

@Alizter
Copy link
Collaborator Author

Alizter commented Dec 29, 2023

@jdchristensen I can say that I didn't design pelim on purpose, it was a happy accident. I was simply trying to remove some funext from the precomposition lemmas and noticed that this pattern I was doing kept working so I turned it into a tactic. I'm glad it worked out in the end, and I hope it can be more widely useful. Especially in the cases where pointed_reduce leaves a poorly reduced goal.

@jdchristensen
Copy link
Collaborator

and I hope it can be more widely useful.

I may use it today after this is merged!

theories/Pointed/Core.v Outdated Show resolved Hide resolved
theories/Pointed/Core.v Outdated Show resolved Hide resolved
@Alizter Alizter force-pushed the ps/branch/2_cat_of_pointed_types branch from 34c5bf6 to bb8df44 Compare December 29, 2023 15:56
@Alizter
Copy link
Collaborator Author

Alizter commented Dec 29, 2023

@jdchristensen All comments addressed. I'll merge once the CI is green.

We show the (2,1)-category structure for pointed types. In order to do
this easily, we introduce a new tactic called pelim which allows easy
path induction on the pointed equation of various pointed structures.
This is particularly useful in removing funext from various pType
coherences.

Signed-off-by: Ali Caglayan <[email protected]>
Signed-off-by: Ali Caglayan <[email protected]>
Signed-off-by: Ali Caglayan <[email protected]>
@Alizter Alizter force-pushed the ps/branch/2_cat_of_pointed_types branch from bb8df44 to 933fe28 Compare December 29, 2023 16:08
@Alizter
Copy link
Collaborator Author

Alizter commented Dec 29, 2023

@jdchristensen I've made the clearing a try. It doesn't affect anything but it might be useful for the reasons you've stated, although I haven't encountered such a situation yet.

@jdchristensen
Copy link
Collaborator

I think it's ok if you merge now that one build has succeeded.

@Alizter Alizter merged commit dfe1e10 into HoTT:master Dec 29, 2023
21 checks passed
@Alizter Alizter deleted the ps/branch/2_cat_of_pointed_types branch December 29, 2023 16:13
@jdchristensen
Copy link
Collaborator

Did you do a squash merge by accident? Just a reminder that that's not our usual procedure.

@Alizter
Copy link
Collaborator Author

Alizter commented Dec 29, 2023

@jdchristensen That was on purpose sorry. I forgot that we preferred not to do this. I've gone ahead and forbid them from the repository settings so now only merge is available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants