Quantum Pin Codes
Christophe Vuillot Nikolas P. Breuckmann








Quantum Pin Codes
    Christophe Vuillot
        and Nikolas P. Breuckmann

C. Vuillot, previously QuTech, TU Delft, now Inria, France, mailto:christophe.vuillot@inria.frchristophe.vuillot@inria.fr.
N. P. Breuckmann, University College London, mailto:n.breuckmann@ucl.ac.ukn.breuckmann@ucl.ac.uk.
 This paper was presented at QEC19 in London.

    December 30, 2023
=====================================================================================================================================================================================================================================================================================================================================





	We introduce quantum pin codes: a class of quantum CSS codes.
	Quantum pin codes are a generalization of quantum color codes and Reed-Muller codes and share a lot of their structure and properties.
	Pin codes have gauge operators, an unfolding procedure and their stabilizers form so-called ℓ-orthogonal spaces meaning that the joint overlap between any ℓ stabilizer elements is always even.
	This last feature makes them interesting for devising magic-state distillation protocols, for instance by using puncturing techniques.
	We study examples of these codes and their properties.






§ INTRODUCTION

The realization of a fault-tolerant universal quantum computer is a tremendous challenge.
At each level of the architecture, from the hardware implementation up to the quantum software, there are difficult problems that need to be overcome. 
Hovering in the middle of the stack, quantum error correcting codes influence both hardware design and software compilation.
They play a major role not only in mitigating noise and faulty operations but also in devising protocols to distill the necessary resources that grant universality to an error corrected quantum computer <cit.>.
The study and design of quantum error correcting codes is therefore one of the major tasks to be undertaken on the way to universal quantum computation.

A well-studied class of quantum error correcting codes are Calderbank-Shor-Steane codes (CSS codes)  <cit.>, which are stabilizer quantum codes <cit.>.
The advantage of CSS codes over general stabilizer codes is their close connection to linear codes which have been studied in classical coding theory.
A CSS code can be constructed by combining two binary linear codes.
Roughly speaking, one code performs parity checks in the Pauli X-basis and the other performs parity checks in the Pauli Z-basis.
Not any two binary linear codes can be used: it is necessary that any two pairs of code words from each code space have to have even overlap.
Several families of CSS codes have been devised based on geometrical, homological or algebraic constructions <cit.>, however, it is still open which parameters can be achieved.

Besides being able to protect quantum information, quantum error correcting codes must also allow for some mechanism to process the encoded information without lifting the protection.
It is always possible to find some operations realizing a desired action on the encoded information but these operations may spread errors in the system.
Therefore we shall only consider operations to be fault-tolerant if they do not spread errors.
For instance, if the operation acts separately on each qubit of a code it cannot spread single qubit errors to multi-qubit errors.
This is called a transversal gate, but not any code admits such gates.
More generally, for many codes in the CSS code family it is possible to fault-tolerantly implement Clifford operations, which are all unitary operations preserving Pauli operators under conjugation.
Clifford operations by themselves do not form a universal gate set.
Several techniques to obtain a universal gate set, by supplementing the non-Clifford T gate to Cliffords for example, have been devised <cit.>, among which magic state distillation is currently the most promising candidate.

In this work we introduce a new class of CSS codes, which we call quantum pin codes.
They are inspired from D-dimensional quantum color codes <cit.> which are known for their transversal gates.
Quantum pin codes form a large family while at the same time have structured stabilizer generators.
Namely, they form ℓ-orthogonal spaces, meaning that the common overlap between any ℓ stabilizer elements is even.
This structure is necessary for codes to admit transversal phase gates and it can be leveraged to obtain codes that can be used within magic state distillation protocols.
This structure comes from an underlying multi-ary relation with a single simple property and we show different ways of constructing such relations.
While the whole family is too large to feature interesting transversal gates for all its members it could lead to interesting subfamilies.
Besides one can obtain magic state distillation protocols from any relation defining a quantum pin code by using puncturing techniques. Moreover, using a slightly different code definition, one can obtain a quantum code with transversal T gates realizing a logical circuit of CCZ gates.
Moreover the construction of pin codes differs substantially from previous approaches making it an interesting space to explore further.

In Section <ref>, after introducing some notations and terminology, we define quantum pin codes, explain their relation to quantum color codes and give some concrete approaches to construct them.
In Section <ref>, we discuss the conditions for transversal implementation of phase gates on a CSS code and magic state distillation.
In Section <ref>, we investigate the properties of pin codes.
Finally, in Section <ref>, we study concrete examples of pin codes obtained from Coxeter groups and chain complexes.
We also discuss applications for magic state distillation.



§ PIN CODES





 §.§ Quantum stabilizer codes, CSS codes and subsystem codes

A quantum code can be defined by considering an Abelian subgroup S of the Pauli group on n qubits such that -I ∉S.
That is to say a commuting group generated by tensor product of the single-qubit Pauli operators and identity:

    X = [ 0 1; 1 0 ],    Y = [  0 -i;  i  0 ],
    
    	Z = [  1  0;  0 -1 ],    I = [ 1 0; 0 1 ].

The quantum code associated with S is defined as the common +1-eigenspace of all elements of S.

    𝒞 = {|ψ⟩ | ∀ s∈ S,s|ψ⟩ = |ψ⟩}.

Quantum codes defined in this way are called stabilizer codes, the generator elements of S are called stabilizer generators and generic elements of S simply stabilizers.
A generating set of S defines stabilizer checks which can be measured in order to infer information about the errors.
The logical operators of a stabilizer code are the Pauli operators which commute with all stabilizers.
That is to say they belong to the centralizer of the stabilizer group.
The fact that they commute with stabilizers makes them preserve the code space.
A logical operator which also belongs to the stabilizer group is called trivial as it not only preserve the code space but also each code state.
Logical operators outside of the stabilizer group are non-trivial as they act non-trivially on the code states while preserving the codes space.
For more background on stabilizer codes see <cit.>.
A stabilizer code is called a Calderbank-Shor Steane (CSS) code <cit.> if there exists a set of stabilizer checks which only act non-trivially as either Pauli-X or Pauli-Z on each qubit in their support.
In that case the code is most conveniently described by two classical binary linear codes, 𝒞_X⊂𝔽_2^n and 𝒞_Z⊂𝔽_2^n, generating the X-type and Z-type stabilizers respectively.
To form a valid stabilizer code the X-type stabilizers and Z-type stabilizer must commute which constraints 𝒞_X and 𝒞_Z to be included in each others dual space:
𝒞_X⊂𝒞_Z^⊥, note that this condition is symmetric.
The logical operators of a CSS code also split into X- and Z-type operators, they are given by 𝒞_Z^⊥ and 𝒞_X^⊥ respectively.
Code states of CSS codes are simply expressed as equal superposition of computational basis states over cosets:

    |x⟩ = 1/√(2^| C_X|)∑_y∈𝒞_X|y⊕ x⟩,

where x∈𝒞_Z^⊥ and x designate the coset of x in 𝒞_Z^⊥/𝒞_X.


Subsystem codes are a generalization of stabilizer codes.
A subsystem code is defined by any (non-Abelian) subgroup of the Pauli group G which is called the gauge group.
In order to define the code we define the stabilizer subgroup S of G to be the center of G, i.e. the largest Abelian subgroup of G.
The code is then defined as the stabilizer code of S.
The reason to define a code in this way is that a generating set of G (called gauge checks) can be of lower weight than any generating elements of S.
This allows to infer the eigenvalues of the stabilizer checks by measuring the lower-weight gauge checks.




 §.§ Terminology and formalism


Consider D+1 finite, disjoint sets, (L_0,…,L_D) which we call levels. 
The elements in each of the levels are called pins. 
If a pin p is contained in a set L_j then j is called the rank of p.
Since all the L_j are disjoint each pin has a unique rank.

Consider a (D+1)-ary relation on the D+1 levels L_0,…,L_D, that is to say a subset of their Cartesian product F⊂ L_0×⋯× L_D.
The tuples in the relation F will be called flags.

A subset of the ranks, T⊂{0,…,D}, is called a type.
We will consider tuples of pins coming from a subset of the levels selected by a type T and call them collection of pins of type T.
A collection of pins of type T={j_1,…,j_k}, is therefore an element s∈ L_j_1×⋯× L_j_k.
Note that we can interchangeably view a collection of pins as a tuple or a set as long as no two pins come from the same level in the set.

We now define specific subsets of flags, called pinned sets, using projections.
[Projection of type T]
	
	Given a set of flags F and a type T={j_1,…,j_k}, the projection, Π_T, is defined as the natural Cartesian product projection acting on the flags
	
    Π_T :   F    → L_j_1×⋯× L_j_k
       (p_0,…,p_D)    ↦ (p_j_1,…,p_j_k).


Note that the projection of empty type, Π_∅, is also well defined: for any f∈ F we have Π_∅(f) = ().
[Pinned set]
	
	Let F be a set of flags, s be a collection of pins of type T and Π_T be the corresponding projection as defined above.
	We define the pinned set of type T and collection of pins s, P_T(s), as the preimage of s under the projection Π_T,
	
    P_T(s) = Π_T^-1 (s )⊂ F.


In words: a pinned set is the set of flags whose projection of a given type T yields a given collection of pins, s.
A definition of a pinned set which is equivalent to the one given above is 

    P_T   (p_j_1,…,p_j_k) = 
       F∩ ( L_0⋯×p_j_1×⋯×p_j_k×⋯ L_D ).

Proving that these definitions are equivalent amounts to proving

    Π_T^-1 (s ) = F∩ ( L_0⋯×p_j_1×⋯×p_j_k×⋯ L_D ).

To prove the inclusion of the left-hand side in the right-hand side we observe that an element in the set from the left hand-side is in F by definition of Π_T and in (L_0⋯×p_j_1×⋯×p_j_k×⋯ L_D ) since s=(p_j_1,…,p_j_k).
To prove the inclusion of the right-hand side in the left-hand side one takes any element f∈ F∩ ( L_0⋯×p_j_1×⋯×p_j_k×⋯ L_D ) and notice that Π_T(f) = s.

The pinned set with respect to the empty type is none other than the full set of flags, F.
For convenience, we will refer to a pinned set defined by a collection with k pins as a .

If one wants to form a mental image one can imagine a pin-board with pins of different colors for each levels on it.
Then the flags can be represented by cords each attached to one pin of each level, see Fig. <ref> as an example.


The structure of pinned sets layed out above is such that they intersect and decompose nicely.
This is captured by the following two propositions.

	
	Given F, a set of flags, let s_1 and s_2 be two collections of pins of types T_1 and T_2 respectively.
	Then the intersection of the two pinned sets P_T_1(s_1) and P_T_2(s_2) is either empty or a pinned set of type T_1∪ T_2 characterized by the collection of pins s_1∪ s_2, 
	
    P_T_1(s_1)   ∩ P_T_2(s_2) = 
       P_T_1∪ T_2(s_1∪ s_2)    if | s_1∪ s_2| = | T_1∪ T_2|
    ∅    otherwise.



	We write s_1 = (p_i_1,…,p_i_k_1) and s_2 = (q_j_1,…,q_j_k_2).
	Consider the case where T_1∩ T_2 = ∅.
	Then it is always the case that | s_1∪ s_2| = | T_1∪ T_2| since the levels are disjoint.
	Using the alternative characterization of pinned sets given in (<ref>) the conclusion then straightforwardly follows.
	Consider the case where T_1∩ T_2 ≠∅.
	Either there exist a rank j∈ T_1∩ T_2 such that p_j ≠ q_j then given f_1∈ P_T_1(s_1) and f_2∈ P_T_2(s_2) one has Π_j(f_1) = p_j ≠ q_j = Π_j(f_2) hence f_1≠ f_2 and so P_T_1(s_1)∩ P_T_2(s_2) = ∅.
	In this case it also holds that | s_1∪ s_2| > | T_1 ∪ T_2| since for every shared rank in j∈ T_1∩ T_2 for which p_j≠ q_j the difference | s_1∪ s_2| - | T_1 ∪ T_2| is increased by one.
	In the other case for all j∈ T_1∩ T_2 we have p_j = q_j.
	Hence it holds that | s_1∪ s_2| = | T_1 ∪ T_2| and P_T_1(s_1)∩ P_T_2(s_2) = P_T_1∪ T_2(s_1∪ s_2) using (<ref>) again.


	
	Given F, a set of flags, let s be a type T collection of pins and let T^' be a type containing T, i.e. T^'⊃ T.
	The pinned set P_T(s) is partitioned into some number, say m, of pinned sets, each characterized by a type T^' collections of pins containing s, i.e. s^'_j ⊃ s,
	
    P_T(s) = _j=1^mP_T^'(s^'_j).



	Let s be a type T collection of pins and let T^' be a type such that T^'⊃ T.
	Define the following set of collections of pins
	
    S = Π_T^' (P_T(s) ),

	then it is the case that
	
    P_T(s) = _s^'∈ S P_T^'(s^').

	Indeed, since T^'⊃ T and ∀ s^'∈ S, s^'⊃ s we have that ∀ s^'∈ S, P_T^'(s^')⊂ P_T(s) showing the right to left inclusion.
	The left to right inclusion follows from the definition of S.
	Finally the fact that the union is disjoint follows from Prop. <ref>.






 §.§ Definition of a (x,z)-pin code


Equipped with the notions layed out in the previous section, we now construct quantum codes.
They are defined by a choice of flags F and two natural integers x and z which fulfill the condition x+z ≤ D.
The flags are identified with qubits, so that n = | F|. 
The X-stabilizers generators are defined by all the x-pinned sets and the Z-stabilizers generators by the z-pinned sets in the following way.
For each x-pinned set we define the Pauli operator acting as the Pauli-X operator on the qubits corresponding to the flags in the pinned set and as the identity on the rest; we then add it to the generating set of the X-stabilizers.
We do similarly for the z-pinned sets to form the generating set of the Z-stabilizers.
In order to ensure the correct commutation relations between the X- and Z-stabilizers it is sufficient to enforce the following condition on the relation F.
[Pin code relation]
	A (D+1)-ary relation, F, is a pin code relation if all D-pinned sets have even cardinality.

This property is sufficient for the overlap between two pinned sets to be even every time they are pinned by a small enough number of pins.
This is summarized in the following proposition.

	Let F be a (D+1)-ary pin code relation as per Definition <ref>.
	Let x and z be two natural integers such that, 
    x+z≤ D.

	Then, the intersection between any x-pinned set and any z-pinned set has even cardinality.


	By Proposition <ref>, the intersection of a x-pinned set and a z-pinned set is either empty or a pinned set with at most x+z≤ D pins.
	In turn by Proposition <ref>, the intersection can be partitionned into D-pinned sets which all have even cardinality since the relation F is a pin code relation.

Using a pin code relation we can therefore define a CSS code as follows.
[(x,z)-pin code]
	Given a pin code relation, F, on (D+1) sets and two natural integers (x,z)∈ℕ^2, such that x+z≤ D, we define the corresponding (x,z)-pin code by associating the elements of F with qubits, all the x-pinned sets with X-stabilizer generators and all the z-pinned sets with Z-stabilizer generators.
	By Proposition <ref> the defined code is a valid CSS code.

A first remark is that the choice of x=0 (or z=0) is not particularly interesting since in this case there is a single X-stabilizer (or Z-stabilizer) acting on all the qubits.
A second remark is that in the strict case, where x+z < D, the code will contain many low weight logical operators which are naturally identified as gauge operators. 
This is explained in details in Sec. <ref>.


Table <ref> summaries the objects defined and their role to define a quantum code.
The main task is to construct a pin code relation which permits to define the rest.
Before explaining how to construct pin code relations we show that Reed-Muller codes can be generated by pinned-sets of a specific relation, and that quantum color codes are a subclass of pin codes.






 §.§ Relation to Reed-Muller codes



Given integers r and m, the classical Reed-Muller code, ℛℳ(r,m), is defined as the space generated by the vectors of all evaluations of polynomials over m variables of degree at most r:

    ℛℳ(r,m) = { (p(x) )_x∈𝔽_2^m:    p∈𝔽_2[X_0,…,X_m-1],
        deg(p)≤ r}.


We now show that ℛℳ(r,m) is generated by the pinned sets with r pins of a certain pin code relation F.
Consider m levels, each containing two pins, 

    ∀ j∈{0,…,m-1}, L_j = {0,1},

and the complete m-ary relation,

    F_ℛℳ^m = L_0×⋯× L_m-1,

see also the left of Figure <ref>.
Consider now a r-pinned set defined, with type T={j_1, …, j_r}, and pins b=(b_j_1,…,b_j_r).
One can check that a flag, f∈ F=𝔽_2^m, belongs to P_T(b) if and only if the following degree r polynomial, p_T,b, evaluates to 1,

    p_T,b = ∏_j∈ T
    b_j=1X_j∏_k∈ T
    b_k=0 (1-X_k ).

So the pinned sets with r pins generate the following code,

    𝒫(r,m) = 
    	⟨ (p_T,b(x) )_x∈𝔽_2^m:    T⊂{0,…,m-1},
       | T| = r,  b∈𝔽_2^m⟩.

Then we just have to check that these generate all polynomial of degree at most r.
By definition they generate polynomials constituted of a product of r elements being either X_j or (1-X_j).
Let's suppose, for some ℓ≤ r, they can generate all such product with only ℓ terms.
Then we can contruct all product with only ℓ-1 terms, q, as follows

    q = q·(1-X_j) + q· X_j,

where X_j is a variable that does not appear in q.
It follows by induction that they generate all degree at most r polynomials and so

    ℛℳ(r,m) = 𝒫(r,m).


Another way to see this is to use the decomposition property of pinned sets (Proposition <ref>) and generate the lower degree monomial directly with pinned sets with less pins and decompose these pinned sets into disjoint union of r-pinned sets.


Classical Reed-Muller codes have been used in several different ways to define quantum codes. 
Some of their useful properties include that the dual of ℛℳ(r,m) is ℛℳ(m-1-r,m) and that if r≤ s then ℛℳ(r,m)⊆ℛℳ(s,m).
Some constructions use directly Reed-Muller codes to define the X and Z stabilizers <cit.>.
In <cit.> the X-stabilizers are given by ℛℳ(r,m) and the Z-stabilizers are given by ℛℳ(r-1,m). 
In addition some of the generators for the X-stabilizers can be modified to increase the distance of the code by half while loosing the CSS property.
Before this modification this construction can be directly interpreted as the quantum pin code defined by the relation F_ℛℳ^m from (<ref>) and by setting x=r and z=r-1 with 2r-1≤ m-1 which ensures that x+z≤ D=m-1.
In the papers <cit.>, the X-stabilizers are given by ℛℳ(r-1, m) and the Z-stabilizers by ℛℳ(m-r-1, m).
This can be directly interpreted as the quantum pin code defined by the relation F_ℛℳ^m from (<ref>) and by setting x=r-1 and z=m-r-1 (then automatically x+z≤ D= m-1).
 
Several other works use the shortened versions of Reed-Muller codes <cit.>.
The shortened version of the Reed-Muller code consists in removing the constant 1 from the polynomials and throwing away the evaluation bit p(0) (it is now always 0).
The idea is that if one where to take ℛℳ(r, m) and ℛℳ(m-r-1, m) as X and Z stabilizers respectively, one would get exactly 0 logical qubits since these two codes are dual of one another.
Taking the shortened versions one gets a single logical qubit.
This can be interpreted as a quantum pin code defined by the relation F_ℛℳ^m from (<ref>), by setting x and z such that x+z=D=m-1, and declaring as free pins the 1 in all levels L_j in (<ref>), see Section <ref>.




 §.§ Relation to quantum color codes


The formalism and definitions for quantum pin codes can be viewed as a generalization of quantum color codes without boundaries <cit.>.
However it is also possible to integrate the notion of boundaries into the general framework of pin codes but we delay these considerations to Sec. <ref>.
A D-dimensional color code is defined by a homogeneous, D-dimensional, simplicial complex, triangulating a D-manifold, whose vertices are (D+1)-colorable.
A D-dimensional, simplicial complex is called homogeneous if every simplex of dimension less than D is a face of some D-simplex.
The (Poincaré) dual of a simplicial complex as defined above is sometimes called a colex <cit.>, it consists in a tessellation where the vertices are (D+1)-valent and the D-cells are (D+1)-colorable.
In the original simplicial complex, the qubits are identified with the D-simplices and one chooses two natural integers, (x̃,z̃ )∈ℕ^2 with x̃+z̃≤ D-2, to define the X- and Z-checks using the x̃- and z̃-simplices in the following way.
Each X-stabilizer generator is identified with a x̃-simplex which acts as Pauli-X on all D-simplices in which it is contained.
Similarly, each Z-stabilizer generator operate on all the D-simplices as Pauli-Z in which the corresponding z̃-simplex is contained, respectively.

This definition can be restated in the language of pin codes: the D+1 levels, L_0,…,L_D, are indexed by the D+1 colors and each level contains the vertices of a given color.
The flags, F, are defined using the D-simplices (each containing D+1 vertices); this defines a relation, F⊂ L_0×⋯× L_D thanks to the colorability condition as each D-simplex will not contain two vertices of the same color.
One can further check that the relation F is a pin code relation as stated in Def. <ref>.

(D-simplices form a pin code relation).
	Let 𝒯 be a homogeneous D-dimensional simplicial complex whose vertices are (D+1)-colorable, triangulating a D-manifold.
	Given a (D+1)-coloration with colors numbered from 0 to D, define L_j as the set of vertices of color number j in 𝒯.
	The relation F⊂ L_0×⋯× L_D representing the set of D-simplices is a pin code relation.


	D-pinned sets correspond to (D-1)-simplices which are contained in exactly two D-simplices since the simplicial-complex triangulates a D-manifold without boundaries.
	This shows that it is a pin code relation.

Then subsets of the (D+1) colors correspond to types and any k-simplex corresponds directly to a collection of pins of type given by the (k+1) different colors of the (k+1) vertices of the k-simplex.
The corresponding (k+1)-pinned set contains all the D-simplices containing the original k-simplex.
As such all the non-empty (k+1)-pinned sets are given by all the collection of pins and type corresponding to all the k-simplices. 
With these consideration, we see that choosing x=x̃+1 and z = z̃+1, the corresponding (x,z)-pin code is the same as the original color code.

(Quantum color codes are quantum pin codes).
	Let 𝒯 be a homogeneous D-dimensional simplicial complex whose vertices are (D+1)-colorable, triangulating a D-manifold.
	For integers x and z such that x+z ≤ D-2, the (x-1, z-1)-color code defined on 𝒯 is equal to the (x,z)-pin code defined by the relation on the colored vertices given by the set of D-simplices.


	By inspection, using Table <ref>, one checks that the qubits and stabilizers exactly coincide in the definition of the (x-1, z-1)-color code and the (x,z)-pin code.




An example for D=2, based on the hexagonal color code, is shown in Figure <ref>.
To summarize: to go from color codes to pin codes one just forgets the geometry, keeping only the (D+1)-ary relation given by the (D+1)-colored D-simplices.

Importantly, pin codes are more general, as there are pin code relations which are not derived from these specific simplicial complexes.
In the next section after recalling a concrete color code construction we give two more general constructions of pin code relations.




 §.§ Constructing pin codes





  §.§.§ Color codes from tilings

In <cit.>, the authors explain how to obtain a colex from any tiled D-manifold.
The idea is to successively inflate the (D-1)-cells, (D-2)-cells, …, 0-cells into D-cells.
The dual of the tiling obtained is then a (D+1)-colorable triangulation of the D-manifold, see Appendix A of <cit.>.
This can also be understood directly, without inflating the cells, as follows:
Separate all the cells into (D+1) sets, L_0,…,L_D, according to their dimensions, i.e. L_j contains all the j-cells.
We can now define a (D+1)-ary relation on the cells via the incidence relation.
Two cells of different dimension are incident if and only if one is a sub-cell of the other.
An element of this relation, i.e. a (D+1)-tuple containing a 0-cell (a vertex), a 1-cell (an edge), etc…up to a D-cell, is called a flag.
See for example Fig. <ref> for a representation of the flags of the square lattice.
The flag relation obtained this way is the same as the one after going through the inflating procedure and it is a pin code relation.



A similar way to construct (D+1)-colorable tessellations in D dimensions directly is to use the Wythoff construction <cit.>.
The construction is quite general, but for simplicity, let us start on the 2D euclidean plane.
Consider a right-angled triangle and draw a point into its interior. From this point we draw three lines, each intersecting a boundary edge in a right angle (see Fig. <ref>).
This creates three regions in the triangle which we assign three different colors.
We can now reflect the triangle along its boundary edges.
The internal points of the original and the reflected triangles become the vertices of a uniform tiling. The faces of the tiling are colored by the three colors and by construction no two faces of the same color are adjacent (see Fig. <ref>).
If the angles of the triangle are 2π/r, 2π/s and 2π/l then the result will be a r.s.l-tiling, meaning that the three faces around a vertex will have r, s and l number of sides.

This idea readily generalizes to higher dimensions by placing a vertex into a D-dimensional simplex and drawing lines to the mid-point of the D-1-dimensional faces of the simplex (see Fig. <ref> for the case D=3).
The faces of the simplex are simplices themselves, so this process can be iterated until D=2.
Reflecting along the faces of the D-simplex gives rise to a uniform tiling of the D-dimensional space with D-cells being colored by D+1 colors and no two cells of the same color sharing a D-1-dimensional face.
The number of vertices of the D-cells is then determined by the orbit of the reflections along all but one of the sides.

The color codes from regular tilings can be obtained this way, for example, in 2D Euclidean space, the hexagonal, 4.8.8. or 4.6.12. color codes or more generally both Euclidean and hyperbolic tilings in any dimension.

In order to obtain a finite code from the infinite tessellation we can either introduce boundaries or by introducing periodic boundary conditions. The details will depend on the individual lattice.




  §.§.§ Coxeter group approach


The Wythoff construction of the previous section can be generalized in the language of group theory.
The reflections used to tile the space form groups called Coxeter groups.
The fundamental triangles can be seen as group elements and reflections about their sides are generators of the group. 
In this section we will explain the more general approach based on these groups or more generally on finite groups which are generated by elements with even order.
A Coxeter group is a finitely presented group with reflections as generators, denoted as

    G = ⟨ a_0,…,a_D| a_0^2 = ⋯ = a_D^2 =  (a_ia_j )^k_ij = r_k = ⋯ = 1⟩,

where the k_ij are integers defining relations between the generators, r_k are additional relations between generators and 1 is the trivial element <cit.>.
Define the subgroups, H_j for , as

    H_j = ⟨{a_0,…,a_D}∖{a_j}⟩.

Define the levels, L_j, as the sets of left cosets for each H_j, i.e.

    L_j = {gH_j | g∈ G}.

The cosets of a subgroup always form a partition of the full group.
So for every j∈{0,…,D}, a group element g∈ G uniquely defines a coset p_j∈ L_j such that g∈ p_j.
Hence, each group element defines a (D+1)-tuple of cosets, (p_0,…,p_D)∈ L_0×⋯× L_D.
Taking the set of all such tuples defines a (D+1)-ary relation on the cosets,  F⊂ L_0×⋯× L_D, which is a pin code relation.
The fact that this F is a pin code relation can be verified by the following argument.
A k-pinned set here correspond to the intersection of k different cosets with respect to k different subgroups H_j.
It always holds that the intersection of several cosets is either empty or is a coset with respect to the intersection of the subgroups of the original cosets.
Hence non-empty k-pinned sets are cosets with respect to a subgroup, H_j_1,…,j_k,

    H_j_1,…,j_k = ⋂_i=1^kH_j_i.

Each subgroup H_j_i is generated by all generators of G except one, this means that H_j_1,…,j_k contains at least a subgroup generated by D-k+1 of the generators,

    H_j_1,…,j_k⊇⟨{a_0,…,a_D}∖{a_j_1,…,a_j_k}⟩.

In particular, the D-pinned sets are cosets with respect to a subgroup that contains ⟨ a_j⟩ for some j.
We note that ⟨ a_j⟩ has order two, since a_j is a reflection, and thus all D-pinned sets have even order.
In well behaved cases the containment in (<ref>) will actually be an equality, but this is not guaranteed due to relations between generators that may exist.

In the case where the Coxeter group describes the symmetries of a tiling this construction is equivalent to the Wythoff construction described above.
But one also obtains more general pin codes when considering Coxeter groups not defining tilings or more general finite groups with generators of even order.

Note that it is generally not possible to directly obtain the properties of the quantum pin code derived from a Coxeter group from the group's representation and the choice of subgroups H_i.



In Sec. <ref> we explore in more details the construction of pin codes from 3D hyperbolic Coxeter groups and give some explicit examples.




  §.§.§ Chain complex approach



An other way of obtaining a pin code relation is from 𝔽_2 chain complexes of length D+1.
For our purposes, these algebraic objects are composed of (D+1) finite-dimensional vector spaces over 𝔽_2, say 𝒞_0,…,𝒞_D, together with D linear maps called boundary maps, ∂_j:𝒞_j→𝒞_j-1, which are such that

    ∀ j∈{0,…,D-1}, ∂_j∘∂_j+1 = 0.

For example the tiling of a D-manifold can be seen as a chain complex, taking the j-cells as a basis for the 𝒞_j vector space and the natural boundary map.
We have shown how to get a pin code relation from such a tiling by taking its flags, but it can as well be obtained from any 𝔽_2 chain complex. For more background see <cit.>.

The construction works as follows: choose a basis set L_j for each vector space 𝒞_j.
The L_j basis sets are the levels and the basis elements the pins.
Then use the boundary map, ∂, to define binary relations, R_j,j+1⊂ L_j× L_j+1, where (p_j,p_j+1)∈ R_j, j+1 if p_j appears in the decomposition of  ∂ (p_j+1 ) over the basis set L_j.
Then the relation F⊂ L_0×⋯× L_D is defined as follows

    F = {(p_0,…,p_D)|∀ j,  (p_j,p_j+1 )∈ R_j,j+1}.

The relation F obtained like this is almost a pin code relation.
All the pinned sets of type t = {0,…,D}∖{j} with 0<j<D have even cardinality since their size is given by the number of paths between the pin p_j+1 and the pin p_j-1 which has to be even by the property of the boundary map ∂ given in (<ref>).
For pinned sets of type T = {1,…,D} or T = {0,…,D-1} it is not generally the case that they have even cardinality.
Although this can be easily fixed by adding at most two pins:
the idea is then to add one rank-0 pin, b_0, in the level L_0 and add all pairs (b_0,c^⋆) such that

    |{p_0 | (p_0,c^⋆)∈ R_0,1}| = 12,

to the new relation R_0,1.
Then do the same for the level D, adding b_D in L_D.
After this modification the resulting flag relation F is a pin code relation.



Note that this way of obtaining a quantum code from any 𝔽_2 chain complex is fundamentally different from the usual homological code construction.
In the homological code construction one chooses one of the levels, say L_j, and identifies its elements with qubits.
Then the Z-stabilizer generators are given by the boundary of the elements in L_j+1 and the X-stabilizer generators by the coboundary of the elements in L_j-1.
These are different from the flags and pinned sets used to define a pin code.

In Sec. <ref> we give some explicit pin codes constructed from chain complexes.



 §.§ Remarks


While some flag relations F obtained from Coxeter groups can be equivalently viewed as coming from some 𝔽_2 chain complex, the converse does not necessarily hold.
Indeed not every multi-ary relation can be decomposed into a sequence of binary relations, the hexagonal lattice depicted in Fig. <ref> is an example of such a relation which cannot be decomposed this way.
The other way around, not all flag relations obtained from a 𝔽_2 chain complex can be seen as coming from a Coxeter groups as in general they would lack the regular structure required. 

Depending on the pin code relation, F, it can happen that some pinned sets can in fact be safely split when defining the stabilizers.
That is to say, one can separate them into several disjoint sets of flags defining each an independent stabilizer still commuting with the rest of the stabilizers.
For example this is the case for Coxeter groups for which (<ref>) is strict, i.e.

    ⟨a_i_1,…,a_i_s⟩∩⟨a_j_1,…,a_j_t⟩⊋
    ⟨a_i_1,…,a_i_s∩a_j_1,…,a_j_t⟩.

In this case the cosets with respect to the first group can be further split into cosets with respect to the second one without harming the commutation relations.
Groups generated by reflections for which (<ref>) is always an equality are called C-groups <cit.>.
If the stabilizers are still defined as whole pinned sets, in cases where they could be split, then these smaller sets of qubits would be logical operators which would be detrimental to the overall distance of the code.



§ TRANSVERSAL GATES AND MAGIC STATE DISTILLATION



In this section we present independently of pin codes what structure is desirable for CSS codes to admit transversal phase gates of different levels of the Clifford hierarchy.
The presentation here is close in spirit to that of <cit.>.
It is included here to fix terminology and to be self-contained.

Given ℓ binary row vectors, v^1, …, v^ℓ∈𝔽_2^n, we denote their element-wise product as, v^1∧⋯∧v^ℓ, its j^th entry is given by

    [⋀_m=1^ℓv^m ]_j = [v^1∧v^2∧⋯∧v^ℓ ]_j = v_j^1v_j^2⋯ v^p_j.

The Hamming weight of a binary vector v is denoted as |v|, it is given by the sum of its entries.
We also define the notions of multi-even and multi-orthogonal spaces:
[Multi-even space]
	Given an integer, ℓ∈ℕ, a subspace 𝒞⊂𝔽_2^n, is called ℓ-even if all vectors in 𝒞 have Hamming weight divisible by 2^ℓ:
	
    ∀v∈𝒞, |v| = 0 2^ℓ.




	Given ℓ∈ℕ, a subspace 𝒞⊂𝔽_2^n is ℓ-even if and only if for any integer s∈{1,…,ℓ} and any s-tuple of vectors, (v^1,…,v^s)∈𝒞^s, it holds that
	
    |v^1∧⋯∧v^s| = 0 2^ℓ - s +1.


The proof is deferred to Appendix <ref>, it makes use of the following convenient lemma for converting binary addition to regular integer addition.

	Denote binary addition with ⊕ and integer addition with + or ∑.
	Given r binary vectors w^1,…,w^r∈𝔽_2^n it holds that
	
    ⊕_m=1^rw^m = ∑_s=1^r(-2)^s-1∑_1≤ m_1<⋯<m_s≤ r ⋀_i=1^sw^m_i.

	Similarly for their Hamming weights
	
    |⊕_m=1^rw^m| = ∑_s=1^r(-2)^s-1∑_1≤ m_1<⋯<m_s≤ r |⋀_i=1^sw^m_i|.


The proof of this lemma is deferred to Appendix <ref> where we also give an illustrative example.
The alternative characterization given in Prop. <ref> for a multi-even space, as per Def. <ref>, shows that some strong divisibility conditions on the overlap between vectors of the space have to be imposed.

It is possible to relax these conditions and define what is called a multi-orthogonal space.

[Multi-orthogonal space]
	Given an integer, ℓ∈ℕ, a subspace 𝒞⊂𝔽_2^n, is called ℓ-orthogonal if for any ℓ-tuple of vectors, (v^1,…,v^ℓ )∈𝒞^ℓ,
	
    |v^1∧⋯∧v^ℓ| = 0  2.



These two characterizations, Prop. <ref> and Def. <ref>, are expressed as conditions on any tuple of vectors from the space.
Although it is strong enough to verify the conditions only on a basis of the space, which is proven in Appendix <ref>.


	It is necessary and sufficient to verify (<ref>) or (<ref>) on a basis to ensure that a space is multi-even or multi-orthogonal respectively.


The single-qubit phase gates are denoted as

    R_ℓ = [   1   0;   0 ω_ℓ ],    ω_ℓ = ^i2π/2^ℓ.

For instance R_1 = Z, R_2=S and R_3 = T in the usual notations.




 §.§ Weighted polynomials and transversal gates


Given k qubits and some integer ℓ, we consider quantum gates, U_F_ℓ, acting diagonally on the computational basis, such that for x∈𝔽_2^k,

    U_F_ℓ|x⟩ = ω_ℓ^F_ℓ(x)|x⟩,

where F_ℓ is a so-called weighted polynomial of the form

    F_ℓ(x)   = ∑_s=1^ℓ2^s-1∑_1≤ m_1<⋯<m_s≤ℓα_m_1… m_s· x_m_1⋯ x_m_s,

with coefficients α_m_1… m_s in 𝔽_2^ℓ.
Any such gate U_F_ℓ belongs to the ℓth level of the Clifford hierarchy <cit.>.
Examples, and generating set for ℓ=3, are given in Table <ref>.


The goal is to implement such a gate on the logical level of a quantum error correcting code by the transversal application of some phase gates.
A transversal application of the single-qubit phase gate R_ℓ means that each qubit is acted on with R_ℓ, which amounts to applying the tensor product R_ℓ^⊗ n = R_ℓ⊗⋯⊗ R_ℓ on the full system.
Given an n, k, d quantum CSS code, define G as the r× n matrix whose rows describe a generating set of the X-stabilizers of the code, and define L as the k× n matrix whose rows describe a basis for the X-logical operators.
The code state in this basis corresponding to x∈𝔽_2^k can then be expressed as

    |x⟩ =1/√(2^r)∑_y∈𝔽_2^r|xL⊕yG⟩.


Applying transversally the gate R_ℓ on this code state, |x⟩, yields

    R_ℓ^⊗ n|x⟩ = 1/√(2^r)∑_y∈𝔽_2^rω_ℓ^|xL⊕yG||xL⊕yG⟩.

Using (<ref>), the power of ω_ℓ above can be rewritten in three parts as 

    |xL⊕yG| = F_ℓ(x) + F^'_ℓ(y) + F^''_ℓ(x,y),

where we defined

    F_ℓ(x)    = |xL|
    
    F^'_ℓ(y)    = |yG|
    
    F^''_ℓ(x, y)    = -2|xL∧yG|


Using again (<ref>), one can express these three parts as weighted polynomials whose coefficients are given by the different overlap between X-logical operator generators, between X-stabilizer generators or between both, see Appendix <ref>.

Provided that it is possible to cancel the action of F^'_ℓ(y) and F^''_ℓ(x,y) then the resulting operation would correspond to the gate U_F_ℓ on the logical qubits of the code.
The following two properties of CSS codes are designed to get rid of these two unwanted parts.

	Let 𝒞 be a CSS code, given an integer ℓ, the code 𝒞 allows for the transversal application of R_ℓ if the following conditions hold:
	
		
  * The X-stabilizers form an ℓ-even space.
		
  * Element-wise products of a X-logical operator and a X-stabilizer always have Hamming weight divisible by 2^ℓ-1.
	
	The gate performed at the logical level is then given by the weighted polynomial in (<ref>).

Indeed the two conditions above exactly give

    F^'_ℓ(y) = F^''_ℓ(x,y) = 0 2^ℓ,

which precisely enforce that the actions of F^'_ℓ(y) and F^''_ℓ(x,y) are trivial.
We can also settle for a weaker condition under which the unwanted part is not trivial but belong to the (ℓ-1)th level of the Clifford hierarchy.

	Let 𝒞 be a n,k,d CSS code, with r× n generating matrix, G, for its X-stabilizers and k× n generating matrix, L, for its X-logical operators.
	Given an integer ℓ, the code 𝒞 allows for the transversal application of R_ℓ up to a (ℓ-1)th-level Clifford correction if the following conditions hold:
	
		
  * The X-stabilizers form an ℓ-orthogonal space.
		
  * For any choice of s≥1 X-logical operators and t≥1 X-stabilizers with s+t≤ℓ
		
    |⋀_i=1^s L^m_i⋀_j=1^tG^n_j| = 0    2.

	
The gate performed at the logical level after correction is then given by the weighted polynomial in (<ref>).

Indeed, under this condition it follows that, see Appendix <ref>

    ω_ℓ^F^'_ℓ(y)+F^''_ℓ(x,y) = ω_ℓ^2F̃_ℓ - 1(x,y) = ω_ℓ-1^F̃_ℓ - 1(x,y),

where F̃_ℓ-1 is a properly weighted polynomial which defines a (ℓ -1)th-level Clifford correction to be applied.
The exact correction is given by the conjugation of U_F̃_ℓ-1 by a decoding circuit for 𝒞, see <cit.>.
Note that we can also define intermediate conditions so that the correction belongs to the (ℓ - q)th level of the Clifford hierarchy for some 1≤ q ≤ℓ.
Here we have just defined the two extreme ones, for which the correction belongs either to the 0th level or the (ℓ-1)th level of the Clifford hierarchy.
Propositions <ref> and <ref> where stated in slightly different form in <cit.>.



 §.§ Magic-state distillation


Given a code which exhibits exact transversality or quasi-transversality it is possible to devise magic-state distillation protocols.
We describe briefly a variant here, see also <cit.>.

A magic state enables the implementation of some gate on another state.
The most common example is the state |A⟩ = T|+⟩ which can be used to implement a T gate using only a CNOT gate, a measurement and possibly a S correction (see for example Figure 2 of <cit.>).
If one uses a CSS code to encode information then the CNOT gate on the encoded level can be done transversally between two encoded blocks.
The main difficulty lies in obtaining an encoded magic state of good quality.

The usual starting point is one logical qubit being encoded in a base code chosen to protect them from noise and with access to fault-tolerant implementations of all Clifford gates.
Then a common protocol consists in concatenating the base code with a distillation code, say of parameters n,k,d, which admits the implementation of logical T gates on the encoded level by applying T gates to the physical qubits.
Then using n possibly low fidelity magic states encoded in the base code, one applies a transversal T gate on |+⟩ states at the level of the distillation code using the circuit described in the previous paragraph.
Measuring the checks of the distillation code conditioning on seeing a trivial syndrome and decoding to the base code one obtains k magic states encoded in the base code of better quality.

Provided that the quality of the initial magic states is not too low, repeating the protocol sufficiently many times will reach any desired accuracy.
Then the amount of resources spent will directly depend on the parameters of the distillation code n,k,d.
The efficiency of the protocol is often summarized in just one quantity:

    γ = log(n/k)/log(d),

since the average number of output distilled magic states at a desired accuracy, ϵ_ out, per initial noisy magic state is given by 1/O (log(ϵ_ out^-1 )^γ).
Hence, the smaller γ the more efficient the distillation protocol.
Previously it was conjectured that γ has to be at least 1. 
However, it has recently been shown that γ<1 is achievable <cit.>.



 §.§ Puncturing techniques



As explained above, most magic state distillation procedures rely on a distillation code which is a CSS code for which the T gate is transversal and correspond to a transversal T gate on the logical level of the code.
These codes are called tri-orthogonal codes <cit.>, and rely on 3-orthogonal or 3-even spaces.

In more details and stated in general for the R_ℓ gate, this n,k,d distillation code, 𝒞_ distill., has to fulfill the conditions of exact transversality as per Prop. <ref> as well as having 

    |xL| = ∑_j=1^k x_j 2^ℓ,

where L is a k× n generating matrix for the X-logical operators of 𝒞_ distill..
Fulfilling the exact transversality conditions of Prop. <ref> ensures that one can transversally apply the R_ℓ gate on the code and (<ref>) ensures that the resulting operation on the logical level is the transversal R_ℓ gate.
If one has easy access to operations in the (ℓ-1)th level of the Clifford hierarchy (as is usual in the case ℓ=3) then the following weaker conditions are enough.
The code 𝒞_ distill. has to fulfill the conditions of quasi-transversality as per Prop. <ref> as well as having

    |xL| = ∑_j=1^k x_j 2.


Starting from an ℓ-even, ℓ-orthogonal space respectively, it is simple to obtain such codes by puncturing them <cit.>.
We describe this technique here and will apply it to some ℓ-orthogonal spaces obtained from pin code relations in Section <ref>.
The idea goes as follows: consider an ℓ-even subspace of 𝔽_2^n of dimension m and take a m× n generating matrix, G∈𝔽_2^m× n.
Using Gaussian elimination it is always possible to change the basis and put the matrix G in the following form:

    G =     ← k →   ← n → 
    		k ↕   𝕀    G_1
    		r ↕    0     G_0,

where k is some chosen integer such that 1≤ k ≤ m and r=m-k.
To obtain this form one just performs row operations.
This corresponds to puncturing the first k positions of the space but note that one can perform some permutation of the columns before the Gaussian elimination which would yield some different G_0 and G_1 and corresponds to puncturing some other k positions.
The rows of G are a basis of the space and hence, by Prop. <ref>, they verify (<ref>).
We can deduce that the CSS code defined by G_0 as the generating matrix for the X-stabilizers and G_1 as the generating matrix for the X-logical operators verify the exact transversality conditions in Prop. <ref>.
The Z-stabilizers of this code are given by the space dual to the space generated by the rows of both G_0 and G_1.
Moreover one can readily compute that 

    |xL| =  (2^ℓ -1 )∑_j=1^k x_j 2^ℓ.

Note that we did not obtain a transversal R_ℓ on the logical level but rather R_ℓ^-1.
The difference is R_ℓ^2 which is in the (ℓ-1)th level of the Clifford hierarchy.

Starting from a ℓ-orthogonal space instead and going through the same procedure it is straightforward to see that one obtains a CSS code for which R_ℓ is quasi-transversal as per Prop. <ref> and that the logical operation is also the transversal R_ℓ up to a (ℓ-1)th level correction.

These type of codes when used in a distillation procedure distill n magic states into k ones of better quality which depends on the distance of the code that has to be computed independently.




§ PROPERTIES OF QUANTUM PIN CODES



In this section we examine the properties of pin codes.
Since their definition is fairly general, their properties depend on the precise choice of pin code relations F.
We stay as general as possible and state precisely when the pin code relations need to be restricted.



 §.§ Code parameters and basic properties

First we investigate the LDPC (Low Density Parity Check) property.
A code family is LDPC if it has stabilizer checks of constant weight and each of its qubits are acted upon by a constant number of checks.
LDPC codes were first considered by Gallager in the classical setting <cit.>.
For pin codes, both properties depend on the relation F, but it is fairly easy to construct LDPC families.
For instance, pin codes based on Coxeter groups with fixed relations between generators and one growing compactifying relation can be LDPC, see Sec. <ref>.
As another example, pin codes from chain complexes with fixed length D+1, sparse boundary map and growing dimension of the levels are LDPC as well.

Let us examine a simple example: choose some D∈ℕ, a set, C, of size 2m for some m∈ℕ and the complete relation on D+1 copies of C: F=C^D+1.
One can easily verify that the relation F is a pin code relation as C has even cardinality.
The number of flags is n_q = | F| = (2m)^D+1 and the number of x- and z-pinned sets are n_x=D+1x×(2m)^x and n_z =D+1z×(2m)^z.
If one considers growing m then, the code would not be LDPC, but more strikingly the ratio of number of stabilizer checks to number of qubits would go to zero.
This illustrates that for a fixed D the complete relation leads to very high rate and very low distance.
To get interesting codes, one either needs to vary D, or find some other relations with a number of flags growing significantly slower than the complete relation.


Concerning logical operators, we first note that they have even weight.

	Let F be a pin code relation on D+1 sets and let 𝒞 be the associated (x,z)-pin code for (x,z)∈{1,…,D}^2 with x+z≤ D.
	Then the X- and Z-logical operators of 𝒞 have even weight. 


	Let the set L⊂ F represent a X-logical operator, and let T be a type of size z.
	Consider the set, S, of collections of pins given by the projection of type T of the set L,
	
    S = Π_T(L).

	For every s∈ S, the pinned set P_T(s) correspond to a Z-stabilizer and therefore has an even intersection with L.
	Pinned sets of the same type but defined by two different collections of pins are disjoint. 
	Hence, every element in L appear in exactly one of the pinned sets P_T(s) for some s∈ S and so the cardinal of L is even.
	The proof for Z-logical operators is the same.	

One can also prove the following general lower bound on the distance of pin codes.

	
	Let F be a pin code relation on D+1 sets and let 𝒞 be the associated (x,z)-pin code for (x,z)∈{1,…,D}^2 with x+z≤ D.
	Then the minimum distance of 𝒞 is at least 2^min(x,z)+1. 


	Without loss of generality we can assume x≤ z.
	Take any set S_x ⊂ F containing less than 2^x+1 distinct flags:
	
    | S_x| < 2^x+1.

	
	Our goal is to  show that this cannot represent a logical Pauli operator.
	To do so we will exhibit a sequence of pins, each pin in this sequence will successively allow us to eliminate half or more of the remaining flags by pinning.
	All the pins of the sequence will define a pinned set corresponding to a stabilizer with overlap on exactly one flag with S_x showing that S_x cannot be a logical Pauli operator.
	
	Since all the flags in S_x are distinct, there necessarily exists a rank j_x such that |Π_{j_x}(S_x) | > 1, that is to say there exists a level on which they go through at least two different pins.
	We can use the pins in Π_{j_x}(S_x) to partition S_x: 
	
    S_x = _p∈Π_{j_x}(S_x) (𝒫_{j_x}(p) ∩ S_x ).

	Since this is a partition, one of these subsets necessarily contains half or less of S_x.
	That is to say there exists a pin p_x∈ L_j_x such that 
	
    0<| P_{j_x}(p_x) ∩ S_x | < 2^x.

	We define a new set, subset of S_x:
	
    S_x-1 = P_{j_x}(p_x) ∩ S_x,

	which is such that
	
    0<| S_x-1| < 2^x.

	There are then two cases: either | S_x-1| = 1 in which case we stop.
	Otherwise we iterate the process on S_x-1.
	This gives a sequence of ranks (j_x,j_x-1,… ) and pins of corresponding ranks (p_x, p_x-1,… ) and a sequence of sets of flags S_x ⊋ S_x-1⊋⋯ which are such that
	
    S_x-m   = P_{j_x-m+1}(p_x-m+1) ∩ S_x-m+1,
    
    	 0<   | S_x-m| < 2^x-m+1.

	Note that a rank chosen at some step cannot be chosen again at a subsequent step. Indeed by construction |Π_{j_x-k}(S_x-k-1) |= |{p_x-k}| = 1 and since for m≥ k we have S_x-k-1⊋ S_x-m-1 then |Π_{j_x-k}(S_x-m-1) |= |{p_x-k}| = 1.
	From (<ref>) we can infer that we necessarily find a set with only one remaining flag, say f, i.e. S_x-k = {f}, and this in at most x steps, hence we have k ≤ x.
	For this set we have 
	
    {f} = S_x-k   = P_{j_x-k+1}(p_x-k+1) ∩ S_x-k+1
       = P_{j_x-k+1}(p_x-k+1) ∩ P_{j_x-k+2}(p_x-k+2) ∩ S_x-k+2
       ⋮
       = ⋂_m=0^k-1 P_{j_x-m}(p_x-m) ∩ S_x
    {f}   = P_{j_x, j_x-1,… j_x-k+1}(p_x, p_x-1, …, p_x-k+1) ∩ S_x,

	where we used the intersection property, Prop. <ref>, for the last equality.
	Since k≤ x≤ z and using the decomposition proposition Prop. <ref>, the k-pinned set P_{j_x, j_x-1,… j_x-k+1}(p_x, p_x-1, …, p_x-k+1) can represent both a X- and a Z-stabilizer and its intersection with S_x is on only one flag, hence S_x cannot represent a X- nor Z-logical operator.
	This concludes the proof that the distance of the code is at least 2^x+1.


In order to get odd weight logical operators, one has to introduce free pins, see Sec. <ref>.
Note that in the presence of free pins, the proof above does not hold anymore.

Making precise statements about the dimension of pin codes is difficult in general.
To get closer to be able to do this we need to study the structure of the logical operators.



 §.§ Colored logical operators and unfolding






The structure of the logical operators of color codes is understood as colored string-nets or membrane nets <cit.> and this structure is directly linked to an unfolding procedure existing for color codes <cit.>.
This structure mostly remains for all pin codes which means that we can map a given quantum pin code (seen as a chain complex) to several smaller chain complexes whose homological representatives can be lifted to logical operators of the original quantum pin code.
In the case of color codes these mappings fully characterize all logical operators.
While this is not true for a general quantum pin code it can bring insight into the structure of some of its logical operators. 

The general idea is to group qubits into sets with even overlap with all except one sort of stabilizer which will correspond to all stabilizers defined by pinned sets of a given type.
Logical operators build out of these sets then only depend on the structure of the one type of stabilizer selected.
Repeating this for different choices of type of stabilizer fully covers all logical operators in the case of color codes.

Consider a pin code relation, F⊂ L_0×⋯× L_D, and the associated (x,z)-pin code.
Define the complement of a type, T, denoted as T:

    T = {0,…,D}∖ T.

The intersection between a pinned set of type T and a pinned set of type T is either empty or it contains exactly one flag.
Furthermore for any another type with the same number of pins as T, the corresponding pinned sets have necessarily even overlap with pinned sets of type T, see Figs. <ref> and <ref> for visual representations of this.
This means that grouping flags according to pinned set of the complementary type T can single out logical operators only having to ensure commutation with pinned sets of type T.
For our code, X-stabilizers are generated by x-pin sets, which come in D+1x different types.
Take one such type, T_x, and group the qubits according to pinned sets of type T_x.
Now the Z-stabilizers are generated by z-pinned sets, which come in D+1z different types.
Some of these types, we denote them as T_z^ inc., are fully included in T, which means that pinned sets of such type fully contain any group of qubits  they intersect.
The other types only partially intersect with the groups of qubits.
The situation is schematized in Fig. <ref> for D=3, x=1 and z=2.
From these considerations, one can construct a chain complex for which the homology gives candidate Z-logical operators.
Take the pinned sets of type T_x, for the level 0, the pinned sets of type T_x for the level 1, and the pinned sets of types T_z^ inc. for level 2 and the boundary map is given by the overlaps of these sets.
This is represented in Fig. <ref>, we call it the T_x-shrunk chain complex.
Then one can check that an element of the homology of this chain complex can be lifted to a potential Z-logical operator for the pin code.
Indeed it would commute with all the X-stabilizer, by homology for the stabilizers of type T_x and by construction for the other X-stabilizers.
It would also not be simply generated by Z-stabilizers of type T_z^ inc. by homology, and one would have to check for the other Z types.
So it is a valid (potentially trivial) Z-logical operator.

The same procedure can be done for each of the X types.
Symmetrically, the same can be done for the X-logical with the Z types, and this is represented in Fig. <ref> in the  case D=3, x=1 and z=2.

Given a type T, the chain complexes constructed like this are called T-shrunk lattices in the case of color codes <cit.>.
For color codes obtained from the Wythoff construction described in Sec. <ref>, the construction of the T-shrunk lattice is fairly direct.
First move the vertex from the middle of the fundamental simplex to the corner corresponding to the first rank in the type T, then focus on the opposite face: a simplex of dimension one less which now looks exactly like the beginning of the procedure but in a lower dimension.
Recursively exhaust all the ranks of T in this way by each time adding a vertex in the middle of the current simplex and moving it to the corresponding corner.
 
These shrunk lattices are the basis for the unfolding procedure proved for color codes in all dimensions in <cit.>.
This procedure establishes a local unitary equivalence between a color codes and the reunion of the homological codes on the shrunk lattices corresponding to all the different types for X-stabilizers except one.
The local unitary acts separately on groups of qubits defined by the X-stabilizer generators of the type that is not used to produce one of the shrunk lattices.
The proof of the existence of the local unitary relies on the analysis of the so called overlap groups of stabilizers restricted to the support of the X-stabilizer generators aforementioned and the corresponding groups of qubits in the shrunk lattices.
The global structure is still present for general pin codes, but for the proof to hold we need to require that the linear dependency between the generators within the overlap groups in the pin code is such that the number of independent generators agrees with the number of independent generators in the corresponding shrunk lattices as an additional assumption.

These shrunk lattices are also the basis for some color code decoders <cit.> but these decoders rely on a lifting procedure from the shrunk lattices to the color code lattice which seems intrinsically geometric as it consists in finding a surface filling inside a boundary.
So it is at this point unclear how to leverage this structure in order to decode general pin codes.




 §.§ Gauge pin codes
 

In this section we define gauge pin codes from a pin code relation.
Gauge pin codes can also be viewed as a generalization of gauge color codes <cit.>.

A gauge code, or subsystem code, is a code defined by a so called gauge group instead of a stabilizer group <cit.>.
For stabilizer codes, the code states are eponymously stabilized by the stabilizer group which is an abelian subgroup of the group of Pauli operators.
For gauge codes, the gauge group is not abelian and hence all gauge operators cannot share a common +1-eigenspace.
In this case the code states are stabilized by the center of the gauge group.
Gauge operators not in the center of the gauge group would qualify as logical operators in the case of a stabilizer code but are not used to encode information.

Take a pin code relation F and two positive integers x and z such that x+z<D.
The associated pin code has its X-stabilizer generators defined by all the x-pinned sets and its Z-stabilizers generators defined by all the z-pinned sets.
Since the relation F is a pin code relation, by Prop. <ref> any (D-x)-pinned set has an even intersection with any x-pinned set.
So all the (D-x)-pinned sets correspond to some Z-logical operators.
On top of that, they generate all the Z-stabilizers.
Indeed using Prop. <ref> and the fact that D-x>z one shows that the z-pinned sets decompose into disjoint (D-x)-pinned sets.
As such (D-x)-pinned set define naturally Z-gauge operators which can be measured individually and whose outcomes can be recombined to reconstruct the value of the Z-stabilizers defined by z-pinned sets.
Symmetrically, the same happens for (D-z)-pinned sets which have even overlap with z-pinned sets and generate x-pinned sets and therefore can be viewed as X-gauge operators.


	Given a pin code relation F and two natural integers x and z such that x+z<D, one can define a gauge pin code by choosing X-gauge operators to be the (D-z)-pinned sets and Z-gauge operators to be the (D-x)-pinned sets.
	The corresponding stabilizer group for this gauge code contains the x-pinned sets as X-stabilizer generators and z-pinned sets as Z-stabilizer generators.
	The number of logical qubits is at most the number of logical qubits of the (x, D-x)-pin code or of the (D-z, z)-pin code obtained from the same relation F.


	Let us first prove that (D-z)-pinned sets and (D-x)-pinned sets indeed define gauge operators that do not necessarily commute.
	For this, take any qubit in F, say f ∈ F, and any two types T_x and T_z of size | T_x| = D-z and | T_z| = D-x, respectively. 
	Define the two collections s_x = Π_T_x(f) and s_z = Π_T_z(f), and the two (D-z)- and (D-x)-pinned sets, P_T_x(s_x) and P_T_z(s_z).
	One straightforwardly verifies that these pinned sets are constructed such that their intersection is a singleton, more precisely
	
    P_T_x(s_x) ∩ P_T_z(s_z) = {f},

	and they define a X-gauge operator and a Z-gauge operator, respectively, which therefore do not commute with one another.
	
	Let us prove now that the center of the gauge group, i.e. the stabilizer group, contains the x-pinned sets as X-stabilizers and z-pinned sets as Z-stabilizers.
	We have that x<D-z, hence by the decomposition property, Prop. <ref>, x-pinned sets as X operators are generated by D-z-pinned sets which are X gauge operators.
	Similarly, z<D-x and  z-pinned sets as Z operators are generated by D-x-pinned sets which are Z gauge operators.
	Moreover, 
	
    x+(D-x)=z+(D-z)=D,

	and so by Proposition <ref>, the x-pinned sets as X operators and z-pinned sets as Z operators commute with all gauge operators and belong to the center of the gauge group.

Note that the stabilizer group can be larger than the group generated by x-pinned sets as X stabilizers and z-pinned sets as Z stabilizers. 
That is why in turn it can happen that the number of logical qubits is strictly smaller than that of the (x, D-x)-pin code or of the (D-z, z)-pin code from the same relation F.

The error correction procedure for a gauge code with only fully X-type or fully Z-type gauge operators is conveniently performed in two parts.
In one part, one measures the X-gauge operators, reconstructs the syndrome for the X-stabilizers and uses it to correct Z-errors.
In the other part, one measures the Z-gauge operators, reconstructs the syndrome for the Z-stabilizers and uses it to correct X-errors.

The advantages of this procedure in the case of gauge pin codes are two-fold.
First, the weight of the gauge generators, i.e. the number of qubits involved in each generator, is reduced compared to the weight of the stabilizer generators making their measurement easier and less error prone.
Second, the record of gauge operator measurements contains the information of the stabilizer measurements with redundancy.
To understand this redundancy consider a x-pinned set and define k = (D-z)-x.
This is the number of additional levels to pin in order to decompose the x-pinned set into (D-z)-pinned sets.
There are D+1-xk different ways to choose these additional levels to pin and therefore that many different ways to reconstruct the x-pinned set.
This redundancy permits a more robust syndrome extraction procedure which can even become in some cases single-shot, meaning that the syndrome measurements do not have to be repeated to reliably decode <cit.>.
Meaning that even when the measurements are noisy one can measure the gauge operators only once and process the obtained information to reduce the noise enough and proceed with the computation.




 §.§ Transversality


We examine here pin codes in regards of Prop. <ref> and Prop. <ref>.
Nicely, x-pinned sets always have some multi-orthogonality property.

	
	Let F be a (D+1)-ary pin code relation. For any x∈{1,…,D}, the x-pinned sets seen as binary vectors in 𝔽_2^F generate a ⌊ D/x⌋-orthogonal space.


	Given x∈{1,…,D}, we have that x·⌊ D/x⌋≤ D.
	Hence by Prop. <ref>, the intersection of ⌊ D/x⌋ (or less) x-pinned sets is either empty or a pinned sets with at most D pins.
	This pinned set with at most D pins can always be decomposed by Prop. <ref> into a disjoint union of D-pinned sets and hence has even weight as F is a pin code relation as per Def. <ref>.

Interestingly it is also not too difficult to find pin code relations for which the 1-pin sets are D-even.
For example, using a chain complex whose boundary map have even row and column weights and is regular enough will typically suffice.

One could also hope for the second part of Proposition <ref> to always holds.
Unfortunately it holds only partially in general.

	Let F be a (D+1)-ary pin code relation, and consider the associated (x, z)-pin code for x∈{1,…,D} and z=D-x.
	Then for any one X-logical operator, L, and k X-stabilizer generators, G^j, with k≤⌊ D/x⌋-1,
	
    |L∧G^1∧⋯∧G^k| = 0  2.



	Indeed, using Prop. <ref>, the overlap between ⌊ D/x⌋ - 1 (or less) different x-pinned sets is either empty or a pinned set with at most D-x = z pins. Hence by Prop. <ref>, it can be decomposed into z-pinned sets, i.e. Z-stabilizers which have even overlap with X-logical operators by definition.


Overlaps involving more than one X-logical operator do not have such guarantees in general.

Focusing on the case ℓ=3, given the two propositions above the only problematic conditions are the ones of type

    |L^j∧L^k∧G^ℓ| = 0 2.

In order for these terms to hold, one has to have that the intersection of two X-logical operators is always a Z-logical operator.
This is the case for example for euclidean color codes.

In Sections <ref> and <ref> we show how to use the multi-orthogonality properties of pinned-sets to get quantum codes with interesting transversal gates from any pin code relation. 
Another approach would be to restrict the pin code relations in order to devise subfamilies of quantum pin codes for which the condition (<ref>) is fulfilled.



 §.§ Boundaries and free pins



The geometrical notion of colored boundaries existing for color codes can also be generalized to pin codes.
The way to do this is to introduce a specific type of pins which will be called free pins.

Consider the chain complex approach to building pin code relations presented in Sec. <ref>.
In this construction, it is sometimes necessary to add a rank-0 pin b_0 (in the level L_0) or a rank-D pin b_D (in the level L_D) in order to ensure that the relation F is a pin code relation.
The new pin b_0 is linked to all the rank-1 pins which previously where linked to an odd number of rank-0 pins.
So even if the initial boundary relation is sparse, the number of connections to b_0 may be large.
As such the 1-pinned set pinned by this new pin b_0 potentially contains a large number of flags.
To keep the size of the 1-pinned sets under control it is then preferable to not allow to pin b_0 alone.
That is why we then call b_0 a free pin.
Any of the D+1 levels can contain free pins, the chain complex construction potentially put one in L_0 and one in L_D.
The rule for a larger collection of pins is that if it contains at least one non-free pin then it can define a valid pinned set, but if it is composed of only free pins then it is disregarded.
Finally consider when a flag is only composed of free pins, in that case this flag will not enter any valid pinned sets.
Hence such flags must also be discarded.
This is summarized in the following definition.

[Pin code with free pins]
	Let F be a pin code relation defined on D+1 levels of pins.
	Let some of the pins be labeled as free pins.
	Let x and z be two natural integers such that x+z≤ D.
	The associated (x,z)-pin code is defined as follows:
	The elements of F containing at least one non-free pin are associated with qubits.
	All the x-pinned sets defined by a collection of pins containing at least one non-free pin are associated with X-stabilizer generators.
	All the z-pinned sets defined by a collection of pins containing at least one non-free pin are associated with Z-stabilizer generators.


As examples we give a representation of Steane's 7,1,3 code and the 4,2,2 code as a (1,1)-pin codes with free pins in Figure <ref>.



One idea to introduce free pins in every level could be to consider boundary map matrices which are almost sparse except for a small number of row or columns which could be dense.
The basis element corresponding to these would then be labeled as free pins in the construction of the pin code relation.

Note that in the presence of free pins, the proof of Prop. <ref> can only be reproduced when at least one level selected by the chosen type T does not contain any free pin.
So as long as at least one level does not contain any free pin, it still holds that all logical operators have even weight.
When all levels contain at least one free pin then the code may contain odd weight logical operators.

The notion of free pins carries over straightforwardly to gauge pin codes.




§ EXAMPLES AND APPLICATIONS




 §.§ Coxeter groups, hyperbolic color codes


In Section <ref> we discussed the construction of pin codes from tilings and Coxeter groups.
Well-known examples of such code families are color codes on euclidean tilings such as the hexagonal tiling in 2D and the bitruncated cubic honeycomb in 3D.
Using the Wythoff construction we can construct tilings which fulfill right pin code condition and therefore have the correct colorability for defining a color code.



Besides the known euclidean examples we can consider tilings of more exotic spaces.
For the projective plane (cf. <cit.>) there exist two tilings based on the Wythoff construction: The first is based on the symmetry group of an octahedron.
It is an 8,2,2  -code where the check generators correspond to one octagon, two red squares and two green squares, see Figure <ref>.
Note that this code does not quite fit the pin code definition because it contains distinct qubits which would be described by the same flag, for example (d,c,a) on edge 1.
This degeneracy explains why it escapes Prop. <ref>.
The second is based on the icosahedral symmetry group, which gives a a 60,2,6  -code with checks given by 6 decagons (blue), 10 hexagons (green) and 15 squares (red), see Figure <ref>.

Color codes based on two-dimensional hyperbolic tilings were first considered in <cit.> were 3-colorability and 3-valence was postulated (see Figure <ref> for an example).
The Wythoff construction of  Section <ref> allows us to obtain color codes from arbitrary regular tilings of closed hyperbolic surfaces.
To define a family of closed surfaces one needs to compactify the infinite lattice as explained in <cit.>.
There are infinitely many regular tilings of 2D hyperbolic space. 
The lowest weight achievable with our construction is 4.8.10, meaning that checks are squares, octagons and dodecagons.
The smallest code in this family is 120,10,6   based on a non-orientable hyperbolic surface (cf. Table 3.1 in <cit.>).
Another small example is a 160,20,8   code with stabilizer checks of weight 4 and 10 based on a 4.10.10 tiling of an orientable hyperbolic surface of genus 10.

Using the construction outlined in Section <ref> we can consider any D-dimensional hyperbolic reflection group and obtain a tiling which is D+1-colorable and which has a D+1-valent graph.
In particular, we can consider hyperbolic tilings in 3D which are 4-colorable.
There exist four regular hyperbolic tilings in 3D of which two are self-dual tilings and two related by duality.
The self-dual ones are a tiling  by dodecahedra, denoted {5,3,5}, and one by icosahedra, denoted {3,5,3}.
The other are a tiling by cubes {4,3,5} and its dual {5,3,4}.
All of these give rise to codes with maximum stabilizer weight 120.
Here we will focus on the {5,3,5}-tiling, which is the unique self-dual tiling of space by dodecahedra where five dodecahedra are placed around an edge.
Performing the Wythoff construction on a family of closed manifolds, all equipped with a {5,3,5}-tiling yields a code family where checks are of weight 20 and 120.
The weight of the stabilizer is given by the order of the subgroup of the full reflection group which is generated by all except for one of the generators.
The smallest example is a 7200,5526,4 code.




 §.§ Pin codes from chain complexes


In Sec. <ref> we showed how from any 𝔽_2 chain complex one can construct a pin code relation.
In this section we explore some specific examples of chain complexes and the corresponding pin codes.

One way to obtain arbitrary length chain complexes  is to use repeatedly the hypergraph product with a classical code.
The hypergraph product was introduced in <cit.> as a way to turn any two classical codes into a quantum code.
This product can be viewed as the tensor product of chain complexes, which takes two length-2 chain complexes to a length-3 chain complex.
More generally the product of a length-k_1 and length-k_2 chain complexes yields a length-(k_1+k_2-1) chain complex.
This generalization and its characteristics has been studied in the context of homological codes <cit.>.
We consider here the approach of <cit.> but look at the resulting chain complexes from the point of view of pin codes.

The idea goes as follows: consider 𝒜, a 𝔽_2 chain complex of length k, characterized by 𝔽_2-vector spaces (𝒜_j)_0≤ j ≤ k-1 and (k-1) boundary maps ∂^𝒜_j: 𝒜_j →𝒜_j-1, obeying (<ref>).
We now take the product with a chain complex of length 2.
Note that any two vector spaces, ℬ_1 and ℬ_0 and any linear map between them ∂^ℬ: ℬ_1→ℬ_0 defines a length-2 chain complex.
The product, 𝒞=𝒜⊗ℬ, is defined by (k+1) vector spaces 𝒞_j for 0≤ j ≤ k,

    𝒞_j=(ℬ_1⊗𝒜_j-1)⊕(ℬ_0⊗𝒜_j),

with the convention that 𝒜_-1 and 𝒜_k are both the zero vector spaces.
And the k boundary maps, ∂_j^𝒞:𝒞_j→𝒞_j-1, are defined as

    ∀ u    = v⊕ w ∈ (ℬ_1⊗𝒜_j-1)⊕(ℬ_0⊗𝒜_j)
    ∂_j^𝒞(u)    = (𝕀_ℬ_1⊗∂^𝒜_j-1 + ∂^ℬ⊗𝕀_𝒜_j-1)(v) + (𝕀_ℬ_0⊗∂^𝒜_j)(w).

One straightforwardly checks that the ∂^𝒞_j are valid boundary maps, i.e. obeying (<ref>).

Repeatedly taking the product with a length-2 chain complex therefore increase the length of the resulting chain complex each time by one.
Moreover any binary matrix defines a valid 𝔽_2 chain complex of length 2 so this approach allows to explore numerically many pin codes.



We have looked at small binary matrices, up to 3× 4, and their self product to form pin code relations with D=2 and D=3.
We plot in Fig. <ref> the code parameters obtained n,k,d.
The distance is upper-bounded by numerically finding instances of low-weight logical operators.
Strinkingly these codes seem to show a general trend of high encoding rate k/n for a small distance.
Indeed most of them are around 1/2 rate but just distance 4 which is the lower bound guaranteed by Prop. <ref>.
A few of them seem to reach distance 6 or 8 but for significantly smaller rates.
The codes yielding no logical qubits are not displayed in this plot.
Note that this procedure is far from generating all chain complex of a given length.

As a comparison note that in <cit.> one can find codes with parameters such as 104, 52, 10, 104, 26, 15 or 104, 13, 19.
This is to illustrate that even at these high rates (1/2, 1/4 and 1/8) the distance can be higher.
Although these codes have larger stabilizer weights.

We have also looked at a few pin code relations for D=6 using small even size levels and the complete relation for F.
Three notable examples are presented in Table. <ref>.
When writing 2^×6×4 we mean that 6 of the levels contain each 2 pins and the last one contains 4.
Since we use the complete relation, the number of flags and the size of the pinned sets are easily computed as a product of the size of some levels.
The number of logical qubits is computed numerically and for the distance we numerically found low-weight logical operators matching the lower bound of Prop. <ref>.
All these examples give a good indication that the lower bound on the distance is tight.


We also represent the maximum weight of the X-stabilizers for these codes in Fig. <ref>.
When checking for transversal phase gates for ℓ=3, most of the codes examined above do not satisfy (<ref>).




 §.§ Puncturing triply-even spaces




If pin codes in general are not guaranteed to fulfill all the requirements of Prop. <ref> or Prop. <ref>, their stabilizers always form multi-orthogonal spaces, see Prop. <ref>.
This is directly useful as multi-orthogonal spaces together with puncturing techniques can be used to construct codes fulfilling Prop. <ref> (or Prop. <ref> if the space is multi-even), see Section <ref>.
We focus here on 3-even spaces (Def. <ref>) and 3-orthogonal spaces (Def. <ref>) also referred to as triply-even spaces and tri-orthogonal spaces respectively.

In <cit.>, the authors use Reed-Muller codes, ℛℳ(r,m), to obtain initial tri-orthogonal spaces (also triply-even).
Viewed as generated by pinned-set, ℛℳ(r,m) comes from a simple chain complex, represented on the left of Figure <ref>, see also Section <ref>.
This chain complex can be modified in several ways to obtain different pin codes.
We tried different modifications in the case D=6, they are represented in Figure <ref>.
For all of them the 2-pinned sets generate a triply-even space.

We tried to randomly puncture the pin codes obtained from these chain complexes; similarly to <cit.> but without deploying the more advanced techniques.
We were able to find a few interesting codes this way, see Table <ref>, which can be used to distill T magic states.
The obtained parameters γ, see (<ref>), are similar but do not improve on the small examples found in <cit.>.




 §.§ Logical circuits of CCZs



It is also possible to use the property of multi-orthogonality of pinned sets on a given pin code relation in a slightly different way.
The construction proposed for Reed-Muller codes in <cit.> can be directly adapted to general pin code relations.


	Let ℓ>1 and x>1 be two integers and F be a pin code relation on xℓ sets (D = xℓ-1).
	The CSS code defined by (x-1)-pinned sets as X-stabilizer generators and x-pinned sets as X-logical operators satisfies Proposition <ref>.


	We need for the condition (i) to verify first that the (x-1)-pinned sets form a ℓ-orthogonal space.
	According to Proposition <ref>, they form a ⌊D/x-1⌋-orthogonal space and we can compute 
	
    ⌊D/x-1⌋ = ⌊xℓ-1/x - 1⌋ = ⌊ℓ + ℓ-1/x-1⌋≥ℓ.

	Hence (i) is satisfied.
	For the condition (ii) we use the intersection property (Prop. <ref>):
	Taking two integers s and t such that s≥ 1, t≥ 1 and s+t≤ℓ, the intersection of s x-pinned sets with t (x-1)-pinned sets, gives a pinned sets with at most (ℓ -1)x+(x-1) = xℓ-1 = D pins.
	Since F is a pin code relation D-pinned sets are always even.
	This proves (ii).	


Note that the parameters D and x where chosen not only to obtain a code guaranteed to satisfy Prop. <ref> but also where the logical operation realized belongs strictly to the level ℓ of the Clifford hierarchy because  some intersections of ℓ X-logical operators will be exactly one.
Indeed X-logical operators are x-pinned sets so intersecting ℓ of them can give (among other things) any pinned set with xℓ = D+1 pins which are either empty or singletons of one flag.

We can for example adapt the pin code relations presented in Fig. <ref> to have the correct dimension D by inserting or removing levels of size 2 in the middle of the chain complexes and look at what code parameters they give.
These parameters are compiled in Table. <ref>, for D=5 we remove the middle level and for D=8 we add two levels of size 2 compared to Fig. <ref>.
All these codes support the transversal T and up to a Clifford correction the logical operation implemented is some circuit of CCZs characterized by which triple of X-logical operators have an odd overlap.





§ DISCUSSION


Quantum pin codes form a large family of CSS codes which we have just begun to explore.
These codes can be viewed as a vast generalization of quantum color codes and the notions of boundaries, colored logical operators and shrunk lattices all generalize to pin codes.
Pin codes also have a gauge code version with potentially similar advantage as the gauge color codes.
The main property of pin codes is that their X- and Z-stabilizers form multi-orthogonal spaces.
We have presented two concrete ways of constructing pin codes and numerically explored some examples.
Several aspects of pin codes merit further studying.

First is finding restricted families with good parameters and LDPC property.
Exploring other finite groups with even order generators, other families of sparse chain complexes or finding other constructions of pin code relations altogether would help figuring out the achievable parameters for pin codes.

Second one concerns logical operators.
Understanding if some conditions on the pin code relation F can make the logical operators fulfill the second condition of Prop. <ref> or Prop. <ref> would help in the design of codes with transversal gates.
Also, logical operators and boundaries of 2D color codes have a richer structure than the colored logical operators and boundaries that we have explored, it would be interesting to generalize to pin codes with D=2 all the ones presented in <cit.>, as well as for larger D.
Moreover, the structure of colored logical operators plays a key role in decoding color codes <cit.>.
Understanding if it can help in finding efficient decoders for more general pin codes is a natural question.

Finally more extensively exploring tri-orthogonal spaces obtained from pin code relations and puncturing them to obtain good T distillation protocols as well as using them as the basis for T-to-CCZ or other protocols seems promising, as distilling magic state will constitute a sizable fraction of any fault-tolerant quantum computation.






§ PROOFS OF SECTION <REF>


This Appendix contains examples and proofs omitted in Section <ref>.

We first restate and prove Lemma <ref>:
lem:idbinadd[Binary addition and integer addition]
	Denote binary addition with ⊕ and integer addition with + or ∑.
	Given r binary vectors w^1,…,w^r∈𝔽_2^n it holds that
	
    ⊕_m=1^rw^m = ∑_s=1^r(-2)^s-1∑_1≤ m_1<⋯<m_s≤ r ⋀_i=1^sw^m_i.

	Similarly for their Hamming weights
	
    |⊕_m=1^rw^m| = ∑_s=1^r(-2)^s-1∑_1≤ m_1<⋯<m_s≤ r |⋀_i=1^sw^m_i|.


It can be useful to work out an example for (<ref>) and (<ref>), here is one with r=3 and n=4

    [ 0; 0; 0; 1 ]⊕[ 0; 0; 1; 1 ]⊕[ 0; 1; 1; 1 ] = 
    [ 0; 1; 0; 1 ],

which can also be computed in the following way

    [
    [ 0; 0; 0; 1 ] + [ 0; 0; 1; 1 ] + [ 0; 1; 1; 1 ] ]    
    - 2 [
    [ 0; 0; 0; 1 ] + [ 0; 0; 0; 1 ] + [ 0; 0; 1; 1 ] ]   
    + 4[ 0; 0; 0; 1 ]   = 
    [ 0; 1; 0; 1 ] .


	Since the Hamming weight of a binary vector is simply the integer sum of its components we immediately have that (<ref>)⇒(<ref>).
	Moreover since the operations in (<ref>) are component-wise operations it is sufficient to prove it for r binary numbers w^1,…,w^r∈𝔽_2.
	One directly checks that for r=2
	
    w^1⊕ w^2 = w^1 + w^2 - 2 w^1∧ w^2.

	By induction suppose that (<ref>) holds for some r≥2, then we have
	
    ⊕_m=1^r+1w^m =    (⊕_m=1^rw^m )⊕ w^r+1
    
    		=    (⊕_m=1^rw^m ) + w^r+1 - 2 (⊕_m=1^rw^m )∧ w^r+1
    
    		=   ∑_s=1^r(-2)^s-1∑_1≤ m_1<⋯<m_s≤ r ⋀_i=1^sw^m_i + w^r+1
       - 2  (∑_s=1^r(-2)^s-1∑_1≤ m_1<⋯<m_s≤ r ⋀_i=1^sw^m_i )∧ w^r+1
    
    		=   ∑_s=1^r+1(-2)^s-1∑_1≤ m_1<⋯<m_s≤ r+1 ⋀_i=1^sw^m_i,

	where we first used (<ref>) then the induction hypothesis then the distributivity of ∧.

We can now restate and prove Proposition <ref>:
prop:equmultieven[Characterization of multi-even spaces]
	Given ℓ∈ℕ, a subspace 𝒞⊂𝔽_2^n is ℓ-even if and only if for any integer s∈{1,…,ℓ} and any s-tuple of vectors, (v^1,…,v^s)∈𝒞^s, it holds that
	
    |v^1∧⋯∧v^s| = 0 2^ℓ - s +1.



	The characterization given in Proposition <ref> implies the one given in Definition <ref>, hence it suffice to prove the converse.
	The case s=1 is trivially verified, now suppose that for some 1≤ s < ℓ one has for all t≤ s and all (v^1,…,v^t)∈𝒞^t
	
    |v^1∧⋯∧v^t| = 0 2^ℓ - t +1.

	Take s+1 vectors (v^1,…,v^s+1)∈𝒞^s+1, using (<ref>) from Lemma <ref> we can write
	
    (-2)^s|v^1∧⋯∧v^s+1| =   |⊕_m=1^s+1w^m|
    - ∑_u=1^s(-2)^u-1   ∑_1≤ m_1<⋯<m_u≤ s+1 |⋀_i=1^uw^m_i|
    
    		=    0 - 02^ℓ,

	using (<ref>) to verify the divisibility by 2^ℓ of the second part.
	Hence we have
	
    |v^1∧⋯∧v^s+1| = 0 2^ℓ-s.



Finally we restate and prove Proposition <ref>:
prop:basisverif[multi-even/orthogonal space verification on a basis]
	It is necessary and sufficient to verify (<ref>) or (<ref>) on a basis to ensure that a space is multi-even or multi-orthogonal respectively.


	As basis vectors belong to the space it is immediate to check that they necessarily verify (<ref>) or (<ref>) respectively, if the space is multi-even or multi-orthogonal respectively.
	The sufficient proof for both the multi-even and multi-orthogonal cases relies on decomposing vectors over the basis ℬ={b^1,…,b^m} which verifies the property (either (<ref>) or (<ref>)) and using (<ref>) several times.
	Pick s∈{1,…,ℓ} and s vectors (v^1,…,v^s )∈𝒞^s.
	Each of the vectors v^j can be decomposed over ℬ:
	
    v^j = ⊕_i=1^p_jb^k^j_i,

	where p_j is the number of basis elements in the decomposition of v^j over ℬ and the k^j_i their indices.
	We can now rewrite the Hamming weight of the element-wise product by using the decomposition of the v^j and (<ref>) one after the other.
	This is done in (<ref>).
	
	
	Considering expression (<ref>), the case of the multi-orthogonal property is the most straightforward.
	In this case we assume that (<ref>) holds for the elements of ℬ and choose s=ℓ.
	Elements of the sum in (<ref>) with ℓ basis vector in the element-wise product will be even by (<ref>) and the other elements have a prefactor of two.	
	This proves that |v^1∧⋯∧v^ℓ|=0 2 and that the space is ℓ-orthogonal.
	
	For the case of the multi-even property, we assume that (<ref>) holds for the elements of ℬ.
	Elements of the sum in (<ref>) where ∑ q_j ≤ℓ have a Hamming weight for the element-wise product which is zero modulo 2^ℓ - ∑ q_j +1 by (<ref>).
	Moreover they are multiplied by 2^∑ q_j - s and hence are zero modulo 2^ℓ - s +1.
	The other terms have a prefactor of 2^ℓ -s +1.
	Hence |v^1∧⋯∧v^s|=02^ℓ-s+1 and the space is ℓ-even.
	




§ QUASI-TRANSVERSALITY



In this appendix we detail the three weighted polynomial in (<ref>), (<ref>) and eq:Flxy which determine the transversal action of R_ℓ on code states.
Using identity (<ref>) and denoting L^m as the m^th row of matrix L and G^n as the n^th row of matrix G we can write 

    F_ℓ(x)    = |xL|
       = ∑_s=1^ℓ(-2)^s-1∑_1≤ m_i≤ k |⋀_i=1^s L^m_i|∏_i=1^sx_m_i,
    
    F^'_ℓ(y)    = |yG|
       = ∑_t=1^ℓ(-2)^t-1∑_1≤ n_j≤ r |⋀_j=1^t G^n_j|∏_j=1^ty_n_j,
    
    F^''_ℓ(x, y)    = -2|xL∧yG| = 
    ∑_s+t=2
    s≥1, t≥1^ℓ(-2   )^s+t-1∑_1≤ m_i≤ k
    1≤ n_j≤ r |⋀_i=1^s L^m_i⋀_j=1^tG^n_j|∏_i=1^sx_m_i∏_j=1^t y_n_j.


One can readily see that these are all correctly weighted polynomial, i.e. with a prefactor of 2^s-1 in front of monomials of degree s, and their coefficients are given by the size of the overlaps between rows of the matrices L or G. 

We can check that (<ref>) follows from Proposition <ref>.
Indeed, assuming Prop. <ref> holds, then (i) enforces that all coefficients |⋀_j=1^t G^n_j| are divisible by 2 and (ii) that all coefficients |⋀_i=1^s L^m_i⋀_j=1^tG^n_j| also are divisible by 2.
Hence we can pull out a factor 2 in front of everything while keeping the correct prefactor in front of each monomial.




§ ACKNOWLEDGMENT

C.V. would like to thank B. Audoux, E.T. Campbell and L.P. Pryadko for fruitful discussions at different stages of this project.
C.V. acknowledge support by the European Research Council (EQEC, ERC Consolidator Grant No: 682726) as well as a QuantERA grant for the QCDA consortium. NPB is supported by the UCLQ fellowship.






IEEEtran



Christophe Vuillot received the Ph.D. degree in computer science from TU Delft, Netherlands, in 2020.
	Since 2021 he is Chargé de Recherche (junior researcher) at Inria, in Nancy, France.
	His research focuses on fault-tolerant quantum computation.

Nikolas P. Breuckmann obtained the Ph.D. degree at RWTH Aachen University working with Prof. Barbara Terhal on quantum fault-tolerance and quantum complexity theory.
	He has worked in industry at PsiQuantum, a Bay Area-based start-up building a silicon-photonics-based quantum computer. He holds a UCLQ Research Fellowship at University College London.
	He is interested in quantum information and related fields.


