Find a course

Module 1: LogicLesson 3 of 1214 min

Predicates and Quantifiers

Express statements about all or some objects with ∀ and ∃, negate quantified statements correctly, and see why the order of nested quantifiers matters.

Step 1 of 13Learn

Statements with variables

"x > 3" isn't a proposition, because its truth depends on x. It's a predicate: a statement with a variable that becomes a proposition when the variable gets a value. Write P(x): "x > 3." Then P(5) is true and P(1) is false.

Predicates can have several variables. L(x, y): "x loves y." C(s, k): "student s has completed course k." Databases are full of predicates: every row of a table states that a predicate is true for some values.

To make a statement about many values at once, use quantifiers:

  • The universal quantifier ∀x P(x) means "for every x, P(x)." It's true if P(x) holds for every x in the domain (the set of allowed values).
  • The existential quantifier ∃x P(x) means "there exists an x such that P(x)." It's true if P(x) holds for at least one x in the domain.

The domain matters. With the domain of positive integers, ∀x (x ≥ 1) is true. With all integers, it's false.

Checking quantified statements:

  • To prove ∃x P(x), find one example (a witness).
  • To disprove ∀x P(x), find one counterexample.
  • To prove ∀x P(x) on an infinite domain, examples are never enough; you need an argument that covers every case. Checking a million cases proves nothing about the million-and-first. (Euler's polynomial n² + n + 41 gives primes for n = 0 through 39, then fails at n = 40.)

Step 2 of 13Compare

Universal vs existential

Aspect∀x P(x) (for all)∃x P(x) (there exists)
MeansEvery x in the domain worksAt least one x works
To prove itA general argumentOne example
To disprove itOne counterexampleA general argument
Its negation∃x ¬P(x)∀x ¬P(x)

Step 3 of 13Practice · Choose one

With the domain of all integers, which statement is true?

Step 4 of 13Learn

Negating quantified statements

What's the opposite of "every student passed the exam"? Not "every student failed." The original fails as soon as one student didn't pass. So:

¬∀x P(x) ≡ ∃x ¬P(x)

"Not everyone passed" means "someone didn't pass."

Similarly, the opposite of "some student got a perfect score" is "no student got a perfect score," that is, every student failed to get one:

¬∃x P(x) ≡ ∀x ¬P(x)

These are De Morgan's laws for quantifiers. Moving a negation past a quantifier flips ∀ to ∃ or ∃ to ∀, and the negation keeps going inward.

Example. Negate "every bug report gets a response within a day." In symbols: ∀r R(r). Negation: ∃r ¬R(r), "some bug report does not get a response within a day."

Example with a conditional. "All prime numbers greater than 2 are odd" is ∀n (P(n) → O(n)). Its negation is ∃n ¬(P(n) → O(n)) ≡ ∃n (P(n) ∧ ¬O(n)): "there is a prime greater than 2 that is even." Remember that a negated conditional becomes an "and."

Translating "all" and "some." "All A are B" uses → inside: ∀x (A(x) → B(x)). "Some A are B" uses ∧: ∃x (A(x) ∧ B(x)). Mixing these up is a classic error. ∃x (A(x) → B(x)) is almost always trivially true, since any x that isn't an A makes the conditional vacuously true.

Step 5 of 13Practice · What would you do?

What would you do?

A product manager claims: "Every user who enabled notifications opened the app this week." You want to prove her wrong. What do you need?

Step 6 of 13Learn

Nested quantifiers: order matters

Statements with several quantifiers are read left to right, and the order can change the meaning completely.

Let L(x, y) be "x loves y," with the domain of all people.

  • ∀x ∃y L(x, y): "Everyone loves somebody." Each person may love a different person.
  • ∃y ∀x L(x, y): "There is somebody whom everyone loves." One single person is loved by all.

The second statement is much stronger. It implies the first, but not the other way around.

A mathematical example over the integers:

  • ∀x ∃y (x + y = 0) is true: for each x, choose y = −x. The y may depend on x.
  • ∃y ∀x (x + y = 0) is false: no single y works for every x.

Rule of thumb: in ∀x ∃y, the y is chosen after x, so it can depend on x. In ∃y ∀x, the y is chosen first and must work for all x. Swapping two quantifiers of the same type (∀x ∀y or ∃x ∃y) doesn't change meaning.

Negating nested quantifiers. Push the negation inward one quantifier at a time, flipping each:

¬∀x ∃y P(x, y) ≡ ∃x ¬∃y P(x, y) ≡ ∃x ∀y ¬P(x, y).

The definition of a limit in calculus ("for every ε > 0 there exists δ > 0 such that…") is a nested quantifier statement, and negating it this way is how you prove a limit does not exist.

Step 7 of 13Tap to reveal

Order matters: x + y = 0 over the integers

  1. ∀x ∃y (x + y = 0)

    True. For each x, pick y = −x. y is chosen after x, so it may depend on x.

  2. ∃y ∀x (x + y = 0)

    False. One fixed y would have to cancel every x at once.

  3. ∀x ∀y (x + y = 0)

    False. 1 + 1 ≠ 0. Swapping two ∀ never changes meaning.

  4. ∃x ∃y (x + y = 0)

    True. x = 2, y = −2 is enough.

Step 8 of 13Practice · Match the pairs

With the domain of all real numbers, match each statement with its truth value and reason.

Tap an answer, then tap the place where it belongs (or drag it there).

  1. ∀x ∃y (y > x)
  2. ∃y ∀x (y > x)
  3. ∃x ∀y (x · y = 0)
  4. ∀x ∃y (x · y = 1)

Step 9 of 13Practice · Choose one

What is the negation of ∀x ∃y P(x, y)?

Step 10 of 13Diagram

Pushing a negation inward

Each time ¬ passes a quantifier, the quantifier flips.

Pushing a negation inwardProcess diagram: ¬∀x ∃y P(x, y) → ∃x ¬∃y P(x, y) → ∃x ∀y ¬P(x, y).¬∀x ∃y P(x, y)∃x ¬∃y P(x, y)∃x ∀y ¬P(x, y)

Tap a shape with to see more.

¬∀x ∃y P(x, y)
∃x ¬∃y P(x, y)

¬∀ becomes ∃¬.

∃x ∀y ¬P(x, y)

¬∃ becomes ∀¬. The negation now sits on the predicate.

Step 11 of 13Note

Step 12 of 13Practice · True or false

The negation of "Some integers are even" is "Some integers are not even."

Step 13 of 13Practice · Choose one

Which statement is the correct negation of "Every course has a student who earned an A"?