open-standards/wai/wai-quantum/course/lessons/t-count/lesson.en.md
Transaction Science fb230d8a62 wai-quantum: the circuits course as data, each exercise checked by the engine, and wai-quantum learn in English and Chinese
engine::course reads the course from wai-quantum/course/: 21 lessons from a
first circuit through superposition, entanglement, interference, the standard
algorithms, noise and mitigation, error correction and fault tolerance to
resource estimates, each a Markdown text in English and Simplified Chinese and
an exercise.json with a schema. A check runs each case of an exercise (a
generator's inputs) with its intent and the verdict, measures its constraints
(the gates allowed, counts, the T count, the critique's smells, the resource
estimate's counts), and says what went wrong from the diagnostics, the verdict
and the critique, never from the solution. The tests hold every solution to
pass by proof, every known wrong answer to fail for its stated reason, and
every locale to every text and message.

wai-quantum learn shows, starts, checks, hints and explains a lesson, keeps
progress only on this machine, and speaks the language --lang or LANG names;
the command summaries and docs topics have Chinese translations held to the
English they came from. The verdict gains of_diagnostic for a generator's
refusal. llms.txt names the course.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 08:42:54 -04:00

886 B

Since T gates dominate the cost of a fault-tolerant program, compilers spend much of their effort removing them. Some come out by algebra alone: T·T = S, T⁴ = Z, and T·T† = I. A T gate can also travel through gates it commutes with to meet its partner.

The engine's rewrites do this one step at a time, each step checked on the qubits it touches, so a chain of them proves the result the same circuit:

cat > ts.qasm <<'QASM'
OPENQASM 3.0;
include "stdgates.inc";
qubit[1] q;
t q[0];
tdg q[0];
h q[0];
QASM
wai-quantum rewrite simplify ts.qasm

The compiler goes further (wai-quantum compile): it folds phases across controlled-NOTs, resynthesises small blocks, and writes every rotation that is not a multiple of π/4 as a Clifford+T word within an error budget, with a certificate of every pass. Its T count is what the next lesson's estimate starts from.