Consider a sentence like
If $x \in \mathcal A$, then we define $f(x) = 0$.
Is it legetimate to replace "If" in that statement by "when", say, for the purpose of linguistic varietiy, such as in
When $x \in \mathcal A$, then we define $f(x) = 0$.
or is that considered bad style?