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: deprecated: physics

Topic: ZX-calculus for category theorists


view this post on Zulip Xuanrui Qi (Jul 20 2023 at 07:17):

I've been trying to learn ZX-calculus for a while. While the calculus itself is quite straightforwadd, I find it a bit confusing when I try to connect it with category theory that I already know. Sure, I know it's a string diagram-like language, but sometimes I find the structures in ZX-calculus a bit inadequately defined. Of course, some correspond directly to category theory, e.g. monoids and comonoids. But sometimes that is not the case e.g. when it comes to spiders, they seem to be kind of similar to but definitely not the same as operads, which leaves me kind of confused coming from a CT background.

So, the question is, is there a sort of dictionary that translates structures in the ZX-caculus to standard category theory structures? I read in many places that the ZX-calculus basically corresponds to dagger-compact categories but most of it seems to be folklore.

view this post on Zulip John Baez (Jul 20 2023 at 08:33):

The ZX calculus is an example of a dagger-compact category, presented using generators and relations. I wouldn't say it "corresponds to dagger-compact categories".

view this post on Zulip John Baez (Jul 20 2023 at 08:35):

The spiders in the ZX calculus, and their basic properties, arise from the fact that this dagger-compact category is a [[hypergraph category]].

view this post on Zulip John Baez (Jul 20 2023 at 08:38):

The nLab has a pretty good explanation of hypergraph categories, but I recommend Fong and Spivak's paper, the last reference on that page, for a deep conceptual explanation - which is also sketched on the nLab page.

view this post on Zulip John Baez (Jul 20 2023 at 08:42):

Hypergraph categories seem confusing at first, since every object is a [[Frobenius monoid]] in a way not preserved by morphisms. But they are extremely important in applications to networks, so it's good to see a conceptual explanation.

view this post on Zulip John Baez (Jul 20 2023 at 09:42):

I have trouble believing that the key facts concerning the ZX calculus are "mostly folklore" because there are a lot of nice papers and theses about it, leading up to the completenesd theorem, but I'm not an expert on these. I vaguely imagine @Aleks Kissinger wrote s useful thesis about this stuff.

view this post on Zulip John Baez (Jul 20 2023 at 10:39):

For example this should explain the point of "spiders" to some extent:

https://arxiv.org/abs/1406.5942

view this post on Zulip John Baez (Jul 20 2023 at 12:17):

See for example Thm. 2.3, the "spider theorem".

view this post on Zulip Xuanrui Qi (Jul 20 2023 at 13:14):

John Baez said:

I have trouble believing that the key facts concerning the ZX calculus are "mostly folklore" because there are a lot of nice papers and theses about it, leading up to the completenesd theorem, but I'm not an expert on these. I vaguely imagine Aleks Kissinger wrote s useful thesis about this stuff.

or perhaps it's the opposite, there are just too many papers! in which case I'm having trouble maneuvering the literature... Thanks for the pointers though!

view this post on Zulip Xuanrui Qi (Jul 20 2023 at 13:17):

John Baez said:

The ZX calculus is an example of a dagger-compact category, presented using generators and relations. I wouldn't say it "corresponds to dagger-compact categories".

Ah, that makes more sense to me now, thanks. Coming from algebra I have no understanding of hypergraph categories at all and they indeed confuse me, I'll try Fong & Spivak's paper

view this post on Zulip Xuanrui Qi (Jul 20 2023 at 13:19):

but perhaps the ZX-calculus is not for me after all! I suppose a lot of it can just be done at the more general level of (arbitrary?) dagger-compact categories?

view this post on Zulip John Baez (Jul 20 2023 at 13:51):

The ZX calculus is a specific dagger-compact category, presented by generators and relations, which is useful in quantum computation: the various generators can in theory be implemented as 'quantum gates' and you can build bigger circuits from these by composing and tensoring them. If you're not interested in applications of category theory to quantum computation or the math of finite-dimensional Hilbert spaces then the ZX calculus is probably not for you.... except perhaps as a nice example of many ideas like dagger-compact categories, Frobenius algebras, hypergraph categories, the spider theorem, etc.

view this post on Zulip John Baez (Jul 20 2023 at 13:52):

I suppose a lot of it can just be done at the more general level of (arbitrary?) dagger-compact categories?

That depends on what "it" is.

view this post on Zulip John Baez (Jul 20 2023 at 13:55):

What are you trying to do, or understand?

view this post on Zulip Xuanrui Qi (Jul 20 2023 at 13:59):

I'm trying to use quantum computation as a vehicle to test/flesh out some of my ideas relating to linear logic, and my understanding so far is that quantum programs can be written in some kind of linear logic-based language :-) Maybe I'm looking for something akin to QWIRE?

view this post on Zulip Xuanrui Qi (Jul 20 2023 at 14:04):

so indeed I'm not trying to study FdHilb per se! I'm looking at it as an example of some class of "nice" symmetric monoidal categories

view this post on Zulip John Baez (Jul 20 2023 at 14:34):

Quantum programs are different than quantum circuits much as ordinary programs are different than ordinary electrical circuits.

You can think of the ZX calculus as describing a bunch of building blocks for quantum circuits, much as you might build ordinary circuits from resistors, capacitors, transistors etc. To understand the general category theory concepts behind the ZX calculus I recommend studying hypergraph categories.

If instead what you want is a "quantum programming language" inspired by category theory, you might look at A categorical model for a quantum circuit description language:

Quipper is a practical programming language for describing families of quantum circuits. In this paper, we formalize a small, but useful fragment of Quipper called Proto-Quipper-M. Unlike its parent Quipper, this language is type-safe and has a formal denotational and operational semantics. Proto-Quipper-M is also more general than Quipper, in that it can describe families of morphisms in any symmetric monoidal category, of which quantum circuits are but one example. We design Proto-Quipper-M from the ground up, by first giving a general categorical model of parameters and state.

There are also a lot of resources on Quipper, but this language is more "practical" and - it seems to me - more complicated.

view this post on Zulip John Baez (Jul 20 2023 at 14:38):

If you're really focused on linear logic (which may not actually be optimal for studying quantum computation) you might try On multiplicative linear logic, modality and quantum circuits.

view this post on Zulip Xuanrui Qi (Jul 20 2023 at 14:39):

Thanks, I'll take a look!

view this post on Zulip Jason Erbele (Jul 20 2023 at 22:30):

If you are interested in a more algebra-flavored string diagram calculus that involves spiders, you might take a look at @Pawel Sobocinski's Graphical Linear Algebra blog. That might help build some intuition that can be used with the ZX calculus.

view this post on Zulip Jason Erbele (Jul 20 2023 at 22:31):

Though if you're not really interested in the ZX calculus after all, I think John's suggestions will be more on target for what your goals seem to be.

view this post on Zulip John Baez (Jul 21 2023 at 08:05):

One exciting thing about the work of Pawel and also Jason himself is that it shows the math of the ZX calculus - the same interesting combination of Hopf and Frobenius monoids - appears not only in (FinVect,)(\mathsf{FinVect}, \otimes) but also in (FinVect,)(\mathsf{FinVect}, \oplus). Besides Jason's and my paper Categories in control, another good place to look for this is Fabio Zanasi's paper Interacting Hopf algebras: the theory of linear systems.

view this post on Zulip Xuanrui Qi (Jul 22 2023 at 14:30):

Interesting! I wonder if this is related to tropical geometry in some way

view this post on Zulip Cole Comfort (Jul 23 2023 at 15:02):

John Baez said:

One exciting thing about the work of Pawel and also Jason himself is that it shows the math of the ZX calculus - the same interesting combination of Hopf and Frobenius monoids - appears not only in (FinVect,)(\mathsf{FinVect}, \otimes) but also in (FinVect,)(\mathsf{FinVect}, \oplus). Besides Jason's and my paper Categories in control, another good place to look for this is Fabio Zanasi's paper Interacting Hopf algebras: the theory of linear systems.

@Xuanrui Qi This connection goes even deeper. For prime qudit dimension p, phase-free ZX (modulo nonzero scalars) is isomorphic as a prop to linear relations over Fp \mathbb{F}_p (one has to take relations internal to (FinVectFp,) ({\sf FinVect }_{\mathbb{F}_p},\oplus) , so what @John Baez said is not quite right) . This isomorphism is constructed by showing that the X X stabilizers have the structure of a vector space over Fp \mathbb{F}_p . This fact has been known since the graphical linear algebra people and categorical quantum mechanics people first met each other, but it is written down for the first time (I think) in @Fabio Zanasi 's PhD thesis for the qubit case.

This nice relational categorical semantics can be pushed to its furthest limit by identifying odd prime dimensional qudit mixed stabilizer ZX (modulo nonzero scalars) with affine coisotropic relations over Fp \mathbb{F}_p .

I prove this in the following preprint:
https://arxiv.org/pdf/2304.10584.pdf

which builds on previous work by @Aleks Kissinger and I:
https://arxiv.org/pdf/2105.06244.pdf

This connects the work that @John Baez, @Brendan Fong, @Brandon Coya where they use the machinery developed by @John Baez and @Jason Erbele in categories in control and show how one can interpret certain classes of electrical circuits in terms of the prop of affine Lagrangian relations. In our papers we give a string diagrammatic treatment of this prop (following the work on graphical linear algebra by and graphical affine algebra by @Pawel Sobocinski, @Fabio Zanasi , @Robin Piedeleu and @Filippo Bonchi ) and show how it is connected to the ZX-calculus. This is very much an active research area still, and we are writing more papers on this subject!

I will soon submit my PhD thesis which will focus on the categorical aspects of the ZX-calculus, and the connection to bicategories of relations.

I also have written about the categorical semantics of fragments of the ZH-calculus:
https://arxiv.org/pdf/2004.05287.pdf

If you don't want to wait for my thesis, a useful resource that exists in the literature is the lecture notes by @Chris Heunen and @Jamie Vicary on categorical quantum mechanics. I don't think they mention the ZX-calculus explicitly, but it is definitely worth a read and develops lots of the underlying theory that is used. After all, the ZX-calculus is more of a marketing term for certain monoidal theories interpreted in finite dimensional Hilbert spaces... so there is lots of related work that makes no mention of the ZX-calculus.

view this post on Zulip John Baez (Jul 23 2023 at 15:50):

Cole is right, I should have said the category of finite-dimensional vector spaces and linear relations - not the (sub)category of finite-dimensional vector spaces and linear maps!

view this post on Zulip Cole Comfort (Jul 23 2023 at 17:34):

John Baez said:

Cole is right, I should have said the category of finite-dimensional vector spaces and linear relations - not the (sub)category of finite-dimensional vector spaces and linear maps!

The usual setting in quantum mechanics is to look at the group of Fp2n \mathbb{F}_p^{2n} affine symplectomorphisms. When p p is an odd prime, this admits a faithful, projective representation into FHilb {\sf FHilb} picking out the Clifford group on n n qudits of prime dimension p p . This is known as the Weil representation when p p is an odd prime.

Now if you instead start with the more general prop of affine coisotropic relations over Fp \mathbb{F}_p then this Weil representation picks out exactly the stabilizer circuits, which is the topic of my paper.

But if you want to see this from a simpler perspective, forget the simplectic stuff and just look at the Weil representation of Fp \mathbb{F}_p linear maps in Hilb, and look at the Weil representation in Hilb. This gives you essentially circuits composed of controlled-not gates. When you then extend this to Fp \mathbb{F}_p linear relations you find that this representation exactly picks out the two frobenius algebras interacting to form a hopf algebra!

So from what I have read it seems like physicists often only use this non-relational representation.... but when you look at the relational/nondeterminisic version of quantized mechanics then the Weil representation gives you interacting Hopf-Frobenius algebras for free! And this is precisely where the ZX-calculus has really nice semantics!