Lattice Mesh · recorded observables

Observable Ledger

Observable Ledger is the Æ Hive product that publishes Pauli expectations and, separately, finite shot samples, each with the method and the sample size written on the record.

What Observable Ledger owns

Observable Ledger is the publishing surface for numbers that leave the laboratory. It does not own the state. It borrows a State Register, a Bond Contract, or a density table from Noise Channel, evaluates what the caller asked, and writes a record that can be quoted without opening the state again. A record always says which product held the state, which observable, whether the number is an exact contraction or a sample mean, and the tolerance or the sample size.

Exact and sampled figures are different types. A function that returns a bare float is not offered, because callers were merging the two in early notebooks. The script methods expect and sample return records. Printing a record includes the method tag.

Pauli strings

An observable in this release is a real linear combination of Pauli strings. A string is a tensor product of I, X, Y, and Z, written in the notebook as tokens such as Z0, X0*X1*X2, or Y1*Z2. The index is the same little-endian wire index as State Register. A missing wire means I on that wire. Coefficients are real. A complex combination is rejected, because the expectation of a Hermitian operator is real and the product refuses to store the imaginary part as if it were data.

The exact expectation on a pure State Register is the contraction of the amplitude table with the Pauli, divided by the squared norm if the caller has not asserted the norm already. On a density table it is the trace against the operator. On Bond Contract it is the left-to-right contraction described on that product’s page. All three paths print the same record type so a comparison across products is a comparison of numbers plus paths, not a comparison of ad hoc printouts.

Exact ledger for the Aether braid

For |ψ⟩ = (|000⟩ + |111⟩) / √2 the computational-basis populations are balanced on every wire, and the wires are perfectly correlated in the Z basis. The three-wire X string is also sharp because X⊗X⊗X exchanges |000⟩ and |111⟩ and the relative phase in this particular braid is zero.

Table 1. Exact expectations on the Aether braid, before any noise.
String⟨P⟩Why
Z0, Z1, Z20Each wire is 0 half the time and 1 half the time.
Z0*Z1, Z1*Z2, Z0*Z21The two nonzero basis states have even parity on every pair.
X0*X1*X21The state is the +1 eigenvector of that string.
X00A single X on this GHZ-type state has no diagonal in the chosen basis after the rotation, and the expectation vanishes.
Y0*Y10Included as a regression control. The braid built from H and CNOT does not produce this correlation.
Lattice script
record = register.expect(["Z0", "Z0*Z1", "X0*X1*X2", "Y0*Y1"])
record.method          # "exact"
record.values          # [0, 1, 1, 0] within 1e-12
record.source          # "state-register"

After Noise Channel depolarizes wire 0 with strength p, the same call with source density returns ⟨Z0*Z1⟩ = 1−p and ⟨X0*X1*X2⟩ = 1−p, while ⟨Z1*Z2⟩ stays 1. The record’s source field changes to noise-channel, and the map string from that product is copied onto the record so the number is not separated from the channel that produced it.

Samples are a different method

sample(observable, shots, seed) draws independent shots from the distribution defined by the current state and returns the mean, the sample variance, and the seed. The seed is mandatory. A call without a seed is a fault, because an unrepeatable ledger entry cannot be audited. The same seed, state, and observable must reproduce the same bit string list.

For a Z-basis measurement of all wires, each shot is a basis label drawn with probability equal to the squared modulus of that amplitude (or the corresponding diagonal of the density table). The estimator of ⟨Z0⟩ is the mean of (−1)^{bit0} over shots. Its variance for the Aether braid is the variance of a fair ±1 coin, which is 1, so the standard error of the mean after s shots is 1/√s. The record prints that standard error beside the mean. It does not replace the mean with the exact value when the author asked for samples.

Table 2. What a record is required to carry.
FieldExact expectSample
methodexactsample
sourcestate-register, bond-contract, or noise-channelsame
observablecanonical Pauli sumsame
valuecontractionsample mean
tolerance or errornumeric tolerance used in the contractionstandard error of the mean
shots, seedabsentboth present
mapabsent, or the noise sequence if source is noise-channelsame rule

Changing the measurement basis

A shot sample in a basis other than Z is written as a unitary change on a copy of the state, then a Z sample, then the copy is dropped. The record stores the basis-change script as well as the seed. Sampling ⟨X0⟩ therefore rotates wire 0 by the adjoint of Hadamard (or by Rx, depending on the basis helper the caller names) and then samples Z0. Helpers are provided for X and Y on listed wires. A hand-written rotation is allowed and is stored verbatim so the helper is not a hidden convention.

Exact expect of an X or Y string does not need that copy. The Pauli contraction covers it. Authors who want the exact number should call expect. Calling sample and then treating the mean as exact is a mistake the types are meant to make obvious, not a mistake the product will silently correct.

Faults

  • Syntax fault: a token the canonical parser does not know.
  • Support fault: a wire index outside the borrowed state.
  • Hermiticity fault: a non-real coefficient.
  • Seed fault: sample called without a seed, or with a seed that is not an unsigned 64-bit integer.
  • Empty fault: the borrowed state is closed or was never prepared.
  • Mismatch fault: a comparison helper is asked to treat an exact record and a sample record as the same method.

Continue in the laboratory