Scroll to turn the page
Discrete Math · Discrete Mathematics
statements that are true or false, and how they combine
Every proof, every program’s if, every database query rests on the same small machine: statements that are either true or false, joined by and, or and not.
In the figure, p and q are two statements. Each can be true (T) or false (F), so there are 2 × 2 = 4 cases. The top lamp shows p ∧ q (“p and q”), lit only when both are true. The bottom lamp shows p ∨ q (“p or q”), lit when at least one is.
This is the same arithmetic a computer’s circuits do: two switches in series behave like and, two in parallel like or. George Boole wrote it down as algebra in 1854, and Claude Shannon showed in his 1937 master’s thesis that relay circuits obey it.
This chapter builds the language of discrete mathematics: propositions and connectives (1.1), the conditional (1.2), equivalent statements (1.3), predicates and quantifiers (1.4), and the rules that make an argument valid (1.5). Chapter 2 uses them to write proofs.
not, and, or, exclusive or
A proposition is a declarative sentence that is either true or false, but not both.
| sentence | a proposition? |
|---|---|
| 7 is a prime number. | proposition: true |
| 2 + 2 = 5 | proposition: false |
| Close the door. | not a proposition: a command |
| x + 1 = 3 | not a proposition until x is given |
Connectives build compound propositions from simpler ones. Each is defined by its truth table, one row for every combination of truth values:
| p | q | ¬p | p ∧ q | p ∨ q | p ⊕ q |
|---|---|---|---|---|---|
| T | T | F | T | T | F |
| T | F | F | F | T | T |
| F | T | T | F | T | T |
| F | F | T | F | F | F |
In everyday English “or” is often exclusive (“soup or salad”). In mathematics and in code (||), “or” is inclusive unless it says otherwise.
if p, then q
The conditional p → q (“if p, then q”) is a promise. It is broken only when p is true and q is false.
Take “If it rains, then the ground is wet.” Rain and a dry ground breaks the promise. If it does not rain, the promise was never tested, so the conditional counts as true whatever the ground does: it is vacuously true. p is the hypothesis, q the conclusion.
| p | q | p → q | q → p | ¬p → ¬q | ¬q → ¬p |
|---|---|---|---|---|---|
| T | T | T | T | T | T |
| T | F | F | T | T | F |
| F | T | T | F | F | T |
| F | F | T | T | T | T |
Three relatives come from swapping and negating:
The table shows the contrapositive has the same column as the conditional, so they always agree. The converse does not: a sprinkler can wet the ground. (The converse and inverse agree with each other, being each other’s contrapositive.)
The biconditional p ↔ q, “p if and only if q”, is (p → q) ∧ (q → p): true exactly when p and q have the same truth value.
different words, same truth table
Two compound propositions are logically equivalent, written ≡, when they have the same truth value in every row of the truth table.
De Morgan’s laws say how negation passes through and and or: it flips each one.
| p | q | ¬(p ∧ q) | ¬p ∨ ¬q | ¬(p ∨ q) | ¬p ∧ ¬q |
|---|---|---|---|---|---|
| T | T | F | F | F | F |
| T | F | T | T | F | F |
| F | T | T | T | F | F |
| F | F | T | T | T | T |
So ¬(p ∧ q) ≡ ¬p ∨ ¬q, and ¬(p ∨ q) ≡ ¬p ∧ ¬q. “Not (hungry and tired)” means “not hungry, or not tired.” In code, !(a && b) is !a || !b.
A compound proposition that is true in every row is a tautology; false in every row, a contradiction; otherwise a contingency:
| proposition | kind |
|---|---|
| p ∨ ¬p | tautology |
| p ∧ ¬p | contradiction |
| p → q | contingency |
A truth table on n variables has 2n rows, because each variable doubles the cases:
| variables | 1 | 2 | 3 | 4 | 5 | 10 |
|---|---|---|---|---|---|---|
| rows | 2 | 4 | 8 | 16 | 32 | 1024 |
That doubling is why tables stop being practical quickly, and why equivalences are used to rewrite statements step by step instead (much as algebra rewrites expressions). Two more: the distributive law p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r), and the conditional as an or, p → q ≡ ¬p ∨ q.
for all, there exists
“x is prime” is not a proposition: its truth depends on x. It is a predicate Q(x), which becomes a proposition once x is chosen from a domain.
Quantifiers turn a predicate into a proposition about the whole domain:
In the figure the domain is {1, 2, 3, 4, 5, 6, 7, 8}. Every element satisfies x² ≥ x, so ∀x P(x) is true. The primes in the domain are 2, 3, 5, 7, so ∃x Q(x) is true, with witness 2. But ∀x Q(x) is false: 1 is not prime, a counterexample.
One counterexample disproves a universal claim. One witness proves an existential one. To prove a universal claim on an infinite domain you need an argument, not examples: that is Chapter 2.
Negating a quantifier flips it and pushes the negation inside (De Morgan’s laws for quantifiers):
| statement | its negation |
|---|---|
| ∀x P(x) | ∃x ¬P(x) |
| ∃x P(x) | ∀x ¬P(x) |
“Not every student passed” means “some student did not pass.” Order matters with two quantifiers: over the integers, ∀x ∃y (y > x) is true (every number has a bigger one), but ∃y ∀x (y > x) is false (no number is bigger than all of them).
valid arguments, and one famous fallacy
An argument is a list of premises and a conclusion. It is valid when the conclusion must be true whenever all the premises are, that is, when no row of the truth table makes every premise true and the conclusion false.
Valid patterns are called rules of inference. The figure checks each one against its truth table:
| rule | premises | conclusion | valid? |
|---|---|---|---|
| modus ponens | p → q, p | q | yes |
| modus tollens | p → q, ¬q | ¬p | yes |
| disjunctive syllogism | p ∨ q, ¬p | q | yes |
| affirming the consequent | p → q, q | p | no |
Modus ponens: “If it rains, the ground is wet. It rains. So the ground is wet.” Modus tollens: “The ground is not wet, so it did not rain.” Disjunctive syllogism: “It is p or q, and not p, so q.” Chaining conditionals is valid too (hypothetical syllogism): from p → q and q → r, conclude p → r; all 8 rows of its table agree.
Affirming the consequent is the classic fallacy: “If it rains, the ground is wet. The ground is wet. So it rained.” The row p = F, q = T (a sprinkler, no rain) makes both premises true and the conclusion false. Its twin, denying the antecedent (from p → q and ¬p, concluding ¬q), fails on the same row.
Validity is about form, not content. A valid argument with a false premise can reach a false conclusion; an argument that is valid and has true premises is sound.