{"abstract":"<ZI> on |01> (qubit 0 excited) evaluates to -1 instead of +1.","category":"Quantum circuit simulation","checks":7,"contract":"Input [n, amps, pauli]; pauli is an n-character string over I,X,Y,Z whose rightmost character acts on qubit 0 (LSB). Return the real expectation <psi|P|psi>/<psi|psi> rounded to 6 decimals. Errors: \"length-mismatch\", \"bad-pauli\" (any character outside uppercase IXYZ).","contract_signature":"x","evaluation_group":"w2-quantum_circuit_simulation-pauli-expectation","failed_approach":"The attempted repair flips the index for bit flips but still reads the phase bit from qubit k, an incomplete refactor.","family":"w2-quantum_circuit_simulation-pauli-expectation-string-to-qubit-mapping","id":"FA-90931","implementations":{"attempt":{"sha256":"952cd39e27d584faec614f9ad43d9963f272249501e74ba554b6f312fe1c4a9b","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nN = 1\nobservations = []\ndef solve(x):\n    n, amps, pauli = x\n    if len(pauli) != n:\n        return 'length-mismatch'\n    if any(c not in 'IXYZ' for c in pauli):\n        return 'bad-pauli'\n    psi = [complex(a, b) for a, b in amps]\n    acc = 0j\n    for i, v in enumerate(psi):\n        j = i\n        phase = 1 + 0j\n        for k, c in enumerate(pauli):\n            q = n - 1 - k\n            bit = (i >> k) & 1\n            if c in 'XY':\n                j ^= 1 << q\n            if c == 'Z' and bit:\n                phase = -phase\n            elif c == 'Y':\n                phase *= 1j if bit == 0 else -1j\n        acc += psi[j].conjugate() * phase * v\n    norm = sum(abs(v) ** 2 for v in psi)\n    return round((acc / norm).real, 6) + 0.0\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['regression: ZI on |01>', [2, [[0, 0], [1, 0], [0, 0], [0, 0]], 'ZI'], 1.0], ['regression: IZ on |01>', [2, [[0, 0], [1, 0], [0, 0], [0, 0]], 'IZ'], -1.0], ['regression: random expectation 12', [3, [[1.741, 0.945], [0.0, 0.0], [0.705, -0.271], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [-1.277, -0.575], [-0.732, 0.787]], 'ZZX'], 0.12672], ['control: Y on |+i>', [1, [[0.707107, 0], [0, 0.707107]], 'Y'], 1.0], ['control: X on |+>', [1, [[0.707107, 0], [0.707107, 0]], 'X'], 1.0], ['control: short string', [2, [[1, 0], [0, 0], [0, 0], [0, 0]], 'Z'], 'length-mismatch'], ['control: long string', [1, [[1, 0], [0, 0]], 'ZZ'], 'length-mismatch']], [['regression: random expectation 10', [3, [[0.0, 0.0], [1.545, 0.342], [0.0, 0.0], [-1.862, -1.433], [0.0, 0.0], [-0.66, -1.507], [0.913, -1.017], [-1.982, -0.009]], 'IZX'], 0.21787], ['regression: random expectation 12', [3, [[1.741, 0.945], [0.0, 0.0], [0.705, -0.271], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [-1.277, -0.575], [-0.732, 0.787]], 'ZZX'], 0.12672], ['regression: random expectation 13', [2, [[-0.447, -0.821], [0.189, -0.56], [0.105, 0.959], [0.741, -0.692]], 'XY'], 0.425941], ['control: short X on bell', [2, [[0.707107, 0], [0, 0], [0, 0], [0.707107, 0]], 'X'], 'length-mismatch'], ['control: short Y on three qubits', [3, [[0.5, 0], [0, 0.5], [0, 0], [0.5, 0], [0, 0], [0, 0], [0, 0], [0.5, 0]], 'YZ'], 'length-mismatch'], ['control: short Z on excited high qubit', [2, [[0, 0], [0, 0], [1, 0], [0, 0]], 'Z'], 'length-mismatch'], ['control: short ZX', [3, [[0.6, 0], [0.8, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]], 'ZX'], 'length-mismatch']], [['regression: random expectation 14', [3, [[-0.975, 0.241], [-0.742, -0.382], [-0.693, 0.269], [0.083, -0.194], [0.274, 0.631], [0.759, 0.874], [0.919, -0.186], [-0.582, 0.068]], 'XIY'], -0.271617], ['regression: random expectation 15', [2, [[0.599, 0.301], [1.478, -0.323], [-0.934, -1.434], [0.207, -0.762]], 'YZ'], 0.153104], ['regression: random expectation 17', [3, [[1.838, 0.283], [0.891, 0.877], [1.546, 0.945], [-0.961, -0.859], [-1.128, 0.574], [1.09, 1.657], [-0.491, 1.307], [0.567, -1.553]], 'YYI'], -0.226212], ['control: lowercase pauli', [1, [[1, 0], [0, 0]], 'z'], 'bad-pauli'], ['control: unnormalized Z', [1, [[3, 0], [0, 4]], 'Z'], -0.28], ['control: random expectation 0', [1, [[0.071, 0.727], [-1.619, -1.464]], 'I'], 1.0], ['control: random expectation 1', [1, [[0.0, 0.0], [1.97, 0.65]], 'X'], 0.0]], [['regression: random expectation 19', [3, [[-1.467, 1.96], [1.04, 1.59], [0.568, -0.807], [-1.506, -0.905], [-0.169, 1.361], [-1.64, -0.753], [1.853, -1.891], [0.222, 0.162]], 'ZIY'], -0.70921], ['regression: random expectation 20', [2, [[0.0, 0.0], [0.216, -0.049], [0.0, 0.0], [0.005, -0.114]], 'XZ'], -0.214762], ['regression: random expectation 21', [3, [[-0.485, -0.865], [1.47, -0.226], [0.134, 0.654], [-0.754, 0.633], [-0.838, 0.604], [-0.388, 1.641], [1.972, 0.518], [0.312, -1.274]], 'XXZ'], -0.444446], ['control: random expectation 2', [1, [[0.489, 0.112], [-0.446, 0.868]], 'X'], -0.200793], ['control: random expectation 3', [1, [[-0.119, -0.141], [0.0, 0.0]], 'Z'], 1.0], ['control: random expectation 4', [1, [[-0.408, 0.461], [-0.359, 0.326]], 'Y'], 0.105809], ['control: random expectation 6', [2, [[0.423, -0.627], [-0.829, 0.103], [0.962, -0.142], [-0.494, -0.183]], 'XX'], -0.7271]], [['regression: random expectation 24', [3, [[0.86, 0.84], [0.244, 0.466], [-1.864, 1.492], [1.769, 1.866], [-1.943, -0.241], [-0.658, 0.243], [-0.056, 0.182], [1.614, -1.453]], 'YZX'], 0.076289], ['regression: random expectation 26', [2, [[0.234, -0.739], [-0.627, 0.79], [0.0, 0.0], [0.107, -0.508]], 'YI'], 0.247917], ['regression: random expectation 33', [2, [[0.861, -0.593], [0.645, 0.002], [0.346, -0.645], [0.069, 0.909]], 'IZ'], 0.132708], ['control: random expectation 7', [1, [[-1.206, 1.877], [0.69, -0.341]], 'I'], 1.0], ['control: random expectation 8', [1, [[0.52, 0.586], [-0.138, -0.781]], 'I'], 1.0], ['control: random expectation 9', [3, [[0.685, -0.091], [1.56, 1.459], [-1.17, 0.687], [-0.305, 1.609], [-0.876, -1.673], [-0.535, 0.008], [-1.818, 1.331], [1.693, 1.162]], 'IXI'], -0.046053], ['control: random expectation 11', [1, [[-0.422, -1.932], [-1.435, 1.833]], 'Z'], -0.161676]]]\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":"503e73a1ed900850b8bf160b70d8747b6a9a4754c99ff46137f66435dae074c0","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nN = 1\nobservations = []\ndef solve(x):\n    n, amps, pauli = x\n    if len(pauli) != n:\n        return 'length-mismatch'\n    if any(c not in 'IXYZ' for c in pauli):\n        return 'bad-pauli'\n    psi = [complex(a, b) for a, b in amps]\n    acc = 0j\n    for i, v in enumerate(psi):\n        j = i\n        phase = 1 + 0j\n        for k, c in enumerate(pauli):\n            q = k\n            bit = (i >> q) & 1\n            if c in 'XY':\n                j ^= 1 << q\n            if c == 'Z' and bit:\n                phase = -phase\n            elif c == 'Y':\n                phase *= 1j if bit == 0 else -1j\n        acc += psi[j].conjugate() * phase * v\n    norm = sum(abs(v) ** 2 for v in psi)\n    return round((acc / norm).real, 6) + 0.0\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['regression: ZI on |01>', [2, [[0, 0], [1, 0], [0, 0], [0, 0]], 'ZI'], 1.0], ['regression: IZ on |01>', [2, [[0, 0], [1, 0], [0, 0], [0, 0]], 'IZ'], -1.0], ['regression: random expectation 12', [3, [[1.741, 0.945], [0.0, 0.0], [0.705, -0.271], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [-1.277, -0.575], [-0.732, 0.787]], 'ZZX'], 0.12672], ['control: Y on |+i>', [1, [[0.707107, 0], [0, 0.707107]], 'Y'], 1.0], ['control: X on |+>', [1, [[0.707107, 0], [0.707107, 0]], 'X'], 1.0], ['control: short string', [2, [[1, 0], [0, 0], [0, 0], [0, 0]], 'Z'], 'length-mismatch'], ['control: long string', [1, [[1, 0], [0, 0]], 'ZZ'], 'length-mismatch']], [['regression: random expectation 10', [3, [[0.0, 0.0], [1.545, 0.342], [0.0, 0.0], [-1.862, -1.433], [0.0, 0.0], [-0.66, -1.507], [0.913, -1.017], [-1.982, -0.009]], 'IZX'], 0.21787], ['regression: random expectation 12', [3, [[1.741, 0.945], [0.0, 0.0], [0.705, -0.271], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [-1.277, -0.575], [-0.732, 0.787]], 'ZZX'], 0.12672], ['regression: random expectation 13', [2, [[-0.447, -0.821], [0.189, -0.56], [0.105, 0.959], [0.741, -0.692]], 'XY'], 0.425941], ['control: short X on bell', [2, [[0.707107, 0], [0, 0], [0, 0], [0.707107, 0]], 'X'], 'length-mismatch'], ['control: short Y on three qubits', [3, [[0.5, 0], [0, 0.5], [0, 0], [0.5, 0], [0, 0], [0, 0], [0, 0], [0.5, 0]], 'YZ'], 'length-mismatch'], ['control: short Z on excited high qubit', [2, [[0, 0], [0, 0], [1, 0], [0, 0]], 'Z'], 'length-mismatch'], ['control: short ZX', [3, [[0.6, 0], [0.8, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]], 'ZX'], 'length-mismatch']], [['regression: random expectation 14', [3, [[-0.975, 0.241], [-0.742, -0.382], [-0.693, 0.269], [0.083, -0.194], [0.274, 0.631], [0.759, 0.874], [0.919, -0.186], [-0.582, 0.068]], 'XIY'], -0.271617], ['regression: random expectation 15', [2, [[0.599, 0.301], [1.478, -0.323], [-0.934, -1.434], [0.207, -0.762]], 'YZ'], 0.153104], ['regression: random expectation 17', [3, [[1.838, 0.283], [0.891, 0.877], [1.546, 0.945], [-0.961, -0.859], [-1.128, 0.574], [1.09, 1.657], [-0.491, 1.307], [0.567, -1.553]], 'YYI'], -0.226212], ['control: lowercase pauli', [1, [[1, 0], [0, 0]], 'z'], 'bad-pauli'], ['control: unnormalized Z', [1, [[3, 0], [0, 4]], 'Z'], -0.28], ['control: random expectation 0', [1, [[0.071, 0.727], [-1.619, -1.464]], 'I'], 1.0], ['control: random expectation 1', [1, [[0.0, 0.0], [1.97, 0.65]], 'X'], 0.0]], [['regression: random expectation 19', [3, [[-1.467, 1.96], [1.04, 1.59], [0.568, -0.807], [-1.506, -0.905], [-0.169, 1.361], [-1.64, -0.753], [1.853, -1.891], [0.222, 0.162]], 'ZIY'], -0.70921], ['regression: random expectation 20', [2, [[0.0, 0.0], [0.216, -0.049], [0.0, 0.0], [0.005, -0.114]], 'XZ'], -0.214762], ['regression: random expectation 21', [3, [[-0.485, -0.865], [1.47, -0.226], [0.134, 0.654], [-0.754, 0.633], [-0.838, 0.604], [-0.388, 1.641], [1.972, 0.518], [0.312, -1.274]], 'XXZ'], -0.444446], ['control: random expectation 2', [1, [[0.489, 0.112], [-0.446, 0.868]], 'X'], -0.200793], ['control: random expectation 3', [1, [[-0.119, -0.141], [0.0, 0.0]], 'Z'], 1.0], ['control: random expectation 4', [1, [[-0.408, 0.461], [-0.359, 0.326]], 'Y'], 0.105809], ['control: random expectation 6', [2, [[0.423, -0.627], [-0.829, 0.103], [0.962, -0.142], [-0.494, -0.183]], 'XX'], -0.7271]], [['regression: random expectation 24', [3, [[0.86, 0.84], [0.244, 0.466], [-1.864, 1.492], [1.769, 1.866], [-1.943, -0.241], [-0.658, 0.243], [-0.056, 0.182], [1.614, -1.453]], 'YZX'], 0.076289], ['regression: random expectation 26', [2, [[0.234, -0.739], [-0.627, 0.79], [0.0, 0.0], [0.107, -0.508]], 'YI'], 0.247917], ['regression: random expectation 33', [2, [[0.861, -0.593], [0.645, 0.002], [0.346, -0.645], [0.069, 0.909]], 'IZ'], 0.132708], ['control: random expectation 7', [1, [[-1.206, 1.877], [0.69, -0.341]], 'I'], 1.0], ['control: random expectation 8', [1, [[0.52, 0.586], [-0.138, -0.781]], 'I'], 1.0], ['control: random expectation 9', [3, [[0.685, -0.091], [1.56, 1.459], [-1.17, 0.687], [-0.305, 1.609], [-0.876, -1.673], [-0.535, 0.008], [-1.818, 1.331], [1.693, 1.162]], 'IXI'], -0.046053], ['control: random expectation 11', [1, [[-0.422, -1.932], [-1.435, 1.833]], 'Z'], -0.161676]]]\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-pauli-expectation-string-to-qubit-mapping","generated_at":"2026-09-29T14:51:31.176975+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Pauli expectation values are the observable layer of variational algorithms; string-order or phase slips bias every energy estimate.","root_cause":"Character k of the string is applied to qubit k instead of qubit n-1-k.","sha256":"b9d29f96911473d7ff7f5ed316e9c03da81f424b92c7faa9a7d224685678e3ec","title":"Pauli expectation maps the leftmost character to qubit 0 · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":40.339,"exit_code":1,"observations":[{"actual":-1.0,"check":"regression: ZI on |01>","expected":1.0,"passed":false},{"actual":1.0,"check":"regression: IZ on |01>","expected":-1.0,"passed":false},{"actual":0.0,"check":"regression: random expectation 12","expected":0.12672,"passed":false},{"actual":1.0,"check":"control: Y on |+i>","expected":1.0,"passed":true},{"actual":1.0,"check":"control: X on |+>","expected":1.0,"passed":true},{"actual":"length-mismatch","check":"control: short string","expected":"length-mismatch","passed":true},{"actual":"length-mismatch","check":"control: long string","expected":"length-mismatch","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: ZI on |01>\", \"actual\": -1.0, \"expected\": 1.0, \"passed\": false}, {\"check\": \"regression: IZ on |01>\", \"actual\": 1.0, \"expected\": -1.0, \"passed\": false}, {\"check\": \"regression: random expectation 12\", \"actual\": 0.0, \"expected\": 0.12672, \"passed\": false}, {\"check\": \"control: Y on |+i>\", \"actual\": 1.0, \"expected\": 1.0, \"passed\": true}, {\"check\": \"control: X on |+>\", \"actual\": 1.0, \"expected\": 1.0, \"passed\": true}, {\"check\": \"control: short string\", \"actual\": \"length-mismatch\", \"expected\": \"length-mismatch\", \"passed\": true}, {\"check\": \"control: long string\", \"actual\": \"length-mismatch\", \"expected\": \"length-mismatch\", \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":39.595,"exit_code":1,"observations":[{"actual":-1.0,"check":"regression: ZI on |01>","expected":1.0,"passed":false},{"actual":1.0,"check":"regression: IZ on |01>","expected":-1.0,"passed":false},{"actual":0.195624,"check":"regression: random expectation 12","expected":0.12672,"passed":false},{"actual":1.0,"check":"control: Y on |+i>","expected":1.0,"passed":true},{"actual":1.0,"check":"control: X on |+>","expected":1.0,"passed":true},{"actual":"length-mismatch","check":"control: short string","expected":"length-mismatch","passed":true},{"actual":"length-mismatch","check":"control: long string","expected":"length-mismatch","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: ZI on |01>\", \"actual\": -1.0, \"expected\": 1.0, \"passed\": false}, {\"check\": \"regression: IZ on |01>\", \"actual\": 1.0, \"expected\": -1.0, \"passed\": false}, {\"check\": \"regression: random expectation 12\", \"actual\": 0.195624, \"expected\": 0.12672, \"passed\": false}, {\"check\": \"control: Y on |+i>\", \"actual\": 1.0, \"expected\": 1.0, \"passed\": true}, {\"check\": \"control: X on |+>\", \"actual\": 1.0, \"expected\": 1.0, \"passed\": true}, {\"check\": \"control: short string\", \"actual\": \"length-mismatch\", \"expected\": \"length-mismatch\", \"passed\": true}, {\"check\": \"control: long string\", \"actual\": \"length-mismatch\", \"expected\": \"length-mismatch\", \"passed\": true}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}