---
title: Finite-Field Qudit ZH Calculus
url: https://www.emergentmind.com/topics/qudit-zh-calculus
type: topic
---

# Finite-Field Qudit ZH Calculus

Qudit ZH calculus is a family of diagrammatic languages for quantum processes in which nonlinear arithmetic on basis labels is represented directly by graphical generators. In its finite-field form, it generalizes the ZH calculus from qubits and prime-dimensional qudits to qudits of prime-power dimension $q=p^t$ by replacing cyclic ring semantics over $\mathbb{Z}/q\mathbb{Z}$ with field semantics over $\mathbb{F}_q$. This replacement preserves multiplicative invertibility of nonzero elements, which is operationally significant for algorithms that require division, and yields a universal graphical language for linear maps $\mathbb{C}^{q^n}\to\mathbb{C}^{q^m}$ with entries in $\mathbb{Z}[\omega]$, up to normalization factors, where $\omega$ is a primitive $p$th root of unity [2406.02219].

## 1. Historical development and conceptual position

The ZH calculus belongs to the same diagrammatic lineage as the ZX and ZW calculi. ZX is tailored to linear gates and complementary observables, whereas ZH emphasizes classical nonlinearity by introducing H-boxes whose semantics realize multiplication on computational-basis labels. In the qubit setting, Z-spiders copy basis states and H-boxes encode Boolean AND, so Toffoli-like structure becomes diagrammatically simple [2406.02219].

The first systematic qudit generalization considered prime dimensions. For prime $d$, the phase-free qudit ZH calculus generalizes the qubit rules, is universal for matrices over $\mathbb{Z}[e^{2\pi i/d}]$ up to global $(1/\sqrt{d})^K$ factors, and is tightly connected to circuits generated by the two-qudit $|0\rangle$-controlled $X$ gate and the $d$-dimensional Hadamard $H_d$. In odd prime dimension, the gate set $\{C_{|0\rangle}(X),H_d\}$ is approximately universal, and phase-free ZH diagrams correspond exactly to postselected circuits over that gate set with ancillas in $|0\rangle$ and postselection onto $\langle 0|$ [2307.10095].

A different line of development used discrete-integral semantics to define a unified ZXH-calculus for any fixed qudit dimension $D>1$, including composite dimensions. In that approach, qudit ZX and qudit ZH share a scalar-exact semantics based on a discrete measure, with white and gray dots, multicharacter H-boxes, and rewrite systems that remain meaningful even when $D$ is composite [2304.03310].

The finite-field formulation for arbitrary prime powers addresses a specific gap in these earlier approaches. Roy’s prime-dimensional calculus uses the isomorphism $\mathbb{F}_p\cong \mathbb{Z}/p\mathbb{Z}$, but that identification ceases to be available when $q=p^t$ with $t>1$. Conversely, cyclic-ring approaches over $\mathbb{Z}/q\mathbb{Z}$ handle arbitrary dimensions but do not implement genuine field arithmetic when $q$ is not prime. The finite-field qudit ZH calculus therefore isolates the case in which the computational basis is indexed by $\mathbb{F}_q$ itself, rather than by a cyclic ring, and makes the field structure diagrammatically available [2406.02219].

## 2. Finite-field semantics and generators

Fix $q=p^t$ with $p$ prime, choose a primitive element $\kappa\in\mathbb{F}_q$ such that $\mathbb{F}_q=\mathbb{F}_p(\kappa)$, and identify the qudit Hilbert space with $\mathbb{C}[\mathbb{F}_q]$, whose computational basis is $\{|i\rangle:i\in\mathbb{F}_q\}$. Let $\omega$ be a primitive $p$th root of unity. The scalar ring is $\mathbb{Z}[\omega]$, and for normalized H-boxes one adjoins $q^{-1/2}$ to account for Fourier normalization [2406.02219].

In the 2024 finite-field presentation, phases are mediated by an $\mathbb{F}_p$-valued symmetric bilinear pairing
\[
(-|-):\mathbb{F}_q\times \mathbb{F}_q\to \mathbb{F}_p,
\]
defined as the dot product of coordinate vectors in the basis $\{1,\kappa,\dots,\kappa^{t-1}\}$. With this choice, the basic generators are the Z-spider
\[
Z_{n\to m}:=\sum_{i\in\mathbb{F}_q}|i\rangle^{\otimes m}\langle i|^{\otimes n},
\]
which copies computational-basis states, and the generalized H-spider
\[
H_{n\to m}:=q^{-1/2}\sum_{i_1,\dots,i_n}\sum_{j_1,\dots,j_m}
\omega^{(j_1\cdots j_m\,|\, i_1\cdots i_n)}
|j_1\rangle\cdots|j_m\rangle\langle i_1|\cdots\langle i_n|,
\]
where the products are taken in $\mathbb{F}_q$. The one-wire case $H_{1\to 1}$ is unitary, and $H_{n\to m}$ is self-transpose up to exchanging inputs and outputs because the pairing is symmetric [2406.02219].

A distinguished state, the $\kappa$-lollipop,
\[
L_\kappa:=q^{1/2}|\kappa\rangle,
\]
is included because powers of $\kappa$ generate all nonzero field elements when $q$ is not prime. The calculus also admits phased H-boxes $H_{n\to m}(r)$ for labels $r$ in a ring $R$ containing $\mathbb{Z}[\omega,q^{-1/2}]$ [2406.02219].

A closely related formulation appears in the 2026 characterization via Graphical Algebraic Geometry, where the H-spider is written using the field trace $\mathrm{tr}_{q/p}:\mathbb{F}_q\to\mathbb{F}_p$:
\[
H_{n,m}\mapsto \frac{1}{\sqrt{q}}\sum \omega^{\mathrm{tr}((j_1\cdots j_m)(i_1\cdots i_n))}
(|j_1\rangle\cdots |j_m\rangle)(\langle i_1|\cdots\langle i_n|),
\]
and the special $1\to 1$ case is the discrete Fourier transform over $\mathbb{F}_q$ with entries $q^{-1/2}\omega^{\mathrm{tr}(jk)}$ [2605.13993].

The special cases reproduce the expected lower-dimensional calculi. For qubits, $p=q=2$, $\omega=-1$, and the pairing reduces to the usual mod-$2$ dot product, so the H-box yields Boolean AND and the X-spider yields XOR. For qutrits, $\omega=e^{2\pi i/3}$ and the calculus recovers addition and multiplication in $\mathbb{F}_3$. For $q=4$, taking $\mathbb{F}_4=\mathbb{F}_2(\kappa)$ with $\kappa^2+\kappa+1=0$ exhibits the genuinely non-prime case in which every nonzero element remains invertible even though the dimension is composite [2406.02219].

## 3. Arithmetic encoding, Fourier structure, and rewrite principles

The finite-field qudit ZH calculus is designed so that addition and multiplication arise as small derived diagrams. An X-spider, constructed from Z-spiders and H-spiders, acts as addition on the computational basis. The unary X gadget implements negation,
\[
\sum_{i\in\mathbb{F}_q}|-i\rangle\langle i|,
\]
and the binary X gadget implements
\[
\sum_{i,j\in\mathbb{F}_q}|i+j\rangle\langle i|\langle j|.
\]
Likewise, a binary H gadget followed by $H^\dagger$ implements multiplication,
\[
\sum_{i,j\in\mathbb{F}_q}|i\cdot j\rangle\langle i|\langle j|,
\]
while a $0\to 1$ H gadget followed by $H^\dagger$ yields $|1\rangle$ [2406.02219].

The arithmetic Fourier transform underlying these constructions is governed by the orthogonality identity
\[
\sum_{k\in\mathbb{F}_q}\omega^{(j|k)}=
\begin{cases}
0,& j\neq 0,\\
q,& j=0.
\end{cases}
\]
This identity drives many contractions and is the finite-field analogue of the Fourier cancellations familiar from qubit and prime-qudit diagrammatics [2406.02219].

A subtlety specific to non-prime prime powers is the failure of flexsymmetry. Over $\mathbb{F}_q$ with $t>1$, one does not generally have $(ij|k)=(j|ik)$, so H-boxes are not flexsymmetric. The remedy is a canonical dualizer
\[
D:=\sum_{j\in\mathbb{F}_q}|M_j^\top 1\rangle\langle j|,
\]
where $M_j:x\mapsto j\cdot x$ and $M_j^\top$ is its transpose with respect to the bilinear pairing. This compensates for the asymmetry and gives a controlled replacement for naive wire-bending symmetry [2406.02219].

The equational theory includes nine core rewrite rules corresponding to elementary algebra over $\mathbb{F}_q$: Z-spider fusion, the identity rule for the $1\to 1$ Z-spider, the characteristic-$p$ rule, H-spider fusion, the Frobenius splitting rule $j^q=j$, copying through the computational basis, two bialgebra-like laws for addition and multiplication, and phase multiplication on Z-spiders. The calculus also supports derived Fourier-copy behavior and scalar gadgets for assembling powers of $q^{\pm 1/2}$ [2406.02219].

For arbitrary fixed dimension $D>1$, the discrete-integral approach supplies a different but related qudit ZH semantics. There the white dot copies in the computational basis, the gray dot enforces a sum-to-zero constraint modulo $D$, generalized-not dots implement affine negation, and multicharacter H-boxes carry amplitudes $\omega^{c t}$. Choosing the measure parameter $\nu=D^{-1/4}$ makes the Fourier transform unitary and yields scalar-exact versions of white fusion, gray fusion, white-gray bialgebra, color change via unit-labeled H-boxes, and H-box multiplication [2304.03310].

## 4. Universality, synthesis, and normal-form considerations

The central expressivity theorem for the finite-field calculus states that if $q=p^t$, $\omega=e^{2\pi i/p}$, and $R=\mathbb{Z}[\omega,q^{-1/2}]$—or $\mathbb{Z}[\omega]$ up to normalization factors—then every linear map
\[
M:\mathbb{C}^{q^n}\to\mathbb{C}^{q^m}
\]
with entries in $R$ is representable by a diagram in the phased finite-field ZH calculus [2406.02219].

The proof is constructive. First, an arbitrary matrix is decomposed as a Schur product of pseudo-binary matrices. Second, each pseudo-binary matrix is encoded by a formula over the field signature $(\mathbb{F}_q,+,-,\cdot,=)$. Third, every such formula is converted into a polynomial $f_\varphi$ satisfying $f_\varphi(i)=0$ iff the formula holds. Fourth, a phase-free diagram computes a test for whether $f_\varphi$ vanishes, using field addition, multiplication, and the map $j\mapsto j^{q-1}$, which sends nonzero elements to $1$ and $0$ to $0$. Finally, a phased H-effect and Choi–Jamiołkowski bending recover the desired linear map. The construction relies essentially on the field structure, especially cyclicity of $\mathbb{F}_q^\times$ and the availability of the normalization scalars used by the Fourier transform [2406.02219].

The prime-dimensional predecessor already established two related universality results. Labeled qudit ZH over a commutative ring $R\supseteq \mathbb{Z}[\omega,1/\sqrt{d}]$ is universal for matrices over $R$, and for prime $d$ the phase-free fragment is universal for matrices over $\mathbb{Z}[\omega]$ up to global powers of $1/\sqrt{d}$. The phase-free proof uses successor gadgets, Pascal-triangle constructions, Schur products of H-labels, and a synthesis of $H(r)$ for arbitrary $r\in\mathbb{Z}[\omega]$ without introducing free labels [2307.10095].

Completeness remains more limited than universality in higher dimensions. For qubits, the phase-free ZH rules are complete for matrices over $\mathbb{Z}$. For prime qudits, the 2023 work proves universality but leaves completeness open. The finite-field calculus for arbitrary prime powers similarly does not claim a full canonical normal form or a finite sound and complete axiom system, although many reductions needed for field addition, multiplication, Fourier manipulations, and scalar normalization are available [2307.10095]. The discrete-integral ZXH framework likewise provides a complete rule set only for selected fragments, notably the ZX stabiliser fragment and a multicharacter fragment of ZH, rather than for the full calculus in arbitrary dimension [2304.03310].

## 5. Circuit correspondences and algorithmic applications

One of the major motivations for qudit ZH is its close relation to reversible arithmetic and generalized Toffoli structure. In prime dimension $d$, the two-qudit gate
\[
C_{|0\rangle}(X)
=
\sum_{c=1}^{d-1}|c\rangle\langle c|\otimes I
+
|0\rangle\langle 0|\otimes X_d
\]
plays the role that the Toffoli gate plays in the qubit setting. For odd $d$, every classical reversible qudit logic circuit can be built from this gate using $O(d^n n)$ many gates and $O(n)$ ancillas, and there are reversible functions requiring at least $\Omega(n d^n/\log n)$ one- and two-qudit gates even with $\Omega(n)$ ancillas. The same work proves that $\{C_{|0\rangle}(X),H_d\}$ is approximately universal for odd prime qudit quantum computing and that phase-free ZH diagrams coincide with postselected circuits over this gate set [2307.10095].

The finite-field calculus sharpens the arithmetic side of this picture by making actual field multiplication available on basis labels. This is exploited in the diagrammatic treatment of polynomial interpolation over $\mathbb{F}_q$. Given a degree-$d$ polynomial
\[
f(x)=a_d x^d+\cdots+a_1 x+a_0,
\]
classically $d+1$ queries suffice and are necessary in the worst case; quantumly, the best known bound quoted in the paper is $d/2+1/2$ queries with bounded error, while Boneh–Zhandry showed that $d$ queries suffice. The finite-field ZH presentation gives a graphical account of a reduction that first lowers to the linear case with $d-1$ classical queries and then uses one quantum query for $f(x)=ax+b$ [2406.02219].

The critical point is that classical Lagrange interpolation depends on inverses:
\[
P(x)=\sum_{i=1}^n y_i \cdot \prod_{\substack{j=1\\ j\neq i}}^n \frac{x-x_j}{x_i-x_j},
\]
and those inverses exist uniformly in $\mathbb{F}_q$ but not in $\mathbb{Z}/q\mathbb{Z}$ when $q$ is composite. For the linear case, the oracle is extended linearly from $F|x\rangle=|ax+b\rangle$ to the controlled query
\[
|x\rangle|y\rangle\mapsto |x\rangle|y+f(x)\rangle.
\]
Starting from the state
\[
\psi_1=\left(q^{-1/2}\sum_{x\in\mathbb{F}_q}|x\rangle\right)\otimes |0\rangle,
\]
one applies the oracle, then a controlled unitary that is trivial on $y=0$ and uses multiplication-by-$y$ together with inverse Fourier transform when $y\neq 0$. Because multiplication by $y$ is invertible precisely for $y\in\mathbb{F}_q^\times$, the controlled transformation is unitary in the required branch. After a non-demolition measurement onto the subspace spanned by $|y\rangle$ with $y\neq 0$, the probability of obtaining $y=0$ is $1/q$; conditioned on $y\neq 0$, the first register returns $a$ with probability $1$ and the second returns $b$ with probability $(q-1)/q$ [2406.02219].

This application is not merely illustrative. It shows that the distinction between field arithmetic and cyclic ring arithmetic is semantically visible at the level of diagrammatic calculi: division-dependent algorithms are naturally expressible in the former but not in the latter [2406.02219].

## 6. Relations to Graphical Algebraic Geometry, alternative semantics, and open problems

A 2026 reformulation places qudit ZH in a broader algebraic setting. Graphical Algebraic Geometry constructs complete graphical languages for commutative algebras, ideals, varieties, and structured spans over finite fields, and then characterizes qudit ZH as a minimal extension of finite-field GAG by adding a single Fourier-basis state and one scalar. In that sense, Graphical Algebraic Geometry is to ZH what Graphical Linear Algebra is to ZX [2605.13993].

More precisely, the extension adds a Fourier-basis Z state
\[
|Z_1\rangle=\sum_{i\in\mathbb{F}_q}\omega^{\mathrm{tr}(i)}|i\rangle
\]
and a scalar interpreted as $q^{-1/2}$. There is a semantics-preserving functor from ZH into this extended GAG language, and two sound rules express that the Fourier-basis state is copied by the classical comultiplication and deleted to $q^{-1/2}$. From these rules one proves that any ZH diagram can be rewritten, up to a power of $q^{-1/2}$, as a pure GAG diagram followed by a single Fourier-basis state at the boundary [2605.13993].

This reduction has an algorithmic consequence for amplitude evaluation. If $D:I\to I$ is a scalar ZH diagram over $\mathbb{F}_q$, then its value can be computed using exactly $q$ queries to an oracle that evaluates closed GAG diagrams, that is, counts $\mathbb{F}_q$-rational points satisfying the corresponding polynomial constraints. The resulting amplitude has the form
\[
\llbracket D\rrbracket
=
q^{-k/2}\sum_{i\in\mathbb{F}_q}\omega^{\mathrm{tr}(i)}\, s_i,
\]
where each $s_i$ is an integer count returned by the oracle. For fixed qudit dimension $q$, this is a constant number of oracle calls [2605.13993].

The comparison with cyclic-ring semantics remains important. The discrete-integral ZXH framework works for every fixed $D>1$ and gives especially simple scalar-exact rules when $\nu=D^{-1/4}$, but its arithmetic is formulated over $\mathbb{Z}_D$, with units and non-units treated uniformly. The finite-field ZH calculus instead singles out the prime-power case and changes the computational-basis arithmetic from cyclic-ring multiplication to multiplication in $\mathbb{F}_q$. The payoff is access to multiplicative inverses for every nonzero basis label; the trade-off is loss of flexsymmetry in non-prime $q$, which must be repaired by the dualizer construction [2304.03310].

Several limitations are explicit in the literature. The finite-field calculus depends on the choice of primitive element $\kappa$ and on the basis-dependent bilinear pairing used to define phases, though any such choice yields a sound calculus. Universality is proved for the phased calculus over $\mathbb{Z}[\omega,q^{-1/2}]$, but completeness is not claimed. Proposed directions include completeness, successor gadgets and synthesis algorithms for the phase-free fragment, stabilizer-like fragments over finite fields, and mixed-wire calculi involving multiple fields or multiple presentations of the same field [2406.02219]. The GAG characterization likewise does not provide a complete rewrite theory for the full qudit ZH calculus itself; its completeness results apply to the nonlinear classical backbone rather than to all of ZH [2605.13993].

Source: https://www.emergentmind.com/topics/qudit-zh-calculus