Recap
- Boolean value:
trueorfalse. - Relational operators (
=,≠,>,<,≥,≤) compare and produce a Boolean. - Logical operators:
NOT pflips;p AND qneeds both;p OR qneeds at least one (inclusive). - Use brackets; evaluate small comparisons first, then combine.
=tests equality;←assigns.
Key relationships
| Idea | Expression | Notes |
|---|---|---|
| Range, ends included | x ≥ lo AND x ≤ hi |
OR would accept every value |
| Outside a range | x < lo OR x > hi |
Equivalent to NOT(x ≥ lo AND x ≤ hi) |
| De Morgan 1 | NOT(p AND q) = (NOT p) OR (NOT q) |
Negating swaps AND and OR |
| De Morgan 2 | NOT(p OR q) = (NOT p) AND (NOT q) |
|
| Opposite of ≥ | NOT(a ≥ b) = a < b |
Boundary flips: ≥ becomes < |
| Divisible by 3 and 5 | n MOD 3 = 0 AND n MOD 5 = 0 |
True for 15, 30, … |
Assumptions
- Each operand of AND/OR/NOT is a Boolean expression or a single Boolean value.
- Comparisons are evaluated before the logical operators that use them.
- Brackets in a question show the intended grouping.
Method
- Substitute the variable values.
- Evaluate each comparison and write
trueorfalsebeside it. - Evaluate
NOT, then combine withAND, thenOR(brackets decide). - For “which expression” questions, test each option at the boundary values.
Mistakes to avoid
- Using OR where AND is needed for a range.
- Using
>where≥is needed (or the reverse). - Writing
x = 5 OR 6. - Forgetting that
NOTof an AND becomes an OR of NOTs. - Stating that OR is false when both sides are true.
Worked mini-example
p ← true
q ← false
DISPLAY(p AND NOT q)
DISPLAY(NOT(p OR q))
DISPLAY((NOT p) OR (NOT q))
Output: true false true
NOT q is true, so p AND true is true. p OR q is true, so NOT(true) is false. (NOT p) is false and (NOT q) is true, so false OR true is true. The last line equals NOT(p AND q), as De Morgan says.
Quick self-check
- What is
5 ≥ 5? - Write “x is not between 3 and 8 inclusive” using OR.
- Is
NOT(a OR b)equal toNOT a OR NOT b?
Answers
- true.
x < 3 OR x > 8.- No. It equals
NOT a AND NOT b.
Where marks are won and lost
Evaluation questions give values for variables and ask whether a compound expression is true or false; write each comparison’s value before combining. Requirement questions ask which of four expressions matches a sentence, and the traps are OR instead of AND, and > instead of ≥ at the boundaries. Equivalence questions give a condition and ask for an equivalent one, so know both De Morgan forms. Test boundary values, not just typical ones.
Back to the full study guide for worked examples and explanations.