A Handbook of Mathematical Discourse
only if
In the mathematical register, if $P$ and $Q$ are assertions, “$P$ only if $Q$” means $P$ implies $Q$. The phrase “only if” is rarely used this way in ordinary English discourse.
Example 1 The sentence
“4 divides $n$ only if 2 divides $n$”
means the same thing as the sentence
“If 4 divides $n$, then 2 divides $n$.”
Example 2 The sentence
“I will carry my umbrella only if it rains.”
does not mean the same thing as
“If I carry my umbrella, it will rain.”
Difficulties Students often get sentence in Example (1) backward, taking it to mean
(2 divides $n )\Rightarrow$ (4 divides $n$) Some of them flatly refuse to believe me when I tell them the correct interpretation. This is a classic example of semantic contamination, a form of cognitive dissonance – two sources of information appear to contradict each other, in this case the professor and a lifetime of intimate experience with the English language, with the consequence that one of them is rejected or suppressed. It is hardly suprising that some students prefer to suppress the professor’s apparently unnatural and usually unmotivated claims.
McCawley [1993] also rejects the equivalence of “$A$ only if $B$” with “If $A$, then $B$”, for ordinary discourse, but in the mathematical register the sentence must be taken to be equivalent to the others. This difference may have come about because conditional assertions in ordinary English carry connotations of causality and time dependence. Because mathematical objects are thought of as inert and eternal, the considerations that distinguish the two sentences in the example do not apply to statements such as the sentence in Example (1); the truth of the statement is determined entirely by the truth table for implication.
The remarks in the preceding paragraph may explain some of the difficulties students have with the contrapositive, as well.
Pages 182–183 of the book (PDF).