# Why must quantum logic gates be linear operators?

Why must quantum logic gates be linear operators? I mean, is it just a consequence of quantum mechanics postulates?

Suppose you pick a state $|\psi_i\rangle$ at random with probability $p_i$ and send it through a logic gate denoted by $G$. This random state is written as a density matrix $\rho = \sum_i p_i |\psi_i\rangle\!\langle\psi_i|$. Denote $G(|\psi_i\rangle\!\langle\psi_i|)$ as the result of applying $G$ to a particular state.
Now if the input is $|\psi_i\rangle\!\langle\psi_i|$ with probability $p_i$, then output is $G(|\psi_i\rangle\!\langle\psi_i|)$ also with probability $p_i$. Thus, the output state must be $\sum_i p_i G(|\psi_i\rangle\!\langle\psi_i|)$ and therefore $$G(\rho) \;=\; G\left(\sum_i p_i |\psi_i\rangle\!\langle\psi_i|\right) \;=\; \sum_i p_i G\Bigl(|\psi_i\rangle\!\langle\psi_i|\Bigr)\,.$$ This can be extended to random mixed input $\rho_i$ in place of $|\psi_i\rangle$, leading us to conclude that $G(\sum_i p_i \rho_i) = \sum_i p_i G(\rho_i)$, which is precisely the definition of linearity.