IF AND ONLY IF
Compound sentences of the form "P if and only if Q" are true when P and Q are both false or are both true; this compound sentence is false otherwise. It says that P and Q have the same truth values; when "P if and only if Q" is true, it is often said that P and Q are logically equivalent. In fact, when "P if and only Q" is true, P can subsitute for Q and Q can subsitute for P in other compound sentences without changing the truth. "P if and only if Q" is rarely found in ordinary English; it's rather legalistic sounding!
The truth table below formalizes this understanding of "if and only if". T stands for true, and F stands for false.
What happens if you interchange (commute) P and Q in an "if and only if"? You get a sentence that means the same thing: if P and Q have the same truth values, it doesn't matter which is listed first. This is shown in the table below:
Theorems which have the form "P if and only Q" are much prized in mathematics. They give what are called "necessary and sufficient" conditions, and give completely equivalent and hopefully interesting new ways to say exactly the same thing. In high school geometry, an triangle is said to be equilateral if all three sides are equal. There is a theorem that says that a triangle is equilateral if and only if all three angles are equal. Once this theorem is presented, there are now at least two different ways to prove that something is (or is not) equilateral: work with the lengths of the sides or work with the sizes of the angles.
Theorems of the style "P if and only Q" are proved in several common ways. One style has two paragraphs: one of them show "if P then Q" and the other shows "if Q then P". Nothing more needs to be said, because the writer assumes that you know that "P if and only if Q" means the same as "(if P then Q) and (if Q then P)". This is proved in the truth table below:
Another style proceeds by a chain of "if and only if"'s. The writer explains that "P if and only if S". Then the writer explains that "S if and only if Q". Now the writer stops. It's supposed to be obvious that "P if and only if Q" is now proven (and to most people it is). Here's one way to understand it: if P and S always have the same truth values, and S and Q always have the same truth values, then P and Q always have the same truth values. The chain does not have to stop with two "if and only if"'s: suppose we know "P if and only if S1", "S1 if and only if S2", ..., and "S18 if and only Q". Then we know, "P if and only Q".