Lesson 2 of 16 · about 12 min
Propositions and connectives
Logic starts with statements that are true or false, glued together with and, or and not. You'll build truth tables, see why "or" in logic means "at least one", and turn a real-world rule into exact logic.
🧭 What you need first: What is a proof? , Logic gates
A concert venue has a door rule: “You can come in if you have a ticket and you’re on the guest list, or you’re with the band.” The bouncer applies it hundreds of times a night, and has to get every case right.
English is slippery. When a waiter says “soup or salad”, they mean one, not both. When a sign says “cash or card accepted”, paying with both is fine. Logic removes the guesswork: every word has one exact meaning, so a rule means the same thing to the bouncer, the manager and the computer that checks tickets.
You’ve already met these ideas as logic gates (F01) and if conditions (F02). Now you’ll see them as a language for thinking precisely, which is the foundation of every proof in this course.
Another way: light switches
Two switches in a row (series) light the bulb only if both are on: that’s and. Two switches side by side (parallel) light it if either is on: that’s or. A switch wired backwards is not.
Make some truth tables
Type a formula and the whole truth table appears. Try p or q, not p, p xor q and (p or q) and not (p and q). Add a third variable, like p and q or r: how many rows now?
| p | q | result |
|---|---|---|
| T | T | T |
| T | F | F |
| F | T | F |
| F | F | F |
🟡 True in 1 of 4 rows: satisfiable, but not always true.
The real words
- A proposition is a statement with a definite truth value: “Paris is in France” (true), "" (false). "" isn’t one yet, because it depends on (that’s a predicate, lesson 6).
- The and, or, not () connectives:
- (” and ”): true only when both are true.
- (” or ”): true when at least one is true. This is inclusive or.
- (“not ”): the opposite of .
- (” xor ”, exclusive or): true when exactly one is true.
- A truth table lists all combinations. Each new variable doubles the rows: 2 variables give 4 rows, 3 give 8, 10 give 1,024. (The same as light switches in F01!)
- Order of operations: not first, then and, then or. So
p or q and rmeansp or (q and r). When in doubt, add parentheses. Python uses the same order fornot,andandor.
Build exclusive or
🎯 Soup or salad, but not both: build exclusive or using only and, or, not.
| p | q | goal | yours | |
|---|---|---|---|---|
| T | T | F | T | ❌ |
| T | F | T | T | ✅ |
| F | T | T | T | ✅ |
| F | F | F | F | ✅ |
Without using: xor
Program the alarm rule
The alarm should sound when the door is open while the system is armed, or when the panic button is pressed. But during a test, it must never sound. Write should_sound so it follows the rule exactly.
p is true and q is false. What is (not p) or q?
Got it?
Finish the lesson to color it in on your map and collect its concept cards.
Did this lesson click?