{"abstract":"The inverse QFT applied to |j> is not the conjugate spectrum; round trips do not return to the input.","category":"Quantum circuit simulation","checks":7,"contract":"Input [n, j, inverse]. Build the textbook QFT on n qubits (qubit 0 = LSB): for q from n-1 down to 0 apply H(q) then CP(pi / 2**(q-k)) between q and each k < q (k descending), then swap q with n-1-q for q < n//2; the inverse is the reversed sequence with negated phases. Apply it to |j> and return the amplitudes as [re, im] rounded to 6 decimals (QFT|j> = sum_k e^{2 pi i jk/N}|k>/sqrt N).","evaluation_group":"w2-quantum_circuit_simulation-qft-gate-decomposition","failed_approach":"The attempted repair reverses and negates the rotations but leaves the swap stage at the end, so the swaps are applied after instead of before the inverse rotations.","family":"w2-quantum_circuit_simulation-qft-gate-decomposition-inverse-phase-negation","id":"FA-91156","implementations":{"attempt":{"sha256":"136c7c086e53b9dd7993fef1b96466e03b6a7170553822c057c2351609651408","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nimport cmath\nN = 1\nobservations = []\ndef solve(x):\n    n, j, inverse = x\n    dim = 1 << n\n    seq = []\n    for q in reversed(range(n)):\n        seq.append(('h', q))\n        for k in reversed(range(q)):\n            seq.append(('cp', k, q, math.pi / 2 ** (q - k)))\n    for q in range(n // 2):\n        seq.append(('swap', q, n - 1 - q))\n    if inverse:\n        seq = [(g[0], g[1], g[2], -g[3]) if g[0] == 'cp' else g for g in reversed(seq) if g[0] != 'swap'] + [g for g in seq if g[0] == 'swap']\n    st = [0j] * dim\n    st[j] = 1 + 0j\n    r = 1 / math.sqrt(2)\n    for g in seq:\n        if g[0] == 'h':\n            m = 1 << g[1]\n            for i in range(dim):\n                if not i & m:\n                    a, b = st[i], st[i | m]\n                    st[i], st[i | m] = (a + b) * r, (a - b) * r\n        elif g[0] == 'cp':\n            mask = (1 << g[1]) | (1 << g[2])\n            ph = cmath.exp(1j * g[3])\n            for i in range(dim):\n                if i & mask == mask:\n                    st[i] *= ph\n        else:\n            a, b = 1 << g[1], 1 << g[2]\n            for i in range(dim):\n                if i & a and not i & b:\n                    k2 = (i ^ a) | b\n                    st[i], st[k2] = st[k2], st[i]\n    return [[round(v.real, 6) + 0.0, round(v.imag, 6) + 0.0] for v in st]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['regression: qft n=2 j=1 inverse', [2, 1, True], [[0.5, 0.0], [0.0, -0.5], [-0.5, 0.0], [0.0, 0.5]]], ['regression: qft n=2 j=3 inverse', [2, 3, True], [[0.5, 0.0], [0.0, 0.5], [-0.5, 0.0], [0.0, -0.5]]], ['repair check: qft n=2 j=2 inverse', [2, 2, True], [[0.5, 0.0], [-0.5, 0.0], [0.5, 0.0], [-0.5, 0.0]]], ['control: qft n=1 j=0', [1, 0, False], [[0.707107, 0.0], [0.707107, 0.0]]], ['control: qft n=1 j=0 inverse', [1, 0, True], [[0.707107, 0.0], [0.707107, 0.0]]], ['control: qft n=1 j=1', [1, 1, False], [[0.707107, 0.0], [-0.707107, 0.0]]], ['control: qft n=1 j=1 inverse', [1, 1, True], [[0.707107, 0.0], [-0.707107, 0.0]]]], [['regression: qft n=3 j=2 inverse', [3, 2, True], [[0.353553, 0.0], [0.0, -0.353553], [-0.353553, 0.0], [0.0, 0.353553], [0.353553, 0.0], [0.0, -0.353553], [-0.353553, 0.0], [0.0, 0.353553]]], ['regression: qft n=3 j=3 inverse', [3, 3, True], [[0.353553, 0.0], [-0.25, -0.25], [0.0, 0.353553], [0.25, -0.25], [-0.353553, 0.0], [0.25, 0.25], [0.0, -0.353553], [-0.25, 0.25]]], ['regression: qft n=2 j=3 inverse', [2, 3, True], [[0.5, 0.0], [0.0, 0.5], [-0.5, 0.0], [0.0, -0.5]]], ['control: qft n=2 j=0', [2, 0, False], [[0.5, 0.0], [0.5, 0.0], [0.5, 0.0], [0.5, 0.0]]], ['control: qft n=2 j=0 inverse', [2, 0, True], [[0.5, 0.0], [0.5, 0.0], [0.5, 0.0], [0.5, 0.0]]], ['control: qft n=2 j=1', [2, 1, False], [[0.5, 0.0], [0.0, 0.5], [-0.5, 0.0], [0.0, -0.5]]], ['control: qft n=2 j=2', [2, 2, False], [[0.5, 0.0], [-0.5, 0.0], [0.5, 0.0], [-0.5, 0.0]]]], [['regression: qft n=3 j=6 inverse', [3, 6, True], [[0.353553, 0.0], [0.0, 0.353553], [-0.353553, 0.0], [0.0, -0.353553], [0.353553, 0.0], [0.0, 0.353553], [-0.353553, 0.0], [0.0, -0.353553]]], ['regression: qft n=3 j=7 inverse', [3, 7, True], [[0.353553, 0.0], [0.25, 0.25], [0.0, 0.353553], [-0.25, 0.25], [-0.353553, 0.0], [-0.25, -0.25], [0.0, -0.353553], [0.25, -0.25]]], ['regression: qft n=3 j=2 inverse', [3, 2, True], [[0.353553, 0.0], [0.0, -0.353553], [-0.353553, 0.0], [0.0, 0.353553], [0.353553, 0.0], [0.0, -0.353553], [-0.353553, 0.0], [0.0, 0.353553]]], ['control: qft n=2 j=3', [2, 3, False], [[0.5, 0.0], [0.0, -0.5], [-0.5, 0.0], [0.0, 0.5]]], ['control: qft n=3 j=0', [3, 0, False], [[0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0]]], ['control: qft n=3 j=0 inverse', [3, 0, True], [[0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0]]], ['control: qft n=3 j=1', [3, 1, False], [[0.353553, 0.0], [0.25, 0.25], [0.0, 0.353553], [-0.25, 0.25], [-0.353553, 0.0], [-0.25, -0.25], [0.0, -0.353553], [0.25, -0.25]]]], [['regression: qft n=4 j=6 inverse', [4, 6, True], [[0.25, 0.0], [-0.176777, -0.176777], [0.0, 0.25], [0.176777, -0.176777], [-0.25, 0.0], [0.176777, 0.176777], [0.0, -0.25], [-0.176777, 0.176777], [0.25, 0.0], [-0.176777, -0.176777], [0.0, 0.25], [0.176777, -0.176777], [-0.25, 0.0], [0.176777, 0.176777], [0.0, -0.25], [-0.176777, 0.176777]]], ['regression: qft n=4 j=9 inverse', [4, 9, True], [[0.25, 0.0], [-0.23097, 0.095671], [0.176777, -0.176777], [-0.095671, 0.23097], [0.0, -0.25], [0.095671, 0.23097], [-0.176777, -0.176777], [0.23097, 0.095671], [-0.25, 0.0], [0.23097, -0.095671], [-0.176777, 0.176777], [0.095671, -0.23097], [0.0, 0.25], [-0.095671, -0.23097], [0.176777, 0.176777], [-0.23097, -0.095671]]], ['repair check: qft n=3 j=4 inverse', [3, 4, True], [[0.353553, 0.0], [-0.353553, 0.0], [0.353553, 0.0], [-0.353553, 0.0], [0.353553, 0.0], [-0.353553, 0.0], [0.353553, 0.0], [-0.353553, 0.0]]], ['control: qft n=3 j=2', [3, 2, False], [[0.353553, 0.0], [0.0, 0.353553], [-0.353553, 0.0], [0.0, -0.353553], [0.353553, 0.0], [0.0, 0.353553], [-0.353553, 0.0], [0.0, -0.353553]]], ['control: qft n=3 j=3', [3, 3, False], [[0.353553, 0.0], [-0.25, 0.25], [0.0, -0.353553], [0.25, 0.25], [-0.353553, 0.0], [0.25, -0.25], [0.0, 0.353553], [-0.25, -0.25]]], ['control: qft n=3 j=4', [3, 4, False], [[0.353553, 0.0], [-0.353553, 0.0], [0.353553, 0.0], [-0.353553, 0.0], [0.353553, 0.0], [-0.353553, 0.0], [0.353553, 0.0], [-0.353553, 0.0]]], ['control: qft n=3 j=5', [3, 5, False], [[0.353553, 0.0], [-0.25, -0.25], [0.0, 0.353553], [0.25, -0.25], [-0.353553, 0.0], [0.25, 0.25], [0.0, -0.353553], [-0.25, 0.25]]]], [['regression: qft n=4 j=15 inverse', [4, 15, True], [[0.25, 0.0], [0.23097, 0.095671], [0.176777, 0.176777], [0.095671, 0.23097], [0.0, 0.25], [-0.095671, 0.23097], [-0.176777, 0.176777], [-0.23097, 0.095671], [-0.25, 0.0], [-0.23097, -0.095671], [-0.176777, -0.176777], [-0.095671, -0.23097], [0.0, -0.25], [0.095671, -0.23097], [0.176777, -0.176777], [0.23097, -0.095671]]], ['regression: qft n=2 j=1 inverse', [2, 1, True], [[0.5, 0.0], [0.0, -0.5], [-0.5, 0.0], [0.0, 0.5]]], ['regression: qft n=3 j=6 inverse', [3, 6, True], [[0.353553, 0.0], [0.0, 0.353553], [-0.353553, 0.0], [0.0, -0.353553], [0.353553, 0.0], [0.0, 0.353553], [-0.353553, 0.0], [0.0, -0.353553]]], ['control: qft n=3 j=6', [3, 6, False], [[0.353553, 0.0], [0.0, -0.353553], [-0.353553, 0.0], [0.0, 0.353553], [0.353553, 0.0], [0.0, -0.353553], [-0.353553, 0.0], [0.0, 0.353553]]], ['control: qft n=3 j=7', [3, 7, False], [[0.353553, 0.0], [0.25, -0.25], [0.0, -0.353553], [-0.25, -0.25], [-0.353553, 0.0], [-0.25, 0.25], [0.0, 0.353553], [0.25, 0.25]]], ['control: qft n=4 j=0', [4, 0, False], [[0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0]]], ['control: qft n=4 j=0 inverse', [4, 0, True], [[0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0]]]]]\nfor label, args, expected in fixtures[N-1]:\n    check(label, solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"d928d142cb9dc5ec9ad3d83f0a7f04cdd7070291b14dc02db9ce136da62facc6","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nimport cmath\nN = 1\nobservations = []\ndef solve(x):\n    n, j, inverse = x\n    dim = 1 << n\n    seq = []\n    for q in reversed(range(n)):\n        seq.append(('h', q))\n        for k in reversed(range(q)):\n            seq.append(('cp', k, q, math.pi / 2 ** (q - k)))\n    for q in range(n // 2):\n        seq.append(('swap', q, n - 1 - q))\n    if inverse:\n        seq = list(reversed(seq))\n    st = [0j] * dim\n    st[j] = 1 + 0j\n    r = 1 / math.sqrt(2)\n    for g in seq:\n        if g[0] == 'h':\n            m = 1 << g[1]\n            for i in range(dim):\n                if not i & m:\n                    a, b = st[i], st[i | m]\n                    st[i], st[i | m] = (a + b) * r, (a - b) * r\n        elif g[0] == 'cp':\n            mask = (1 << g[1]) | (1 << g[2])\n            ph = cmath.exp(1j * g[3])\n            for i in range(dim):\n                if i & mask == mask:\n                    st[i] *= ph\n        else:\n            a, b = 1 << g[1], 1 << g[2]\n            for i in range(dim):\n                if i & a and not i & b:\n                    k2 = (i ^ a) | b\n                    st[i], st[k2] = st[k2], st[i]\n    return [[round(v.real, 6) + 0.0, round(v.imag, 6) + 0.0] for v in st]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['regression: qft n=2 j=1 inverse', [2, 1, True], [[0.5, 0.0], [0.0, -0.5], [-0.5, 0.0], [0.0, 0.5]]], ['regression: qft n=2 j=3 inverse', [2, 3, True], [[0.5, 0.0], [0.0, 0.5], [-0.5, 0.0], [0.0, -0.5]]], ['repair check: qft n=2 j=2 inverse', [2, 2, True], [[0.5, 0.0], [-0.5, 0.0], [0.5, 0.0], [-0.5, 0.0]]], ['control: qft n=1 j=0', [1, 0, False], [[0.707107, 0.0], [0.707107, 0.0]]], ['control: qft n=1 j=0 inverse', [1, 0, True], [[0.707107, 0.0], [0.707107, 0.0]]], ['control: qft n=1 j=1', [1, 1, False], [[0.707107, 0.0], [-0.707107, 0.0]]], ['control: qft n=1 j=1 inverse', [1, 1, True], [[0.707107, 0.0], [-0.707107, 0.0]]]], [['regression: qft n=3 j=2 inverse', [3, 2, True], [[0.353553, 0.0], [0.0, -0.353553], [-0.353553, 0.0], [0.0, 0.353553], [0.353553, 0.0], [0.0, -0.353553], [-0.353553, 0.0], [0.0, 0.353553]]], ['regression: qft n=3 j=3 inverse', [3, 3, True], [[0.353553, 0.0], [-0.25, -0.25], [0.0, 0.353553], [0.25, -0.25], [-0.353553, 0.0], [0.25, 0.25], [0.0, -0.353553], [-0.25, 0.25]]], ['regression: qft n=2 j=3 inverse', [2, 3, True], [[0.5, 0.0], [0.0, 0.5], [-0.5, 0.0], [0.0, -0.5]]], ['control: qft n=2 j=0', [2, 0, False], [[0.5, 0.0], [0.5, 0.0], [0.5, 0.0], [0.5, 0.0]]], ['control: qft n=2 j=0 inverse', [2, 0, True], [[0.5, 0.0], [0.5, 0.0], [0.5, 0.0], [0.5, 0.0]]], ['control: qft n=2 j=1', [2, 1, False], [[0.5, 0.0], [0.0, 0.5], [-0.5, 0.0], [0.0, -0.5]]], ['control: qft n=2 j=2', [2, 2, False], [[0.5, 0.0], [-0.5, 0.0], [0.5, 0.0], [-0.5, 0.0]]]], [['regression: qft n=3 j=6 inverse', [3, 6, True], [[0.353553, 0.0], [0.0, 0.353553], [-0.353553, 0.0], [0.0, -0.353553], [0.353553, 0.0], [0.0, 0.353553], [-0.353553, 0.0], [0.0, -0.353553]]], ['regression: qft n=3 j=7 inverse', [3, 7, True], [[0.353553, 0.0], [0.25, 0.25], [0.0, 0.353553], [-0.25, 0.25], [-0.353553, 0.0], [-0.25, -0.25], [0.0, -0.353553], [0.25, -0.25]]], ['regression: qft n=3 j=2 inverse', [3, 2, True], [[0.353553, 0.0], [0.0, -0.353553], [-0.353553, 0.0], [0.0, 0.353553], [0.353553, 0.0], [0.0, -0.353553], [-0.353553, 0.0], [0.0, 0.353553]]], ['control: qft n=2 j=3', [2, 3, False], [[0.5, 0.0], [0.0, -0.5], [-0.5, 0.0], [0.0, 0.5]]], ['control: qft n=3 j=0', [3, 0, False], [[0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0]]], ['control: qft n=3 j=0 inverse', [3, 0, True], [[0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0]]], ['control: qft n=3 j=1', [3, 1, False], [[0.353553, 0.0], [0.25, 0.25], [0.0, 0.353553], [-0.25, 0.25], [-0.353553, 0.0], [-0.25, -0.25], [0.0, -0.353553], [0.25, -0.25]]]], [['regression: qft n=4 j=6 inverse', [4, 6, True], [[0.25, 0.0], [-0.176777, -0.176777], [0.0, 0.25], [0.176777, -0.176777], [-0.25, 0.0], [0.176777, 0.176777], [0.0, -0.25], [-0.176777, 0.176777], [0.25, 0.0], [-0.176777, -0.176777], [0.0, 0.25], [0.176777, -0.176777], [-0.25, 0.0], [0.176777, 0.176777], [0.0, -0.25], [-0.176777, 0.176777]]], ['regression: qft n=4 j=9 inverse', [4, 9, True], [[0.25, 0.0], [-0.23097, 0.095671], [0.176777, -0.176777], [-0.095671, 0.23097], [0.0, -0.25], [0.095671, 0.23097], [-0.176777, -0.176777], [0.23097, 0.095671], [-0.25, 0.0], [0.23097, -0.095671], [-0.176777, 0.176777], [0.095671, -0.23097], [0.0, 0.25], [-0.095671, -0.23097], [0.176777, 0.176777], [-0.23097, -0.095671]]], ['repair check: qft n=3 j=4 inverse', [3, 4, True], [[0.353553, 0.0], [-0.353553, 0.0], [0.353553, 0.0], [-0.353553, 0.0], [0.353553, 0.0], [-0.353553, 0.0], [0.353553, 0.0], [-0.353553, 0.0]]], ['control: qft n=3 j=2', [3, 2, False], [[0.353553, 0.0], [0.0, 0.353553], [-0.353553, 0.0], [0.0, -0.353553], [0.353553, 0.0], [0.0, 0.353553], [-0.353553, 0.0], [0.0, -0.353553]]], ['control: qft n=3 j=3', [3, 3, False], [[0.353553, 0.0], [-0.25, 0.25], [0.0, -0.353553], [0.25, 0.25], [-0.353553, 0.0], [0.25, -0.25], [0.0, 0.353553], [-0.25, -0.25]]], ['control: qft n=3 j=4', [3, 4, False], [[0.353553, 0.0], [-0.353553, 0.0], [0.353553, 0.0], [-0.353553, 0.0], [0.353553, 0.0], [-0.353553, 0.0], [0.353553, 0.0], [-0.353553, 0.0]]], ['control: qft n=3 j=5', [3, 5, False], [[0.353553, 0.0], [-0.25, -0.25], [0.0, 0.353553], [0.25, -0.25], [-0.353553, 0.0], [0.25, 0.25], [0.0, -0.353553], [-0.25, 0.25]]]], [['regression: qft n=4 j=15 inverse', [4, 15, True], [[0.25, 0.0], [0.23097, 0.095671], [0.176777, 0.176777], [0.095671, 0.23097], [0.0, 0.25], [-0.095671, 0.23097], [-0.176777, 0.176777], [-0.23097, 0.095671], [-0.25, 0.0], [-0.23097, -0.095671], [-0.176777, -0.176777], [-0.095671, -0.23097], [0.0, -0.25], [0.095671, -0.23097], [0.176777, -0.176777], [0.23097, -0.095671]]], ['regression: qft n=2 j=1 inverse', [2, 1, True], [[0.5, 0.0], [0.0, -0.5], [-0.5, 0.0], [0.0, 0.5]]], ['regression: qft n=3 j=6 inverse', [3, 6, True], [[0.353553, 0.0], [0.0, 0.353553], [-0.353553, 0.0], [0.0, -0.353553], [0.353553, 0.0], [0.0, 0.353553], [-0.353553, 0.0], [0.0, -0.353553]]], ['control: qft n=3 j=6', [3, 6, False], [[0.353553, 0.0], [0.0, -0.353553], [-0.353553, 0.0], [0.0, 0.353553], [0.353553, 0.0], [0.0, -0.353553], [-0.353553, 0.0], [0.0, 0.353553]]], ['control: qft n=3 j=7', [3, 7, False], [[0.353553, 0.0], [0.25, -0.25], [0.0, -0.353553], [-0.25, -0.25], [-0.353553, 0.0], [-0.25, 0.25], [0.0, 0.353553], [0.25, 0.25]]], ['control: qft n=4 j=0', [4, 0, False], [[0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0]]], ['control: qft n=4 j=0 inverse', [4, 0, True], [[0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0]]]]]\nfor label, args, expected in fixtures[N-1]:\n    check(label, solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"fixed":{"sha256":"7b0a8e7c2167110d0829a187b3625338bf795bf1ac543baccd0d525fd396974e","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nimport cmath\nN = 1\nobservations = []\ndef solve(x):\n    n, j, inverse = x\n    dim = 1 << n\n    seq = []\n    for q in reversed(range(n)):\n        seq.append(('h', q))\n        for k in reversed(range(q)):\n            seq.append(('cp', k, q, math.pi / 2 ** (q - k)))\n    for q in range(n // 2):\n        seq.append(('swap', q, n - 1 - q))\n    if inverse:\n        seq = [(g[0], g[1], g[2], -g[3]) if g[0] == 'cp' else g for g in reversed(seq)]\n    st = [0j] * dim\n    st[j] = 1 + 0j\n    r = 1 / math.sqrt(2)\n    for g in seq:\n        if g[0] == 'h':\n            m = 1 << g[1]\n            for i in range(dim):\n                if not i & m:\n                    a, b = st[i], st[i | m]\n                    st[i], st[i | m] = (a + b) * r, (a - b) * r\n        elif g[0] == 'cp':\n            mask = (1 << g[1]) | (1 << g[2])\n            ph = cmath.exp(1j * g[3])\n            for i in range(dim):\n                if i & mask == mask:\n                    st[i] *= ph\n        else:\n            a, b = 1 << g[1], 1 << g[2]\n            for i in range(dim):\n                if i & a and not i & b:\n                    k2 = (i ^ a) | b\n                    st[i], st[k2] = st[k2], st[i]\n    return [[round(v.real, 6) + 0.0, round(v.imag, 6) + 0.0] for v in st]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['regression: qft n=2 j=1 inverse', [2, 1, True], [[0.5, 0.0], [0.0, -0.5], [-0.5, 0.0], [0.0, 0.5]]], ['regression: qft n=2 j=3 inverse', [2, 3, True], [[0.5, 0.0], [0.0, 0.5], [-0.5, 0.0], [0.0, -0.5]]], ['repair check: qft n=2 j=2 inverse', [2, 2, True], [[0.5, 0.0], [-0.5, 0.0], [0.5, 0.0], [-0.5, 0.0]]], ['control: qft n=1 j=0', [1, 0, False], [[0.707107, 0.0], [0.707107, 0.0]]], ['control: qft n=1 j=0 inverse', [1, 0, True], [[0.707107, 0.0], [0.707107, 0.0]]], ['control: qft n=1 j=1', [1, 1, False], [[0.707107, 0.0], [-0.707107, 0.0]]], ['control: qft n=1 j=1 inverse', [1, 1, True], [[0.707107, 0.0], [-0.707107, 0.0]]]], [['regression: qft n=3 j=2 inverse', [3, 2, True], [[0.353553, 0.0], [0.0, -0.353553], [-0.353553, 0.0], [0.0, 0.353553], [0.353553, 0.0], [0.0, -0.353553], [-0.353553, 0.0], [0.0, 0.353553]]], ['regression: qft n=3 j=3 inverse', [3, 3, True], [[0.353553, 0.0], [-0.25, -0.25], [0.0, 0.353553], [0.25, -0.25], [-0.353553, 0.0], [0.25, 0.25], [0.0, -0.353553], [-0.25, 0.25]]], ['regression: qft n=2 j=3 inverse', [2, 3, True], [[0.5, 0.0], [0.0, 0.5], [-0.5, 0.0], [0.0, -0.5]]], ['control: qft n=2 j=0', [2, 0, False], [[0.5, 0.0], [0.5, 0.0], [0.5, 0.0], [0.5, 0.0]]], ['control: qft n=2 j=0 inverse', [2, 0, True], [[0.5, 0.0], [0.5, 0.0], [0.5, 0.0], [0.5, 0.0]]], ['control: qft n=2 j=1', [2, 1, False], [[0.5, 0.0], [0.0, 0.5], [-0.5, 0.0], [0.0, -0.5]]], ['control: qft n=2 j=2', [2, 2, False], [[0.5, 0.0], [-0.5, 0.0], [0.5, 0.0], [-0.5, 0.0]]]], [['regression: qft n=3 j=6 inverse', [3, 6, True], [[0.353553, 0.0], [0.0, 0.353553], [-0.353553, 0.0], [0.0, -0.353553], [0.353553, 0.0], [0.0, 0.353553], [-0.353553, 0.0], [0.0, -0.353553]]], ['regression: qft n=3 j=7 inverse', [3, 7, True], [[0.353553, 0.0], [0.25, 0.25], [0.0, 0.353553], [-0.25, 0.25], [-0.353553, 0.0], [-0.25, -0.25], [0.0, -0.353553], [0.25, -0.25]]], ['regression: qft n=3 j=2 inverse', [3, 2, True], [[0.353553, 0.0], [0.0, -0.353553], [-0.353553, 0.0], [0.0, 0.353553], [0.353553, 0.0], [0.0, -0.353553], [-0.353553, 0.0], [0.0, 0.353553]]], ['control: qft n=2 j=3', [2, 3, False], [[0.5, 0.0], [0.0, -0.5], [-0.5, 0.0], [0.0, 0.5]]], ['control: qft n=3 j=0', [3, 0, False], [[0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0]]], ['control: qft n=3 j=0 inverse', [3, 0, True], [[0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0], [0.353553, 0.0]]], ['control: qft n=3 j=1', [3, 1, False], [[0.353553, 0.0], [0.25, 0.25], [0.0, 0.353553], [-0.25, 0.25], [-0.353553, 0.0], [-0.25, -0.25], [0.0, -0.353553], [0.25, -0.25]]]], [['regression: qft n=4 j=6 inverse', [4, 6, True], [[0.25, 0.0], [-0.176777, -0.176777], [0.0, 0.25], [0.176777, -0.176777], [-0.25, 0.0], [0.176777, 0.176777], [0.0, -0.25], [-0.176777, 0.176777], [0.25, 0.0], [-0.176777, -0.176777], [0.0, 0.25], [0.176777, -0.176777], [-0.25, 0.0], [0.176777, 0.176777], [0.0, -0.25], [-0.176777, 0.176777]]], ['regression: qft n=4 j=9 inverse', [4, 9, True], [[0.25, 0.0], [-0.23097, 0.095671], [0.176777, -0.176777], [-0.095671, 0.23097], [0.0, -0.25], [0.095671, 0.23097], [-0.176777, -0.176777], [0.23097, 0.095671], [-0.25, 0.0], [0.23097, -0.095671], [-0.176777, 0.176777], [0.095671, -0.23097], [0.0, 0.25], [-0.095671, -0.23097], [0.176777, 0.176777], [-0.23097, -0.095671]]], ['repair check: qft n=3 j=4 inverse', [3, 4, True], [[0.353553, 0.0], [-0.353553, 0.0], [0.353553, 0.0], [-0.353553, 0.0], [0.353553, 0.0], [-0.353553, 0.0], [0.353553, 0.0], [-0.353553, 0.0]]], ['control: qft n=3 j=2', [3, 2, False], [[0.353553, 0.0], [0.0, 0.353553], [-0.353553, 0.0], [0.0, -0.353553], [0.353553, 0.0], [0.0, 0.353553], [-0.353553, 0.0], [0.0, -0.353553]]], ['control: qft n=3 j=3', [3, 3, False], [[0.353553, 0.0], [-0.25, 0.25], [0.0, -0.353553], [0.25, 0.25], [-0.353553, 0.0], [0.25, -0.25], [0.0, 0.353553], [-0.25, -0.25]]], ['control: qft n=3 j=4', [3, 4, False], [[0.353553, 0.0], [-0.353553, 0.0], [0.353553, 0.0], [-0.353553, 0.0], [0.353553, 0.0], [-0.353553, 0.0], [0.353553, 0.0], [-0.353553, 0.0]]], ['control: qft n=3 j=5', [3, 5, False], [[0.353553, 0.0], [-0.25, -0.25], [0.0, 0.353553], [0.25, -0.25], [-0.353553, 0.0], [0.25, 0.25], [0.0, -0.353553], [-0.25, 0.25]]]], [['regression: qft n=4 j=15 inverse', [4, 15, True], [[0.25, 0.0], [0.23097, 0.095671], [0.176777, 0.176777], [0.095671, 0.23097], [0.0, 0.25], [-0.095671, 0.23097], [-0.176777, 0.176777], [-0.23097, 0.095671], [-0.25, 0.0], [-0.23097, -0.095671], [-0.176777, -0.176777], [-0.095671, -0.23097], [0.0, -0.25], [0.095671, -0.23097], [0.176777, -0.176777], [0.23097, -0.095671]]], ['regression: qft n=2 j=1 inverse', [2, 1, True], [[0.5, 0.0], [0.0, -0.5], [-0.5, 0.0], [0.0, 0.5]]], ['regression: qft n=3 j=6 inverse', [3, 6, True], [[0.353553, 0.0], [0.0, 0.353553], [-0.353553, 0.0], [0.0, -0.353553], [0.353553, 0.0], [0.0, 0.353553], [-0.353553, 0.0], [0.0, -0.353553]]], ['control: qft n=3 j=6', [3, 6, False], [[0.353553, 0.0], [0.0, -0.353553], [-0.353553, 0.0], [0.0, 0.353553], [0.353553, 0.0], [0.0, -0.353553], [-0.353553, 0.0], [0.0, 0.353553]]], ['control: qft n=3 j=7', [3, 7, False], [[0.353553, 0.0], [0.25, -0.25], [0.0, -0.353553], [-0.25, -0.25], [-0.353553, 0.0], [-0.25, 0.25], [0.0, 0.353553], [0.25, 0.25]]], ['control: qft n=4 j=0', [4, 0, False], [[0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0]]], ['control: qft n=4 j=0 inverse', [4, 0, True], [[0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0], [0.25, 0.0]]]]]\nfor label, args, expected in fixtures[N-1]:\n    check(label, solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"A deterministic bounded teaching model with a stipulated toy contract; amplitudes are rounded to fixed decimals for strict JSON output. It is not a production quantum SDK and claims no standards conformance. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-quantum_circuit_simulation-qft-gate-decomposition-inverse-phase-negation","generated_at":"2026-09-29T14:51:33.462666+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"QFT circuits are the core of phase estimation and arithmetic; decomposition slips produce bit-reversed or dephased spectra.","repair":"Reverse the gate order and negate every controlled-phase angle.","root_cause":"The inverse sequence reverses gate order but reuses the positive controlled-phase angles.","sha256":"2af6c6adfae3339a4b1b96daf79f757e037f3d0272fa857176766ba3508104b3","title":"Inverse QFT reverses the gates but keeps phase signs · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":42.925,"exit_code":1,"observations":[{"actual":[[0.5,0.0],[0.5,0.0],[-0.5,0.0],[-0.5,0.0]],"check":"regression: qft n=2 j=1 inverse","expected":[[0.5,0.0],[0.0,-0.5],[-0.5,0.0],[0.0,0.5]],"passed":false},{"actual":[[0.5,0.0],[-0.5,0.0],[0.0,0.5],[0.0,-0.5]],"check":"regression: qft n=2 j=3 inverse","expected":[[0.5,0.0],[0.0,0.5],[-0.5,0.0],[0.0,-0.5]],"passed":false},{"actual":[[0.5,0.0],[-0.5,0.0],[0.0,-0.5],[0.0,0.5]],"check":"repair check: qft n=2 j=2 inverse","expected":[[0.5,0.0],[-0.5,0.0],[0.5,0.0],[-0.5,0.0]],"passed":false},{"actual":[[0.707107,0.0],[0.707107,0.0]],"check":"control: qft n=1 j=0","expected":[[0.707107,0.0],[0.707107,0.0]],"passed":true},{"actual":[[0.707107,0.0],[0.707107,0.0]],"check":"control: qft n=1 j=0 inverse","expected":[[0.707107,0.0],[0.707107,0.0]],"passed":true},{"actual":[[0.707107,0.0],[-0.707107,0.0]],"check":"control: qft n=1 j=1","expected":[[0.707107,0.0],[-0.707107,0.0]],"passed":true},{"actual":[[0.707107,0.0],[-0.707107,0.0]],"check":"control: qft n=1 j=1 inverse","expected":[[0.707107,0.0],[-0.707107,0.0]],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: qft n=2 j=1 inverse\", \"actual\": [[0.5, 0.0], [0.5, 0.0], [-0.5, 0.0], [-0.5, 0.0]], \"expected\": [[0.5, 0.0], [0.0, -0.5], [-0.5, 0.0], [0.0, 0.5]], \"passed\": false}, {\"check\": \"regression: qft n=2 j=3 inverse\", \"actual\": [[0.5, 0.0], [-0.5, 0.0], [0.0, 0.5], [0.0, -0.5]], \"expected\": [[0.5, 0.0], [0.0, 0.5], [-0.5, 0.0], [0.0, -0.5]], \"passed\": false}, {\"check\": \"repair check: qft n=2 j=2 inverse\", \"actual\": [[0.5, 0.0], [-0.5, 0.0], [0.0, -0.5], [0.0, 0.5]], \"expected\": [[0.5, 0.0], [-0.5, 0.0], [0.5, 0.0], [-0.5, 0.0]], \"passed\": false}, {\"check\": \"control: qft n=1 j=0\", \"actual\": [[0.707107, 0.0], [0.707107, 0.0]], \"expected\": [[0.707107, 0.0], [0.707107, 0.0]], \"passed\": true}, {\"check\": \"control: qft n=1 j=0 inverse\", \"actual\": [[0.707107, 0.0], [0.707107, 0.0]], \"expected\": [[0.707107, 0.0], [0.707107, 0.0]], \"passed\": true}, {\"check\": \"control: qft n=1 j=1\", \"actual\": [[0.707107, 0.0], [-0.707107, 0.0]], \"expected\": [[0.707107, 0.0], [-0.707107, 0.0]], \"passed\": true}, {\"check\": \"control: qft n=1 j=1 inverse\", \"actual\": [[0.707107, 0.0], [-0.707107, 0.0]], \"expected\": [[0.707107, 0.0], [-0.707107, 0.0]], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":44.197,"exit_code":1,"observations":[{"actual":[[0.5,0.0],[0.0,0.5],[-0.5,0.0],[0.0,-0.5]],"check":"regression: qft n=2 j=1 inverse","expected":[[0.5,0.0],[0.0,-0.5],[-0.5,0.0],[0.0,0.5]],"passed":false},{"actual":[[0.5,0.0],[0.0,-0.5],[-0.5,0.0],[0.0,0.5]],"check":"regression: qft n=2 j=3 inverse","expected":[[0.5,0.0],[0.0,0.5],[-0.5,0.0],[0.0,-0.5]],"passed":false},{"actual":[[0.5,0.0],[-0.5,0.0],[0.5,0.0],[-0.5,0.0]],"check":"repair check: qft n=2 j=2 inverse","expected":[[0.5,0.0],[-0.5,0.0],[0.5,0.0],[-0.5,0.0]],"passed":true},{"actual":[[0.707107,0.0],[0.707107,0.0]],"check":"control: qft n=1 j=0","expected":[[0.707107,0.0],[0.707107,0.0]],"passed":true},{"actual":[[0.707107,0.0],[0.707107,0.0]],"check":"control: qft n=1 j=0 inverse","expected":[[0.707107,0.0],[0.707107,0.0]],"passed":true},{"actual":[[0.707107,0.0],[-0.707107,0.0]],"check":"control: qft n=1 j=1","expected":[[0.707107,0.0],[-0.707107,0.0]],"passed":true},{"actual":[[0.707107,0.0],[-0.707107,0.0]],"check":"control: qft n=1 j=1 inverse","expected":[[0.707107,0.0],[-0.707107,0.0]],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: qft n=2 j=1 inverse\", \"actual\": [[0.5, 0.0], [0.0, 0.5], [-0.5, 0.0], [0.0, -0.5]], \"expected\": [[0.5, 0.0], [0.0, -0.5], [-0.5, 0.0], [0.0, 0.5]], \"passed\": false}, {\"check\": \"regression: qft n=2 j=3 inverse\", \"actual\": [[0.5, 0.0], [0.0, -0.5], [-0.5, 0.0], [0.0, 0.5]], \"expected\": [[0.5, 0.0], [0.0, 0.5], [-0.5, 0.0], [0.0, -0.5]], \"passed\": false}, {\"check\": \"repair check: qft n=2 j=2 inverse\", \"actual\": [[0.5, 0.0], [-0.5, 0.0], [0.5, 0.0], [-0.5, 0.0]], \"expected\": [[0.5, 0.0], [-0.5, 0.0], [0.5, 0.0], [-0.5, 0.0]], \"passed\": true}, {\"check\": \"control: qft n=1 j=0\", \"actual\": [[0.707107, 0.0], [0.707107, 0.0]], \"expected\": [[0.707107, 0.0], [0.707107, 0.0]], \"passed\": true}, {\"check\": \"control: qft n=1 j=0 inverse\", \"actual\": [[0.707107, 0.0], [0.707107, 0.0]], \"expected\": [[0.707107, 0.0], [0.707107, 0.0]], \"passed\": true}, {\"check\": \"control: qft n=1 j=1\", \"actual\": [[0.707107, 0.0], [-0.707107, 0.0]], \"expected\": [[0.707107, 0.0], [-0.707107, 0.0]], \"passed\": true}, {\"check\": \"control: qft n=1 j=1 inverse\", \"actual\": [[0.707107, 0.0], [-0.707107, 0.0]], \"expected\": [[0.707107, 0.0], [-0.707107, 0.0]], \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":46.682,"exit_code":0,"observations":[{"actual":[[0.5,0.0],[0.0,-0.5],[-0.5,0.0],[0.0,0.5]],"check":"regression: qft n=2 j=1 inverse","expected":[[0.5,0.0],[0.0,-0.5],[-0.5,0.0],[0.0,0.5]],"passed":true},{"actual":[[0.5,0.0],[0.0,0.5],[-0.5,0.0],[0.0,-0.5]],"check":"regression: qft n=2 j=3 inverse","expected":[[0.5,0.0],[0.0,0.5],[-0.5,0.0],[0.0,-0.5]],"passed":true},{"actual":[[0.5,0.0],[-0.5,0.0],[0.5,0.0],[-0.5,0.0]],"check":"repair check: qft n=2 j=2 inverse","expected":[[0.5,0.0],[-0.5,0.0],[0.5,0.0],[-0.5,0.0]],"passed":true},{"actual":[[0.707107,0.0],[0.707107,0.0]],"check":"control: qft n=1 j=0","expected":[[0.707107,0.0],[0.707107,0.0]],"passed":true},{"actual":[[0.707107,0.0],[0.707107,0.0]],"check":"control: qft n=1 j=0 inverse","expected":[[0.707107,0.0],[0.707107,0.0]],"passed":true},{"actual":[[0.707107,0.0],[-0.707107,0.0]],"check":"control: qft n=1 j=1","expected":[[0.707107,0.0],[-0.707107,0.0]],"passed":true},{"actual":[[0.707107,0.0],[-0.707107,0.0]],"check":"control: qft n=1 j=1 inverse","expected":[[0.707107,0.0],[-0.707107,0.0]],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: qft n=2 j=1 inverse\", \"actual\": [[0.5, 0.0], [0.0, -0.5], [-0.5, 0.0], [0.0, 0.5]], \"expected\": [[0.5, 0.0], [0.0, -0.5], [-0.5, 0.0], [0.0, 0.5]], \"passed\": true}, {\"check\": \"regression: qft n=2 j=3 inverse\", \"actual\": [[0.5, 0.0], [0.0, 0.5], [-0.5, 0.0], [0.0, -0.5]], \"expected\": [[0.5, 0.0], [0.0, 0.5], [-0.5, 0.0], [0.0, -0.5]], \"passed\": true}, {\"check\": \"repair check: qft n=2 j=2 inverse\", \"actual\": [[0.5, 0.0], [-0.5, 0.0], [0.5, 0.0], [-0.5, 0.0]], \"expected\": [[0.5, 0.0], [-0.5, 0.0], [0.5, 0.0], [-0.5, 0.0]], \"passed\": true}, {\"check\": \"control: qft n=1 j=0\", \"actual\": [[0.707107, 0.0], [0.707107, 0.0]], \"expected\": [[0.707107, 0.0], [0.707107, 0.0]], \"passed\": true}, {\"check\": \"control: qft n=1 j=0 inverse\", \"actual\": [[0.707107, 0.0], [0.707107, 0.0]], \"expected\": [[0.707107, 0.0], [0.707107, 0.0]], \"passed\": true}, {\"check\": \"control: qft n=1 j=1\", \"actual\": [[0.707107, 0.0], [-0.707107, 0.0]], \"expected\": [[0.707107, 0.0], [-0.707107, 0.0]], \"passed\": true}, {\"check\": \"control: qft n=1 j=1 inverse\", \"actual\": [[0.707107, 0.0], [-0.707107, 0.0]], \"expected\": [[0.707107, 0.0], [-0.707107, 0.0]], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}