# Optimizations in quantum circuits

In a paper called On quantum circuits employing roots of the Pauli matrices, I found this figure, where I couldn't understand the equality in the circled circuits. I need an explanation of how the circuits in the circle are equal with any rules used in reduction. Especially the CNOT underlined in red - How it is reduced? For circuit equalities I find using quirk with the state-channel duality super useful where you setup the inverse of a circuit, see the identity in the amplitude display and then play around with the gates then on the left side.

In the given equality this is my thinking:

I'm sure there's simpler explanations :)

The two CNOTs that have gone missing have been moved rightward until they reach the CNOT between the two top qubits. They are then moved through that CNOT, which cancels one of them out. The remaining one was then moved to the right side of the circuit using the fact that its control can travel unmodified through phasing operations (S, T) and paired CNOTs. That being said, the decomposition you've relayed is not optimal. Because the two Toffoli operations share a target and a control, they can be merged into one Toffoli operation. Here's what that looks like: And this can be decomposed into a circuit using four T gates (instead of eight) by using an ancilla: • You mean that the CNOT underlined in red is cancelled by the CNOT between the two top qubits. but sorry I haven't studied a rule that says that. Can you share any reference with that rule? I only know that if 2 CNOTs share the same target and same control, the 2 CNOTs give Identity gate. Thanks for help. Nov 3 '20 at 23:38
• @monicamagdy just work out the truth table for the three involved bits to convince yourself it's the same. Nov 4 '20 at 1:39