COMP233 · Chapter 3 Interactive Companion

The Logic of Quantified Statements

Predicates, the quantifiers ∀ and ∃, Tarski's World, and multiple quantifiers.
Back to COMP233

About this chapter

First-order logic extends the propositional logic of Chapter 2 with two new tools: predicates like Triangle(x) or StudyAt(p, BZU), and quantifiers (for all) and (there exists). The pair lets us reason about an entire domain in a single statement.

Where it is used. Quantified statements appear in every later definition and theorem in this course: every integer is rational, some prime is even, for every ε > 0 there exists δ > 0 such that …. They are the language of mathematics, of SQL aggregation, of program contracts, and of model checking.

Section 3.1Predicates and quantified statements

A statement from Chapter 2 was either true or false. A predicate P(x₁, x₂, …, xₙ) waits to become one until its variables receive values. The number of variables is the predicate's arity.

Two new pieces of vocabulary make the jump from propositional to first-order logic possible:

  • ∀ universal: "for all x in D, Q(x)". A big AND across the domain.
  • ∃ existential: "there exists x in D such that Q(x)". A big OR across the domain.

3.1.1 Predicates and truth sets

Pick a predicate over a small domain. The companion lists every element together with the truth value of the predicate, and collects the truth set automatically.

3.1.2 Universal (∀) and existential (∃) statements

Toggle each domain element to choose whether the predicate holds for it. The verdicts for ∀x Q(x) and ∃x Q(x) update together: is one big conjunction, is one big disjunction.

Click each element to toggle whether the predicate Q holds:

Try this. Switch every chip to T: both ∀ and ∃ are true. Switch every chip to F: both are false. Flip a single chip to T: ∃ is true, ∀ is false. One counterexample kills ∀; one witness proves ∃.

3.1.3 Formalize and verbalize

Statements rarely arrive in formal notation. Slide examples in both directions:
EnglishFormal
All triangles have three sides.∀t ∈ Triangle, ThreeSided(t)
No dogs have wings.∀d ∈ Dog, ∼HasWings(d)
Some programs are structured.∃p ∈ Program, Structured(p)
All bytes have eight bits.∀b ∈ Byte, EightBits(b)
No fire trucks are green.∀t ∈ FireTruck, ∼Green(t)
If a person is born in Hebron then they are Khalili.∀x ∈ Person, BornIn(x, Hebron) → Khalili(x)
People who like hummus are smart.∀x ∈ Person, Likes(x, Hummus) → Smart(x)
Watch the trap. "No X are Y" formalizes as ∀x ∈ X, ∼Y(x) (a universal with negation), not as . The everyday word "a" or "any" often hides an implicit ; "some" or "there is" signals .

3.1.4 Tarski's World (Figure 3.1.1)

A finite world of named shapes with colors and positions, built to match Epp Figure 3.1.1. Eleven objects named a, b, …, k. Predicates available: Triangle(x), Square(x), Circle(x), Blue(x), Gray(x), Black(x), RightOf(x, y), Above(x, y), SameColor(x, y). Type any quantified statement; the companion evaluates it against the scene and walks the evaluation step by step.
Domain: all eleven objects in the scene.
RightOf(x, y): x is in a column to the right of y. Above(x, y): x is in a row above y (row 4 is the top of the figure).
Variables:
Try these (Epp Section 3.1.13 worked examples):

Practice exercises · Section 3.1

Adapted from Epp Section 3.1, suggested questions: 10, 16(b), 19.
Exercise 3.1.A
Let D = {−2, −1, 0, 1, 2}. Determine the truth value of each:
  1. ∀x ∈ D, x² ≥ 0
  2. ∀x ∈ D, x² > 0
  3. ∃x ∈ D such that x³ = 1

(1) ∀x ∈ D, x² ≥ 0. Squares: (−2)² = 4, (−1)² = 1, 0² = 0, 1² = 1, 2² = 4. All ≥ 0. True.

(2) ∀x ∈ D, x² > 0. False. Counterexample: x = 0 gives x² = 0, which is not strictly greater than 0.

(3) ∃x ∈ D, x³ = 1. True. Witness: x = 1, since 1³ = 1.

Exercise 3.1.B
Rewrite each statement in the form ∀x, …:
  1. "Every real number is positive, negative, or zero."
  2. "No irrational numbers are integers."

(1) ∀x ∈ ℝ, (x > 0) ∨ (x < 0) ∨ (x = 0).

(2) "No P is a Q" is equivalent to "every P is not a Q":
∀x, Irrational(x) → ∼Integer(x)
Equivalently: ∀x ∈ ℝ, Irrational(x) → x ∉ ℤ.

Reminder: "No X are Y" is the Section 3.1 trap. The formalization is a universal with a negated conclusion, never an existential.

Exercise 3.1.C · Tarski's World
Using Tarski's World (Figure 3.1.1 above), decide each. Verify with the evaluator widget.
  1. ∀x, Square(x) → Blue(x)
  2. ∃x, Circle(x) ∧ Blue(x)
  3. ∀x, Triangle(x) → Blue(x)

(1) ∀x, Square(x) → Blue(x). Squares in the world: e, g, h, j. False. Counterexample: h is a square but its colour is black, not blue.

(2) ∃x, Circle(x) ∧ Blue(x). True. Witness: b is a blue circle.

(3) ∀x, Triangle(x) → Blue(x). Triangles in the world: d, f, i, k. All blue. True.

Section 3.2Negation, conditional statements, and quantifiers

How do we deny a quantified claim? The first instinct, "no X are Y" to negate "all X are Y", is wrong. One counterexample is enough to break a universal, and one witness is enough to make an existential true.

The two negation theorems for quantifiers are the workhorses of this section. They look like De Morgan's laws and behave like them.

3.2.1 Negation of quantified statements

Two equivalence laws govern every negation that appears in this chapter.
Theorem 3.2.1. $$\sim(\forall x \in D,\; Q(x)) \;\equiv\; \exists x \in D,\; \sim\! Q(x)$$
Theorem 3.2.2. $$\sim(\exists x \in D,\; Q(x)) \;\equiv\; \forall x \in D,\; \sim\! Q(x)$$

"All are" becomes "some are not"; "some are" becomes "none are". Side-by-side examples from the slides:

OriginalCorrect negation
All Palestinians like Zaatar.
∀p ∈ Palestinian, Likes(p, Zaatar)
Some Palestinians do not like Zaatar.
∃p ∈ Palestinian, ∼Likes(p, Zaatar)
Some Palestinians like Zaatar.
∃p ∈ Palestinian, Likes(p, Zaatar)
No Palestinian likes Zaatar.
∀p ∈ Palestinian, ∼Likes(p, Zaatar)
Every prime is odd.
∀p ∈ Prime, Odd(p)
There is a prime that is not odd.
∃p ∈ Prime, ∼Odd(p)  (witness: 2)
No computer hacker is over 40.
∀h ∈ Hacker, ∼Over40(h)
Some computer hacker is over 40.
∃h ∈ Hacker, Over40(h)
All computer programs are finite.
∀c ∈ Program, Finite(c)
Some computer program is not finite.
∃c ∈ Program, ∼Finite(c)

Common mistake. Negating "all mathematicians wear glasses" as "no mathematicians wear glasses" is wrong. The correct negation only asks for at least one mathematician without glasses.

3.2.2 Negating a universal conditional

Most statements in mathematics have the shape ∀x, P(x) → Q(x). Pushing through gives a useful pattern.
∼(∀x, P(x) → Q(x))
≡ ∃x, ∼(P(x) → Q(x)) by Theorem 3.2.1
≡ ∃x, P(x) ∧ ∼Q(x) since ∼(P → Q) ≡ P ∧ ∼Q from Ch 2

In words: "there is at least one x that satisfies the hypothesis but fails the conclusion."

Original (universal conditional)Negation
If a computer program has more than 10,000 lines, then it contains a bug.
∀c, ManyLines(c) → HasBug(c)
There is a computer program with more than 10,000 lines and no bug.
∃c, ManyLines(c) ∧ ∼HasBug(c)
If a person is blond, then they have blue eyes.
∀p, Blond(p) → BlueEyes(p)
There is a blond person who does not have blue eyes.
∃p, Blond(p) ∧ ∼BlueEyes(p)

Watch the shape. The negation of "if P then Q" does not start with "if". It starts with "there is".

3.2.3 Vacuous truth

A universal conditional ∀x ∈ D, P(x) → Q(x) is vacuously true when P(x) is false for every x in D. Toggle the demo: an empty bowl satisfies "all the balls in the bowl are blue". In Tarski's World, ∀x, Pentagon(x) → Yellow(x) is vacuously true: there are no pentagons (and no yellow objects) anywhere.
Bowl contents
Claim: ∀b ∈ Bowl, Blue(b)

Empty the bowl. With no balls at all, the claim has no non-blue ball to contradict it, so it is vacuously true. Add a red ball and the claim immediately becomes false.

3.2.4 Contrapositive, converse, and inverse

Given a universal conditional ∀x ∈ D, P(x) → Q(x), the same three derived forms appear as in Ch 2, now under a universal quantifier.

Original

$\forall x \in D,\; P(x) \to Q(x)$
"for every x in D, if P(x) then Q(x)"

Contrapositive · equivalent

$\forall x \in D,\; \sim\! Q(x) \to \sim\! P(x)$
Flip and negate. Always equivalent to the original.

Converse · not equivalent

$\forall x \in D,\; Q(x) \to P(x)$
Just flip. Not equivalent in general.

Inverse · not equivalent

$\forall x \in D,\; \sim\! P(x) \to \sim\! Q(x)$
Just negate. Not equivalent, but equivalent to the converse.

Worked example: squares greater than 4

Original: ∀x ∈ ℝ, x > 2 → x² > 4. True.

Converse: ∀x ∈ ℝ, x² > 4 → x > 2. False, pick x = −3: x² = 9 > 4 yet x = −3 is not greater than 2.

This single witness shows the original and its converse are not equivalent.

3.2.5 Necessary and sufficient conditions, "only if"

The Ch 2 vocabulary returns under a universal:
  • "r(x) is sufficient for s(x)": ∀x, r(x) → s(x).
  • "r(x) is necessary for s(x)": ∀x, ∼r(x) → ∼s(x), equivalently ∀x, s(x) → r(x).
  • "r(x) only if s(x)": ∀x, ∼s(x) → ∼r(x), equivalently ∀x, r(x) → s(x).

Pick a statement to see the symbolic form:

Practice exercises · Section 3.2

Adapted from Epp Section 3.2, suggested questions: 14, 17, 23.
Exercise 3.2.A
Write a careful negation of each statement.
  1. ∀ real numbers x, x > 1/x
  2. ∃ an integer n such that n is prime and n is even
  3. ∀ integers a, (a − 1)/a is not an integer

(1) ∼(∀x ∈ ℝ, x > 1/x) ≡ ∃x ∈ ℝ such that x ≤ 1/x.
(The predicate's domain implicitly excludes x = 0 for 1/x to be defined.)

(2) ∼(∃n ∈ ℤ, Prime(n) ∧ Even(n)) ≡ ∀n ∈ ℤ, ∼Prime(n) ∨ ∼Even(n). In words: every integer is either not prime or not even (or both).

(3) ∼(∀a ∈ ℤ, (a − 1)/a is not an integer) ≡ ∃a ∈ ℤ such that (a − 1)/a is an integer. Witness: a = 1 gives (1 − 1)/1 = 0, which is an integer. So the original is false and its negation is true.

Exercise 3.2.B
Write the contrapositive, converse, and inverse of: "For all integers n, if n is even then n² is even."

Original: ∀n ∈ ℤ, P(n) → Q(n) where P(n) is "n is even" and Q(n) is "n² is even". True.

Contrapositive: ∀n ∈ ℤ, ∼Q(n) → ∼P(n) · "if n² is not even, then n is not even", equivalently "if n² is odd, then n is odd." True · equivalent to the original.

Converse: ∀n ∈ ℤ, Q(n) → P(n) · "if n² is even, then n is even." Happens to be true, but does not follow from the original; a separate proof is needed.

Inverse: ∀n ∈ ℤ, ∼P(n) → ∼Q(n) · "if n is not even, then n² is not even." Also true, also separate; equivalent to the converse, not to the original.

Key point. Equivalence between the original and its variants is a question of logical form, not whether each individual variant happens to be true. Original ≡ contrapositive always.

Exercise 3.2.C · vacuous truth
Why is the following vacuously true in Tarski's World (Figure 3.1.1)?
∀x, (Pentagon(x) ∧ Red(x)) → SameColor(x, a)

The hypothesis Pentagon(x) ∧ Red(x) requires x to be both a pentagon and red.

  • Pentagons in this world: none. Only triangles, squares, and circles exist.
  • Red objects in this world: none. Only blue, gray, and black.

So the hypothesis is false for every x in the domain. A conditional with a false hypothesis is automatically true (vacuously true), regardless of what the conclusion says.

Sanity check. The statement remains vacuously true even if we replace the conclusion: ∀x, (Pentagon(x) ∧ Red(x)) → ∼SameColor(x, a) is also vacuously true. Both hold at once, because no x ever triggers the hypothesis.

Section 3.3Statements with multiple quantifiers

So far one quantifier at a time. Real definitions in mathematics nest them: "for every ε > 0 there exists δ > 0 such that …". The two big ideas of Section 3.3:

  • Order counts. ∀x ∃y P(x, y) and ∃y ∀x P(x, y) usually mean different things.
  • Negation pushes inward. To negate, flip every quantifier (∀↔∃) and negate the innermost predicate.

3.3.1 Order of quantifiers, and the challenge game

From the slides: "There is a person supervising every detail of the production process." Two readings, two formal statements, very different meanings.

The challenge game

Read nested quantifiers as a two-player game.

  • ∀x ∃y, P(x, y): the opponent picks any x they want from D. You then respond with some y that makes P(x, y) hold. The y is allowed to depend on x. The statement is true if you have a winning strategy.
  • ∃x ∀y, P(x, y): you commit to one specific x first. The opponent picks any y. Your x is fixed, so it must work against every y.

The order of moves changes everything. ∃∀ is generally stronger than ∀∃.

∃p ∀d, Supervises(p, d)

Reading A. One supervisor oversees every detail.

A single fixed person handles all details.

∀d ∃p, Supervises(p, d)

Reading B. Every detail has someone supervising it.

Possibly a different person for each detail.

∀x ∃y P(x, y)

To prove it true: opponent picks any x; you must find a y that works for that x.

The y is allowed to depend on x.

∃x ∀y P(x, y)

To prove it true: you pick one specific x; it must work for every y.

The x is fixed before anyone gives you a y.

Adjacent same-type quantifiers commute (∀x ∀y ≡ ∀y ∀x, and similarly for ∃). Mixed quantifiers do not.

3.3.2 The loves table

Slide-faithful list of every way to combine ∀ and ∃ with the binary predicate Loves(x, y). Reading the formal version aloud is the easiest way to internalise the meaning.
FormalInformal meaning
∀x ∀y · Loves(x, y)Everything loves everything.
∃x ∃y · Loves(x, y)Something loves something.
∀x ∃y · Loves(x, y)Everything loves something (possibly different y for each x).
∃y ∀x · Loves(x, y)Something is loved by everything (one fixed y).
∃x ∀y · Loves(x, y)Something loves everything (one lover, many loved).
∀y ∃x · Loves(x, y)Everything is loved by something (possibly different x for each y).

3.3.3 Cafeteria worked example

From Epp Example 3.3.3. Three students go through a four-station line. The table records who chose what. The four quantified statements below show how nesting changes everything.
Studentgreen saladfruit saladspaghettifishpiecakemilksodacoffee
Uta
Tim
Yuen
(a)  ∃I ∈ Item, ∀S ∈ Student, Chose(S, I)
"There is an item every student chose."
True · every student chose pie.
(b)  ∃S ∈ Student, ∀I ∈ Item, Chose(S, I)
"There is a student who chose every available item."
False · no student chose all nine items.
(c)  ∃S ∈ Student, ∀Z ∈ Station, ∃I ∈ Z, Chose(S, I)
"There is a student who chose at least one item from every station."
True · both Uta and Tim chose from every station.
(d)  ∀S ∈ Student, ∀Z ∈ Station, ∃I ∈ Z, Chose(S, I)
"Every student chose at least one item from every station."
False · Yuen did not choose any salad.

What to watch. In (a) one item must satisfy every student. In (c) the inner ∃I sits inside ∀Z, so the chosen item can depend on the station. In (d) the inner ∃I sits inside both ∀S and ∀Z, so it can depend on both the student and the station.

3.3.4 Tarski's World with multiple quantifiers (Figure 3.3.1)

A second scene matching Epp Figure 3.3.1 · built specifically for the multi-quantifier examples (Epp Section 3.3.1, 3.3.2, 3.3.8). Try nested quantifiers like ∀x (Circle(x) → ∃y (Square(y) ∧ SameColor(x, y))). The companion expands every ∀ over the domain (big AND) and every ∃ (big OR), reporting the verdict step by step.
Domain: ten objects, a, b, …, j. Different scene from 3.1.4 · layout tuned for the Section 3.3 worked examples.
Try these (Epp Section 3.3 worked examples):

3.3.5 Formal logical notation

Domain restrictions like "for all circles x" are sugar. The fully formal first-order shape uses the connectives differently for ∀ and ∃:
∀x ∈ D, P(x)

Formal: ∀x (D(x) → P(x))

Universal restrictions attach with : "if x is in D, then P(x)". Outside the restriction the conditional is vacuously true.

∃x ∈ D, P(x)

Formal: ∃x (D(x) ∧ P(x))

Existential restrictions attach with : "x is in D and P(x) holds". Outside the restriction the conjunction fails.

Four Tarski-style examples (Epp Section 3.3.10):

  • For all circles x, x is above f.
    ∀x (Circle(x) → Above(x, f))
  • There is a square x such that x is black.
    ∃x (Square(x) ∧ Black(x))
  • For all circles x, there is a square y such that x and y have the same colour.
    ∀x (Circle(x) → ∃y (Square(y) ∧ SameColor(x, y)))
  • There is a square x such that for all triangles y, x is to the right of y.
    ∃x (Square(x) ∧ ∀y (Triangle(y) → RightOf(x, y)))

3.3.6 Negating multiply-quantified statements

The mechanical rule: flip every outer quantifier (∀ ↔ ∃) and negate the innermost predicate. Type any quantified statement; the companion applies the negation step by step.
Try these:

Practice exercises · Section 3.3

Adapted from Epp Section 3.3, suggested questions: 11, 22, 46.
Exercise 3.3.A · challenge game
Let D = {−2, −1, 0, 1, 2}. Explain why each is true (use the challenge-game framing).
  1. ∀x ∈ D, ∃y ∈ D such that x + y = 0
  2. ∃x ∈ D such that ∀y ∈ D, x · y = 0

(1) Opponent picks any x from D. You respond with y = −x. Check every case:

x = −2  →  y = 2,  x + y = 0
x = −1  →  y = 1,  x + y = 0
x =  0  →  y = 0,  x + y = 0
x =  1  →  y = −1, x + y = 0
x =  2  →  y = −2, x + y = 0

Every x has a partner. True. The y depends on x: that is what ∀∃ allows.

(2) You commit to one x before any y is offered. Pick x = 0. Then 0 · y = 0 for every y in D. True. Here x is fixed first, the hallmark of ∃∀.

Exercise 3.3.B · negation
Write a formal negation of each statement.
  1. ∀ real numbers x, ∃ a real number y such that x + y = 0
  2. ∃ a real number y such that ∀ real numbers x, x + y = 0

(1) Walk through left-to-right, flipping each quantifier:

∼(∀x ∈ ℝ, ∃y ∈ ℝ, x + y = 0)
≡ ∃x ∈ ℝ, ∼(∃y ∈ ℝ, x + y = 0)
≡ ∃x ∈ ℝ, ∀y ∈ ℝ, x + y ≠ 0

The original is true (every x has additive inverse −x), so its negation is false.

(2)

∼(∃y ∈ ℝ, ∀x ∈ ℝ, x + y = 0)
≡ ∀y ∈ ℝ, ∼(∀x ∈ ℝ, x + y = 0)
≡ ∀y ∈ ℝ, ∃x ∈ ℝ, x + y ≠ 0

The original claims one universal y zeros out every x, false. The negation is true.

Compare the originals. (1) says "every x has some inverse" (true). (2) says "one y is the inverse of every x" (false). Same predicate, different quantifier order, opposite truth values.

Exercise 3.3.C · Tarski Figure 3.3.1
Refer to Tarski's World in Figure 3.3.1 (the second scene above).
"There is a triangle x such that for all squares y, x is above y."
  1. Is the statement true or false? Justify by inspecting the figure.
  2. Write the statement in formal logical notation.
  3. Write the formal negation.

(a) Truth value. Triangles in Figure 3.3.1: d, f, i. Squares: e, g, h, j. Try each triangle:

  • d (row 3): square e is also in row 3, so d is not above e. Fails.
  • f (row 2): squares e (row 3) and below sit above or alongside, f is not above e. Fails.
  • i (row 2): same story, e is in row 3 above. Fails.

False. No single triangle is above every square.

(b) Formal notation. ∃x (Triangle(x) ∧ ∀y (Square(y) → Above(x, y)))

(c) Negation · push all the way in:

∼∃x (Triangle(x) ∧ ∀y (Square(y) → Above(x, y)))
≡ ∀x ∼(Triangle(x) ∧ ∀y (Square(y) → Above(x, y))) flip ∃
≡ ∀x (∼Triangle(x) ∨ ∼∀y (Square(y) → Above(x, y))) De Morgan
≡ ∀x (Triangle(x) → ∼∀y (Square(y) → Above(x, y))) ∼A ∨ B ≡ A → B
≡ ∀x (Triangle(x) → ∃y ∼(Square(y) → Above(x, y))) flip ∀
≡ ∀x (Triangle(x) → ∃y (Square(y) ∧ ∼Above(x, y))) negate conditional

In English: "for every triangle x, there is a square y such that x is not above y." This matches the falsity of the original.

Recap: Chapter 3

  • A predicate waits for variable values to become a statement; its truth set is the set of values that make it true.
  • ∀ universal is a big AND across the domain; one counterexample kills it. ∃ existential is a big OR; one witness proves it.
  • The domain decides truth. The same predicate can be true over one set and false over another.
  • "No X are Y" formalizes as ∀x ∈ X, ∼Y(x), not as an existential.
  • Negation laws (Theorems 3.2.1 and 3.2.2): ∼∀x Q(x) ≡ ∃x ∼Q(x) and ∼∃x Q(x) ≡ ∀x ∼Q(x).
  • Negation of a universal conditional: ∼∀x (P(x) → Q(x)) ≡ ∃x (P(x) ∧ ∼Q(x)).
  • Vacuous truth: a universal conditional with no x satisfying the hypothesis is true by default.
  • The Ch 2 trio, contrapositive, converse, inverse, carry over under a universal quantifier, with the same equivalence rules.
  • Order of quantifiers counts. ∀x ∃y lets y depend on x; ∃x ∀y fixes x first. ∃∀ is stronger than ∀∃.
  • Multi-quantifier negation: flip every quantifier and negate the innermost predicate.
What's next. Chapter 4: Elementary Number Theory and Methods of Proof. Direct proof, counterexample (now formally introduced), rational numbers, divisibility, and the Quotient-Remainder theorem, all built on the quantified statements practised here.