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.
Some promising approaches to automated equational reasoning for monoidal categories that I and others have been playing with https://www.philipzucker.com/metatheory-progress/
This is really interesting! I had intended to experiment using Z3 for verifying diagrammatic proofs, so it's good to see someone has already tried. What kind of structures does Metatheory.jl support natively? Am I right in understanding you're trying to encode GATs into those structures (with partial success)?
It is unclear to me exactly what Metatheory supports in theoretical terms. It does what it does. It's something like a rewrite system, something like the theory of uninterpreted functions. I put forward what a think is a correct method to encode GATs. but I am not 100% certain. I have not mechanized actually producing this encoding yet. I did it by hand.
I would have thought the "right" structure (at least from a theoretical point of view) would be generalised algebraic theories with rewrites, though I'm not sure if this translates across to e-graphs. You can encode structure like binding operators using generalised algebraic theories, which avoids having to describe more complex higher-order structures directly in e-graphs.
You can encode binding using GATs? How?
As in the point free formulation of binding? vs Or something else?
You describe everything internally: so you have a type for "contexts", a type for "types", a type for "terms", etc. Then you have operations for extending contexts, etc. This is essentially the approach of "type-theory-in-type-theory", which uses quotient-inductive-inductive types (which are closely related to GATs).
I think I see. You explicilty hold bound terms before a turnstile?
A -abstraction operator would take a term in an extended context, for instance, and return a term in the non-extended context. E.g. something like in an untyped setting.
That's very interesting. It does seem like a rather heavyweight encoding for automation to handle, but who knows.
Agreed: the disadvantage with describing everything internally is that the automation can't take advantage of knowing "what the constructions mean" for optimisation purposes (at least naïvely), but the advantage is that you can describe many more structures than you would be able to externally (because you don't need to invent new structures for describing more complex data types).
If you are even able to demonstrate viability of automation for equations involving categories, functors, and natural transformations, that will already be a huge step forwards, though.
That's the dream. Workin' on it
This is a problem I'm very interested in, and would be very happy to discuss in more detail at some point :)
The current set of discussion that I'm aware has been happening on the Julia zulip. I poke my head in over here very rarely because it is overwhelming.
But where does the variable go? Is everything de bruijn indexed?
Essentially, yes. You avoid variable names altogether.
(Though possibly a more principled approach to variable names, like nominal calculi, could also work as a GAT.)
I see. Manipulating de bruijn indices in the egraph is so far non obvious(to me) that one can do it, and non obvious if they even make sense. My intuition so far is that the egraph is a bit more than just a bag of syntax. The automated sharing and congruence closure can do some surprising things.
I emailed one of the egg authors https://egraphs-good.github.io/ about this and it seems it's still an open question from his perspective as well
It's not necessarily to think about de Bruijn indices explicitly, though: they're hidden in the structure of the GAT. If you can represent arbitrary GATs, you can represent de Bruijn indices.
Nathanael Arkor said:
A -abstraction operator would take a term in an extended context, for instance, and return a term in the non-extended context. E.g. something like in an untyped setting.
Note that there are no explicit indices here.
This suggests to me that either de bruijn indices are fine or I'm not actually able to represent arbitrary GATs.
There are indices in t though?
If I'm not wrong, F* uses de Bruijn indices in practice in its SMT encoding (but I don't think that's the most efficient part of the encoding)
Oh really? Fascinating.
Do they describe that in a paper or is it just internally in the code base?
Philip Zucker said:
There are indices in t though?
Where? You mean would be represented by an index?
I was assuming a term would be something like abs(var(0))
for id for example.
Actually you can represent a variable just by an operator without an index; its index is captured by the context it is in. It's a little involved to describe exactly how this works, though.
This is what I meant by "Essentially, yes." Actually there are no explicit indices, and they are instead represented by the term structure itself.
(Probably the type-theory-in-type-theory literature contains an explicit worked example in this vein.)
So what would you write for id? Or is the question poorly formed?
And how would you write \x y -> x
The intuition is that you don't encode arbitrary higher-order operations: you encode structures that have higher-order operations (e.g. lambda-calculi). So whenever you want to describe a higher-order operation, you first need to describe contexts and terms.
Another way to describe it is that in a GAT, you have a first-order context. But you can encode higher-order contexts using GATs. So they if you have a higher-order structure, you can describe it internally with respect to the encoded higher-order context, rather than the "metatheoretical" first-order context of the GAT.
I'm afraid I don't follow without something more specific
I wanted to write up an explicit example at some point anyway, so when I get around to it, I'll let you know. Then I can figure out how best to present it :)
Hi everybody! Author of Metatheory.jl here
@Alessandro: hi! I would be interested to hear your thoughts on data structures for algebraic/symbol computation, especially in terms of what Metatheory.jl currently supports and what you have considered supporting in the future. Have you looked at generalised algebraic theories at all?
I have given a quick look at GATs. I'm not a mathematician sadly.
Nathanael Arkor said:
Alessandro: hi! I would be interested to hear your thoughts on data structures for algebraic/symbol computation, especially in terms of what Metatheory.jl currently supports and what you have considered supporting in the future. Have you looked at generalised algebraic theories at all?
Here are our current efforts:
https://github.com/0x0f0f0f/Metatheory.jl/blob/master/test/test_cat.jl
Simple equivalence proving in SMCs with explicit type tagging
@Philip Zucker 's blogpost
https://www.philipzucker.com/metatheory-progress/
I also made a version of the same rules that is compiled to the browser using the egg library (Metatheory and egg are related systems, one in Julia, one in Rust)
http://www.philipzucker.com/rust-category/