*>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); X, Z, I = alg.X, alg.Z, alg.I 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:
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 on the left.
⁂
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! This is a neat generalization of the algebra of qudits.
Q. Aren't operators just as low-level as circuits?
A. Yes, in the same way gauge theory is equivalent to regular
electrodynamics. The former abstracts the latter.
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.
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. Global phase is fake anyway
(and a source of bugs) so it's no 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 given 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!
⁂
5 Citation
D. Wakeham, Structure and Interpretation of Quantum Programs II:
The Way of Yaw. Torsor Labs, 2026. https://yawlang.dev
D. Wakeham, Structure and Interpretation of Quantum Programs I:
Foundations. Torsor Labs, 2025. arXiv:2509.04527.