9

What is the representation of the CH gate in ZX-calculus?

Is there a general recipe for going from a ZX-calculus representation of a gate to the representation of the controlled version?

Sanchayan Dutta
  • 17,497
  • 7
  • 48
  • 110
Daniel Mahler
  • 331
  • 1
  • 5

4 Answers4

11

In answer to your first question, yes there is a way to build controlled-$H$ in ZX. It more or less mirrors the construction in quantum circuits. First, one can construct controlled-$Z$-phase gates using the technique described in the "Quantum Computing" chapter of mine and Coecke's book (Picturing Quantum Processes, p. 687):

controlled-Z phase

n.b. the white dots are $Z$-spiders, gray dots are $X$-spiders.

This is a controlled phase gate, which conditionally applies a $Z(\alpha)$ on the second qubit if the first qubit is $|1\rangle$. Using the bialgebra law, it is not too hard to show this is actually equivalent to a more familiar "circuit-like" form of the gate:

CZ circuit form

From the controlled-$\operatorname{Z}$ phase gate, wrap the control bit in Hadamards to get a controlled-$X$ phase gate.

To create a controlled Hadamard, take its Euler decomposition to get $Z(\pi/2) X(\pi/2) Z(\pi/2)$, then to get the controlled version, replace each of the phase gates with controlled-phase gates.

As a general rule (and somewhat in line with Nick's answer), any "circuit-like" ZX-diagram (i.e. built out of $\operatorname{CNOT}$, $H$, and phase gates) can be transformed into the controlled version much like you can with a circuit. Phases become controlled-phases, $H$s becomes controlled-$H$s, and $\operatorname{CNOT}$s become Toffolis (which can also be constructed from spiders, though it's a bit more elaborate).

There is also a general technique for adding control wires to ZX-diagrams, which is explained in a recent paper by Jeandel, Perdrix, and Vilmart: arXiv:1805.05296

However, either technique tends to yields big, unwieldy diagrams. If you find you are working with controlled or multiply-controlled operations a lot, the ZH calculus (a variation on ZX which allows many-legged $H$-gates) could be more convenient to work with: arXiv:1805.02175.

Sanchayan Dutta
  • 17,497
  • 7
  • 48
  • 110
Aleks Kissinger
  • 211
  • 1
  • 3
  • Thanks Aleks! Did you by and chance mean that the H gates wrap the target qubit to turn a CZ into a CX? – Daniel Mahler May 05 '19 at 04:17
  • 1
    An important detail is missing from this post: the Hadamard gate is only equal to the Euler decomposition Aleks gave up to a global phase of $e^{i\pi/4}$. This global phase is not important when considering the Hadamard on its own, but when making it controlled, this global phase becomes a local phase and needs to be taken into account. – John Dec 15 '20 at 10:10
6

The easiest way to do this would be to use the general controlled unitary construction given in this post: Given a decomposition for a unitary $U$, how do you decompose the corresponding controlled unitary gate $C(U)$? translate the circuit to ZX and hopefully simplify the circuit using ZX rewrite rules to get a nicer expression.

5

First, there is a neat way of performing the controlled Hadamard, with only two occurrences of the $T$ gate:

control-H

Regarding your second question, I can give an answer that will get a tad technical, based on the paper arXiv:1805.05296. We are going to use the following construction

control-plus

that we generalise to $n$ wires:

control-plus-generalised

The reason we denote this operator like this is if plug $|0\rangle$ on the control half-edge, we get the identity, while if we plug $|1\rangle$ we get $2|+\rangle\langle+|$.

We are given a diagram $U:n\to n$. The first thing we do is use the map/state duality to get a diagram $U':0\to 2n$

map-state-duality

Now, suppose there exists a diagram $\Lambda U':1\to 2n$ such that $\Lambda U'|0\rangle = 2^n|+^{2n}\rangle$ and $\Lambda U'|1\rangle = U'$. Then the controlled version of $U$ can be performed by building:

control-U

The question hence boils down to finding such a $\Lambda U'$. A first "naive" solution is to treat the map $U'$ nearly as a black box: we only require you know a non-null entry of $U'$: $\langle a_1...a_{2n}| U' = x \neq0$ for some $a_1,...,a_{2n}\in\{0,1\}^{2n}$, and such that one can represent $\begin{pmatrix}1\\1/x\end{pmatrix}$ with a diagram $\Lambda (1/x):0\to 1$ in the fragment (in the unrestricted ZX-Calculus, this is always possible). Using yet another construction:

transistor

generalised to:

transistor-generalised

we can define $\Lambda U'$ as:

lambda-U

Renaud Vilmart
  • 382
  • 3
  • 7
  • 1
    Your first decomposition is not correct, as it does not take into account the global phase of the Hadamard gate that becomes a local phase when making it controlled. An additional $T^\dagger$ gate needs to be added to the control wire to fix this (which gives the standard 3 T gate decomposition of a CHAD) – John Dec 15 '20 at 10:11
4

If you use the symbol of triangle and lambda box in ZX, see e.g. my paper with KangFeng Ng arXiv:1706.09877, then there are two simple ways of representing the CH gate in ZX-calculus, one of them even need not any decomposition of the H gate (diagrams should be read from top to bottom):

CH without decomposition

If you don't want any H showing in CH, then you have another diagram for CH: CH without H

From my experience, translating C(U) circuits into ZX usually is not an easy way for getting nice expression even after ZX simplification, if you don't know a nicer expression in advance.

Harny Wang
  • 49
  • 2