Library / State Register / State Register examples

State Register examples

Three scripts the laboratory stores for State Register: the braid, a rotation, and a rejected custom matrix.

Example 1 — Aether braid

Lattice script
register = Lattice.open(width=3, endian="little", ceiling="64 MiB")
register.apply("H", on=0)
register.apply("CNOT", control=0, target=1)
register.apply("CNOT", control=1, target=2)
register.assert_norm(tol=1e-12)
amps = register.amplitudes()

amps[0] and amps[7] equal 1/√2. The other six entries are 0. Index 7 is |111⟩ because wire 0 is the least significant bit.

Example 2 — a declared rotation

Lattice script
import math
register = Lattice.open(width=1, endian="little", ceiling="1 MiB")
register.apply("Rx", on=0, angle=math.pi)
# Rx(π) = −i X, up to the global phase the catalogue commits to:
# |0⟩ maps to −i |1⟩.

The catalogue commits to Rx(θ) = exp(−i θ X / 2), not to a phase convention invented per call. At θ = π the image of |0⟩ is −i |1⟩. Global phase is left in the table. Callers who pin a pivot use the phase-lock described in the essay; it is off by default.

Example 3 — a matrix that must be rejected

Lattice script
bad = [[1, 0], [0, 2]]  # not unitary
register = Lattice.open(width=1, endian="little", ceiling="1 MiB")
register.apply("custom", matrix=bad, wires=[0])  # Unitary fault
# the register is unchanged, still |0⟩

There is no flag that writes the non-unitary and continues. If you need a non-unitary map, it belongs in Noise Channel’s catalogue, not in a custom matrix on State Register.