Skip to content
DoingCamp CS

Make it comfy

Lesson style

Quick mode shows the key picture, a summary and the practice. Good for a refresher.

Theme
Font

Both fonts are designed to be easy to read. Some readers with dyslexia prefer Lexend.

Text size
Spacing
Animations

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

The story

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.

Play with it

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?

pqresult
TTT
TFF
FTF
FFF

🟡 True in 1 of 4 rows: satisfiable, but not always true.

Name it

The real words

  • A proposition is a statement with a definite truth value: “Paris is in France” (true), "2+2=52 + 2 = 5" (false). "x>3x > 3" isn’t one yet, because it depends on xx (that’s a predicate, lesson 6).
  • The and, or, not (∧,∨,¬\land, \lor, \lnot) connectives:
    • p∧qp \land q (”pp and qq”): true only when both are true.
    • p∨qp \lor q (”pp or qq”): true when at least one is true. This is inclusive or.
    • ¬p\lnot p (“not pp”): the opposite of pp.
    • p⊕qp \oplus q (”pp xor qq”, 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 2n2^n as light switches in F01!)
  • Order of operations: not first, then and, then or. So p or q and r means p or (q and r). When in doubt, add parentheses. Python uses the same order for not, and and or.
Build it

Build exclusive or

🎯 Soup or salad, but not both: build exclusive or using only and, or, not.

pqgoalyours
TTFT❌
TFTT✅
FTTT✅
FFFF✅

Without using: xor

Challenge

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.

Remember it

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?