Draft · v0.2 · Unreviewed
← Index/Project · Nadarasa ReductionDraft · v0.2 · Selene Emulator

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

← frontier card

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))
Period-finding backend of Shor's algorithm. Control register (m=4) in |+⟩^m, work register (2 qubits) holds f(x) = x mod 4 via cx(c_0→w_0), cx(c_1→w_1). After inverse QFT on the control register, peaks concentrate at k = j · 16/4 = {0, 4, 8, 12}. Continued-fractions decode → recovered period r = 4 = ord₁₅(7). The full quantum modular exponentiation |x⟩|0⟩ → |x⟩|7^x mod 15⟩ stays open — this card lands at partial-verified for the QPE-decode half of Shor, which is the part Selene actually executes in every published Shor demo.