Manuscript En02-C@1 · En02-C-v1.tex · section · 7549c6df

Standalone exact finite checks

Standalone exact finite checks · lines 1984–2088

Back to manuscript

target = index_of(bs) out[target] = add(out[target], term) return out

def circuit(v, ops, h=0): for op in ops: v = gate(v, op) h += op[0] == "H" return v, h

def project(v, fixed, survivors): n = nq(v) need(set(fixed).isdisjoint(survivors), "overlapping coordinates") need(set(fixed) | set(survivors) == set(range(n)), "unaccounted coordinates") out = [ZERO] * (1 << len(survivors)) for j, amp in enumerate(v): bs = bits(j, n) if all(bs[q] == b for q, b in fixed.items()): out[index_of(tuple(bs[q] for q in survivors))] = amp return out

def reduced_matrix(v, w, survivors, h): """Reduction of |v><w| divided by 2**h.""" n = nq(v) need(nq(w) == n, "different state dimensions") env = tuple(q for q in range(n) if q not in survivors) size = 1 << len(survivors) groups_v = {} groups_w = {} for j in range(1 << n): bs = bits(j, n) a = index_of(tuple(bs[q] for q in survivors)) e = index_of(tuple(bs[q] for q in env)) groups_v[a, e] = v[j] groups_w[a, e] = w[j] out = [[ZERO for _ in range(size)] for _ in range(size)] for a in range(size): for b in range(size): value = ZERO for e in range(1 << len(env)): value = add(value, mul(groups_v[a, e], conj(groups_w[b, e]))) out[a][b] = (F(value[0], 1 << h), F(value[1], 1 << h)) return out

def pauli_matrix(word, minus=False): n = len(word) size = 1 << n out = [[ZERO for _ in range(size)] for _ in range(size)] for col in range(size): v = [ZERO] * size v[col] = ONE for q, letter in enumerate(word): if letter != "I": v = gate(v, (letter, q)) for row, amp in enumerate(v): out[row][col] = neg(amp) if minus else amp return out

BELL_PREP = ( ("H", 0), ("CX", 0, 3), ("H", 2), ("CX", 2, 4), )

ENCODE_BACK = ( ("Y", 1), ("CX", 2, 1), ("CX", 0, 1), ("H", 0), ("H", 2), ("S", 0), ("S", 2), ("CZ", 0, 1), ("CZ", 1, 2), )

EARLY_DECODER = ( ("H", 1), ("CX", 0, 1), ("SD", 0), ("H", 0), )

def encode_basis(i, injection_only=False): v = [ZERO] * 32 v[8 * i] = ONE # message is physical position 2 ops = BELL_PREP + ENCODE_BACK if injection_only: ops = ops[:-1] # W_2 supplies the final CZ return circuit(v, ops)

def check_prefix_channels(): encoded = [encode_basis(i) for i in (0, 1)] need(all(h == 4 for _, h in encoded), "encoder H count changed") LX = pauli_matrix("ZXZ", minus=True) LY = pauli_matrix("XYX", minus=True) LZ = pauli_matrix("YZY", minus=True)

for i, j in product((0, 1), repeat=2): v, h = encoded[i] w, _ = encoded[j]

Nearby in this section