-
Notifications
You must be signed in to change notification settings - Fork 23
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
free strict symmetric monoidal category #21
base: master
Are you sure you want to change the base?
Conversation
> freeComposition as bs cs fm1 fm2 = MkCompositionFreeMorphism fm1 fm2 | ||
> | ||
> postulate | ||
> freeLeftIdentity : |
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.
These postulates makes it possible to prove false:
oops : Void
oops = constructorsDisjoint (freeLeftIdentity [] [] (MkIdFreeMorphism []))
where
DistinguishThem : FreeMorphism () [] [] [] -> Type
DistinguishThem (MkIdFreeMorphism []) = Void
DistinguishThem _ = ()
constructorsDisjoint : MkCompositionFreeMorphism {t = ()} {generatingMorphisms = []} (MkIdFreeMorphism []) (MkIdFreeMorphism []) = (MkIdFreeMorphism []) -> Void
constructorsDisjoint p = replace {P = DistinguishThem} p ()
What you need to pursue this approach is some form of quotient type, which Idris unfortunately doesn't support.
But maybe there is some clever way to construct the free strict monoidal category explicitly, e.g. the free category on a graph can be constructed as the transitive closure of the edge relation (in other words, a morphism is a list of edges), which gives you the category laws for free, instead of having to quotient by them explicitly.
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.
This is fucked :( Do you have a reference for building free cats over graphs? Are you referring to the same construction one can find, say, on MacLane?
Also, should it be possible to generalize to monoidal categories by using hypegraphs as generators? :)
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 don't have access to MacLane at the moment, but it's probably the same construction. The nlab is quite explicit, and has further references:
https://ncatlab.org/nlab/show/path+category
From a type theory point of view, what is nice with this construction is that it is only involving free concepts (that hence can be implemented by inductive definitions), with no need to quotient. Compare with the construction of the free monoid, which is a very similar situation. I'll have to think about if hypergraphs would work. My immediate concern would be that we now also have to introduce morphisms not only from compositions of previously introduced ones, but also by applying the functoriality of the tensor, which I fear would need something more than just paths of edges.
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 dealt with similar issues a lot in Coq and Agda. I don't know if the path category approach works, but there are several ways to deal with the issue that quotient types don't exist.
In this scenario, I would postulate the existence of the quotient type locally. I.e. keep the type FreeMorphism
as it is but rename it to PreFreeMorphism
, and then postulate the existence of a new type FreeMorphism
together with a map quot : PreFreeMorphism ... -> FreeMorphism ...
, such that the type FreeMorphism
has exactly the structure that we want (i.e. the map is surjective, and quot x = quot y
if and only if they are of the forms as described by the postulates here). This is for example how real numbers are implemented in Coq.
Alternatively, one could deal with setoids, but everytime I did I regretted it big time.
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.
My gut feeling is that trying to go with what Fred said, but using hypegraphs, is probably worth trying first. If this experience has taught me something it is that postulate is a very dangerous construct to use. So if there's a way of giving definitions which avoids it completely, I'd gladly go for it.
In addition to it, Petri nets can clearly be seen as hypegraphs, where places are vertexes and transitions are hyperedges. Generating a free smc from an hypegraph should basically be exactly what we want (you have to add symmetries but I don't want to think about this right now :) )
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.
yes, I guess they are practically the same approach. This is just a concrete implementation
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.
Well then we know that at least two people in the team like this now!
Anyway, if this fixes it, go for it. Nevertheless, I'd consider it more of a momentary fix that a definitive thing: If we can get stuff done in terms of free compositions of other structures I'd feel way better :)
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.
In principle, other than using setoids this is the only solution in Idris, so if you consider this to be only a temporary fix, we either have to make large changes (like switching to a language that supports quotients or using setoids everywhere), or we have to give a quotient type explicitly.
In this scenario, there might actually be a reasonable way to do this. As long as the sets of generators are finite, the set of objects should be countable infinite and the set of morphisms between two objects should be finite (I haven't given much thought to it, maybe it is possible that some are coubtably infinite?). Thus, it should be possible to figure out the size of all the required types, and you would be able to construct something that is isomorphic to the quotient you want, without using postulates. That would be much more work though.
As an alternative, Agda 2.6 supports cubical type theory, so in particular quotient inductive types. Translating Idris code to Agda is reasonably quick and I have already translated everything in the Basic
directory. So we could just postulate that the quotients exist in a different file, and then have an Agda copy of that file where we just add the definition of the quotient we want and replace the postulates by theorems there. If it's just a definition of that one quotient, it's unlikely that that will change, so it shouldn't be a maintenance problem.
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.
Did you read my previous comments in terms of free structures? Why do you think it is not possible to do anything like this? It works for the path category, do you have elements to affirm there is no possible construction of FSSMCS in terms of free structures?
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.
To recap what we've decided in the meeting: It seems best to use postulates right now, to just give us the existence of the type we need. I think the proposal by @marcosh is a great start, but it should be done in such a way that the implementation of FSSMCS is parametrized over the implementation of the quotient. This would mean that whenever we find a good way to construct the type we need without postulates, we can just change a single line of code to switch between the implementation with postulates and any other implementation. Afterwards, we can decide how to tackle the implementation of that type, either via a subtype using normal forms, doing some random stuff with isomorphisms or by getting some of @FabrizioRomanoGenovese's ideas to work.
@WhatisRT @fredrikNordvallForsberg @FabrizioRomanoGenovese I pushed an update to this, which should solve the issue raised by Fredrik. Could you please take a look at it again and check it this could work? |
I think it looks good, but I'm thinking that it might be a good idea to export In case that export would also expose the constructors for |
@WhatisRT I'm not sure exporting Do you have in mind any example or use case where it could be useful to actually export it? In any case we could just postpone this decision and write a comment above the definition which states that, if needed |
Ok, I've realized that the functions provided already enable writing morphisms in the FSSMC. It might still be a good idea to expose the |
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.
So this seems to implement a symmetric monoidal category given a category (which can probably be turned into a free functor from categories to symmetric monoidal categories?), but I think if you want to get strictness from that, you need quotients...
To start off from generators and relations, you probably need to turn the generators and relations into a graph, then take the associated category, and then apply this construction.
No description provided.