# 2 following gates, inverse circuit

I have a circuit that has 4 wires and 2 following each other Toffoli gates. The first Toffoli gate occupies 3 wires from above, the following Toffoli gate occupies 3 wires from below.
What will look like the inverse circuit of this entire circuit?

Thanks much!

-
Related question from OP: physics.stackexchange.com/q/57811/2451 –  Qmechanic Mar 25 '13 at 13:51
Yes, they are started similar, but here is quite another question :) –  ABCD Mar 25 '13 at 14:03

Well, if inverse means "how to undo", you just need to calculate the inverse matrix of the product of the two matrices discussed there: 2 following gates, permutation matrix

Have fun.

-
thanks, but I wonder how will the circuit look like –  ABCD Mar 25 '13 at 19:47
Well, it seems to me that a Toffoli gate is its own inverse when looking at the permutation table... By the way circuits and logic gates are supposed to be reversibly, isn't it ? –  FraSchelle Mar 25 '13 at 20:38
Thanks. I'm sorry, I don't understand your question. The circuit for an inverse of BA will look the same as the circuit for BA? –  ABCD Mar 26 '13 at 6:24
Not in general, but $(B.A)^{-1}=A^{-1}.B^{-1}$ and for Toffoli, $A^{-1}.B^{-1}=A.B$, am I right ? –  FraSchelle Mar 26 '13 at 9:27