VU-VFS-2025. Lecture 3 - First Order Logic [000u]
- November 22, 2025
VU-VFS-2025. Lecture 3 - First Order Logic [000u]
- November 22, 2025
1. Syntax
- November 22, 2025
1. Syntax
- November 22, 2025
Definition 1.1. FOL - Syntax [000v]
- November 22, 2025
Definition 1.1. FOL - Syntax [000v]
- November 22, 2025
We can define a first order language as a tuple of 3 sets \(\langle \mathcal C, \mathcal F, \mathcal R\rangle \) where:
- Constants (\(\mathcal C\)): the set of constants in the language. E.g., \(\{a, b, c\}\)
- Function Symbols (\(\mathcal F\)): the set of function symbols in the language. E.g., \(\{f, g, h\}\)
- Relation Symbols (\(\mathcal R\)): the set of relation symbols in the language. E.g., \(\{R, S, T\}\)
Using BNF we can define the syntax as follows
Here the atom \(p\) represents an atomic predicate applied to terms \(t_1, \ldots , t_n\), where \(p \in \mathcal R\) with an arity of \(n\)
Quiz 1.2. First Order Logic - Syntax [000w]
- November 22, 2025
Which of the following are syntactically valid formulas in first order logic?Quiz 1.2. First Order Logic - Syntax [000w]
- November 22, 2025
- \(f(x)\)
- \(p(x)\)
- \(p(f(x))\)
- \(p(p(x))\)
- \(p(f(f(x)))\)
Solution.
- November 22, 2025
Solution.
- November 22, 2025
- \(f(x)\): Invalid, as \(f\) is a function symbol and cannot stand alone as a formula.
- \(p(x)\): Valid, as \(p\) is a relation symbol applied to the term \(x\).
- \(p(f(x))\): Valid, as \(f(x)\) is a term and \(p\) is a relation symbol applied to that term.
- \(p(p(x))\): Invalid, as \(p(x)\) is a formula, not a term, and cannot be an argument to \(p\).
- \(p(f(f(x)))\): Valid, as \(f(x)\) is a term, and applying \(f\) again yields another term, which can be an argument to \(p\).
2. Quantifiers & Scoping
- November 22, 2025
2. Quantifiers & Scoping
- November 22, 2025
Definition 2.1. FOL - Quantifiers and Scoping [000x]
- November 22, 2025
Definition 2.1. FOL - Quantifiers and Scoping [000x]
- November 22, 2025
For quantifiers:
\[ \forall x.\ F \quad \exists x.\ F \]Each variable occurring within the formula \(F\) known as the scope is either:
- bound: if it is within the scope of a quantifier that binds it. E.g., in \(\forall x.\ P(x, y)\), the variable \(x\) is bound.
- free: if it is not bound by any quantifier within the formula. E.g., in \(\forall x.\ P(x, y)\), the variable \(y\) is free.
Quiz 2.2. Quantifiers and Scoping in FOL [000y]
- November 22, 2025
Quiz 2.2. Quantifiers and Scoping in FOL [000y]
- November 22, 2025
Consider the formula
\[ \forall y.\ ((\forall x.\ p(x))) \to q(x, y) \]- Is the \(y\) bound or free?
- Is the first occurrence of \(x\) bound or free?
- Is the second occurrence of \(x\) bound or free?
Solution.
- November 22, 2025
Solution.
- November 22, 2025
- \(y\) is bound, as it is within the scope of the quantifier \(\forall y\).
- The first occurrence of \(x\) is bound, as it is within the scope of the quantifier \(\forall x\).
- The second occurrence of \(x\) is free, as it is not within the scope of any quantifier that binds it.
3. Closed, Open & Ground Formulas
- November 22, 2025
3. Closed, Open & Ground Formulas
- November 22, 2025
Definition 3.1. Closed, Open, and Ground Formulas (FOL) [000z]
- November 22, 2025
Definition 3.1. Closed, Open, and Ground Formulas (FOL) [000z]
- November 22, 2025
We have 3 important classifications of formulas in First Order Logic (FOL) based on the nature of their variables:
- Closed Formula: A formula with no free variables. All variables in the formula are bound by quantifiers. E.g., \(\forall x.\ \exists y.\ p(x, y)\) is a closed formula.
- Open Formula: A formula with at least one free variable. E.g., \(p(x, y)\) is an open formula since both \(x\) and \(y\) are free.
- Ground Formula: A formula with no variables at all. E.g., \(p(a, b)\) is a ground formula if \(a\) and \(b\) are constants.
Quiz 3.2. FOL - Closed, Open, and Ground Formulas [0010]
- November 22, 2025
Quiz 3.2. FOL - Closed, Open, and Ground Formulas [0010]
- November 22, 2025
Consider the following formula
\[ \forall y.\ ((\forall x.\ p(x))) \to (\exists x.\ q(x, y)) \]Is this formula closed, open, or ground?
Solution.
- November 22, 2025
This formula is a closed formula because all variables within the formula are bound by quantifiers. The variable \(y\) is bound by the quantifier \(\forall y\), and both occurrences of \(x\) are bound by their respective quantifiers \(\forall x\) and \(\exists x\). There are no free variables in this formula.
A nice example of a ground formula is something like this
\[
p(a, f(b)) \to q(c)
\]
We can see here that there are no variables at all; \(a\), \(b\), and \(c\) are not bound by any quantifiers, hence the formula is ground since we aren't substituting/quantifying over any variables.
Solution.
- November 22, 2025
4. Term Evaluation
- November 22, 2025
4. Term Evaluation
- November 22, 2025
Definition 4.1. Interpretation (FOL) [0012]
- November 22, 2025
Definition 4.1. Interpretation (FOL) [0012]
- November 22, 2025
In first order logic a Interpretation; similar to the case of propositional logic; is a mapping which assigns meaning to the syntax of the language. In this instance it's a mapping from constants, function symbols and predicate symbols to specific objects, functions and relations in a given domain. We can define an interpretation as a sort of piece wise function as follows:
\[ \begin {align*} I &: \mathcal C \cup \mathcal F \cup \mathcal R \to D \cup (D^n \to D) \cup (D^n \to \{\top , \bot \}) \\ I(c) & = d \quad \forall c \in \mathcal C, d \in D \\ I(f) & = f_D: D^n \to D \quad \forall f \in \mathcal F \\ I(p) & = p_D: D^n \to \{\top , \bot \} \quad \forall p \in \mathcal R \\ \end {align*} \]Where \(D\) (sometimes also denoted as \(U\)) is the domain of discourse which is a non-empty set of objects over which the quantifiers range. Intuitively the domain of discourse represents what we wish to talk about in our interpretation. We can break this down into 3 parts:
- constants (\(c \in \mathcal C\)): are mapped to specific elements in the domain \(d \in D\). For example if \(c\) is the constant \("a"\) and \(D = \{1, 2, 3\}\), then \(I(a) = 1\) could be a valid mapping.
- function symbols (\(f \in \mathcal F\)): are mapped to functions that take elements from the domain and return elements in the domain. For example if \(f\) is a unary function symbol \("f"\) and \(D = \{1, 2, 3\}\), then \(I(f) = f_D\) where \(f_D(1) = 2\), \(f_D(2) = 3\), and \(f_D(3) = 1\) could be a valid mapping.
- relation symbols (\(p \in \mathcal R\)): are mapped to relations (or predicates) that take elements from the domain and return truth values \(\{\top , \bot \}\). For example if \(p\) is a binary relation symbol \("R"\) and \(D = \{1, 2, 3\}\), then \(I(R) = R_D\) where \(R_D(1, 2) = \top \), \(R_D(2, 3) = \bot \), and \(R_D(3, 1) = \top \) could be a valid mapping.
Definition 4.2. Structures and Variable Assignments (FOL) [0013]
- November 22, 2025
Definition 4.2. Structures and Variable Assignments (FOL) [0013]
- November 22, 2025
A structure \(\mathcal {M}\) for a first-order language \(\mathcal {L}\) consists of:
- A non-empty domain \(D\), which is the set of objects that the variables can refer to.
- An interpretation function \(I\) that assigns meanings to the non-logical symbols in \(\mathcal {L}\):
- For each constant symbol \(c\) in \(\mathcal {L}\), \(I(c)\) is an element of \(D\).
- For each n-ary function symbol \(f\) in \(\mathcal {L}\), \(I(f)\) is a function from \(D^n\) to \(D\).
- For each n-ary predicate symbol \(P\) in \(\mathcal {L}\), \(I(P)\) is a subset of \(D^n\).
A variable assignment \(\sigma \) for a structure \(S\) is a function that assigns each variable to an element of the domain \(D\) of the structure. That is, for each variable \(x\), \(\sigma (x) \in D\).
Definition 4.3. Term evaluation (FOL) [0011]
- November 22, 2025
Definition 4.3. Term evaluation (FOL) [0011]
- November 22, 2025
In First Order Logic, terms are evaluated based on an interpretation \(I\) and a variable assignment \(\sigma \) within a structure \(S\) denoted as \(\langle I, \sigma \rangle (t)\). The evaluation rules are as follows:
- If \(t\) is a constant symbol \(c\), then \(\langle I, \sigma \rangle (c) = I(c)\).
- If \(t\) is a variable \(x\), then \(\langle I, \sigma \rangle (x) = \sigma (x)\).
- If \(t\) is a function application \(f(t_1, t_2, \ldots , t_n)\), then \[ \langle I, \sigma \rangle (f(t_1, t_2, \ldots , t_n)) = I(f)(\langle I, \sigma \rangle (t_1), \langle I, \sigma \rangle (t_2), \ldots , \langle I, \sigma \rangle (t_n)) \]
Quiz 4.4. Term evaluation (FOL) [0014]
- November 22, 2025
Quiz 4.4. Term evaluation (FOL) [0014]
- November 22, 2025
Consider the following domain/universe of discourse, variable assignment, and interpretation:
- Universe \[ U \triangleq \{1, 2\} \]
- Variable assignment \[ \sigma \triangleq \{x\mapsto 2, y\mapsto 1\} \]
- Interpretation \[ \begin {align*} I & \triangleq \{a \mapsto 1, b \mapsto 2\} \\ I & \triangleq \{f(1, 1) \mapsto 2, f(1, 2) \mapsto 2, f(2, 1) \mapsto 1, f(2, 2) \mapsto 1\} \end {align*} \]
What is the evaluation of the following terms under the given interpretation and variable assignment?
- \(f(a, y)\)
- \(f(x, b)\)
- \(f(f(x, b), f(a, y))\)
Solution.
- November 22, 2025
Solution.
- November 22, 2025
- \(\langle I, \sigma \rangle (f(a, y)) = I(f)(\langle I, \sigma \rangle (a), \langle I, \sigma \rangle (y)) = I(f)(I(a), \sigma (y)) = I(f)(1, 1) = 2\)
- \(\langle I, \sigma \rangle (f(x, b)) = I(f)(\langle I, \sigma \rangle (x), \langle I, \sigma \rangle (b)) = I(f)(\sigma (x), I(b)) = I(f)(2, 2) = 1\)
- \(\langle I, \sigma \rangle (f(f(x, b), f(a, y))) = I(f)(\langle I, \sigma \rangle (f(x, b)), \langle I, \sigma \rangle (f(a, y))) = I(f)(1, 2) = 2\)
5. Semantic Entailment
- November 22, 2025
5. Semantic Entailment
- November 22, 2025
Definition 5.1. Semantic Entailment \(\models \) (FOL) [0015]
- November 22, 2025
Definition 5.1. Semantic Entailment \(\models \) (FOL) [0015]
- November 22, 2025
We evaluate formulas in first order logic under a structure which consists of a domain and an interpretation function. In addition, we need a variable assignment to evaluate formulas with free variables. To denote truth under a structure \(S\) and variable assignment \(\sigma \) we write:
- True: If a formula \(F\) evaluates to true under \(U, I, \sigma \) we write \[U, I, \sigma \models F\]
- False: If a formula \(F\) evaluates to false under \(U, I, \sigma \) we write \[U, I, \sigma \nvDash F\]
We can define semantic entailment inductively as follows:
Quiz 5.2. Semantic Entailment (FOL) [0016]
- November 22, 2025
Quiz 5.2. Semantic Entailment (FOL) [0016]
- November 22, 2025
Consider constants (free variables) \(a, b\) and a unary function \(f\), and a binary predicate \(p\). Let \(U = \{\alpha , \beta \}\) and interpretation function \(I\) be defined as follows:
\[ \begin {align*} I &= \{a \mapsto \alpha , b \mapsto \beta \} \\ I &= \{f(\alpha ) \mapsto \beta , f(\beta ) \mapsto \alpha \} \\ I &= \{p(\beta , \alpha ) \mapsto \top , p(\beta , \beta ) \mapsto \top \} \end {align*} \]Under the structure \(S = (U, I)\) and variable assignment \(\sigma = \{x \mapsto \alpha \}\) what do the following formulas evaluate to?
- \(p(f(b), f(x))\)
- \(p(f(x), f(b))\)
- \(p(a, f(x))\)
Solution.
- November 22, 2025
Solution.
- November 22, 2025
- \(p(f(b), f(x))\) evaluates to \(\top \) because \(f(b) = f(\beta ) = \alpha \) and \(f(x) = f(\alpha ) = \beta \), and \(p(\alpha , \beta ) = \top \).
- \(p(f(x), f(b))\) evaluates to \(\top \) because \(f(x) = f(\alpha ) = \beta \) and \(f(b) = f(\beta ) = \alpha \), and \(p(\beta , \alpha ) = \top \).
- \(p(a, f(x))\) evaluates to \(\bot \) because \(a = \alpha \) and \(f(x) = f(\alpha ) = \beta \), and \(p(\alpha , \beta ) = \bot \).
6. Semantic argument method
- November 22, 2025
6. Semantic argument method
- November 22, 2025
Definition 6.1. Connectives and Quantifiers (FOL) [0017]
- November 22, 2025
Definition 6.1. Connectives and Quantifiers (FOL) [0017]
- November 22, 2025
In addition to evaluating atomic formulas, we can define the evaluation of complex formulas using logical connectives and quantifiers as follows:
For the proof rules of quantifiers we have two variants depending on whether we are dealing with free or bound variables:
Definition 6.2. Semantic Argument method (FOL) [0018]
- November 22, 2025
Definition 6.2. Semantic Argument method (FOL) [0018]
- November 22, 2025
In first order logic, the semantic argument method represents a proof by contradiction. The basic idea is as follows:
- We assume that our formula \(F\) is not valid, i.e., \(\exists S, \sigma \nvDash F\)
- Use the proof rules to derive a contradiction from this assumption.
- If we can indeed derive a contradiction, we conclude that our initial assumption was false, and therefore \(F\) must be valid.
We can express the semantic argument method via the following inference rule:
So the idea here being that if we have a predicate and its negation both holding under the same interpretation and variable assignment, we can derive a contradiction. This allows us to conclude that our initial assumption (that the formula is not valid) must be false, thereby proving the validity of the formula.
Quiz 6.3. Semantic Argument method (FOL) [0019]
- November 22, 2025
Quiz 6.3. Semantic Argument method (FOL) [0019]
- November 22, 2025
Consider the following formula:
\[ F \triangleq (\forall x.\ p(x)) \to (\forall y.\ p(y)) \]Using the semantic argument method, determine whether the formula \(F\) is valid.
Solution.
- November 22, 2025
We begin by assuming that \(\exists S, \sigma \nvDash F\)
\[
\begin {align*}
& S, \sigma \nvDash (\forall x.\ p(x)) \to (\forall y.\ p(y)) \\
& \therefore S, \sigma \models \forall x.\ p(x) \land S, \sigma \nvDash \forall y.\ p(y) \\
& \therefore S, \sigma \models \forall x.\ p(x) \land S, \sigma \models \neg \forall y.\ p(y) \\
\end {align*}
\]
Since we have \(p\) and its negation both holding under the same interpretation and variable assignment, we can derive a contradiction using the Contradiction rule from the semantic argument method. Therefore, our initial assumption that \(F\) is not valid must be false. Hence, we conclude that the formula \(F\) is valid.
Solution.
- November 22, 2025