End of Lesson
End of Lesson
We have seen how to combine statements with AND (∧) and OR (∨). Now we introduce two very important operators: Implication and Biconditional. These are used to represent conditional and "if and only if" relationships between statements.
The implication between p and q is written as p → q, and is read as "if p then q". The result is false only when p is true but q is false. In every other case, it is true.
If you say, "If it rains, I will take an umbrella," you are making an implication: p → q. You only break your promise if it rains (p is true) but you do not take an umbrella (q is false).
if (isLoggedIn) { showDashboard(); } → "If the user is logged in, show the dashboard."Click on a cell to change its value to true or false. Press the submit button when you think you have gotten it right.
| p | q | p → q | q → p |
|---|---|---|---|
| F | F | ||
| F | T | ||
| T | F | ||
| T | T |
The biconditional between p and q is written as p ↔ q, and is read as "p if and only if q". It is true only when p and q have the same truth value (both true or both false).
Think of this as a perfect equivalence. Saying "I will eat ice cream if and only if it is Saturday" means both statements always match: if it’s Saturday, you eat ice cream; if it’s not Saturday, you do not.
if (isOnline === isAvailable) { ... } → checks if both states match.Click on a cell to change its value to true or false. Press the submit button when you think you have gotten it right.
| p | q | p ↔ q | q ↔ p |
|---|---|---|---|
| F | F | ||
| F | T | ||
| T | F | ||
| T | T |
Implication tells us what happens when one thing leads to another, while biconditional tells us that the two statements are always in sync — either both true or both false.