# The XP Stabiliser Formalism: a Generalisation of the Pauli Stabiliser
Formalism with Arbitrary Phases

Mark A. Webster<EMAIL_ADDRESS>Centre for Engineered Quantum
Systems, School of Physics, University of Sydney, Sydney, NSW 2006, Australia
Sydney Quantum Academy, Sydney, NSW, Australia  Benjamin J. Brown  Centre for
Engineered Quantum Systems, School of Physics, University of Sydney, Sydney,
NSW 2006, Australia  Niels Bohr International Academy, Niels Bohr Institute,
Blegdamsvej 17, University of Copenhagen, 2100 Copenhagen, Denmark  Stephen D.
Bartlett  Centre for Engineered Quantum Systems, School of Physics, University
of Sydney, Sydney, NSW 2006, Australia

###### Abstract

We propose an extension to the Pauli stabiliser formalism that includes
fractional $2\pi/N$ rotations around the $Z$ axis for some integer $N$. The
resulting generalised stabiliser formalism – denoted the _XP stabiliser
formalism_ – allows for a wider range of states and codespaces to be
represented. We describe the states which arise in the formalism, and
demonstrate an equivalence between XP stabiliser states and ‘weighted
hypergraph states’ - a generalisation of both hypergraph and weighted graph
states. Given an arbitrary set of XP operators, we present algorithms for
determining the codespace and logical operators for an XP code. Finally, we
consider whether measurements of XP operators on XP codes can be classically
simulated.

##  1 Introduction

Representing general quantum states of $n$ qubits requires an amount of
information that is exponential in $n$. For tractable theoretical study of
quantum systems, we require more compact representations of quantum states of
interest. Some examples of such representations include tensor network states
e.g. Matrix Product States and Projected Entangled Pair States [20] and states
created by low-depth quantum circuits [9].

The Pauli stabiliser formalism allows for the efficient description and
manipulation of an important subset of quantum states, known as Pauli
stabiliser states [12]. Pauli stabiliser states and codes can be efficiently
described using a set of stabiliser generators, which are elements of the
Pauli group $\langle iI,X,Z\rangle^{\otimes n}$, with only $n$ such generators
needed to describe a Pauli stabiliser state. Many key quantum features such as
entanglement and superposition can be captured using stabiliser states. Given
the stabiliser generators, efficient algorithms exist for determining the
codespace, logical operators and simulating measurements of Pauli operators.
On the other hand, the states which can be represented within the Pauli
stabiliser formalism are quite limited. The fact that we can simulate the
behaviour of Pauli stabiliser states suggests that we are missing some
important aspects of quantum advantage.

Given the ubiquity and the utility of the Pauli stabiliser formalism in
quantum information theory, it is no surprise that there have been several
studies into generalising this formalism in order to broaden the classes of
stabiliser states. One such approach is the _qudit_ stabiliser formalism,
where we fix a dimension $D$ and stabiliser generators are from the
generalised Pauli group on $D$-level systems. The algorithms from the Pauli
stabiliser formalism can be extended to qudit codes [11], and measurement of
any generalised Pauli group operator is known to be classically simulable [2].

Another generalisation is the _XS stabiliser formalism_ [18], wherein
stabiliser codes are defined using elements of $\langle\alpha
I,X,S\rangle^{\otimes n}$ which act on qubits and where $\alpha:=e^{i\pi/4}$
and $S:=\text{diag}(1,i)$ is the phase gate. In Ref. [18], the authors
demonstrate that states outside the Pauli stabiliser formalism can be
represented as XS stabiliser states. In particular, they demonstrate that
Quantum Twisted Double models which harbour non-Abelian anyons can be
represented in the XS formalism. The authors present algorithms for
determining the codespace, expectation values and logical operators for such
codes, but these are limited to certain ‘regular’ codes.

In this paper, we introduce the XP stabiliser formalism which generalises the
concept of the XS formalism. In the XP formalism, we fix an integer $N$ and
define XP codes using elements of $\langle\omega I,X,P\rangle^{\otimes n}$
where $\omega:=e^{i\pi/N},P:=\text{diag}(1,\omega^{2})$. We prove that
hypergraph and weighted graph states can be represented as XP stabiliser
states. These are useful classes of states which cannot be represented as
Pauli stabiliser states. We present XP versions of many of the algorithms
available in the Pauli stabiliser formalism, which apply to any XP code. This
includes algorithms to determine the codespace, logical operators and simulate
the measurement of diagonal Pauli operators on an XP codespace. Computational
complexity of these tasks increases with the precision $N$ of the code. We
demonstrate that measurement of XP operators on a codespace is not always
efficiently simulable. Hence, the XP formalism lies on the boundary between
what is classically simulable and what is not, suggesting that we may be able
to capture some aspects of quantum advantage.

The XP stabiliser formalism has a number of potential applications. For
instance, the logical operator structure of XP codes is much richer than is
the case for Pauli stabiliser codes. We could potentially use the XP formalism
to describe codes with transversal logical non-Clifford operations (for
instance T or CCZ gates) that could be used for fault-tolerant preparation of
magic states. As the stabiliser generators of XP codes do not commute, certain
no-go theorems may not apply, for instance, in the area of quantum memories
[4]. Compared to the Pauli stabiliser formalism, a wider range of topological
phases can be represented, which makes studying them more straightforward
using the techniques presented in this paper.

This paper is structured to present the framework and tools necessary to start
exploration of the XP formalism, with examples used throughout the paper.
Where possible, examples are linked to interactive Jupyter notebooks that
allow for further exploration and modification of these examples by the
reader.

In Chapter 2, we review the Pauli stabiliser formalism and the XS Formalism
introduced in Ref. [18]. We then introduce the XP formalism and summarise the
main results of this paper. In Chapter 3, we set out definitions for XP
operators and give a full description of their algebra. In Chapter 4, we show
how to identify the codespace of an arbitrary set of XP operators and
calculate a set of codewords which form a basis of the codespace. In Chapter
5, we classify the states which arise in the XP formalism and show that two
important classes of states can be represented as XP stabiliser states:
hypergraph [23] and weighted graph states [14, 13].

In Chapter 6, we address the logical operator structure of XP codes. We show
how to find XP operators which generate the logical operator group for a given
codespace. We can allocate quantum numbers to the codewords of Chapter 4, and
this leads to a classification of XP codes into XP-regular and non-XP-regular
codes. We show that any XP-regular code can be mapped to a CSS code with
similar logical operator structure. We show how to determine all possible
logical actions which can be applied by diagonal operators and demonstrate
that non-XP-regular codes give rise to logical operators with complex actions.

In Chapter 7, we look at measurements in the XP formalism. We demonstrate an
efficient algorithm for simulation of measurement of diagonal Pauli operators
on any XP code. Beyond this special case, XP operators cannot in general be
measured within the XP formalism. Estimating measurement outcome probabilities
for XP operators is in general an NP-complete problem.

We conclude in Chapter 8 with a discussion and list of outstanding questions
for the XP formalism.

##  2 The XP Stabiliser Formalism

The Pauli stabiliser formalism (PSF) has been hugely valuable for describing
the quantum error-correcting codes we need to overcome the decohering effects
of the environment on quantum systems. Moreover, its structure is such that we
can prove powerful results on the simulability of Clifford circuits.

Nevertheless, this formalism is limited in the types of quantum states it can
describe. Extending the stabiliser formalism gives us new tools to describe
more general quantum systems, and to explore their potential applications.

In this section, we first review the PSF and discuss the desirable features
that we would like to carry over into an extension to the formalism. We next
discuss the XS Formalism introduced in Ref. [18], which is an extension of the
PSF. We then introduce our new formalism, the XP formalism, which generalises
the concept of the XS Formalism. Finally, we outline the main properties of
the XP formalism and summarise the results presented in this paper.

###  2.1 Review of the Pauli Stabiliser Formalism

Pauli stabiliser codes are amongst the most commonly studied quantum error
correction codes. A stabiliser code is specified by a list of stabiliser
generators. The stabiliser generators are tensor products of operators in the
single-qubit Pauli group $\mathcal{P}=\langle iI,X,Z\rangle$. The stabiliser
group is the group generated by the stabiliser generators. The codespace is
the simultaneous $+1$ eigenspace of the stabiliser group. The codewords are a
basis of the codespace (i.e. spanning and independent).

The power of the Pauli stabiliser formalism is that stabiliser codes can be
analysed and simulated by operations on the stabiliser generators rather the
codewords. In Chapter 10 of Ref. [19], efficient algorithms involving
operations on the stabiliser generators are set out for the following tasks:

  1. 1.

Check if a set of Pauli operators identify a non-trivial codespace: equivalent
to checking whether $-I$ is in the stabiliser group.

  2. 2.

Find codewords and logical operators: represent the stabiliser generators as
binary vectors which form the rows of a check matrix, then apply linear
algebra techniques.

  3. 3.

Simulate action of Clifford Unitary Operator $U$: the updated code generators
are obtained by conjugating each of the generators by $U$.

  4. 4.

Simulate measurement of Pauli Operator $A$: update the stabiliser generators
by determining if they commute or anticommute with $A$.

The above properties allow us to detect and correct errors in Pauli stabiliser
codes by measuring the stabiliser generators.

###  2.2 Extending the Pauli Stabiliser Formalism - Existing Work

The Pauli stabiliser formalism (PSF) is capable of describing only a limited
subset of all possible quantum states. One way to extend the PSF is to
consider qudit stabiliser codes using the Generalised Pauli Group [11], and
there is a fairly substantial literature on this generalisation.

Another way is to work with qubits, but to admit operators with finer
rotations around the Z axis in stabiliser groups. In the XS stabiliser
formalism, introduced in Ref. [18], stabiliser generators are tensor products
of operators in $\langle\alpha I,X,S\rangle$ where $S:=\text{diag}(1,i)$ so
that $S^{4}=I$ and $\alpha:=\exp(i\pi/4)$ so that $\alpha^{8}=1$. The XS
stabiliser formalism can describe a wider range of states compared to the PSF,
meaning there are XS code states that cannot be expressed within the PSF.
Examples of such XS code states are the twisted quantum double models [8].

A set of XS stabiliser generators do not need to commute to form a valid code.
As a result, we cannot in general perform simultaneous measurements of the
generators, as is commonly done in PSF codes for error correction. Even so,
commuting parent Hamiltonians for XS codes exist, and so error correction is
possible with XS codes.

In the XS stabiliser formalism, regular codes are a special case, defined as
those where the diagonal generators are tensor products of
$\langle-I,Z\rangle$. For these regular codes, Ref. [18] presents algorithms
to: calculate the codewords from a list of stabiliser generators; calculate
the stabiliser generators for a given codeword; calculate logical $Z$ and $X$
operators for a codespace; construct a circuit to find expectation values for
measurements of Pauli operators on the code.

In summary, Ref. [18] provides a useful generalisation of the PSF, as well as
generalising a number of algorithms for analysing and simulating codes. One of
the main limitations of the XS stabiliser formalism is that many algorithms
only work for regular codes, which are a subset of possible XS codes.

###  2.3 The XP Stabiliser Formalism

In our work, we introduce a formalism that generalises the the XS stabiliser
formalism concept, allowing us to represent an even wider set of states. We
demonstrate algorithms for most of the operations we have under the PSF, with
a corresponding increase in computational complexity. The algorithms work on
any XP code and are not restricted to regular codes as in Ref. [18]. The XP
formalism is at a similar level of generality as that presented for qudits in
Ref. [11], and we prove many analogous results. The properties of XP and qudit
stabiliser codes are compared in Table 1.

|  Qudit Codes Ref. [11] |  XP Codes
---|---|---
Parameters |  Qudit Dimension $D$, Number of qudits $n$ |  Precision $N$, Number of qubits $n$
Phases |  $\omega=\exp(2\pi i/D)$ |  $\omega=\exp(\pi i/N)$
Generalised X |  $X=\sum_{0\leq j\leq D-1}|j\rangle\langle j+1|$ |  Pauli $X$
Generalised Z |  $Z=\sum_{0\leq j\leq D-1}\omega^{j}|j\rangle\langle j|$ |  $P=\text{diag}(1,\omega^{2})$
Vector form of operators |  $\omega^{p}X^{\mathbf{x}}Z^{\mathbf{z}}$ where $p\in\mathbb{Z}_{D},\mathbf{x},\mathbf{z}\in\mathbb{Z}_{D}^{n}$ |  $\omega^{p}X^{\mathbf{x}}P^{\mathbf{z}}$ where $p\in\mathbb{Z}_{2N},\mathbf{x}\in\mathbb{Z}_{2}^{n},\mathbf{z}\in\mathbb{Z}_{N}^{n}$
Commutators |  Operators commute, up to phase |  Operators commute, up to a diagonal operator
Clifford (Normaliser) Group |  Known - Table III of Ref. [11] |  Unknown - most likely restricted to tensors of single-qubit XP operators and Controlled Z operators
Generalised Hadamard |  Quantum Fourier Transform |  None
Code Stabilisers $\langle G\rangle$ Commute |  Yes |  No
Code Stabilisers Uniquely defined by Codespace |  Yes |  No - but Logical Identity Group is Unique (Section 6.2.3)
Standard form of Stabiliser Groups |  Yes - Using Smith Normal Form |  Yes - Using Howell Matrix Form
Codespace Dimension |  $\dim(\mathcal{C})=D^{n}/|\langle G\rangle|$ |  Arbitrary
Classical Simulation of Measurements |  Yes - any generalised Pauli Ref. [2] |  Not possible for arbitrary XP operators
Table 1: Qudit Stabiliser Codes Compared to XP Codes

An XP stabiliser code is defined by fixing an integer $N\geq 2$ which we refer
to as the precision of the code. We then specify a set of stabiliser
generators which are from $\langle\omega I,X,P\rangle^{\otimes n}$ where

$\displaystyle\omega$ $\displaystyle:=\exp\Big{(}\frac{\pi
i}{N}\Big{)}=\exp\Big{(}\frac{1}{2N}2\pi i\Big{)}\text{ so }\omega^{2N}=1$ (1)
$\displaystyle P$ $\displaystyle:=\text{diag}(1,\omega^{2})\text{ so
}P^{N}=I\,.$ (2)

Each choice of precision $N$ leads to a different stabiliser formalism. For
example, $N=2$ corresponds to the standard Pauli stabiliser formalism, with
$\omega=i$ and $Z^{2}=I$. The XS stabiliser formalism of Ref. [18] corresponds
to $N=4$, with $\omega=\sqrt{i}$ and $S^{4}=I$. Note that $N$ does not need to
be a power of 2 - e.g., $N=6$ or $N=7$ are valid choices.

Unlike the Pauli stabiliser formalism, the XPF is not closed under conjugation
by Hadamard operators. In particular, if $N=2M$ then:

$\displaystyle HPH^{-1}=\sqrt[M]{X}$ (3)

One could consider expanding the formalism to allow fractional $X$ operators
of this type, but this does not lead to a finite set of operators that is
closed under group operations.

There are a number of open questions from Ref. [18] which we also address for
both XS codes and the general XP case:

  * •

How do we find all transversal logical operators for a given code?

  * •

Which sets of operators stabilise the same codespace?

  * •

Can we simulate measurements efficiently?

  * •

Which classes of states can be described within a generalisation of the
stabiliser formalism?

|  XS Formalism [18] |  XP Formalism
---|---|---
Form of Stabiliser Generators |  $\langle\alpha I,X,S\rangle^{\otimes n}:S^{4}=I,\alpha^{8}=1$ |  $\langle\omega I,X,P\rangle^{\otimes n}:P^{N}=I,\omega^{2N}=1$
Determine Codewords from Stabiliser Generators |  Regular codes only |  All XP codes
Determine Stabiliser Generators from Codewords |  States only (1D codespaces) |  Any codespace
Which stabiliser groups have the same codespace? |  Open question |  Same logical identity group $\Leftrightarrow$ same codespace
Determine Logical Operators for a Code |  Regular codes only: $\overline{Z}$ and $\overline{X}$ |  All XP codes: Generators for XP logical operator group, which may include non-Clifford logical operators
Simulate Measurements on a Code |  Regular codes: circuit method to calculate expectation value when measuring Paulis |  All XP codes: Stabiliser algorithm to measure diagonal Paulis; Codeword algorithm to calculate outcome probabilities when measuring any XP operator.
Table 2: Summary of Results and Comparison with XS Formalism

###  2.4 Summary of Results

We present algorithms within the XPF for many of the operations that are
possible within the Pauli stabiliser formalism (PSF). Our formalism is broader
than the XS formalism and answers a number of open questions from Ref. [18].
Table 2 compares the XS stabiliser formalism with the XPF and summaries the
results we demonstrate in this paper.

We start by setting out the algebra of XP operators in Chapter 3. We show how
to represent XP operators as vectors of integers. By generalising the
symplectic product of the PSF, we write elegant closed form expressions for
the main algebraic operations on XP operators - including multiplication,
inverses, powers, conjugation and commutation. We also show efficient ways to
calculate the eigenvalues and the action of projectors of XP operators.

We specify XP codes by giving a list of XP operators which have a non-trivial
simultaneous $+1$ eigenspace. In Chapter 4, we show how to identify the
codespace for an arbitrary set of XP operators. In Ref. [18], a method is
presented for doing this, but only for ‘regular’ codes where the diagonal
stabiliser generators are from $\langle-I,Z\rangle^{\otimes n}$. We
demonstrate an algorithm which works for any XP code, whether regular or not.

Having introduced some of the basic techniques for working with XP codes, in
Chapter 5 we determine which states arise under the XP formalism. We identify
the form of the phase function of XP stabiliser states and show an equivalence
between ‘weighted hypergraph states’ and XP stabiliser states. In particular,
two important classes of states - hypergraph and weighted graph states - can
be represented as XP stabiliser states. We give examples which have potential
uses in measurement-based quantum computation and self-correcting quantum
memories.

Understanding which logical operators arise for a given XP code has important
implications for which error-protected operations are possible. In Chapter 6
we show how to calculate generators for the entire group of logical operators
of XP form. The algorithm works for all XP codes, and yields any non-Clifford
logical operators (e.g., logical T, CCZ etc) of XP form which act on the
codespace.

The stabiliser group of a codespace is not unique in the XPF, but the group of
XP operators which act as logical identities on the codespace is unique. We
show how to efficiently calculate generators for the logical identity group
for a given XP group, resulting in a test for whether two XP groups stabilise
the same codespace.

In Section 6.5 we introduce a classification of XP codes into XP-regular and
non-XP-regular codes. XP-regular codes include all ‘regular’ codes as defined
in Ref. [18], but is a broader class. We show that, as in the PSF, the
codespace dimension of XP-regular codes is a power of 2. For non-XP-regular
codes, the codespace dimension is arbitrary. Non-XP-regular codes are non-
additive and have a structure similar to that of codeword stabilised (CWS)
quantum codes [7]. Each XP-regular code can be mapped to a CSS code which has
a similar logical operator structure. We demonstrate that for non-XP-regular
codes, more complex diagonal operators can arise compared to the PSF. A
summary of the differences between XP-regular and non XP-regular codes is in
Table 3.

Property |  XP-Regular |  Non-XP-Regular
---|---|---
Codespace Dimension |  $2^{k}$ for some $k$ |  Arbitrary
Additive |  Yes |  No
Related CSS Code |  Maps to a CSS code with similar logical operator structure |  No related CSS code
Diagonal Logicals |  Same as related CSS code |  Exotic
Non-diagonal Logicals |  Similar to related CSS code |  Transversal logical X may not exist
Table 3: XP-Regular vs Non XP-Regular Codes

Determining the extent to which computations on a quantum computer can be
classically simulated is one of the central questions in the field of quantum
information. In the Pauli stabiliser formalism, we can classically simulate
the measurement of any Pauli operator on any stabiliser code. A similar result
holds for the qudit stabiliser formalism for generalised Pauli group
operators. Chapter 7 covers measurement in the XP formalism. Measurement of
diagonal Pauli operators can be efficiently simulated on any XP code, and we
present an efficient stabiliser method for calculating the outcome
probabilities and updated XP code. We then consider extending the algorithm to
precision 4 operators. We show that finding the outcome probabilities when
measuring collections of diagonal precision 4 diagonal operators is NP-
complete. We also give examples where the measurement of precision 4 operators
cannot be done within the XP formalism.

Finally in Chapter 8, we summarise what is known about the XP formalism,
discuss implications, and lay out possible future research directions.

###  2.5 XPF Software Package

We have produced a Python software package implementing all algorithms
discussed in this paper. The Github repository is made available subject to
GPL licensing. Interactive Jupyter notebooks for all examples in this paper
are included and can be modified to run different scenarios.

##  3 Algebra of XP Operators

In this section, we lay out fundamental results for the algebra of XP
operators, including closed form expressions for algebraic operations which
support efficient simulation on a classical computer. We show how to write a
unique vector representation for XP operators. We generalise the symplectic
product of the Pauli stabiliser formalism and show how to express algebraic
operations in terms of the vector representation and the generalised
symplectic product. We also introduce the concepts of the degree and
fundamental phase of XP operators. These concepts allow us to determine the
eigenvalues and actions of the projectors of XP operators.

###  3.1 Vector Representation of XP Operators

In this section, we show that there is a natural identification of XP
operators on $n$ qubits with vectors of integers. Let
$\mathbf{u}=(p|\mathbf{x}|\mathbf{z})\in\mathbb{Z}\times\mathbb{Z}^{n}\times\mathbb{Z}^{n}$
be an integer vector of length $2n+1$. Define the XP operator of precision $N$
corresponding to $\mathbf{u}$ as:

$\displaystyle XP_{N}(\mathbf{u})$ $\displaystyle:=\omega^{p}\bigotimes_{0\leq
i<n}X^{\mathbf{x}[i]}P^{\mathbf{z}[i]}$ (4)

where $\omega$ and $P$ are as defined in Eqs. (1) and (2). Each component is
periodic in that we can write:

$\displaystyle XP_{N}(p|\mathbf{x}|\mathbf{z})$
$\displaystyle=XP_{N}(p\operatorname{mod}2N|\mathbf{x}\operatorname{mod}2|\mathbf{z}\operatorname{mod}N)$
(5)

Accordingly, we can write a unique vector representation
$(p|\mathbf{x}|\mathbf{z})\in\mathbb{Z}_{2N}\times\mathbb{Z}_{2}^{n}\times\mathbb{Z}_{N}^{n}$
for each XP operator. We call $p$ the phase component, $\mathbf{x}$ the X
component and $\mathbf{z}$ the Z component.

Here we list some properties of this notation:

  1. 1.

The identity XP operator is $XP_{N}(0|\mathbf{0}|\mathbf{0})$ where
$\mathbf{0}$ is the length $n$ vector with all entries $0$.

  2. 2.

Because $\omega^{N}=-1$, we have $XP_{N}(N|\mathbf{0}|\mathbf{0})=-I$.

  3. 3.

The single qubit X operator is $XP_{N}(0|1|0)$.

  4. 4.

Diagonal operators are of form $XP_{N}(p|\mathbf{0}|\mathbf{z})$, i.e. the $X$
component is the zero vector.

  5. 5.

If $N$ is even, the single qubit $Z$ operator is $XP_{N}(0|0|\frac{N}{2})$.
For $N$ odd, $Z$ operators cannot be represented as XP operators. Note that
one may rescale the code to be of precision $2N$ by doubling the phase and Z
components of stabiliser generators, in which case the rescaled code has the
same codespace and accommodates $Z$ operators.

######  Example 3.1 (Using XP operator notation)

Consider the following example of an XP operator:

$\displaystyle A=XP_{8}(12|1110000|0040000)\,.$ (6)

The precision is specified by the subscript $8$, in this case $N=8$. This
means that $\omega=\exp(\frac{1}{16}2\pi i)$ and $P^{8}=I$ so $P=T$ where $T$
is the operator $\text{diag}(1,\sqrt{i})$. In other words, this is an XT
operator. Most of the examples we consider in this paper are precision $N=8$
codes.

The components of $A$ are as follows. The phase component is a value
$p\in\mathbb{Z}_{16}$. In this case $p=12$ means the overall phase of the
operator is $\omega^{12}=\exp(\frac{12}{16}2\pi i)=\exp(\frac{3}{4}2\pi
i)=-i$. The X component is a binary vector of length $n$ so that
$\mathbf{x}\in\mathbb{Z}_{2}^{n}$. In this case, $\mathbf{x}=1110000$,
representing $X_{1}X_{2}X_{3}$, where $X_{i}$ represents the operator which
applies $X$ to the $i$th qubit and $I$ elsewhere. The Z component is a value
$\mathbf{z}\in\mathbb{Z}_{8}^{n}$. In this case $\mathbf{z}=0040000$
representing $T_{3}^{4}$.

In terms of $X$ and $T$ operators, we can write:

$\displaystyle XP_{8}(12|1110000|0040000)$
$\displaystyle=\exp(\frac{12}{16}2\pi i)X_{1}X_{2}X_{3}T_{3}^{4}$ (7)
$\displaystyle=-iX_{1}X_{2}X_{3}Z_{3}$ (8)

As the phase and Z components are divisible by 4, we can rescale $A$ and write
it as a precision 2 operator by dividing the phase and Z components by 4:

$\displaystyle XP_{8}(12|1110000|0040000)$
$\displaystyle=XP_{2}(3|1110000|0010000)$ (9)

###  3.2 Multiplication Rule and Generalised Symplectic Product

In the Pauli stabiliser formalism, we represent operators as binary vectors
and understand commutation relations in terms of the symplectic product. In
this section, we generalise the symplectic product to the XP formalism, and
this allows us to write a simple rule for multiplying XP operators.

Let $\mathbf{z}\in\mathbb{Z}^{n}$ be an integer vector of length $n$ with
$i$th component denoted $\mathbf{z}[i]$. The antisymmetric operator of
precision $N$ corresponding to $\mathbf{z}$ is:

$\displaystyle D_{N}(\mathbf{z})$
$\displaystyle:=XP_{N}(\sum_{i}\mathbf{z}[i]|\mathbf{0}|{-}\mathbf{z})\,.$
(10)

In this paper, arithmetic operations on vectors are component-wise in
$\mathbb{Z}$ i.e.:

$\displaystyle(\mathbf{a}+\mathbf{b})[i]$
$\displaystyle:=\mathbf{a}[i]+\mathbf{b}[i]$ (11)
$\displaystyle(\mathbf{a}\mathbf{b})[i]$
$\displaystyle:=\mathbf{a}[i]\mathbf{b}[i]\,.$ (12)

We can then express the multiplication of two XP operators as the sum of their
vector representations, adjusted by an antisymmetric operator:

######  Proposition 3.1 (Multiplication of XP Operators)

The product of two XP operators given in vector format is:

$\displaystyle
XP_{N}(\mathbf{u_{1}})XP_{N}(\mathbf{u_{2}})=XP_{N}(\mathbf{u_{1}}+\mathbf{u_{2}})D_{N}(2\mathbf{x_{2}}\mathbf{z_{1}})$
(13)

###### Proof.

For $n=1$, looking at matrix representations of $X$ and $P$ we see that:

$\displaystyle PX=\omega^{2}XP^{-1}=(XP)(\omega^{2}P^{-2})=(XP)D_{N}(2)$ (14)

From this, we can show that the multiplication rule applies for all single
qubit XP operators in $\langle\omega I,X,P\rangle$ and in turn to the tensor
products of such operators. ∎

######  Example 3.2 (Multiplication of XP Operators)

Let $N=4,n=3$ so that unique vector representations of XP operators are
$XP_{N}(p|\mathbf{x}|\mathbf{z})$ where
$(p|\mathbf{x}|\mathbf{z})\in\mathbb{Z}_{8}\times\mathbb{Z}_{2}^{3}\times\mathbb{Z}_{4}^{3}$.
Consider two example XP operators $A_{1}$ and $A_{2}$ defined as

$\displaystyle A_{1}$ $\displaystyle=XP_{4}(2|111|330)\,,\quad\text{with}\
\mathbf{u}_{1}=(2|111|330)\,,$ $\displaystyle A_{2}$
$\displaystyle=XP_{4}(6|010|020)\,,\quad\text{with}\
\mathbf{u}_{2}=(6|010|020)\,.$

Then

$A_{1}A_{2}=XP_{4}(\mathbf{u}_{1}+\mathbf{u}_{2})D_{N}(2\mathbf{x}_{2}\mathbf{z}_{1})=XP_{4}(6|101|330)\,.$
(15)

This example is worked out in detail in the linked Jupyter notebook. You can
also explore how multiplication works for random XP operators of arbitrary
precision and length.

###  3.3 Other Algebraic Identities

We can write simple closed form identities for various algebraic operations in
terms of antisymmetric operators, and these are summarised in Table 4. These
identities allow us to efficiently implement algebraic operations in the XPF
software package.

Name | Rule
---|---
MUL | Multiplication of two XP operators
|
$XP_{N}(\mathbf{u_{1}})XP_{N}(\mathbf{u_{2}})=XP_{N}(\mathbf{u_{1}}+\mathbf{u_{2}})D_{N}(2\mathbf{x_{2}}\mathbf{z_{1}})$
SQ | Square of an XP operator
| $A^{2}=XP_{N}(2p|0|2\mathbf{z})D_{N}(2\mathbf{x}\mathbf{z})$
POW | XP operator raised to a power
|
$A^{m}=XP_{N}(mp|a\mathbf{x}|m\mathbf{z})D_{N}((m-a)\mathbf{x}\mathbf{z}),\text{
where }a=m\operatorname{mod}2$
INV | Inverse of an XP operator
| $A^{-1}=XP_{N}(-p|\mathbf{x}|-\mathbf{z})D_{N}(-2\mathbf{x}\mathbf{z})$
CONJ | Conjugation of XP operators
|
$A_{1}A_{2}A_{1}^{-1}=A_{2}D_{N}(2\mathbf{x_{1}}\mathbf{z_{2}}+2\mathbf{x_{2}}\mathbf{z_{1}}-4\mathbf{x_{1}}\mathbf{x_{2}}\mathbf{z_{1}})$
COMM | Commutator of XP operators
|
$A_{1}A_{2}A_{1}^{-1}A_{2}^{-1}=D_{N}(2\mathbf{x_{1}}\mathbf{z_{2}}-2\mathbf{x_{2}}\mathbf{z_{1}}+4\mathbf{x_{1}}\mathbf{x_{2}}\mathbf{z_{1}}-4\mathbf{x_{1}}\mathbf{x_{2}}\mathbf{z_{2}})$
OP | Action of an XP operator on a computational basis vector
|
$XP_{N}(p|\mathbf{x}|\mathbf{z})|\mathbf{e}\rangle=\omega^{p+2\mathbf{e}\cdot\mathbf{z}}|\mathbf{e}\oplus\mathbf{x}\rangle$
Table 4: Algebraic Identities for XP Operators

######  Example 3.3 (Algebraic Identities)

The following are some consequences of algebraic identities in Table 4:

  1. 1.

The MUL and INV rules imply that products and inverses of diagonal operators
are diagonal.

  2. 2.

The SQ and COMM rules imply that squares and commutators of XP operators $A,B$
are always diagonal.

  3. 3.

The CONJ rule implies that conjugating an operator $A$ by an operator $B$
results in $A$ times a diagonal operator.

###  3.4 Group Structure of XP Operators

Because we have rules for products and inverses of XP operators, the XP
operators of precision $N$ on $n$ qubits form a group, denoted
$\mathcal{XP}_{N,n}$.

For any set of XP operators $\mathbf{G}$, we can determine the group generated
by the operators which we denote $\mathcal{G}=\langle\mathbf{G}\rangle$. The
subset of diagonal XP operators $\mathcal{G}_{Z}$ forms an Abelian subgroup.
This is because diagonal operators commute and $\mathcal{G}_{Z}$ is closed
under multiplication (and so includes all inverses and the identity operator).

There is a natural group homomorphism Zp between $\mathcal{G}_{Z}$ over
multiplication and $\mathbb{Z}_{2N}^{n+1}$ over addition modulo $2N$. For
diagonal operators, the action of Zp is:

$\displaystyle\text{Zp}(XP_{N}(p|\mathbf{0}|\mathbf{z}))=(2\mathbf{z}|p)\operatorname{mod}2N$
(16)

The Zp map is well defined and is a group homomorphism because:

$\displaystyle A_{1}A_{2}$
$\displaystyle=XP_{N}((p_{1}+p_{2})\operatorname{mod}2N|\mathbf{0}|(\mathbf{z}_{1}+\mathbf{z}_{2})\operatorname{mod}N)$
(17)

and so:

$\displaystyle\text{Zp}(A_{1}A_{2})$
$\displaystyle=(2(\mathbf{z}_{1}+\mathbf{z}_{2})\operatorname{mod}2N|(p_{1}+p_{2})\operatorname{mod}2N)$
(18) $\displaystyle=(\text{Zp}(A_{1})+\text{Zp}(A_{2}))\operatorname{mod}2N$
(19)

The inverse map
$\text{Zp}^{-1}(\mathbf{z}|p)=XP_{N}(p|\mathbf{0}|\mathbf{z}/2)$ is well
defined providing each component of $\mathbf{z}$ is divisible by $2$ in
$\mathbb{Z}_{2N}$ (even Z components). Addition over $\mathbb{Z}_{2N}^{n+1}$
takes vectors with even Z components to vectors with even Z components. Hence,
we can find the generators of $\mathcal{G}_{Z}$ by finding a set of vectors
$B\subset\mathbb{Z}_{2N}^{n+1}$ which span $\text{Zp}(\mathcal{G}_{Z})$. Using
the Howell matrix form of Appendix A, we set
$B=\text{How}_{\mathbb{Z}_{N}}(\text{Zp}(\mathcal{G}))$. The set
$\text{Zp}^{-1}(B)$ generates $\mathcal{G}_{Z}$. This method is used to
determine a unique set of canonical generators for an XP group (see Section
4.1).

###  3.5 Eigenvalues and Projectors of XP Operators

Identifying the eigenvalues and eigenvectors of XP operators will be important
when considering measurements. We first show how to determine the action of an
XP operator on computational basis elements. The degree and fundamental phase
of an XP operator, defined in this section, allow us to determine the
eigenvalues of XP operators efficiently. These results are used in the
chapters on identifying the codespace and measurements in the XP formalism
(Chapters 4, 7).

The action of an XP operator on a computational basis element
$|\mathbf{e}\rangle$ of $\mathcal{H}_{2}^{n}$ where
$\mathbf{e}\in\mathbb{Z}_{2}^{n}$ is:

$\displaystyle
XP_{N}(p|\mathbf{x}|\mathbf{z})|\mathbf{e}\rangle=XP_{N}(p|\mathbf{x}|\mathbf{z})XP_{N}(0|\mathbf{e}|\mathbf{0})|\mathbf{0}\rangle=\omega^{p+2\mathbf{e}\cdot\mathbf{z}}|\mathbf{e}\oplus\mathbf{x}\rangle$
(20)

When calculating the action on computational basis elements, we apply the
diagonal part of the operator first, then the X component. The notation
$\mathbf{e}\cdot\mathbf{z}=\sum_{i}\mathbf{e}[i]\mathbf{z}[i]$ is the usual
dot product for vectors in $\mathbb{Z}$. The notation
$\mathbf{e}\oplus\mathbf{x}=(\mathbf{e}+\mathbf{x})\operatorname{mod}2$
denotes component-wise addition modulo 2 which is equivalent to XOR for binary
vectors $\mathbf{e}$ and $\mathbf{x}$.

For a given XP operator $A,A^{2N}=I$ so there must be a minimal
$\deg(A)\in\mathbb{Z}_{2N}$ such that for some $q\in\mathbb{Z}_{2N}$:

$\displaystyle A^{\deg(A)}=\omega^{q}I$ (21)

We call $\deg(A)$ the degree of $A$ and $q$ the fundamental phase of $A$. The
degree can be calculated efficiently via the method below:

######  Proposition 3.2 (Calculating Degree of Operator)

We calculate the degree of XP operator $A=XP_{N}(p|\mathbf{x}|\mathbf{z})$ as
follows:

  1. 1.

If $A$ is diagonal:
$\deg(A)=\operatorname{LCM}\\{N/\operatorname{GCD}(N,\mathbf{z}[i]):0\leq
i<n\\}$

  2. 2.

If $A$ is non-diagonal: $\deg(A)=2\deg(A^{2})$, noting that $A^{2}$ is
diagonal.

###### Proof.

To show 1, note that where $A$ is diagonal,
$A^{m}=XP_{N}(mp|\mathbf{0}|m\mathbf{z})$. We need to solve for
$m\mathbf{z}=\mathbf{0}\operatorname{mod}N$. To show 2, note that odd powers
of $A$ are non-diagonal, so the degree must be even. Apply 1 to $A^{2}$ which
is diagonal. ∎

Once we have the degree of an operator, the fundamental phase is the phase
component of $A^{\deg(A)}$. Determining the fundamental phase and degree of an
XP operator allows us to identify its eigenvalues, as follows:

######  Proposition 3.3 (Eigenvalues of Operator)

If $A$ has degree $d$ and fundamental phase $q$, the only possible eigenvalues
of $A$ are $\omega^{m}:m=(q+2Nj)/d$ for $j\in[0\ldots d-1]$.

###### Proof.

Let $|\psi\rangle$ be an eigenvector with
$A|\psi\rangle=\omega^{p}|\psi\rangle$. By the definition of degree and
fundamental phase, $A^{d}=\omega^{q}I$ so
$A^{d}|\psi\rangle=\omega^{dp}|\psi\rangle=\omega^{q}|\psi\rangle$. Hence
$dp=q\operatorname{mod}2N$ and the result follows. ∎

The following proposition allows us to calculate the action of projectors of
XP operators on a computational basis element:

######  Proposition 3.4 (Action of XP Projectors on computational basis
elements)

Consider the projectors $A_{\lambda}$ of $A$ onto the $\lambda$-eigenspace of
$A$. If $A$ is diagonal, the action of $A_{\lambda}$ on the basis element
$|\mathbf{e}\rangle$ is:

$\displaystyle A_{\lambda}|\mathbf{e}\rangle$
$\displaystyle=\begin{cases}|\mathbf{e}\rangle:\text{ if
}A|\mathbf{e}\rangle=\lambda|\mathbf{e}\rangle\\\ 0:\text{ if
}A|\mathbf{e}\rangle\neq\lambda|\mathbf{e}\rangle\end{cases}$ (22)

If $A$ is non-diagonal, the action of $A_{\lambda}$ is:

$\displaystyle A_{\lambda}|\mathbf{e}\rangle$
$\displaystyle=\begin{cases}\frac{1}{2}(I+\lambda^{-1}A)|\mathbf{e}\rangle:\text{
if }A^{2}|\mathbf{e}\rangle=\lambda^{2}|\mathbf{e}\rangle\\\ 0:\text{ if
}A^{2}|\mathbf{e}\rangle\neq\lambda^{2}|\mathbf{e}\rangle\end{cases}$ (23)

###### Proof.

To verify Eq. (23), note that where
$A^{2}|\mathbf{e}\rangle=\lambda^{2}|\mathbf{e}\rangle$:

$A\Big{(}\frac{1}{2}(I+\lambda^{-1}A)|\mathbf{e}\rangle\Big{)}=\frac{1}{2}(A+\lambda^{-1}A^{2})|\mathbf{e}\rangle=\frac{1}{2}(A+\lambda^{-1}\lambda^{2}I)|\mathbf{e}\rangle=\lambda\Big{(}\frac{1}{2}(I+\lambda^{-1}A)|\mathbf{e}\rangle\Big{)}\,.$
(24)

∎

##  4 Calculating Codewords from Stabiliser Generators

In this section, we show how to identify the codespace stabilised by a given
set of XP operators. In the Pauli stabiliser formalism, there is a very simple
relationship between the number of stabiliser generators and the dimension of
the codespace the stabiliser group defines. Given a stabiliser group on $n$
qubits with $k$ independent commuting generators, the codespace has dimension
$2^{(n-k)}$.

In the XP formalism, this relationship is much more complex. For example, the
eigenspace dimensions of XP operators vary widely and are not in general
powers of 2. As an illustration of this complexity, the $+1$ eigenspace
dimensions which arise for various 7-qubit diagonal XP operators of precision
8 are listed in Table 5. Readers can explore eigenspaces of diagonal XP
operators in the linked Jupyter notebook.

$\begin{array}[]{|l r||l r||l
r|}\hline\cr\textbf{Operator}&\textbf{Dim}&\textbf{Operator}&\textbf{Dim}&\textbf{Operator}&\textbf{Dim}\\\
\hline\cr\hline\cr
XP_{8}(0|\mathbf{0}|3333333)&1&XP_{8}(0|\mathbf{0}|1333355)&15&XP_{8}(0|\mathbf{0}|2222266)&28\\\
XP_{8}(0|\mathbf{0}|2555555)&2&XP_{8}(0|\mathbf{0}|6133555)&16&XP_{8}(0|\mathbf{0}|6111177)&30\\\
XP_{8}(0|\mathbf{0}|0133333)&4&XP_{8}(0|\mathbf{0}|1173335)&17&XP_{8}(0|\mathbf{0}|4222666)&32\\\
XP_{8}(0|\mathbf{0}|2355555)&6&XP_{8}(0|\mathbf{0}|6111735)&18&XP_{8}(0|\mathbf{0}|3333555)&35\\\
XP_{8}(0|\mathbf{0}|3333335)&7&XP_{8}(0|\mathbf{0}|1173355)&19&XP_{8}(0|\mathbf{0}|2222666)&36\\\
XP_{8}(0|\mathbf{0}|2223555)&8&XP_{8}(0|\mathbf{0}|6135555)&20&XP_{8}(0|\mathbf{0}|0333555)&40\\\
XP_{8}(0|\mathbf{0}|6133335)&10&XP_{8}(0|\mathbf{0}|3333355)&21&XP_{8}(0|\mathbf{0}|0003355)&48\\\
XP_{8}(0|\mathbf{0}|6133355)&12&XP_{8}(0|\mathbf{0}|6155555)&22&XP_{8}(0|\mathbf{0}|4444444)&64\\\
XP_{8}(0|\mathbf{0}|1733333)&13&XP_{8}(0|\mathbf{0}|2661117)&24&XP_{8}(0|\mathbf{0}|0000000)&128\\\
XP_{8}(0|\mathbf{0}|6113555)&14&XP_{8}(0|\mathbf{0}|6111117)&26&&\\\
\hline\cr\end{array}$ Table 5: Example: Eigenspace dimensions for selected
diagonal XP operators with $n=7$, $N=8$.

Here we present an algorithm to identify the codespace of a set of $XP$
operators. The input for our algorithm is an arbitrary list of XP operators
$\mathbf{G}\subset\mathcal{XP}_{N,n}$. The output is a list of codewords
$\\{|\kappa_{i}\rangle:0\leq i<\dim(\mathcal{C})\\}$ that form a basis for the
codespace $\mathcal{C}$ stabilised by the group
$\mathcal{G}=\langle\mathbf{G}\rangle$, or an empty set if there is no
codespace. The algorithm operates in two steps:

  1. 1.

Convert the set of XP operators into a canonical form. This is a set of
generators $\mathbf{S}$ in a particular form which generate the stabiliser
group $\langle\mathbf{S}\rangle=\langle\mathbf{G}\rangle$. We split the
canonical generators into diagonal $\mathbf{S}_{Z}$ and non-diagonal
generators $\mathbf{S}_{X}$, where the diagonal canonical generators
$\mathbf{S}_{Z}$ generate the diagonal subgroup of the stabiliser group.

  2. 2.

Calculate an independent set of codewords $|\kappa_{i}\rangle$ that span the
codespace. We do this by applying the orbit operator (defined below in terms
of the $\mathbf{S}_{X}$) to particular computational basis elements
$|\mathbf{m}_{i}\rangle$ in the simultaneous $+1$ eigenspace of the
$\mathbf{S}_{Z}$.

We will describe these steps in detail in the following sections.

###  4.1 Canonical Generators of XP Groups

For any set of XP operators $\mathbf{G}$, we can calculate a set of operators
in canonical form that generate the same XP group as $\mathbf{G}$.
Specifically, we calculate an independent set of diagonal ($\mathbf{S}_{Z}$)
and non-diagonal ($\mathbf{S}_{X}$) operators that generate
$\langle\mathbf{G}\rangle$. The diagonal subgroup of
$\langle\mathbf{G}\rangle$ is generated by $\mathbf{S}_{Z}$.

Proposition 4.1 sets out the form and properties of the canonical generators.
The proposition uses the concept of a generator product which is defined as
follows. The generator product of an ordered set of XP operators
$\mathbf{S}=\\{S_{0},\dots,S_{m-1}\\}$ specified by a vector of integers
$\mathbf{a}\in\mathbb{Z}^{m}$ is:

$\displaystyle\mathbf{S}^{\mathbf{a}}=\prod_{0\leq i<m}S_{i}^{\mathbf{a}[i]}$
(25)

######  Proposition 4.1 (Canonical Generators of an XP Group)

For any set of XP Operators $\mathbf{G}=\\{G_{i}:0\leq i<m\\}$, there exists a
unique set of diagonal operators $\mathbf{S}_{Z}:=\\{B_{j}:0\leq j<s\\}$ and
non-diagonal operators $\mathbf{S}_{X}:=\\{A_{i}:0\leq i<r\\}$ with the
following form:

  1. 1.

Let $S_{X}$ be the $r\times n$ binary matrix formed from the X-components of
the $\mathbf{S}_{X}$. The matrix $S_{X}$ is in Reduced Row Echelon Form
(RREF).

  2. 2.

Let $S_{Zp}$ be the $s\times(n+1)$ matrix with rows taken from the image of
$\mathbf{S}_{Z}$ under the Zp map of Section 3.4 (i.e.
$\text{Zp}(XP_{N}(p|\mathbf{0}|\mathbf{z}))=(2\mathbf{z}|p)$). The matrix
$S_{Zp}$ is in Howell Form (see Appendix A).

  3. 3.

For $XP_{N}(p|\mathbf{x}|\mathbf{z})\in\mathbf{S}_{X}$, the matrix
$\begin{pmatrix}1&(2\mathbf{z}|p)\\\ \mathbf{0}&S_{Zp}\end{pmatrix}$ is in
Howell Form.

The following properties hold for the canonical generators:

##### Property 1:

All group elements $G\in\langle\mathbf{G}\rangle$ can be expressed as
$G=\mathbf{S}_{X}^{\mathbf{a}}\mathbf{S}_{Z}^{\mathbf{b}}$ where
$\mathbf{a}\in\mathbb{Z}_{2}^{|\mathbf{S}_{X}|}$,
$\mathbf{b}\in\mathbb{Z}_{N}^{|\mathbf{S}_{Z}|}$

##### Property 2:

Two sets of XP operators of precision $N$ generate the same group if and only
if they have the same canonical generators.

Conditions 1-3 ensure the canonical generators are unique for a given set of
operators, and so can form the basis of the test in Property 2. The entries of
$S_{Zp}$ are from $\mathbb{Z}_{2N}$ which is in general a ring. The Howell
matrix form is a generalisation of the RREF which gives us a canonical basis
for the row span of a matrix over a ring. See Appendix A for a full
description of the Howell matrix form and linear algebra over rings.

We briefly consider the implications of Properties 1 and 2. Let
$\langle\mathbf{G}\rangle$ be an XP stabiliser group. If there is an operator
of form $\omega^{q}I,q\neq 0$ in $\langle\mathbf{G}\rangle$, the codespace is
empty. Due to the Howell Property (see Section A.2), we can determine if this
is the case by checking if $\omega^{q}I\in\mathbf{S}_{Z}$ for some $q\neq 0$.
This is a generalisation of the requirement that
$-I\notin\langle\mathbf{G}\rangle$ in the Pauli stabiliser formalism and the
concept of admissible generating sets in the XS stabiliser formalism (see Ref.
[18] on page 7). Going forward, we assume that XP codes are specified in terms
of their canonical generators $\mathbf{S}_{Z},\mathbf{S}_{X}$ and that there
is no element $\omega^{q}I,q\neq 0$ in $\mathbf{S}_{Z}$.

Because the matrices $S_{X},S_{Zp}$ are in echelon form, this imposes a
natural ordering on $\mathbf{S}_{X},\mathbf{S}_{Z}$. Property 1 states that we
can write any $G\in\langle\mathbf{G}\rangle$ as a product of the canonical
generators where operators are applied in this order. It implies that
$\mathbf{S}_{Z}$ generates the diagonal subgroup of $\langle\mathbf{G}\rangle$
because the diagonal subgroup is the set of operators where
$\mathbf{a}=\mathbf{0}$. Recalling Example 3.3, all commutators and squares of
elements in $\langle\mathbf{G}\rangle$ are diagonal and so are in
$\langle\mathbf{S}_{Z}\rangle$. Applying the results in Section 3 of Ref.
[15], we can also determine the size of the group $\langle\mathbf{G}\rangle$
once we have the canonical generator form.

In Appendix B, we demonstrate an algorithm for calculating the canonical
generators and prove Proposition 4.1.

###  4.2 Finding a Basis of the Codespace

In this section, we will show how to find a basis of the codespace stabilised
by the canonical generators $\mathbf{S}_{Z},\mathbf{S}_{X}$ of Section 4.1.
The result is a set of independent codewords that span the codespace.

The codespace is the intersection of the simultaneous $+1$ eigenspace of the
diagonal generators and the $+1$ eigenspace of the non-diagonal generators:

$\displaystyle\mathcal{C}=\mathcal{C}_{Z}\cap\mathcal{C}_{X}$ (26)

The diagonal generators determine the Z-support of the codewords. We define
the Z-support of a state $|\psi\rangle$ in $\mathcal{H}_{2}^{n}$ as the set of
length $n$ binary vectors $\mathbf{e}$ such that the coefficient of the
corresponding computational basis vector $|\mathbf{e}\rangle$ in
$|\psi\rangle$ is non-zero. That is:

$\displaystyle\operatorname{ZSupp}(|\psi\rangle)$
$\displaystyle=\\{\mathbf{e}\in\mathbb{Z}_{2}^{n}:\langle\mathbf{e}|\psi\rangle\neq
0\\}$ (27)

Because all elements in $\mathbf{S}_{Z}$ are diagonal, we can write a basis of
$\mathcal{C}_{Z}$ as a set of computational basis vectors:

$\displaystyle\mathcal{C}_{Z}$
$\displaystyle=\operatorname{Span}_{\mathbb{C}}\\{|\mathbf{e}\rangle:\mathbf{e}\in\mathbb{Z}_{2}^{n},B|\mathbf{e}\rangle=|\mathbf{e}\rangle,\forall
B\in\mathbf{S}_{Z}\\}$ (28)

Let $E:=\operatorname{ZSupp}(\mathcal{C}_{Z})$ be the binary vectors
corresponding to the computational basis vectors in $\mathcal{C}_{Z}$. Any
codeword expressed in terms of the computational basis must be a linear
combination over $\mathbb{C}$ of $|\mathbf{e}\rangle,\mathbf{e}\in E$.

The non-diagonal generators determine the relative phases of the computational
basis vectors in the codewords. The relative phase information is captured by
the orbit operator. Let $\mathbf{S}_{X}$ be the non-diagonal canonical
generators $\\{A_{i}:0\leq i<r\\}$ ordered as in Section 4.1. Using the
generator product notation of Eq. (25), the orbit operator is defined as:

$\displaystyle
O_{\mathbf{S}_{X}}:=\sum_{\mathbf{v}\in\mathbb{Z}_{2}^{r}}\mathbf{S}_{X}^{\mathbf{v}}$
(29)

Where $\mathbf{e}\in E$, the image of $|\mathbf{e}\rangle$ under the orbit
operator, $O_{\mathbf{S}_{X}}|\mathbf{e}\rangle$, is fixed by all elements of
the stabiliser group $\langle\mathbf{S}_{Z},\mathbf{S}_{X}\rangle$ (see
Proposition C.1). In the next section, we demonstrate how to find an
independent set of codewords of this form which span the codespace.

####  4.2.1 Coset Structure of $E$ and Orbit Representatives

In this section, we assume we are given $E$, the Z-support of
$\mathcal{C}_{Z}$ as in Eq. (28), and show how to identify a subset $E_{m}$ of
$E$ such that the image of $E_{m}$ under the orbit operator is a basis of the
codespace (i.e. an independent spanning set). The resulting basis is a set of
un-normalised codewords $|\kappa_{i}\rangle$ such that:

$\displaystyle|\kappa_{i}\rangle$
$\displaystyle:=O_{\mathbf{S}_{X}}|\mathbf{m}_{i}\rangle:\mathbf{m}_{i}\in
E_{m}$ (30)

The normalisation constant is $\frac{1}{\sqrt{2^{r}}}$ where $r$ is the number
of non-diagonal canonical generators, and is omitted for clarity. Once we have
$E_{m}$, we know the dimension of the codespace:

$\displaystyle\dim(\mathcal{C})$ $\displaystyle=|E_{m}|$ (31)

We identify the subset $E_{m}$ by looking at the coset structure of $E$.
First, we show that the Z-support of a codeword in the form of Eq. (30) can be
viewed as a coset in the group $\mathbb{Z}_{2}^{n}$ under component-wise
addition modulo 2. Let $S_{X}$ be the binary matrix formed from the
X-components of the $\mathbf{S}_{X}$ which is in RREF by construction (See
Proposition 4.1). Then $\text{Span}_{\mathbf{Z}_{2}}(S_{X})=\langle
S_{X}\rangle$ is a subgroup of $\mathbb{Z}_{2}^{n}$ of size $2^{r}$ where
$r=|S_{X}|$. The Z-support of $O_{\mathbf{S}_{X}}|\mathbf{e}\rangle$ can be
identified with a coset in the group of binary vectors $\mathbb{Z}_{2}^{n}$:

$\displaystyle\operatorname{ZSupp}(O_{\mathbf{S}_{X}}|\mathbf{e}\rangle)=\mathbf{e}+\langle
S_{X}\rangle:=\\{(\mathbf{e}+\mathbf{u}S_{X})\operatorname{mod}2:\mathbf{u}\in\mathbb{Z}_{2}^{r}\\}$
(32)

Next, we introduce the residue function which tells us whether two vectors are
in the same coset, and hence occur in the Z-support of the same codeword. Let
$\mathbf{m}=\text{Res}_{\mathbb{Z}_{2}}(S_{X},\mathbf{e})$ be defined as:

$\displaystyle\begin{pmatrix}1&\mathbf{m}\\\
\mathbf{0}&S_{X}\end{pmatrix}:=\text{RREF}_{\mathbb{Z}_{2}}\begin{pmatrix}1&\mathbf{e}\\\
\mathbf{0}&S_{X}\end{pmatrix}$ (33)

Two vectors $\mathbf{e}_{1},\mathbf{e}_{2}\in E$ are in the same coset if and
only if
$\text{Res}_{\mathbb{Z}_{2}}(S_{X},\mathbf{e}_{1})=\text{Res}_{\mathbb{Z}_{2}}(S_{X},\mathbf{e}_{2})$.
The residue of $\mathbf{e}$ is zero if and only if $\mathbf{e}\in\langle
S_{X}\rangle$.

We use the residue function to identify a subset of $E$ of minimal size whose
image under the orbit operator yields a basis of the codespace. The set of
orbit representatives $E_{m}$ is defined as the image of $E$ under the residue
function:

$\displaystyle
E_{m}:=\\{\text{Res}_{\mathbb{Z}_{2}}(S_{X},\mathbf{e}):\mathbf{e}\in E\\}$
(34)

The cosets of $E_{m}$ partition $E$ (see Proposition C.3). Accordingly, the
image of $E_{m}$ under the orbit operator is a basis of the codespace (see
Proposition C.4).

####  4.2.2 Codewords Notation

The following notation for codewords is used throughout this paper. Let
$S_{X}$ be the matrix formed from the X-components of the non-diagonal
canonical generators $\mathbf{S}_{X}$. As $S_{X}$ is in echelon form, rows
have a natural ordering and we interchangeably consider $S_{X}$ to be a set of
binary vectors. Let $S_{X}$ have $r$ non-zero rows or $|S_{X}|=r$. The set of
codewords generated from the orbit representatives is uniquely determined.
When written in terms of the computational basis, we refer to the following as
the orbit form of the codewords:

$\displaystyle|\kappa_{i}\rangle$
$\displaystyle=O_{\mathbf{S}_{X}}|\mathbf{m}_{i}\rangle:=\sum_{0\leq
j<2^{r}}\omega^{p_{ij}}|\mathbf{e}_{ij}\rangle:\mathbf{m}_{i}\in E_{m},\exists
p_{ij}\in\mathbb{Z}_{2N},\mathbf{e}_{ij}\in\mathbb{Z}_{2}^{n}$ (35)

The Z-support of the codewords is the same as the Z-support of
$\mathcal{C}_{Z}$, the simultaneous $+1$ eigenspace of the $\mathbf{S}_{Z}$,
and is denoted $E$:

$\displaystyle E$
$\displaystyle=\operatorname{ZSupp}(\mathcal{C}_{Z})=\bigcup_{i}\operatorname{ZSupp}(|\kappa_{i}\rangle)$
(36)

We can write a coset decomposition of $E$ in terms of $E_{m}$ as follows:

$\displaystyle E$ $\displaystyle=E_{m}+\langle
S_{X}\rangle=\\{(\mathbf{m}_{i}+\mathbf{u}S_{X})\operatorname{mod}2:\mathbf{m}_{i}\in
E_{m},\mathbf{u}\in\mathbb{Z}_{2}^{r}\\}$ (37)

There is a direct relationship with the Z-support of each codeword as follows:

$\displaystyle E_{i}$
$\displaystyle:=\operatorname{ZSupp}(|\kappa_{i}\rangle)=\mathbf{m}_{i}+\langle
S_{X}\rangle$ (38)

In addition, there is a unique coset decomposition of $E_{m}$ so that
$E_{m}=E_{q}+\langle L_{X}\rangle$ for sets of binary vectors $E_{q}$ and
$L_{X}$ so that $E=E_{q}+\langle L_{X}\rangle+\langle S_{X}\rangle$. We
demonstrate how to find this decomposition in Section 6.3.2. The full coset
decomposition is useful for the following reasons:

  * •

The X-components of logical operators must be in $\langle L_{X}\rangle+\langle
S_{X}\rangle$, and we can calculate a generating set of non-diagonal logical
operators with X components in $L_{X}$ (Section 6.3.2)

  * •

The size of $E_{q}$ gives rise to a natural classification of XP codes
(Section 6.5).

  * •

We assign quantum numbers to each codeword (Section 6.4) based on the coset
decomposition of $E_{m}$ which then allows us to analyse the logical action of
operators (Section 6.7).

###  4.3 Calculating Orbit Representatives from the Canonical Generators

We have demonstrated that the image of the orbit representatives under the
orbit operator is a basis of the codespace, and that the dimension of the
codespace is given by the number of orbit representatives. In previous
sections we have assumed that we have been given $E$, the Z-support of the
simultaneous $+1$ eigenspace of the $\mathbf{S}_{Z}$, as a starting point. In
practice, we generally start with the stabiliser generators of a code, and
calculating $E$ from them is an NP-complete problem for XP codes (see Ref.
[18] Section VII).

In this section, we show how to calculate the orbit representatives from the
canonical generators. Orbit representatives have a specific form which reduces
the search space significantly compared to searching for the whole of $E$. We
use a graph search algorithm to make finding the orbit representatives
tractable for ‘reasonable’ codes.

####  4.3.1 Exhaustive Algorithm to find $E$

We first show how to find $E$ using an exhaustive inefficient algorithm. Let
$\mathbf{S}_{Z}=\\{B_{i}=XP_{N}(p_{i}|\mathbf{0}|\mathbf{z}_{i}):0\leq
i<s\\}$. Calculating the $+1$ eigenspace of $\mathbf{S}_{Z}$ is equivalent to
solving the following equation in binary vectors $\mathbf{e}$:

$\displaystyle
B_{i}|\mathbf{e}\rangle=\omega^{p_{i}+2\mathbf{e}\cdot\mathbf{z}_{i}}|\mathbf{e}\rangle$
$\displaystyle=\omega^{0}|\mathbf{e}\rangle,\forall B_{i}\in\mathbf{S}_{Z}$
(39)

For this equation to have solutions in $\mathbf{e}$, $p_{i}$ must be divisible
by $2$ in $\mathbb{Z}_{2N}$. Let $S_{Zp}$ be the matrix with rows
$(\mathbf{z}_{i}|p_{i}/2)$. Let $(\mathbf{e}|1)$ represent the column vector
$\mathbf{e}$ with an entry of 1 appended. Eq. (39) can be written in matrix
form as:

$\displaystyle S_{Zp}^{T}(\mathbf{e}|1)\operatorname{mod}N$
$\displaystyle=\mathbf{0}\,.$ (40)

Solutions are of form:

$\displaystyle(\mathbf{e}|1)=\mathbf{a}K\operatorname{mod}N\,,$ (41)

where $K$ is the Howell basis of $\operatorname{Ker}_{\mathbb{Z}_{N}}(S_{Zp})$
(see Section A.2). To find solutions for binary vectors $\mathbf{e}$, we seek
$\mathbf{a}\in\mathbb{Z}_{N}^{n}$ such that
$(\mathbf{e}|1)=\mathbf{a}K\operatorname{mod}N$ is a vector of zeros and ones.
Linear algebra techniques cannot be used to find the vectors $\mathbf{a}$. We
would in principle need to search through all possible values of $\mathbf{a}$
to find valid solutions. Given that there are $N^{|K|}$ possible values of
$\mathbf{a}$, this is of exponential complexity.

####  4.3.2 Graph Search Algorithm for Orbit Representatives

Rather than searching through all possible values of $\mathbf{a}$ in Eq. (41)
to find $E$, we employ a more efficient graph search algorithm which uses the
special form of the orbit representatives to speed up the the search.

The special form of the orbit representatives is as follows. Let
$\mathbf{x}_{j}$ be the $j$th row of $\mathbf{S}_{X}$ and let $l_{j}$ be the
leading index of $\mathbf{x}_{j}$ \- i.e. $\mathbf{x}_{j}[l_{j}]=1$ and
$\mathbf{x}_{j}[k]=0,\forall k<l_{j}$. In Proposition C.5, we show that for
any orbit representative $\mathbf{m}_{i}\in E_{m},\mathbf{m}_{i}[l_{j}]=0$ for
all leading indices $l_{j}$, $0\leq j<|S_{X}|$. In each coset of $S_{X}$,
$\mathbf{m}_{i}$ is the unique vector with this property. As $S_{X}$ is in
RREF, there are exactly $r=|S_{X}|$ leading indices $l_{j}$ where
$\mathbf{m}_{i}[l_{j}]$ is guaranteed to be zero.

We modify the exhaustive search algorithm presented in Section 4.3.1 to take
into account the special form of the orbit representatives:

  1. 1.

Find the Howell basis $K$ of $\operatorname{Ker}_{\mathbb{Z}_{N}}(S_{Zp})$

  2. 2.

Search for solutions $(\mathbf{e}|1)=\mathbf{a}K\operatorname{mod}N$ where
$\mathbf{e}$ is a binary vector

  3. 3.

As we only need a orbit representative $\mathbf{m}_{i}$ for each codeword, we
can restrict $\mathbf{e}[l]=0$ where the $l$ are the indices of the leading
entries in $S_{X}$.

The search is made more efficient by storing and re-using partial solutions
(dynamic programming) and results in a graph object from which the solutions
can be generated. The main advantage over the exhaustive algorithm is due to
the reduction of the search space by a factor of $2^{r}$ by using the special
form of the orbit representatives. Where all stabiliser generators are
diagonal and $r=|S_{X}|=0$, the advantage over the exhaustive algorithm is not
as significant. However, for ‘reasonable’ codes which have both diagonal and
non-diagonal generators, and which encode a relatively low number of logical
qubits, the graph search algorithm is efficient in practice.

It is possible that the search algorithm returns an empty set. In this case,
the simultaneous $+1$ eigenspace of the $\mathbf{S}_{Z}$ is empty and there is
no codespace. In this case, the XP stabiliser group does not define a code.

###  4.4 Summary of Codewords Algorithm

In summary, the algorithm for identifying the codespace stabilised by an
arbitrary set of XP operators $\mathbf{G}$ is:

  1. 1.

Calculate the canonical generators $\mathbf{S}_{Z}$ and $\mathbf{S}_{X}$ such
that $\langle\mathbf{G}\rangle=\langle\mathbf{S}_{Z},\mathbf{S}_{X}\rangle$
using the algorithm in Section 4.1. If $\omega^{q}I\in\mathbf{S}_{Z}$ for
$q\neq 0$, the codespace is empty.

  2. 2.

Find the orbit representatives $E_{m}=\\{\mathbf{m}_{i}\\}$ using the graph
search algorithm in Section 4.3.2. The dimension of the codespace is
$\dim(\mathcal{C})=|E_{m}|$. If $E_{m}=\emptyset$, the codespace is empty as
the simultaneous $+1$ eigenspace of the $\mathbf{S}_{Z}$ is of dimension zero.

  3. 3.

A basis of the codespace is given by
$\\{|\kappa_{i}\rangle=O_{\mathbf{S}_{X}}|\mathbf{m}_{i}\rangle:\mathbf{m}_{i}\in
E_{m}\\}$ using the orbit operator of Eq. (29).

###  4.5 Example: Calculating Codewords - Code 1

We illustrate our algorithm to find the codewords with an example. We will use
this same example throughout this paper to illustrate various concepts. The
detailed calculations for this example are set out in the linked Jupyter
notebook. We start with the following stabiliser generators of precision $N=8$
on $n=7$ qubits:

$\displaystyle\mathbf{G}$
$\displaystyle=\begin{matrix}XP_{8}(8|0000000|6554444)\\\
XP_{8}(7|1111111|1241234)\\\ XP_{8}(1|1110000|3134444)\end{matrix}$ (42)

##### Step 1: Canonical Generators

Using the algorithm in Appendix B, the canonical generators for this code are:

$\displaystyle\mathbf{S}_{Z}$
$\displaystyle=\begin{matrix}XP_{8}(8|0000000|2334444)\\\
XP_{8}(0|0000000|0440000)\end{matrix}$ (43) $\displaystyle\mathbf{S}_{X}$
$\displaystyle=\begin{matrix}XP_{8}(9|1110000|1240000)\\\
XP_{8}(14|0001111|0001234)\end{matrix}$ (44)

Note that a single diagonal generator yields multiple diagonal canonical
generators. This behaviour is typical of XP groups.

##### Step 2: Orbit Representatives

The graph search algorithm in Section 4.3.2 yields the following orbit
representatives:

$\displaystyle E_{m}$ $\displaystyle=\begin{pmatrix}0000001\\\ 0000010\\\
0000100\\\ 0000111\\\ \end{pmatrix}$ (45)

The dimension of the codespace is $\dim(\mathcal{C})=|E_{m}|=4$.

##### Step 3: Image of orbit representatives under orbit operator is a basis

Finally, we form an independent set of codewords $\\{\kappa_{i}\\}$ by
applying the orbit operator $O_{\mathbf{S}_{X}}$ of Eq. (29) to the
computational basis elements corresponding to the $E_{m}$:

$\displaystyle\begin{matrix}|\kappa_{0}\rangle&=O_{\mathbf{S}_{X}}|0000001\rangle=|0000001\rangle&+\omega^{6}|0001110\rangle&+\omega^{9}|1110001\rangle&+\omega^{15}|1111110\rangle\\\
|\kappa_{1}\rangle&=O_{\mathbf{S}_{X}}|0000010\rangle=|0000010\rangle&+\omega^{4}|0001101\rangle&+\omega^{9}|1110010\rangle&+\omega^{13}|1111101\rangle\\\
|\kappa_{2}\rangle&=O_{\mathbf{S}_{X}}|0000100\rangle=|0000100\rangle&+\omega^{2}|0001011\rangle&+\omega^{9}|1110100\rangle&+\omega^{11}|1111011\rangle\\\
|\kappa_{3}\rangle&=O_{\mathbf{S}_{X}}|0000111\rangle=|0000111\rangle&+|0001000\rangle&+\omega^{9}|1110111\rangle&+\omega^{9}|1111000\rangle\\\
\end{matrix}$ (46)

###  4.6 Calculating Codewords - Discussion and Summary of Results

Given a set of XP operators $\mathbf{G}$, we can determine a basis for the
codespace stabilised by $\langle\mathbf{G}\rangle$. We first determine a set
of canonical generators using linear algebra techniques over rings (Section
4.1). The method uses the unique vector representation of XP operators of
Section 3.1 and can be done efficiently. This mirrors the result for
generalised Pauli groups in Ref. [11].

Once we have the generators in canonical form, we find the orbit
representatives $E_{m}$ using a graph search algorithm (Section 4.3.2). The
codespace dimension corresponds to the number of orbit representatives, and
applying the orbit operator defined in Eq. (29) to the orbit representatives
results in a basis of the codespace. The graph search algorithm works for any
XP code, but its efficiency depends on the precision of the code and the
number of non-diagonal stabiliser generators. In the worst case, where we have
only diagonal stabilisers, finding the orbit representatives reduces to an NP-
complete problem.

##  5 Classification of XP Stabiliser States

Now that we have some familiarity with the XP stabiliser formalism, it is
natural to ask which quantum states can be represented within the formalism.
In this chapter, we demonstrate an equivalence between XP stabiliser states
and ‘weighted hypergraph states’ - a generalisation of both hypergraph [23]
and weighted graph states [14].

In the Pauli stabiliser formalism, any stabiliser state can be mapped via
local Clifford operators to a graph state [26]. In the XS Formalism [18], the
authors show that the phases of an XS stabiliser state are described by a
phase function which is a polynomial of maximum degree 3. In this chapter, we
generalise these results to the XP formalism.

In Section 5.1, we introduce definitions for weighted hypergraph states. In
Section 5.2, we describe the phases which are possible for XP stabiliser
states. In Section 5.3, we show how to represent any XP stabiliser state as a
weighted hypergraph state. Finally, in Section 5.4 we show how to represent
any weighted hypergraph state as an XP stabiliser state. In general, this
requires us to embed the weighted hypergraph state into a larger Hilbert
space.

###  5.1 Weighted Hypergraph State Definitions

In this section, we introduce the concept of weighted hypergraph states - a
class of states which includes graph, hypergraph and weighted graph states. A
generalised controlled phase operator $CP(p/q,\mathbf{v})$ is specified by a
rational number $p/q$ and a binary vector $\mathbf{v}$ of length $r$. The
action of the operator on a computational basis state
$|\mathbf{e}\rangle,\mathbf{e}\in\mathbb{Z}_{2}^{r}$ is:

$\displaystyle CP(p/q,\mathbf{v})|\mathbf{e}\rangle:=\begin{cases}\exp(i2\pi
p/q)|\mathbf{e}\rangle:\mathbf{e}\mathbf{v}=\mathbf{v}\\\
|\mathbf{e}\rangle:\text{ Otherwise}\end{cases}\,.$ (47)

Multiplication of vectors in the above equation is component wise. We
construct a weighted hypergraph state by applying a series of generalised
controlled phase operators to the $|+\rangle^{\otimes r}$ state.

In the Pauli stabiliser formalism, all stabiliser states can be mapped to
graph states by applying a set of local Clifford unitaries. A graph state on
$r$ vertices is specified by a set of edges $E=\\{(i,j):i<j\in[0\dots
r-1]\\}$. The graph state is formed by applying controlled $Z$ operators
corresponding to the edges to $|+\rangle^{\otimes r}$ i.e.
$|\phi\rangle=(\prod_{(i,j)\in E}CZ_{ij})|+\rangle^{\otimes r}$.

We now show how graph states generalise to weighted hypergraph states. For a
binary vector $\mathbf{v}$, the support of $\mathbf{v}$ defines an edge (i.e.
$\text{supp}(\mathbf{v}):=\\{i\in[0\dots r-1]:\mathbf{v}[i]=1\\}$). Graph
states have edges composed of 2 vertices only so
$\text{wt}(\mathbf{v})=|\text{supp}(\mathbf{v})|=2$. Generalised controlled
phase operators can have edges involving between $1$ and $r$ vertices. The
condition $\mathbf{e}\mathbf{v}=\mathbf{v}$ means that we apply the phase when
$\text{supp}(\mathbf{v})\subset\text{supp}(\mathbf{e})$.

For graph states, only phases of $\pm 1$ are possible as we apply controlled Z
operators. Generalised controlled phase operators, on the other hand, can
apply any phase of form $\exp(i2\pi p/q)$. Where $p/q=1/2$, the operator acts
as a generalised controlled $Z$ operator because it applies a phase of
$\exp(i\pi)=-1$ if $\mathbf{e}\mathbf{v}=\mathbf{v}$.

###  5.2 Phase Functions of XP States

In this section, we describe which relative phases are possible for XP
stabiliser states. The phase function of an XP stabiliser state $|\phi\rangle$
of precision $N$ is an integer valued function $f$ on vectors
$\mathbf{e}\in\operatorname{ZSupp}(|\phi\rangle)$ such that:

$\displaystyle|\phi\rangle:=\sum_{\mathbf{e}\in\operatorname{ZSupp}(|\phi\rangle)}\omega^{f(\mathbf{e})}|\mathbf{e}\rangle=\sum_{\mathbf{e}\in\operatorname{ZSupp}(|\phi\rangle)}\omega^{f(e_{0}\dots
e_{n-1})}|\mathbf{e}\rangle\,.$ (48)

We generally consider $f$ to be a function of the binary variables
$e_{i}:=\mathbf{e}[i],0\leq i<n$. In this chapter, phase functions are defined
by a vector $\mathbf{q}\in\mathbb{Z}^{2^{n}}$ and are polynomials of form:

$\displaystyle f(e_{0}\dots e_{n-1})=\sum_{s\subset[0\dots
n-1]}\mathbf{q}[s]\prod_{j\in s}e_{j}$ (49)

For phase functions of this form, we can identify each term of the polynomial
with a generalised controlled phase operator. The term
$\mathbf{q}[s]\prod_{j\in s}e_{j}$ corresponds to the controlled phase
operator $CP(\mathbf{q}[s]/2N,\mathbf{v})$ where $\mathbf{v}[j]=1$ if $j\in s$
or $0$ otherwise. It is known that for Pauli stabiliser states ($N=2=2^{1})$,
the phase function is a polynomial of the form in Eq. (49) of degree at most
$2$ in the variables $e_{i}$, whilst for XS codes ($N=4=2^{2}$), the maximum
degree is $3$. Our aim is to generalise these results to XP codes.

We first show how to express the Z-support of any XP stabiliser state in terms
of a set of binary variables $\\{u_{i}\\}$, which are a subset of the
$\\{e_{i}\\}$ variables defined above. We will then express the form of the
phase function of an XP stabiliser state in terms of the $\\{u_{i}\\}$. Due to
the results of Section 4.4, any XP stabiliser state can be written in the
following canonical form:

$\displaystyle|\phi\rangle=O_{\mathbf{S}_{X}}|\mathbf{m}\rangle=\sum_{\mathbf{u}\in\mathbb{Z}_{2}^{r}}\mathbf{S}_{X}^{\mathbf{u}}|\mathbf{m}\rangle$
(50)

for non-diagonal canonical generators $\mathbf{S}_{X}$, $r=|\mathbf{S}_{X}|$
and where $\mathbf{m}$ is the single orbit representative. The orbit operator
$O_{\mathbf{S}_{X}}$ is defined in Eq. (29) and the generator product
$\mathbf{S}_{X}^{\mathbf{u}}$ is defined in Eq. (25). Let
$\mathbf{S}_{X}=\\{XP_{N}(p_{i}|\mathbf{x}_{i}|\mathbf{z}_{i}):0\leq i<r\\}$.
We can write $|\phi\rangle$ in terms of the binary variables
$u_{i}:=\mathbf{u}[i],0\leq i<r$ as follows:

$\displaystyle|\phi\rangle=\sum_{u_{i}\in\mathbb{Z}_{2}}\prod_{0\leq
i<r}XP_{N}(u_{i}p_{i}|u_{i}\mathbf{x}_{i}|u_{i}\mathbf{z}_{i})|\mathbf{m}\rangle\,.$
(51)

The sum in the above equation ranges over all possible values of
$u_{i}\in\mathbb{Z}_{2}$, for $0\leq i<r$. The Z-support of $|\phi\rangle$ can
be expressed in terms of the $\\{u_{i}\\}$ as follows:

$\displaystyle\operatorname{ZSupp}(|\phi\rangle)=\\{\mathbf{m}\oplus\bigoplus_{0\leq
i<r}u_{i}\mathbf{x}_{i}:u_{i}\in\mathbb{Z}_{2}\\}\,.$ (52)

We now show that the binary variable $u_{i}$ can be identified with the value
of a particular component $\mathbf{e}[l_{i}]$ of the vectors
$\mathbf{e}\in\operatorname{ZSupp}(|\phi\rangle)$. Let $l_{i}$ be the leading
index of $\mathbf{x}_{i}$ (see 4.3.2). Because $\mathbf{S}_{X}$ is in
canonical form and $\mathbf{m}$ is an orbit representative, we have
$\mathbf{x}_{j}[l_{i}]=\delta_{ij},\mathbf{m}[l_{i}]=0$. Hence for
$\mathbf{e}:=\mathbf{m}\oplus\bigoplus_{0\leq
i<r}u_{i}\mathbf{x}_{i}\in\operatorname{ZSupp}(|\phi\rangle),\mathbf{e}[l_{i}]=u_{i}$.

In the following Proposition, we express the phase function for an XP
stabiliser state in terms of the $\\{u_{i}\\}$ and describe its form:

######  Proposition 5.1 (Phase Functions of XP States)

Let
$|\phi\rangle=O_{\mathbf{S}_{X}}|\mathbf{m}\rangle=\sum_{\mathbf{u}\in\mathbb{Z}_{2}^{r}}\mathbf{S}_{X}^{\mathbf{u}}|\mathbf{m}\rangle$
be an XP stabiliser state in the canonical form of Eq. (50) with
$r:=|\mathbf{S}_{X}|$. Let $u_{i},0\leq i<r$ be binary variables such that
$u_{i}:=\mathbf{u}[i]$. Then:

  1. (a)

The phase function is of the following form for some vector
$\mathbf{q}\in\mathbb{Z}^{2^{r}}$ indexed by the subsets $s$ of $[0\dots
r-1]$:

$\displaystyle f(u_{0},u_{1},\dots,u_{r-1})=\sum_{s\subset[0\dots
r-1]}\mathbf{q}[s]2^{|s|-1}\prod_{j\in s}u_{j}.$ (53)

  2. (b)

For $N=2^{t}$, the maximum degree of the phase function is $t+1$.

Proof of Proposition 5.1 is in Appendix D.

###  5.3 Representation of XP States as Weighted Hypergraph States

We now demonstrate a method for determining the phase function for a given XP
state. This allows us to represent XP stabiliser states as weighted hypergraph
states.

####  5.3.1 Algorithm: Weighted Hypergraph Representation of a Given XP State

##### Input:

An XP state $|\phi\rangle=O_{\mathbf{S}_{X}}|\mathbf{m}\rangle$ of precision
$N$. Let $\mathbf{S}_{X}=\\{XP_{N}(p_{i}|\mathbf{x}_{i}|\mathbf{z}_{i}):0\leq
i<r\\}$.

##### Output:

A set of generalised controlled phase operators
$\\{CP(p_{i}/2N,\mathbf{v}_{i})\\}$ such that
$|\phi\rangle=\Big{(}\prod_{i}CP(p_{i}/2N,\mathbf{v}_{i})\Big{)}\sum_{\mathbf{e}\in\operatorname{ZSupp}(|\phi\rangle)}|\mathbf{e}\rangle$.

##### Method

  1. 1.

Let $l_{i}$ be the leading index of $\mathbf{x}_{i}$ and define the $r\times
n$ binary matrix $L$ by setting $L_{ij}=1$ if $j=l_{i}$ and $0$ otherwise.

  2. 2.

Let $\mathbf{p}$ be a vector whose entries are indexed by rows
$\mathbf{u}\in\mathbb{Z}_{2}^{r}$ such that $\mathbf{p}[\mathbf{u}]$ is the
phase component of $\mathbf{S}_{X}^{\mathbf{u}}|\mathbf{m}\rangle$

  3. 3.

For $\mathbf{u}$ in $\mathbb{Z}_{2}^{r}$, ordered by weight then lexicographic
order:

    1. (a)

If $\mathbf{p}[\mathbf{u}]\neq 0$, add the operator
$CP(\mathbf{p}[\mathbf{u}]/2N,\mathbf{u}L)$ to the list of operators

    2. (b)

For all $\mathbf{v}\in\mathbb{Z}_{2}^{r}$ such that
$\mathbf{v}\mathbf{u}=\mathbf{u}$, set
$\mathbf{p}[\mathbf{v}]=(\mathbf{p}[\mathbf{v}]-\mathbf{p}[\mathbf{u}])\operatorname{mod}2N$

If the precision $N=2^{t}$ is a power of $2$, we only need to consider rows of
weight at most $t+1$ due to Proposition 5.1. By multiplying the $1\times r$
vector $\mathbf{u}$ by the $r\times n$ matrix L in step 3(a), we create a
$1\times n$ vector $\mathbf{v}$ such that $\mathbf{v}[l_{i}]=u_{i}$.

######  Example 5.1 (Weighted Hypergraph Representation of XP State - Union
Jack State)

The following example illustrates the operation of the algorithm to determine
the phase function of an XP stabiliser state and hence the weighted hypergraph
representation. For precision $N=4$, let
$|\phi\rangle=O_{\mathbf{S}_{X}}|\mathbf{m}\rangle$ with:

$\displaystyle\mathbf{m}$ $\displaystyle=\mathbf{0}$ (54)
$\displaystyle\mathbf{S}_{X}$
$\displaystyle=\begin{matrix}XP_{4}(0|1000111000|0112000033)\\\
XP_{4}(0|0100100110|1001003000)\\\ XP_{4}(0|0010010101|1001003000)\\\
XP_{4}(0|0001001011|2110330000)\end{matrix}$ (55)

Calculating the phase component of
$\mathbf{S}_{X}^{\mathbf{u}}|\mathbf{m}\rangle$ for all values of
$\mathbf{u}\in\mathbb{Z}_{2}^{r}$, we find that the phase is zero for all
values of $\mathbf{u}$, apart from $\mathbf{u}=1011$ and $1101$ where the
phase is $-1$. For precision $N=4$, $\omega=\exp(i\pi/4)$ so $\omega^{4}=-1$.
Hence, the phase function of $|\phi\rangle$ is
$f(u_{0},u_{1},u_{2},u_{3})=4u_{0}u_{2}u_{3}+4u_{0}u_{1}u_{3}$. The degree of
$f$ is 3, which is the maximum degree for states of precision $N=4=2^{2}$. We
can write $|\phi\rangle$ as a weighted hypergraph state by applying
$CP(1/2,1011000000)$ and $CP(1/2,1101000000)$ to
$\sum_{\mathbf{e}\in\operatorname{ZSupp}(|\phi\rangle)}|\mathbf{e}\rangle$.

The state $|\phi\rangle$ is the unit cell of the ‘Union Jack’ state introduced
in Ref. [17]. This is a hypergraph state with 2-dimensional Symmetry Protected
Topological Order (SPTO) and is a universal resource for quantum computation
using only single qubit measurements in the X, Y, and Z basis - see Figure 1.
Detailed working for this example is available in the linked Jupyter notebook.

$0$$1$$2$$3$ (a) Unit Cell of the Union Jack State of Ref. [17] which is a
hypergraph state. Qubits on the corners of each of the shaded triangles
represent the edge size 3 operators $CP(1/2,1101)$ and $CP(1/2,1011)$ which
act on $|+\rangle^{\otimes 4}$.

$0$$1$$2$$3$ (b) Unit Cell of the weighted graph state in Ref. [13]. Qubits
connected by bold lines are acted on by controlled Z operators and those by
dashed lines by controlled S operators. The weighted graph state is formed by
the operator $CP(1/2,1100)CP(1/2,0011)CP(1/4,1001)CP(1/4,0110)$ acting on
$|+\rangle^{\otimes 4}$ and can be represented as a precision 4 XP stabiliser
state.

Figure 1: Examples of Weighted Hypergraph States which can be be represented
as XP stabiliser states.

###  5.4 Representation of Weighted Hypergraph States as XP Stabiliser States

In this section, we show how to represent any weighted hypergraph state as an
XP stabiliser state. In general, this involves embedding the state into a
larger Hilbert space using an embedding operator. We first demonstrate this
for a single generalised controlled phase operator i.e.
$|\phi\rangle=CP(p/q,\mathbf{v})|+\rangle^{\otimes r}$. There are two possible
cases depending on the weight of the vector $\mathbf{v}$.

##### Case 1 $\text{wt}(\mathbf{v})=1$:

Let $\text{wt}(\mathbf{v})=1$ and let $i$ be the single non-zero component of
$\mathbf{v}$. For a given precision $N$, we can identify $CP(1/2N,\mathbf{v})$
with the operator $\sqrt{P}=\text{diag}(1,\omega)$ acting on qubit $i$ because
for a computational basis vector
$|\mathbf{e}\rangle,\sqrt{P}_{i}|\mathbf{e}\rangle=\omega|\mathbf{e}\rangle$
if $\mathbf{e}[i]=1$ and $|\mathbf{e}\rangle$ otherwise. Hence, to create a
phase of $\exp(\frac{p}{q}2\pi i)$, we can let $2N=q$. We also need $N$ to be
an integer $\geq 2$ so we set $N$ as follows:

$\displaystyle N=\begin{cases}q/2:\text{ if }q>2\text{ and
}q\operatorname{mod}2=0\\\ q:\text{ Otherwise}.\end{cases}$ (56)

The state $|+\rangle^{\otimes r}$ is stabilised by $\\{X_{j}:j\in[0\dots
r-1]\\}$ where $X_{j}$ is the Pauli X operator acting on qubit $j$. We can
also write $X_{j}=XP_{N}(0|\mathbf{x}_{j}|\mathbf{0})$ where $\mathbf{x}_{j}$
is the $j$th row of $I_{r}$. The result of conjugating $X_{j}$ by
$\sqrt{P}_{i}$ is $\omega X_{j}P_{i}$ if $i=j$ and $X_{j}$ otherwise. This can
also be written
$\sqrt{P}_{i}X_{j}\sqrt{P}_{i}^{-1}=X_{j}D_{N}(\mathbf{x}_{j}\mathbf{v})$ as
is a generalisation of the identity $SXS^{-1}=X(iZ)=Y$ for Pauli operators.
Hence the state $|\phi\rangle$ is stabilised by
$\mathbf{S}_{X}=\\{XP_{N}(0|\mathbf{x}_{j}|\mathbf{0})D_{N}(\frac{p}{q}2N\mathbf{x}_{j}\mathbf{v})\\}$.

##### Case 2 $\text{wt}(\mathbf{v})\geq 2$:

For $m:=\text{wt}(\mathbf{v})\geq 2$, we in general need to embed the weighted
graph state $|\phi\rangle$ into a larger Hilbert space to represent it as an
XP stabiliser state. The embedding operator is defined in terms of
$M^{r}_{m}$, the binary matrix whose columns are the bit strings of length $r$
of weight between $1$ and $m$ inclusive. We order the columns of $M^{r}_{m}$
first by weight then by lexicographic order. The embedding operator
$\mathcal{E}^{r}_{m}$ acts on computational basis vectors as follows:

$\displaystyle\mathcal{E}^{r}_{m}|\mathbf{e}\rangle=|\mathbf{e}M^{r}_{m}\operatorname{mod}2\rangle\,.$
(57)

Our aim is to find a precision $N$ and a set of stabiliser generators
$\mathbf{S}_{X},\mathbf{S}_{Z}$ which stabilise the embedded state
$|\psi\rangle:=\mathcal{E}^{r}_{m}|\phi\rangle$.

We set the precision $N=q2^{m-2}$ \- this is because phase function terms of
degree $m$ include a factor of $2^{m-1}$ modulo $2N$ (see Proposition 5.1) and
we need to allow for phases of form $\exp(2\pi i/q)$. If $N$ is odd, we
multiply it by $2$ so that we can form the diagonal stabiliser generators (see
Eq. (62) below).

The non-diagonal stabiliser generators $\mathbf{S}_{X}$ determine the phase
function and are defined as follows. The X-components of the $\mathbf{S}_{X}$
are the rows $\mathbf{x}_{j}$ of $M^{r}_{m}$. The Z-components are obtained by
multiplying the $\mathbf{x}_{j}$ by an ‘alternating vector’ $\mathbf{a}$ and
an ‘inclusion vector’ $\mathbf{w}$. The vector $\mathbf{a}$ is indexed by the
columns $\mathbf{u}$ of $M^{r}_{m}$ and is $1$ if the weight of $\mathbf{u}$
is even, and $-1$ otherwise:

$\displaystyle\mathbf{a}[\mathbf{u}]:=(-1)^{\text{wt}(\mathbf{u})}\,.$ (58)

The inclusion vector $\mathbf{w}$ with respect to $\mathbf{v}$ is:

$\displaystyle\mathbf{w}[\mathbf{u}]:=\begin{cases}1:\mathbf{u}\mathbf{v}=\mathbf{u}\\\
0:\text{ Otherwise}\end{cases}\,.$ (59)

Multiplying the rows $\mathbf{x}_{j}$ of $M^{r}_{m}$ by the inclusion vector
$\mathbf{w}$ ensures that we only consider columns of $M^{r}_{m}$ whose
support is a subset of the support of $\mathbf{v}$. As a result of Proposition
D.3, the following operators generate the required phase function:

$\displaystyle\mathbf{S}_{X}=\\{XP_{N}(0|\mathbf{x}_{j}|\frac{p}{q}\frac{2N}{2^{m-1}}\mathbf{a}\mathbf{x}_{j}\mathbf{w}):0\leq
j<r\\}\,.$ (60)

We now show how to construct the diagonal stabiliser generators
$\mathbf{S}_{Z}$. We calculate a basis of
$\operatorname{Ker}_{\mathbb{Z}_{2}}(M^{r}_{m})$ as follows. Because the
columns of weight 1 occur first, $M^{r}_{m}$ is of form
$M^{r}_{m}=\begin{pmatrix}I|A\end{pmatrix}$ for some binary matrix $A$. Hence
the kernel of $M^{r}_{m}$ over $\mathbb{Z}_{2}$ is spanned by:

$\displaystyle K^{r}_{m}:=\begin{pmatrix}A^{T}|I\end{pmatrix}\,.$ (61)

It is easy to see that $K^{r}_{m}(M^{r}_{m})^{T}\operatorname{mod}2=0$. Let
$\mathbf{z}_{j}$ be the $j$th row of $K^{r}_{m}$ so that
$\mathbf{x}_{i}\cdot\mathbf{z}_{j}\operatorname{mod}2=0$. The following
operators commute with the elements of $\mathbf{S}_{X}$:

$\displaystyle\mathbf{S}_{Z}:=\\{XP_{2}(0|\mathbf{0}|\mathbf{z}_{j})\\}=\\{XP_{N}(0|\mathbf{0}|N\mathbf{z}_{j}/2)\\}\,.$
(62)

This can be seen by using the COMM rule of Table 4 and noting that
$N\mathbf{x}_{j}\cdot\mathbf{z}_{j}\operatorname{mod}2N=0$:

$\displaystyle[XP_{N}(0|\mathbf{x}_{j}|\mathbf{w}_{j}),XP_{N}(0|\mathbf{0}|N\mathbf{z}_{j}/2)]$
$\displaystyle=D_{N}(N\mathbf{x}_{j}\mathbf{z}_{j})=XP_{N}(N\mathbf{x}_{j}\cdot\mathbf{z}_{j}|\mathbf{0}|\mathbf{0})=I\,.$
(63)

We are now in a position to state the algorithm for weighted hypergraph states
with multiple generalised controlled phase operators.

####  5.4.1 Algorithm: Representation of Weighted Hypergraph States as XP
Stabiliser States

##### Input:

A weighted hypergraph state
$|\phi\rangle=\big{(}\prod_{i}CP(p_{i}/q_{i},\mathbf{v}_{i})\big{)}|+\rangle^{\otimes
r}$ with $p_{i},q_{i}$ mutually prime and $\mathbf{v}_{i}$ of weight
$m_{i}\geq 0$.

##### Output:

A precision $N$, an embedding operator $\mathcal{E}^{r}_{m}$ and stabiliser
generators $\mathbf{S}_{X},\mathbf{S}_{Z}$ of an XP code whose codespace is
spanned by $|\psi\rangle:=\mathcal{E}^{r}_{m}|\phi\rangle$, a state with the
same phase function as $|\phi\rangle$.

##### Method:

  1. 1.

Let $m=\max(\\{m_{i}\\})$ \- we use the embedding operator
$\mathcal{E}^{r}_{m}$. Note that when $m=1$, the embedding operator is trivial
as $M^{r}_{1}=I_{r}$.

  2. 2.

We set the precision of the code as $N:=\text{LCM}(2,\\{N_{i}\\})$ where we
define the $N_{i}$ as follows:

     * •

If $m_{i}\geq 2$: set $N_{i}=q_{i}2^{m_{1}-2}$.

     * •

If $m_{i}=1$: if $q_{i}>2$ and $q_{i}\operatorname{mod}2=0$ set
$N_{i}=q_{i}/2$; otherwise set $N_{i}=q_{i}$.

  3. 3.

If $m=1$, $\operatorname{Ker}(I_{r})=\emptyset$ so we do not require any
diagonal stabiliser generators. For $m>1$, the diagonal stabiliser generators
are $\mathbf{S}_{Z}:=\\{XP_{N}(0|\mathbf{0}|N/2\mathbf{z}_{j})\\}$ where
$\mathbf{z}_{j}$ is the $j$th row of $K^{r}_{m}$ as in Eq. (61).

  4. 4.

The non-diagonal stabiliser generators $\mathbf{S}_{X}:=\\{A_{j}\\}$ are
determined as follows:

    1. (a)

Set $A_{j}=XP_{N}(0|\mathbf{x}_{j}|\mathbf{0})$ for $j\in[0\dots r-1]$ and
$\mathbf{x}_{j}$ the $j$th row of $M^{r}_{m}$.

    2. (b)

Update the $A_{j}$ for each of the operators $CP(p_{i}/q_{i},\mathbf{v}_{i})$:

       * •

For $m_{i}=1$,
$A_{j}:=A_{j}D_{N}(\frac{p_{i}}{q_{i}}2N\mathbf{x}_{j}\mathbf{w}_{i})$.

       * •

For $m_{i}\geq 2$,
$A_{j}:=A_{j}XP_{N}(0|\mathbf{0}|\frac{p_{i}}{q_{i}}\frac{2N}{2^{m_{i}-1}}\mathbf{a}\mathbf{x}_{j}\mathbf{w}_{i})$
where $\mathbf{a}$ is the alternating vector of Eq. (58) and $\mathbf{w}_{i}$
is the inclusion vector of Eq. (59) with respect to $\mathbf{v}_{i}$.

The algorithm can be optimised by only including qubits which for some
operator $A_{j}$ has a non-trivial Z-component. In Proposition D.4, we show
that we can further optimise for generalised controlled Z operators with
$p_{i}/q_{i}=1/2$ by replacing the factor $\mathbf{a}\mathbf{x}_{j}$ in step
(b) by $\mathbf{v}_{i}[j]\mathbf{a}(\mathbf{x}_{j}-1)$. This has the effect of
clearing the Z-component of $A_{j}$ indexed by column $\mathbf{v}_{i}$ of
$M^{r}_{m}$. This implies, for instance, that we can represent graph states,
which are created using CZ operators, with a trivial embedding.

######  Example 5.2 (Representing Weighted Hypergraph States as XP Stabiliser
States)

In Ref. [13], an example of a weighted graph state is given which is a
universal resource for measurement-based quantum computation; see Figure 1.
The unit cell of this state is

$\displaystyle|\phi\rangle=CP(1/2,1100)CP(1/2,0011)CP(1/4,1001)CP(1/4,0110)|+\rangle^{\otimes
4}\,.$ (64)

The weighted graph state $|\phi\rangle$ can be represented as an embedded
state $|\psi\rangle=\mathcal{E}_{2}^{4}|\phi\rangle$ stabilised by the
following XP code of precision $N=4$ on $10$ qubits:

$\displaystyle\mathbf{S}_{X}$
$\displaystyle=\begin{matrix}XP_{4}(0|1000111000|1000201000)\\\
XP_{4}(0|0100100110|0100200100)\\\ XP_{4}(0|0010010101|0010000102)\\\
XP_{4}(0|0001001011|0001001002)\end{matrix}\;\;\;\mathbf{S}_{Z}=\begin{matrix}XP_{4}(0|\mathbf{0}|2200200000)\\\
XP_{4}(0|\mathbf{0}|2020020000)\\\ XP_{4}(0|\mathbf{0}|2002002000)\\\
XP_{4}(0|\mathbf{0}|0220000200)\\\ XP_{4}(0|\mathbf{0}|0202000020)\\\
XP_{4}(0|\mathbf{0}|0022000002)\end{matrix}$ (65)

Using the optimised method of Proposition D.4 and deleting redundant qubits,
we find a more compact representation on $6$ qubits as follows:

$\displaystyle\mathbf{S}_{X}$
$\displaystyle=\begin{matrix}XP_{4}(0|100010|320010)\\\
XP_{4}(0|010001|230001)\\\ XP_{4}(0|001001|003201)\\\
XP_{4}(0|000110|002310)\end{matrix}\;\;\;\mathbf{S}_{Z}=\begin{matrix}XP_{4}(0|\mathbf{0}|200220)\\\
XP_{4}(0|\mathbf{0}|022002)\end{matrix}$ (66)

Detailed working for this example is available in the linked Jupyter notebook.

###  5.5 Discussion and Summary of Results

In this chapter we have shown an equivalence between XP stabiliser states and
weighted hypergraph states. For any XP stabiliser state, we can write a
weighted hypergraph representation and vice-versa. A very wide range of states
can be represented within the XP stabiliser formalism, including all weighted
graph states and hypergraph states.

These results may prove useful in implementing fault-tolerant versions of
quantum algorithms. The Grover and Deutsch-Jozsa algorithms both employ real
equally weighted (REW) pure states. In Ref. [23], the authors showed that each
REW state has an associated hypergraph state. As we can represent any
hypergraph state within the XP formalism, this could be an interesting
application.

##  6 Logical Operators and the Classification of XP Codes

The objective of this section is to understand the logical operator structure
of a given XP code. Our aim is to determine all XP operators that act as
logical operators on the codespace (“logical XP operators”), and classify the
logical actions that arise.

We start by setting out definitions for logical XP operators and introduce the
notion of a phase vector which allows us to describe the logical action of
diagonal operators (Section 6.1).

In the Pauli stabiliser formalism, the stabiliser group
$\langle\mathbf{G}\rangle$ is unique for a given codespace and a Pauli
operator acts as a trivial logical operator if and only if it is an element of
$\langle\mathbf{G}\rangle$. In the XP formalism, there may be many different
stabiliser groups for a given codespace. In Section 6.2, we show how to find a
set of XP operators $\mathbf{M}$ in the canonical form of Section 4.1 that
generates the set of trivial logical XP operators and which uniquely defines
the codespace.

In Section 6.3, we show how to find a set of non-trivial logical XP operators
$\mathbf{L}$ which together with $\mathbf{M}$ generates all logical XP
operators. Using the example of Reed-Muller codes, we show that in some cases
Pauli stabiliser codes can be viewed more naturally as XP codes and that we
can systematically determine all possible logical XP operators for such codes
using our techniques. Figure 2 explains how the various groups described above
relate to each other.

In Section 6.4, we show how to assign quantum numbers to the codewords of
Section 4.4 based on the logical operator structure of the code. This in turn
leads to a natural classification of XP codes into XP-regular and non-XP-
regular codes, which we discuss in Section 6.5. We show that each XP-regular
code can be mapped to a CSS code which has the same diagonal logical operators
and similar non-diagonal logical operators.

The algorithms for determining the generators for the logical XP group require
the codewords of Section 4.4 as input. In Section 6.6, we demonstrate modified
algorithms which take the canonical generators and orbit representatives of
Section 4.2 rather than the codewords as input. These methods are more
efficient than using the codewords as a starting point.

In Section 6.7, we describe a framework for analysing the action of diagonal
logical XP operators based on the codeword quantum numbers. We show how to
determine all possible diagonal logical actions for a given code and how to
calculate an operator with a desired logical action. In Section 6.8, we use
this framework to classify diagonal logical XP operators into core and regular
operators and demonstrate that complex logical operators arise in non-XP-
regular codes.

$\mathcal{XP}_{N,n}$$\mathcal{L}_{\text{XP}}=\langle\omega
I,\mathbf{M},\mathbf{L}\rangle$$\mathcal{I}_{\text{XP}}=\langle\mathbf{M}\rangle$$\mathcal{G}=\langle\mathbf{G}\rangle$
Figure 2: Relationship between XP Operator Groups: Here, $\mathcal{XP}_{N,n}$
is the group of all XP operators of precision $N$ on $n$ qubits. The
stabiliser group $\mathcal{G}=\langle\mathbf{G}\rangle$ is the same as the
group generated by the canonical generators $\mathbf{S}_{X},\mathbf{S}_{Z}$.
The logical identity group $\mathcal{I}_{\text{XP}}=\langle\mathbf{M}\rangle$
fixes all elements of the codespace $\mathcal{C}$. It contains but is in
general not equal to $\mathcal{G}$. The logical operator group
$\mathcal{L}_{\text{XP}}=\langle\omega I,\mathbf{M},\mathbf{L}\rangle$ is the
set of XP operators that preserve the codespace.

###  6.1 Definitions: Logical XP Operators

The logical XP identity group, denoted $\mathcal{I}_{\text{XP}}$, is the group
of XP operators that fixes all elements in the codespace $\mathcal{C}$. The
codewords $\\{|\kappa_{i}\rangle\\}$ of Section 4.4 are a basis of the
codespace, so we use the following definition:

$\displaystyle\mathcal{I}_{\text{XP}}:=\\{A\in\mathcal{XP}_{N,n}:A|\kappa_{i}\rangle=|\kappa_{i}\rangle,\forall
i\\}\,.$ (67)

In the Pauli stabiliser formalism, the logical identity group for a stabiliser
code is the same as the stabiliser group for the code. In the XP formalism,
this is not necessarily the case and we show an example of this in 6.1.
Determining the logical identity group is non-trivial, so we present an
algorithm to construct it which takes the codewords as input.

The logical XP group, denoted $\mathcal{L}_{\text{XP}}$, is the group of XP
operators that preserves the codespace - that is, the set of XP operators
$A\in\mathcal{XP}_{N,n}$ such that $A(\mathcal{C})=\mathcal{C}$. In the Pauli
stabiliser formalism, an operator $A$ is a logical operator if and only if it
commutes with all the stabiliser generators. In the XP formalism, $A$ is a
logical operator if and only if the group commutator of $A$ with any logical
identity operator is in the logical identity group (see Proposition E.2).

The action of a logical XP operator $A$ on the codewords
$\\{|\kappa_{i}\rangle\\}$ can be described in terms of a vector $\mathbf{f}$
and a permutation $\pi$ of the codewords as follows:

$\displaystyle
A|\kappa_{i}\rangle=\omega^{\mathbf{f}[i]}|\kappa_{\pi(i)}\rangle\,.$ (68)

The vector $\mathbf{f}\in\mathbb{Z}_{2N}^{\dim\mathcal{C}}$ is referred to as
the phase vector and tells us which phase is applied by $A$ to each codeword.
The permutation $\pi$ describes the non-diagonal action and $\pi^{2}=1$ (see
Proposition E.1). We call a logical operator non-trivial if it is not a
logical identity (i.e.
$A\in\mathcal{L}_{\text{XP}}\setminus\mathcal{I}_{\text{XP}}$). If the phase
vector for a diagonal operator $A$ is constant, say $c$, then the logical
action of $A$ is $\omega^{c}I$. A diagonal operator is trivial iff its phase
vector is zero.

###  6.2 Determining the Logical Identity Group

We present an algorithm to construct the generators of the logical identity
group for an XP code. This algorithm takes the codewords of the XP code, as in
Section 4.4, as input. The result is a list of XP operators $\mathbf{M}$ in
the canonical form of Proposition 4.1 that generate the logical identity
group, or FALSE if the complex span of codewords is not the codespace of any
XP code of precision $N$. Detailed proofs of the results in this section are
found in Appendix E.

We first demonstrate how to find generators for the diagonal logical identity
group, then turn to the non-diagonal generators.

####  6.2.1 Diagonal Logical Identity Group Generators $\mathbf{M}_{Z}$

Our algorithm for finding the diagonal logical identity group is as follows:

  1. 1.

Let $E$ be the Z-support of the codewords (as defined in Section 4.2.2) and
let $E_{M}$ be the matrix formed by taking $\\{(\mathbf{e}|1):\mathbf{e}\in
E\\}\subset\mathbb{Z}_{2}^{n}\times\mathbb{Z}_{2}$ as rows.

  2. 2.

Determine the Howell basis $K_{M}$ of
$\operatorname{Ker}_{\mathbb{Z}_{N}}(E_{M})$ (see Section A.2).

  3. 3.

Let $(\mathbf{z}_{k}|q_{k})$ denote the rows of $K_{M}$ and let
$\mathbf{M}_{Z}=\\{XP_{N}(2q_{k}|\mathbf{0}|\mathbf{z}_{k})\\}$.

  4. 4.

Calculate the orbit representatives corresponding to $\mathbf{M}_{Z}$ (see
Section 4.3.2). If the number of orbit representatives does not match the
number of codewords, return FALSE.

We show that this algorithm produces a generating set of diagonal logical
identity operators in Proposition E.3.

####  6.2.2 Non-diagonal Logical Identity Group Generators $\mathbf{M}_{X}$

We now set out the algorithm to find the non-diagonal generators, which
consists of two steps: first, we find the X components of the generators;
second, we find the phase and Z components that are consistent with the
relative phases between the computational basis elements in the codewords.

##### Step 1: Identifying the X-Components.

Let $E_{i}$ be the Z-support of the codeword $|\kappa_{i}\rangle$ as defined
in Section 4.2.2. Take any element $\mathbf{e}_{i}\in E_{i}$ and let $T$ be
the binary matrix with rows formed from
$\\{\mathbf{e}_{i}\oplus\mathbf{e}:\mathbf{e}\in E_{i}\\}$. Let
$S_{X}=\operatorname{RREF}_{\mathbb{Z}_{2}}(T)$ and let
$\mathbf{m}_{i}=\operatorname{Res}_{\mathbb{Z}_{2}}(T,\mathbf{e}_{i})$ using
the residue function defined in Eq. (201). Verify that
$E_{i}=\mathbf{m}_{i}+\langle S_{X}\rangle$ for each codeword. If not, return
FALSE.

##### Step 2: Determining the Phase and Z-Components.

We use linear algebra modulo $N$ (see Section A.3) to find valid phase and
Z-components for the generators identified in Step 1. Assume that the
codewords $|\kappa_{i}\rangle$ are written in orbit form as in Eq. (35). For
each $\mathbf{x}$ in $S_{X}$ we complete the following steps:

  1. 1.

Let $\mathbf{e}^{\prime}_{ij}=\mathbf{e}_{ij}\oplus\mathbf{x}$, and let
$p^{\prime}_{ij}$ be the phase of $\mathbf{e}^{\prime}_{ij}$ in the codewords

  2. 2.

Let $p^{\prime\prime}_{ij}=(p^{\prime}_{ij}-p_{ij})\operatorname{mod}2N$. For
there to be a valid solution, the $p^{\prime\prime}_{ij}$ are all either even
(i.e. divisible by 2 in $\mathbb{Z}_{2N}$) or odd. Let
$a=p_{00}^{\prime\prime}\operatorname{mod}2$ be an adjustment factor. Let
$p^{\prime\prime\prime}_{ij}=(p^{\prime\prime}_{ij}-a)/2$ so that
$p^{\prime\prime\prime}_{ij}\in\mathbb{Z}_{N}$. Let
$\mathbf{p}^{\prime\prime\prime}$ be the vector formed from the
$p^{\prime\prime\prime}_{ij}$

  3. 3.

Find a solution $(\mathbf{z}|q)\in\mathbb{Z}_{N}^{n}\times\mathbb{Z}_{N}$ such
that $E_{M}^{T}(\mathbf{z}|q)=\mathbf{p}^{\prime\prime\prime}$ using linear
algebra modulo $N$ (see Section A.3).

  4. 4.

If there is no such solution, return FALSE

  5. 5.

Otherwise, let $K_{M}$ be the Howell basis of
$\operatorname{Ker}_{\mathbb{Z}_{N}}(E_{M})$. Let
$(\mathbf{z}^{\prime}|p^{\prime})=\operatorname{Res}_{\mathbb{Z}_{N}}(K_{M},(\mathbf{z}|q))$
and add the operator $XP_{N}(a+2p^{\prime}|\mathbf{x}|\mathbf{z}^{\prime})$ to
$\mathbf{M}_{X}$.

We show that this algorithm produces a non-diagonal logical identity operator
in Proposition E.6.

####  6.2.3 Properties of the Canonical Logical Identity Generators

The algorithm to find the logical identity generators take the codewords as
input and results in a set of generators $\mathbf{M}$ in canonical form.
Hence, the set $\mathbf{M}$ uniquely identifies the codespace. Any XP group
stabilising the codewords is composed of operators that act as logical
identities on the codespace and so is a subgroup of
$\langle\mathbf{M}\rangle$. In Proposition E.14, we demonstrate an algorithm
for determining $\mathbf{M}$ that does not require the codewords as input, and
so results in a test for whether two sets of XP operators stabilise the same
codespace.

The logical identity algorithm can also be used to determine if a given
quantum state is a stabiliser state of an XP code of precision $N$. We simply
apply the algorithm - if it fails, the state is not a valid XP stabiliser
state. If it succeeds, the set of operators $\mathbf{M}$ is a set of
stabiliser generators for the state. The method can also be used for
codespaces with dimensions greater than $1$. We illustrate the algorithm for
the logical identity generators using our main example:

######  Example 6.1 (Logical Identity Group - Code 1)

Taking the codewords calculated for the code in Example 4.5 as input, we find
that the canonical generators of the logical identity group are:

$\displaystyle\mathbf{M}_{X}=\begin{matrix}XP_{8}(9|1110000|0070000)\\\
XP_{8}(14|0001111|0001234)\end{matrix}\;,\quad\mathbf{M}_{Z}=\begin{matrix}XP_{8}(0|0000000|1070000)\\\
XP_{8}(0|0000000|0170000)\\\ XP_{8}(8|0000000|0004444)\end{matrix}$ (69)

Compare these to the canonical generators:

$\displaystyle\mathbf{S}_{X}=\begin{matrix}XP_{8}(9|1110000|1240000)\\\
XP_{8}(14|0001111|0001234)\end{matrix}\,,\quad\mathbf{S}_{Z}=\begin{matrix}XP_{8}(8|0000000|2334444)\\\
XP_{8}(0|0000000|0440000)\end{matrix}$ (70)

By definition, any stabiliser of the codespace is a logical identity so
$\langle\mathbf{S}_{X},\mathbf{S}_{Z}\rangle\subset\langle\mathbf{M}_{X},\mathbf{M}_{Z}\rangle$.
In this example, the diagonal generators $\mathbf{S}_{Z}$ are not the same as
$\mathbf{M}_{Z}$, but they have the same simultaneous $+1$ eigenspace. In all
cases, $\langle\mathbf{S}_{Z}\rangle\subset\langle\mathbf{M}_{Z}\rangle$. For
this example, we observe that none of the operators in $\mathbf{M}_{Z}$ are in
$\langle\mathbf{S}_{Z}\rangle$, but all of the operators in $\mathbf{S}_{Z}$
are in $\langle\mathbf{M}_{Z}\rangle$. For example:

$\displaystyle XP_{8}(8|0|2334444)$
$\displaystyle=XP_{8}(0|0|1070000)^{2}XP_{8}(0|0|0170000)^{3}XP_{8}(8|0|0004444)$
(71)

The non-diagonal generators $\mathbf{S}_{X}$ are the same as $\mathbf{M}_{X}$,
up to a product of elements of $\langle\mathbf{M}_{Z}\rangle$. Full working
for this example is in the linked Jupyter notebook.

###  6.3 Determining the Logical Operator Group

We now present an algorithm that will identify the logical XP operator group
of an XP code. This algorithm again takes as input the codewords of Section
4.4, and is similar to the algorithm for the logical identity group. The
result is a list of XP operators $\mathbf{L}$ that generate the logical XP
operator group together with $\mathbf{M}$ and $\omega I$. Detailed proofs of
these results are in Appendix E.

We first demonstrate how to find generators for the diagonal logical operator
group, then turn to the non-diagonal generators.

####  6.3.1 Diagonal Logical Operator Algorithm

The following algorithm gives a list of operators $\mathbf{L}_{Z}$ which
together with $\omega I$ and $\mathbf{M}_{Z}$ generate all diagonal logical XP
operators. We assume we have the codewords $\\{|\kappa_{i}\rangle\\}$ in orbit
form as in Eq. (35) expressed as a linear combination of computational basis
elements $|\mathbf{e}_{ij}\rangle$. The key to finding the diagonal logical
operators is to form a matrix from the binary vectors corresponding to the
basis vectors for each codeword, and an index which indicates which codeword
the vector is from:

  1. 1.

For each $\mathbf{e}_{ij}$, let $\mathbf{i}$ be a binary vector of length
$\dim(\mathcal{C})$ which is all zeros apart from the $i$th component which is
$1$.

  2. 2.

Let $E_{L}$ be the matrix formed by taking
$(\mathbf{e}_{ij}|\mathbf{i})\in\mathbb{Z}_{2}^{n}\times\mathbb{Z}_{2}^{\dim(\mathcal{C})}$
as rows.

  3. 3.

Determine the Howell basis $K_{L}$ of
$\operatorname{Ker}_{\mathbb{Z}_{N}}(E_{L})$ modulo $N$ (see Section A.2).

  4. 4.

Let
$(\mathbf{z}_{k}|\mathbf{q}_{k})\in\mathbb{Z}_{N}^{n}\times\mathbb{Z}_{N}^{\dim(\mathcal{C})}$
be a row of $K_{L}$ and let $M_{Z}$ be the matrix formed from the Z-components
of the diagonal logical identity operators $\mathbf{M}_{Z}$ of Section 6.2.1.
Let $K$ be the Howell basis of the matrix formed from the residue of each row
of the $\mathbf{z}_{k}$ over $\mathbb{Z}_{N}$ with respect to $M_{Z}$.

  5. 5.

Let $\mathbf{z}_{k}$ be a row of $K$ and let
$B_{k}=XP_{N}(0|\mathbf{0}|\mathbf{z}_{k})$. Then the set
$\mathbf{L}_{Z}=\\{B_{k}\\}$ is a set of non-trivial diagonal logical
operators which together with $\mathbf{M}_{Z}$ and $\omega I$ generate all
diagonal logical XP operators.

Note that the operator $XP(1|\mathbf{0}|\mathbf{0})=\omega I$ is always a
logical operator for any XP code - it has the effect of applying a phase
$\omega$ to all codewords. By convention, we do not include it in
$\mathbf{L}_{Z}$. We show that the algorithm produces a generating set of
diagonal logical XP operators in Proposition E.4.

####  6.3.2 Non-diagonal Logical Operators

In this section, we demonstrate how to find a generating set of non-diagonal
logical XP operators. We first show how to find the X-components of a
generating set of non-diagonal logical operators. We then demonstrate how to
find valid phase and Z-components for a logical operator with a given X
component.

##### Step 1: Identifying the X-Components.

Here, we identify the valid X-components for all non-diagonal logical
operators by calculating a coset decomposition of the orbit representatives
$E_{m}$. In Section 4.2.1, we showed that we can write the Z-support of the
codewords, $E$, in coset form $E=E_{m}+\langle S_{X}\rangle$. We can decompose
the orbit representatives themselves into cosets $E_{m}=E_{q}+\langle
L_{X}\rangle$. To find the matrix $L_{X}$ and set of vectors $E_{q}$, we use
the following result:

######  Proposition 6.1 (Coset Decomposition of $E_{m}$)

Given a set of binary vectors $E_{m}\subset\mathbb{Z}_{2}^{n}$ there exists a
unique binary matrix $L_{X}$ in RREF such that:

$\displaystyle E_{m}$ $\displaystyle=E_{q}+\langle L_{X}\rangle$
$\displaystyle E_{q}$
$\displaystyle:=\\{\text{Res}_{\mathbf{Z}_{2}}(L_{X},\mathbf{e}):\mathbf{e}\in
E_{m}\\}$ (72) $\displaystyle\mathbf{x}\in\langle L_{X}\rangle$
$\displaystyle\iff\mathbf{x}\oplus E_{m}=E_{m}$

###### Proof.

Let $T=\\{\mathbf{x}\in\mathbb{Z}_{2}^{n}:\mathbf{x}\oplus\mathbf{e}\in
E_{m},\forall\mathbf{e}\in E_{m}\\}$. Choose an arbitrary $\mathbf{e}_{0}\in
E_{m}$. Then $T$ is a subset of
$E_{m}^{\prime}=\\{\mathbf{e}\oplus\mathbf{e}_{0}:\mathbf{e}\in E_{m}\\}$. We
can check whether $\mathbf{x}\in E_{m}^{\prime}$ is in $T$ by checking if
$\mathbf{x}\oplus\mathbf{e}\in E_{m},\forall\mathbf{e}\in E_{m}$. If
$\mathbf{x}\in T$ then it permutes the elements of $E_{m}$ so
$\mathbf{x}\oplus E_{m}=E_{m}$.

$T$ is a group under component-wise addition modulo $2$ because
$\mathbf{x}_{1},\mathbf{x}_{2}\in
T\implies\mathbf{x}_{1}\oplus\mathbf{x}_{2}\in T$, so
$L_{X}=\operatorname{RREF}_{\mathbb{Z}_{2}}(T)$ generates $T$ under component
wise addition modulo $2$.

Finally, the residue function is an equivalence relation partitioning $E_{m}$
into cosets of $\langle L_{X}\rangle$. ∎

We can think of $T=\langle L_{X}\rangle$ as the group of all vectors
$\mathbf{x}$ such that $\mathbf{x}\oplus E_{m}=E_{m}$. The X-component of any
logical XP operator must be in $\langle L_{X}\rangle+\langle S_{X}\rangle$
because logical operators preserve the codespace. In Proposition E.8, we show
that logical operators with X-components in $L_{X}$ together with
$\mathbf{L}_{Z}$, $\mathbf{S}_{X}$, $\mathbf{S}_{Z}$ and $\omega I$ generate
the full set of logical XP operators.

##### Step 2: Valid Phase and Z-components.

Assume that the codewords $|\kappa_{i}\rangle$ are written in orbit form as in
Eq. (35). The algorithm for finding the phase and Z-components of the
operators for a given $\mathbf{x}\in L_{X}$ is as follows:

  1. 1.

Let $\mathbf{e}^{\prime}_{ij}=\mathbf{e}_{ij}\oplus\mathbf{x}$, and let
$p^{\prime}_{ij}$ be the phase of $\mathbf{e}^{\prime}_{ij}$in the codewords

  2. 2.

Let $p^{\prime\prime}_{ij}=(p^{\prime}_{ij}-p_{ij})\operatorname{mod}2N$. For
there to be a valid solution, for fixed $i$ the $p^{\prime\prime}_{ij}$ are
all either even or odd. Let $a_{i}=p^{\prime\prime}_{i0}\operatorname{mod}2$
be an adjustment factor

  3. 3.

Let $p^{\prime\prime\prime}_{ij}=(p^{\prime\prime}_{ij}-a_{i})/2$ so that
$p^{\prime\prime\prime}_{ij}\in\mathbb{Z}_{N}$, and let
$\mathbf{p}^{\prime\prime\prime}$ be the binary vector with the
$p^{\prime\prime\prime}_{ij}$ as components

  4. 4.

Find a solution
$(\mathbf{z}|\mathbf{q})\in\mathbb{Z}_{N}^{n}\times\mathbb{Z}_{N}^{\dim(\mathcal{C})}$
such that
$E_{L}^{T}(\mathbf{z}|\mathbf{q})\operatorname{mod}N=\mathbf{p}^{\prime\prime\prime}$
using linear algebra modulo $N$ (see Section A.3). Then
$A=XP_{N}(0|\mathbf{x}|\mathbf{z})$ is a logical operator.

In Proposition E.5, we show that the above algorithm generates a valid logical
operator with X-component $\mathbf{x}$, or returns FALSE if this is not
possible. The resulting operator is non-diagonal, but is not necessarily a
logical X operator. For $A$ to be a logical X operator, then $A^{2}$ should be
a logical identity operator. Applying the SQ rule of Section 3.3, $A^{2}$ is
diagonal. Hence we require $A^{2}\in\langle\mathbf{M}_{Z}\rangle$. We show how
to adjust the phase and Z component to ensure this in Section E.8.

####  6.3.3 Examples: Logical Operators

We now illustrate this algorithm for the logical XP operator group for two
example XP codes:

######  Example 6.2 (Logical Operators - Code 1)

The orbit representatives for Code 1 of Example 4.5 are given by Eq. (45). We
calculate the coset decomposition of $E_{m}$ which gives us the X-components
of the non-diagonal logical generators. Using the technique in Proposition
6.1, we find that $L_{X}$ has $2$ rows and $E_{q}$ is of size $1$:

$\displaystyle L_{X}$ $\displaystyle=\begin{pmatrix}0000101\\\ 0000011\\\
\end{pmatrix}$ (73) $\displaystyle E_{q}$
$\displaystyle=\begin{pmatrix}0000001\end{pmatrix}$ (74)

By adding elements of $\langle L_{X}\rangle$ to any orbit representative
$\mathbf{m}_{i}$, we can reach any other orbit representative
$\mathbf{m}_{j}$. The logical operator group generators are:

$\displaystyle\mathbf{L}_{X}=\begin{matrix}XP_{8}(2|0000101|0000204)\\\
XP_{8}(1|0000011|0000034)\end{matrix}\,,\quad\mathbf{L}_{Z}=\begin{matrix}XP_{8}(0|0000000|0002226)\\\
XP_{8}(0|0000000|0000404)\\\ XP_{8}(0|0000000|0000044)\end{matrix}$ (75)

Full working for this example is in the linked Jupyter notebook. We look at
the logical action of these logical operators in Example 6.9.

######  Example 6.3 (Logical Operators - Code 2)

We now introduce our second main example, which is the code given by the
following canonical stabiliser generators:

$\displaystyle\mathbf{S}=$
$\displaystyle\begin{matrix}XP_{8}(0|0000000|1322224)\\\
XP_{8}(12|1111111|1234567)\end{matrix}$ (76)

Using the graph search algorithm of Section 4.3.2, the orbit representatives
for Code 2 are:

$\displaystyle E_{m}$ $\displaystyle=\begin{pmatrix}0000000\\\ 0000111\\\
0001011\\\ 0001101\\\ 0011110\\\ 0011001\\\ 0010101\\\ 0010011\end{pmatrix}$
(77)

The algorithm in Section 4.4 yields the following codewords:

$\displaystyle\begin{array}[]{rrr}|\kappa_{0}\rangle=&|0000000\rangle&+\omega^{12}|1111111\rangle\\\
|\kappa_{1}\rangle=&|0000111\rangle&\;\;\;+|1111000\rangle\\\
|\kappa_{2}\rangle=&|0001011\rangle&+\omega^{14}|1110100\rangle\\\
|\kappa_{3}\rangle=&|0001101\rangle&+\omega^{12}|1110010\rangle\\\
|\kappa_{4}\rangle=&|0011110\rangle&\;\;\;+|1100001\rangle\\\
|\kappa_{5}\rangle=&|0011001\rangle&+\omega^{8}|1100110\rangle\\\
|\kappa_{6}\rangle=&|0010101\rangle&+\omega^{10}|1101010\rangle\\\
|\kappa_{7}\rangle=&|0010011\rangle&+\omega^{12}|1101100\rangle\end{array}$
(86)

Calculating the coset decomposition of $E_{m}=E_{q}+\langle L_{X}\rangle$
using Proposition 6.1 we find that $L_{X}$ contains only one row but $E_{q}$
has $4$ elements:

$\displaystyle L_{X}=$ $\displaystyle\begin{pmatrix}0011110\end{pmatrix}$ (87)
$\displaystyle E_{q}=$ $\displaystyle\begin{pmatrix}0000000\\\ 0000111\\\
0001011\\\ 0001101\end{pmatrix}$ (88)

From the starting point $\mathbf{m}_{i}$, we can only reach orbit
representatives $\mathbf{m}_{j}=\mathbf{m}_{i}\oplus 0011110$ by adding
elements of $\langle L_{X}\rangle$ modulo $2$. We could, however, apply a
unitary $U$ which permutes codewords as follows.

$\displaystyle|\kappa_{0}\rangle$
$\displaystyle\rightarrow|\kappa_{1}\rangle\rightarrow|\kappa_{2}\rangle\rightarrow|\kappa_{3}\rangle\rightarrow|\kappa_{0}\rangle$
(89) $\displaystyle|\kappa_{4}\rangle$
$\displaystyle\rightarrow|\kappa_{5}\rangle\rightarrow|\kappa_{6}\rangle\rightarrow|\kappa_{7}\rangle\rightarrow|\kappa_{4}\rangle$
(90)

Let the codewords in orbit form be $|\kappa_{i}\rangle=\sum_{0\leq
j<2^{r}}\omega^{p_{ij}}|\mathbf{e}_{ij}\rangle$. Let
$k=(i+1)\operatorname{mod}4$ then $U$ is the operator given by:

$\displaystyle U$ $\displaystyle=\sum_{\mathbf{e}_{ij}\in
E}|\mathbf{e}_{kj}\rangle\langle\mathbf{e}_{ij}|+\sum_{\mathbf{e}\in\mathbb{Z}_{2}^{n}\setminus
E}|\mathbf{e}\rangle\langle\mathbf{e}|$ (91)

$U$ cannot, however, be written as an XP operator.

Applying the algorithms in sections 6.3.1 and 6.3.2 we find the following
generators for the logical XP group:

$\displaystyle\mathbf{L}_{X}=$ $\displaystyle
XP_{8}(2|0011110|0012304)\,,\quad\mathbf{L}_{Z}=\begin{matrix}XP_{8}(0|0000000|0211112)\\\
XP_{8}(0|0000000|0022220)\\\ XP_{8}(0|0000000|0004004)\\\
XP_{8}(0|0000000|0000404)\\\ XP_{8}(0|0000000|0000044)\\\ \end{matrix}$ (92)

Full working for this example is in the linked Jupyter notebook.

######  Example 6.4 (Reed Muller Codes)

In this example, we look at Reed Muller codes. These can be viewed as XP
codes, and the algorithms of this chapter make it straightforward to determine
their full logical operator structure. By varying the parameters of these
codes, we show that they give rise to transversal logical operators at any
level of the Clifford hierarchy.

We can write the 15-qubit Reed Muller code as a precision 2 code (i.e. using
Pauli group operators) in terms of diagonal ($\mathbf{S}_{Z}$) and non-
diagonal ($\mathbf{S}_{X}$) stabiliser generators:

$\displaystyle\mathbf{S}_{Z}$
$\displaystyle=\begin{array}[]{l}XP_{2}(0|\mathbf{0}|100011100011101)\\\
XP_{2}(0|\mathbf{0}|010010011011011)\\\
XP_{2}(0|\mathbf{0}|001001010110111)\\\
XP_{2}(0|\mathbf{0}|000100101101111)\\\
XP_{2}(0|\mathbf{0}|000010000011001)\\\
XP_{2}(0|\mathbf{0}|000001000010101)\\\
XP_{2}(0|\mathbf{0}|000000100001101)\\\
XP_{2}(0|\mathbf{0}|000000010010011)\\\
XP_{2}(0|\mathbf{0}|000000001001011)\\\
XP_{2}(0|\mathbf{0}|000000000100111)\end{array},\;\;\;\mathbf{S}_{X}=\begin{array}[]{l}XP_{2}(0|100011100011101|\mathbf{0})\\\
XP_{2}(0|010010011011011|\mathbf{0})\\\
XP_{2}(0|001001010110111|\mathbf{0})\\\
XP_{2}(0|000100101101111|\mathbf{0})\end{array}$ (107)

The logical operators for precision $N=2$ are:

$\displaystyle\bar{X}=XP_{2}(0|000011111100001|\mathbf{0}),\;\;\;\bar{Z}=XP_{2}(0|\mathbf{0}|000000000011111)$
(108)

We can rescale this code to be of precision $N=8$ by multiplying the
Z-components of the generators by 4. Applying the algorithm in Section 6.3, we
find additional diagonal operators as follows:

$\displaystyle\bar{S}^{\dagger}=XP_{8}(0|\mathbf{0}|000022222200002),\;\;\;\bar{T}^{\dagger}=XP_{8}(0|\mathbf{0}|111111111111111)$
(109)

Note that $\bar{S}^{\dagger}$ has an $S$ operator on same qubits as $\bar{X}$,
whilst $\bar{T}^{\dagger}$ has a $T$ operator on all 15 qubits. If we again
rescale to precision $N=16$, we do not obtain any additional logical
operators. This suggests that the code has a ‘natural precision’ of $8$.

In the XPF, the stabiliser group for a given codespace is not unique. We can
write a more compact generating set of precision 4 operators that stabilise
the same codespace. The operators are symmetrical in X and S and generate a
different stabiliser group to those in Eq. (107):

$\displaystyle\mathbf{S}_{Z}$
$\displaystyle=\begin{array}[]{l}XP_{4}(0|\mathbf{0}|100011100011101)\\\
XP_{4}(0|\mathbf{0}|010010011011011)\\\
XP_{4}(0|\mathbf{0}|001001010110111)\\\
XP_{4}(0|\mathbf{0}|000100101101111)\end{array},\;\;\;\mathbf{S}_{X}=\begin{array}[]{l}XP_{4}(0|100011100011101|\mathbf{0})\\\
XP_{4}(0|010010011011011|\mathbf{0})\\\
XP_{4}(0|001001010110111|\mathbf{0})\\\
XP_{4}(0|000100101101111|\mathbf{0})\end{array}$ (118)

Note here that the X-components of the non-diagonal generators and the
Z-components of the diagonal generators are the rows of the binary matrix
$M^{4}_{4}$ as defined in Section 5.4.

In Proposition E.9, we generalise this example and show the Reed-Muller code
on $2^{r}-1$ qubits can be written as the codespace of a precision $N=2^{r-2}$
code whose stabiliser generators are symmetric in X and P with X and
Z-components the rows of the matrix $M^{r}_{r}$ respectively. Pleasingly, this
gives a self-dual set of stabiliser generators for all codes in this family.
This generalises the known result for the Steane code, where $r=3$ and $N=2$.
Furthermore, to stabilise the code space of $n=2^{r}-1$ qubits, we require
only $2r$ stabilisers, a logarithmic scaling. The code has natural precision
of $2^{r-1}$ and a transversal logical $\text{diag}(1,\exp(2\pi i/2^{r-1}))$
operator.

You can explore which logical operators arise in codes with different
parameters for Reed Muller codes in the linked Jupyter notebook.

###  6.4 Assigning Quantum Numbers to the Codewords

In this section, we demonstrate a natural way of assigning quantum numbers to
the codewords of Section 4.4. This view of the codewords gives rise to a
classification of XP codes (Section 6.5). It also allows us to develop more
efficient algorithms to determine the logical operator group (Section 6.6) and
to analyse the logical action of operators (Sections 6.7, 6.8).

The assignment of quantum numbers is based on the coset structure of the
Z-support of the codewords $E$ (see Section 4.2.2). Recall from Section 6.3.2
that $L_{X}$ is a set of binary vectors such that $E_{m}=E_{q}+\langle
L_{X}\rangle$. Hence, we can write $E$ in coset form as:

$\displaystyle E$ $\displaystyle=E_{q}+\langle S_{X}\rangle+\langle
L_{X}\rangle$ (119)
$\displaystyle=\\{(\mathbf{q}_{l}+\mathbf{u}S_{X}+\mathbf{v}L_{X})\operatorname{mod}2:\mathbf{q}_{l}\in
E_{q},\mathbf{u}\in\mathbb{Z}_{2}^{r},\mathbf{v}\in\mathbb{Z}_{2}^{k}\\}$
(120)

We refer to $E_{q}$ as the core of the code. We can index elements of $E$ by
writing:

$\displaystyle\mathbf{e}_{l,\mathbf{u},\mathbf{v}}$
$\displaystyle:=(\mathbf{q}_{l}+\mathbf{u}S_{X}+\mathbf{v}L_{X})\operatorname{mod}2$
(121)

We can assign quantum numbers to the orbit representatives $\mathbf{m}\in
E_{m}$ of Section 4.2.2 as follows:

$\displaystyle\mathbf{m}_{l,\mathbf{v}}$
$\displaystyle:=(\mathbf{q}_{l}+\mathbf{v}L_{X})\operatorname{mod}2$ (122)

and these also apply to the codewords of Section 4.4:

$\displaystyle|\kappa_{l,\mathbf{v}}\rangle$
$\displaystyle:=O_{\mathbf{S}_{X}}|\mathbf{m}_{l,\mathbf{v}}\rangle\,.$ (123)

We refer to $l$ as the Core Index, $\mathbf{u}$ as the Stabiliser Index and
$\mathbf{v}$ as the Logical Index. The orbit distance is used to develop more
efficient versions the logical identity and logical operator algorithms (see
Section 6.6), and is defined as:

$\displaystyle\operatorname{dist}(\mathbf{e}):=\operatorname{wt}(\mathbf{u})+\operatorname{wt}(\mathbf{v})\,.$
(124)

######  Example 6.5 (Quantum Numbers - Code 1)

For Code 1 of Example 4.5, the orbit representatives can be written
$E_{m}=E_{q}+\langle L_{X}\rangle$ where
$E_{q}=\\{0000001\\},L_{X}=\\{0000100,0000010\\}$. The full decomposition of
$E_{q}+\langle S_{X}\rangle+\langle L_{X}\rangle$ and associated quantum
numbers as per Section 6.4 is:

$\displaystyle\begin{array}[]{c | c || r: r r : r}&&\lx@intercol\text{Stabiliser Index}\hfil\lx@intercol\\\ \text{Logical Index}&\text{Core Index}&00&10&01&11\\\ \hline\cr\hline\cr 00&0&0000001&1110001&0001110&1111110\\\ \hdashline 10&0&0000100&1110100&0001011&1111011\\\ 01&0&0000010&1110010&0001101&1111101\\\ \hdashline 11&0&0000111&1110111&0001000&1111000\end{array}$

The vectors in the first column of the table with Stabiliser Index
$\mathbf{u}=\mathbf{0}$ correspond to the orbit representatives $E_{m}$. The
vectors in row $i$ of the table are the Z-support of the $i$th codeword
$|\kappa_{i}\rangle$ as in Eq. (30). Each codeword can be identified by the
quantum numbers $(l,\mathbf{v})$ where $\mathbf{v}$ is the Logical Index and
$l$ is the Core Index. In this case, the size of the core is 1, so the core
index is the same for all codewords. The dashed lines group together vectors
with the same orbit distance.

######  Example 6.6 (Quantum Numbers - Code 2)

For code 2 of Example 6.3, the full decomposition of $E_{q}+\langle
S_{X}\rangle+\langle L_{X}\rangle$ and associated indexing as per Section 6.4
is:

$\displaystyle\begin{array}[]{c | c||r : r}&&\lx@intercol\text{Stabiliser Index}\hfil\lx@intercol\\\ \hline\cr\text{Logical Index}&\text{Core Index}&0&1\\\ \hline\cr\hline\cr 0&0&0000000&1111111\\\ 0&1&0000111&1111000\\\ 0&2&0001011&1110100\\\ 0&3&0001101&1110010\\\ \hdashline 1&0&0011110&1100001\\\ 1&1&0011001&1100110\\\ 1&2&0010101&1101010\\\ 1&3&0010011&1101100\end{array}$

The vectors with orbit distance 0, i.e. $\mathbf{u}=\mathbf{0}$ and
$\mathbf{v}=\mathbf{0}$ correspond to the core $E_{q}$. In this case, the size
of the core is 4, so we need both the Logical Index and the core index to
specify the codewords. These examples are illustrated in the linked Jupyter
notebook.

###  6.5 Classification of XP Codes

In this section, we present a way of classifying XP codes into XP-regular and
non-XP-regular codes. The main result is that each XP-regular code can be
mapped via a diagonal unitary operator to a CSS code that has a very similar
logical operator structure. We will see in Section 6.8 that non-XP-regular
codes have a much richer logical operator structure that is distinct from PSF
codes and so offer the possibility for interesting new classes of codes.

In Section 6.5.1, we introduce the concept of XP-regular codes and give some
examples and elementary properties. In Section 6.5.2, we demonstrate that each
XP-regular code can be mapped to a CSS code with identical diagonal logical
operators, and similar non-diagonal logical operators.

####  6.5.1 Definition of XP-Regular and Non-XP-Regular Codes

Consider an XP code, and let $E_{q}$ be the core of a code as defined in
Section 6.4. If $|E_{q}|=1$, the code is XP-regular. Otherwise, the code is
non-XP-regular.

One major difference between XP-regular and non-XP-regular codes is the
codespace dimension. The codespace dimension for an XP code is
$\dim(\mathcal{C})=|E_{q}|2^{k}$ where $k=|L_{X}|$ (see Section 6.4). For an
XP-regular code, $|E_{q}|=1$ so the codespace dimension is a power of $2$ and
it encodes $k$ logical qubits. The codespace dimension of non-XP-regular codes
may or may not be a power of $2$. Non-XP-regular codes are not additive, and
their structure resembles that of the codeword stabilised (CWS) quantum codes
of Ref. [7]. The CWS class is very broad and includes all Pauli stabiliser and
qudit stabiliser codes. There are examples of CWS codes which have better
error correction properties than any known additive code with the same number
of physical qubits. [21].

In Ref. [18], a ‘regular code’ is defined as one where the diagonal stabiliser
generators of the code are elements of $\langle-I,Z\rangle^{\otimes n}$. All
regular codes are XP-regular and in Section 6.5.2 we will show a link between
the two definitions. The examples below illustrate our definition of XP-
regular codes:

######  Example 6.7 (XP-Regular and Non-XP-Regular Codes)

Examples of XP-Regular and Non-XP-Regular codes include:

  1. 1.

All XP stabiliser states (i.e. XP codes with one-dimensional codespaces) are
XP-regular;

  2. 2.

All Pauli codes (i.e. XP codes with precision $N=2$) are XP-regular;

  3. 3.

Code 1 of Example 4.5 is XP-regular as $|E_{q}|=1$, though it is not regular
according to the definition in Ref. [18];

  4. 4.

Code 2 of Example 6.3 is non-XP-regular, as $|E_{q}|=4$;

####  6.5.2 Mapping XP-Regular Codes to CSS Codes

In this section, we show that each XP-regular code can be mapped via a
diagonal unitary operator to a CSS code with a very similar logical operator
structure. This is significant because it shows that the logical operator
structure of an XP-regular code is no more complex than the corresponding CSS
code.

The algorithm for mapping a regular code whose canonical generators are
$\mathbf{S}_{X},\mathbf{S}_{Z}$ is:

  1. 1.

Determine a set of diagonal Pauli operators $\mathbf{R}_{Z}$ with the same
simultaneous $+1$ eigenspace as the $\mathbf{S}_{Z}$

  2. 2.

If $\mathbf{S}_{X}=\\{(p_{i}|\mathbf{x}_{i}|\mathbf{z}_{i})\\}$ then let
$\mathbf{R}_{X}=\\{(0|\mathbf{x}_{i}|\mathbf{0})\\}$

  3. 3.

The mapped CSS code has stabiliser generators $\mathbf{R}_{X},\mathbf{R}_{Z}$.

We first show how to calculate a set of diagonal Pauli operators
$\mathbf{R}_{Z}$ which have the same simultaneous $+1$ eigenspace as
$\mathbf{S}_{Z}$. This links to the definition of ‘regular code’ in Ref. [18],
where regular codes were defined as those in which all diagonal generators are
diagonal Paulis and implies that all ‘regular codes’ are XP-regular.

######  Lemma 6.2 (Regular Diagonal Generators)

If a code is XP-regular with diagonal canonical stabilisers $\mathbf{S}_{Z}$,
then there exist diagonal Pauli operators whose simultaneous $+1$ eigenspace
is the same as $\mathbf{S}_{Z}$.

###### Proof.

If the code is XP-regular, it has core size 1. Let $\mathbf{q}$ be the sole
element in the core. The Z-support of the simultaneous $+1$ eigenspace of the
$\mathbf{S}_{Z}$ can be written as:

$\displaystyle E=\mathbf{q}+\langle S_{X}\rangle+\langle L_{X}\rangle$ (125)

Let $G_{X}$ be the matrix formed from the rows of $L_{X}$ and $S_{X}$. The
rows of $G_{X}$ are independent. Find the Howell basis $K$ of
$\operatorname{Ker}_{\mathbb{Z}_{2}}(G_{X})$. Because there are
$|S_{X}|+|L_{X}|=r+k$ independent rows in $G_{X}$, there are $n-r-k$
independent rows in $K$.

Let
$\mathbf{R}_{Z}=\\{XP_{2}(-2\mathbf{q}\cdot\mathbf{z},\mathbf{0},\mathbf{z}):\mathbf{z}\in
K\\}$ and let the Z-support of the simultaneous $+1$ eigenspace of the
$\mathbf{R}_{Z}$ be $E^{\prime}$. Operators in $\mathbf{R}_{Z}$ stabilise all
elements $\mathbf{e}\in E$ so $E\subset E^{\prime}$.

Because $\mathbf{R}_{Z}$ has $n-k-r$ independent diagonal Pauli operators,
$|E^{\prime}|=2^{r+k}=|E|$. Hence the simultaneous $+1$ eigenspaces of
$\mathbf{S}_{Z},\mathbf{R}_{Z}$ are the same. ∎

We are now in a position to prove the main result of this section:

######  Proposition 6.3 (Mapping XP-Regular Codes to CSS Codes)

Given a XP-regular code $\mathbf{C}$ with canonical generators
$\mathbf{S}_{X},\mathbf{S}_{Z}$, there is a mapping to a CSS code
$\mathbf{C}^{\prime}$ with generators $\mathbf{R}_{X},\mathbf{R}_{Z}$ such
that:

  1. 1.

If $|\kappa_{i}\rangle=\sum_{0\leq
j<2^{r}}\omega^{p_{ij}}|\mathbf{e}_{ij}\rangle$ is codeword of $\mathbf{C}$
then $|\kappa_{i}\rangle^{\prime}=\sum_{0\leq j<2^{r}}|\mathbf{e}_{ij}\rangle$
is a codeword of $\mathbf{C}^{\prime}$;

  2. 2.

$\mathbf{C}^{\prime}$ has the same diagonal logical operators as $\mathbf{C}$;

  3. 3.

If $XP_{N}(p|\mathbf{x}|\mathbf{z})$ is a non-diagonal logical operator of
$\mathbf{C}$, then $XP_{N}(0|\mathbf{x}|\mathbf{0})$ is a logical operator of
$\mathbf{C}^{\prime}$.

###### Proof.

Let $\mathbf{S}_{X}$ and $\mathbf{S}_{Z}$ be the canonical generators for
$\mathbf{C}$. Because $\mathbf{C}$ is XP-regular, by Proposition 6.2 we can
find a decomposition $E=\mathbf{q}+\langle S_{X}\rangle+\langle L_{X}\rangle$
and $\mathbf{R}_{Z}$ which from $\langle-I,Z\rangle^{\otimes n}$ and which
have the same simultaneous $+1$ eigenspace as the $\mathbf{S}_{Z}$. Let
$\mathbf{R}_{X}=\\{XP_{N}(0|\mathbf{x}|\mathbf{0}):\mathbf{x}\in L_{X}\\}$ and
let $\mathbf{C}^{\prime}$ be the code defined by the stabiliser generators
$\mathbf{R}_{X},\mathbf{R}_{Z}$.

By construction, the simultaneous $+1$ eigenspaces of the diagonal generators
are the same (and so are the respective Z-supports i.e. $E=E^{\prime}$). The
matrices formed from the X-components of the non-diagonal canonical generators
are the same (i.e. $S_{X}=R_{X}$). Hence, the orbit representatives are the
same (i.e. $E_{m}^{\prime}=E_{m}=\\{\mathbf{m}_{i}\\}$), and so
$|\kappa_{i}\rangle^{\prime}=O_{\mathbf{R}_{X}}|\mathbf{m}_{i}\rangle=\sum_{j}|\mathbf{e}_{ij}\rangle$
form a basis for the codespace of $C^{\prime}$.

The algorithm for computing the diagonal logical operators in Section 6.3.1
depends only on the Z-support of the codewords. As $E^{\prime}=E$, the
diagonal logical operators are the same.

In Section 6.3.2, we showed that the X components of the logical operators
depend only on $E=E^{\prime}$, so for any logical operator
$XP_{N}(p|\mathbf{x}|\mathbf{z})$ of $\mathbf{C}$,
$XP_{N}(0|\mathbf{x}|\mathbf{0})$ is a logical operator of
$\mathbf{C}^{\prime}$. ∎

We can transform the codespaces $\mathcal{C}^{\prime}$ to $\mathcal{C}$ by
applying the diagonal unitary $U$ specified by:

$\displaystyle U=\sum_{\mathbf{e}_{ij}\in
E}\omega^{p_{ij}}|\mathbf{e}_{ij}\rangle\langle\mathbf{e}_{ij}|+\sum_{\mathbf{e}\in\mathbb{Z}_{2}^{n}\setminus
E}|\mathbf{e}\rangle\langle\mathbf{e}|\,.$ (126)

######  Example 6.8 (Map XP-Regular Code to CSS - Code 1)

Code 1 of Example 4.5 is an XP-regular code. Applying Proposition 6.3 regular
generators are given by:

$\displaystyle\mathbf{R}_{Z}$
$\displaystyle=\begin{array}[]{l}XP_{2}(0|0000000|1010000)\\\
XP_{2}(0|0000000|0110000)\\\ XP_{2}(2|0000000|0001111)\end{array}\,\
\quad\mathbf{R}_{X}=\begin{array}[]{l}XP_{2}(0|1110000|0000000)\\\
XP_{2}(0|0001111|0000000)\end{array}\,.$ (132)

Full working for this example is in the linked Jupyter notebook.

####  6.5.3 Error Correction for XP-Regular Codes

We now briefly consider error correction for XP codes. One of the complexities
associated with this problem is that the stabiliser generators of XP codes are
not guaranteed to commute, so simultaneous measurements may not be possible. A
possible error-correction routine for XP-regular codes is as follows. In this
case, we calculate the regular diagonal generators $\mathbf{R}_{Z}$ which are
diagonal Pauli operators. By measuring the $\mathbf{R}_{Z}$ first and
correcting for errors, we guarantee that we are in a subspace where all
stabiliser generators commute and can complete the error-correction process by
measuring the non-diagonal generators $\mathbf{S}_{X}$. A similar process is
outlined in section V of Ref. [18].

Another approach would be to adopt the error correction methods for codeword
stabilised (CWS) quantum codes presented in Ref. [7]. In this approach, the
codewords of a Pauli stabiliser code are viewed as translations of a graph
state $|S\rangle$ by tensors of Pauli Z operators
$XP_{2}(0|\mathbf{0}|\mathbf{w}_{i})$. The vectors $\mathbf{w}_{i}$ are called
word operators and form a classical code over $\mathbb{Z}_{2}^{n}$. Any
single-qubit error can be propagated along the edges of the graph state by
applying stabilisers of $|S\rangle$ and converted into a tensor of Pauli Z
operators $XP_{2}(0|\mathbf{0}|\mathbf{z})$. This allows decoding using
classical techniques using the bit string $\mathbf{z}$. To use this approach,
we would need to be able to convert an arbitrary XP code into a graph state
translated by tensors of Pauli Z operators. We have seen in Chapter 5 that XP
states can be represented as weighted hypergraph states. The orbit
representatives $E_{m}$ of XP codes play a similar role to the word operators
of CWS codes so this approach may have potential.

###  6.6 Modified Logical Operator Algorithms

The logical identity and logical operator algorithms presented in sections 6.2
and 6.3 require as input the codewords in the orbit form of Eq. (35). In the
Pauli stabiliser formalism, there are algorithms for determining the logical Z
and X operators that do not require us to first calculate the codewords. Can
we find such algorithms in the XP formalism?