---
title: Code Transformation Graph (CTG)
url: https://www.emergentmind.com/topics/code-transformation-graph-ctg
type: topic
---

# Code Transformation Graph (CTG)

A Code Transformation Graph (CTG) is a directed graph whose vertices are CSS codes with parameters $\llbracket n,k,d \rrbracket$, and whose edges represent explicit code transformations articulated via sequences of ZX-diagram rewrites connecting code encoding maps in phase-free ZX normal form. The CTG structure provides a rigorous graphical framework for analyzing interrelations among CSS codes and implementing procedures such as code morphing and gauge fixing, as well as facilitating the derivation of physical implementations of logical operators through diagrammatic means [2307.02437].

## 1. Formal Definition and Construction

Let $\mathcal{C}$ be the class of all CSS codes. The CTG is given by $CTG=(V,E)$ with
- $V = \{ C \in \mathcal{C}\,|\,C\text{ has parameters }\llbracket n,k,d \rrbracket \text{ for some } n,k,d\}$,
- $E = \{ (C_1 \to C_2, R)\,|\,R \text{ is a sequence of ZX-diagram rewrites converting } E_{C_1} \mapsto E_{C_2}\}$.

For each vertex $C \in V$, $E_C: \mathbb{C}^{2^k} \to \mathbb{C}^{2^n}$ is the encoding isometry of code $C$, specified in ZX normal form. This ZX diagram is composed of $m$ Z-spiders (one for each X-type stabilizer generator $S^X_i$), $k$ blue Z-spiders (for the logical X operators $\overline{X}_j$), all connected to $n$ X-spiders corresponding to each physical qubit, with diagrammatic wiring encoding support structure and operator action. 

Edges of the CTG are labeled by the specific ZX-rewrite sequences that witness the transformation from $E_{C_1}$ to $E_{C_2}$. This framework ensures that each transformation is both explicit and directly traceable in the graphical formalism of the ZX calculus [2307.02437].

## 2. Bidirectional Logical-to-Physical Rewrite

A key structural edge in the CTG is induced by the bidirectional rewrite rule (Proposition 3.1 in [2307.02437]). Given any phase-free ZX subdiagram $L$ on the $k$ logical wires, the relation
\[
E_C \circ L = P \circ E_C
\]
holds, where $P$ is the unique “push-through” ZX subdiagram on the $n$ physical qubits, determined using strong complementarity and the ZX-normal form of $E_C$. This rule, denoted (BR), guarantees that any logical operation implementable by $L$ admits an explicit, generally non-transversal, physical realization $P$ in the code. In the CTG, such edges from $C$ to itself are systematically labeled (BR), and they encode the capacity to derive physical circuits or measurements corresponding to arbitrary logical phase-free ZX transformations.

## 3. Code Morphing Transformations

Code morphing constitutes a transformation in which a parent code is altered by the selection and operation on a subset $R$ of its physical qubits. In ZX graphical terms:

- In $E_{C_\text{parent}}$, a subset $R$ of X-spiders (physical qubits) is selected.
- All Z-spiders with support on both $R$ and its complement $\overline{R}$ are “unfused.”
- Identity X-spiders are inserted on newly formed edges, and wires entirely in $R$ are “cut.”

The excised subdiagram yields $E_{C(R)}$ (a “child code”), and the remainder is the morphed code $E_{C\setminus R}$. Both inherit certain logical structure from the parent, with $k$ preserved in $C_{\setminus R}$ and transversal gates inherited accordingly. In the CTG, these “(morph)” edges are recorded as
\[
C=\llbracket n,k,\ldots\rrbracket \xrightarrow{\text{morph on }R} C(R), \qquad
C \xrightarrow{\setminus R} C_{\setminus R}.
\]
A concrete instance is the transformation from the Steane code $\llbracket 7,1,3 \rrbracket$ with $R=\{2,3,6,7\}$ resulting in $C(R)=\llbracket 4,3,1 \rrbracket$ and $C_{\setminus R}=\llbracket 6,1,1 \rrbracket$ [2307.02437].

## 4. Gauge Fixing and Code Switching

Gauge fixing (code switching) in the CTG pertains to transitions between subsystem codes and complementary CSS codes via measurement and recovery procedures. Consider a CSS subsystem code $C_\text{sub}=\llbracket 15,1;3 \rrbracket$ with $r=3$ gauge qubits, generating two associated codes: the extended Steane code $C_\text{ex}$ and the quantum Reed-Muller code $C_\text{qrm}$. The transformation proceeds as:

- ZX-normal form for $E_{C_\text{sub}}$ includes Z-spiders for X-stabilizers, Z-spiders for gauge-X operators $g^X_i$ ($i=1,2,3$), and a blue Z-spider for the logical X.
- The $(\pi\text{-copy})$ rule is applied to gauge Z-spiders based on syndrome outcomes $k_i \in \{0,1\}$, converting them to X-phase $\pi$ spiders.
- The push-through rule (BR) maps these phases back to the logical-gauge layer.
- Measurement (collapsing Z-spiders to $|+\rangle$ or $|0\rangle$) and, if necessary, Pauli recovery, yields either $C_\text{ex}$ or $C_\text{qrm}$ as encoded in edges:
  \[
  C_{\mathrm{sub}} \xrightarrow{+\ \text{(measure }g^X_i,\, \text{apply }(g^Z_i)^{k_i})} C_{\mathrm{ex}},
  \]
  \[
  C_{\mathrm{sub}} \xrightarrow{+\ \text{(measure }g^Z_i,\, \text{apply }(g^X_i)^{\ell_i})} C_{\mathrm{qrm}}.
  \]
Here, $+$ denotes discarding gauge qubits and the bracketed Paulis describe conditionally enacted recoveries read off from the ZX diagram [2307.02437].

## 5. Example: Steane–Reed-Muller Subgraph

An explicit CTG subgraph can be constructed for the codes $\llbracket 7,1,3 \rrbracket$ (Steane), $\llbracket 15,1,3 \rrbracket_\text{ex}$ (extended Steane), $\llbracket 15,1,3 \rrbracket_\text{qrm}$ (QRM), and $\llbracket 15,1;3 \rrbracket_\text{sub}$ (subsystem code), with the following transformations:

| Transformation                | Source                         | Target                              | CTG Edge Label   |
|-------------------------------|--------------------------------|--------------------------------------|------------------|
| Ancilla embedding             | $\llbracket 7,1,3 \rrbracket$  | $\llbracket 15,1;3 \rrbracket_\text{sub}$ | add gauge qubits |
| Gauge-fix X                   | $\llbracket 15,1;3 \rrbracket_\text{sub}$ | $\llbracket 15,1,3 \rrbracket_\text{ex}$  | gauge-fix X      |
| Gauge-fix Z                   | $\llbracket 15,1;3 \rrbracket_\text{sub}$ | $\llbracket 15,1,3 \rrbracket_\text{qrm}$ | gauge-fix Z      |
| Remove ancillas (reverse)     | $\llbracket 15,1,3 \rrbracket_{\ast}$    | $\llbracket 7,1,3 \rrbracket$       | discard ancillas |

Each arrow corresponds to a precise ZX-rewrite process, and the reversibility (by e.g. discarding ancillas) can also be represented as edges in the CTG. This subgraph enables, for instance, algorithmic conversion from Steane to QRM code in order to access a transversal $T$ gate, via the sequence: Steane $\rightarrow$ Subsystem (add ancillas) $\rightarrow$ QRM (gauge-fix Z). The ZX calculus prescribes all measurement and recovery operations along this path [2307.02437].

## 6. Structural and Practical Implications

The CTG organizes the landscape of CSS codes and their relationships as a navigable network of explicit, diagrammatically certified transformations. All fault-tolerant transformations captured by code morphing, gauge fixing, and the bidirectional push-through rule become traceable paths. The edges encode sufficient information to extract the sequence of ZX diagram manipulations (including measurements, wire cuts, and recovery operations) corresponding to code switching or logical gate implementation in physical circuits. This formalism thus serves both as a research tool for investigating code structure and as a practical map for constructing fault-tolerant protocols for universal quantum computation between well-characterized codes [2307.02437].

Source: https://www.emergentmind.com/topics/code-transformation-graph-ctg