# Valid actions of Reductions to NP-Completeness

To my understanding, as long as we can find some polytime function $f$ such that $\forall x:x \in A \Longleftrightarrow f(x) \in B, x\notin A \Longleftrightarrow f(x) \notin B$, it follows that if $A$ is NP-complete and B is in NP, then B is also in NP-complete.

My question is about what sort of 'things' we can do to obtain reductions from NP-completeness. That is, I want to know if $f$ is allowed to do anything so long as it is still done in polytime and satisfies the above property? If not, then what sort of limitations are there?

The only restriction is the one you mention: the reduction must work in polynomial time. That is, there must be some algorithm and some polynomial function $t(n)$ (e.g. $t(n)=n^5+n^3+42$) such that, on all inputs $x$ of length $n$, the algorithm outputs $f(x)$ and the time it takes the algorithm to do that is less than or equal to $t(n)$.