# A Complete Graphical Language for Linear Optical Circuits with Finite-Photon-Number Sources and Detectors

Nicolas Heurtel

► To cite this version:

Nicolas Heurtel. A Complete Graphical Language for Linear Optical Circuits with Finite-Photon-Number Sources and Detectors. CSL 2025 - 33rd EACSL Annual Conference on Computer Science Logic, Feb 2025, Amsterdam, Netherlands. 10.4230/LIPIcs.CSL.2025.38 . hal-05333097

HAL Id: hal-05333097

https://hal.science/hal-05333097v1

Submitted on 27 Oct 2025

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# A Complete Graphical Language for Linear Optical Circuits with Finite-Photon-Number Sources and Detectors

Nicolas Heurtel

<figure><img src="image_2.png" /></figure>

Quandela, 7 Rue Léonard de Vinci, 91300 Massy, France

Université Paris-Saclay, CNRS, ENS Paris-Saclay, Inria, Laboratoire Méthodes Formelles, 91190, Gif-sur-Yvette, France

## Abstract

Graphical languages are powerful and useful to represent, rewrite and simplify different kinds of processes. In particular, they have been widely used for quantum processes, improving the state of the art for compilation, simulation and verification. In this work, we focus on one of the main carrier of quantum information and computation: linear optical circuits. We introduce the $LO_{fi}$-calculus, the first graphical language to reason on the infinite-dimensional photonic space with circuits only composed of the four core elements of linear optics: the phase shifter, the beam splitter, and auxiliary sources and detectors with bounded photon number. First, we study the subfragment of circuits composed of phase shifters and beam splitters, for which we provide the first minimal equational theory. Next, we introduce a rewriting procedure on those $LO_{fi}$-circuits that converge to normal forms. We prove those forms to be unique, establishing both a novel and unique representation of linear optical processes. Finally, we complement the language with an equational theory that we prove to be complete: two $LO_{fi}$-circuits represent the same quantum process if and only if one can be transformed into the other with the rules of the $LO_{fi}$-calculus.

**2012 ACM Subject Classification** Theory of computation → Quantum computation theory; Theory of computation → Axiomatic semantics; Hardware → Quantum computation

**Keywords and phrases** Quantum Computing, Graphical Language, Linear Optical Circuits, Linear Optical Quantum Computing, Completeness, Fock Space.

**Funding** This work has been partially funded by the European Commission as part of the EIC accelerator program, under the grant agreement 190188855, by the French National Research Agency (ANR) with the project TaQC ANR-22-CE47-0012 and within the framework of “Plan France 2030”, under the research projects EPIQ ANR-22-PETQ-0007, OQULUS ANR-23-PETQ-0013, HQI-Acquisition ANR-22-PNCQ-0001 and HQI-R&D ANR-22-PNCQ-0002, and by the CIFRE 2022/0081.

## Contents

<table><tr><td>1 Introduction</td><td>2</td></tr><tr><td>2 LOPP: Linear optical quantum circuits with single-photon semantics</td><td>4</td></tr><tr><td>2.1 Syntax and single-photon semantics</td><td>5</td></tr><tr><td>2.2 Simpler equational theory of LOPP</td><td>6</td></tr><tr><td>2.3 Useful triangular forms</td><td>7</td></tr><tr><td>3 $LO_{fi}$-calculus</td><td>9</td></tr><tr><td>3.1 Fock space</td><td>9</td></tr><tr><td>3.2 Syntax and many-photon semantics</td><td>10</td></tr><tr><td>3.3 Equational theory of $LO_{fi}$</td><td>11</td></tr></table>
<table><tbody><tr><td>4</td><td>Unique normal forms leading to the completeness of the LO<sub>fi</sub>-calculus</td><td>11</td></tr><tr><td>4.1</td><td>Deterministic rewriting procedure</td><td>13</td></tr><tr><td>4.2</td><td>Normal forms of the LO<sub>fi</sub>-calculus</td><td>13</td></tr><tr><td>4.3</td><td>The normal forms are unique: sketch of the proof</td><td>16</td></tr><tr><td>4.4</td><td>Completeness of the LO<sub>fi</sub>-calculus: Proof of Theorem 31</td><td>17</td></tr><tr><td>5</td><td>Outlook</td><td>17</td></tr><tr><td>A</td><td>Notations</td><td>22</td></tr><tr><td>B</td><td>Section 2</td><td>22</td></tr><tr><td>B.1</td><td>Euler angles of (E2) and (E3)</td><td>22</td></tr><tr><td>B.1.1</td><td>Euler angles of (E2)</td><td>23</td></tr><tr><td>B.1.2</td><td>Euler angles of (E3)</td><td>24</td></tr><tr><td>B.2</td><td>Completeness of LOPP: Theorem 7</td><td>25</td></tr><tr><td>B.3</td><td>Minimality of LOPP: Equation (E3) is necessary</td><td>29</td></tr><tr><td>B.4</td><td>Properties of the triangular forms of Section 2.3</td><td>31</td></tr><tr><td>C</td><td>Some properties of the LO<sub>fi</sub>-circuits</td><td>32</td></tr><tr><td>C.1</td><td>Choice of the generators</td><td>32</td></tr><tr><td>C.2</td><td>Remarkable properties</td><td>32</td></tr><tr><td>D</td><td>Rewriting system of Section 4</td><td>33</td></tr><tr><td>D.1</td><td>LO<sub>fi</sub> is complete for LOPP</td><td>33</td></tr><tr><td>D.2</td><td>Derivation of the rewriting system: Lemma 35</td><td>33</td></tr><tr><td>D.3</td><td>Strongly normalising: Proof of Lemma 39</td><td>37</td></tr><tr><td>D.4</td><td>Rewriting to the zero normal form: Proof of Remark 38</td><td>38</td></tr><tr><td>E</td><td>Uniqueness of the normal forms of Section 4</td><td>40</td></tr><tr><td>E.1</td><td>Uniqueness of T in the normal form: Lemma 41</td><td>40</td></tr><tr><td>E.2</td><td>Linear independence of the Ω-morphisms</td><td>41</td></tr><tr><td>E.3</td><td>Equivalent decomposition with the creation operators</td><td>42</td></tr><tr><td>E.4</td><td>Uniqueness of the canonical decomposition</td><td>43</td></tr><tr><td>F</td><td>Proofs of Appendix E</td><td>44</td></tr><tr><td>F.1</td><td>Proof of Proposition 58</td><td>44</td></tr><tr><td>F.2</td><td>Example 60: the creation operator through a beam splitter</td><td>45</td></tr><tr><td>F.3</td><td>Proof of Lemma 62</td><td>45</td></tr></tbody></table>

# 1 Introduction

Quantum computing is a paradigm for processing information [42, 46] that performs computation with quantum states, instead of the classical states of bits. This computational paradigm allows specific computational problems to be solved with quadratic [25] or even exponential speedup [51, 27] compared to their classical counterparts. To encode that quantum data, many technologies have been pursued, such as superconducting circuits [33], trapped ions [8] and cold atoms [24].

One of the prominent candidates for quantum computation is linear optics [37, 43, 48], where the *logical* information is encoded into the quantum states of photons, the *particles* of light. For quantum computation, the logical states are encoded onto the *modes* of the
photons, i.e. their degrees of freedom like their *positions* in the circuit, and the desired logical
operations are performed with optical components. All scalable quantum computations with
linear optics [35, 50, 34, 41] encoding with the positions of the photons use predominantly
these following elements.

- Sources: they generate the quantum state, i.e. a vector in a Hilbert space,

- Phase shifters: they change the quantum state by adding a phase to the light passing through them<fnref n="1" />,

- Beam splitters: they alter the quantum state by causing photons on two different paths to interfere with each other<fnref n="2" />,

- Detectors: they project the quantum state on a subspace.

As ubiquitous as the circuits made of those components are in linear optical quantum computation schemes, as illustrated in Figure 1 and 2, many unanswered questions persist regarding optimality, minimality and an efficient use of those components. We wish to have a framework finding the most appropriate implementation for the desired computation or protocol. The purpose of this work is therefore to propose a formal framework to model and manipulate generic circuits composed of the four previous elements.

**State of the art.** Some main formal frameworks to study, develop or optimize quantum processes are graphical languages [2, 50, 3, 44], representing processes with diagrams and equations between those diagrams. These formalisms have been shown to be very useful for addressing quantum processes in general, such as **ZX**-diagrams [13] with applications in compilation [30, 5, 52], simulation [32, 31, 36] and verification [19, 22]. To completely capture the processes those diagrams model, [29, 26] have introduced a complete set of equations: two equivalent **ZX**-diagrams can always be transformed from one to the other with those equations.

Recently, some works have modeled optical processes with diagrams [4, 12, 40], including notably **LO<sub>v</sub>** [10], a complete graphical language for linear optical circuits with vacuum sources and detectors, and **QPath** [15], a graphical language to compute amplitudes. Remarkably, both have also led to results beyond the optical realm, as a subfragment of the first led to derive the first complete equational theory for quantum circuits [11], while the second introduced a functor from the **ZX**-calculus [15] and led to a more generic language [16].

However, those two frameworks don't completely capture linear optical circuits with sources and detection schemes. In particular, **LO<sub>v</sub>** lacks a many-photon semantics and can only cover the single-photon case, while **QPath** uses sums of diagrams in the rewriting process along with generators that are not linear optical components. For instance, we would like to be able to model the photonic implementation of the CZ gate [35, 34], a prominent logical quantum gate, and rewrite it to equivalent forms, as illustrated in Figure 1.

**Challenges.** In seeking to develop a graphical language for modeling linear optical circuits with a many-photon semantics, there are two main challenges. First, the bosonic Fock space, representing all the states that photons can be in, is an infinite-dimensional Hilbert space: the bosonic Fock space. In particular, some properties and generators of graphical languages with finite-dimensional theories [45, 53, 18] cannot be used. Second, the

<footnote n="1">¹ They are typically implemented using thermo-optic components, where the refractive index of the waveguide is changed by heating the material.</footnote>

<footnote n="2">² In integrated circuits, beam splitters are implemented using waveguides that split and combine light paths.</footnote>

<footnote n="3">³ Some phases have been added to take into account the different conventions for the semantics of the beam splitters.</footnote>
<figure><img src="image_3.png" /><figcaption>■ **Figure 1** Optical circuits implementing the CZ two-qubit logic gate with auxiliary sources and detectors. On the left is the original circuit³ of [34]. There are two auxiliary photon generated on the bottom left: if exactly one photon is detected for each of the two last wires on the bottom right, then we know we have performed the operation $|11\rangle \mapsto -|11\rangle$ on the two first wires. This event has a probability $\frac{2}{27}$ to occur. On the right is an equivalent representation in the $LO_{fi}$-calculus, where $f$ and $g$ are two-photon states and linear forms.</figcaption></figure>

<figure><img src="image_4.png" /><figcaption>■ **Figure 2** Linear optical circuit generating with a $\frac{1}{9}$ probability the Bell state $|\Phi^+\rangle = |1010\rangle + |0101\rangle$, with the use of auxiliary sources and detectors. On the left is the original³ circuit of [21], on the right is an equivalent and modular description. Both are equivalent circuits in the $LO_{fi}$-calculus.</figcaption></figure>

interaction of photons, even without bringing auxiliary modes and detections into the picture, is described by the permanents of matrices [49, 1], making cumbersome explicit expression and manipulation of all the involved terms.

**Contributions.** In this paper, we propose such a framework, and introduce the $LO_{fi}$-calculus, the first graphical language defined on the bosonic Fock space, with circuits composed of four core elements of linear optics: the phase shifter, the beam splitter, and auxiliary finite-photon-number sources and detectors. Our main contributions are the following.

- A complete equational theory for circuits with phase shifters and beam splitters which is simpler than the one in [10], and that we prove to be minimal (Section 2).

- A new sound and complete equational theory for linear optical circuits that allows all auxiliary finite-photon-number states and detections (Section 3).

- A unique and compact universal form for optical circuits of this kind, obtained through a deterministic rewriting procedure and proven to be unique with new techniques (Section 4). All the notation introduced in the paper is summarized in Table 1.

## 2 LOPP: Linear optical quantum circuits with single-photon semantics

A linear optical quantum circuit consists of spatial modes through which photons pass — which may be physically instantiated by optical fibers, waveguides in integrated circuits, or simply by paths in free space (bulk optics) — and operations that act on those spatial
$$ \begin{gathered} \left[ \mathop{\vcenter{\hbox{\strut \$\displaystyle\left|\vphantom{\displaystyle\int} \right.\vphantom{\displaystyle\int} \right|}} \right]_1 : \mathbb{C}^2 \to \mathbb{C}^2 := \begin{array}{rcl} |1,0\rangle & \mapsto & |0,1\rangle \\ |0,1\rangle & \mapsto & |1,0\rangle \end{array} \\ \left[ \mathop{\vcenter{\hbox{\strut \$\displaystyle\int}} \vphantom{\displaystyle\int}} \right]_1 : \mathbb{C}^2 \to \mathbb{C}^2 := \begin{array}{rcl} |1,0\rangle & \mapsto & c_\theta |1,0\rangle + i s_\theta |0,1\rangle \\ |0,1\rangle & \mapsto & i s_\theta |1,0\rangle + c_\theta |0,1\rangle \end{array} \\ \text{where } c_\theta = \cos(\theta) \text{ and } s_\theta = \sin(\theta). \end{gathered} $$

**Remark 4.** It is also usual to represent those linear operators as matrices, with

$$ [[C_1]]_1 \oplus [[C_2]]_1 = \left( \frac{\left[ \begin{array}{c} C_1 \end{array} \right]_1}{0} \middle| \frac{0}{\left[ \begin{array}{c} C_2 \end{array} \right]_1} \right) \quad \text{and for instance} \quad \left[ \mathop{\vcenter{\hbox{\strut \$\displaystyle\int}} \vphantom{\displaystyle\int}} \right]_1 = \begin{pmatrix} c_\theta & i s_\theta \\ i s_\theta & c_\theta \end{pmatrix}. $$

## 2.2 Simpler equational theory of LOPP

Two distinct **LOPP**-circuits may represent the same quantum evolution. For instance, shifting the phase of a photon by two phase shifters of phase $\varphi_1$ and $\varphi_2$ is the same as shifting it with one phase $\varphi_1 + \varphi_2$. In order to characterize those equivalences, an equational theory of **LOPP** has been introduced in [10]. In this section, we provide a simpler set of equations in Figure 3. Some of the old equations, given in Figure 4, have been removed, while two Equations (oE2) and (oE3) of Figure 4 have been replaced by the two Equations (E2) and (E3), respectively representing Euler rotations with two and three axes. Previously, those old Euler equations were not directly reversible; while the angles of the right-hand side (RHS) could be uniquely determined by those of the left-hand side (LHS), the inverse was true only with non-trivial constraints, making the equations hardly reversible and not explicitly constructive. More specifically, we made the following simplifications:

- The Equations (b0), (p0) and (pp-b) have been derived and removed from the equational theory.

- A phase has been added in Equation (oE2), so now the LHS can also represent any element of the unitary group $U(2)$. Now the angles of the LHS can be straightforwardly derived without any constraints from the RHS.

- All the phases of Equation (oE3) have been removed. The formulae of the equations are now far simpler, and the equation is now both symmetrical and reversible.

**Definition 5 (LOPP-calculus).** Two **LOPP**-circuits $D, D'$ are equivalent according to the rules of the **LOPP**-calculus, denoted **LOPP** $\vdash D = D'$, if one can transform $D$ into $D'$ using the equations given in Figure 3. More precisely, **LOPP** $\vdash \cdot = \cdot$ is defined as the smallest congruence which satisfies the equations of Figure 3 and the axioms of PROP.

**Proposition 6 (Soundness of LOPP).** For any **LOPP**-circuits $D$ and $D'$, if **LOPP** $\vdash D = D'$ then $[[D]]_1 = [[D']_1$.

**Proof.** Since semantic equality is a congruence, it suffices to check that for every equation of Figure 3. The soundness of Equations (swap), (p2$\pi$) and (p-p) are direct consequences of Definition 3. We can notice that $R_X(-2\theta) = \left[ \mathop{\vcenter{\hbox{\strut \$\displaystyle\int}} \vphantom{\displaystyle\int}} \right]_1$ and $e^{i\frac{\pi}{2}} R_Z(\varphi) = \left[ \mathop{\vcenter{\hbox{\strut \$\displaystyle\int}} \vphantom{\displaystyle\int}} \right]_1$, where $R_X$ (resp. $R_Z$) is the rotation operator about the $\hat{x}$ axis (resp. $\hat{z}$ axis) of the Bloch sphere [42]. Any unitary of $U(2)$ can be decomposed into $e^{i \cdot R_X(\cdot) R_Z(\cdot) R_X(\cdot)}$ (resp. $e^{i \cdot R_Z(\cdot) R_X(\cdot) R_Z(\cdot)}$), giving the LHS (resp. RHS) angles of (E2). More explicit formulae are given in Section B.1.1. By transforming the $iY$-axis into the $Y$-axis, the three rotations of the LHS (resp. RHS) of (E3) can be seen as three real rotations along the $z - x - z$ real axes (resp. $x - z - x$). The angles are therefore given by the Euler angles [23]. More explicit formulae are given in Section B.1.2.

<figure><img src="image_5.png" /></figure>
<figure><img src="image_6.png" /><figcaption>■ **Figure 4** Old axioms of the **LOPP**-calculus that are not in Figure 3. They are derived in Appendix B.2. In Equations (oE2) and (oE3), the LHS circuit has arbitrary parameters which uniquely determine the parameters of the RHS circuit. For any $\alpha_i \in \mathbb{R}$, there exist $\beta_j \in [0, 2\pi)$ such that Equation (oE2) is sound, and for any $\gamma_i \in \mathbb{R}$, there exist $\delta_j \in [0, 2\pi)$ such that Equation (oE3) is sound. We can ensure that the angles $\beta_j$ are unique by assuming that $\beta_1, \beta_2 \in [0, \pi)$ and if $\beta_2 \in \{0, \frac{\pi}{2}\}$ then $\beta_1 = 0$, and we can ensure that the angles $\delta_j$ are unique by assuming that $\delta_1, \delta_2, \delta_3, \delta_4, \delta_5, \delta_6 \in [0, \pi)$. If $\delta_3 \in \{0, \frac{\pi}{2}\}$ then $\delta_1 = 0$, if $\delta_4 \in \{0, \frac{\pi}{2}\}$ then $\delta_2 = 0$, if $\delta_4 = 0$ then $\delta_3 = 0$, and if $\delta_6 \in \{0, \frac{\pi}{2}\}$ then $\delta_5 = 0$. The existence and uniqueness of such $\beta_j$ and $\delta_j$ are given by Lemmas 10 and 11 of [10].</figcaption></figure>

► **Definition 9** ($\triangle$-circuits). A $\triangle$-circuit is a **LOPP**-circuit with the following shape:

<figure><img src="image_7.png" /></figure>

with $\varphi_{i,j} \in [0, 2\pi)$, $\theta_{i,j} \in [0, \frac{\pi}{2}]$ and the following conditions: $\theta_{i,j} = 0 \Rightarrow (\forall j' > j, \varphi_{i,j'} = \theta_{i,j'} = 0)$ and $\theta_{i,j} = \frac{\pi}{2} \Rightarrow \varphi_{i,j} = 0$. $\theta_{i,j}$ is on the $i^{th}$ right (resp. $j^{th}$ left) diagonal, and on the $(i + j - 1)^{th}$ row of beam splitters.

► **Remark 10** (Coefficients of $[\triangle]_1$). The coefficient $t_{i,j}$ of $[\triangle]_1$ is determined by the sum of all the paths from the $j^{th}$ input wire to the $i^{th}$ output wire, where for each path we multiply by a cos (resp. sin) term when the photon is reflected on (resp. transmitted through) a beam splitter, and by a phase when the path crosses a phase shifter. For instance, $t_{1,2} = \cos(\theta_{1,2})e^{i\varphi_{1,2}}i \sin(\theta_{1,1})e^{i\varphi_{1,1}}$. More generally, we have $t_{i,j} = e^{i\varphi_{i,j}} \cos(\theta_{i,j}) \times q_{i,j} + r_{i,j}$ where $q_{i,j}, r_{i,j}$ are terms depending uniquely on the angles with lower indexes.

► **Proposition 11** (Universality and Uniqueness of $T$). For any **LOPP**-circuit $D$, there exists a unique circuit $T$ in triangular form of Definition 9 such that $[D]_1 = [T]_1$.

**Proof.** The existence is a direct consequence of [47] or the Proposition 26 of [10]. The uniqueness is a consequence of Remark 10 by sequentially showing the uniqueness of $(\varphi_{i,j}, \theta_{i,j})$ in $t_{i,j}$, and by noticing that for any $z$ with $0 < |z| \le 1$, there are unique $\varphi, \theta \in [0, 2\pi) \times [0, \frac{\pi}{2})$ such that $e^{i\varphi}c_{\theta} = z$, with $\varphi, \theta = (0, 0)$ for the special case of $z = 0$. More details are provided in Appendix B.4.

<figure><img src="image_8.png" /></figure>
► **Remark 12.** A generic $\triangle$-circuit $T: n \rightarrow n$ has $\frac{n(n-1)}{2}$ beam splitters and $\frac{n(n+1)}{2}$ phase shifters, having a total of $n^2$ different angles, the dimension of the unitary group $U(n)$.

► **Definition 13** ($\tilde{n} \triangleq \tilde{m}$-circuits). A LOPP-circuit $\tilde{\triangle} : n + \tilde{n} \rightarrow m + \tilde{m}$ is a $\tilde{n} \triangleq \tilde{m}$-circuit if:

1. $\tilde{\triangle}$ is a $\triangle$-circuit as defined in Definition 9,

2. there is no beam splitter or phase shifter fully and directly connected to the $\tilde{n}$ last input wires, ie. $\phi_{i,j} = \theta_{i,j} = 0$ if $row_{i,j} = i + j - 1 > n$ and there doesn't exist $(k, \ell)$ such that $k + \ell - 1 = row_{i,j} - 1$, $k < i$ and $\theta_{k,\ell} \neq 0$,

3. there is no beam splitter or phase shifter fully and directly connected to the $\tilde{m}$ last output wires, ie. $\phi_{i,j} = \theta_{i,j} = 0$ if $row_{i,j} = i + j - 1 > m$ and there doesn't exist $(k, \ell)$ such that $k + \ell - 1 = row_{i,j} - 1$, $k \ge i$ and $\theta_{k,\ell} \neq 0$, and

4. there exists one nonzero $\theta_{i,j}$ for each of the last $\max(\tilde{n}, \tilde{m})$ rows.

The Property 4 is an additional constraint that appears in the normal forms defined in Definition 36. Property 2 and 3 imply the only nonzero angles have indexes $(i \le m, j \le n)$, leading to the following proposition, direct consequence of Remark 10 and the proof of Proposition 11.

► **Proposition 14** (Uniqueness of $\tilde{n} \triangleq \tilde{m}$-circuits on their $m \times n$ submatrix). For any $\tilde{n} \triangleq \tilde{m}$-circuits $\triangle, \triangle': n + \tilde{n} \rightarrow m + \tilde{m}$, if $[\triangle]_1 (1:m, 1:n) = [\triangle']_1 (1:m, 1:n)$ then $\triangle = \triangle'$, where $M(1:k, 1:\ell)$ is the $k \times \ell$ matrix composed of the first $k$ rows and $\ell$ columns of $M$.

► **Definition 15** ($\tilde{n} \Diamond_n$-circuits). A $\tilde{n} \triangleq \tilde{m}$-circuit $\tilde{\triangle} : n + \tilde{n} \rightarrow m + \tilde{m}$ is a $\tilde{n} \Diamond_n$-circuit if $\tilde{m} = n$.

► **Remark 16.** As $\tilde{m} = n$, $\tilde{n} \Diamond_n$-circuits have exactly $\tilde{n} \times n$ beam splitters shaped like in Table 10. Furthermore, their angles are necessarily nonzero, as one zero would imply the rest of the right-diagonal to be zero with Definition 9, contradicting the Property 4. That particular shape and those nonzero properties will be useful in the proofs of Section 4.

# 3 LO<sub>fi</sub>-calculus

## 3.1 Fock space

As described in Section 2.1, the state space of one photon with $m$ spatial modes is $C^m$, as it can be on a superposition of all the different positions. Photons are particles that can bunch and share the same state, so each mode can be occupied by many photons. Furthermore, to observe quantum effects like interferences, we need the photons to be indistinguishable, meaning we can't know which photon is in which state.

For those two reasons, the usual way to represent a state with indistinguishable photons is by using the occupation number representation, where we indicate "$how many photons are there in each state$". We consider the basis states $\Phi_m := \{|n_1, n_2, \dots, n_m\rangle, (n_1, n_2, \dots, n_m) \in \mathbb{N}^m\}$ [1], denoted as *Fock states*. The state $|n_1, n_2, \dots, n_m\rangle$ represents a configuration where $n_i$ photons occupy the $i^{th}$ mode. The space of possible many-photon states over $m$ modes, the *bosonic (symmetrical) Fock space* and denoted as $\mathcal{B}_m$, is defined as follows.

► **Definition 17** (Fock space). We define the Hilbert space $\mathcal{B}_m$ as the Hilbert completion $\ell^2(\Phi_m)$ equipped with the *bra-ket inner product* $\langle\cdot|\cdot\rangle$, with the convention $\mathcal{B}_0 = \mathbb{C}$.

► **Remark 18.** $\mathcal{B}_1$ contains states that are an *infinite* superposition of basis states, like the coherent states $|\alpha\rangle = e^{-\frac{|\alpha|^2}{2}} \sum_{k=0}^{\infty} \frac{\alpha^k}{k!} |k\rangle$. We can note that $\mathcal{B}_m$ is isomorphic to $\ell^2(\mathbb{N}^m)$.
To describe the space of the auxiliary sources, we consider a sub vector space of $\mathcal{B}_m$.
**Definition 19 (Subspace of the Fock space: $\mathcal{B}_m^{\text{pre}}$).** We define the pre-Hilbert space $\mathcal{B}_m^{\text{pre}}$ as the linear span of $\Phi_m$ equipped with the bra-ket inner product $\langle\cdot|\cdot\rangle$, with the convention $\mathcal{B}_0^{\text{pre}} = \mathbb{C}$.

**Remark 20.** $\mathcal{B}_m^{\text{pre}}$ only contain states that are finite linear combination of the Fock basis states. In particular, the coherent states are not included. We can note that $\mathcal{B}_1^{\text{pre}}$ is isomorphic to $c_{00}$, i.e. the space of eventually zero sequences.

**Definition 21 ($\mathcal{B}_m^{\text{pre}}$).** We define the pre-Hilbert space $\mathcal{B}_m^{\text{pre}}$ as the linear span of $\{(n_1, \dots, n_{\tilde{m}} | (n_1, \dots, n_{\tilde{m}}) \in \mathbb{N}^{\tilde{m}})\}$.

## 3.2 Syntax and many-photon semantics

**Definition 22 (LO<sub>fi</sub>-calculus).** $\text{LO}_{fi}$ is the PROP of LO<sub>fi</sub>-circuits generated by

<figure><img src="image_9.png" /></figure>

where $\varphi, \theta \in \mathbb{R}$, and $\mathbf{f}$ (resp. $\mathbf{g}$) is a state in $\mathcal{B}_{\tilde{n}}^{\text{pre}}$ (resp. in $\mathcal{B}_{\tilde{m}}^{*\text{pre}}$) with $\tilde{n}, \tilde{m} \in \mathbb{N}^+$.

**Remark 23.** In string diagrams, a process $0 \to \tilde{n}$ (resp. $\tilde{m} \to 0$) is called a state (resp. an effect). We will keep the source (resp. detector) terms to be consistent with their physical representation. A process $0 \to 0$ is called a scalar.

**Remark 24.** The choice of those generators is discussed in Appendix C.1.

**Definition 25 (Conventions for the notations).** Bold terms will always be vectors. In particular $\mathbf{f}, \mathbf{f}_k$ (resp. $\mathbf{g}, \mathbf{g}_l$) will always represent a ket (resp. a bra). Bold integers $k$ (resp. $\ell$) will represent $|k\rangle$ (resp. $\langle\ell|$) in the sources (resp. detectors). The summation term $\sum$ will often be omitted, the index being implicitly the sum index. Note that for clarity, the summation term won't be omitted in Figure 6, and for conciseness, they will be omitted in Figure 5. For instance $\mathbf{f} = \sum_{k \in \mathcal{K}} |\mathbf{f}_k\rangle |k\rangle$ will simply be noted as $\mathbf{f}_k \otimes \mathbf{k}$. $|\cdot\rangle$ (resp. $\langle\cdot|$) represents an arbitrary ket (resp. bra) on one mode. $|\dots\rangle$ (resp. $\langle\dots|$) represents an arbitrary ket (resp. bra) for an arbitrary number of modes, representing an arbitrary scalar when the number of modes is zero. Those are used to omit terms when the specific value of those terms are not of interest, as in some equations of Figure 5. For the zero vector $\mathbf{f} = 0$ (resp. $\mathbf{g} = 0$), as there is no term in the sum, we chose to represent it with $|0\rangle$ (resp. an empty detector $\mathbf{f} = 0$). Note it is different from $|1\rangle$ (resp. $\mathbf{f} = 1$) representing the nonzero vector $|0\rangle$ (resp. $\langle 0|$).

**Definition 26.** Let $C: n \to m$ a LO<sub>fi</sub>-circuit, let $[[C]] : \mathcal{B}_n \to \mathcal{B}_m$ be the linear map inductively defined as $[[C_2 \circ C_1]] = [[C_2]] \circ [[C_1]]$, $[[C_1 \otimes C_2]] = [[C_1]] \otimes [[C_2]]$ and:

<figure><img src="image_10.png" /></figure>
where $B_{\theta}(|k_1, k_2\rangle) := \sum_{\ell_1+\ell_2=k_1+k_2} \sqrt{\frac{\ell_1!\ell_2!}{k_1!k_2!}} \sum_{\substack{p+q=\ell_1 \\ \delta=p-q}} \binom{k_1}{p} \binom{k_2}{q} c_{\theta}^{k_2+\delta} (i s_{\theta})^{k_1-\delta} |\ell_1, \ell_2\rangle$ and

$P_{\varphi}(|k\rangle) := e^{ik\varphi} |k\rangle$, with the convention $\binom{k}{k'} = 0$ for $k < k'$.

We can check that $P_{\varphi}$ and $B_{\theta}$ are unitary operators [1] and are therefore well-defined on the Hilbert space by continuity and linearity. One can also look at [37] or the Examples 59 and 60 in Appendix E.3 for a more physical interpretation of where the formulas come from.

► **Remark 27 (Hermitian conjugate).** We have $P_{\varphi}^{\dagger} = P_{-\varphi}$ and $B_{\theta}^{\dagger} = B_{-\theta}$, where $\dagger$ is the Hermitian conjugate. Therefore, $\langle \ell | P_{\varphi} = (P_{-\varphi} | \ell \rangle)^{\dagger}$ and $\langle \ell_1, \ell_2 | B_{\theta} = (B_{-\theta} | \ell_1, \ell_2 \rangle)^{\dagger}$.

### 3.3 Equational theory of LO<sub>fi</sub>

Similarly to Section 2.2, we introduce an equational theory for LO<sub>fi</sub> in Figure 5.

► **Definition 28 (LO<sub>fi</sub>-calculus).** Two LO<sub>fi</sub>-circuits C, C' are equivalent according to the rules of the LO<sub>fi</sub>-calculus, denoted LO<sub>fi</sub> $\vdash$ C = C', if one can transform C into C' using the equations given in Figure 5.

► **Remark 29.** The Equation (p-p) is not present for it can be derived with the Equations (p2π), (E2) and (s0-0d), alongside with Equation (b0), that can be derived with the rules of the PROP, and the Equations (swap) and (E2). The derivation is detailed in Appendix D.1. Note that the Equaiton (h2) can be considered an equation of diagrams with holes.

► **Proposition 30 (Soundness).** For any two LO<sub>fi</sub>-circuits C and C', if LO<sub>fi</sub> $\vdash$ C = C' then $[C] = [C']$.

**Proof.** Since semantic equality is a congruence, it suffices to check the soundness for every equation of Figure 5, which follows from Proposition 6 and Definition 26. Informally, Axiom (zero) means that if there is the scalar<fnref n="5" /> 0, then the semantics of all the circuit ($X \otimes 0 = 0$) is the null function. We can therefore nullify the other wires with the zeros $\emptyset$ and $-\emptyset$. This rule is specifically used for Remark 38. Axiom (s-0d) means we can either (from LHS to RHS) project on $|0\rangle$ on the last mode or (from right to left) add any states $f_k \otimes |k\rangle$ with $k \neq 0$ as they are trivially orthogonal and cancelling. Axiom (h2) means we can shift any function $h: B_2^{\text{pre}} \to B_2^{\text{pre}}$ from left to right where there are identity wires, direct consequence of the associativity: $\langle \ell_1, \ell_2 | (h | k_1, k_2) \rangle = (\langle \ell_1, \ell_2 | h \rangle | k_1, k_2)$. The rules (dd), (b-d), (p-d) and (s0-d) are respectively the duals of (ss), (s-b), (s-p) and (s-0d). ◀

► **Theorem 31 (Completeness).** For any two LO<sub>fi</sub>-circuits C and C', if $[C] = [C']$ then LO<sub>fi</sub> $\vdash$ C = C'.

**Proof.** The proof is in Section 4.4, direct consequence of the uniqueness of the normal forms of Section 4. ◀

## 4 Unique normal forms leading to the completeness of the LO<sub>fi</sub>-calculus

We introduce a set of oriented rewriting rules in Section 4.1, that converge to a set of LO<sub>fi</sub>-circuits with specific shape and properties, defined in Section 4.2. The proof of their uniqueness is summarised in Section 4.3. As a direct collorary of the uniqueness of the normal forms, we prove the completeness of the LO<sub>fi</sub>-calculus in Section 4.4.

<footnote n="5">⁵ $\boxed{0} \dashv\dashv \boxed{1}$ is an impossible event and is one way to represent the scalar $0 = \langle 1 | 0 \rangle = [[\boxed{0}] \dashv\dashv \boxed{1}]$.</footnote>
$$ \boxed{2\pi} = \underbrace{\phantom{\alpha_1}}_{\alpha_2} \underbrace{\alpha_3}_{\boxed{\phantom{\alpha_1}}} = \underbrace{\phantom{\beta_1}}_{\beta_2} \underbrace{\beta_3}_{\boxed{\phantom{\beta_1}}} \quad \text{(swap)} $$

$$ \alpha_1 \quad \alpha_2 \quad \alpha_3 = \underbrace{\beta_1}_{\boxed{\phantom{\beta_1}}} \quad \underbrace{\beta_2}_{\boxed{\phantom{\beta_2}}} \quad \underbrace{\beta_3}_{\boxed{\phantom{\beta_3}}} \quad \text{(E2)} $$

$$ \gamma_1 \quad \gamma_2 \quad \gamma_3 = \underbrace{\delta_1}_{\delta_2} \quad \underbrace{\delta_2}_{\delta_3} \quad \underbrace{\delta_3}_{\delta_1} \quad \text{(E3)} $$

$$ \boxed{0} = \boxed{\phantom{\alpha_1}} \quad \text{(s0-0d)} \quad \underbrace{\phantom{\alpha_1}}_{\alpha_2} = \underbrace{\phantom{\alpha_1}}_{\alpha_3} \quad \text{(zero)} $$

$$ \boxed{f} = \boxed{\phantom{\alpha_1}} \quad \text{(ss)} \quad \boxed{\phantom{\alpha_1}} = \boxed{\phantom{\alpha_1}} \quad \text{(s-b)} $$

$$ \boxed{f_k \otimes k} = \boxed{\phantom{\alpha_1}} \quad \text{(s-0d)} \quad \boxed{\phantom{\alpha_1}} = \boxed{\phantom{\alpha_1}} \quad \text{(s-p)} $$

$$ \boxed{g} = \boxed{\phantom{\alpha_1}} \quad \text{(dd)} \quad \boxed{\phantom{\alpha_1}} = \boxed{\phantom{\alpha_1}} \quad \text{(b-d)} $$

$$ \boxed{g \otimes l} = \boxed{\phantom{\alpha_1}} \quad \text{(s0-d)} \quad \boxed{\phantom{\alpha_1}} = \boxed{\phantom{\alpha_1}} \quad \text{(p-d)} $$

$$ \boxed{|\dots\rangle \otimes h(k_1 k_2)} = \boxed{\phantom{\alpha_1}} \quad \text{(h2)} $$

■ **Figure 5** Axioms of the $LO_{fi}$-calculus. The angles of (E2) and (E3) are the same as in the axioms of the $LOPP$-calculus (Figure 3). $h$ is any linear function $B_2^{\text{pre}} \to B_2^{\text{pre}}$. The conventions for $\{\emptyset, |., ...\rangle, \langle., |, ...|\rangle$, and the omitted sums are detailed in Definition 25. The interpretations of the axioms are given in Proposition 30.
## 4.1 Deterministic rewriting procedure

A strongly normalising rewriting system, i.e. terminating to normal forms, has been introduced in [10] for **LOPP**-circuits. We mainly reuse all the rules, alongside additional rules to now take into account the sources and the detectors.

**► Definition 32 (Rewriting system).** *Our rewriting system is defined on the PRO<sup>6</sup> of LO<sub>fi</sub>-circuits with the rules of Figure 6.*

We can check that all the rules are sound, and have the following meaning:

- The rules 1-11 are either the same or just slightly different from the rules described in [10]. With those rules, the **LOPP<sup>PRO</sup>-circuits** will converge to the triangular **△-circuits** defined in Section 2.3.

- The rule 12 removes any vector $|f_{k'}\rangle \otimes |k'\rangle$ in the sources that is trivially cancelling with the detector on the connected last wire, meaning that $\langle g_{k'} | = 0$, i.e. that $k' \notin \mathcal{L}$.

- The rule 13 removes any $\langle g_{\ell'} | \otimes \langle \ell' |$ in the detectors that is trivially cancelling with the source on the connected last wire, meaning that $|f_{\ell'}\rangle = 0$, i.e. that $\ell' \notin \mathcal{K}$.

- The rule 14 allows, without changing the semantics, to transfer the generic coefficients from the detectors to the sources. Specifically, any term of the form $\sum_{\ell} \xi_{\ell} \langle \mathcal{N}_{\tilde{m}}(L) | \langle \ell |$ will be rewritten to $\langle \mathcal{N}_{\tilde{m}}(L) | \langle L |$. The coefficients $\xi_{\ell}$ will be in the source, as $|f_{\ell}\rangle |L\rangle$ will be rewritten to $(\sum_{i \in \mathcal{K}} \xi_i |f_i\rangle) |L\rangle$. At the end and by repeating this rule, there won't be any degree of freedom in the detectors, and $g = \sum_{\ell \in \mathcal{L}} \langle \mathcal{N}_{\tilde{m}}(\ell) | \langle \ell |$. The condition $(\xi_L \neq 1) \lor (\exists \ell \neq L, \xi_\ell \neq 0)$ is there to ensure that the rule is only used once for each $L$, and only when it's necessary.

- The rule 15 uses the bijection $\mathcal{N}_2 : \mathbb{N} \to \mathbb{N}^2$ to remove one identity wire, by just relabelling the indexes in the sources and detectors. Note that one identity wire will always remain at the end.

- The oriented rule (from left to right) coming from the axioms (ss) and (dd) merge all the sources and detectors together.

- The oriented rule (from left to right) coming from the axioms (s-b), (s-p), (b-d) and (p-d) reduce the number of phase shifters and beam splitters as much as possible, by making them be absorbed into the sources and detectors.

**► Definition 33 (Inputs of the rewriting system).** *For convenience, the inputs of the rewriting procedures are LO<sub>fi</sub>-circuits with at least one identity wire connecting sources and generators, and where all the sources (resp. detectors) are on the bottom left (resp. right).*

**► Remark 34.** Note that choice is not restrictive, as the identity wire can always be added with Axiom (s0-0d), and the sources and detectors can be placed at the desired position, without changing the semantics, with the rules of PROP and by adding SWAPs.

**► Lemma 35.** If $C_1$ rewrites to $C_2$ using the rules of Figure 6, then $LO_{fi} \vdash C_1 = C_2$.

*Proof.* The rules are derived in Appendix D.2.

<figure><img src="image_11.png" /></figure>

## 4.2 Normal forms of the LO<sub>fi</sub>-calculus

Formally with the rules of Figure 6 and informally with their meaning described in Section 4.1, we can show that an irreducible form is a **LO<sub>fi</sub>-circuit** defined as follows:

<footnote n="6">⁶ This is similar to [10], to prevent any deformation of the form $\mathcal{L} \mathcal{L} = \mathcal{L}$.</footnote>
**► Definition 36 (Normal form).** The normal forms of any nonzero LO<sub>fi</sub>-circuits are denoted $N(T, \boldsymbol{f}) : n \to m$ and are of the form:

<figure><img src="image_12.png" /></figure>

where:

- $\boldsymbol{f}$ is a nonzero generic state of $B_{\tilde{n}+1}^{pre}$.

- $\boldsymbol{g} = \sum_{\ell \in K} \langle N_m(\ell) | \otimes | \ell \rangle$, where $N_m : \mathbb{N} \to \mathbb{N}^m$ is a bijection defined in Figure 6 and $K$ is the nonempty finite set $\{k \in \mathbb{N} | \boldsymbol{f}_k \neq 0\}$ of $\boldsymbol{f} = \sum_{k \in K} \boldsymbol{f}_k \otimes |k\rangle$, with the convention $K = \{0\}$ if $\tilde{n} = 0$ or $\tilde{m} = 0$.

- $T : n + \tilde{n} \to m + \tilde{m}$ is a $\tilde{n} \Delta_{\tilde{m}}$-circuit as defined in Definition 13.

**► Remark 37.** If $\tilde{n} = \tilde{m} = 0$, then the normal form is a normal form of LOPP (can be $\begin{tikzpicture}[baseline={([yshift=-.5ex]current bounding box.center)}] \draw (0,0) -- (0,1); \draw (1,0) -- (1,1); \node[above] at (0,1) {$N$}; \node[above] at (1,1) {$m$}; \node[right] at (1,0) {$\tilde{n} = 0$}; \node[left] at (0,0) {$\tilde{m} = 0$}; \node[below] at (0.5,0) {$\alpha \in \mathbb{C}$}; \end{tikzpicture}$ for $n = m = 0$) tensored with the scalar $\begin{tikzpicture}[baseline={([yshift=-.5ex]current bounding box.center)}] \draw (0,0) -- (0,1); \draw (1,0) -- (1,1); \node[above] at (0,1) {$N$}; \node[above] at (1,1) {$m$}; \node[right] at (1,0) {$\tilde{n} = 0$}; \node[left] at (0,0) {$\tilde{m} = 0$}; \node[below] at (0.5,0) {$\alpha \in \mathbb{C}$}; \end{tikzpicture}$ which has the semantics of a global scalar $\alpha \in \mathbb{C}$.

**► Remark 38.** We could also consider the particular case of $\boldsymbol{f} = 0$, i.e. $K = \emptyset$, where $[[N]] : B_n \to B_m$ is the null function. We show in Appendix D.4 that $N : n \to m$ can be written to $(\begin{tikzpicture}[baseline={([yshift=-.5ex]current bounding box.center)}] \draw (0,0) -- (0,1); \draw (1,0) -- (1,1); \node[above] at (0,1) {$N$}; \node[above] at (1,1) {$m$}; \node[right] at (1,0) {$\tilde{n} = 0$}; \node[left] at (0,0) {$\tilde{m} = 0$}; \node[below] at (0.5,0) {$\alpha \in \mathbb{C}$}; \end{tikzpicture}) \otimes^m \begin{tikzpicture}[baseline={([yshift=-.5ex]current bounding box.center)}] \draw (0,0) -- (0,1); \draw (1,0) -- (1,1); \node[above] at (0,1) {$N$}; \node[above] at (1,1) {$m$}; \node[right] at (1,0) {$\tilde{n} = 0$}; \node[left] at (0,0) {$\tilde{m} = 0$}; \node[below] at (0.5,0) {$\alpha \in \mathbb{C}$}; \end{tikzpicture} \otimes^n$, which is a more fitted form for representing the null function.

**► Lemma 39 (Strongly normalising).** The rewriting system of Figure 6 is strongly normalising.

**Proof.** We introduce a ranking function $(x_1, \dots, x_6) \in \mathbb{N}^6$, where each component of the tuple is determined by properties of the circuit, like the number of beam splitter with angles out of $[0, 2\pi)$, the number of sources and detectors, or the number of identity wires connecting them. One nontrivial component is $x_6$, that we explicit here.

Let note the generic terms in the sources as $\boldsymbol{f} = \sum \alpha_{k_1, \dots, k_{\tilde{n}+1}} |k_1, \dots, k_{\tilde{n}+1}\rangle$ and in the detectors as $\boldsymbol{g} = \sum \beta_{\ell_1, \dots, \ell_{\tilde{m}+1}} |\ell_1, \dots, \ell_{\tilde{m}+1}\rangle$. We define:

$$x_6 := \sum_{\boldsymbol{f} \in \text{sources}} C_1(\boldsymbol{f}) + \sum_{\boldsymbol{g} \in \text{detectors}} (2C_2(\boldsymbol{g}) - C_3(\boldsymbol{g}))$$

with $C_1(\boldsymbol{f}) := \#\{\alpha_{k_1, \dots, k_{\tilde{n}+1}} \neq 0\}$, $C_2(\boldsymbol{g}) := \#\{\beta_{\ell_1, \dots, \ell_{\tilde{m}+1}} \neq 0\}$, and $C_3(\boldsymbol{g}) := \#\{\beta_{N_{\tilde{m}}(L), L} = 1, L \in \mathbb{N}\}$. The proof to show that the rule (14) strictly decreases $x_6$ is the following. Let us consider the two cases: $(\xi_L \neq 1) \land (\forall \ell \neq L, \xi_\ell = 0)$ and $(\xi_L = 1) \land (\exists \ell \neq L, \xi_\ell = 0)$. The first case doesn't change $C_1$ and $C_2$, but the term $-C_3$ strictly decreases by 1. The second case doesn't change $C_3$, and the increase of $C_1$, i.e. the amount of new terms in $\boldsymbol{f}$, is bounded by $\#\{\xi_i \neq 0, i \neq L\}$, the number of terms removed in $\boldsymbol{g}$, which is the exact decrease of $C_2$. Therefore, $C_1 + 2C_2$ decreases by at least $\#\{\xi_i \neq 0, i \neq L\} > 0$. We can conclude that the rule (14) strictly decreases $x_6$. The rest of the proof is given in Appendix D.3. ◀

Now that the normal forms are well-defined, it remains to prove their uniqueness, which is the purpose of the Section 4.3.

**► Lemma 40 (Uniqueness of the Normal Forms).** If two LO<sub>fi</sub>-circuits $N$ and $N'$ in normal forms are such that $[[N]] = [[N']']$, then $N = N'$.
**► Proposition 46** (Threshold properties of the Δ-morphisms). For any $\tilde{n} \diamondsuit_n$-circuit $\tilde{\Delta} : n+m \rightarrow n+m$ and $(\mathbf{u}, \mathbf{v}) \in (\mathbb{N}^n, \mathbb{N}^m)$, $\langle \mathbf{y} | \Delta^{\mathbf{u},\mathbf{v}}(\tilde{\Delta}) | \mathbf{x} \rangle$ is nonzero for $(\mathbf{x}, \mathbf{y}) = (\mathbf{v}, \mathbf{u})$ and is zero if $(\mathbf{x} \prec_r \mathbf{v}) \lor (\mathbf{y} \prec_r \mathbf{u})$, where $\prec_r$ is the reverse lexicographical order, i.e. $\mathbf{y} \prec_r \mathbf{v}$ if there exists $k$ such that $y_n = v_n, \dots, y_{k+1} = v_{k+1}$ and $y_k < v_k$.

**Proof.** It is a consequence of the shape of the $\tilde{n} \diamondsuit_n$-circuits (Definition 15), and the properties of $\Delta^{\mathbf{u},\mathbf{v}}$. As there is no photon in the auxiliary sources, the input needs a certain number of photons for them to be detected in the auxiliary detectors. Similarly, as we create photons at the output with the creation operators $\hat{a}^\dagger$, the output needs a certain number of photons. More details are in Appendix E. ◀

The linear independence of $\Delta$ will be a consequence of Proposition 46 and a decomposition of the $\Omega$ with $\Delta$ morphisms will give the independence of the $\Omega$, thus the uniqueness of the $\omega_{i,j}$, and therefore the uniqueness of the normal forms with Proposition 45. Everything is detailed in Appendix E.

## 4.4 Completeness of the LO<sub>fi</sub>-calculus: Proof of Theorem 31

Let $C, C'$ two LO<sub>fi</sub>-circuits such that $[[C]] = [[C']]$. They can be rewritten to normal forms by Lemma 35: $\mathbf{LO}_{fi} \vdash C = N$ and $\mathbf{LO}_{fi} \vdash C' = N'$. By soundness of LO<sub>fi</sub>, we have $[[N]] = [[C]] = [[C')] = [[N]]$ thus $[[N]] = [[N]]'$. By Lemma 35, the normal forms are unique. Therefore, $N = N'$ and we have $\mathbf{LO}_{fi} \vdash C = N = N' = C'$, thus $\mathbf{LO}_{fi} \vdash C = C'$, proving the completeness of the LO<sub>fi</sub>-calculus. ◀

# 5 Outlook

The formalism of the LO<sub>fi</sub>-calculus helped to find normal forms for linear optical circuits, and the new operators introduced in Section 4 were particularly relevant for proving their uniqueness. It is an open problem to know if those normal forms and new operators can have further applications in simulation, compilation or the synthesis of linear optical circuits, or even broader reach as the LOPP-calculus had for quantum circuits [11]. As those normal forms make only sense with finite states, it is also an open problem to determine whether normal forms exist in the infinite case, let alone their uniqueness.

## Acknowledgements

We would like to thank Marc de Visme and Vladimir Zamdzhiev for helpful discussions, Alexandre Clément for the insight into the angles of (E3) and the derivation of (oE3), and particularly Shane Mansfield, Benoît Valiron and Renaud Vilmart for helpful discussions, support and reviews of some parts of the paper. We would also like to thank all the anonymous reviewers for their insightful comments and suggestions, which greatly helped to improve the quality of this manuscript.
References

1 Scott Aaronson and Alex Arkhipov. The computational complexity of linear optics. In *Proceedings of the 43th Annual ACM Symposium on Theory of Computing (STOC)*, STOC '11, page 333–342, New York, NY, USA, 2011. Association for Computing Machinery. doi: 10.1145/1993636.1993682.

2 Samson Abramsky and Bob Coecke. A categorical semantics of quantum protocols. In *19th Annual IEEE Symposium on Logic in Computer Science (LICS)*, pages 415–425, 2004. doi:10.1109/LICS.2004.1319636.

3 Samson Abramsky and Bob Coecke. Categorical quantum mechanics, 2008. arXiv:0808.1023.

4 Stefan Ataman. A graphical method in quantum optics. *Journal of Physics Communications*, 2(3):035032, Mar 2018. URL: https://dx.doi.org/10.1088/2399-6528/aab50f, doi:10.1088/2399-6528/aab50f.

5 Miriam Backens, Hector Miller-Bakewell, Giovanni de Felice, Leo Lobski, and John van de Wetering. There and back again: A circuit extraction tale. *Quantum*, 5:421, Mar 2021. doi:10.22331/q-2021-03-25-421.

6 Sara Bartolucci, Patrick Birchall, Hector Bombin, Hugo Cable, Chris Dawson, Mercedes Gimeno-Segovia, Eric Johnston, Konrad Kieling, Naomi Nickerson, Mihir Pant, Fernando Pastawski, Terry Rudolph, and Chris Sparrow. Fusion-based quantum computation. *Nature Communications*, 14(1):912, 2023. arXiv:2101.09310, doi:10.1038/s41467-023-36493-1.

7 Daniel E. Browne and Terry Rudolph. Resource-efficient linear optical quantum computation. *Phys. Rev. Lett.*, 95:010501, Jun 2005. URL: https://link.aps.org/doi/10.1103/PhysRevLett.95.010501.

8 Colin D. Bruzewicz, John Chiaverini, Robert McConnell, and Jeremy M. Sage. Trapped-ion quantum computing: Progress and challenges. *Applied Physics Reviews*, 6(2), May 2019. URL: http://dx.doi.org/10.1063/1.5088164, doi:10.1063/1.5088164.

9 Alexandre Clément, Noé Delorme, and Simon Perdrix. Minimal equational theories for quantum circuits, 2023. arXiv:2311.07476.

10 Alexandre Clément, Nicolas Heurtel, Shane Mansfield, Simon Perdrix, and Benoît Valiron. Lov-calculus: A graphical language for linear optical quantum circuits. In *Proceedings of the 47th International Symposium on Mathematical Foundations of Computer Science (MFCS)*, volume 241 of *Leibniz International Proceedings in Informatics (LIPIcs)*, pages 35:1–35:16, Dagstuhl, Germany, 2022. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. URL: https://drops.dagstuhl.de/opus/volltexte/2022/16833, doi:10.4230/LIPIcs.MFCS.2022.35.

11 Alexandre Clément, Nicolas Heurtel, Shane Mansfield, Simon Perdrix, and Benoît Valiron. A complete equational theory for quantum circuits. In *Proceedings of the 38th Annual ACM IEEE Symposium on Logic in Computer Science (LICS)*, Boston, MA, USA, 2023. arXiv:2206.10577.

12 Alexandre Clément and Simon Perdrix. PBS-calculus: A graphical language for coherent control of quantum computations. In Javier Esparza and Daniel Kráľ, editors, *Proceedings of the 45th International Symposium on Mathematical Foundations of Computer Science (MFCS)*, volume 170 of *Leibniz International Proceedings in Informatics (LIPIcs)*, pages 24:1–24:14, Dagstuhl, Germany, Aug 2020. Schloss Dagstuhl–Leibniz-Zentrum für Informatik. arXiv:2002.09387, doi:10.4230/LIPIcs.MFCS.2020.24.

13 Bob Coecke and Ross Duncan. Interacting quantum observables: Categorical algebra and diagrammatics. *New Journal of Physics*, 13(4):043016, Apr 2011. URL: http://arxiv.org/abs/0906.4725, doi:10.1088/1367-2630/13/4/043016.

14 N. Coste, D. A. Fioretto, N. Belabas, S. C. Wein, P. Hilaire, R. Frantzeskakis, M. Gundin, B. Goes, N. Somaschi, M. Morassi, A. Lemaître, I. Sagnes, A. Harouri, S. E. Economou, A. Auffeves, O. Krebs, L. Lanco, and P. Senellart. High-rate entanglement between a semiconductor spin and indistinguishable photons. *Nature Photonics*, 17(7):582–587, 2023. doi:10.1038/s41566-023-01186-0.
15 Giovanni de Felice and Bob Coecke. Quantum linear optics via string diagrams. *Electronic Proceedings in Theoretical Computer Science (EPTCS)*, 394:83–100, Nov 2023. URL: http://dx.doi.org/10.4204/EPTCS.394.6, doi:10.4204/eptcs.394.6.

16 Giovanni de Felice, Razin A. Shaikh, Boldizsár Poór, Lia Yeh, Quanlong Wang, and Bob Coecke. Light-matter interaction in the zxw calculus. *Electronic Proceedings in Theoretical Computer Science (EPTCS)*, 384:20–46, Aug 2023. URL: http://dx.doi.org/10.4204/EPTCS.384.2, doi:10.4204/eptcs.384.2.

17 Grégoire de Gliniasty, Paul Hilaire, Pierre-Emmanuel Emeriau, Stephen C. Wein, Alexia Salavrakos, and Shane Mansfield. A spin-optical quantum computing architecture, 2024. URL: https://arxiv.org/abs/2311.05605, arXiv:2311.05605.

18 Marc de Visme and Renaud Vilmart. Minimality in finite-dimensional zw-calculi, 2024. arXiv:2401.16225.

19 Ross Duncan and Maxime Lucas. Verifying the steane code with quantomatic. *Electronic Proceedings in Theoretical Computer Science (EPTCS)*, 171:33–49, Dec 2014. URL: http://dx.doi.org/10.4204/EPTCS.171.4, doi:10.4204/eptcs.171.4.

20 David Eberly. Euler angle formulas. Geometric Tools, 2020. URL: https://www.geometrictools.com/Documentation/EulerAngles.pdf.

21 Suren A. Fldzhyan, Mikhail Yu. Saygin, and Sergei P. Kulik. Compact linear optical scheme for bell state generation. *Physical Review Research*, 3(4):043031, 2021. URL: https://link.aps.org/doi/10.1103/PhysRevResearch.3.043031, doi:10.1103/PhysRevResearch.3.043031.

22 Liam Garvie and Ross Duncan. Verifying the smallest interesting colour code with quantomatic. *Electronic Proceedings in Theoretical Computer Science (EPTCS)*, 266:147–163, Feb 2018. URL: http://dx.doi.org/10.4204/EPTCS.266.10, doi:10.4204/eptcs.266.10.

23 Herbert Goldstein, Charles Poole, and John Safko. *Classical Mechanics*. Addison Wesley, 3 edition, 2002.

24 Christian Gross and Immanuel Bloch. Quantum simulations with ultracold atoms in optical lattices. *Science*, 357(6355):995–1001, 2017. URL: https://www.science.org/doi/abs/10.1126/science.aal3837, doi:10.1126/science.aal3837.

25 Lov K. Grover. A fast quantum mechanical algorithm for database search. In *Proceedings of the 28th Annual ACM Symposium on Theory of Computing (STOC)*, STOC '96, pages 212–219, New York, NY, USA, Jul 1996. Association for Computing Machinery. doi:10.1145/237814.237866.

26 Amar Hadzihasanovic, Kang Feng Ng, and Quanlong Wang. Two complete axiomatisations of pure-state qubit quantum computing. In *Proceedings of the 33rd Annual ACM/IEEE Symposium on Logic in Computer Science (LICS)*, LICS '18, page 502–511, New York, NY, USA, 2018. Association for Computing Machinery. doi:10.1145/3209108.3209128.

27 Aram W. Harrow, Avinatan Hassidim, and Seth Lloyd. Quantum algorithm for linear systems of equations. *Physical Review Letters*, 103(15):150502, 2009. URL: https://link.aps.org/doi/10.1103/PhysRevLett.103.150502, doi:10.1103/PhysRevLett.103.150502.

28 Nicolas Heurtel, Shane Mansfield, Jean Senellart, and Benoît Valiron. Strong simulation of linear optical processes. *Computer Physics Communications*, page 108848, 2023. URL: https://www.sciencedirect.com/science/article/pii/S0010465523001935, doi:10.1016/j.cpc.2023.108848.

29 Emmanuel Jeandel, Simon Perdrix, and Renaud Vilmart. A complete axiomatisation of the ZX-calculus for Clifford+T quantum mechanics. In *Proceedings of the 33rd Annual ACM/IEEE Symposium on Logic in Computer Science (LICS)*, LICS '18, page 559–568, New York, NY, USA, 2018. Association for Computing Machinery. doi:10.1145/3209108.3209131.

30 Aleks Kissinger and John van de Wetering. Reducing T-count with the ZX-calculus. *Physical Review A*, 102:022406, Aug 2020. doi:10.1103/PhysRevA.102.022406.

31 Aleks Kissinger and John van de Wetering. Simulating quantum circuits with zx-calculus reduced stabiliser decompositions. *Quantum Science and Technology*, 7(4):044001, Jul 2022. URL: http://dx.doi.org/10.1088/2058-9565/ac5d20, doi:10.1088/2058-9565/ac5d20.
32 Aleks Kissinger, John van de Wetering, and Renaud Vilmart. Classical simulation of quantum circuits with partial and graphical stabiliser decompositions. In François Le Gall and Tomoyuki Morimae, editors, *Proceedings of the 17th Conference on the Theory of Quantum Computation, Communication and Cryptography (TQC)*, volume 232 of *Leibniz International Proceedings in Informatics (LIPIcs)*, pages 5:1–5:13, Dagstuhl, Germany, 2022. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. URL: https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.TQC.2022.5, doi:10.4230/LIPIcs.TQC.2022.5.

33 Morten Kjaergaard, Mollie E. Schwartz, Jochen Braumüller, Philip Krantz, Joel I.-J. Wang, Simon Gustavsson, and William D. Oliver. Superconducting qubits: Current state of play. *Annual Review of Condensed Matter Physics*, 11(1):369–395, Mar 2020. URL: http://dx.doi.org/10.1146/annurev-conmatphys-031119-050605, doi:10.1146/annurev-conmatphys-031119-050605.

34 E. Knill. Quantum gates using linear optics and postselection. *Physical Review A*, 66(5):052306, 2002. URL: http://arxiv.org/abs/quant-ph/0110144, arXiv:quant-ph/0110144, doi:10.1103/PhysRevA.66.052306.

35 E. Knill, R. Laflamme, and G. J. Milburn. A scheme for efficient quantum computation with linear optics. *Nature*, 409(6816):46–52, 2001. URL: https://www.nature.com/articles/35051009, doi:10.1038/35051009.

36 Mark Koch, Richie Yeung, and Quanlong Wang. Speedy contraction of zx diagrams with triangles via stabiliser decompositions, 2023. arXiv:2307.01803.

37 Pieter Kok, W. J. Munro, Kae Nemoto, T. C. Ralph, Jonathan P. Dowling, and G. J. Milburn. Review article: Linear optical quantum computing. *Reviews of Modern Physics*, 79(1):135–174, 2007. URL: http://arxiv.org/abs/quant-ph/0512071, arXiv:quant-ph/0512071, doi:10.1103/RevModPhys.79.135.

38 J. C. Loredo, C. Antón, B. Reznychenko, P. Hilaire, A. Harouri, C. Millet, H. Ollivier, N. Somaschi, L. De Santis, A. Lemaître, I. Sagnes, L. Lanco, A. Auffèves, O. Krebs, and P. Senellart. Generation of non-classical light in a photon-number superposition. *Nature Photonics*, 13(11):803–808, 2019. doi:10.1038/s41566-019-0506-3.

39 Saunders Mac Lane. Categorical algebra. *Bulletin of the American Mathematical Society*, 71:40–106, 1965. doi:10.1090/S0002-9904-1965-11234-4.

40 Paul McCloud. The category of linear optical quantum computing, 2022. arXiv:2203.05958.

41 Michael A. Nielsen. Optical quantum computation using cluster states. *Phys. Rev. Lett.*, 93:040503, Jul 2004. URL: https://link.aps.org/doi/10.1103/PhysRevLett.93.040503, doi:10.1103/PhysRevLett.93.040503.

42 Michael A. Nielsen and Isaac L. Chuang. *Quantum computation and quantum information*. Cambridge University Press, Cambridge, New York, 10th anniversary edition edition, 2010.

43 Jeremy L. O'Brien, Akira Furusawa, and Jelena Vučković. Photonic quantum technologies. *Nature Photonics*, 3(12):687–695, Dec 2009. URL: http://dx.doi.org/10.1038/nphoton.2009.229, doi:10.1038/nphoton.2009.229.

44 Roger Penrose. Angular momentum: an approach to combinatorial space-time. In T. Bastin, editor, *Quantum Theory and Beyond*, pages 151–180. Cambridge University Press, Cambridge, 1971.

45 Boldizsár Poór, Quanlong Wang, Razin A. Shaikh, Lia Yeh, Richie Yeung, and Bob Coecke. Completeness for arbitrary finite dimensions of zx-calculus, a unifying calculus. In *38th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS)*. IEEE, Jun 2023. URL: http://dx.doi.org/10.1109/LICS56636.2023.10175672, doi:10.1109/lics56636.2023.10175672.

46 John Preskill. Quantum computing 40 years later, 2023. arXiv:2106.10522.

47 Michael Reck, Anton Zeilinger, Herbert J. Bernstein, and Philip Bertani. Experimental realization of any discrete unitary operator. *Physical Review Letters*, 73:58–61, 1994. URL: http://adsabs.harvard.edu/abs/1994PhRvL..73..58R, doi:10.1103/PhysRevLett.73.58.
48 Terry Rudolph. Why I am optimistic about the silicon-photonic route to quantum computing. *APL Photonics*, 2, 2017. URL: http://dx.doi.org/10.1063/1.4976737, arXiv:1607.08535, doi:10.1063/1.4976737.

49 Stefan Scheel. Permanents in linear optical networks, 2004.

50 Peter Selinger. Dagger compact closed categories and completely positive maps: (extended abstract). *Electronic Notes in Theoretical Computer Science*, 170:139–163, 2007. URL: https://www.sciencedirect.com/science/article/pii/S1571066107000606, doi:10.1016/j.entcs.2006.12.018.

51 Peter W. Shor. Algorithms for quantum computation: discrete logarithms and factoring. In *Proceedings of the 35th Annual Symposium on Foundations of Computer Science (FOCS)*, pages 124–134, Nov 1994. doi:10.1109/SFCS.1994.365700.

52 John van de Wetering, Richie Yeung, Tuomas Laakkonen, and Aleks Kissinger. Optimal compilation of parametrised quantum circuits, Jan 2024. arXiv:2401.12877.

53 Quanlong Wang, Boldizsár Poór, and Razin A. Shaikh. Completeness of qufinite zxw calculus, a graphical language for finite-dimensional quantum theory, 2024. arXiv:2309.13014.

54 N. Yoran and B. Reznik. Deterministic linear optics quantum computation with single photon qubits. *Phys. Rev. Lett.*, 91:037903, Jul 2003. URL: https://link.aps.org/doi/10.1103/PhysRevLett.91.037903, doi:10.1103/PhysRevLett.91.037903.
A Notations

<table><caption>Table 1 Notations used in the paper.</caption><thead><tr><th>Symbol</th><th>Meaning</th></tr></thead><tbody><tr><td>C, C'</td><td>LO<sub>fi</sub>-circuits.</td></tr><tr><td>D, D', T, Δ̃, Δ̂</td><td>LOPP-circuits, cf Table 10 for the specific classes of circuits.</td></tr><tr><td>φ, θ</td><td>Parameters (angles) of phase shifters and beam splitters</td></tr><tr><td>n, m, ñ, m̃</td><td>Integers used for the number of inputs (n or n + ñ) and outputs (m or m + m̃)</td></tr><tr><td>i, j, k, ℓ, p, q</td><td>Integers used for indexing.</td></tr><tr><td>s, t, u, v, x, y</td><td>Fock basis vectors.</td></tr><tr><td>S, T, U, V</td><td>Finite set of indexes associated with their lowercase vector. Often omitted in the sums.</td></tr><tr><td>B<sub>m</sub></td><td>Hilbert space of the bosonic Fock space over m modes, cf Definition 17.</td></tr><tr><td>B<sup>pre</sup><sub>m</sub></td><td>Pre-Hilbert space of the bosonic Fock space over m modes, cf Definition 19.</td></tr><tr><td>f, f'</td><td>Vectors of B<sup>pre</sup>.</td></tr><tr><td>g, g'</td><td>Vectors of (B<sup>pre</sup>)<sup>*</sup>, the dual of B<sup>pre</sup>.</td></tr><tr><td>â<sup>†</sup><sub>j</sub></td><td>Creation operator over the mode j, introduced in Definition 42</td></tr><tr><td>Λ'</td><td>Operator defined in Proposition 61</td></tr><tr><td>Ω<sup>...</sup>, Δ<sup>...</sup></td><td>Operators defined in Definition 42.</td></tr><tr><td>Σ, Π</td><td>Finite sums and products when the upper bound or the set of indexes is omitted.</td></tr><tr><td>≤, ≤</td><td>Weak order on vectors, cf Lemma 62.</td></tr><tr><td>∠, ∠</td><td>Lexicographic order on vectors, cf Lemma 62.</td></tr><tr><td>∠<sub>r</sub>, ∠<sub>r</sub></td><td>Reverse lexicographic order on vectors, cf Proposition 46.</td></tr></tbody></table>

B Section 2

B.1 Euler angles of (E2) and (E3)

Let us define the following matrices:

$$R_X(\theta) := \begin{pmatrix} \cos(\frac{\theta}{2}) & -i \sin(\frac{\theta}{2}) \\ -i \sin(\frac{\theta}{2}) & \cos(\frac{\theta}{2}) \end{pmatrix} \qquad H := \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}$$

$$R_z(\varphi) := \begin{pmatrix} \cos(\varphi) & -\sin(\varphi) & 0 \\ \sin(\varphi) & \cos(\varphi) & 0 \\ 0 & 0 & 1 \end{pmatrix} \qquad R_x(\theta) := \begin{pmatrix} 1 & 0 & 0 \\ 0 & \cos(\theta) & -\sin(\theta) \\ 0 & \sin(\theta) & \cos(\theta) \end{pmatrix}$$

$$P_{iy} := \begin{pmatrix} 1 & 0 & 0 \\ 0 & i & 0 \\ 0 & 0 & 1 \end{pmatrix}$$

with $HH^\dagger = I_2 = P_{iy}P_{iy}^\dagger$ where $I_2$ is the 2 × 2 identity matrix and $\dagger$ is the conjugate transpose.

Let us also note:

$$B(\theta) = \begin{pmatrix} \cos(\theta) & i \sin(\theta) \\ i \sin(\theta) & \cos(\theta) \end{pmatrix} \qquad P(\varphi) = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\varphi} \end{pmatrix}$$
with

$$
B_{1,2}(\theta) := \begin{pmatrix} \cos(\theta) & i \sin(\theta) & 0 \\ i \sin(\theta) & \cos(\theta) & 0 \\ 0 & 0 & 1 \end{pmatrix} \qquad B_{2,3}(\theta) := \begin{pmatrix} 1 & 0 & 0 \\ 0 & \cos(\theta) & i \sin(\theta) \\ 0 & i \sin(\theta) & \cos(\theta) \end{pmatrix}
$$

B.1.1 Euler angles of (E2)

Let us note $U_{E_2} := \begin{pmatrix} u_{1,1} & u_{1,2} \\ u_{2,1} & u_{2,2} \end{pmatrix}$ with $[[LHS]]_1 = U_{E_2} = [[RHS]]_1$. It is straightforward to compute the elements of $U_{E_2}$ with either the angles of the LHS or the RHS with the definitions (cf Definition 3). Therefore, it is sufficient to give the angles from the elements of $U_{E_2}$. In the following paragraphs, we first give one solution for the angles, then precise all the angles that satisfy the equations.

From $U_{E_2}$ to RHS

We have:

$$
[[RHS]]_1 = \begin{pmatrix} e^{i\beta_0} \cos(\beta_2) & i e^{i(\beta_0+\beta_1)} \sin(\beta_2) \\ i e^{i\beta_3} \sin(\beta_2) & e^{i(\beta_1+\beta_3)} \cos(\beta_2) \end{pmatrix} = \begin{pmatrix} u_{1,1} & u_{1,2} \\ u_{2,1} & u_{2,2} \end{pmatrix}
$$

The following is a solution:

$$
\left\{
\begin{aligned}
\beta_0 &= \arg(u_{1,1}), \\
\beta_1 &= \arg(u_{2,2}) - \arg(u_{2,1}) + \frac{\pi}{2}, \\
\beta_2 &= \operatorname{acos}(|u_{1,1}|), \\
\beta_3 &= \arg(u_{2,1}) - \frac{\pi}{2},
\end{aligned}
\right.
\qquad (16)
$$

We can note that:

- if $\beta_2+ = \pi$ then the RHS is the same with $\beta_0+ = \pi$ and $\beta_3+ = \pi$,

- if $\beta_2 \mapsto \pi - \beta_2$ then the RHS is the same with $\beta_0+ = \pi$ and $\beta_1+ = \pi$,

- all the angles can be taken modulo $2\pi$ without changing the RHS.

The complete set of solutions for $\beta_0, \beta_1, \beta_2$ and $\beta_3$ includes all possible configurations
that can be derived from the values of (16) and the three transformations outlined above.

Note there is a unique set of angles such that $\beta_2 \in [0, \frac{\pi}{2}]$, $\beta_0, \beta_1, \beta_3 \in [0, 2\pi)$ satisfying
$\beta_1 = 0$ if $\beta_2 \in \{0, \frac{\pi}{2}\}$. In particular, if $|u_{1,1}| = 1$, then $\beta_2 = 0, \beta_1 = 0$, and if $|u_{1,1}| = 0$, then
$\beta_2 = \frac{\pi}{2}$ and $\beta_1 = 0$.

From $U_{E_2}$ to LHS

Let us first notice that:

$$
HP(\varphi)H = e^{i\frac{\varphi}{2}} R_X(\varphi) = e^{i\frac{\varphi}{2}} B(-\frac{\varphi}{2})
$$

We can therefore come back to a form similar to the RHS:
$$
\begin{align*}
H[[LHS]]_1 H &= e^{i\alpha_0} H(B(\alpha_1)P(\alpha_2 - \alpha_0)B(\alpha_3)) H \\
&= e^{i\alpha_0} (HB(\alpha_1)H)(HP(\alpha_2 - \alpha_0)H)(HB(\alpha_3)H) \\
&= e^{i\alpha_0} (e^{i\alpha_1} P(-2\alpha_1)) \left(e^{i\frac{\alpha_2-\alpha_0}{2}} B\left(-\frac{\alpha_2-\alpha_0}{2}\right)\right) (e^{i\alpha_3} P(-2\alpha_3)) \\
&= e^{i\left(\frac{\alpha_0+2\alpha_1+\alpha_2+2\alpha_3}{2}\right)} P(-2\alpha_1)B\left(\frac{\alpha_0-\alpha_2}{2}\right) P(-2\alpha_3)
\end{align*}
$$

By noting $\begin{pmatrix} u'_{1,1} & u'_{1,2} \\ u'_{2,1} & u'_{2,2} \end{pmatrix} = HUH$, and from the previous paragraph we can infer the
following solution:

$$
\left\{
\begin{array}{l}
\displaystyle \frac{\alpha_0 + 2\alpha_1 + \alpha_2 + 2\alpha_3}{2} = \arg(u'_{1,1}), \\[1em]
\displaystyle \frac{\alpha_0 - \alpha_2}{2} = \operatorname{acos}(|u'_{1,1}|), \\[1em]
\displaystyle -2\alpha_3 + \frac{\alpha_0 + 2\alpha_1 + \alpha_2 + 2\alpha_3}{2} = \arg(u'_{2,1}) - \frac{\pi}{2}, \\[1em]
\displaystyle -2\alpha_1 = \arg(u'_{2,2}) - \arg(u'_{1,1}) + \frac{\pi}{2}
\end{array}
\right.
$$

Thus we have the following solution:

$$
\left\{
\begin{aligned}
\alpha_0 &= \arg(u'_{1,1}) + \arg(u'_{2,2}), \\
\alpha_1 &= \frac{\arg(u'_{2,1}) - \arg(u'_{2,2})}{2} - \frac{\pi}{4} \\
\alpha_2 &= \arg(u'_{1,1}) + \arg(u'_{2,2}) - 2\arcsin(|u'_{1,1}|), \\
\alpha_3 &= \arcsin(|u'_{1,1}|) - \frac{\arg(u'_{2,1}) + \arg(u'_{2,2})}{2} + \frac{\pi}{4},
\end{aligned}
\right.
\qquad (17)
$$

We can note that:

- if $\alpha_1 + \pi = \pi$ then the LHS is the same with $\alpha_0 + \pi$ and $\alpha_2 + \pi$,

- if $\alpha_3 + \pi = \pi$ then the LHS is the same with $\alpha_0 + \pi$ and $\alpha_2 + \pi$,

- all the angles can be taken modulo $2\pi$ without changing the LHS.

The complete set of solutions for $\alpha_0, \alpha_1, \alpha_2$ and $\alpha_3$ includes all possible configurations
that can be derived from the values of (17) and the three transformations outlined above.

Note there is a unique set of angles such that $\alpha_1 \in [0, \frac{\pi}{2})$, $\alpha_3 \in [0, \pi)$, $\alpha_0, \alpha_2 \in [0, 2\pi)$ satisfying $\alpha_1 = 0$ if $\alpha_0 - \alpha_2 = 0 \pmod{\pi}$. In particular, if $|u_{1,2}| = 0$, then $\alpha_0 - \alpha_2 = 0 \pmod{\pi}$ and $\alpha_1 = \alpha_3 = 0$, and if $|u_{1,1}| = 0$, then $\alpha_0 - \alpha_2 = 0 \pmod{\pi}$, $\alpha_1 = 0$ and $\alpha_3 = \frac{\pi}{2}$.

B.1.2 Euler angles of (E3)

Note that $P_{iy}^{\dagger} B_{1,2}(\theta) P_{iy} = R_z(\theta)$ and $P_{iy}^{\dagger} B_{2,3}(\theta) P_{iy} = R_x(\theta)$ with $P_{iy}^{\dagger} P_{iy} = I_3$, so we have:

$$
\begin{align*}
P_{iy}^{\dagger} [[LHS]]_1 P_{iy} &= P_{iy}^{\dagger} B_{1,2}(\gamma_1) B_{2,3}(\gamma_2) B_{1,2}(\gamma_3) P_{iy} \\
&= (P_{iy}^{\dagger} B_{1,2}(\gamma_1) P_{iy}) (P_{iy}^{\dagger} B_{2,3}(\gamma_2) P_{iy}) (P_{iy}^{\dagger} B_{1,2}(\gamma_3) P_{iy}) \\
&= R_z(\gamma_1) R_x(\gamma_2) R_z(\gamma_3)
\end{align*}
$$

and

$$
\begin{align*}
P_{iy}^{\dagger} [[RHS]]_1 P_{iy} &= P_{iy}^{\dagger} B_{2,3}(\delta_1) B_{1,2}(\delta_2) B_{2,3}(\delta_3) P_{iy} \\
&= (P_{iy}^{\dagger} B_{2,3}(\delta_1) P_{iy}) (P_{iy}^{\dagger} B_{1,2}(\delta_2) P_{iy}) (P_{iy}^{\dagger} B_{2,3}(\delta_3) P_{iy}) \\
&= R_x(\delta_1) R_z(\delta_2) R_x(\delta_3)
\end{align*}
$$
Thus the angles of (E3) are exactly the Euler angles for rotations in $\mathbb{R}^3$:

$$ \begin{align*} \llbracket \text{LHS} \rrbracket_1 &= \llbracket \text{RHS} \rrbracket \\ \Leftrightarrow P_{iy}^\dagger \llbracket \text{LHS} \rrbracket_1 P_{iy} &= P_{iy}^\dagger \llbracket \text{RHS} \rrbracket P_{iy} \\ \Leftrightarrow R_z(\gamma_3) R_x(\gamma_2) R_z(\gamma_1) &= R_x(\delta_3) R_z(\delta_2) R_x(\delta_1) \end{align*} $$

One can look at [23] for the theory. For the explicit formula, let us define the 3 × 3 real

matrix $R_{E_3} := \begin{pmatrix} r_{1,1} & r_{1,2} & r_{1,3} \\ r_{2,1} & r_{2,2} & r_{2,3} \\ r_{3,1} & r_{3,2} & r_{3,3} \end{pmatrix} = P_{iy}^\dagger \llbracket \text{LHS} \rrbracket_1 P_{iy} = P_{iy}^\dagger \llbracket \text{RHS} \rrbracket_1 P_{iy}$. It is straightforward to compute the elements of $R_{E_3}$ with either the angles of the LHS or the RHS with the definitions (cf Definition 3). Therefore, it is sufficient to give the angles from the elements of $R_{E_3}$.

Here, we give the formula directly taken from [20].

### From $R_{E_3}$ to RHS

- If $-1 < r_{1,1} < 1$ then $\delta_1 = \text{atan2}(r_{1,3}, -r_{1,2})$, $\delta_2 = \text{acos}(r_{1,1})$ and $\delta_3 = \text{atan2}(r_{3,1}, r_{2,1})$.

- If $r_{1,1} = 1$, then necessarily $\delta_2 = 0$, and the solutions are all the angles such that $\delta_1 + \delta_3 = \text{atan2}(r_{3,2}, r_{3,3})$.

- If $r_{1,1} = -1$, then necessarily $\delta_2 = \pi$, and the solutions are all the angles such that $\delta_1 - \delta_3 = \text{atan2}(r_{3,2}, r_{3,3})$.

All those angles can be taken modulo $2\pi$.

### From $R_{E_3}$ to LHS

- If $-1 < r_{3,3} < 1$ then $\gamma_2 = \text{acos}(r_{3,3})$, $\gamma_3 = \text{atan2}(r_{1,3}, -r_{2,3})$ and $\gamma_1 = \text{atan2}(r_{3,0}, r_{3,2})$.

- If $r_{3,3} = 1$, then necessarily $\gamma_2 = 0$, and the solutions are all the angles such that $\gamma_1 + \gamma_3 = \text{atan2}(-r_{1,2}, r_{1,1})$.

- If $r_{3,3} = -1$, then necessarily $\gamma_2 = \pi$, and the solutions are all the angles such that $\gamma_1 - \gamma_3 = \text{atan2}(-r_{1,2}, r_{1,1})$.

All those angles can be taken modulo $2\pi$.

## B.2 Completeness of LOPP: Theorem 7

To prove Equation (p0), we have:

$$ \boxed{0} \stackrel{(p2\pi)}{=} \boxed{0} - \boxed{2\pi} $$

$$ (p-p) = \boxed{2\pi} $$

$$ (p2\pi) = \boxed{\hspace{20em}} $$
To prove Equation (b0), we have:

<figure><img src="image_13.png" /></figure>

(swap) =

<figure><img src="image_14.png" /></figure>

(E2) =

<figure><img src="image_15.png" /></figure>

(swap),PROP =

<figure><img src="image_16.png" /></figure>

To prove Equation (pp-b), we have:

<figure><img src="image_17.png" /></figure>

(b0) =

<figure><img src="image_18.png" /></figure>

(E2) =

<figure><img src="image_19.png" /></figure>

(p0) =

► Lemma 47 (Useful LOPP equations). We can derive the three following equations in LOPP:

$$ \text{[LOPP 1]} \qquad \begin{tikzpicture}[baseline=(current bounding box.center), scale=0.4, every node/.style={scale=0.8}] 
\draw (-0.5,0) -- (0.5,0); 
\node[fill=gray!20, circle, minimum size=15pt] at (0,0) (A) {};
\node[fill=gray!20, circle, minimum size=15pt] at (-0.5,0) (B) {};
\node[fill=gray!20, circle, minimum size=15pt] at (0.5,0) (C) {};
\node[fill=gray!20, circle, minimum size=15pt] at (0,0) (D) {};
\node[fill=gray!20, circle, minimum size=15pt] at (-0.5,0) (E) {};
\node[fill=gray!20, circle, minimum size=15pt] at (0.5,0) (F) {};
\node[fill=gray!20, circle, minimum size=15pt] at (0,0) (G) {};
\node[fill=gray!20, circle, minimum size=15pt] at (-0.5,0) (H) {};
\draw (A) -- (B) node[left, blue, scale=0.7] {$\theta$};
\draw (B) -- (C) node[right, blue, scale=0.7] {$\theta$};
\draw (C) -- (D) node[right, blue, scale=0.7] {$\theta$};
\draw (D) -- (E) node[left, blue, scale=0.7] {$\theta$};
\draw (E) -- (F) node[right, blue, scale=0.7] {$\theta$};
\draw (F) -- (G) node[right, blue, scale=0.7] {$\theta$};
\draw (G) -- (H) node[left, blue, scale=0.7] {$\theta$};
\node[below=1em of A, blue] {$\varphi$};
\node[below=1em of B, blue] {$\varphi$};
\node[below=1em of C, blue] {$\varphi$};
\node[below=1em of D, blue] {$\varphi$};
\node[below=1em of E, blue] {$\varphi$};
\node[below=1em of F, blue] {$\varphi$};
\node[below=1em of G, blue] {$\varphi$};
\node[below=1em of H, blue] {$\varphi$};
\end{tikzpicture} \qquad (18) $$

$$ \text{[LOPP 2]} \qquad \begin{tikzpicture}[baseline=(current bounding box.center), scale=0.4, every node/.style={scale=0.8}] 
\draw (-0.5,0) -- (0.5,0); 
\node[fill=gray!20, circle, minimum size=15pt] at (0,0) (A) {};
\node[fill=gray!20, circle, minimum size=15pt] at (-0.5,0) (B) {};
\node[fill=gray!20, circle, minimum size=15pt] at (0.5,0) (C) {};
\node[fill=gray!20, circle, minimum size=15pt] at (0,0) (D) {};
\node[fill=gray!20, circle, minimum size=15pt] at (-0.5,0) (E) {};
\node[fill=gray!20, circle, minimum size=15pt] at (0.5,0) (F) {};
\node[fill=gray!20, circle, minimum size=15pt] at (0,0) (G) {};
\node[fill=gray!20, circle, minimum size=15pt] at (-0.5,0) (H) {};
\draw (A) -- (B) node[left, blue, scale=0.7] {$\theta$};
\draw (B) -- (C) node[right, blue, scale=0.7] {$\theta$};
\draw (C) -- (D) node[right, blue, scale=0.7] {$\theta$};
\draw (D) -- (E) node[left, blue, scale=0.7] {$\theta$};
\draw (E) -- (F) node[right, blue, scale=0.7] {$\theta$};
\draw (F) -- (G) node[right, blue, scale=0.7] {$\theta$};
\draw (G) -- (H) node[left, blue, scale=0.7] {$\theta$};
\node[below=1em of A, blue] {$\varphi$};
\node[below=1em of B, blue] {$\varphi$};
\node[below=1em of C, blue] {$\varphi$};
\node[below=1em of D, blue] {$\varphi$};
\node[below=1em of E, blue] {$\varphi$};
\node[below=1em of F, blue] {$\varphi$};
\node[below=1em of G, blue] {$\varphi$};
\node[below=1em of H, blue] {$\varphi$};
\end{tikzpicture} \qquad (19) $$

$$ \text{[LOPP 3]} \qquad \begin{tikzpicture}[baseline=(current bounding box.center), scale=0.4, every node/.style={scale=0.8}] 
\draw (-0.5,0) -- (0.5,0); 
\node[fill=gray!20, circle, minimum size=15pt] at (0,0) (A) {};
\node[fill=gray!20, circle, minimum size=15pt] at (-0.5,0) (B) {};
\node[fill=gray!20, circle, minimum size=15pt] at (0.5,0) (C) {};
\node[fill=gray!20, circle, minimum size=15pt] at (0,0) (D) {};
\node[fill=gray!20, circle, minimum size=15pt] at (-0.5,0) (E) {};
\node[fill=gray!20, circle, minimum size=15pt] at (0.5,0) (F) {};
\node[fill=gray!20, circle, minimum size=15pt] at (0,0) (G) {};
\node[fill=gray!20, circle, minimum size=15pt] at (-0.5,0) (H) {};
\draw (A) -- (B) node[left, blue, scale=0.7] {$\frac{\pi}{2}$};
\draw (B) -- (C) node[right, blue, scale=0.7] {$\frac{\pi}{2}$};
\draw (C) -- (D) node[right, blue, scale=0.7] {$\frac{\pi}{2}$};
\draw (D) -- (E) node[left, blue, scale=0.7] {$\frac{\pi}{2}$};
\draw (E) -- (F) node[right, blue, scale=0.7] {$\frac{\pi}{2}$};
\draw (F) -- (G) node[right, blue, scale=0.7] {$\frac{\pi}{2}$};
\draw (G) -- (H) node[left, blue, scale=0.7] {$\frac{\pi}{2}$};
\node[below=1em of A, blue] {$\varphi$};
\node[below=1em of B, blue] {$\varphi$};
\node[below=1em of C, blue] {$\varphi$};
\node[below=1em of D, blue] {$\varphi$};
\node[below=1em of E, blue] {$\varphi$};
\node[below=1em of F, blue] {$\varphi$};
\node[below=1em of G, blue] {$\varphi$};
\node[below=1em of H, blue] {$\varphi$};
\end{tikzpicture} \qquad (20) $$
If $\sin(\delta_1) \neq 0$, we can also derive:

$$ \begin{tikzpicture}[baseline=(current bounding box.center), scale=0.8, every node/.style={scale=0.8}] 
% Coordinates for the nodes
\coordinate (delta1) at (0,1); 
\coordinate (delta2) at (1,0.5); 
\coordinate (alpha) at (0.5,0.3); 
\coordinate (gamma1) at (1.5,1); 
\coordinate (gamma3) at (2.5,0.5); 
\coordinate (piOver2) at (1,0); 

% Edges
\draw[->] (delta1) -- (delta2) node[left] {$\delta_2$};
\draw[->] (gamma1) -- (gamma3) node[right] {$\gamma_3$};
\draw[->] (delta1) -- (gamma1) node[left] {$\alpha$};
\draw[->] (gamma1) -- (gamma3) node[right] {$\gamma_1$};

% Angles
\node[above=0.1cm of delta1] {$\theta$};
\node[above=0.1cm of delta2] {$\theta$};
\node[above=0.1cm of alpha] {$\alpha$};
\node[above=0.1cm of piOver2] {$\pi$};

% Labels
\node[below=0.1cm of piOver2] {$\frac{\pi}{2}$};
\node[above=0.1cm of gamma1] {$\gamma_1$};
\node[above=0.1cm of gamma3] {$\gamma_3$};

% Dashed lines
\draw[dashed] (delta1) -- (gamma1);
\draw[dashed] (delta1) -- (gamma3);
\draw[dashed] (gamma1) -- (gamma3);

\end{tikzpicture} \qquad (21) $$

with $\alpha = \tan(\frac{c_{\delta_1}}{s_{\delta_1} c_{\delta_2}})$.

**Proof.** To derive Equation (18), we have:

$$ \begin{tikzpicture}[baseline=(current bounding box.center), scale=0.8, every node/.style={scale=0.8}] 
% Coordinates for the nodes
\coordinate (p0) at (0,0.5); 
\coordinate (p1) at (1,0.5); 
\coordinate (p2) at (0.5,0.3); 
\coordinate (p3) at (1.5,0.3); 
\coordinate (p4) at (0.5,-0.3); 
\coordinate (p5) at (1.5,-0.3); 

% Edges
\draw[->] (p0) -- (p1) node[left] {$\theta$};
\draw[->] (p0) -- (p2) node[right] {$\varphi$};
\draw[->] (p1) -- (p3) node[right] {$\varphi$};
\draw[->] (p2) -- (p5) node[right] {$\varphi$};
\draw[->] (p3) -- (p5) node[right] {$\varphi$};

% Angles
\node[above=0.1cm of p0] {$\theta$};
\node[above=0.1cm of p1] {$\varphi$};
\node[above=0.1cm of p2] {$\varphi$};
\node[above=0.1cm of p3] {$\varphi$};
\node[above=0.1cm of p4] {$\varphi$};
\node[above=0.1cm of p5] {$\varphi$};

% Labels
\node[below=0.1cm of p0] {$\varphi$};
\node[below=0.1cm of p1] {$\varphi$};
\node[below=0.1cm of p2] {$\varphi$};
\node[below=0.1cm of p3] {$\varphi$};
\node[below=0.1cm of p4] {$\varphi$};
\node[below=0.1cm of p5] {$\varphi$};

% Dashed lines
\draw[dashed] (p0) -- (p1);
\draw[dashed] (p0) -- (p2);
\draw[dashed] (p1) -- (p3);
\draw[dashed] (p2) -- (p5);
\draw[dashed] (p3) -- (p5);

\end{tikzpicture} \qquad \begin{tikzpicture}[baseline=(current bounding box.center), scale=0.8, every node/.style={scale=0.8}] 
% Coordinates for the nodes
\coordinate (p0) at (0,0.5); 
\coordinate (p1) at (1,0.5); 
\coordinate (p2) at (0.5,0.3); 
\coordinate (p3) at (1.5,0.3); 
\coordinate (p4) at (0.5,-0.3); 
\coordinate (p5) at (1.5,-0.3); 

% Edges
\draw[->] (p0) -- (p1) node[left] {$\theta$};
\draw[->] (p0) -- (p2) node[right] {$\varphi$};
\draw[->] (p1) -- (p3) node[right] {$\varphi$};
\draw[->] (p2) -- (p5) node[right] {$\varphi$};
\draw[->] (p3) -- (p5) node[right] {$\varphi$};

% Angles
\node[above=0.1cm of p0] {$\theta$};
\node[above=0.1cm of p1] {$\varphi$};
\node[above=0.1cm of p2] {$\varphi$};
\node[above=0.1cm of p3] {$\varphi$};
\node[above=0.1cm of p4] {$\varphi$};
\node[above=0.1cm of p5] {$\varphi$};

% Labels
\node[below=0.1cm of p0] {$\varphi$};
\node[below=0.1cm of p1] {$\varphi$};
\node[below=0.1cm of p2] {$\varphi$};
\node[below=0.1cm of p3] {$\varphi$};
\node[below=0.1cm of p4] {$\varphi$};
\node[below=0.1cm of p5] {$\varphi$};

\end{tikzpicture} $$

To derive Equation (19), we have:

$$ \begin{tikzpicture}[baseline=(current bounding box.center), scale=0.8, every node/.style={scale=0.8}] 
% Coordinates for the nodes
\coordinate (p0) at (0,0.5); 
\coordinate (p1) at (1,0.5); 
\coordinate (p2) at (0.5,0.3); 
\coordinate (p3) at (1.5,0.3); 
\coordinate (p4) at (0.5,-0.3); 
\coordinate (p5) at (1.5,-0.3); 

% Edges
\draw[->] (p0) -- (p1) node[left] {$\theta$};
\draw[->] (p0) -- (p2) node[right] {$\varphi$};
\draw[->] (p1) -- (p3) node[right] {$\varphi$};
\draw[->] (p2) -- (p5) node[right] {$\varphi$};
\draw[->] (p3) -- (p5) node[right] {$\varphi$};

% Angles
\node[above=0.1cm of p0] {$\theta$};
\node[above=0.1cm of p1] {$\varphi$};
\node[above=0.1cm of p2] {$\varphi$};
\node[above=0.1cm of p3] {$\varphi$};
\node[above=0.1cm of p4] {$\varphi$};
\node[above=0.1cm of p5] {$\varphi$};

% Labels
\node[below=0.1cm of p0] {$\varphi$};
\node[below=0.1cm of p1] {$\varphi$};
\node[below=0.1cm of p2] {$\varphi$};
\node[below=0.1cm of p3] {$\varphi$};
\node[below=0.1cm of p4] {$\varphi$};
\node[below=0.1cm of p5] {$\varphi$};

% Dashed lines
\draw[dashed] (p0) -- (p1);
\draw[dashed] (p0) -- (p2);
\draw[dashed] (p1) -- (p3);
\draw[dashed] (p2) -- (p5);
\draw[dashed] (p3) -- (p5);

\end{tikzpicture} \qquad \begin{tikzpicture}[baseline=(current bounding box.center), scale=0.8, every node/.style={scale=0.8}] 
% Coordinates for the nodes
\coordinate (p0) at (0,0.5); 
\coordinate (p1) at (1,0.5); 
\coordinate (p2) at (0.5,0.3); 
\coordinate (p3) at (1.5,0.3); 
\coordinate (p4) at (0.5,-0.3); 
\coordinate (p5) at (1.5,-0.3); 

% Edges
\draw[->] (p0) -- (p1) node[left] {$\theta$};
\draw[->] (p0) -- (p2) node[right] {$\varphi$};
\draw[->] (p1) -- (p3) node[right] {$\varphi$};
\draw[->] (p2) -- (p5) node[right] {$\varphi$};
\draw[->] (p3) -- (p5) node[right] {$\varphi$};

% Angles
\node[above=0.1cm of p0] {$\theta$};
\node[above=0.1cm of p1] {$\varphi$};
\node[above=0.1cm of p2] {$\varphi$};
\node[above=0.1cm of p3] {$\varphi$};
\node[above=0.1cm of p4] {$\varphi$};
\node[above=0.1cm of p5] {$\varphi$};

% Labels
\node[below=0.1cm of p0] {$\varphi$};
\node[below=0.1cm of p1] {$\varphi$};
\node[below=0.1cm of p2] {$\varphi$};
\node[below=0.1cm of p3] {$\varphi$};
\node[below=0.1cm of p4] {$\varphi$};
\node[below=0.1cm of p5] {$\varphi$};

\end{tikzpicture} $$

To derive Equation (20), we have:

$$ \begin{tikzpicture}[baseline=(current bounding box.center), scale=0.8, every node/.style={scale=0.8}] 
% Coordinates for the nodes
\coordinate (p0) at (0,0.5); 
\coordinate (p1) at (1,0.5); 
\coordinate (p2) at (0.5,0.3); 
\coordinate (p3) at (1.5,0.3); 
\coordinate (p4) at (0.5,-0.3); 
\coordinate (p5) at (1.5,-0.3); 

% Edges
\draw[->] (p0) -- (p1) node[left] {$\frac{\pi}{2}$};
\draw[->] (p0) -- (p2) node[right] {$\varphi$};
\draw[->] (p1) -- (p3) node[right] {$\varphi$};
\draw[->] (p2) -- (p5) node[right] {$\varphi$};
\draw[->] (p3) -- (p5) node[right] {$\varphi$};

% Angles
\node[above=0.1cm of p0] {$\frac{\pi}{2}$};
\node[above=0.1cm of p1] {$\varphi$};
\node[above=0.1cm of p2] {$\varphi$};
\node[above=0.1cm of p3] {$\varphi$};
\node[above=0.1cm of p4] {$\varphi$};
\node[above=0.1cm of p5] {$\varphi$};

% Labels
\node[below=0.1cm of p0] {$\varphi$};
\node[below=0.1cm of p1] {$\varphi$};
\node[below=0.1cm of p2] {$\varphi$};
\node[below=0.1cm of p3] {$\varphi$};
\node[below=0.1cm of p4] {$\varphi$};
\node[below=0.1cm of p5] {$\varphi$};

% Dashed lines
\draw[dashed] (p0) -- (p1);
\draw[dashed] (p0) -- (p2);
\draw[dashed] (p1) -- (p3);
\draw[dashed] (p2) -- (p5);
\draw[dashed] (p3) -- (p5);

\end{tikzpicture} \qquad \begin{tikzpicture}[baseline=(current bounding box.center), scale=0.8, every node/.style={scale=0.8}] 
% Coordinates for the nodes
\coordinate (p0) at (0,0.5); 
\coordinate (p1) at (1,0.5); 
\coordinate (p2) at (0.5,0.3); 
\coordinate (p3) at (1.5,0.3); 
\coordinate (p4) at (0.5,-0.3); 
\coordinate (p5) at (1.5,-0.3); 

% Edges
\draw[->] (p0) -- (p1) node[left] {$\frac{\pi}{2}$};
\draw[->] (p0) -- (p2) node[right] {$\varphi$};
\draw[->] (p1) -- (p3) node[right] {$\varphi$};
\draw[->] (p2) -- (p5) node[right] {$\varphi$};
\draw[->] (p3) -- (p5) node[right] {$\varphi$};

% Angles
\node[above=0.1cm of p0] {$\frac{\pi}{2}$};
\node[above=0.1cm of p1] {$\varphi$};
\node[above=0.1cm of p2] {$\varphi$};
\node[above=0.1cm of p3] {$\varphi$};
\node[above=0.1cm of p4] {$\varphi$};
\node[above=0.1cm of p5] {$\varphi$};

% Labels
\node[below=0.1cm of p0] {$\varphi$};
\node[below=0.1cm of p1] {$\varphi$};
\node[below=0.1cm of p2] {$\varphi$};
\node[below=0.1cm of p3] {$\varphi$};
\node[below=0.1cm of p4] {$\varphi$};
\node[below=0.1cm of p5] {$\varphi$};

\end{tikzpicture} $$
For Equation (21), by looking at the matrices of both sides of the equation we have:

$$ [[LHS]]_1 = \begin{pmatrix} * & * & * \\ * & * & * \\ * & * & -s_{\alpha}s_{\delta_1}c_{\delta_2} + c_{\alpha}c_{\delta_1} \end{pmatrix} = \begin{pmatrix} * & * & * \\ * & * & * \\ * & * & 0 \end{pmatrix} = [[RHS]]_1 $$

Therefore, for $\delta_1 \neq 0$, we have:

$$ -s_{\alpha}s_{\delta_1}c_{\delta_2} + c_{\alpha}c_{\delta_1} = 0 \Leftrightarrow \tan(\alpha) = \frac{c_{\delta_1}}{s_{\delta_1}c_{\delta_2}} \Leftrightarrow \alpha = \operatorname{atan}\left(\frac{c_{\delta_1}}{s_{\delta_1}c_{\delta_2}}\right). $$

To derive Equation (oE2), we have:

<figure><img src="image_20.png" /></figure>

To derive Equation (oE3) if $\gamma_3 = 0$, we have:

<figure><img src="image_21.png" /></figure>

To derive Equation (oE3) if $\gamma_3 \neq 0$, we have:
<figure><img src="image_22.png" /></figure>

B.3 Minimality of LOPP: Equation (E3) is necessary

Here is the sketch of the proof:

■ We define an equivalence relation ~ϕ on three-wire LOPP-circuits.
- We introduce a confluent rewriting procedure that is conserving the relation $\sim_{\phi}$, and that is converging to normal forms.

- All the rules of the PROP, (p0), (swap), (p-p) and (E2) also conserve the relation $\sim_{\phi}$.

- We conclude that (E3) is necessary, because the LHS and RHS are different normal forms, and therefore can't be transformed from one to the other without (E3).

**Definition 48 (Minimal block decomposition).** Let $D$ be a LOPP-circuit on three wires. We define the minimal block decomposition as the minimal partition of $D$ into sub-circuits $B_1, B_2, \dots, B_n$ such that $D$, up to deformation, is of the form:

<figure><img src="image_23.png" /></figure>

where for each $i$, $B_i$ contains as many as phase shifters as possible that are not part of the $B_1, \dots, B_{i-1}$, and $n$ is minimal.

Note that $B_1$ and $B_n$ can be identities or swap, and that $B_{n-1}$ can be a SWAP (but not the identity).

**Definition 49 (Equivalence relation).** Let $D, D'$ two three-wire LOPP-circuits. We have $D \sim_{\phi} D'$ if and only if their minimal block decomposition $B_1, \dots, B_n$ and $B'_1, \dots, B'_n$ have the same number of blocks, and are semantically equal up to phases that can be exchanged between the blocks.

It means that $D \sim_{\phi} D'$ if there exists $\varphi_1, \dots, \varphi_n, \psi_1, \dots, \psi_n$ such that the semantics of the $i^{th}$ dash box of the following figure:

<figure><img src="image_24.png" /></figure>

**Definition 50 (Rewriting system).** We consider the rewriting system that is rewriting each block $B_i$ containing at least one beam splitter by $\begin{array}{l} \xrightarrow{\text{---}\varphi---} \\ \xrightarrow{\text{---}\psi---} \end{array}$ if $[[B_i]]_1 = \begin{pmatrix} e^{i\varphi} & 0 \\ 0 & e^{i\psi} \end{pmatrix}$ and by
$$ \xrightarrow{\text{---}\varphi---} \xrightarrow{\text{---}\psi---} \text{ if } [[B_i]]_1 = \begin{pmatrix} 0 & e^{i\psi} \\ e^{i\varphi} & 0 \end{pmatrix}. $$

We can notice that:

- The system strictly decreases the number of beam splitters, hence is strongly normalising.

- It follows from the definition of $\sim_{\phi}$ that the systems preserves $\sim_{\phi}$.

- The system is locally confluent. Starting from $D$, if we rewrite $B_i$ giving $D_1$ or $B_j$ giving $D_2$, we can independently rewrite $B_i$ in $D_2$ and $B_j$ in $D_1$, giving the same circuit $D'$.
Finally, we can notice that the rules (p0), (swap), (p-p), (E2) and all the rules of the PROP also converse the relation $\approx_1$.

As the LHS and the RHS are distinct normal forms of our system, we know they can't be derived from the rules conserving $\sim_{\phi}$. Therefore, (E3) is necessary.

## B.4 Properties of the triangular forms of Section 2.3

<table><caption>**Table 10** Shapes and properties of classes of triangle LOPP-circuits: $n + \tilde{n} \to m + \tilde{m}$. ($\cdot, \circ$) are angles in $[0, 2\pi) \times [0, \frac{\pi}{2}]$ that satisfy the properties of Definitions 9 and 13. We emphasize the nonzero angles of $\tilde{\circ}$ by noting $\circ$ an arbitrary angle in $(0, \frac{\pi}{2}]$. The angles which are necessarily zero for the property 3 and 4 of Definition 13 are in red. We have $n = \tilde{n} = 3, m = 4$ and $\tilde{m} = 2$ for the first two figures, and $\tilde{m} = n = 2$ and $\tilde{n} = m = 3$ for the third.</caption><thead><tr><th>Shape</th><th>Properties</th></tr></thead><tbody><tr><td></td><td>Δ-circuits (Definition 9)<br>Uniquely determined by [[·]]<sub>1</sub> (Proposition 11).</td></tr><tr><td></td><td>n̄Δn̄-circuits (Definition 13)<br>Uniquely determined by the sub-matrix [[·]]<sub>1</sub> (1 : m, 1 : n) (Proposition 14). Used for the normal forms of LO<sub>fi</sub>.</td></tr><tr><td></td><td>n̄◇n̄-circuits (Definition 15)<br>They have exactly n̄ × m̄ nonzero beam splitters, with no identity wire. They are used in the proofs of Section 4.</td></tr></tbody></table>

## Proof of Proposition 11

The coefficient $t_{i,j}$ of $[[\Delta]]_1$ is determined by the sum of all the paths from the $j^{th}$ input wire to the $i^{th}$ output wire, where for each path, we multiply by a cos (resp. sin) term when the photon is reflected on (resp. transmitted through) a beam splitter, and by a phase when the path crosses a phase shifter. For instance:

$$t_{1,2} = \cos(\theta_{1,2})e^{i\varphi_{1,2}}i \sin(\theta_{1,1})e^{i\varphi_{1,1}} \text{ and}$$

$$t_{2,2} = i \sin(\theta_{1,2}) \cos(\theta_{2,2})e^{i\varphi_{2,2}}i \sin(\theta_{2,1})e^{i\varphi_{2,1}} + \cos(\theta_{1,2})e^{i\varphi_{1,2}}i \sin(\theta_{1,1}) \cos(\theta_{2,1})e^{i\varphi_{2,1}}.$$

More generally, we have $t_{i,j} = e^{i\varphi_{i,j}} \cos(\theta_{i,j}) \times q_{i,j} + r_{i,j}$ where $q_{i,j}, r_{i,j}$ are terms depending uniquely on the angles with lower indexes. We can notice there is at most one path from the $j^{th}$ input wire to the $i^{th}$ output wire involving $\theta_{i,j}$ and $\varphi_{i,j}$ and that $q_{i,j} \neq 0$ if and only if all $\theta_{k<i,j}$ and $\theta_{i,\ell<j}$ are nonzero. If one $\theta_{i,\ell<j}$ is zero, then we have $\varphi_{i,j} = \theta_{i,j} = 0$ by the properties of the Δ-circuits. If there are $K$ values of $\theta_{k<i,j}$ which are zero, then all the $K$ diagonals $\theta_{k,\ell' \ge j}$ are zero. By now considering the path from the $(j+K)^{th}$ input wire to the
$i^{th}$ output wire, we recover the same type of equation with $q_{i,j} \neq 0$. Now, we can subtract $r_{i,j}$ and dividing by $q_{i,j}$, so that we have $e^{i\varphi_{i,j}} \cos(\theta_{i,j}) = z_{i,j}$ with $z_{i,j} = (t_{i,j} - r_{i,j})/q_{i,j}$. If $z_{i,j} \neq 0$ then $\theta_{i,j} \in [0, \frac{\pi}{2})$ and $\varphi \in [0, 2\pi)$ are uniquely determined. If $z_{i,j} = 0$, then $\theta_{i,j} = \frac{\pi}{2}$ and by the properties of Δ-circuits, we have $\varphi_{i,j} = 0$.

**Remark 51.** The existence and the uniqueness have been shown in [10] for very similar circuits that have two minor differences; the phases were on the top left of the beam splitters, and the range of the thetas and phases, expect the last layer, were all in $[0, \pi)$. We can therefore have an alternative proof by changing the strongly normalising and confluent rewriting system so the thetas are always in $[0, \frac{\pi}{2}]$ and the phases stay on the bottom left instead of the top left, without restricting their range.

**C Some properties of the LO<sub>fi</sub>-circuits**

**C.1 Choice of the generators**

The sources and detectors of the LO<sub>fi</sub>-calculus allow any and arbitrary finite support state on many modes, which may seem to be too powerful or far from the physical implementation. In that regard, we would like to highlight that:

- Some sources can directly generate more generic states such as a coherent superposition with the vacuum of the 2-photon state [38], or even directly create entangled states [14].

- Linear optical circuits are very modular, and each building block is usually used many times. It would therefore be more convenient to sometimes represent those building blocks directly by specifying what they do, instead of how they are implemented, as illustrated in Figure 2.

- Optical interactions are very combinatorics, thus being unlikely to have a complete equational theory with only single mode sources<sup>7</sup>.

- This formalism still allows finding new results for linear optics, like the unique normal forms Section 4.

**C.2 Remarkable properties**

In this subsection, we show a list of remarkable properties that either illustrate the behavior of some circuits or give more insight on how they work.

Circuit with an identity wire have the semantics of a sum of smaller diagrams.

<figure><img src="image_25.png" /></figure>

$\llbracket C \rrbracket_{pre}$ can always be expressed as a sum of $\Omega$.

<footnote n="7">7 We can note that [15] bypasses that problem by allowing sums of diagrams</footnote>
**► Proposition 52 (Canonical decomposition).** For every LO<sub>fi</sub>-circuit C, [[C]]<sub>pre</sub> can be expressed as a linear combination of Ω<sup>u,v</sup>(D), with D a LOPP-circuit.

**Proof.** This is a direct consequence of the linearity of [[·]]<sub>pre</sub>. With $f = \sum_{\mathbf{u} \in \mathcal{U}} \alpha_{\mathbf{u}} |\mathbf{u}\rangle$, $\mathcal{U} \subset_f \mathbb{N}^{\tilde{n}}$ and $g = \sum_{\mathbf{v} \in \mathcal{V}} \beta_{\mathbf{v}} \langle \mathbf{v}|$, $\mathcal{V} \subset_f \mathbb{N}^{\tilde{n}}$, we have:

$$ \begin{aligned} [[C]]_{\text{pre}} &= \left[ \left( \begin{array}{c} \alpha_{\mathbf{u}} |\mathbf{u}\rangle \\ \vdots \\ \beta_{\mathbf{v}} \langle \mathbf{v}| \end{array} \right) \right]_{\text{pre}} \\ &= \sum_{\mathbf{u} \in \mathcal{U}} \sum_{\mathbf{v} \in \mathcal{V}} \alpha_{\mathbf{u}} \beta_{\mathbf{v}} \left[ \left( \begin{array}{c} |\mathbf{u}\rangle \\ \vdots \\ \langle \mathbf{v}| \end{array} \right) \right]_{\text{pre}} \\ &= \sum_{\mathbf{u}, \mathbf{v}} \alpha_{\mathbf{u}} \beta_{\mathbf{v}} \Omega^{\mathbf{u}, \mathbf{v}}(D) \\ &= \sum_{\mathbf{u}, \mathbf{v}} \omega_{\mathbf{u}, \mathbf{v}} \Omega^{\mathbf{u}, \mathbf{v}}(D) \end{aligned} $$

<figure><img src="image_26.png" /></figure>

**D Rewriting system of Section 4**

## D.1 LO<sub>fi</sub> is complete for LOPP

**► Lemma 53 (LO<sub>fi</sub> is complete for LOPP).** We can derive the equations of Figure 3 with the rules of the LO<sub>fi</sub>-calculus.

**Proof.** All the rules are present aside from (p-p). Note that Equation (b0) can be derived with the rules of the PROP, and the Equations (swap) and (E2), as detailed in Appendix B.2. We can now derive (p-p) as follows:

$$ \begin{array}{ccc} \begin{tikzpicture}[baseline=-0.5ex, scale=0.35, every node/.style={font=\scriptsize}] 
    \node (left) at (0,0) {$(s0-0d)(p2\pi)(b0)$};
    \node (right) at (6,0) {};
    \draw (-.5,0) -- (0,0);
    \draw (-.5,0) -- (0,-.5);
    \node[below=0.25cm of (-.5,0)] (top) {$\varphi_1$};
    \node[below=0.25cm of (0,-.5)] (bottom) {$\varphi_2$};
    \draw (-.5,0) -- (top);
    \draw (0,-.5) -- (bottom);
  \end{tikzpicture} & \cong & 
  \begin{tikzpicture}[baseline=-0.5ex, scale=0.35, every node/.style={font=\scriptsize}] 
    \node (left) at (0,0) {};
    \node (right) at (6,0) {};
    \draw (-.5,0) -- (0,0);
    \draw (-.5,0) -- (0,-.5);
    \node[below=0.25cm of (-.5,0)] (top) {$\varphi_1 + \varphi_2$};
    \node[below=0.25cm of (0,-.5)] (bottom) {};
    \draw (-.5,0) -- (top);
    \draw (0,-.5) -- (bottom);
  \end{tikzpicture} \\ 
  \cong & & 
  \begin{tikzpicture}[baseline=-0.5ex, scale=0.35, every node/.style={font=\scriptsize}] 
    \node (left) at (0,0) {};
    \node (right) at (6,0) {};
    \draw (-.5,0) -- (0,0);
    \draw (-.5,0) -- (0,-.5);
    \node[below=0.25cm of (-.5,0)] (top) {$\varphi_1 + \varphi_2$};
    \node[below=0.25cm of (0,-.5)] (bottom) {};
    \draw (-.5,0) -- (top);
    \draw (0,-.5) -- (bottom);
  \end{tikzpicture} \\ 
  \cong & & 
  \begin{tikzpicture}[baseline=-0.5ex, scale=0.35, every node/.style={font=\scriptsize}] 
    \node (left) at (0,0) {};
    \node (right) at (6,0) {};
    \draw (-.5,0) -- (0,0);
    \draw (-.5,0) -- (0,-.5);
    \node[below=0.25cm of (-.5,0)] (top) {$\varphi_1 + \varphi_2$};
    \node[below=0.25cm of (0,-.5)] (bottom) {};
    \draw (-.5,0) -- (top);
    \draw (0,-.5) -- (bottom);
  \end{tikzpicture} 
\end{array} $$

<figure><img src="image_27.png" /></figure>

## D.2 Derivation of the rewriting system: Lemma 35

Note that all equations including LOPP-circuits of Figure 6 can be derived, as a direct collorary of Lemma 53. For the other equations, we show that we can derive all equations of Figure 7, including the rules (12), (13) and (15). The rule (14) is proven in Lemma 55.
$$ (\dots | k_1 k_2 \quad \dots \quad \dots) \otimes (\dots | \ell_1 \ell_2 \quad \dots \quad \dots) = (\dots | k \quad \dots \quad \dots) \otimes (\dots | \ell \quad \dots \quad \dots) \qquad (\text{Rw}) $$

$$ f_k \otimes k \quad \dots \quad g_l \otimes l = \underset{k \notin \mathcal{L}}{f_k \otimes k + F \otimes \tilde{k}} \quad \dots \quad g_l \otimes l \qquad (+F) $$

$$ f_k \otimes k \quad \dots \quad g_l \otimes l = f_k \otimes k \quad \dots \quad g_l \otimes l + G \otimes \tilde{l} \qquad (+G) $$

$$ (\dots | \tilde{h}(k) \quad \dots \quad \dots) \otimes (\dots | \ell) = (\dots | k \quad \dots \quad \dots) \otimes (\dots | \ell(\tilde{h})) \qquad (\text{h1}) $$

$$ \tilde{m} : \quad g = \tilde{m} : \quad g' \qquad (\text{s-md}) $$

$$ f : \quad \tilde{n} \quad g = f' : \quad \tilde{n} \qquad (\text{sn-d}) $$

■ **Figure 7** Useful equations derived by the $LO_{fi}$-calculus as shown in Lemma 54. Equation (Rw) is removing one identity wire when there are two, Equation (+F) (resp. (+G)) add any term in the source (resp. detector) trivially orthogonal on the last mode, Equation (h1) is the same as Axiom (h2) on one mode, Equations (s-md) and (sn-d) are projections.
► Lemma 54 (Useful LO<sub>fi</sub>-equations). We can derive the equations of Figure 7 with the rules of the LO<sub>fi</sub>-calculus.

**Proof.** We consider a linear function $h : \mathcal{B}_2^{\text{pre}} \to \mathcal{B}_2^{\text{pre}}$ such that for every $k \in \mathbb{N}$, $h(|k, 0\rangle) = \tilde{h}(|k\rangle)$ and $(\langle k, 0|)h = (\langle k|)\tilde{h}$.

<figure><img src="image_28.png" /></figure>

<figure><img src="image_29.png" /></figure>

<figure><img src="image_30.png" /></figure>

<figure><img src="image_31.png" /></figure>

<figure><img src="image_32.png" /></figure>

<figure><img src="image_33.png" /></figure>

<figure><img src="image_34.png" /></figure>

We consider a linear function $h : \mathcal{B}_2^{\text{pre}} \to \mathcal{B}_2^{\text{pre}}$ and a finite set $K \subset \mathbb{N}$ such that for every $k \in K$, $h(|k, 0\rangle) = |k_1, k_2\rangle$.

<figure><img src="image_35.png" /></figure>

<figure><img src="image_36.png" /></figure>

<figure><img src="image_37.png" /></figure>
<figure><img src="image_38.png" /></figure>

We consider a linear function $h : \mathcal{B}_2^{\text{pre}} \to \mathcal{B}_2^{\text{pre}}$ such that $h = h^\dagger$, $h$ is swapping the states $|\tilde{\ell}, 0\rangle$ and $|\tilde{\ell}, 1\rangle$ and is the identity everywhere else. We have:

<figure><img src="image_39.png" /></figure>

Similarly and symmetrically, we can derive Equation (+F).

We consider a linear map $\tilde{h} : \mathcal{B}_1^{\text{pre}} \to \mathcal{B}_1^{\text{pre}}$ such that $\tilde{h}(|0\rangle) = \tilde{f}$. We have:

<figure><img src="image_40.png" /></figure>

Similarly and symmetrically, we can derive Equation (sn-d).

<figure><img src="image_41.png" /></figure>
► Lemma 55. We can derive the equation (14) in the LO<sub>fi</sub>-calculus:

<figure><img src="image_42.png" /></figure>

**Proof.** Let $\langle \psi_L | = \sum_{\ell \in \mathcal{L}} \xi_\ell \langle \ell |$. We have $g = \langle \mathcal{N}_{\tilde{m}}(L) | \langle \psi_L | + \sum_{\ell \in \mathcal{L} \setminus \{L\}} \langle g_\ell | \langle \ell |$. Let $\tilde{h} : \mathcal{B}_1^{\text{pre}} \to \mathcal{B}_1^{\text{pre}}$ be a linear function which is the identity on $|i\rangle$ for every $i \in (\mathcal{K} \cup \mathcal{L}) \setminus \{L\}$, such that $\langle L | \tilde{h} = \langle \psi_L |$, and zero elsewhere. We can check that $\tilde{h} |k\rangle = |k\rangle + \xi_k |L\rangle$ for $k \neq L$, and $\tilde{h} |L\rangle = \xi_L |L\rangle$. We have:

$$
\begin{align*}
g &= \langle \mathcal{N}_{\tilde{m}}(\ell) | \langle \psi_L | + \sum_{\ell \in \mathcal{L} \setminus \{L\}} \langle g_\ell | \langle \ell | \\
  &= \langle \mathcal{N}_{\tilde{m}}(L) | \langle L | \tilde{h} + \sum_{\ell \in \mathcal{L} \setminus \{L\}} \langle g_\ell | \langle \ell | \tilde{h}
\end{align*}
$$

The linear function $\tilde{h}$ can therefore be removed with the equation (h1), leading to:

$$
\begin{align*}
f &= |f_L\rangle \tilde{h}(|L\rangle) + \sum_{k \neq L} |f_k\rangle \tilde{h}(|k\rangle) \\
  &= \xi_L |f_L\rangle |L\rangle + \sum_{k \neq L} |f_k\rangle (|k\rangle + \xi_k |L\rangle) \\
  &= (\sum_{i \in \mathcal{K}} \xi_i |f_i\rangle) |L\rangle + \sum_{k \neq L} |f_k\rangle |k\rangle
\end{align*}
$$

<figure><img src="image_43.png" /></figure>

D.3 Strongly normalising: Proof of Lemma 39

Given a circuit C generated by the PRO version of the LO<sub>fi</sub>-circuits, we define (x<sub>1</sub>, x<sub>2</sub>, x<sub>3</sub>, ..., x<sub>6</sub>)
as:

n $x_1 = \sum_{i=0}^{n-2} (n-i)c(i)$ where c(i) is the number of beam splitters in C between the position i and i + 1.

x<sub>2</sub> is the sum of the number of beam splitters with angles not in [0, π/2], with those not in
[0, π) and those not in [0, 2π). For instance, a beam splitter with an angle of 3π will be
counted three times, and those with 3π/2 will be counted twice.

To define $x_3$, let us define the depth of a phase shifter $p$ of $C$, denoted $d(p)$, as the maximal number of beam splitters that a photon starting from $p$ and going to the right would be able to traverse before reaching an output port, if it were allowed to choose each time whether to be reflected or transmitted. Then $e := \sum_{p \text{ phase shifter in } C} w(p)9^{d(p)}$

where, given a phase shifter $p = [\varphi]$ of $C$, we define $w(p)$ as:

<figure><img src="image_44.png" /></figure>

x₄ is the number of identity wire connecting the sources and detectors.

x<sub>5</sub> is the number of sources and detectors in C,

to define x₆ let write in the Fock basis the generic terms in the sources as **f** =
∑<sub>k₁,...,k<sub>n+1</sub></sub> α<sub>k₁,...,k<sub>n+1</sub></sub> |k₁,...,k<sub>n+1</sub>⟩ and in the detectors as **g** = ∑<sub>ℓ₁,...,ℓ<sub>m+1</sub></sub> β<sub>ℓ₁,...,ℓ<sub>m+1</sub></sub> |ℓ₁,...,ℓ<sub>m+1</sub>⟩.
Then $x_6 := \sum_{f \in \text{sources}} C_1(f) + \sum_{g \in \text{detectors}} (2C_2(g) - C_3(g))$, with $C_1(f) := \#\{\alpha_{k_1, \dots, k_{\hat{n}+1}} \neq 0\}$, $C_2(g) := \#\{\beta_{\ell_1, \dots, \ell_{\hat{n}+1}} \neq 0\}$, and $C_3(g) := \#\{\beta_{\mathcal{N}_{\hat{m}}(L), L} = 1, L \in \mathbb{N}\}$.

We can highlight that $(x_1, x_2, x_3)$ are mainly inspired from [10]. We conclude the proof by noticing that:

- Rule 1 strictly decreases $x_3$ without changing previous components of the tuple.

- Rule 2 strictly decreases $x_2$ without changing $x_1$.

- Rule 3 strictly decreases $x_3$ without changing previous components of the tuple.

- Rule 4 strictly decreases $x_3$ without changing previous components of the tuple.

- Rule 5 strictly decreases $x_1$.

- Rule 6 strictly decreases $x_3$ without changing previous components of the tuple.

- Rule 7 strictly decreases $x_3$ without changing previous components of the tuple.

- Rule 8 strictly decreases $x_2$ without changing $x_1$.

- Rule 9 strictly decreases $x_2$ without changing $x_1$.

- Rule 10 strictly decreases $x_1$.

- Rule 11 strictly decreases $x_1$.

- Rule 12 strictly decreases $C_1$ without changing anything else, therefore strictly decreasing $x_6$.

- Rule 13 strictly decreases $2C_2 - C_3$, without changing anything else. Indeed, if we remove a coefficient where $\beta_{\mathcal{N}_{\hat{m}}(L), L} = 1$, then $-C_3$ increases by 1 but $2C_2$ decreases by two. Therefore, $2C_2 - C_3$ strictly decreases and $x_6$ is strictly decreasing.

- Rule 14 can change the three values of $C_1, C_2$ and $C_3$, but still strictly decreases $x_6$. Let us consider the two cases: $(\xi_L \neq 1) \land (\forall \ell \neq L, \xi_\ell = 0)$ and $(\xi_L = 1) \land (\exists \ell \neq L, \xi_\ell = 0)$. The first case doesn't change $C_1$ and $C_2$, but the term $-C_3$ strictly decreases by 1. The second case doesn't change $C_3$, and the increase of $C_1$, i.e. the amount of new terms in $f$, is bounded by $\#\{\xi_i \neq 0, i \neq L\}$, the number of terms removed in $g$, which is the exact decrease of $C_2$. Therefore, $C_1 + 2C_2$ decreases by at least $\#\{\xi_i \neq 0, i \neq L\} > 0$. We can check that the rule 13 is not changing any other component of the tuple, and can conclude it only strictly decreases $x_6$.

- Rule 15 strictly decreases $x_4$ without changing previous components of the tuple.

- The rules coming from the axioms ss and dd strictly decrease $x_5$ without changing the previous components.

- The rules coming from the axioms s-p and p-d strictly decrease $x_3$.

- The rules coming from the axioms s-b and b-d strictly decrease $x_1$.

## D.4 Rewriting to the zero normal form: Proof of Remark 38

In the normal form of Definition 36, it is possible that $K = \emptyset$, meaning the semantics of the all circuit is the null function. Note the zero vector on $B_2^{\text{pre}}$ can be written as $0 = 0 \otimes |0\rangle$ and the zero vector on $B_2^{*\text{pre}}$ as $0 = 0 \otimes \langle 1|$. We have:

<figure><img src="image_45.png" /></figure>
=

<figure><img src="image_46.png" /></figure>

(ss)(dd)

<figure><img src="image_47.png" /></figure>

PROP.(zero)

<figure><img src="image_48.png" /></figure>

(s-p)(s-b)

<figure><img src="image_49.png" /></figure>

(ss)(dd)

<figure><img src="image_50.png" /></figure>

=

<figure><img src="image_51.png" /></figure>

(sn-d)(s-md)

<figure><img src="image_52.png" /></figure>
E Uniqueness of the normal forms of Section 4

E.1 Uniqueness of T in the normal form: Lemma 41

► **Proposition 56.** Let $[[\tilde{\Delta}]]_1 = \left[\left[\begin{array}{cc} \theta & \mathbf{\Gamma} \\ & \mathbf{\Gamma}' \end{array}\right]\right]_1 = \begin{pmatrix} e^{i\varphi} c_{\theta} & i e^{i\varphi} s_{\theta} \\ i s_{\theta} & c_{\theta} \end{pmatrix} = \begin{pmatrix} a e^{i\varphi} & b e^{i\varphi} \\ b & a \end{pmatrix}$. Let $k, \ell, n \in \mathbb{N}$, with $n \gg k, \ell$ and $N = n + k - \ell$. For $a \neq 0$, we have:

$$ \langle N, \ell | \left[ \left[ \begin{array}{cc} \theta & \mathbf{\Gamma} \\ & \mathbf{\Gamma}' \end{array} \right] \right] | n, k \rangle = e^{iN\varphi} a^N \sqrt{\frac{N!}{n!}} Q_k^\ell(n) $$

where $Q_k^\ell$ is a real polynomial of degree $\ell$.

**Proof.** It directly follows from Definition 26, by noting that $n - N = \ell - k$:

$$ \begin{align*} \langle N, \ell | \left[ \left[ \begin{array}{cc} \theta & \mathbf{\Gamma} \\ & \mathbf{\Gamma}' \end{array} \right] \right] | n, k \rangle & = e^{iN\varphi} \sqrt{\frac{N!\ell!}{n!k!}} \sum_{\substack{p+q=N \\ \delta=p-q}} \binom{n}{p} \binom{k}{q} a^{k+\delta} b^{n-\delta} |\ell_1, \ell_2\rangle \\ & = e^{iN\varphi} \sqrt{\frac{N!\ell!}{n!k!}} \sum_{q=0}^{k} \binom{n}{N-q} \binom{k}{q} a^{k+(N-q)-q} b^{n-((N-q)-q)} \\ & = e^{iN\varphi} \sqrt{\frac{N!\ell!}{n!k!}} \sum_{q=0}^{k} \binom{n}{N-k+q} \binom{k}{q} a^{N+k-2q} b^{n-N+2q} \\ & = e^{iN\varphi} \sqrt{\frac{N!\ell!}{n!k!}} \sum_{q=0}^{k} \binom{n}{\ell-k+q} \binom{k}{q} a^{N+k-2q} b^{(\ell-k)+2q} \\ & = e^{iN\varphi} a^N \sqrt{\frac{N!}{n!}} \left( \sqrt{\frac{\ell!}{k!}} \sum_{q=0}^{k} \frac{n(n-1)\dots(n-\ell+k-q)}{(\ell-k+q)!} \binom{k}{q} a^{k-2q} b^{(\ell-k)+2q} \right) \\ & = e^{iN\varphi} a^N \sqrt{\frac{N!}{n!}} Q_k^\ell(n) \end{align*} $$

<figure><img src="image_53.png" /></figure>

Base case of Lemma 41

**Proof.** Let $[[\tilde{\Delta}]]_1 = \left[\left[\begin{array}{cc} \theta & \mathbf{\Gamma} \\ & \mathbf{\Gamma}' \end{array}\right]\right]_1 = \begin{pmatrix} a e^{i\varphi} & b e^{i\varphi} \\ b & a \end{pmatrix}$ and $[[\tilde{\Delta}')]_1 = \left[\left[\begin{array}{cc} \theta' & \mathbf{\Gamma}' \\ & \mathbf{\Gamma} \end{array}\right]\right]_1 =$
$\begin{pmatrix} a'e^{i\varphi'} & b'e^{i\varphi'} \\ b' & a' \end{pmatrix}$ with $0 < a \le 1$ and $0 < a' \le 1$ as$^8 \theta, \theta' \in (0, \frac{\pi}{2}]$. Let $W = \sum_{k, \ell} \omega_{k, \ell} \Omega^{k, \ell}(\tilde{\Delta}) =$
$\sum_{k, \ell} \omega'_{k, \ell} \Omega^{k, \ell}(\tilde{\Delta}') = W'$. Without loss of generality, let us consider that $0 < a \le a' \le 1$. By
hypothesis, there exists one $\omega'_{k, \ell} \ne 0$. Let us consider the maximum $\ell_{max}$ such that there
exists $k_m$ with $\omega_{k_m, \ell_{max}} \ne 0$. We have that for every $n \gg \ell_{max}, k$ with $N = k_m - \ell_{max} + n$:

$$ \begin{align*} \langle N | W | n \rangle &= \langle N | W' | n \rangle \\ \Leftrightarrow e^{iN\varphi} a^N \sqrt{\frac{N!}{n!}} \left( \sum_{k-\ell=k_m-\ell_{max}} \omega_{k,\ell} Q_k^\ell(n) \right) &= e^{iN\varphi'} a'^N \sqrt{\frac{N!}{n!}} \left( \sum_{k-\ell=k_m-\ell_{max}} \omega'_{k,\ell} Q_k'^\ell(n) \right) \end{align*} $$

<footnote>$^8$ Note the case $a = 0$ is not considered as $\tilde{\Delta}$ or $\tilde{\Delta}'$ would be a phase tensored the identity, and therefore wouldn't be a $\tilde{n}\tilde{\Delta}\tilde{m}$-circuit.</footnote>
where $Q_k^\ell$ and $Q_k^{\ell'}$ are real polynomials of degree $\ell$ (Proposition 56). Therefore for every such $n$, $N$ we have:

$$e^{iN(\varphi-\varphi')} \left(\frac{a}{a'}\right)^N \left( \sum_{k-\ell=k_m-\ell_{max}} \omega_{k,\ell} Q_k^\ell(n) \right) = \left( \sum_{k-\ell=k_m-\ell_{max}} \omega'_{k,\ell} Q_k^{\ell'}(n) \right)$$

As $\omega_{k_m, \ell_{max}} \neq 0$, the RHS is a nonzero complex polynomial of degree $\ell_{max}$ evaluated in $n$. Note the limit of the absolute value of the RHS is $\infty$ for $n \to \infty$. Then the LHS has necessarily a nonzero $\omega_{k, \ell}$ and $a' \le a$, otherwise the limit of the absolute value of the LHS is 0. Therefore, $a = a'$, thus $\cos(\theta) = \cos(\theta')$ and $\theta = \theta'$ as they are in $[0, \frac{\pi}{2}]$.

As $\theta = \theta'$, we have $a = a'$ and $b = b'$, thus $Q_k^\ell = Q_k^{\ell'}$ and for every $N \gg k_m, \ell_{max}$ with $n = \ell_{max} - k_m + N$:

$$\sum_{k-\ell=k_m-\ell_{max}} \left( e^{iN(\varphi-\varphi')} \omega_{k,\ell} - \omega'_{k,\ell} \right) Q_k^\ell(n) = 0$$

Necessarily, there exists $N_0$ such that for every $N \ge N_0$, we have $e^{iN(\varphi-\varphi')} \omega_{k_m, \ell_{max}} = \omega'_{k_m, \ell_{max}} \neq 0$. Otherwise, the absolute value of the LHS doesn't converge to 0 and therefore can't be equal to 0 for every $N$. As it is true for every $N \ge N_0$, it is in particular true for $N = N_0$ and $N = N_0 + 1$, thus $e^{i(\varphi-\varphi')} = 1$, thus $\varphi = \varphi'$. ◀

## Induction of Lemma 41

For the induction step, we add arbitrary nonzero inputs on the first $k$ (resp. last $k'$) wires and arbitrary nonzero $\ell$ (resp. last $\ell'$) outputs on $\tilde{\Delta}$ and $\tilde{\Delta}'$. That projects both sides of the equation on a strictly smaller space. By the induction hypothesis, we can deduce an equality between smaller submatrices, i.e. $[[\tilde{\Delta}]_1] (k:k', \ell:\ell') = [[\tilde{\Delta}']_1] (k:k', \ell:\ell')$. By taking complementary subspaces, we recover that $[[\tilde{\Delta}]_1] (1:m, 1:n) = [[\tilde{\Delta}']_1] (1:m, 1:n)$. We conclude that $\tilde{\Delta} = \tilde{\Delta}'$ with Proposition 14.

## E.2 Linear independence of the $\Omega$-morphisms

**Lemma 57 (Linear independence of $\Omega(\tilde{\Delta})$).** For any $\tilde{n} \Delta \tilde{m}$-circuit $\tilde{\Delta} : n + \tilde{n} \to m + \tilde{m}$, if $\sum_{u,v} \omega_{u,v} \Omega^{u,v}(\tilde{\Delta}) = \sum_{u,v} \omega'_{u,v} \Omega^{u,v}(\tilde{\Delta})$ then and $\omega_{u,v} = \omega'_{u,v}$ for every $u, v \in U, V$.

The proof of Lemma 57 is the focus of Section E.3 and E.4. In order to simplify the proofs, we show that the linear independence of $\Omega(\tilde{\Delta})$ with $\tilde{n} \Delta \tilde{m}$-circuits is equivalent to a linear independence on $\tilde{n} \Diamond_n$-circuits introduced in Definition 15. That is the following proposition.

**Proposition 58 (Linear independence of $\Omega(\tilde{\Omega})$).** For any $\tilde{n} \Delta \tilde{m}$-circuit $\tilde{\Delta} : n' + \tilde{n} \to m' + \tilde{m}$, there exist $n \le n'$, $m \le m'$ and a $\tilde{n} \Diamond_n$-circuit $\tilde{\Omega} : n + \tilde{n} \to m + \tilde{m}$ such that $\sum_{u,v} \omega_{u,v} \Omega^{u,v}(\tilde{\Delta}) = \sum_{u,v} \omega'_{u,v} \Omega^{u,v}(\tilde{\Delta})$ if and only if $\sum_{u,v} \omega_{u,v} \Omega^{u,v}(\tilde{\Omega}) = \sum_{u,v} \omega'_{u,v} \Omega^{u,v}(\tilde{\Omega})$.

**Proof.** By rewriting the shape of $\tilde{\Delta}$ with the rules of **LOPP**, we can show that $[[\tilde{\Delta}]_{pre} = [[D']_{pre} \llbracket (id^{\otimes n-\tilde{m}}) \otimes \tilde{\Omega} \rrbracket_{pre} [[D]_{pre}$. By applying the inverse of those morphisms to the first equation with the $\Omega(\tilde{\Delta})$ and by reversibly removing the identities, we obtain the second one with the $\Omega(\tilde{\Omega})$. More details are provided in Appendix F.1. ◀
### E.3 Equivalent decomposition with the creation operators

It is standard in the second quantification formalism of quantum physics to look at the evolution of the operators acting on the system rather than directly the evolution of the state. In particular, we associate for each mode $i$ a creation operator $\hat{a}_i^\dagger$ such that $\hat{a}_j^\dagger |x_1, \dots, x_m\rangle = \sqrt{x_j+1} |x_1, \dots, x_j+1, \dots, x_m\rangle$. This formalism has shown to be simpler to work with as given a linear optical circuit $D$, while the state evolutions are given by $[[D]]_{pre}$, the evolution of the creation operators are linear, hence linear optics, and directly given by $[[D]]_1$ [37, 28]. We give here the examples of the evolution of $\hat{a}_j^\dagger$ through a phase shifter and a beam splitter, while the case for a generic circuit $D$ is described in Proposition 61.

**Example 59** ($\hat{a}_j^\dagger$ through a phase shifter). Let $D = -[\varphi]$ with $[[D]]_1 = e^{i\varphi}$. Through $[[D]]_{pre}$, the creation operator has the following transformation: $\hat{a}_1^\dagger \mapsto e^{i\varphi}\hat{a}_1^\dagger$. We can check it is sound with $P_\varphi^{pre} := [[-\varphi]]_{pre}$. By first noticing $|k\rangle = \frac{(\hat{a}_1^\dagger)^k}{\sqrt{k!}}|0\rangle$, we have:

$$P_{\varphi}^{pre} |k\rangle = P_{\varphi}^{pre} \frac{(\hat{a}_1^\dagger)^k}{\sqrt{k!}} |0\rangle = \frac{(e^{i\varphi} \hat{a}_1^\dagger)^k}{\sqrt{k!}} P_{\varphi}^{pre} |0\rangle = \frac{(e^{i\varphi} \hat{a}_1^\dagger)^k}{\sqrt{k!}} |0\rangle = e^{ik\varphi} |k\rangle$$

**Example 60** ($\hat{a}_j^\dagger$ through a beam splitter). Let $D = \underbrace{\theta}_{\text{with } [[D]]_1} \underbrace{\left(\begin{matrix} c_\theta & is_\theta \\ is_\theta & c_\theta \end{matrix}\right)}_{\text{with } [[D]]_1}$. Similarly to Example 59 and as described in Appendix F.2, the creation operators have the following transformations: $\hat{a}_1^\dagger \mapsto c_\theta \hat{a}_1^\dagger + is_\theta \hat{a}_2^\dagger$ and $\hat{a}_2^\dagger \mapsto is_\theta \hat{a}_1^\dagger + c_\theta \hat{a}_2^\dagger$.

**Proposition 61** (General commutation rule with $[[\cdot]]_1$). For any LOPP-circuit $D: n + \tilde{n} \to m + \tilde{m}$ with $(d_{i,j}) = [[D]]_1$, we have:

$$\Lambda^{\mathbf{u}} [[D]]_{\text{pre}} = \prod_{j=1}^{\tilde{n}} \left( \sum_{i=1}^{n+\tilde{n}} d_{i,j} \hat{a}_i^{\dagger} \right)^{u_j} [[D]]_{\text{pre}} = \sum_{\#\mathbf{s}+\#\mathbf{s}'=\#\mathbf{u}} \delta_{\mathbf{s},\mathbf{s}'} (\Lambda^{\mathbf{s}} \otimes \Lambda^{\mathbf{s}'}) [[D]]_{\text{pre}}$$

where $\#\mathbf{x} := \sum_k x_k$ and $\Lambda^{\mathbf{u}} := \prod_{j=1}^{\tilde{n}} (a_j^\dagger)^{u_j}$.

**Proof.** We can prove $[[D]]_{pre} \hat{a}_j^\dagger = (\sum_i d_{i,j} \hat{a}_i^\dagger) [[D]]_{pre}$ by commuting each $\hat{a}_i^\dagger$ with all the phase shifters and beam splitters of $D$ with the formulas of Example 59 and 60. The first equality follows as the $\hat{a}_j^\dagger$ commute with each other. The second equality is shown by developing and noticing that $(\hat{a}_1^\dagger)^{s_1} \dots (\hat{a}_{\tilde{n}}^\dagger)^{s_{\tilde{n}}} (\hat{a}_{\tilde{n}+1}^\dagger)^{s_1'} \dots (\hat{a}_{\tilde{n}+n}^\dagger)^{s_{\tilde{n}}} = \Lambda^{\mathbf{s}} \otimes \Lambda^{\mathbf{s}'}$. $\quad$

We can now introduce the following new decomposition.

**Lemma 62** ($\Delta$-decomposition of $\Omega^{\mathbf{u},\mathbf{v}}(\tilde{\Omega})$). For any $\tilde{n}\Diamond_n$-circuit $\tilde{\Omega}$, $\mathbf{u} \in \mathbb{N}^{\tilde{n}}, \mathbf{v} \in \mathbb{N}^n$:

$$\Omega^{\mathbf{u},\mathbf{v}}(\tilde{\Omega}) = \sum_{\substack{s \preceq \mathbf{u}, \ t \leq \mathbf{v} \\ \#s-\#t=\#\mathbf{u}-\#\mathbf{v}}} \delta_{s,t} \Delta^{\mathbf{s},t}(\tilde{\Omega})$$

where $\Delta^{\mathbf{s},t}(\tilde{\Omega}) := (\Lambda^{\mathbf{s}} \otimes \mathrm{id}^n) \circ \Omega^{0,t}(\tilde{\Omega})$, $\delta_{\mathbf{u},\mathbf{v}} \neq 0$, $\prec$ is the lexicographical order, ie. $\mathbf{x} \prec \mathbf{u}$ if there exists $k$ such that $x_1 = u_1, \dots, x_{k-1} = u_{k-1}$ and $x_k < u_k$, and $\prec$ is the weak order on vectors such that $\mathbf{y} < \mathbf{v}$ if there exists $\ell$ with $y_\ell < v_\ell$ and $y_j \le v_j$ for $j \ne \ell$.

**Proof.** Let us define $\lambda(\mathbf{u}) := \prod_{j=1}^{\tilde{n}} \sqrt{u_j!}$. First, we commute $[[\tilde{\Omega}]]_{pre}$ and $\Lambda^{\mathbf{u}}$ as follows:

$$\begin{align*}
\Omega^{\mathbf{u},\mathbf{v}}(D) & \stackrel{\text{Def. } 42}{=} (\mathrm{id}^{\otimes m} \otimes \langle \mathbf{v} |) [[\tilde{\Omega}]]_{\text{pre}} (\mathrm{id}^{\otimes n} \otimes |\mathbf{u}\rangle) \\
& \stackrel{\text{Def. } 61}{=} (\mathrm{id}^{\otimes m} \otimes \langle \mathbf{v} |) [[\tilde{\Omega}]]_{\text{pre}} (\mathrm{id}^{\otimes n} \otimes \lambda(\mathbf{u})^{-1} \Lambda^{\mathbf{u}} |\mathbf{0}\rangle^{\tilde{n}}) \\
& \stackrel{\text{Prop. } 61}{=} \sum_{\substack{(\mathbf{s},\mathbf{s}') \in (\mathbf{S},\mathbf{S}') \\ \#\mathbf{s}+\#\mathbf{s}'=\#\mathbf{u}}} \lambda(\mathbf{u})^{-1} \delta'_{\mathbf{s},\mathbf{s}'} (\Lambda^{\mathbf{s}} \otimes \langle \mathbf{v} | \Lambda^{\mathbf{s}'} \rangle) [[\tilde{\Omega}]]_{\text{pre}} (\mathrm{id}^{\otimes n} \otimes |\mathbf{0}\rangle^{\tilde{n}})
\end{align*}$$
■ If $s'_j > v_j$ then $\langle v | \Lambda^{s'} = 0$. Otherwise, we have $\langle v | \Lambda^{s'} \propto \langle v - s' |$. By taking $t = v - s'$, the sum is over the set $\mathcal{T} = \{t, 0 \le t_1 \le v_1 \wedge \dots \wedge 0 \le t_n \le v_n\} = \{t, t \le v\}$.

■ The elements of $\mathcal{S}$ are determined by the formula in Proposition 61. As $\tilde{\Diamond}$ is a $\tilde{n}\Diamond_n$-circuit, $d_{i,j} = 0$ for $i < j - n$. We can show by developing the product of sums that necessarily $\delta'_{s,s'} = 0$ if $s \succ u$ and $\delta'_{u,v} \neq 0$. That is illustrated in Appendix F.3.

■ $\#s + \#s' = \#u$. As $t = v - s'$, we have $\#t = \#v - \#s'$ so $\#s - \#t = \#u - \#v$.

By taking $\delta_{s,t} = \lambda(\mathbf{u})^{-1}\delta'_{s,t}$, we conclude that $\Omega^{u,v}(\tilde{\Diamond})$ is equal to:

$$ \sum_{\substack{s \preceq u, t \leq v \\ \#s - \#t = \#u - \#v}} \delta_{s,t} (\Lambda^s \otimes \langle t |) [\tilde{\Diamond}]_{pre} (id^{\otimes n} \otimes |0\rangle^{\tilde{n}}) \\ = \sum_{\substack{s \preceq u, t \leq v \\ \#s - \#t = \#u - \#v}} \delta_{s,t} (\Lambda^u \otimes id^n) \circ \Omega^{0,t}(\tilde{\Diamond}) $$

$$ = \sum_{\substack{s \preceq u, t \leq v \\ \#s - \#t = \#u - \#v}} \delta_{s,t} \Delta^{s,t}(\tilde{\Diamond}) $$

<figure><img src="image_54.png" /></figure>

## E.4 Uniqueness of the canonical decomposition

Let us consider the scalar $z = \langle y | \Delta^{s,t}(\tilde{\Diamond}) | x \rangle$. $\Lambda^s$ adds $s_j$ photons on the $j^{th}$ output wire, so we need to detect at least $y_j$ on the $j^{th}$ output mode, otherwise $z$ is zero. Furthermore, $\Omega^{0,t}(\tilde{\Diamond})$ has no ancilla photon in the input, so to detect $t_n$ in the last detector, we need at least $t_{\tilde{n}}$ in the last input mode. If we have exactly $t_n$ in the last input mode, then we need at least $t_{n-1}$ photon in the second to last input mode, to be able to detect $t_{n-1}$ in the second last detector, otherwise $z = 0$. We can therefore prove the following proposition.

**Proposition 63 (Δ<sup>s,t</sup>(Δ̃) threshold properties).** For any $\tilde{n}\Diamond_n$-circuit $\tilde{\Diamond} : n + m \to n + m$ and $(s, t) \in (\mathbb{N}^n, \mathbb{N}^m)$, $\langle y | \Delta^{s,t}(\tilde{\Diamond}) | x \rangle$ is nonzero for $(x, y) = (t, s)$ and is zero if $(x \prec_r t) \lor (y \prec_r s)$, where $\prec_r$ is the reverse lexicographical order, i.e. $y \prec_r v$ if there exists $k$ such that $y_n = v_n, \dots, y_{k+1} = v_{k+1}$ and $y_k < v_k$.

**Proof.** More generally, $\langle y | \Delta^{s,t}(\tilde{\Diamond}) | x \rangle = 0$ if there exists one $y_j$ such that $y_j < s_j$. We chose a stronger constraint with $y \prec_r s$. The nonzero term for the case $(x, y) = (t, s)$ is a direct consequence of the definitions and the nonzero beam splitters of $\tilde{n}\Diamond_n$-circuits. ◀

**Lemma 64 (Linear independence of Δ<sup>s,t</sup>(Δ̃)).** For any $\tilde{n}\Diamond_n$-circuit $\tilde{\Diamond} : n + m \to n + m$, if $\sum_{s,t} \delta_{s,t} \Delta^{s,t}(\tilde{\Diamond}) = \sum_{s,t} \delta'_{s,t} \Delta^{s,t}(\tilde{\Diamond})$ then $\delta_{s,t} = \delta'_{s,t}$ for every $s, t \in (S, \mathcal{T})$.

**Proof.** Let $\Delta = \sum_{s,t} \delta_{s,t} \Delta^{s,t}(\tilde{\Diamond})$ and $\Delta' = \sum_{s,t} \delta'_{s,t} \Delta^{s,t}(\tilde{\Diamond})$. By Proposition 63, we have $\langle y | \Delta^{x,y}(\tilde{\Diamond}) | x \rangle \neq 0$. Let us consider the equation $\langle y | \Delta | x \rangle = \langle y | \Delta' | x \rangle$. By starting with $|x\rangle = |0\rangle^{\otimes n}$ and $\langle y | = \langle 0 |^{\otimes m}$, we deduce with Proposition 63 that $\delta_{0,0} = \delta'_{0,0}$. By instancing $y$ with the successive values of $\mathcal{S}$ ordered by $\prec_r$, we deduce that for every $s \in \mathcal{S}$, $\delta_{s,0} = \delta'_{s,0}$. Then, for each $s$ and by instancing $x$ with the successive values of $\mathcal{T}$ ordered by $\prec_r$, we deduce that for every $s, t$, $\delta_{s,t} = \delta'_{s,t}$. ◀

### Linear independence of Ω(Δ̃): Proof of Lemma 57

Let $W = \sum_{u,v} \omega_{u,v} \Omega^{u,v}(\tilde{\Diamond})$ Lem. 62 $\sum_{u,v} \omega_{u,v} (\sum_{s,t} \delta_{s,t}^{u,v} \Delta^{s,t}(\tilde{\Diamond})) = \sum_{s,t} \delta_{s,t} \Delta^{s,t}(\tilde{\Diamond})$ and $W' = \sum_{u,v} \omega'_{u,v} \Omega^{u,v}(\tilde{\Diamond})$ Lem. 62 $\sum_{u,v} \omega'_{u,v} (\sum_{s,t} \delta_{s,t}^{u,v} \Delta^{s,t}(\tilde{\Diamond})) = \sum_{s,t} \delta'_{s,t} \Delta^{s,t}(\tilde{\Diamond})$ with $W' = W$. We have $\delta_{u,v}^{u,v} \neq 0$ (Lemma 62) and $\delta_{s,t} = \delta'_{s,t}$ (Lemma 64). By taking $u_M$ the maximum of $\mathcal{U}$ with the total order $\prec$, and $v_m$ a maximal element of $\{v, \omega_{u_M, v} \neq 0\}$ with the partial order $\prec$, we have $\omega_{u_M, v_m} \delta_{u_M, v_m}^{u_M, v_m} = \delta_{u_M, v_m} = \omega'_{u_M, v_m} \delta_{u_M, v_m}^{u_M, v_m}$, therefore
$\omega_{u_M,v_m} = \omega'_{u_M,v_m}$. By repeating the same procedure with $W - \omega_{u_M,v_m} \Omega^{u_M,v_m}(\tilde{\Omega})$ and $W' - \omega'_{u_M,v_m} \Omega^{u_M,v_m}(\tilde{\Omega})$, we deduce that $\omega_{u,v} = \omega'_{u,v}$ for every $u, v \in \mathcal{U}, \mathcal{V}$, thus proving Proposition 58 and Lemma 57. ◀

F Proofs of Appendix E

F.1 Proof of Proposition 58

Let us consider a generic subtriangle $\tilde{n} \triangleq \tilde{m} : n + \tilde{n} \rightarrow m + \tilde{m}$. With the property 4, we know there exists one beam splitter with a nonzero angle on the $(n + \tilde{n} - 1, n + \tilde{n})$ wires. We note ★ the one on the most right. As this beam splitter cannot be connected to the $\tilde{n}$ last input wires, there is necessarily one beam splitter on the $(n + \tilde{n} - 1, n + \tilde{n})$ on its top left, and we also denote the most right of them with ★. Up to the $(\tilde{n} - 1, \tilde{n})$, we can show there is at least one nonzero beam splitter on the top left of the previous considered nonzero beam splitters, and we note with ★ the most right of them, meaning all the other beam splitters on its right and before the have zero angles 0. We denote $\circ$ (resp. $\bullet$) an arbitrary (resp. arbitrary but nonzero) beam splitter angle. With the property of Definition 9, if there is a nonzero angle ★ (resp. zero angle 0), then we necessarily have nonzero (resp. zero) angles for all the beam splitters above (resp. under) in the right diagonal. The angles which are necessarily zero for the property 3 and 4 of Definition 13 are in red.

Therefore, a $\tilde{n} \triangleq \tilde{m}$-circuit is always of the following form:

<figure><img src="image_55.png" /></figure>

Now, we can prove the following lemma.

► Lemma 65 ($\tilde{n} \Diamond_n$-circuit extraction). Any $\tilde{n} \triangleq \tilde{m}$-circuit can be rewritten to:

<figure><img src="image_56.png" /></figure>

where $D: n \rightarrow n$ and $D': m \rightarrow m$ are two **LOPP**-circuits and $\tilde{\Diamond}$ is a $\tilde{n} \Diamond \tilde{m}$-circuit.

**Proof.** With the completeness of **LOPP**, we can change the shape of the circuit so the apex of the triangle is now at the bottom. More precisely, we can apply Equation (oE3) many times to move all the beam splitters under the diagonal of ★ as follows:

<figure><img src="image_57.png" /></figure>
We conclude by noticing we have indeed the nonzero beam splitters as expected.

We can now prove Proposition 58. Let $U = D \otimes id^{\otimes \tilde{n}}$, $U' = D' \otimes id^{\otimes \tilde{m}}$ and $I_k = id^{\otimes n - \tilde{m}}$.
We have:

$$
\begin{align*}
& \sum_{u,v} \omega_{u,v} \Omega^{u,v}(\tilde{\Delta}) &&= \sum_{u,v} \omega'_{u,v} \Omega^{u,v}(\tilde{\Delta}) \\
\Leftrightarrow \quad & \sum_{u,v} \omega_{u,v} \Omega^{u,v}(U' \circ (I_k \otimes \tilde{\Delta}) \circ U) &&= \sum_{u,v} \omega'_{u,v} \Omega^{u,v}(U' \circ (I_k \otimes \tilde{\Delta}) \circ U) \\
\Leftrightarrow \quad & \sum_{u,v} \omega_{u,v} ([[D']_{pre} \Omega^{u,v}(I_k \otimes \tilde{\Delta})) [[D]]_{pre}) &&= \sum_{u,v} \omega'_{u,v} ([[D']_{pre} \Omega^{u,v}(I_k \otimes \tilde{\Delta})) [[D]]_{pre}) \\
\Leftrightarrow \quad & [[D']_{pre} \left( \sum_{u,v} \omega_{u,v} \Omega^{u,v}(I_k \otimes \tilde{\Delta}) \right) [[D]]_{pre}) &&= [[D']_{pre} \left( \sum_{u,v} \omega'_{u,v} \Omega^{u,v}(I_k \otimes \tilde{\Delta}) \right) [[D]]_{pre}) \\
\Leftrightarrow \quad & \sum_{u,v} \omega_{u,v} \Omega^{u,v}(I_k \otimes \tilde{\Delta}) &&= \sum_{u,v} \omega'_{u,v} \Omega^{u,v}(I_k \otimes \tilde{\Delta}) \\
\Leftrightarrow \quad & I_k \otimes \left( \sum_{u,v} \omega_{u,v} \Omega^{u,v}(\tilde{\Delta}) \right) &&= I_k \otimes \left( \sum_{u,v} \omega'_{u,v} \Omega^{u,v}(\tilde{\Delta}) \right) \\
\Leftrightarrow \quad & \sum_{u,v} \omega_{u,v} \Omega^{u,v}(\tilde{\Delta}) &&= \sum_{u,v} \omega'_{u,v} \Omega^{u,v}(\tilde{\Delta})
\end{align*}
$$

## F.2 Example 60: the creation operator through a beam splitter

Similarly to Example 59 with the phase shifter, let $D = \underbrace{\theta}_{\text{with } [[D]]_1 = \begin{pmatrix} c_\theta & is_\theta \\ is_\theta & c_\theta \end{pmatrix}}$.
Through $[[D]]$, the creation operators have the following transformations: $\hat{a}_1^\dagger \mapsto c_\theta \hat{a}_1^\dagger + is_\theta \hat{a}_2^\dagger$ and $\hat{a}_2^\dagger \mapsto is_\theta \hat{a}_1^\dagger + c_\theta \hat{a}_2^\dagger$. We can check it is sound with $[[\underbrace{\theta}_{\text{defined in Definition 26}}]]$.
Indeed, we have:

$$
\begin{align*}
& [[\underbrace{\theta}_{\text{}}]] |k_1, k_2\rangle \\
&= [[\underbrace{\theta}_{\text{}}]] \frac{(\hat{a}_1^\dagger)^{k_1} (\hat{a}_2^\dagger)^{k_2}}{\sqrt{k_1! k_2!}} |0, 0\rangle \\
&= \frac{1}{\sqrt{k_1! k_2!}} (c_\theta \hat{a}_1^\dagger + is_\theta \hat{a}_2^\dagger)^{k_1} (is_\theta \hat{a}_1^\dagger + c_\theta \hat{a}_2^\dagger)^{k_2} [[\underbrace{\theta}_{\text{}}]] |0, 0\rangle \\
&= \frac{1}{\sqrt{k_1! k_2!}} (c_\theta \hat{a}_1^\dagger + is_\theta \hat{a}_2^\dagger)^{k_1} (is_\theta \hat{a}_1^\dagger + c_\theta \hat{a}_2^\dagger)^{k_2} |0, 0\rangle \\
&= \frac{1}{\sqrt{k_1! k_2!}} \left( \sum_{p=0}^{k_1} \binom{k_1}{p} (c_\theta \hat{a}_1^\dagger)^p (is_\theta \hat{a}_2^\dagger)^{k_1-p} \right) \left( \sum_{q=0}^{k_2} \binom{k_2}{q} (is_\theta \hat{a}_1^\dagger)^q (c_\theta \hat{a}_2^\dagger)^{k_2-q} \right) |0, 0\rangle \\
&= \frac{1}{\sqrt{k_1! k_2!}} \left( \sum_{\substack{\ell_1=0 \\ \delta=p-q}}^{k_1+k_2} \sum_{p+q=\ell_1} \binom{k_1}{p} \binom{k_2}{q} c_\theta^{k_2+\delta} (is_\theta)^{k_1-\delta} (\hat{a}_1^\dagger)^{\ell_1} (\hat{a}_2^\dagger)^{k_1+k_2-\ell_1} \right) |0, 0\rangle \\
&= \sum_{\ell_1+\ell_2=k_1+k_2} \sqrt{\frac{\ell_1! \ell_2!}{k_1! k_2!}} \sum_{\substack{p+q=\ell_1 \\ \delta=p-q}} \binom{k_1}{p} \binom{k_2}{q} c_\theta^{k_2+\delta} (is_\theta)^{k_1-\delta} |\ell_1, \ell_2\rangle
\end{align*}
$$

## F.3 Proof of Lemma 62

We want to illustrate that $s \preceq t$ in the $\Delta$-decomposition of $\Omega^{u,v}(\tilde{\Delta})$. Let us consider the following example with $n = 2$ and $\tilde{n} = 3$:
<figure><img src="image_58.png" /></figure>

At first, we have $[[\tilde{\Delta}]_{pre}(\hat{a}_3^\dagger)^{u_1}(\hat{a}_4^\dagger)^{u_2}(\hat{a}_5^\dagger)^{u_3}$. The only path for the photons to be in the first output wire is by the third input wire. Therefore, we necessarily have $s_1 \le u_1$. If all the photons went into the first output wire, ie. $s_1 = u_1$, then necessarily we have $s_2 \le u_2$, as the only paths that could add photons to the second output are the third and fourth input modes. Similarly, if $s_2 = u_2$ then $s_3 \le u_3$. Therefore, we have $s \le u$.