Fig. 5: An example in which measurement-based uncomputation tricks can be recovered by AlphaTensor-Quantum.

a, The original NC Toff3 circuit. b, The Hadamard gadgetization process maps a portion of the circuit to three CCZ gates. c, After moving all Clifford gates to the end, two of the CCZ gates (in the highlighted box) share two inputs. d, AlphaTensor-Quantum optimizes this pair by expressing it as a single gadget, saving one Toffoli gate with respect to the original construction. This kind of optimization happens often because CCZ gates can usually be moved freely along the circuit, as the corresponding unitary matrix will be diagonal after compilation. This is reminiscent of the temporary logical-AND construction from ref. 38, although some patterns with more than two CCZ gates can also be combined in this way.