I have read this question. I am now stuck with the difference between "if and only if" and "only if". Please help me out.
Thanks
I have read this question. I am now stuck with the difference between "if and only if" and "only if". Please help me out.
Thanks
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.
The way logic is written can be confusing. Tip: whenever you see something like "A only if B", mentally insert "A [is true] only if B [is true]".
What does "A only if B" mean? It means "if A then B", or more precisely, "If A is true, then B is true".
What does "A if B" mean? It means "If B then A", or more precisely, "If B is true, then A is true", the reverse from before.
What does "A if and only if B" mean? It means "A if B and A only if B". In other words, "If B is true, then A is true, and if A is true, then B is true". A and B are always both true or both false.
How I understood this:
A rectangle is a square only if it has all sides equal. In this case the sentence gives us information, how we should name rectangles fulfilling the condition. It does not say that only these rectangles are squares. There may be many other rectangles which do not have equal sides, but are squares as well, for example the definition of "a square" could be "a square is a rectangle with equal sides or a circle with radius larger than 2 cm". So from this sentence I only know how to name particular rectangle, but I don't know what a square is in general, I know only one case.
Each square is a rectangle with all sides equal (or using "if" a square exists only if it is a rectangle with its sides equal). In this sentence we know that it is necessary for squares to be rectangles with equal sides. However, it does not say, that each rectangle with equal sides is a square. The might be some rectangles with equal sides, that we could name "circles". So again, I know only one case.
A rectangle is a square if and only if it has equal sides means that 1. only each rectangle with equal sides can be called a square, but also 2. each square is a rectangle with equal sides. There are no other conditions for both. No other figure can be a square, and a rectangle with equal sides can be nothing but a square.
If I say that an object is an apple only if it is a fruit ($\text{Fruit} \Leftarrow \text{Apple}$), then that means that something has to be a fruit in order for it to be an apple, but it does not have to be an apple. If something is a fruit, it can also be an orange or a banana.
However, if said that an object is an apple if and only if it is a fruit ($\text{Fruit} \iff \text{Apple}$), then that would once again mean that something has to be a fruit in order for it to be an apple, but here the main difference is that it would also have to be an apple and not an orange or a banana. If it is a fruit, then it's an apple, and if it is an apple, then it is a fruit.
In the second example, we have also added $\text{Fruit} \Rightarrow \text{Apple}$ which, on it's own, means that if something is a fruit, then it has to be an apple. Another way of writing $A \iff B$ is $(A \Rightarrow B) \ \& \ (A\Leftarrow B)$.
$A \text{ iff } B$ is the statement
"if B then A" and "only if B then A"
$(B \Rightarrow A) \land (notB \Rightarrow notA)$
$(B \Rightarrow A) \land (A \Rightarrow B)$
$A=B$
I am just putting an another comprehnsive answer which steals important points from other answers. Other answers don't break the IF AND ONLY IF
correctly.
Let's try to prove the truth table of P IFF Q
Label P Q P IFF Q
-------------------------
tt T T T
tf T F F
ft F T F
ff F F T
Proof:
### P IFF Q
<=> P IF AND ONLY IF Q
<=> (P IF Q) AND (P ONLY IF Q)
<=> (IF Q THEN P) AND (P THEN Q)
Let's put a truth table for our last expression now.
P | Q | (IF Q THEN P) | (P THEN Q) | R AND S <=> P IFF Q
| | (R) | (S) |
----------------------------------------------------------------
T T T T T
T F T F F
F T F T F
F F T T T
QED.
I win the competition if I compete.
This sentence implies that if I compete, I necessarily win the competition, but not that I only win if I compete.
I win the competition only if I compete.
This sentence implies I only win if I compete, but not necessarily that if I compete, I win the competition.
I win the competition if and only if I compete.
This sentence implies that if I compete, I necessarily win the competition AND that I only win if I compete.