Category Theory
Zulip Server
Archive

You're reading the public-facing archive of the Category Theory Zulip server.
To join the server you need an invite. Anybody can get an invite by contacting Matteo Capucci at name dot surname at gmail dot com.
For all things related to this archive refer to the same person.


Stream: practice: software

Topic: Catlab.jl


view this post on Zulip Sophie Libkind (May 11 2020 at 20:38):

@James Fairbanks @Evan Patterson I've been playing around with Catlab.js and I was wondering how to instantiate something like a Poset. Would it make sense to define a theory that inherits from Category? Or as an instance of a Category?

view this post on Zulip James Fairbanks (May 11 2020 at 20:42):

you are thinking of a poset as a category where Ob(C)Ob(C) is the elements of the set and Hom(a,b)Hom(a,b) is empty unless aba\leq b right?

view this post on Zulip James Fairbanks (May 11 2020 at 20:43):

Here is the version for preorders https://github.com/epatters/Catlab.jl/pull/148/files

view this post on Zulip Sophie Libkind (May 11 2020 at 20:44):

I'm thinking of a poset as a category with Hom(a,b)BoolHom(a,b) \in Bool

view this post on Zulip Sophie Libkind (May 11 2020 at 20:44):

Ah cool! Thanks!

view this post on Zulip sarahzrf (May 11 2020 at 20:45):

a poset is a category enriched in truth values, not where the hom sets are the set of truth values

view this post on Zulip sarahzrf (May 11 2020 at 20:45):

so you want an \in up there, not an ==

view this post on Zulip Evan Patterson (May 11 2020 at 20:45):

The source file added by that PR is: https://github.com/epatters/Catlab.jl/blob/master/src/doctrines/Preorders.jl

view this post on Zulip sarahzrf (May 11 2020 at 20:45):

also, it's probably a good idea to distinguish between truth values and booleans if you're doing constructive work!

view this post on Zulip Evan Patterson (May 11 2020 at 20:46):

So you can see that we have a thin category, which inherits from category, and also a preorder, which does not. From the comment at the end, you can see that we want to say that these are related, but haven't yet implemented that machinery.

view this post on Zulip James Fairbanks (May 11 2020 at 20:47):

I think you just need to add antisymmetry to go from preorder to poset. so you could inherit from ThinCategory and add an additional axiom for antisymmetry. We don't really have the machinery for enforcing or testing the axioms, right now they are carried around in the relevant data structures

view this post on Zulip James Fairbanks (May 11 2020 at 20:49):

following the julia approach we leave a lot of the rule following to the user. since you can't actually enforce anything in julia, haven't spent a lot of effort on implementing enforcement.

view this post on Zulip Sophie Libkind (May 11 2020 at 20:51):

In one experiment, I composed two morphisms ff and gg where the codomain of ff did not match the domain of gg and it composed no problem. Is that an example of leaving the rule following to the user?

view this post on Zulip Evan Patterson (May 11 2020 at 20:52):

That can be enforced. It depends on how the expressions are set up in the @syntax macro.

view this post on Zulip Evan Patterson (May 11 2020 at 20:53):

When strict=true, like here, it should work. (If it doesn't, it's a bug and please report it.)

view this post on Zulip James Fairbanks (May 11 2020 at 20:53):

that might be bug i've hit stuff like that before where stuff composes fine and then later you try to convert it to a wiring diagram or something and you get a runtime error in the WD code because it is checking that things match up.

view this post on Zulip James Fairbanks (May 11 2020 at 20:54):

when strict=true, that means that the syntax system will check for well formedness, right?

view this post on Zulip Evan Patterson (May 11 2020 at 20:54):

It means that it will check that, e.g., domains and codomains match when composing. More generally, it enforces the equalities implied by the GAT term and type constructors.

view this post on Zulip Sophie Libkind (May 11 2020 at 20:55):

In this particular experiment, I believe I had defined an @instance macro. What are the use case differences between @instance and @syntax?

view this post on Zulip James Fairbanks (May 11 2020 at 20:55):

i definitely assumed that strict meant strictification

view this post on Zulip Evan Patterson (May 11 2020 at 20:55):

OK, maybe we should use a different word.

view this post on Zulip Evan Patterson (May 11 2020 at 20:56):

The reason that this is even an option, BTW, is that if you have nontrivial equations between your objects, then it may be difficult or impossible to verify that the domain and codomain objects are actually equal before composing.

view this post on Zulip James Fairbanks (May 11 2020 at 20:57):

so an instance is basically a functor into the "category" of julia types and julia functions. You map every object to a julia type and every morphism to a julia function.

view this post on Zulip Evan Patterson (May 11 2020 at 20:57):

Sophie, the short version is that @instance is for regular Julia types and @syntax is for symbolic expressions.

view this post on Zulip James Fairbanks (May 11 2020 at 20:57):

oh yeah that is shorter than my version.

view this post on Zulip Evan Patterson (May 11 2020 at 20:58):

A long version is here :)

view this post on Zulip Sophie Libkind (May 11 2020 at 20:58):

Okay! So if I want to work with integers and functions between integers then I use an @instance macro and Julia will do the work of composition etc. for me

view this post on Zulip James Fairbanks (May 11 2020 at 20:58):

yeah

view this post on Zulip Sophie Libkind (May 11 2020 at 20:59):

vs. if I was to define a more abstract category then I use the @syntax macro and Catlab will keep track of all my expressions

view this post on Zulip James Fairbanks (May 11 2020 at 21:00):

yeah and you would often do both, like have a syntax where you express things symbolically and then have an instance where "real" computation happens.

view this post on Zulip James Fairbanks (May 11 2020 at 21:01):

like in the GLA case you want to use symbolic expressions to describe linear operators as composites of small linear operators and then you want to pick some matrices and solve some equations.

view this post on Zulip James Fairbanks (May 11 2020 at 21:03):

This file shows you a pretty complex example, https://github.com/epatters/Catlab.jl/blob/master/src/linear_algebra/GLA.jl

view this post on Zulip James Fairbanks (May 11 2020 at 21:03):

the instance comes from LinearMaps.jl which is like a lazy linear algebra library.

view this post on Zulip Evan Patterson (May 11 2020 at 21:06):

Another example says that wiring diagrams are an instance of symmetric monoidal categories.