Introduction

Propositional logic treats "every prime greater than 2 is odd" as one indivisible proposition. It cannot see the structure inside: the objects (numbers), the properties (prime, odd) and the word "every". First-order logic (predicate logic) adds exactly these: variables that range over a domain, predicates that describe properties and relations of objects, and the quantifiers "for all" and "there exists".

First-order logic is the language of mathematical definitions (limits, asymptotic notation, injectivity), of database queries (tuple relational calculus is a fragment of it), and of program specifications. The working skills are translation between English and formulas, the effect of quantifier order, negation of quantified statements, and deciding which formulas are valid.

Prerequisites

Core concepts

Predicates, domain, and quantifiers

  • The domain of discourse (universe) DD is the non-empty set of objects variables can take. The truth of a quantified statement depends on DD.
  • A predicate P(x)P(x) or R(x,y)R(x, y) becomes a proposition once its variables are given values in DD. Example: L(x,y)L(x, y): "x<yx < y" over the integers; L(2,5)L(2, 5) is true.
  • Universal quantifier: ∀x P(x)\forall x\, P(x) is true if P(d)P(d) is true for every d∈Dd \in D.
  • Existential quantifier: ∃x P(x)\exists x\, P(x) is true if P(d)P(d) is true for at least one d∈Dd \in D.
  • Uniqueness: ∃!x P(x)\exists! x\, P(x) abbreviates ∃x (P(x)∧∀y (P(y)→y=x))\exists x\,(P(x) \land \forall y\,(P(y) \to y = x)).

Over a finite domain D={d1,…,dn}D = \{d_1, \ldots, d_n\}:

∀x P(x)≡P(d1)∧⋯∧P(dn),∃x P(x)≡P(d1)∨⋯∨P(dn).\forall x\, P(x) \equiv P(d_1) \land \cdots \land P(d_n), \qquad \exists x\, P(x) \equiv P(d_1) \lor \cdots \lor P(d_n).

This is the bridge between first-order and propositional reasoning, and a reliable way to test a claim on a small domain.

Domain convention. Domains are always non-empty here (the standard convention). Under it, ∀x P(x)→∃x P(x)\forall x\, P(x) \to \exists x\, P(x) is valid; over an empty domain it would fail.

Free and bound variables, scope

In ∀x (P(x)→Q(x,y))\forall x\,(P(x) \to Q(x, y)), the variable xx is bound by ∀x\forall x, whose scope is the parenthesised formula; yy is free. A formula with no free variables is a sentence and has a truth value once the domain and the meaning of the predicates (an interpretation) are fixed.

Precedence: quantifiers bind more tightly than all connectives, so ∀x P(x)∨Q(x)\forall x\, P(x) \lor Q(x) means (∀x P(x))∨Q(x)(\forall x\, P(x)) \lor Q(x), and the second xx is free. Write the parentheses explicitly when the scope should extend.

Restricted quantifiers: the two standard patterns

EnglishFormulaWrong version (and why)
Every student is enrolled∀x (S(x)→E(x))\forall x\,(S(x) \to E(x))∀x (S(x)∧E(x))\forall x\,(S(x) \land E(x)): says everything is a student
Some student is enrolled∃x (S(x)∧E(x))\exists x\,(S(x) \land E(x))∃x (S(x)→E(x))\exists x\,(S(x) \to E(x)): true if any non-student exists

Rule: ∀\forall goes with →\to; ∃\exists goes with ∧\land.

Negating quantifiers (De Morgan for quantifiers)

¬∀x P(x)≡∃x ¬P(x),¬∃x P(x)≡∀x ¬P(x).\neg \forall x\, P(x) \equiv \exists x\, \neg P(x), \qquad \neg \exists x\, P(x) \equiv \forall x\, \neg P(x).

Negation moves inward, flipping each quantifier it passes and finally negating the matrix:

¬∀x ∃y P(x,y)≡∃x ∀y ¬P(x,y).\neg \forall x\, \exists y\, P(x, y) \equiv \exists x\, \forall y\, \neg P(x, y).

For restricted forms: ¬∀x (S(x)→E(x))≡∃x (S(x)∧¬E(x))\neg \forall x\,(S(x) \to E(x)) \equiv \exists x\,(S(x) \land \neg E(x)) ("some student is not enrolled"), and ¬∃x (S(x)∧E(x))≡∀x (S(x)→¬E(x))\neg \exists x\,(S(x) \land E(x)) \equiv \forall x\,(S(x) \to \neg E(x)) ("no student is enrolled").

Order of quantifiers

Quantifiers of the same kind commute: ∀x ∀y≡∀y ∀x\forall x\, \forall y \equiv \forall y\, \forall x and ∃x ∃y≡∃y ∃x\exists x\, \exists y \equiv \exists y\, \exists x. Quantifiers of different kinds generally do not:

  • ∀x ∃y L(x,y)\forall x\, \exists y\, L(x, y) with L(x,y)L(x, y): "x<yx < y" over the integers: "every integer has a larger integer". True; yy may depend on xx.
  • ∃y ∀x L(x,y)\exists y\, \forall x\, L(x, y): "some integer is larger than every integer". False (take x=yx = y).

The valid direction is

∃y ∀x P(x,y)  ⇒  ∀x ∃y P(x,y),\exists y\, \forall x\, P(x, y) \;\Rightarrow\; \forall x\, \exists y\, P(x, y),

and the converse is not valid. A single witness yy that works for all xx certainly provides a yy for each xx, but not the other way round.

Quantifier order and negation of nested quantifiers
Figure 1. On the domain {1, 2, 3}, a relation drawn as a bipartite picture: for every x some y is related (one arrow out of each x), versus one y related to every x (all arrows into one y). Below, negation pushed through two quantifiers step by step.

Distribution of quantifiers over connectives

StatementStatus
∀x (P(x)∧Q(x))≡∀x P(x)∧∀x Q(x)\forall x\,(P(x) \land Q(x)) \equiv \forall x\, P(x) \land \forall x\, Q(x)Equivalence
∃x (P(x)∨Q(x))≡∃x P(x)∨∃x Q(x)\exists x\,(P(x) \lor Q(x)) \equiv \exists x\, P(x) \lor \exists x\, Q(x)Equivalence
∀x P(x)∨∀x Q(x)⇒∀x (P(x)∨Q(x))\forall x\, P(x) \lor \forall x\, Q(x) \Rightarrow \forall x\,(P(x) \lor Q(x))One direction only
∃x (P(x)∧Q(x))⇒∃x P(x)∧∃x Q(x)\exists x\,(P(x) \land Q(x)) \Rightarrow \exists x\, P(x) \land \exists x\, Q(x)One direction only
∀x (P(x)→Q(x))⇒(∀x P(x)→∀x Q(x))\forall x\,(P(x) \to Q(x)) \Rightarrow (\forall x\, P(x) \to \forall x\, Q(x))One direction only
∀x (P(x)→Q(x))⇒(∃x P(x)→∃x Q(x))\forall x\,(P(x) \to Q(x)) \Rightarrow (\exists x\, P(x) \to \exists x\, Q(x))One direction only

Counterexample for the converse of row 3: domain {1,2}\{1, 2\}, PP true only at 1, QQ true only at 2. Every element satisfies P∨QP \lor Q, but neither PP nor QQ holds everywhere.

When xx does not occur free in AA:

∀x (A∨P(x))≡A∨∀x P(x),∃x (A∧P(x))≡A∧∃x P(x),\forall x\,(A \lor P(x)) \equiv A \lor \forall x\, P(x), \quad \exists x\,(A \land P(x)) \equiv A \land \exists x\, P(x),
∀x (A→P(x))≡A→∀x P(x),∀x (P(x)→A)≡∃x P(x)→A,∃x (P(x)→A)≡∀x P(x)→A.\forall x\,(A \to P(x)) \equiv A \to \forall x\, P(x), \quad \forall x\,(P(x) \to A) \equiv \exists x\, P(x) \to A, \quad \exists x\,(P(x) \to A) \equiv \forall x\, P(x) \to A.

The last two need care: moving a quantifier out of the antecedent of an implication flips it. (∃x (P(x)→A)≡∀x P(x)→A\exists x\,(P(x) \to A) \equiv \forall x\, P(x) \to A relies on the domain being non-empty.)

Validity, satisfiability and interpretations

A sentence is valid if it is true in every interpretation (every non-empty domain and every meaning of the predicates), satisfiable if true in at least one, and unsatisfiable if true in none. To show a sentence is not valid, give one interpretation that makes it false. To show it is valid, argue for an arbitrary interpretation.

Unlike propositional logic, validity in first-order logic cannot in general be decided by any algorithm (Church and Turing). On short problems, small counter-models are the practical tool.

Rules of inference with quantifiers

RuleFromInferCondition
Universal instantiation∀x P(x)\forall x\, P(x)P(c)P(c)any c∈Dc \in D
Universal generalisationP(c)P(c)∀x P(x)\forall x\, P(x)cc arbitrary, with no special assumption
Existential instantiation∃x P(x)\exists x\, P(x)P(c)P(c)cc a new name not used before
Existential generalisationP(c)P(c)∃x P(x)\exists x\, P(x)some c∈Dc \in D

Universal modus ponens: from ∀x (P(x)→Q(x))\forall x\,(P(x) \to Q(x)) and P(a)P(a), infer Q(a)Q(a). Example: "All primes greater than 2 are odd; 7 is a prime greater than 2; so 7 is odd."

Worked examples

Example 1: translation

Domain: people. L(x,y)L(x, y): "xx loves yy".

EnglishFormula
Everybody loves somebody∀x ∃y L(x,y)\forall x\, \exists y\, L(x, y)
There is somebody whom everybody loves∃y ∀x L(x,y)\exists y\, \forall x\, L(x, y)
Nobody loves everybody¬∃x ∀y L(x,y)≡∀x ∃y ¬L(x,y)\neg \exists x\, \forall y\, L(x, y) \equiv \forall x\, \exists y\, \neg L(x, y)
Everybody loves exactly one person∀x ∃y (L(x,y)∧∀z (L(x,z)→z=y))\forall x\, \exists y\,(L(x, y) \land \forall z\,(L(x, z) \to z = y))

Example 2: negation

Let DD be the domain of ff, with aa an accumulation point of DD. Negate “for every ε>0\varepsilon>0 there is δ>0\delta>0 such that for all x∈Dx\in D, 0<∣x−a∣<δ→∣f(x)−L∣<ε0<|x-a|<\delta\to |f(x)-L|<\varepsilon”:

∃ε>0  ∀δ>0  ∃x∈D  (0<∣x−a∣<δ∧∣f(x)−L∣≥ε).\exists\varepsilon>0\;\forall\delta>0\;\exists x\in D\;\big(0<|x-a|<\delta\land |f(x)-L|\ge\varepsilon\big).

This is precisely "the limit of ff at aa is not LL" (see Limits). The implication becomes a conjunction, as ¬(p→q)≡p∧¬q\neg(p \to q) \equiv p \land \neg q.

Example 3: test a claimed equivalence on a small domain

Claim: ∀x ∃y P(x,y)≡∃y ∀x P(x,y)\forall x\, \exists y\, P(x, y) \equiv \exists y\, \forall x\, P(x, y).

Domain {1,2}\{1, 2\}, P(x,y)P(x, y) true exactly when x=yx = y. Left side: for x=1x = 1 choose y=1y = 1, for x=2x = 2 choose y=2y = 2: true. Right side: y=1y = 1 fails at x=2x = 2, y=2y = 2 fails at x=1x = 1: false. The claim is false. Over the 24=162^4 = 16 possible relations PP on {1,2}\{1, 2\}, the left side is true for 9 of them and the right side for 7, and every relation that makes the right side true also makes the left side true.

Example 4: which is valid?

Is ∃x (P(x)→Q(x))→(∃x P(x)→∃x Q(x))\exists x\,(P(x) \to Q(x)) \to (\exists x\, P(x) \to \exists x\, Q(x)) valid?

Try to falsify. Need ∃x P(x)\exists x\, P(x) true and ∃x Q(x)\exists x\, Q(x) false, so QQ is false everywhere; and need ∃x (P(x)→Q(x))\exists x\,(P(x) \to Q(x)) true. Domain {1,2}\{1, 2\}, P(1)P(1) true, P(2)P(2) false, QQ false everywhere: at x=2x = 2, P→QP \to Q is F→F=TF \to F = T. Antecedent true, consequent false: not valid. Compare with the valid sentence ∀x (P(x)→Q(x))→(∃x P(x)→∃x Q(x))\forall x\,(P(x) \to Q(x)) \to (\exists x\, P(x) \to \exists x\, Q(x)).

Important properties and observations

  • The truth of a quantified sentence depends on the domain: ∀x ∃y (y<x)\forall x\, \exists y\,(y < x) is true over the integers and false over the natural numbers (with x=0x = 0, if N\mathbb{N} includes 0, or x=1x = 1 otherwise).
  • ∃y ∀x⇒∀x ∃y\exists y\, \forall x \Rightarrow \forall x\, \exists y, never the reverse in general.
  • ∀\forall distributes over ∧\land; ∃\exists distributes over ∨\lor. The other two combinations hold in one direction only.
  • Moving a quantifier out of the antecedent of →\to flips it.
  • ∀x P(x)→∃x P(x)\forall x\, P(x) \to \exists x\, P(x) is valid only because domains are non-empty.
  • Renaming a bound variable preserves meaning only with capture-avoiding substitution. A safe rule is to choose a completely fresh variable yy, absent both free and bound from PP, and replace just the occurrences bound by the displayed ∀x\forall x: ∀x P≡∀y P[y/x]\forall x\,P\equiv\forall y\,P[y/x]. More generally, yy must be free for xx in PP and absent from its free variables; alpha-rename conflicting inner binders first.

GATE examination perspective

  • Translation MCQs and MSQs. Check that each option keeps the restricted-quantifier rule (∀\forall with →\to, ∃\exists with ∧\land).
  • Negation. Push ¬\neg inward one quantifier at a time; convert ¬(p→q)\neg(p \to q) to p∧¬qp \land \neg q.
  • "Which of the following is valid?" Build a two-element counter-model. For implications, make the antecedent true and the consequent false.
  • Quantifier swap trap. ∀x ∃y\forall x\, \exists y and ∃y ∀x\exists y\, \forall x differ; only ∃∀⇒∀∃\exists \forall \Rightarrow \forall \exists holds.
  • Database link. Relational calculus queries with "for all" (division-style queries) are usually written as ¬∃ … ¬\neg \exists\ \ldots\ \neg.

Summary

Sources

  1. K. H. Rosen, Discrete Mathematics and Its Applications, 7th ed., McGraw-Hill, 2012: Sections 1.4 (Predicates and Quantifiers), 1.5 (Nested Quantifiers) and 1.6 (Rules of Inference).

Next steps