{"abstract":"cx q[0],r with a three-qubit r emits one CNOT instead of three.","category":"Quantum circuit simulation","checks":7,"contract":"Input a list of OpenQASM-2-like statements: \"qreg n[k];\", \"creg n[k];\", gate statements \"g a,b;\" and \"measure a -> b;\" where operands are whole registers or \"n[i]\". Registers are flattened in declaration order per kind (qubits and clbits have separate counters). Whole-register operands broadcast; a single qubit operand is reused across the broadcast. Return [[g, [flat qubits]] or [\"measure\", q, c]...] or [error, statement index] with errors \"unknown-register\", \"index-out-of-range\", \"size-mismatch\".","evaluation_group":"w2-quantum_circuit_simulation-qasm-register-expansion","failed_approach":"The attempted repair uses the last operand width, which fails for cx q,r[0].","family":"w2-quantum_circuit_simulation-qasm-register-expansion-broadcast-width","id":"FA-91316","implementations":{"attempt":{"sha256":"8af1fa2afab197fafdb1893942f801afa243b61fa9ca0f0e8e0d8b4ffa674d13","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport re\nN = 1\nobservations = []\ndef solve(x):\n    qregs, cregs = {}, {}\n    nq = nc = 0\n    out = []\n    def ref(tok, regs):\n        m = re.fullmatch(r'([a-z]\\w*)(?:\\[(\\d+)\\])?', tok.strip())\n        name, idx = m.group(1), m.group(2)\n        if name not in regs:\n            raise KeyError('unknown-register')\n        off, size = regs[name]\n        if idx is None:\n            return [off + i for i in range(size)]\n        if int(idx) >= size:\n            raise KeyError('index-out-of-range')\n        return [off + int(idx)]\n    for no, stmt in enumerate(x):\n        s = stmt.strip().rstrip(';').strip()\n        head, _, rest = s.partition(' ')\n        try:\n            if head in ('qreg', 'creg'):\n                m = re.fullmatch(r'([a-z]\\w*)\\[(\\d+)\\]', rest.strip())\n                size = int(m.group(2))\n                if head == 'qreg':\n                    qregs[m.group(1)] = (nq, size)\n                    nq += size\n                else:\n                    cregs[m.group(1)] = (nc, size)\n                    nc += size\n            elif head == 'measure':\n                src, dst = rest.split('->')\n                qs, cs = ref(src, qregs), ref(dst, cregs)\n                if len(qs) != len(cs):\n                    raise KeyError('size-mismatch')\n                out += [['measure', a, b] for a, b in zip(qs, cs)]\n            else:\n                args = [ref(t, qregs) for t in rest.split(',')]\n                width = len(args[-1])\n                if any(len(a) not in (1, width) for a in args):\n                    raise KeyError('size-mismatch')\n                for i in range(width):\n                    out.append([head, [a[0] if len(a) == 1 else a[i] for a in args]])\n        except KeyError as e:\n            return [e.args[0], no]\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['regression: single control broadcast target', ['qreg q[1];', 'qreg r[3];', 'cx q[0],r;'], [['cx', [0, 1]], ['cx', [0, 2]], ['cx', [0, 3]]]], ['regression: random program 6', ['qreg q[3];', 'creg c[2];', 'cx q[2],q;'], [['cx', [2, 0]], ['cx', [2, 1]], ['cx', [2, 2]]]], ['repair check: register control single target', ['qreg q[3];', 'qreg r[1];', 'cx q,r[0];'], [['cx', [0, 3]], ['cx', [1, 3]], ['cx', [2, 3]]]], ['control: two registers broadcast', ['qreg q[2];', 'qreg r[2];', 'creg c[2];', 'cx q,r;', 'measure r -> c;'], [['cx', [0, 2]], ['cx', [1, 3]], ['measure', 2, 0], ['measure', 3, 1]]], ['control: creg declared between qregs', ['qreg a[1];', 'creg c[2];', 'qreg b[2];', 'h b[1];'], [['h', [2]]]], ['control: index equals size', ['qreg q[2];', 'h q[2];'], ['index-out-of-range', 1]], ['control: second register overflow', ['qreg q[2];', 'qreg r[2];', 'x r[3];'], ['index-out-of-range', 2]]], [['regression: random program 14', ['qreg q[3];', 'creg c[2];', 'qreg r[2];', 'creg d[3];', 'qreg s[2];', 'x r[1];', 'x q;', 'x r[0];', 'cx s[0],r;'], [['x', [4]], ['x', [0]], ['x', [1]], ['x', [2]], ['x', [3]], ['cx', [5, 3]], ['cx', [5, 4]]]], ['regression: random program 17', ['qreg q[2];', 'qreg r[3];', 'creg c[3];', 'qreg s[2];', 'measure q[1] -> c[2];', 'cx s,r[2];', 'measure q[0] -> c[2];', 'cx s[0],r;'], [['measure', 1, 2], ['cx', [5, 4]], ['cx', [6, 4]], ['measure', 0, 2], ['cx', [5, 2]], ['cx', [5, 3]], ['cx', [5, 4]]]], ['repair check: random program 32', ['qreg q[2];', 'creg c[2];', 'qreg r[1];', 'creg d[3];', 'qreg s[3];', 'h q[0];', 'cx s,s[0];', 'measure s[2] -> c[1];'], [['h', [0]], ['cx', [3, 3]], ['cx', [4, 3]], ['cx', [5, 3]], ['measure', 5, 1]]], ['control: measure size mismatch', ['qreg q[3];', 'creg c[2];', 'measure q -> c;'], ['size-mismatch', 2]], ['control: measure into qreg name', ['qreg q[1];', 'qreg r[1];', 'measure q[0] -> r[0];'], ['unknown-register', 2]], ['control: unknown register', ['qreg q[1];', 'h z[0];'], ['unknown-register', 1]], ['control: random program 0', ['qreg q[2];', 'creg c[2];', 'h q[0];', 'measure q[1] -> c[0];'], [['h', [0]], ['measure', 1, 0]]]], [['regression: single control broadcast target', ['qreg q[1];', 'qreg r[3];', 'cx q[0],r;'], [['cx', [0, 1]], ['cx', [0, 2]], ['cx', [0, 3]]]], ['regression: random program 6', ['qreg q[3];', 'creg c[2];', 'cx q[2],q;'], [['cx', [2, 0]], ['cx', [2, 1]], ['cx', [2, 2]]]], ['repair check: random program 47', ['qreg q[1];', 'creg c[1];', 'qreg r[2];', 'creg d[3];', 'qreg s[3];', 'cx q,s[1];', 'cx s,r[1];'], [['cx', [0, 4]], ['cx', [3, 2]], ['cx', [4, 2]], ['cx', [5, 2]]]], ['control: random program 1', ['qreg q[3];', 'creg c[2];', 'h q;', 'measure q[0] -> c;'], ['size-mismatch', 3]], ['control: random program 2', ['qreg q[3];', 'creg c[3];', 'qreg r[1];', 'creg d[1];', 'h q[1];'], [['h', [1]]]], ['control: random program 3', ['qreg q[2];', 'creg c[2];', 'h q[1];'], [['h', [1]]]], ['control: random program 4', ['qreg q[3];', 'creg c[3];', 'qreg r[1];', 'creg d[3];', 'qreg s[1];', 'creg e[2];', 'x s;', 'measure s[0] -> e;', 'cx q,r[0];'], ['size-mismatch', 7]]], [['regression: random program 14', ['qreg q[3];', 'creg c[2];', 'qreg r[2];', 'creg d[3];', 'qreg s[2];', 'x r[1];', 'x q;', 'x r[0];', 'cx s[0],r;'], [['x', [4]], ['x', [0]], ['x', [1]], ['x', [2]], ['x', [3]], ['cx', [5, 3]], ['cx', [5, 4]]]], ['regression: random program 17', ['qreg q[2];', 'qreg r[3];', 'creg c[3];', 'qreg s[2];', 'measure q[1] -> c[2];', 'cx s,r[2];', 'measure q[0] -> c[2];', 'cx s[0],r;'], [['measure', 1, 2], ['cx', [5, 4]], ['cx', [6, 4]], ['measure', 0, 2], ['cx', [5, 2]], ['cx', [5, 3]], ['cx', [5, 4]]]], ['repair check: register control single target', ['qreg q[3];', 'qreg r[1];', 'cx q,r[0];'], [['cx', [0, 3]], ['cx', [1, 3]], ['cx', [2, 3]]]], ['control: random program 5', ['qreg q[1];', 'creg c[3];', 'qreg r[1];', 'creg d[3];', 'cx r[0],q[0];', 'measure r -> d[0];', 'cx q[0],q[0];', 'cx r[0],r;'], [['cx', [1, 0]], ['measure', 1, 3], ['cx', [0, 0]], ['cx', [1, 1]]]], ['control: random program 7', ['qreg q[1];', 'creg c[3];', 'x q;', 'cx q,q[1];', 'cx q[0],q[0];', 'cx q[0],q;'], ['index-out-of-range', 3]], ['control: random program 8', ['qreg q[2];', 'qreg r[1];', 'qreg s[2];', 'creg c[2];', 'cx r[0],s[1];', 'h s;', 'measure q[1] -> c[1];', 'h s;'], [['cx', [2, 4]], ['h', [3]], ['h', [4]], ['measure', 1, 1], ['h', [3]], ['h', [4]]]], ['control: random program 9', ['qreg q[1];', 'qreg r[1];', 'qreg s[1];', 'creg c[2];', 'h q[0];'], [['h', [0]]]]], [['regression: single control broadcast target', ['qreg q[1];', 'qreg r[3];', 'cx q[0],r;'], [['cx', [0, 1]], ['cx', [0, 2]], ['cx', [0, 3]]]], ['regression: random program 6', ['qreg q[3];', 'creg c[2];', 'cx q[2],q;'], [['cx', [2, 0]], ['cx', [2, 1]], ['cx', [2, 2]]]], ['repair check: random program 32', ['qreg q[2];', 'creg c[2];', 'qreg r[1];', 'creg d[3];', 'qreg s[3];', 'h q[0];', 'cx s,s[0];', 'measure s[2] -> c[1];'], [['h', [0]], ['cx', [3, 3]], ['cx', [4, 3]], ['cx', [5, 3]], ['measure', 5, 1]]], ['control: random program 10', ['qreg q[2];', 'qreg r[2];', 'creg c[2];', 'h q[0];', 'x q;', 'measure r[0] -> c;'], ['size-mismatch', 5]], ['control: random program 11', ['qreg q[2];', 'creg c[1];', 'qreg r[1];', 'creg d[3];', 'measure q -> d[2];', 'x r[0];', 'x q;', 'measure q[0] -> d[0];'], ['size-mismatch', 4]], ['control: random program 12', ['qreg q[3];', 'creg c[1];', 'qreg r[2];', 'creg d[3];', 'x q;', 'h r;', 'x r[1];'], [['x', [0]], ['x', [1]], ['x', [2]], ['h', [3]], ['h', [4]], ['x', [4]]]], ['control: random program 15', ['qreg q[1];', 'qreg r[2];', 'qreg s[3];', 'creg c[2];', 'x q;', 'h r[1];', 'cx s[2],r[1];', 'cx r[1],q[0];'], [['x', [0]], ['h', [2]], ['cx', [5, 2]], ['cx', [2, 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":"85c191eb2c95a8b97b7943b337a842de97d0f49b2b6db1f9972116c6646815ea","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport re\nN = 1\nobservations = []\ndef solve(x):\n    qregs, cregs = {}, {}\n    nq = nc = 0\n    out = []\n    def ref(tok, regs):\n        m = re.fullmatch(r'([a-z]\\w*)(?:\\[(\\d+)\\])?', tok.strip())\n        name, idx = m.group(1), m.group(2)\n        if name not in regs:\n            raise KeyError('unknown-register')\n        off, size = regs[name]\n        if idx is None:\n            return [off + i for i in range(size)]\n        if int(idx) >= size:\n            raise KeyError('index-out-of-range')\n        return [off + int(idx)]\n    for no, stmt in enumerate(x):\n        s = stmt.strip().rstrip(';').strip()\n        head, _, rest = s.partition(' ')\n        try:\n            if head in ('qreg', 'creg'):\n                m = re.fullmatch(r'([a-z]\\w*)\\[(\\d+)\\]', rest.strip())\n                size = int(m.group(2))\n                if head == 'qreg':\n                    qregs[m.group(1)] = (nq, size)\n                    nq += size\n                else:\n                    cregs[m.group(1)] = (nc, size)\n                    nc += size\n            elif head == 'measure':\n                src, dst = rest.split('->')\n                qs, cs = ref(src, qregs), ref(dst, cregs)\n                if len(qs) != len(cs):\n                    raise KeyError('size-mismatch')\n                out += [['measure', a, b] for a, b in zip(qs, cs)]\n            else:\n                args = [ref(t, qregs) for t in rest.split(',')]\n                width = len(args[0])\n                if any(len(a) not in (1, width) for a in args):\n                    raise KeyError('size-mismatch')\n                for i in range(width):\n                    out.append([head, [a[0] if len(a) == 1 else a[i] for a in args]])\n        except KeyError as e:\n            return [e.args[0], no]\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['regression: single control broadcast target', ['qreg q[1];', 'qreg r[3];', 'cx q[0],r;'], [['cx', [0, 1]], ['cx', [0, 2]], ['cx', [0, 3]]]], ['regression: random program 6', ['qreg q[3];', 'creg c[2];', 'cx q[2],q;'], [['cx', [2, 0]], ['cx', [2, 1]], ['cx', [2, 2]]]], ['repair check: register control single target', ['qreg q[3];', 'qreg r[1];', 'cx q,r[0];'], [['cx', [0, 3]], ['cx', [1, 3]], ['cx', [2, 3]]]], ['control: two registers broadcast', ['qreg q[2];', 'qreg r[2];', 'creg c[2];', 'cx q,r;', 'measure r -> c;'], [['cx', [0, 2]], ['cx', [1, 3]], ['measure', 2, 0], ['measure', 3, 1]]], ['control: creg declared between qregs', ['qreg a[1];', 'creg c[2];', 'qreg b[2];', 'h b[1];'], [['h', [2]]]], ['control: index equals size', ['qreg q[2];', 'h q[2];'], ['index-out-of-range', 1]], ['control: second register overflow', ['qreg q[2];', 'qreg r[2];', 'x r[3];'], ['index-out-of-range', 2]]], [['regression: random program 14', ['qreg q[3];', 'creg c[2];', 'qreg r[2];', 'creg d[3];', 'qreg s[2];', 'x r[1];', 'x q;', 'x r[0];', 'cx s[0],r;'], [['x', [4]], ['x', [0]], ['x', [1]], ['x', [2]], ['x', [3]], ['cx', [5, 3]], ['cx', [5, 4]]]], ['regression: random program 17', ['qreg q[2];', 'qreg r[3];', 'creg c[3];', 'qreg s[2];', 'measure q[1] -> c[2];', 'cx s,r[2];', 'measure q[0] -> c[2];', 'cx s[0],r;'], [['measure', 1, 2], ['cx', [5, 4]], ['cx', [6, 4]], ['measure', 0, 2], ['cx', [5, 2]], ['cx', [5, 3]], ['cx', [5, 4]]]], ['repair check: random program 32', ['qreg q[2];', 'creg c[2];', 'qreg r[1];', 'creg d[3];', 'qreg s[3];', 'h q[0];', 'cx s,s[0];', 'measure s[2] -> c[1];'], [['h', [0]], ['cx', [3, 3]], ['cx', [4, 3]], ['cx', [5, 3]], ['measure', 5, 1]]], ['control: measure size mismatch', ['qreg q[3];', 'creg c[2];', 'measure q -> c;'], ['size-mismatch', 2]], ['control: measure into qreg name', ['qreg q[1];', 'qreg r[1];', 'measure q[0] -> r[0];'], ['unknown-register', 2]], ['control: unknown register', ['qreg q[1];', 'h z[0];'], ['unknown-register', 1]], ['control: random program 0', ['qreg q[2];', 'creg c[2];', 'h q[0];', 'measure q[1] -> c[0];'], [['h', [0]], ['measure', 1, 0]]]], [['regression: single control broadcast target', ['qreg q[1];', 'qreg r[3];', 'cx q[0],r;'], [['cx', [0, 1]], ['cx', [0, 2]], ['cx', [0, 3]]]], ['regression: random program 6', ['qreg q[3];', 'creg c[2];', 'cx q[2],q;'], [['cx', [2, 0]], ['cx', [2, 1]], ['cx', [2, 2]]]], ['repair check: random program 47', ['qreg q[1];', 'creg c[1];', 'qreg r[2];', 'creg d[3];', 'qreg s[3];', 'cx q,s[1];', 'cx s,r[1];'], [['cx', [0, 4]], ['cx', [3, 2]], ['cx', [4, 2]], ['cx', [5, 2]]]], ['control: random program 1', ['qreg q[3];', 'creg c[2];', 'h q;', 'measure q[0] -> c;'], ['size-mismatch', 3]], ['control: random program 2', ['qreg q[3];', 'creg c[3];', 'qreg r[1];', 'creg d[1];', 'h q[1];'], [['h', [1]]]], ['control: random program 3', ['qreg q[2];', 'creg c[2];', 'h q[1];'], [['h', [1]]]], ['control: random program 4', ['qreg q[3];', 'creg c[3];', 'qreg r[1];', 'creg d[3];', 'qreg s[1];', 'creg e[2];', 'x s;', 'measure s[0] -> e;', 'cx q,r[0];'], ['size-mismatch', 7]]], [['regression: random program 14', ['qreg q[3];', 'creg c[2];', 'qreg r[2];', 'creg d[3];', 'qreg s[2];', 'x r[1];', 'x q;', 'x r[0];', 'cx s[0],r;'], [['x', [4]], ['x', [0]], ['x', [1]], ['x', [2]], ['x', [3]], ['cx', [5, 3]], ['cx', [5, 4]]]], ['regression: random program 17', ['qreg q[2];', 'qreg r[3];', 'creg c[3];', 'qreg s[2];', 'measure q[1] -> c[2];', 'cx s,r[2];', 'measure q[0] -> c[2];', 'cx s[0],r;'], [['measure', 1, 2], ['cx', [5, 4]], ['cx', [6, 4]], ['measure', 0, 2], ['cx', [5, 2]], ['cx', [5, 3]], ['cx', [5, 4]]]], ['repair check: register control single target', ['qreg q[3];', 'qreg r[1];', 'cx q,r[0];'], [['cx', [0, 3]], ['cx', [1, 3]], ['cx', [2, 3]]]], ['control: random program 5', ['qreg q[1];', 'creg c[3];', 'qreg r[1];', 'creg d[3];', 'cx r[0],q[0];', 'measure r -> d[0];', 'cx q[0],q[0];', 'cx r[0],r;'], [['cx', [1, 0]], ['measure', 1, 3], ['cx', [0, 0]], ['cx', [1, 1]]]], ['control: random program 7', ['qreg q[1];', 'creg c[3];', 'x q;', 'cx q,q[1];', 'cx q[0],q[0];', 'cx q[0],q;'], ['index-out-of-range', 3]], ['control: random program 8', ['qreg q[2];', 'qreg r[1];', 'qreg s[2];', 'creg c[2];', 'cx r[0],s[1];', 'h s;', 'measure q[1] -> c[1];', 'h s;'], [['cx', [2, 4]], ['h', [3]], ['h', [4]], ['measure', 1, 1], ['h', [3]], ['h', [4]]]], ['control: random program 9', ['qreg q[1];', 'qreg r[1];', 'qreg s[1];', 'creg c[2];', 'h q[0];'], [['h', [0]]]]], [['regression: single control broadcast target', ['qreg q[1];', 'qreg r[3];', 'cx q[0],r;'], [['cx', [0, 1]], ['cx', [0, 2]], ['cx', [0, 3]]]], ['regression: random program 6', ['qreg q[3];', 'creg c[2];', 'cx q[2],q;'], [['cx', [2, 0]], ['cx', [2, 1]], ['cx', [2, 2]]]], ['repair check: random program 32', ['qreg q[2];', 'creg c[2];', 'qreg r[1];', 'creg d[3];', 'qreg s[3];', 'h q[0];', 'cx s,s[0];', 'measure s[2] -> c[1];'], [['h', [0]], ['cx', [3, 3]], ['cx', [4, 3]], ['cx', [5, 3]], ['measure', 5, 1]]], ['control: random program 10', ['qreg q[2];', 'qreg r[2];', 'creg c[2];', 'h q[0];', 'x q;', 'measure r[0] -> c;'], ['size-mismatch', 5]], ['control: random program 11', ['qreg q[2];', 'creg c[1];', 'qreg r[1];', 'creg d[3];', 'measure q -> d[2];', 'x r[0];', 'x q;', 'measure q[0] -> d[0];'], ['size-mismatch', 4]], ['control: random program 12', ['qreg q[3];', 'creg c[1];', 'qreg r[2];', 'creg d[3];', 'x q;', 'h r;', 'x r[1];'], [['x', [0]], ['x', [1]], ['x', [2]], ['h', [3]], ['h', [4]], ['x', [4]]]], ['control: random program 15', ['qreg q[1];', 'qreg r[2];', 'qreg s[3];', 'creg c[2];', 'x q;', 'h r[1];', 'cx s[2],r[1];', 'cx r[1],q[0];'], [['x', [0]], ['h', [2]], ['cx', [5, 2]], ['cx', [2, 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":"b02304a508f373a8f3cb4f8ba6f0fe52aad2ba7f41a76fb5f24327b018298aa2","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport re\nN = 1\nobservations = []\ndef solve(x):\n    qregs, cregs = {}, {}\n    nq = nc = 0\n    out = []\n    def ref(tok, regs):\n        m = re.fullmatch(r'([a-z]\\w*)(?:\\[(\\d+)\\])?', tok.strip())\n        name, idx = m.group(1), m.group(2)\n        if name not in regs:\n            raise KeyError('unknown-register')\n        off, size = regs[name]\n        if idx is None:\n            return [off + i for i in range(size)]\n        if int(idx) >= size:\n            raise KeyError('index-out-of-range')\n        return [off + int(idx)]\n    for no, stmt in enumerate(x):\n        s = stmt.strip().rstrip(';').strip()\n        head, _, rest = s.partition(' ')\n        try:\n            if head in ('qreg', 'creg'):\n                m = re.fullmatch(r'([a-z]\\w*)\\[(\\d+)\\]', rest.strip())\n                size = int(m.group(2))\n                if head == 'qreg':\n                    qregs[m.group(1)] = (nq, size)\n                    nq += size\n                else:\n                    cregs[m.group(1)] = (nc, size)\n                    nc += size\n            elif head == 'measure':\n                src, dst = rest.split('->')\n                qs, cs = ref(src, qregs), ref(dst, cregs)\n                if len(qs) != len(cs):\n                    raise KeyError('size-mismatch')\n                out += [['measure', a, b] for a, b in zip(qs, cs)]\n            else:\n                args = [ref(t, qregs) for t in rest.split(',')]\n                width = max(len(a) for a in args)\n                if any(len(a) not in (1, width) for a in args):\n                    raise KeyError('size-mismatch')\n                for i in range(width):\n                    out.append([head, [a[0] if len(a) == 1 else a[i] for a in args]])\n        except KeyError as e:\n            return [e.args[0], no]\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['regression: single control broadcast target', ['qreg q[1];', 'qreg r[3];', 'cx q[0],r;'], [['cx', [0, 1]], ['cx', [0, 2]], ['cx', [0, 3]]]], ['regression: random program 6', ['qreg q[3];', 'creg c[2];', 'cx q[2],q;'], [['cx', [2, 0]], ['cx', [2, 1]], ['cx', [2, 2]]]], ['repair check: register control single target', ['qreg q[3];', 'qreg r[1];', 'cx q,r[0];'], [['cx', [0, 3]], ['cx', [1, 3]], ['cx', [2, 3]]]], ['control: two registers broadcast', ['qreg q[2];', 'qreg r[2];', 'creg c[2];', 'cx q,r;', 'measure r -> c;'], [['cx', [0, 2]], ['cx', [1, 3]], ['measure', 2, 0], ['measure', 3, 1]]], ['control: creg declared between qregs', ['qreg a[1];', 'creg c[2];', 'qreg b[2];', 'h b[1];'], [['h', [2]]]], ['control: index equals size', ['qreg q[2];', 'h q[2];'], ['index-out-of-range', 1]], ['control: second register overflow', ['qreg q[2];', 'qreg r[2];', 'x r[3];'], ['index-out-of-range', 2]]], [['regression: random program 14', ['qreg q[3];', 'creg c[2];', 'qreg r[2];', 'creg d[3];', 'qreg s[2];', 'x r[1];', 'x q;', 'x r[0];', 'cx s[0],r;'], [['x', [4]], ['x', [0]], ['x', [1]], ['x', [2]], ['x', [3]], ['cx', [5, 3]], ['cx', [5, 4]]]], ['regression: random program 17', ['qreg q[2];', 'qreg r[3];', 'creg c[3];', 'qreg s[2];', 'measure q[1] -> c[2];', 'cx s,r[2];', 'measure q[0] -> c[2];', 'cx s[0],r;'], [['measure', 1, 2], ['cx', [5, 4]], ['cx', [6, 4]], ['measure', 0, 2], ['cx', [5, 2]], ['cx', [5, 3]], ['cx', [5, 4]]]], ['repair check: random program 32', ['qreg q[2];', 'creg c[2];', 'qreg r[1];', 'creg d[3];', 'qreg s[3];', 'h q[0];', 'cx s,s[0];', 'measure s[2] -> c[1];'], [['h', [0]], ['cx', [3, 3]], ['cx', [4, 3]], ['cx', [5, 3]], ['measure', 5, 1]]], ['control: measure size mismatch', ['qreg q[3];', 'creg c[2];', 'measure q -> c;'], ['size-mismatch', 2]], ['control: measure into qreg name', ['qreg q[1];', 'qreg r[1];', 'measure q[0] -> r[0];'], ['unknown-register', 2]], ['control: unknown register', ['qreg q[1];', 'h z[0];'], ['unknown-register', 1]], ['control: random program 0', ['qreg q[2];', 'creg c[2];', 'h q[0];', 'measure q[1] -> c[0];'], [['h', [0]], ['measure', 1, 0]]]], [['regression: single control broadcast target', ['qreg q[1];', 'qreg r[3];', 'cx q[0],r;'], [['cx', [0, 1]], ['cx', [0, 2]], ['cx', [0, 3]]]], ['regression: random program 6', ['qreg q[3];', 'creg c[2];', 'cx q[2],q;'], [['cx', [2, 0]], ['cx', [2, 1]], ['cx', [2, 2]]]], ['repair check: random program 47', ['qreg q[1];', 'creg c[1];', 'qreg r[2];', 'creg d[3];', 'qreg s[3];', 'cx q,s[1];', 'cx s,r[1];'], [['cx', [0, 4]], ['cx', [3, 2]], ['cx', [4, 2]], ['cx', [5, 2]]]], ['control: random program 1', ['qreg q[3];', 'creg c[2];', 'h q;', 'measure q[0] -> c;'], ['size-mismatch', 3]], ['control: random program 2', ['qreg q[3];', 'creg c[3];', 'qreg r[1];', 'creg d[1];', 'h q[1];'], [['h', [1]]]], ['control: random program 3', ['qreg q[2];', 'creg c[2];', 'h q[1];'], [['h', [1]]]], ['control: random program 4', ['qreg q[3];', 'creg c[3];', 'qreg r[1];', 'creg d[3];', 'qreg s[1];', 'creg e[2];', 'x s;', 'measure s[0] -> e;', 'cx q,r[0];'], ['size-mismatch', 7]]], [['regression: random program 14', ['qreg q[3];', 'creg c[2];', 'qreg r[2];', 'creg d[3];', 'qreg s[2];', 'x r[1];', 'x q;', 'x r[0];', 'cx s[0],r;'], [['x', [4]], ['x', [0]], ['x', [1]], ['x', [2]], ['x', [3]], ['cx', [5, 3]], ['cx', [5, 4]]]], ['regression: random program 17', ['qreg q[2];', 'qreg r[3];', 'creg c[3];', 'qreg s[2];', 'measure q[1] -> c[2];', 'cx s,r[2];', 'measure q[0] -> c[2];', 'cx s[0],r;'], [['measure', 1, 2], ['cx', [5, 4]], ['cx', [6, 4]], ['measure', 0, 2], ['cx', [5, 2]], ['cx', [5, 3]], ['cx', [5, 4]]]], ['repair check: register control single target', ['qreg q[3];', 'qreg r[1];', 'cx q,r[0];'], [['cx', [0, 3]], ['cx', [1, 3]], ['cx', [2, 3]]]], ['control: random program 5', ['qreg q[1];', 'creg c[3];', 'qreg r[1];', 'creg d[3];', 'cx r[0],q[0];', 'measure r -> d[0];', 'cx q[0],q[0];', 'cx r[0],r;'], [['cx', [1, 0]], ['measure', 1, 3], ['cx', [0, 0]], ['cx', [1, 1]]]], ['control: random program 7', ['qreg q[1];', 'creg c[3];', 'x q;', 'cx q,q[1];', 'cx q[0],q[0];', 'cx q[0],q;'], ['index-out-of-range', 3]], ['control: random program 8', ['qreg q[2];', 'qreg r[1];', 'qreg s[2];', 'creg c[2];', 'cx r[0],s[1];', 'h s;', 'measure q[1] -> c[1];', 'h s;'], [['cx', [2, 4]], ['h', [3]], ['h', [4]], ['measure', 1, 1], ['h', [3]], ['h', [4]]]], ['control: random program 9', ['qreg q[1];', 'qreg r[1];', 'qreg s[1];', 'creg c[2];', 'h q[0];'], [['h', [0]]]]], [['regression: single control broadcast target', ['qreg q[1];', 'qreg r[3];', 'cx q[0],r;'], [['cx', [0, 1]], ['cx', [0, 2]], ['cx', [0, 3]]]], ['regression: random program 6', ['qreg q[3];', 'creg c[2];', 'cx q[2],q;'], [['cx', [2, 0]], ['cx', [2, 1]], ['cx', [2, 2]]]], ['repair check: random program 32', ['qreg q[2];', 'creg c[2];', 'qreg r[1];', 'creg d[3];', 'qreg s[3];', 'h q[0];', 'cx s,s[0];', 'measure s[2] -> c[1];'], [['h', [0]], ['cx', [3, 3]], ['cx', [4, 3]], ['cx', [5, 3]], ['measure', 5, 1]]], ['control: random program 10', ['qreg q[2];', 'qreg r[2];', 'creg c[2];', 'h q[0];', 'x q;', 'measure r[0] -> c;'], ['size-mismatch', 5]], ['control: random program 11', ['qreg q[2];', 'creg c[1];', 'qreg r[1];', 'creg d[3];', 'measure q -> d[2];', 'x r[0];', 'x q;', 'measure q[0] -> d[0];'], ['size-mismatch', 4]], ['control: random program 12', ['qreg q[3];', 'creg c[1];', 'qreg r[2];', 'creg d[3];', 'x q;', 'h r;', 'x r[1];'], [['x', [0]], ['x', [1]], ['x', [2]], ['h', [3]], ['h', [4]], ['x', [4]]]], ['control: random program 15', ['qreg q[1];', 'qreg r[2];', 'qreg s[3];', 'creg c[2];', 'x q;', 'h r[1];', 'cx s[2],r[1];', 'cx r[1],q[0];'], [['x', [0]], ['h', [2]], ['cx', [5, 2]], ['cx', [2, 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-qasm-register-expansion-broadcast-width","generated_at":"2026-09-29T14:51:34.867496+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Front-end register flattening decides which physical qubits every later pass touches; offset or broadcast slips silently rewire circuits.","repair":"Use the maximum operand width.","root_cause":"The broadcast width is len(args[0]) rather than the widest operand.","sha256":"cf306f1e7f5e42abbd71f1a1bffc5eb4a296f35ac78a7534818dc4883d19c283","title":"Register expansion takes broadcast width from the first operand · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":41.441,"exit_code":1,"observations":[{"actual":[["cx",[0,1]],["cx",[0,2]],["cx",[0,3]]],"check":"regression: single control broadcast target","expected":[["cx",[0,1]],["cx",[0,2]],["cx",[0,3]]],"passed":true},{"actual":[["cx",[2,0]],["cx",[2,1]],["cx",[2,2]]],"check":"regression: random program 6","expected":[["cx",[2,0]],["cx",[2,1]],["cx",[2,2]]],"passed":true},{"actual":["size-mismatch",2],"check":"repair check: register control single target","expected":[["cx",[0,3]],["cx",[1,3]],["cx",[2,3]]],"passed":false},{"actual":[["cx",[0,2]],["cx",[1,3]],["measure",2,0],["measure",3,1]],"check":"control: two registers broadcast","expected":[["cx",[0,2]],["cx",[1,3]],["measure",2,0],["measure",3,1]],"passed":true},{"actual":[["h",[2]]],"check":"control: creg declared between qregs","expected":[["h",[2]]],"passed":true},{"actual":["index-out-of-range",1],"check":"control: index equals size","expected":["index-out-of-range",1],"passed":true},{"actual":["index-out-of-range",2],"check":"control: second register overflow","expected":["index-out-of-range",2],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: single control broadcast target\", \"actual\": [[\"cx\", [0, 1]], [\"cx\", [0, 2]], [\"cx\", [0, 3]]], \"expected\": [[\"cx\", [0, 1]], [\"cx\", [0, 2]], [\"cx\", [0, 3]]], \"passed\": true}, {\"check\": \"regression: random program 6\", \"actual\": [[\"cx\", [2, 0]], [\"cx\", [2, 1]], [\"cx\", [2, 2]]], \"expected\": [[\"cx\", [2, 0]], [\"cx\", [2, 1]], [\"cx\", [2, 2]]], \"passed\": true}, {\"check\": \"repair check: register control single target\", \"actual\": [\"size-mismatch\", 2], \"expected\": [[\"cx\", [0, 3]], [\"cx\", [1, 3]], [\"cx\", [2, 3]]], \"passed\": false}, {\"check\": \"control: two registers broadcast\", \"actual\": [[\"cx\", [0, 2]], [\"cx\", [1, 3]], [\"measure\", 2, 0], [\"measure\", 3, 1]], \"expected\": [[\"cx\", [0, 2]], [\"cx\", [1, 3]], [\"measure\", 2, 0], [\"measure\", 3, 1]], \"passed\": true}, {\"check\": \"control: creg declared between qregs\", \"actual\": [[\"h\", [2]]], \"expected\": [[\"h\", [2]]], \"passed\": true}, {\"check\": \"control: index equals size\", \"actual\": [\"index-out-of-range\", 1], \"expected\": [\"index-out-of-range\", 1], \"passed\": true}, {\"check\": \"control: second register overflow\", \"actual\": [\"index-out-of-range\", 2], \"expected\": [\"index-out-of-range\", 2], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":40.984,"exit_code":1,"observations":[{"actual":["size-mismatch",2],"check":"regression: single control broadcast target","expected":[["cx",[0,1]],["cx",[0,2]],["cx",[0,3]]],"passed":false},{"actual":["size-mismatch",2],"check":"regression: random program 6","expected":[["cx",[2,0]],["cx",[2,1]],["cx",[2,2]]],"passed":false},{"actual":[["cx",[0,3]],["cx",[1,3]],["cx",[2,3]]],"check":"repair check: register control single target","expected":[["cx",[0,3]],["cx",[1,3]],["cx",[2,3]]],"passed":true},{"actual":[["cx",[0,2]],["cx",[1,3]],["measure",2,0],["measure",3,1]],"check":"control: two registers broadcast","expected":[["cx",[0,2]],["cx",[1,3]],["measure",2,0],["measure",3,1]],"passed":true},{"actual":[["h",[2]]],"check":"control: creg declared between qregs","expected":[["h",[2]]],"passed":true},{"actual":["index-out-of-range",1],"check":"control: index equals size","expected":["index-out-of-range",1],"passed":true},{"actual":["index-out-of-range",2],"check":"control: second register overflow","expected":["index-out-of-range",2],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: single control broadcast target\", \"actual\": [\"size-mismatch\", 2], \"expected\": [[\"cx\", [0, 1]], [\"cx\", [0, 2]], [\"cx\", [0, 3]]], \"passed\": false}, {\"check\": \"regression: random program 6\", \"actual\": [\"size-mismatch\", 2], \"expected\": [[\"cx\", [2, 0]], [\"cx\", [2, 1]], [\"cx\", [2, 2]]], \"passed\": false}, {\"check\": \"repair check: register control single target\", \"actual\": [[\"cx\", [0, 3]], [\"cx\", [1, 3]], [\"cx\", [2, 3]]], \"expected\": [[\"cx\", [0, 3]], [\"cx\", [1, 3]], [\"cx\", [2, 3]]], \"passed\": true}, {\"check\": \"control: two registers broadcast\", \"actual\": [[\"cx\", [0, 2]], [\"cx\", [1, 3]], [\"measure\", 2, 0], [\"measure\", 3, 1]], \"expected\": [[\"cx\", [0, 2]], [\"cx\", [1, 3]], [\"measure\", 2, 0], [\"measure\", 3, 1]], \"passed\": true}, {\"check\": \"control: creg declared between qregs\", \"actual\": [[\"h\", [2]]], \"expected\": [[\"h\", [2]]], \"passed\": true}, {\"check\": \"control: index equals size\", \"actual\": [\"index-out-of-range\", 1], \"expected\": [\"index-out-of-range\", 1], \"passed\": true}, {\"check\": \"control: second register overflow\", \"actual\": [\"index-out-of-range\", 2], \"expected\": [\"index-out-of-range\", 2], \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":41.897,"exit_code":0,"observations":[{"actual":[["cx",[0,1]],["cx",[0,2]],["cx",[0,3]]],"check":"regression: single control broadcast target","expected":[["cx",[0,1]],["cx",[0,2]],["cx",[0,3]]],"passed":true},{"actual":[["cx",[2,0]],["cx",[2,1]],["cx",[2,2]]],"check":"regression: random program 6","expected":[["cx",[2,0]],["cx",[2,1]],["cx",[2,2]]],"passed":true},{"actual":[["cx",[0,3]],["cx",[1,3]],["cx",[2,3]]],"check":"repair check: register control single target","expected":[["cx",[0,3]],["cx",[1,3]],["cx",[2,3]]],"passed":true},{"actual":[["cx",[0,2]],["cx",[1,3]],["measure",2,0],["measure",3,1]],"check":"control: two registers broadcast","expected":[["cx",[0,2]],["cx",[1,3]],["measure",2,0],["measure",3,1]],"passed":true},{"actual":[["h",[2]]],"check":"control: creg declared between qregs","expected":[["h",[2]]],"passed":true},{"actual":["index-out-of-range",1],"check":"control: index equals size","expected":["index-out-of-range",1],"passed":true},{"actual":["index-out-of-range",2],"check":"control: second register overflow","expected":["index-out-of-range",2],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: single control broadcast target\", \"actual\": [[\"cx\", [0, 1]], [\"cx\", [0, 2]], [\"cx\", [0, 3]]], \"expected\": [[\"cx\", [0, 1]], [\"cx\", [0, 2]], [\"cx\", [0, 3]]], \"passed\": true}, {\"check\": \"regression: random program 6\", \"actual\": [[\"cx\", [2, 0]], [\"cx\", [2, 1]], [\"cx\", [2, 2]]], \"expected\": [[\"cx\", [2, 0]], [\"cx\", [2, 1]], [\"cx\", [2, 2]]], \"passed\": true}, {\"check\": \"repair check: register control single target\", \"actual\": [[\"cx\", [0, 3]], [\"cx\", [1, 3]], [\"cx\", [2, 3]]], \"expected\": [[\"cx\", [0, 3]], [\"cx\", [1, 3]], [\"cx\", [2, 3]]], \"passed\": true}, {\"check\": \"control: two registers broadcast\", \"actual\": [[\"cx\", [0, 2]], [\"cx\", [1, 3]], [\"measure\", 2, 0], [\"measure\", 3, 1]], \"expected\": [[\"cx\", [0, 2]], [\"cx\", [1, 3]], [\"measure\", 2, 0], [\"measure\", 3, 1]], \"passed\": true}, {\"check\": \"control: creg declared between qregs\", \"actual\": [[\"h\", [2]]], \"expected\": [[\"h\", [2]]], \"passed\": true}, {\"check\": \"control: index equals size\", \"actual\": [\"index-out-of-range\", 1], \"expected\": [\"index-out-of-range\", 1], \"passed\": true}, {\"check\": \"control: second register overflow\", \"actual\": [\"index-out-of-range\", 2], \"expected\": [\"index-out-of-range\", 2], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}