Logical operations
A statement is a declarative sentence of which we can say that it is true or false; questions and commands are not statements. We denote statements by letters such as A and B, and true by 1 and false by 0. Compound statements are made from simple ones with the words AND, OR and NOT. The conjunction A ∧ B is true only when both statements are true (11→1, 10→0, 01→0, 00→0); the disjunction A ∨ B is true when at least one is true (11→1, 10→1, 01→1, 00→0); the negation ¬A reverses the value (¬1 = 0, ¬0 = 1). In an expression, brackets come first, then negation, then ∧, and finally ∨; operations of the same rank go from left to right. A truth table with n variables has 2ⁿ rows.
| A | B | A ∧ B | A ∨ B | ¬A |
|---|---|---|---|---|
| 1 | 1 | 1 | 1 | 0 |
| 1 | 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 1 | 1 |
| 0 | 0 | 0 | 0 | 1 |
F = A AND B → 0
The A and B buttons flip an input between 0 and 1
The teacher stated a rule: “If you have both a notebook and a pen, we start the written work.” A pupil with a pen but no notebook could not start, because both parts of the condition had to be true.
Programmers write conditions, search-engine developers build queries with “and” and “or”, and accountants filter lists by a condition.
Write an “if ... and ...” rule for three simple conditions from your day and list the cases in which it is true.
| A | B | ¬A | ¬A ∨ B |
|---|---|---|---|
| 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 0 |
| 0 | 1 | 1 | 1 |
| 0 | 0 | 1 | 1 |
“True-false” game: the teacher says a sentence; pupils stand if it is true and sit if it is false. Then two sentences are joined with “AND” or “OR” and the class discusses how to react.