*>yaw
yaw is a quantum programming language which specifies what operators do and not what
states are. It reduces code complexity, is interoperable between
architectures, and makes error correction first class.
1 Examples
Grover search, with database size \(d\) a functional parameter:
def grover(d, marked):
$alg = qudit(d)
def reflect(P): return I - 2*P
G = reflect(proj(Z, marked)) * (-reflect(proj(X, 0)))
r = int((pi/4)*sqrt(d)) + 1
return measure(Z, (G**r) « char(X, 0))()[1]
Checking Knill-Laflamme for the five-qubit code:
$alg = qudit(2, n=5) stabs = [cycle(k, X[0, 3]*Z[1, 2]) for k in range(4)] P = prod([((@5) I + S)*0.5 for S in stabs]) errs = [E[k] for k in range(5) for E in (X, Z)] def kl(A, B): return scalar(P * A.d * B * P, P) all(kl(A, B) is not None for A in errs for B in errs) # True
Defining the GKP state on a photonic quantum computer:
$alg = <X, Z | unit, braid(-1)> gkp = weylState(lambda a, b: 1 if a % 2 == 0 else 0) gkp | X**2, gkp | Z**2 # (1, 1) gkp | X, gkp | Z # (0, 1)
See SIQP II for more examples.
⁂
2 Installation
Install the repo (requires Python 3.10 or later):
git clone https://github.com/torsor-io/yaw.git cd yaw pip install -r requirements.txt
Run the REPL locally, or explore it here:
python yaw/yaw_repl.py
Compile a .yaw file:
python yaw/y2py.py program.yaw -o program.py python program.py
Import as package:
from yaw import *
⁂
3 SIQP II
This site hosts Structure and Interpretation of Quantum Programs II: The Way of Yaw, a living textbook which develops the language from scratch and uses it to build a canonical set of quantum algorithms. A live table of contents is available by toggling §.
⁂
4 FAQs
Q. Isn't this just a library with fancy syntax?
A. No, it's a different way of thinking about quantum computing and a language to implement that thinking.
Q. Can I keep working with qubits?
A. Sure, but you address them via their Pauli algebra and
corresponding eigenvectors rather than bitstrings.
Q. Can I do continuous variable computing?
A. Yes! See the GKP example above. CV computing is under active development
and not yet fully-fledged, however.
Q. Aren't operators just as low-level as circuits?
A. In the same way that gauge theory is equivalent to regular
electrodynamics. The former gives a more abstract way of thinking
about the latter.
Q. Are there any concrete complexity-theoretic benefits?
A. Using operators can lead to exponential improvements to simulation;
stabilizer circuits/tableaus are a special case.
Q. Presentations are related to the word problem, which is
undecidable, right?
A. Yes, so we restrict to a decidable fragment that happens to include
everything we care about (braided presentations).
Q. How can you actually compile any of this to hardware?
A. Cramming one Hilbert space into another is called error correction,
and the tools for it already exist. Implementation is a work in progress.
Q. Doesn't your approach throw away phase information?
A. Global phase yes, relative phase no. Since global phase is fake
anyway and a source of Heisenbugs, it's no great loss.
Q. Sounds like a lot of hard math…
A. You can get by with high school algebra! Operators are variables
like \(x\) and \(y\) and their behaviour is governed by equations.
Q. What does "yaw" mean?
A. It is a self-conjugating recursive acronym for "Yaw Algebraic
Way". It's also the direction you head.
Q. Where are the solutions to exercises?
A. Coming to the appendix soon, along with further exercises.
⁂
5 How to cite
D. Wakeham, Structure and Interpretation of Quantum Programs II:
The Way of Yaw. Torsor Labs, 2026. yawlang.dev, accessed on {insert.date}.
D. Wakeham, Structure and Interpretation of Quantum Programs I:
Foundations. Torsor Labs, 2025. arXiv:2509.04527.