Technical documentation
How QHoTT works
This page documents the two verification engines, the artifact format, the on-chain program, and the places where the system stops. If you want the plain-language version first, read Start Here.
- 1. The cyclotomic ring Z[omega][1/sqrt(2)]
- 2. Why exact beats approximate for equality questions
- 3. The eight unit phases and global phase
- 4. The gate set and the claim language
- 5. The type theory kernel and the J rule
- 6. Artifacts, canonical JSON and SHA-256
- 7. The Solana program: accounts, PDAs and token gating
- 8. Limitations
1. The cyclotomic ring Z[omega][1/sqrt(2)]
Let omega = e^(i*pi/4), a primitive 8th root of unity. It satisfies omega^4 = -1, so {1, omega, omega^2, omega^3} is a basis for Z[omega] as a free Z-module and every higher power folds back into it. Note that omega^2 = i and omega + omega^7 = sqrt(2); equivalently sqrt(2) = omega - omega^3.
Adjoining 1/sqrt(2) gives the ring QHoTT computes in. An element is stored as
x = (a + b.omega + c.omega^2 + d.omega^3) / sqrt(2)^k
a, b, c, d : bigint
k : non-negative integerAddition lifts both operands to a common k and adds coefficientwise. Multiplication is a convolution reduced modulo omega^4 = -1, with the denominator exponents summing:
(xy).a = x.a*y.a - (x.b*y.d + x.c*y.c + x.d*y.b)
(xy).b = x.a*y.b + x.b*y.a - (x.c*y.d + x.d*y.c)
(xy).c = x.a*y.c + x.b*y.b + x.c*y.a - x.d*y.d
(xy).d = x.a*y.d + x.b*y.c + x.c*y.b + x.d*y.a
(xy).k = x.k + y.kComplex conjugation is the automorphism sending omega to omega^7 = -omega^3, which on coefficients is (a, b, c, d) -> (a, -d, -c, -b). The denominator is real and untouched.
Canonical forms
Representations are not unique: multiplying numerator and denominator by sqrt(2) gives the same value with a larger k. The ring module therefore reduces after every operation, repeatedly scaling the numerator by sqrt(2) and halving while all four coefficients stay even, until no further factor cancels. Zero is normalised to a single representative.
This is the load-bearing step. Once every element is canonical, equality is componentwise comparison of four BigInts and an integer. Equality is decidable, therefore unitarity and circuit equivalence are decidable.
Why Clifford+T lands here
Every generator of Clifford+T has entries in the ring, and the ring is closed under the operations used to build a circuit matrix:
| X, Y, Z, CX, CZ, CCX, SWAP | Entries in {0, 1, -1, i, -i}, all with k = 0. |
|---|---|
| S, S-dagger | diag(1, i) and diag(1, -i), i.e. omega^2 and omega^6. |
| T, T-dagger | diag(1, omega) and diag(1, omega^7). The T gate is the single reason omega is needed at all. |
| H | All four entries are +/- 1/sqrt(2), i.e. k = 1. The Hadamard is the only reason 1/sqrt(2) is adjoined. |
Tensor products and matrix products of such matrices stay in the ring, because the ring is closed under addition and multiplication. So the full 2^n x 2^n unitary of any Clifford+T circuit has entries in the ring, and it can be computed with integers alone. Kliuchnikov, Maslov and Mosca proved the converse direction too: a unitary is exactly implementable in Clifford+T with ancillas precisely when its entries lie in this ring. The representation is not a convenience, it is exactly the right one.
2. Why exact beats approximate for equality questions
A floating point simulator answers "are these two circuits the same?" with a distance. You then choose a tolerance, and the choice is not innocent:
- Too tight and correct circuits get rejected because accumulated rounding exceeded the threshold.
- Too loose and genuinely wrong circuits pass. A circuit differing by a small-angle error, or by one wrong gate in a position where the discrepancy is numerically small, is exactly the failure mode you most want to catch.
- The right tolerance depends on circuit depth, gate order, and the summation order inside the matrix multiply. It is not a property of the mathematics.
With exact arithmetic the question changes shape entirely. There is no threshold because there is nowhere to put one. Two entries are the same canonical quadruple or they are not. When they are not, the verifier performs a scan for the first disagreeing position and returns it as a counterexample with both ring elements printed, so a failure is a located, auditable fact rather than a scalar you have to interpret.
The cost is BigInt arithmetic instead of hardware floats, and coefficients that grow with circuit depth. For the circuit sizes this fragment supports, that cost is irrelevant — the headline 15-gate, 3-qubit Toffoli check completes in well under a millisecond, as the timer on the front page reports from your own machine.
3. The eight unit phases and global phase
The units of Z[omega] that matter here are the eight powers omega^0, ..., omega^7, that is e^(i*k*pi/4) for k = 0..7. These are precisely the global phases reachable by a Clifford+T circuit.
A global phase is physically unobservable: U and c.U with |c| = 1 produce identical measurement statistics in every context. So "equal" has two reasonable meanings, and QHoTT makes you pick:
| Check | Decides |
|---|---|
U = V | Strict equality, entry for entry. Phase differences are reported as failures. |
U = omega^k . V | Equality up to global phase. The verifier scans all eight units and, on success, names the specific k that worked. |
Two points of honesty about this. First, the phase search ranges over eight units and no more, because that is the phase group a Clifford+T circuit can produce — it is not a general-purpose "up to any unit complex number" check. Second, a relative phase, a phase on a controlled branch, is not a global phase and is very much observable; the strict check catches those and the up-to-phase check still catches them, because scaling the whole matrix by a unit cannot repair a relative discrepancy.
Try it: the phase-trap preset on the verifier is S X S = i.X, which fails strict equality against X and passes up to phase, naming omega^2.
4. The gate set and the claim language
Qubit ordering: qubit 0 is the most significant bit of a basis index, so for three qubits index 0b101 denotes |q0=1, q1=0, q2=1>. Circuit width is capped at MAX_QUBITS = 8.
| Gate | Arity | Description | Adjoint |
|---|---|---|---|
| I | 1 | Identity | I |
| X | 1 | Pauli-X (bit flip) | X |
| Y | 1 | Pauli-Y | Y |
| Z | 1 | Pauli-Z (phase flip) | Z |
| H | 1 | Hadamard | H |
| S | 1 | Phase gate, S^2 = Z | Sdg |
| Sdg | 1 | Inverse phase gate | S |
| T | 1 | pi/8 gate, T^2 = S | Tdg |
| Tdg | 1 | Inverse pi/8 gate | T |
| CX | 2 | Controlled-NOT | CX |
| CY | 2 | Controlled-Y | CY |
| CZ | 2 | Controlled-Z | CZ |
| CH | 2 | Controlled-Hadamard | CH |
| SWAP | 2 | Exchange two qubits | SWAP |
| CCX | 3 | Toffoli | CCX |
| CCZ | 3 | Doubly-controlled Z | CCZ |
Controlled gates are applied without materialising a 2^n x 2^n gate matrix: the implementation walks row pairs that differ only in the target bit and whose control bits are all set, applying the 2x2 base matrix in place. SWAP is a row exchange. This keeps a gate application linear in the matrix size rather than cubic.
The source language
qubits 2 # width declaration, must come first
h 0 # gate name, then qubit indices
cx 0 1 # 'cnot' and 'toffoli' are accepted aliases
# comments run to end of lineNames are case insensitive and q0 is accepted for 0. Arity mismatches, repeated qubit indices, out-of-range indices and unknown gates are all rejected at parse time with a line number.
Claims
A claim is a proposition about the circuit's denotational semantics. Each is decided exactly; none has a tolerance.
| Claim | Decided by |
|---|---|
| unitary | Computing U*U with the conjugate transpose and comparing to the identity. |
| identity | Direct comparison against the identity matrix. |
| self_inverse | Comparing U^2 to the identity. |
| cancels_with_inverse | Reversing the gate list, replacing each gate by its tabulated adjoint, and checking the composite is the identity. This also audits the adjoint table itself. |
| classical_reversible | Checking the matrix is a permutation matrix: exactly one entry per row equal to 1, the rest exactly 0. Equivalent to the circuit denoting a reversible Boolean function with no superposition and no phase. |
| equivalent | Entrywise comparison with a second circuit, strictly or over the eight unit phases. |
| commutes_with | Comparing UV with VU. |
| prepares_uniform_over | Comparing column zero of U against the uniform superposition over the listed basis strings. Requires a power-of-two number of targets, since 1/sqrt(3) is not in the ring. |
5. The type theory kernel and the J rule
The second engine is a small Martin-Lof dependent type theory with intensional identity types. It is a bidirectional checker built on normalisation by evaluation: terms are evaluated into a semantic domain with closures, and quoted back to syntax at de Bruijn levels when a normal form or a conversion check is needed.
The core theory:
- A predicative hierarchy of universes
Type 0 : Type 1 : ..., with cumulative subtyping. There is noType : Type, so the usual paradoxes are unavailable. - Dependent functions
(x : A) -> B xand dependent pairs(x : A) * B x, with eta for both. Eta matters more than it looks: it is what makes the contractibility of singletons go through, since the goal mentions(fst s, snd s)where the kernel needss. NatwithnatElim, the only recursion in the language. There is no general recursion and therefore no termination checker is needed.Unit,Emptywith its eliminator, and the identity type.
The J rule
The identity type Id A a b is introduced by refl A a : Id A a a and eliminated by based path induction:
C : (b : A) -> Id A a b -> Type i
d : C a (refl A a)
---------------------------------------------
J A a C d b p : C b p for p : Id A a b
computation rule:
J A a C d a (refl A a) == dIn words: to prove something about an arbitrary path out of a, it suffices to prove it for the constant path at a. The rule is not obvious and it is not negotiable — it is the only way to consume an identity proof.
"Derived from J alone, no axioms"
The prelude contains the standard path infrastructure, and every piece of it is an ordinary term the checker has to accept, not a primitive:
| Lemma | Statement |
|---|---|
| sym | Id A x y -> Id A y x |
| trans | Id A x y -> Id A y z -> Id A x z |
| ap | (f : A -> B) -> Id A x y -> Id B (f x) (f y) |
| transport | (P : A -> Type) -> Id A x y -> P x -> P y |
Each is defined by a single application of J with an appropriate motive. On top of them the prelude proves the groupoid laws (unit, inverse, associativity), functoriality of ap, the contractibility of singletons, and enough arithmetic to show zero is distinct from any successor via large elimination into the universe.
The claim "no axioms" is checked rather than asserted. The explorer computes, for each declaration, the transitive set of constants it depends on and intersects that with the set of declared axioms. The prelude has exactly one axiom, funext, which is genuinely not provable in this theory, and exactly one lemma depends on it. Every other result reports an empty axiom list. The explorer shows this per declaration.
A note on the name. This kernel is MLTT, not HoTT proper. It has the identity type and the path-as-equality reading that motivates homotopy type theory, but it has neither univalence nor higher inductive types. Uniqueness of identity proofs is correspondingly not derivable, which the test suite asserts directly.
6. Artifacts, canonical JSON and SHA-256
An artifact is the complete record of a verification run. The registry stores a 32-byte digest of one, which is only meaningful if the digest is reproducible: two parties holding the same artifact must compute the same bytes.
What enters the digest
Only mathematically load-bearing fields. For a quantum artifact that is the schema identifier, the method string, the circuit width and canonical operation list, the claim identifiers with their outcomes in order, the verdict, and every entry of the unitary in exact ring notation. For a proof artifact it is the schema, the declarations with their names, kinds and types, the sorted axiom list, and the verdict.
Prose is deliberately excluded. Explanations, display labels and per-claim commentary travel alongside the payload but outside it, so rewording a description never invalidates a registered proof. You can watch this happen on the Start Here page.
The serialisation
- Object keys are emitted in lexicographic order at every depth.
- Arrays keep their given order, because order is semantically meaningful for operations and claims.
- No insignificant whitespace.
undefined-valued keys are dropped rather than serialised.
The digest is SHA-256 of the UTF-8 encoding of that string, computed with Web Crypto. The axiom list in a proof payload is sorted before hashing, so axiom discovery order cannot change the digest; a proof that leans on a postulate is intentionally a different object from one that does not.
Why reproducibility is the whole point
A hash that only the producer can recompute is a receipt for nothing. Because the serialisation is pinned, a third party can fetch an artifact, re-run the verifier, recompute the digest, and compare it to the chain record. Agreement means the registered claim is the claim they just checked. Disagreement means the record is void, and the ledger entry is then evidence of precisely who submitted what.
7. The Solana program: accounts, PDAs and token gating
qhott_registry is an Anchor 0.31 program. It records digests. It does not verify anything, and it is not capable of doing so.
| Program ID | FPHpwqiA7HDPYdYnzaavXZjWx7q8dqF8r5LS9cjcLicn |
|---|---|
| Gating mint | 7QDjhZZ29CdgMRgNUFQF8yQfjLXrjiudBq43RgbHpump |
| Token program | TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb |
| Status | Compiles, not deployed. The deploy wallet is unfunded and devnet faucets are rate limited. |
Accounts
| Account | Seeds | Fields |
|---|---|---|
| Registry | ["registry"] | authority, mint, min_balance, proof_count, bump. A singleton. |
| ProofRecord | ["proof", digest] | submitter, digest (32 bytes), kind, qubits, gate_count, claim_count, index, slot, unix_timestamp, uri, label, bump. |
The record PDA is seeded by the digest itself. That single design choice gives the registry its properties for free: the same artifact can never be registered twice, because the second attempt fails at account creation; and the first submitter wins, because account creation is atomic and ordered by the validator. No counter, no auction, no governance.
Instructions
| Instruction | Effect |
|---|---|
| initialize(min_balance) | Creates the singleton registry and pins it to one Token-2022 mint. |
| register_proof(args) | Creates the record PDA for args.digest. Args carry the digest, artifact kind, verified flag, qubit and gate counts, claim count, URI and label. |
| set_min_balance(n) | Authority-only. Adjusts the gating threshold. |
| set_authority(pubkey) | Authority-only. Hands the registry over. |
What register_proof enforces
- The submitter's token account holds the registry's mint (
WrongMint) and is owned by the submitter (TokenAccountNotOwned). - The balance is at least
min_balance(InsufficientBalance). This is the token gate. - The artifact's verdict is verified (
ArtifactNotVerified) and it discharges at least one claim (NoClaims). A wrong proof cannot be registered regardless of balance. - The digest is non-empty (
EmptyDigest), the kind is known (UnknownArtifactKind), and the URI and label are within length bounds.
Note what this does not establish. The program takes the verified flag and the counts on trust from the submitter; it cannot recompute them. What makes the record meaningful is that the digest commits to the full artifact including its verdict, so a submitter who flags a refuted artifact as verified has published a digest that will not match the artifact they claim it is. The chain does not catch the lie; it makes the lie permanent, attributable, and trivially detectable by anyone who re-runs the verifier.
8. Limitations
Every item here is a real boundary. Some are engineering limits that could move; several are hard mathematical boundaries that will not.
Quantum verifier
- Maximum 8 qubits. The unitary has
4^nentries, so 8 qubits is 65,536 exact ring elements per matrix and a matrix product is on the order of8^nBigInt multiplications. This is a hard scaling wall, not a tuning parameter. Verifying a 50-qubit circuit this way is not possible for anyone. - Clifford+T only. An arbitrary rotation
Rz(theta)has entries outside the ring, so it cannot be represented, let alone compared. This is mathematical, not a missing feature: exactness is bought precisely by staying inside the ring. Circuits using arbitrary rotations must first be synthesised into Clifford+T, and the approximation error lives in that synthesis step, outside this tool. - No measurement, classical control, or mid-circuit branching. The object verified is a unitary, which is the complete semantics of a measurement-free circuit and nothing beyond it.
- No noise, decoherence or hardware models. QHoTT says what a circuit means, not what a device will do.
- Uniform superposition claims need a power-of-two target count, because
1/sqrt(3)is not an element of the ring. - The up-to-phase check ranges over eight units only. That is the correct group for Clifford+T, but it is not a general "up to any complex unit" comparison.
- Correct answers to the wrong question are still possible. The verifier decides the claims you select. It has no view on whether those were the claims worth making.
Type theory kernel
- No univalence. The univalence axiom is not assumed and not available. This kernel is MLTT; calling the project QHoTT describes the intellectual lineage and the intended direction, not a claim that univalence is implemented.
- No higher inductive types. No circle, no interval, no truncations, no quotients. Synthetic homotopy theory is therefore out of reach.
- No universe polymorphism. A lemma proved at
Type 0must be restated to be used at a higher level. The test suite pins this behaviour. - No implicit arguments and no unification. Type arguments are written out by hand, which makes the prelude verbose on purpose.
- Only
natElimrecursion. No general recursion, no pattern matching, no inductive type declarations by the user. - Intensional identity. UIP is not derivable, which is correct for this theory and is asserted by a test rather than hoped for.
- One axiom in the prelude. Function extensionality is postulated, because it is genuinely unprovable here. Exactly one lemma depends on it, and the explorer reports that dependency per declaration.
Chain and token
- The chain does not verify. It stores digests. Verification happens in your browser and nowhere else.
- The program is not deployed. It builds under Anchor 0.31, but the deploy wallet has no SOL. The registry page reports live status and degrades rather than erroring.
- The token has not launched. The mint address is a reserved pump.fun vanity address whose account does not exist on mainnet.
- Artifact hosting does not exist yet. The program carries a URI field for it; nothing is hosted.
- The program trusts the submitter's verified flag and counts. It cannot recompute them. The digest is what makes a false submission detectable after the fact.
- None of this makes Solana quantum resistant. Homotopy type theory and post-quantum cryptography are unrelated subjects.
Start Here | Verify | Explorer | Registry | Research Finance