What is the difference between only if and iff?

Let's assume A and B are two statements. Then to say "A only if B" means that A can only ever be true when B is true. That is, B is necessary for A to be true. To say "A if and only if B" means that A is true if B is true, and B is true if A is true. That is, A is necessary and sufficient for B. Succinctly,

$A \text{ only if } B$ is the logic statement $A \Rightarrow B$.

$A \text{ iff } B$ is the statement $(A \Rightarrow B) \land (B \Rightarrow A)$


I will find a million dollars inside this locker only if I know the combination.

But that doesn't mean I will find a million dollars there if I know the combination. After all, there might be only a half million in there.


A "only if B"

is the same as saying

"B is necessary" for A

which is the same as saying

A could not have happened without B

but that does mean that other things do not also need to happen for A to be true.

Therefore,

$A \to B$

but it is not true that $B \to A$ because B being true does not guarantee A happened. There could also be other requirements for A to be true.

e.g.:

You are eligible to be president only if you are at least 35 years old.

let $p$: "You are eligible to be president" and $a$: "You are at least 35 years old".

Here is is the case that $p \to a$,

but it is not the case that $a \to p$

In other words, $a$ is necessary for $p$, but just because $a$ is true does not mean that $a$ is the one single requirement for $p$. Just because you're at least 35 years old does not mean that you are eligible to be president.

As far as the difference goes, (which I guess was the specific question), if and only if means just that. $p$ if and only if $q$ means ($p$ if $q$) AND ($p$ only if $q$).


The bottom line is:

$p$ if $q$

equates

if $q$, then $p$

which is the same as $q \to p$

I just (hopefully well) explained that

$p$ only if $q$

equates

$p \to q$

Also,

$q \to p$ and $p \to q$

is the same as saying $p \iff q$

So there you have. One statement is unidirectional, the other is bidirectional.


If A then B is true unless A is true and B is false and written $A \implies B$.

A only if B is true unless A is true and B is false, equivalent to if A then B.

A if B is true unless A is false and B is true, the converse of the above, and is written $B \implies A$

A iff B, also written A if and only if B, is true if A and B have the same truth value. It represents (A if B) and (A only if B) and is written $A \iff B$


A real number is positive if and only if it is greater than zero.

A real number is an rational only if it has a finite decimal expansion. A real number, in general, however need not be rational.