Propositional Logic: Statements, Connectives & Truth Tables

Discrete Mathematics Fundamentals

Chapter 2 · Propositional Logic: Statements, Connectives & Truth Tables

Chapter 1 claimed that "every if statement, every boolean expression ... is propositional logic wearing different syntax." This chapter makes that literal — the formal system for reasoning about statements that are simply true or false, and the exact operations that combine them: the same operations as &&, ||, and !, just written with mathematical symbols instead of code syntax.

What Counts as a Proposition

A proposition is a statement that is unambiguously either true or false — never both, never neither, and never a matter of opinion.

StatementIs it a proposition?
5 > 3Yes — true
"Paris is the capital of France"Yes — true
"What time is it?"No — a question, not a statement that's true or false
x > 3No — not yet. Its truth depends on a value x hasn't been given. This is a predicate, and Chapter 3 is entirely about it.

The Five Core Connectives

Propositions combine using connectives — and every one of them already has a direct equivalent in code you've used before.

ConnectiveSymbolMeaningCode equivalent
NOT¬pTrue exactly when p is falsenot p / !p
ANDp ∧ qTrue only when both are truep and q / p && q
ORp ∨ qTrue when at least one is truep or q / p || q
XORp ⊕ qTrue when exactly one is true, not bothp != q (on booleans) / p ^ q
IMPLIESp → qFalse only when p is true and q is falseNo direct operator — built from (not p) or q

Truth Tables — Defining a Connective by Every Possible Case

A truth table lists every combination of inputs and the resulting output — the formal, complete definition of what a connective actually means.

p¬p
TF
FT
pqp ∧ qp ∨ qp ⊕ qp → q
TTTTFT
TFFTTF
FTFTTT
FFFFFT
The counterintuitive row: IMPLIES is true when p is false
"If p, then q" is considered true whenever p is false — regardless of q. "If pigs can fly, then 2 + 2 = 5" is, by this definition, a true statement, since the premise is false. This isn't a trick — it's why a guard clause like if not condition: return works the way it does: when the precondition doesn't hold, the rest of the logic is vacuously satisfied, because there was never a case to check in the first place.

De Morgan's Laws — Simplifying Negated Conditions

Two of the most practically useful identities in this entire chapter, both directly checkable against the truth tables above:

LawStatement
De Morgan's (AND)¬(p ∧ q) ≡ ¬p ∨ ¬q
De Morgan's (OR)¬(p ∨ q) ≡ ¬p ∧ ¬q

In plain terms: negating an AND flips it to an OR of the negations, and negating an OR flips it to an AND of the negations — the connective itself flips, not just the individual pieces.

# These two conditions are logically identical — De Morgan's (AND): if not (a and b): ... if (not a) or (not b): ... # A genuinely common mistake — this is NOT the same thing: if not a and not b: # this is ¬a ∧ ¬b, a completely different condition
Why this matters in real code
not a and not b looks like a natural way to write "not both" but it's actually the truth table for "neither" — a genuinely different condition. De Morgan's Law is exactly the tool that tells you the correct rewrite of not (a and b) is (not a) or (not b), not (not a) and (not b).

Logical Equivalence

Two propositions are logically equivalent (written ≡) when they produce the same output for every possible combination of inputs — verified by comparing their truth tables row by row. De Morgan's Laws above are exactly this: two differently-written expressions that are provably, always, the same thing. This matters directly for refactoring — if two boolean expressions are logically equivalent, replacing one with the other can never change what your program does.

A quick way to double-check p → q ≡ ¬p ∨ q
Compare the IMPLIES column above (T, F, T, T) against a truth table for ¬p ∨ q: row by row, ¬p is F, F, T, T and q is T, F, T, F, so ¬p ∨ q comes out T, F, T, T — an exact match, row for row. This is exactly how you'd verify any claimed equivalence: build both truth tables, compare every row.

Short-Circuit Evaluation — A Runtime Detail, Not a Logic Change

Python and JavaScript's and/or (&&/||) don't always evaluate both sides — if the left side of and is already false, the right side is never even run, since the overall result is already determined. This is called short-circuit evaluation. It doesn't change the truth table at all — the logical result is identical either way — but it does matter if the right-hand side has a side effect (like calling a function), since that side effect might never actually happen.

Hands-On Exercises

Exercise 1

Build a complete truth table for the compound proposition (p ∨ q) ∧ ¬p, and state in plain English what condition it actually captures.

📄 View solution
Exercise 2

A function contains the condition if not (is_valid and is_authorized):. Using De Morgan's Law, rewrite this without a negated compound expression, and explain why your rewrite is guaranteed to behave identically for every possible combination of is_valid and is_authorized.

📄 View solution
Exercise 3

Determine whether p → q and q → p are logically equivalent, by building both truth tables and comparing them row by row. If they're not equivalent, give a concrete real-world example of a true "if p then q" statement whose reverse is false.

📄 View solution

Chapter 2 Quick Reference

  • A proposition is a statement that's unambiguously true or false — a statement with an unknown variable is a predicate instead (Chapter 3)
  • Five connectives: NOT (¬), AND (∧), OR (∨), XOR (⊕), IMPLIES (→) — each with a direct code equivalent
  • A truth table defines a connective completely, by listing the output for every combination of inputs
  • p → q is true whenever p is false, regardless of q — the source of "vacuous truth"
  • De Morgan's Laws: ¬(p ∧ q) ≡ ¬p ∨ ¬q, and ¬(p ∨ q) ≡ ¬p ∧ ¬q — the connective itself flips
  • Logically equivalent expressions can always be swapped for each other without changing program behavior
  • Short-circuit evaluation is a runtime detail — it doesn't change the logical truth table, only whether side effects on the right-hand side actually run
  • Next chapter: Predicate logic and quantifiers — what happens once a statement has a variable in it