A closed quantum circuit cannot throw information away. Its gates are unitary operators, and unitary operators have inverses.
This is the basic reason quantum circuits are reversible.
Unitary means invertible
A closed-system quantum gate is represented by a unitary operator . By definition,
Therefore
So every valid closed-system quantum gate can be undone. If a state evolves as
then applying recovers the original state:
Irreversible classical functions lose information
Many classical functions are not reversible. For example,
loses information if only the sum is kept.
The output could have come from many inputs:
So the map
cannot be inverted in general. The output does not contain enough information to recover the input.
That kind of collapse is not allowed for a unitary gate, because a unitary gate must have a unique way back.
Reversible embeddings keep the input
To use a classical function inside a quantum circuit, one usually embeds it into a reversible transformation.
For a classical function , the standard pattern is
where is bitwise XOR.
The important point is that is preserved. The function value is written into a separate target register by modifying .
This transformation is reversible because applying it twice recovers the original target:
The input was kept all along, so the second application uses the same again.