primitive · G11
Period-finding backend of Shor (N = 15, a = 7)
Control register (m = 4) in |+⟩4, two work qubits encode the compiled periodic function f(x) = x mod 4 (the same period as ord15(7) = 4). Inverse QFT on the control register, no final swap (bit-reversal absorbed in the host decoder). Continued-fractions on the non-zero peaks recovers r = 4.
period_decode_verified · recovered r = 4 · peak share on {0,4,8,12} = 1.0000 · 2048 shots
Control-register histogram (k ∈ 0..15)
Top peaks
0, 4, 8, 12
Continued-fractions candidates
2, 4, 4
LCM (recovered r)
4
Kernel snippet
open in Playpond ↗from quantum.nadarasa_g11_lib import (
guppy, qubit, h, x, cx, rz, measure, result, angle, cphase_h,
)
@guppy
def program() -> None:
c0 = qubit()
c1 = qubit()
c2 = qubit()
c3 = qubit()
w0 = qubit()
w1 = qubit()
# Control register in |+>^4 (sweep x = 0..15 in superposition).
h(c0); h(c1); h(c2); h(c3)
# Compiled f(x) = x mod 4 into the work register: w_j = c_j for j<2.
cx(c0, w0)
cx(c1, w1)
# Inverse QFT on (c0, c1, c2, c3), no final swap.
h(c3)
cphase_h(c3, c2, -0.5)
h(c2)
cphase_h(c3, c1, -0.25)
cphase_h(c2, c1, -0.5)
h(c1)
cphase_h(c3, c0, -0.125)
cphase_h(c2, c0, -0.25)
cphase_h(c1, c0, -0.5)
h(c0)
result("c0", measure(c0))
result("c1", measure(c1))
result("c2", measure(c2))
result("c3", measure(c3))
result("w0", measure(w0))
result("w1", measure(w1))