First-Order Logic — Syntax
Prerequisites
- Propositional Logic — Syntax & Semantics
- Basic set theory notation
🎯 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
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
Refer to specific objects in the domain. Typically lowercase or proper names.
Examples: socrates, 3, delhi, block_A
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.”
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
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.
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
A term is an expression that refers to an object. Defined inductively:
- Every constant symbol is a term.
- Every variable symbol is a term.
- 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.
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)
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.
- 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.
∀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.”
∃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.”
∀ 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)
- Every atomic formula is a WFF.
- If φ is a WFF, then ¬φ is a WFF.
- If φ and ψ are WFFs, then (φ ∧ ψ), (φ ∨ ψ), (φ → ψ), and (φ ↔ ψ) are WFFs.
- 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
In ∀x φ or ∃x φ, the formula φ is the scope of the quantifier. The variable x is bound within φ.
- 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).
- ∀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
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
Predicates: Student(x), StudiesHard(x), Passes(x)
FOL: ∀x ((Student(x) ∧ StudiesHard(x)) → Passes(x))
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.
FOL: ∀x ∃y Loves(x, y)
Compare with “There is someone whom everyone loves”: ∃y ∀x Loves(x, y) — different meaning!
FOL: ¬∀x (Bird(x) → CanFly(x))
Equivalent: ∃x (Bird(x) ∧ ¬CanFly(x)) — “There exists a bird that cannot fly.”
9. Quick Reference Table
| Symbol Type | Examples | Role |
|---|---|---|
| Constants | a, b, john, 2 | Name specific objects |
| Variables | x, y, z | Range over domain objects |
| Predicates | P, Loves, > | Relations (return T/F) |
| Functions | f, 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.