First-Order Logic — Syntax

GATE Relevance: High

Prerequisites

🎯 Learning Objectives

  • Distinguish constants, variables, predicates, and functions in FOL
  • Construct well-formed formulas using quantifiers ∀ and ∃
  • Identify free and bound variables and understand scope of quantifiers
  • Translate English sentences into FOL and vice versa

1. Why First-Order Logic?

Propositional logic treats the world as a collection of facts that are either true or false. It cannot express statements about objects, their properties, or relationships between them. First-Order Logic (FOL), also called Predicate Logic, extends propositional logic with:

  • Objects — things in the world (people, numbers, cities)
  • Predicates — properties of objects or relations among them
  • Functions — mappings from objects to objects
  • Quantifiers — statements about all or some objects
Example — Propositional vs. FOL

Propositional: “Socrates is mortal” → P (a single proposition)

FOL: Mortal(Socrates) — we can now express who is mortal and reason about it generally: ∀x (Human(x) → Mortal(x))

2. Vocabulary of FOL

Constant Symbols

Refer to specific objects in the domain. Typically lowercase or proper names.

Examples: socrates, 3, delhi, block_A

Variable Symbols

Range over objects in the domain. Typically x, y, z, w.

Variables allow us to make general statements: ∀x P(x) means “P holds for every object.”

Predicate Symbols (Relation Symbols)

Map a tuple of objects to {true, false}. Each predicate has a fixed arity (number of arguments).

  • Unary: Human(x), Even(n) — arity 1
  • Binary: Loves(x, y), GreaterThan(a, b) — arity 2
  • Ternary: Between(x, y, z) — arity 3

Special predicate: Equality (=) is built-in: x = y

Function Symbols

Map a tuple of objects to a single object. Each function has a fixed arity.

  • Unary: Father(x), Successor(n) — returns one object
  • Binary: Plus(x, y), LeftLeg(x) — arity 2

A constant is a zero-arity function symbol.

GATE Tip

In GATE questions, carefully distinguish predicates (return truth values) from functions (return objects). Father(john) as a function returns an object; IsFather(john) as a predicate returns true/false.

3. Terms

Definition — Term

A term is an expression that refers to an object. Defined inductively:

  1. Every constant symbol is a term.
  2. Every variable symbol is a term.
  3. If f is an n-ary function symbol and t1, …, tn are terms, then f(t1, …, tn) is a term.

Nothing else is a term.

Term Examples
  • john — constant (term)
  • x — variable (term)
  • Father(john) — function applied to constant (term)
  • Plus(x, Successor(0)) — nested function application (term)
  • Loves(x, y) — NOT a term (this is an atomic formula, since Loves is a predicate)

4. Atomic Sentences (Atoms)

Definition — Atomic Formula

If P is an n-ary predicate and t1, …, tn are terms, then P(t1, …, tn) is an atomic formula (atom).

An atom with no variables is called a ground atom.

Atomic Formula Examples
  • Human(socrates) — ground atom
  • Loves(x, Mother(x)) — atom with variable x
  • GreaterThan(Plus(2,3), 4) — ground atom with nested function
  • x = Father(y) — equality atom

5. Quantifiers

The power of FOL comes from two quantifiers that let us make statements about collections of objects.

Universal Quantifier ∀ (“for all”)

∀x P(x) means “P(x) is true for every object x in the domain.”

Common pattern: ∀x (Condition(x) → Conclusion(x))

Example: ∀x (Dog(x) → Mammal(x)) — “All dogs are mammals.”

Existential Quantifier ∃ (“there exists”)

∃x P(x) means “there is at least one object x in the domain for which P(x) is true.”

Common pattern: ∃x (Property1(x) ∧ Property2(x))

Example: ∃x (Dog(x) ∧ Black(x)) — “There exists a black dog.”

Common Mistake

∀ uses → (implication), not ∧ (conjunction). Writing ∀x (Dog(x) ∧ Mammal(x)) says “everything is both a dog and a mammal” — almost certainly wrong!

∃ uses ∧ (conjunction), not →. Writing ∃x (Dog(x) → Black(x)) is satisfied whenever there exists any non-dog, making it almost vacuously true.

6. Well-Formed Formulas (WFFs)

Inductive Definition of WFF
  1. Every atomic formula is a WFF.
  2. If φ is a WFF, then ¬φ is a WFF.
  3. If φ and ψ are WFFs, then (φ ∧ ψ), (φ ∨ ψ), (φ → ψ), and (φ ↔ ψ) are WFFs.
  4. If φ is a WFF and x is a variable, then ∀x φ and ∃x φ are WFFs.

Nothing else is a WFF.

7. Scope, Free and Bound Variables

Scope of a Quantifier

In ∀x φ or ∃x φ, the formula φ is the scope of the quantifier. The variable x is bound within φ.

Free vs. Bound Variables
  • An occurrence of variable x is bound if it falls within the scope of a quantifier ∀x or ∃x.
  • An occurrence of x is free if it is not bound by any quantifier.
  • A formula with no free variables is called a sentence (or closed formula).
Free and Bound Variables — Examples
  • ∀x (P(x) → Q(x, y)) — x is bound, y is free
  • ∃x P(x) ∧ Q(x) — first x is bound (in ∃x P(x)), second x is free (outside the scope of ∃x if scope is just P(x))
  • ∀x ∃y Loves(x, y) — both x and y are bound; this is a sentence
Notation Caution

The scope of ∃x in “∃x P(x) ∧ Q(x)” depends on parenthesization. With standard precedence, ∃x binds only P(x), so the second x in Q(x) is free. If we write ∃x (P(x) ∧ Q(x)), both occurrences of x are bound.

8. FOL Translation Examples

Example 1: “Every student who studies hard passes the exam.”

Predicates: Student(x), StudiesHard(x), Passes(x)

FOL: ∀x ((Student(x) ∧ StudiesHard(x)) → Passes(x))

Example 2: “There is a barber who shaves everyone who does not shave himself.”

Predicates: Barber(x), Shaves(x, y)

FOL: ∃x (Barber(x) ∧ ∀y (¬Shaves(y, y) → Shaves(x, y)))

Note: This is the famous Barber Paradox — leads to contradiction in classical logic.

Example 3: “Everyone loves someone.”

FOL: ∀x ∃y Loves(x, y)

Compare with “There is someone whom everyone loves”: ∃y ∀x Loves(x, y) — different meaning!

Example 4: “Not all birds can fly.”

FOL: ¬∀x (Bird(x) → CanFly(x))

Equivalent: ∃x (Bird(x) ∧ ¬CanFly(x)) — “There exists a bird that cannot fly.”

9. Quick Reference Table

Symbol TypeExamplesRole
Constantsa, b, john, 2Name specific objects
Variablesx, y, zRange over domain objects
PredicatesP, Loves, >Relations (return T/F)
Functionsf, Father, +Mappings (return objects)
Connectives¬, ∧, ∨, →, ↔Combine formulas
Quantifiers∀, ∃Generalize over objects
Equality=Identity of objects

Summary

  • FOL extends propositional logic with objects, predicates, functions, and quantifiers.
  • Terms refer to objects; atomic formulas are predicates applied to terms.
  • ∀ (universal) typically pairs with →; ∃ (existential) typically pairs with ∧.
  • A variable is bound if within scope of a quantifier, otherwise free.
  • A sentence is a WFF with no free variables.
  • Quantifier order matters: ∀x∃y ≠ ∃y∀x in general.

References

  • Russell, S. & Norvig, P. AIMA, 4th Ed. — Chapter 8: First-Order Logic
  • Enderton, H.B. A Mathematical Introduction to Logic, 2nd Ed.