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)]

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 integer

Addition 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.k

Complex 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, SWAPEntries in {0, 1, -1, i, -i}, all with k = 0.
S, S-daggerdiag(1, i) and diag(1, -i), i.e. omega^2 and omega^6.
T, T-daggerdiag(1, omega) and diag(1, omega^7). The T gate is the single reason omega is needed at all.
HAll 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:

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:

CheckDecides
U = VStrict equality, entry for entry. Phase differences are reported as failures.
U = omega^k . VEquality 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.

GateArityDescriptionAdjoint
I1IdentityI
X1Pauli-X (bit flip)X
Y1Pauli-YY
Z1Pauli-Z (phase flip)Z
H1HadamardH
S1Phase gate, S^2 = ZSdg
Sdg1Inverse phase gateS
T1pi/8 gate, T^2 = STdg
Tdg1Inverse pi/8 gateT
CX2Controlled-NOTCX
CY2Controlled-YCY
CZ2Controlled-ZCZ
CH2Controlled-HadamardCH
SWAP2Exchange two qubitsSWAP
CCX3ToffoliCCX
CCZ3Doubly-controlled ZCCZ

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 line

Names 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.

ClaimDecided by
unitaryComputing U*U with the conjugate transpose and comparing to the identity.
identityDirect comparison against the identity matrix.
self_inverseComparing U^2 to the identity.
cancels_with_inverseReversing 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_reversibleChecking 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.
equivalentEntrywise comparison with a second circuit, strictly or over the eight unit phases.
commutes_withComparing UV with VU.
prepares_uniform_overComparing 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:

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)  ==  d

In 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:

LemmaStatement
symId A x y -> Id A y x
transId 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

  1. Object keys are emitted in lexicographic order at every depth.
  2. Arrays keep their given order, because order is semantically meaningful for operations and claims.
  3. No insignificant whitespace.
  4. 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 IDFPHpwqiA7HDPYdYnzaavXZjWx7q8dqF8r5LS9cjcLicn
Gating mint7QDjhZZ29CdgMRgNUFQF8yQfjLXrjiudBq43RgbHpump
Token programTokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb
StatusCompiles, not deployed. The deploy wallet is unfunded and devnet faucets are rate limited.

Accounts

AccountSeedsFields
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

InstructionEffect
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

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

Type theory kernel

Chain and token


Start Here | Verify | Explorer | Registry | Research Finance