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

Standalone exact finite checks

Standalone exact finite checks · lines 2163–2255

Back to manuscript

def check_swap_HP(iterations): # Positions: R, C, D, E, F, recovered M. # After the physical SWAP, prepare Bell pairs RD, CE, F M. v = [ZERO] * 64 v[0] = ONE prep = ( ("H", 0), ("CX", 0, 2), ("H", 1), ("CX", 1, 3), ("H", 4), ("CX", 4, 5), ) v, h = circuit(v, prep) v, h = circuit(v, swap_ops(4, 3), h) # U* on F,E

for _ in range(iterations): # Q-reflection on D,D', where D' is now position E=3. v, h = circuit(v, bell_reflection(2, 3), h) # P-reflection: U^T, auxiliary Bell reflection, U*. v, h = circuit(v, swap_ops(4, 3), h) v, h = circuit(v, bell_reflection(4, 5), h) v, h = circuit(v, swap_ops(4, 3), h)

# Final Bell measurement on D,D'. v, h = circuit(v, (("CX", 2, 3), ("H", 2)), h) success = project(v, 2: 0, 3: 0, (0, 1, 4, 5)) p = F(sum(sq(a) for a in success), 1 << h) expected = F(1, 4) if iterations == 0 else F(1) need(p == expected, "wrong HP success probability")

# On success, reference and recovered message are a Bell pair. # Survivors are ordered R,C,C',M. for j, amp in enumerate(success): bs = bits(j, 4) if bs[0] != bs[3]: need(amp == ZERO, "HP output not Bell-correlated") e0 = project(success, 0: 0, 3: 0, (1, 2)) e1 = project(success, 0: 1, 3: 1, (1, 2)) need(e0 == e1, "HP success loses Bell coherence") return p

def check_live_ledger(capacity): """Snapshot delivery: supplier initially holds all three carriers.""" lab = set() supplier = "q1", "q2", "q3" peak = 0 total_peak = len(supplier) gate_count = 0 depth = 0

instructions = ( ("receive", ("q1",)), ("receive", ("q2",)), ("gate", ("q2",)), ("gate", ("q1", "q2")), ("gate", ("q1",)), ("gate", ("q1",)), ("measure", ("q1", "q2")), ("receive", ("q3",)), ("gate", ("q3",)), ("gate", ("q3",)), ("gate", ("q3",)), # worst-history correction ("return", ("q3",)), ) for kind, names in instructions: names = set(names) if kind == "receive": need(names <= supplier, "carrier delivered twice or absent") if len(lab | names) > capacity: raise CapacityRefusal("laboratory capacity exceeded") supplier -= names lab |= names elif kind == "gate": need(names <= lab, "gate uses absent qubit") gate_count += 1 depth += 1 elif kind == "measure": need(names <= lab, "measurement uses absent qubit") depth += 1 lab -= names elif kind == "return": need(names <= lab, "return uses absent qubit") lab -= names else: raise CheckFailure("unknown ledger instruction") peak = max(peak, len(lab)) total_peak = max(total_peak, len(lab) + len(supplier))

need(not lab and not supplier, "unconsumed carrier") need((peak, total_peak, gate_count, depth) == (2, 3, 7, 8), "incorrect resource ledger") return peak, total_peak, gate_count, depth

Nearby in this section