barenco_tof_4_t24.qasm) to role circuit.Going below 24 likely needs a construction that doesn't separate toggles from stage phases: for example, phases applied while an ancilla is in its X frame, or a joint toggle of q4/q5. Literature results for C4X with dirty ancillas are the place to start. Note that Hadamard-gadget methods (TODD/AlphaTensor-style) need extra qubits, which this revision forbids.
Local tooling (outside TfP): pyzx, qiskit, mqt.qcec 3.11 and ortools from PyPI. Scripts build.py, build2.py, opt.py, norm.py, check.py and stage_ilp.py are in the job folder. The Skill could not be read: MCP resource reads fail client-side (ttlMs/cacheScope schema error). Reference inputs were fetched via their signed download_urls, and the hashes match.
T-count 24 (22 t + 2 tdg), 38 CX, 30 H, on the original 7 qubits. Gates: h, s, t, tdg, z, cx.
Method. The reference is Barenco's dirty-ancilla C4X: q6 ^= q0·q1·q2·q3, with q4 and q5 restored for every input. In the Hadamard frame of q6 this is the phase (−1)^{r·(x0x1)(x2x3)}. q4 is toggled by x0x1 and q5 by x2x3 using relative-phase (Margolus) Toffolis, 4 T each, in the order R1, R2, R1†, R2†. The relative phases depend only on the controls, so they cancel. The four stages visit (a,b), (a',b), (a',b'), (a,b') with a' = a⊕x0x1 and b' = b⊕x2x3. A CCZ(q4,q5,q6) in each stage multiplies out to (−1)^{r(a⊕a')(b⊕b')}, which is the target phase. I folded the four CCZ phase polynomials by hand, which PyZX cannot do across the Hadamards inside the relative-phase Toffolis: the r terms (4×) and the single-ancilla terms and ancilla⊕r terms (2× each) become Cliffords. That leaves 2 T per stage. Total: 4·4 + 4·2 = 24. I then cleaned up with PyZX full_optimize (T unchanged, fewer CX) and normalised rz/cz to the allowed gates.
Local checks. Exact 128×128 unitary equal to the reference up to global phase (qiskit Operator). MQT QCEC 3.11 default config returns equivalent, and the alternating DD checker alone also returns equivalent. The ZX checker alone gives its known false negative on resynthesised circuits.
What I ran (local, /home/user/work/ajb_tn1wz7dx6t/scripts; pyzx, qiskit, mqt.qcec 3.11 from PyPI):
a; they merge only because R1·X·R1† changes q5 alone, which is a semantic commutation that PyZX doesn't see.equivalent.ttlMs/cacheScope), so I could not read the pinned Skill. I downloaded reference_circuit and spec from their signed download_urls; sha256 matches the bound hashes.