Back to Program Verification Index | Previous: (y-02) Propositional Logic | Next: (y-04) First-Order Theories
Mental Model for First-Order Logic
- First-Order Logic (FOL) is Propositional Logic + Objects, Functions, and Relations. It allows us to talk about “all elements” () or “some elements” ().
- Syntax: We build Terms (representing objects) and Formulas (representing truth).
- Semantics: A formula is only true or false relative to a Model (a universe of objects and a mapping of symbols to meanings).
- Substitution: The “engine” of reasoning in FOL. To prove something about “all ”, we often substitute with a specific term .
Introduction to First-Order Logic

While Propositional Logic is powerful, it can’t easily express statements about objects and their properties. First-Order Logic (FOL), also known as Predicate Logic, adds the machinery needed to formalize math and complex program states.
🧠 Deep Dive: Famous Theorems in FOL
These examples show how FOL can formalize complex mathematical statements.

- Triangle Inequality: The length of one side of a triangle is less than the sum of the lengths of the other two sides.
- Fermat’s Last Theorem: For any integer , no three positive integers satisfy .
- Pumping Lemma (for Regular Languages):
Syntax: Terms and Formulas

In FOL, we distinguish between Terms (representing values/objects) and Formulas (representing truth values).
1. The Vocabulary (Signature)

A vocabulary is a tuple :
- Variables (): A countable set .
- Constants (): A countable set .
- Function Symbols (): Each with an arity (e.g., ).
- Predicate Symbols (): Each with an arity (e.g., ). Arity 0 predicates are like propositional variables.
2. Terms

Terms are the “nouns” of the language. They are defined inductively:
- Every variable is a term.
- Every constant is a term.
- If are terms and has arity , then is a term.
3. Formulas
Formulas are the “sentences”. They are defined inductively:
falseis a formula.- Atoms: If are terms and has arity , then is a formula.
- Connectives: If and are formulas, then are formulas.
- Quantifiers: If is a formula and , then and are formulas.
- Abbreviation: .
Semantics: Models and Interpretations
A formula is assigned a truth value relative to a Model and a Variable Assignment .
- Interpretation Domain (): A non-empty set of objects.
- Interpretation Function ():
- For , .
- For of arity , .
- For of arity , (a relation).
- Variable Assignment (): A mapping .
- Notation: denotes a mapping that is the same as except it maps to .
Evaluation of Terms
Evaluation of Formulas
- iff
- iff
- iff and
- iff there exists such that
Free vs. Bound Variables

- Free Variables (
freevars): The variables not captured by a quantifier.freevars(x) = {x},freevars(c) = ∅freevars(p(t1, ..., tn)) = freevars(t1) ∪ ... ∪ freevars(tn)freevars(∃x. φ) = freevars(φ) \ {x}
- Bound Variable: A variable in the scope of or .
- Closed Formula (Sentence): A formula where
freevars(φ) = ∅. Its truth value is independent of the variable assignment .
Substitution and Variable Capture
Substitution means replacing every free occurrence of in with the term . To avoid Variable Capture, we must ensure that no variable in becomes bound after substitution.
Formal Definition (): If and we apply substitution :
- If , then .
- If , we must rename to a fresh variable :
NFOL: Natural Deduction for FOL
NFOL extends Natural Deduction for Propositional Logic (NPL) with rules for quantifiers.
| Rule | Intro/Elim | Formula | Side Condition |
|---|---|---|---|
| () | Intro | (a) and (b) ( or ) | |
| () | Elim | None | |
| () | Intro | None | |
| () | Elim | (a) and (b) ( or ) |
💡 Why the Side Conditions?
The condition "" in ensures that is an arbitrary element. If we knew something specific about (i.e., it was in ), we couldn’t generalize it to “all ”.
Decidability

- Satisfiability in FOL is undecidable (Church-Turing Theorem).
- Validity in FOL is semi-decidable (we can enumerate proofs, but if a formula is invalid, we might never find out).
Example: A Derivation in NFOL

Goal: Prove .
Let .
- Bottom-up: .
- Use (): . Let .
- Use () on transitivity in with : .
- Use () and () on to get and .
- Use () on these to get .
- Use () with steps 3 and 5 to get .
- Use () on symmetry in with : .
- Use () with steps 6 and 7 to get . QED.
Summary
- FOL = Propositional Logic + Quantifiers + Functions/Predicates.
- Terms represent objects; Formulas represent truth.
- Models give meaning to symbols.
- Decidability: Satisfiability in FOL is undecidable, but Validity is semi-decidable.
Self-Check
- What is the difference between a term and a formula in FOL?
Answer
Terms denote objects and are built from variables, constants, and function symbols applied to other terms. Formulas denote truth values and are built from atoms , the constant
false, propositional connectives, and quantifiers. Terms never have a truth value on their own; formulas always do (relative to a model and assignment).
- What is needed to assign a truth value to a FOL formula?
Answer
A model with a non-empty domain and an interpretation for each constant, function, and predicate symbol, plus a variable assignment . For a closed formula (sentence), the truth value is independent of because no free variables remain.
- Why does the substitution sometimes require renaming a bound variable?
Answer
A naive substitution can let a variable inside be captured by an existing quantifier in , changing the meaning. If and , the rule renames to a fresh first and then substitutes, preserving the original semantics. Capture-avoiding substitution is the engine of every quantifier rule that follows.
- State the side condition for () and explain why it is needed.
Answer
The rule requires (and either or ). The condition forces to be a genuinely arbitrary element: if already constrained in some way, the proof would only establish the property for that specific , not for all .
- Is satisfiability decidable in full first-order logic? What about validity?
Answer
Satisfiability in FOL is undecidable (a consequence of Church-Turing). Validity is semi-decidable: proof systems can enumerate derivations and will find a proof for any valid formula, but for an invalid formula the search may run forever without ever halting.
Back to Program Verification Index | Previous: (y-02) Propositional Logic | Next: (y-04) First-Order Theories | (y) Return to Notes | (y) Return to Home