-
Notifications
You must be signed in to change notification settings - Fork 184
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
biproducts, additive and abelian categories #1929
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Ali Caglayan <alizter@gmail.com>
Signed-off-by: Ali Caglayan <alizter@gmail.com>
Signed-off-by: Ali Caglayan <alizter@gmail.com>
Signed-off-by: Ali Caglayan <alizter@gmail.com>
Signed-off-by: Ali Caglayan <alizter@gmail.com>
Signed-off-by: Ali Caglayan <alizter@gmail.com>
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've only read partway, and will read more later.
I pushed a slight cleanup to using decidability. I'm guessing the lemmas/tactics I added can be used elsewhere. But if you think they don't help, feel free to revert. |
@jdchristensen They look helpful, thanks! |
Signed-off-by: Ali Caglayan <alizter@gmail.com>
Signed-off-by: Ali Caglayan <alizter@gmail.com>
Signed-off-by: Ali Caglayan <alizter@gmail.com>
Signed-off-by: Ali Caglayan <alizter@gmail.com>
Signed-off-by: Ali Caglayan <alizter@gmail.com>
Signed-off-by: Ali Caglayan <alizter@gmail.com>
Signed-off-by: Ali Caglayan <alizter@gmail.com>
theories/WildCat/Coproducts.v
Outdated
Definition coproduct_op {I A : Type} (x : I -> A) | ||
`{Is1Cat A} {H' : Product I x} | ||
: Coproduct I (A:=A^op) x. | ||
Proof. | ||
snrapply Build_Product. | ||
- exact (cat_prod I x). | ||
- exact cat_pr. | ||
- exact (fun z => cat_prod_corec I). | ||
- intros z f i. | ||
apply cat_prod_beta. | ||
- intros z f g p. | ||
apply cat_prod_pr_eta. | ||
exact p. | ||
Defined. | ||
: Coproduct I (A:=A^op) x | ||
:= H'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's interesting that this is very fast, but the test I tried to add showing that the Is1Cat
structure on A^op^op
is definitionally equal to the original Is1Cat
structure is slow. Any idea why, or how to make that test faster?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its just a bad combination of typeclass search and unification. I switched reflexivity
to nrefine idpath
and that cut it down to 3s from 6. I think whats left is just reduction.
The issue is that this completely unbundled approach has very poor sharing of terms. If you Set Printing All
you will see how huge the terms become. Coq is spending most of it's time unfolding and trying to unify stuff I believe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I don't understand is that in the proof of coproduct_op
, Coq should need to know that these Is1Cat
structures agree, and it does so almost instantly. Why is it fast here but takes 6s in the test? (If you add in the Defined
that adds an additional 6s, so it really takes 12s in the test.)
(Also, nrefine idpath
and exact idpath
are both slightly slower for me than reflexitivity
, and all three take around 6s.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's create an issue about this since I don't want to debug it at the moment. What I would do is create an opam switch with function pointer fp
enabled in the OCaml compiler. Afterwards I would use something like https://github.com/janestreet/memtrace to inspect the processor trace of the reduction. There we should be able to see what is taking the most time. (fp just names the function symbols in the machine code with nice names so we can find them in Coq's source).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try #[local] Strategy -100 [<list of constants that need to be unfolded for unification>]
or #[local] Strategy 100 [<list of constants that should not be unfolded>]
. You could debug by manually doing unfold Product, Coproduct in *. refine H'.
and seeing how much you have to unfold manually before things become fast
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the tip @JasonGross. Unfortunately it didn't help much. The terms involved just become so large that Coq's printer fails to even print it. I have no idea why there is such a huge increase in complexity compared to other tests in that file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've created #1936 so we can continue the discussion there.
Did you replace |
@jdchristensen I think |
@jdchristensen FTR, I will push some changes here shortly. I am working on smart constructors for biproducts and showing that AbGroup has them. |
Signed-off-by: Ali Caglayan <alizter@gmail.com>
Signed-off-by: Ali Caglayan <alizter@gmail.com>
Signed-off-by: Ali Caglayan <alizter@gmail.com>
@jdchristensen In the |
Signed-off-by: Ali Caglayan <alizter@gmail.com>
@jdchristensen Would you like me to split off the changes to |
Yes, it might be helpful to split it up. |
Signed-off-by: Ali Caglayan <alizter@gmail.com>
Signed-off-by: Ali Caglayan <alizter@gmail.com>
Signed-off-by: Ali Caglayan <alizter@gmail.com>
One of my merges accidentally introduced some WIP changes so the build fails. I will fix the build accordingly soon enough. |
Signed-off-by: Ali Caglayan <alizter@gmail.com>
I've fixed the build errors and tried to make progress on the cocommutative comonoids giving commutative monoid structures on the homs. Unfortunately, this doesn't follow formally from what I can tell so I had to reprove the argument like I did for commutative monoids giving commutative monoids. Once this is done, I have trouble using it since the is1bifunctor instance for cat_binbiprod and cat_bincoprod are different. One way to fix this is to redefine biproduct so that the coproduct structure is something that can be proved rather than part of the data. I don't know if this will really work, but I am getting quite stuck with this approach, however I'll continue to experiment when I have more time. |
It should be formal. If I haven't looked at the code you pushed, so I don't know how this compares to what have done, but the point is that the argument factors into two parts, and the second part is definitional, and doesn't require that you check the commutative monoid axioms again. |
As you said, it should be possible to prove that the double opposite monoid structure is the original structure, however this does not appear to be the case definitionally hence why I struggled earlier. One possible way to fix this is to fix natural transformations (and equivlaences) to become definitionally involutive as highlighted in #1961. This would allow the associator and unitors to be definitionally involutive. (For the full monoidal structure it seems we would need two pentagons and two traingles) however I don't see any use for that yet) |
Even if it is not definitional that a comonoid in |
Here is a definition of biproducts, semiadditive categories and additive categories. We show that semiadditive categories have a commutative monoid structure on their hom and additive categories have an abelian group structure.
We also show that the group of endormorphisms forms a ring with composition.
Kernels, cokernels and abelian categories are also defined.
I will probably split this PR further into smaller parts once the main theory has been settled. I'll keep it here for a global overview.
TODO
5 years ago I was apparently interested in doing this: