If and only if
In that it is biconditional, the connective can be likened to the standard material conditional ("only if", equal to "if ... then") combined with its reverse ("if"); hence the name. The result is that the truth of either one of the connected statements requires the truth of the other, i.e., either both statements are true, or both are false. It is controversial whether the connective thus defined is properly rendered by the English "if and only if", with its pre-existing meaning. Of course, there is nothing to stop us stipulating that we may read this connective as "only if and if", although this may lead to confusion.
In writing, phrases commonly used, with debatable propriety, as alternatives to P "if and only if" Q include Q is necessary and sufficient for P, P is equivalent (or materially equivalent) to Q (compare material implication), P precisely if Q, P precisely (or exactly) when Q, P exactly in case Q, and P just in case Q. Many authors regard "iff" as unsuitable in formal writing; others use it freely.
In logic formulae, logical symbols are used instead of these phrases; see the discussion of notation.
p ↔ q
The corresponding logical symbols are "↔", "⇔" and "≡", and sometimes "iff". These are usually treated as equivalent. However, some texts of mathematical logic (particularly those on first-order logic, rather than propositional logic) make a distinction between these, in which the first, ↔, is used as a symbol in logic formulas, while ⇔ is used in reasoning about those logic formulas (e.g., in metalogic). In Łukasiewicz's notation, it is the prefix symbol 'E'.
In most logical systems, one proves a statement of the form "P iff Q" by proving "if P, then Q" and "if Q, then P". Proving this pair of statements sometimes leads to a more natural proof, since there are not obvious conditions in which one would infer a biconditional directly. An alternative is to prove the disjunction "(P and Q) or (not-P and not-Q)", which itself can be inferred directly from either of its disjuncts—that is, because "iff" is truth-functional, "P iff Q" follows if P and Q have both been shown true, or both false.
Origin of iff 
Usage of the abbreviation "iff" first appeared in print in John L. Kelley's 1955 book General Topology. Its invention is often credited to Paul Halmos, who wrote "I invented 'iff,' for 'if and only if'—but I could never believe I was really its first inventor."
Distinction from "if" and "only if" 
- "If the fruit is an apple, then Madison will eat it." or "Madison will eat the fruit if it is an apple." (equivalent to "Only if Madison will eat the fruit, is it an apple;" or "Madison will eat the fruit ← fruit is an apple")
- This states only that Madison will eat fruits that are apples. It does not, however, preclude the possibility that Madison might also have occasion to eat bananas. Maybe she will, maybe she will not—the sentence does not tell us. All we know for certain is that she will eat any and all apples that she happens upon. That the fruit is an apple is a sufficient condition for Madison to eat the fruit.
- "Only if the fruit is an apple, will Madison eat it." or "Madison will eat the fruit only if it is an apple." (equivalent to "If Madison will eat the fruit, then it is an apple" or "Madison will eat the fruit → fruit is an apple")
- This states that the only fruit Madison will eat is an apple. It does not, however, preclude the possibility that Madison will refuse an apple if it is made available, in contrast with (1), which requires Madison to eat any available apple. In this case, that a given fruit is an apple is a necessary condition for Madison to be eating it. It is not a sufficient condition since Madison might not eat any and all apples she is given.
- "If and only if the fruit is an apple will Madison eat it" or "Madison will eat the fruit if and only if it is an apple" or "Madison will eat the fruit ↔ fruit is an apple."
- This, however, makes it quite clear that Madison will eat all and only those fruits that are apples. She will not leave any such fruit uneaten, and she will not eat any other type of fruit. That a given fruit is an apple is both a necessary and a sufficient condition for Madison to eat the fruit.
Sufficiency is the inverse of necessity. That is to say, given P→Q (i.e. if P then Q), P would be a sufficient condition for Q, and Q would be a necessary condition for P. Also, given P→Q, it is true that ¬Q→¬P (where ¬ is the negation operator, i.e. "not"). This means that the relationship between P and Q, established by P→Q, can be expressed in the following, all equivalent, ways:
- P is sufficient for Q
- Q is necessary for P
- ¬Q is sufficient for ¬P
- ¬P is necessary for ¬Q
As an example, take (1), above, which states P→Q, where P is "the fruit in question is an apple" and Q is "Madison will eat the fruit in question". The following are four equivalent ways of expressing this very relationship:
- If the fruit in question is an apple, then Madison will eat it.
- Only if Madison will eat the fruit in question, is it an apple.
- If Madison will not eat the fruit in question, then it is not an apple.
- Only if the fruit in question is not an apple, will Madison not eat it.
So we see that (2), above, can be restated in the form of if...then as "If Madison will eat the fruit in question, then it is an apple"; taking this in conjunction with (1), we find that (3) can be stated as "If the fruit in question is an apple, then Madison will eat it; AND if Madison will eat the fruit, then it is an apple".
Advanced considerations 
Philosophical interpretation 
A sentence that is composed of two other sentences joined by "iff" is called a biconditional. "Iff" joins two sentences to form a new sentence. It should not be confused with logical equivalence which is a description of a relation between two sentences. The biconditional "A iff B" uses the sentences A and B, describing a relation between the states of affairs which A and B describe. By contrast "A is logically equivalent to B" mentions both sentences: it describes a logical relation between those two sentences, and not a factual relation between whatever matters they describe. See use–mention distinction for more on the difference between using a sentence and mentioning it.
The distinction is a very confusing one, and has led many a philosopher astray. Certainly it is the case that when A is logically equivalent to B, "A iff B" is true. But the converse does not hold. Reconsidering the sentence:
- If and only if the fruit is an apple will Madison eat it.
There is clearly no logical equivalence between the two halves of this particular biconditional. For more on the distinction, see W. V. Quine's Mathematical Logic, Section 5.
One way of looking at "A if and only if B" is that it means "A if B" (B implies A) and "A only when B" (not B implies not A). "Not B implies not A" means A implies B, so then we get two way implication.
In philosophy and logic, "iff" is used to indicate definitions, since definitions are supposed to be universally quantified biconditionals. In mathematics and elsewhere, however, the word "if" is normally used in definitions, rather than "iff". This is due to the observation that "if" in the English language has a definitional meaning, separate from its meaning as a propositional conjunction. This separate meaning can be explained by noting that a definition (for instance: A group is "abelian" if it satisfies the commutative law; or: A grape is a "raisin" if it is well dried) is not an equivalence to be proved, but a rule for interpreting the term defined.
Here are some examples of true statements that use "iff" - true biconditionals (the first is an example of a definition, so it should normally have been written with "if"):
- A person is a bachelor iff that person is a marriageable man who has never married.
- "Snow is white" in English is true iff "Schnee ist weiß" in German is true.
- For any p, q, and r: (p & q) & r iff p & (q & r). (Since this is written using variables and "&", the statement would usually be written using "↔", or one of the other symbols used to write biconditionals, in place of "iff").
- For any real numbers x and y, x=y+1 iff y=x−1.
- A subset containing n elements of an n-dimensional vector space is linearly independent iff it spans the vector space.
- The triangular number n(n+1)/2 is an even perfect number iff n = 2p-1 is a Mersenne prime, with p being a prime number. As of Feb 2013, only 48 such even perfect numbers and Mersenne primes have been discovered.
Other words are also sometimes emphasized in the same way by repeating the last letter; for example orr for "Or and only Or" (the exclusive disjunction).
The statement "(A iff B)" is equivalent to the statement "(not A or B) and (not B or A)," and is also equivalent to the statement "(not A and not B) or (A and B)".
It is also equivalent to: not[(A or B) and (not A or not B)],
or more simply:
- ¬ [ ( ¬A ∨ ¬B ) ∧ ( A ∨ B ) ]
which converts into
- [ ( ¬A ∧ ¬B) ∨ (A ∧ B) ]
- [ ( ¬A ∨ B) ∧ (A ∨ ¬B) ]
which were given in verbal interpretations above.
More general usage 
Iff is used outside the field of logic, wherever logic is applied, especially in mathematical discussions. It has the same meaning as above: it is an abbreviation for if and only if, indicating that one statement is both necessary and sufficient for the other. This is an example of mathematical jargon. (However, as noted above, if, rather than iff, is more often used in statements of definition.)
The elements of X are all and only the elements of Y is used to mean: "for any z in the domain of discourse, z is in X if and only if z is in Y."