MAT2033 · Week 2 · nested quantifiers and introduction to proofs

Nested quantifiers and rules of inference

The difference between ∀x∃y and ∃y∀x, truth values of nested quantifiers, their negation, and showing with rules that an argument is valid.

nested quantifiersorder of quantifiersnegationargumentpremiseconclusionvalid argumentrule of inferencemodus ponensmodus tollenshypothetical syllogismdisjunctive syllogismresolutionfallacyuniversal instantiationexistential generalization

Last week you saw statements with a single quantifier. Real mathematical sentences usually contain two or three quantifiers: “every number has an inverse”, “there is no number greater than everything”. The first half of this page explains how to read these statements, how to find their truth value and how to negate them. The second half covers rules of inference: going from premises to a conclusion step by step, writing a rule name next to each step. Both come up on the midterm; the truth value of a quantified statement is almost certain, and “is the argument valid” is also common.

Golden rules:

  1. Quantifiers are read and chosen from left to right. The one that comes first is chosen first; the next one can be chosen looking at it.
  2. In ∀x ∃y\forall x\,\exists y, yy may depend on xx. In ∃y ∀x\exists y\,\forall x it may not.
  3. When negating, every quantifier flips and the order does not change.
  4. Valid argument = if the premises are true, the conclusion is certainly true. To show invalidity, a single row with premises T and conclusion F is enough.

Nested quantifiers

Let P(x,y)P(x, y) be a predicate of two variables. Think of ∀x ∃y P(x,y)\forall x\,\exists y\, P(x,y) as two nested loops:

∀x ∃y P(x,y):   for each x:              (outer loop, all must pass)
                    search some y        (inner loop, finding one is enough)
                    with P(x,y) true
∃y ∀x P(x,y):   find ONE y such that
                    for each x: P(x,y)   (the same y must work with all x)

From a programmer’s point of view: ∀\forall means all items in a for loop return true, and ∃\exists means break as soon as one true is found in the loop. Changing the order means swapping the loops, and it changes the result.

Everyday example. Domain: the players and coaches on a team. C(y,x)C(y, x): ”yy is the coach of xx”.

  • ∀x ∃y C(y,x)\forall x\,\exists y\, C(y, x): “Every player has a coach.” The striker’s coach can be one person and the defender’s another.
  • ∃y ∀x C(y,x)\exists y\,\forall x\, C(y, x): “There is a single person who is everyone’s coach.” A much stronger claim.

If the second is true, the first is also true (you choose that single person for everyone). The converse is generally not true.

The four basic statements with two variables

Domain: the integers, P(x,y)P(x, y): "x<yx < y".

StatementReadingTruthWhy
∀x ∀y (x<y)\forall x\,\forall y\,(x < y)x<yx < y for every pairFx=y=0x = y = 0 breaks it
∀x ∃y (x<y)\forall x\,\exists y\,(x < y)for every number there is a greater numberTy=x+1y = x + 1
∃y ∀x (x<y)\exists y\,\forall x\,(x < y)there is a number greater than everythingFonce yy is chosen, x=yx = y breaks it
∃x ∃y (x<y)\exists x\,\exists y\,(x < y)there is a pairT0<10 < 1

On the exam you write the truth value of a statement like this:

  • If you say True: for ∃\exists give the concrete value (“take y=x+1y = x + 1”), for ∀\forall argue with an arbitrary element (“for any integer xx …”).
  • If you say False: for ∀\forall give a concrete counterexample, for ∃\exists show that no element satisfies it.

Worked examples

The domain is the integers.

∀x ∃y (x=2y)\forall x\,\exists y\,(x = 2y). False. Counterexample x=1x = 1: if 1=2y1 = 2y then y=12∉Zy = \tfrac12 \notin \mathbb{Z}. (If the domain were the reals it would be true with y=x/2y = x/2.)

∃x ∀y (x+y=y)\exists x\,\forall y\,(x + y = y). True. Take x=0x = 0: 0+y=y0 + y = y for every integer yy.

∀x ∃y (xy=1)\forall x\,\exists y\,(xy = 1). False. Counterexample x=2x = 2: 2y=12y = 1 has no integer solution. x=0x = 0 also breaks it.

PITFALL · Thinking “the order doesn’t matter”. ∀x ∃y\forall x\,\exists y and ∃y ∀x\exists y\,\forall x can swap places only when the quantifiers are of the same kind (∀∀\forall\forall or ∃∃\exists\exists). With mixed quantifiers the order changes the meaning.

Translation

The domain is the students in a class, F(x,y)F(x, y): ”xx and yy are friends”.

SentenceLogic
Everyone has a friend.∀x ∃y F(x,y)\forall x\,\exists y\, F(x, y)
Someone is a friend of everyone.∃x ∀y F(x,y)\exists x\,\forall y\, F(x, y)
Nobody is friends with everyone.¬∃x ∀y F(x,y)≡∀x ∃y ¬F(x,y)\lnot\exists x\,\forall y\, F(x, y) \equiv \forall x\,\exists y\,\lnot F(x, y)
Every student has a friend other than themselves.∀x ∃y (x≠y∧F(x,y))\forall x\,\exists y\,(x \ne y \land F(x, y))

Pattern: ∀\forall for “every” and “all”, ∃\exists for “some”, “a”, “at least one”. The connective inside again follows last week’s rule: if there is a condition under ∀\forall use →\to, under ∃\exists use ∧\land.

Negating nested quantifiers

The rule is the same as last week’s, just applied several times: as you push the ¬\lnot from left to right, you flip each quantifier.

¬ ∀x ∃y (P(x,y) ∧ Q(x))
≡ ∃x ¬∃y (P(x,y) ∧ Q(x))
≡ ∃x ∀y ¬(P(x,y) ∧ Q(x))
≡ ∃x ∀y (¬P(x,y) ∨ ¬Q(x))        De Morgan

With restricted quantifiers the restriction stays as it is: ¬ ∀x>0  P(x)≡∃x>0  ¬P(x)\lnot\,\forall x > 0\; P(x) \equiv \exists x > 0\; \lnot P(x). If “every positive number satisfies it” is false, there is a positive number that does not satisfy it.

Rules of inference

An argument consists of premises and a conclusion. An argument is valid if the conclusion is certainly true whenever all the premises are true. That is, (p1∧p2∧⋯∧pn)→q(p_1 \land p_2 \land \dots \land p_n) \to q is a tautology. Validity is about the form, not the content.

Instead of building a long truth table, you chain known valid patterns:

RulePremisesConclusion
Modus ponenspp, p→qp \to qqq
Modus tollens¬q\lnot q, p→qp \to q¬p\lnot p
Hypothetical syllogismp→qp \to q, q→rq \to rp→rp \to r
Disjunctive syllogismp∨qp \lor q, ¬p\lnot pqq
Additionppp∨qp \lor q
Simplificationp∧qp \land qpp
Conjunctionpp, qqp∧qp \land q
Resolutionp∨qp \lor q, ¬p∨r\lnot p \lor rq∨rq \lor r

Rules with quantifiers:

RulePremiseConclusion
Universal instantiation∀x P(x)\forall x\, P(x)P(c)P(c), for any cc
Universal generalizationP(c)P(c) for arbitrary cc∀x P(x)\forall x\, P(x)
Existential instantiation∃x P(x)\exists x\, P(x)P(c)P(c) for some (unnamed) cc
Existential generalizationP(c)P(c) for a specific cc∃x P(x)\exists x\, P(x)
Universal modus ponens∀x (P(x)→Q(x))\forall x\,(P(x) \to Q(x)), P(a)P(a)Q(a)Q(a)

Two classic fallacies

  • Affirming the conclusion: p→qp \to q, qq ∴p\therefore p. Invalid. “Whoever studies hard passes. Ali passed. So Ali studied hard.” Maybe he was lucky.
  • Denying the hypothesis: p→qp \to q, ¬p\lnot p ∴¬q\therefore \lnot q. Invalid. “Whoever studies hard passes. Ali did not study. So Ali failed.” Maybe he passed anyway.

In both, the row that breaks it is p=Fp = F, q=Tq = T: the premises are true and the conclusion is false.

Worked example: solving an argument with rules

Premises: “If I wake up early and I am not tired, I go to the gym.” “I did not go to the gym.” “I woke up early.” Conclusion: “I was tired.”

First assign letters: ww: wake up early, hh: tired, gg: go to the gym. The premises are (w∧¬h)→g(w \land \lnot h) \to g, ¬g\lnot g, ww. The conclusion is hh.

1. (w ∧ ¬h) → g      premise
2. ¬g                premise
3. ¬(w ∧ ¬h)         modus tollens, 1, 2
4. ¬w ∨ h            De Morgan + double negation, 3
5. w                 premise
6. h                 disjunctive syllogism, 4, 5   (¬w is false, so h remains)

The argument is valid. Step 4 is not a rule of inference but an equivalence law; it is enough to write its name too.

Worked example: resolution

Premises p∨qp \lor q, ¬p∨r\lnot p \lor r, ¬q∨r\lnot q \lor r. Conclusion rr.

1. p ∨ q        premise
2. ¬p ∨ r       premise
3. q ∨ r        resolution, 1, 2
4. ¬q ∨ r       premise
5. r ∨ r        resolution, 3, 4
6. r            idempotent law, 5

In everyday terms: “I will go either by bus (pp) or by train (qq). If I go by bus I will be late. If I go by train I will also be late. So I will be late.” This pattern is also called proof by cases; you will see it again on the proof page.

TIP · Write the letters first. The line “Let pp: …, qq: …” is part of your marks on the exam. Then go on with numbered lines; to the right of each line write “premise” or the rule name and the line numbers you used.

Common mistakes

Wrong ideaThe truth
∀x ∃y\forall x\,\exists y and ∃y ∀x\exists y\,\forall x are the sameWith mixed quantifiers the order changes the meaning
For ∃y ∀x\exists y\,\forall x, choosing a separate yy for each xxA single yy is chosen and must work with all xx
In negation, flipping only the first quantifierAll of them flip, the order is kept
¬ ∀x>0 P(x)≡∃x≤0 ¬P(x)\lnot\,\forall x > 0\, P(x) \equiv \exists x \le 0\,\lnot P(x)The restriction stays: ∃x>0 ¬P(x)\exists x > 0\,\lnot P(x)
Skipping the word “other”You need the condition x≠yx \ne y
p→qp \to q, qq ∴p\therefore p is validAffirming the conclusion, invalid
p→qp \to q, ¬p\lnot p ∴¬q\therefore \lnot q is validDenying the hypothesis, invalid
Explaining invalidity with “I don’t think so”Write down the concrete row with premises T and conclusion F
Adding a line without writing the rule nameThe justification of every line is worth marks

Test yourself

Exam-style questions. Solve them on paper first, then reveal the answer.

Question 1easy

The domain of all variables is the integers. Determine the truth values of (a) ∀x ∃y (x+y=5)\forall x\,\exists y\,(x + y = 5) and (b) ∃y ∀x (x+y=5)\exists y\,\forall x\,(x + y = 5).

Show answer
(a) true, (b) false

(a) For each xx choose y=5−xy = 5 - x; this is an integer and x+y=5x + y = 5. yy is allowed to depend on xx, so there is no problem.
(b) We need a SINGLE yy that works for all xx. Once yy is fixed, x+y=5x + y = 5 holds only for x=5−yx = 5 - y; for example x=6−yx = 6 - y breaks it. False.

Question 2easy

The domain is the integers. Is ∃x ∀y (xy=0)\exists x\,\forall y\,(xy = 0) true? Justify.

Show answer
True, take x = 0

With ∃x\exists x in front, you first pick a single xx, and then that xx must work with all yy. If you pick x=0x = 0, then 0⋅y=00 \cdot y = 0 for every yy. True.

Question 3medium

The domain is the real numbers. Determine the truth values of (a) ∀x ∃y (y2=x)\forall x\,\exists y\,(y^2 = x) and (b) ∀x ∃y (x=y3)\forall x\,\exists y\,(x = y^3).

Show answer
(a) false, (b) true

(a) Counterexample x=−1x = -1: no real yy gives y2=−1y^2 = -1, because y2≥0y^2 \ge 0.
(b) For every real xx, y=x3y = \sqrt[3]{x} is a real number and y3=xy^3 = x. The cube root is defined for negatives too. True.

Question 4medium

The domain is the positive integers. Is ∀x ∃y (y<x)\forall x\,\exists y\,(y < x) true?

Show answer
False, counterexample x = 1

One counterexample is enough for ∀x\forall x. For x=1x = 1 there is no positive integer with y<1y < 1. If the domain were the integers it would be true (y=x−1y = x - 1).

Question 5medium

Let the domain of xx and yy be {1,2,3}\{1, 2, 3\}. Find the truth values of (a) ∀x ∃y (x+y=4)\forall x\,\exists y\,(x + y = 4), (b) ∃y ∀x (x≤y)\exists y\,\forall x\,(x \le y), (c) ∀x ∀y (x+y≤5)\forall x\,\forall y\,(x + y \le 5).

Show answer
(a) T, (b) T, (c) F

(a) x=1⇒y=3x=1 \Rightarrow y=3, x=2⇒y=2x=2 \Rightarrow y=2, x=3⇒y=1x=3 \Rightarrow y=1. Every xx has a partner: T.
(b) y=3y = 3 is greater than or equal to everyone: T.
(c) For x=y=3x = y = 3, 6≤56 \le 5 is false: F. With ∀∀\forall\forall you check every pair, and one of them fails.

Question 6medium

Let C(x,y)C(x, y) mean "xx has chatted with yy", the domain being the students in a class. Express in logic: "Every student has chatted with at least one other student in the class."

Show answer
∀x ∃y (x ≠ y ∧ C(x, y))

"Every student" is the outer ∀x\forall x. "At least one" is the inner ∃y\exists y. The word "other" brings the condition x≠yx \ne y; if you forget it, a student chatting with themselves would also count. Because it is ∃\exists, the connective is ∧\land.

Question 7medium

Write the negation of ∀x ∃y (P(x,y)→Q(y))\forall x\,\exists y\,(P(x, y) \to Q(y)) so that no negation sign is in front of a quantifier.

Show answer
∃x ∀y (P(x, y) ∧ ¬Q(y))

Flip each quantifier from left to right: ∀x→∃x\forall x \to \exists x, ∃y→∀y\exists y \to \forall y. The order stays the same. Then the inside: ¬(P→Q)≡P∧¬Q\lnot(P \to Q) \equiv P \land \lnot Q.

Question 8hard

Negate the statement ∀ε>0  ∃N  ∀n>N  (∣an∣<ε)\forall \varepsilon > 0\; \exists N\; \forall n > N\; (\lvert a_n \rvert < \varepsilon) so that no negation sign is in front of a quantifier.

Show answer
∃ε > 0 ∀N ∃n > N (|a_n| ≥ ε)

The three quantifiers flip in turn: ∀ε→∃ε\forall\varepsilon \to \exists\varepsilon, ∃N→∀N\exists N \to \forall N, ∀n→∃n\forall n \to \exists n. The restrictions (ε>0\varepsilon > 0, n>Nn > N) stay as they are, because they give the range of the quantifier. In the innermost part, ¬(∣an∣<ε)≡∣an∣≥ε\lnot(\lvert a_n \rvert < \varepsilon) \equiv \lvert a_n \rvert \ge \varepsilon.

Question 9easy

Which rule of inference is used? "If the code compiles, the tests run. The tests did not run. Therefore the code did not compile."

Show answer
Modus tollens

pp: compiles, qq: tests run. The premises are p→qp \to q and ¬q\lnot q, the conclusion is ¬p\lnot p. This pattern is called modus tollens. It is valid, because ((p→q)∧¬q)→¬p((p \to q) \land \lnot q) \to \lnot p is a tautology.

Question 10medium

Is the following argument valid? "If the server is down, the website is offline. The website is offline. Therefore the server is down." Justify.

Show answer
Invalid (fallacy of affirming the conclusion); row p = F, q = T

pp: server down, qq: website offline. The pattern is p→qp \to q, qq ∴p\therefore p. To show it is invalid, find a row where all premises are T and the conclusion is F: p=Fp = F, q=Tq = T. In this row p→q=Tp \to q = T and q=Tq = T but p=Fp = F. The site could be offline for another reason.

Question 11medium

Show that the premises "If it rains, practice is cancelled", "If practice is cancelled, I study", "It rains or I am injured" and "I am not injured" imply "I study". Name each rule.

Show answer
Valid: disjunctive syllogism gives r, hypothetical syllogism gives r → s, modus ponens gives s.

rr: rains, cc: cancelled, ss: I study, ii: injured. The premises are r→cr \to c, c→sc \to s, r∨ir \lor i, ¬i\lnot i.
1. r∨ir \lor i (premise), 2. ¬i\lnot i (premise), 3. rr (disjunctive syllogism, 1, 2)
4. r→cr \to c, 5. c→sc \to s (premises), 6. r→sr \to s (hypothetical syllogism, 4, 5)
7. ss (modus ponens, 3, 6). Write a number and a rule name on every line.

Question 12hard

"Every computer engineering student takes MAT2033. Selin is a computer engineering student. Therefore Selin takes MAT2033." Write the argument in logic and name the rule that justifies it.

Show answer
∀x (E(x) → M(x)), E(Selin) ∴ M(Selin); universal modus ponens

E(x)E(x): computer engineering student, M(x)M(x): takes MAT2033. First, universal instantiation gives E(Selin)→M(Selin)E(\text{Selin}) \to M(\text{Selin}), then modus ponens gives M(Selin)M(\text{Selin}). The combination of the two is called universal modus ponens.

Verification: Quantifier truth values were checked by brute force over finite domains and over the integer window -200..200, nested negations over random finite models, and all arguments with truth tables (is the conclusion T whenever the premises are T) using node (verify/MAT2033/02.mjs).

Review card

∀x∃y: y may depend on x (a separate y for each x). ∃y∀x: ONE y works for everyone. If ∃y∀x P is true, then ∀x∃y P is true too; the converse is generally NOT. ∀x∀y: one failing pair makes it false. ∃x∃y: one satisfying pair makes it true. Negate: flip each quantifier from left to right, keep the order, negate the inside last. ¬∀x∃y P(x,y) ≡ ∃x∀y ¬P(x,y) ¬(P→Q) ≡ P∧¬Q ¬(a<b) ≡ a≥b "other" → the condition x≠y. A restriction (ε>0, n>N) stays unchanged under negation. Modus ponens p, p→q ∴ q Modus tollens ¬q, p→q ∴ ¬p Hyp. syllogism p→q, q→r ∴ p→r Disj. syllogism p∨q, ¬p ∴ q Addition p ∴ p∨q Simplification p∧q ∴ p Conjunction p, q ∴ p∧q Resolution p∨q, ¬p∨r ∴ q∨r INVALID: p→q, q ∴ p (affirming conclusion); p→q, ¬p ∴ ¬q (denying hypothesis) To show invalid: one row with premises T and conclusion F ∀x(A(x)→B(x)), A(c) ∴ B(c): universal modus ponens