Professional Documents
Culture Documents
(/cs/) (https://www.baeldung.com/cs/)
First-Order Logic
1. Overview
In this tutorial, we’ll study the foundation of first-order logic and become
accustomed to its theoretical and conceptual bases.
https://www.baeldung.com/cs/first-order-logic 1/14
6/17/23, 2:21 PM First-Order Logic | Baeldung on Computer Science
We’ll first start by studying the relationship between natural and formal
languages. Subsequently, we’ll compare first-order logic with
propositional logic. In doing so, we’ll learn the specific characteristics
that the former has and when it’s advantageous to use it over the latter.
We’ll finally study the notation and syntax of first-order structures. This
will allow us to translate expression in natural language into valid
expressions in first-order logic.
At the end of this tutorial, we’ll know what first-order logic is and how it
differs from propositional logic. We’ll also know its syntactic rules, and
will be able to translate natural language expressions into first-order
expressions.
https://www.baeldung.com/cs/first-order-logic 3/14
6/17/23, 2:21 PM First-Order Logic | Baeldung on Computer Science
https://www.baeldung.com/cs/first-order-logic 4/14
6/17/23, 2:21 PM First-Order Logic | Baeldung on Computer Science
https://www.baeldung.com/cs/first-order-logic 5/14
6/17/23, 2:21 PM First-Order Logic | Baeldung on Computer Science
The arity of a function means exactly the same thing as the arity of a
predicate; i.e., the number of its variables.
4.4. Predicates
Predicates (/cs/predicates) are the fundamental components of
formulas and indicate relations between objects. These relationships
can be any of those that are allowed in a discursive domain.
For example, in the domain of family relationships, predicates can be
brother of, father of, mother of. In the context of business relationships,
predicates can be employee of, subsidiary of, controlled by. More
complex predicates, such as son of this father and this mother can also
be defined.
In general, we indicate a relationship between a finite set of variables
with an uppercase letter and, between brackets, the
ordered elements of that set, such as . We can then say
that the predicate has arity n, or, equivalently, that it’s n-
ary, because it refers to terms.
Predicates can have arity higher than unary. A predicate can refer not
only to one but also to two or more terms. In this case, we indicate the
extra variables by separating them with additional commas, as in
or and so forth.
The ternary relationship son of this father and this mother, for example,
can be indicated as the predicate between three variables , ,
. If we then assign the values to , , and ,
https://www.baeldung.com/cs/first-order-logic 6/14
6/17/23, 2:21 PM First-Order Logic | Baeldung on Computer Science
https://www.baeldung.com/cs/first-order-logic 8/14
6/17/23, 2:21 PM First-Order Logic | Baeldung on Computer Science
https://www.baeldung.com/cs/first-order-logic 9/14
6/17/23, 2:21 PM First-Order Logic | Baeldung on Computer Science
5. Well-Formed Formulas
We can finally define well-formed formulas for first-order logic, by
compounding terms, predicates, and quantifiers, according to the
following rules.
The first rule says that predicates consisting of terms are, on their own,
valid formulas. This means that a predicate of the form
constitutes by itself a valid formula.
The second rule says that the equivalence between terms is a valid
formula. This means that , , , and are
all valid formulas, because they comprise exclusively of terms and the
equal sign.
The third rule says that unary logical operators applied to formulas
also constitute formulas. That means that if is a formula, then is
also a formula. If, for example, corresponds to the formula , then
corresponding to is also a formula.
The fourth rule concerns logical operators of arity higher than one.
Formulas connected by those logical operators are also formulas. If
and are two formulas, then , , and are also all valid
formulas.
The last rule relates to quantifiers, and it states that if is a formula
that contains a term , then and are also formulas. We say that a
variable to which a quantifier is assigned for a given formula is called a
bound term for that formula, whereas in the opposite case we call it free
term. A formula that contains only bound terms is special because it can
have only one and one truth value that doesn’t depend on the specific
value of its bound terms.
https://www.baeldung.com/cs/first-order-logic 10/14
6/17/23, 2:21 PM First-Order Logic | Baeldung on Computer Science
https://www.baeldung.com/cs/first-order-logic 11/14
6/17/23, 2:21 PM First-Order Logic | Baeldung on Computer Science
https://www.baeldung.com/cs/first-order-logic 12/14
6/17/23, 2:21 PM First-Order Logic | Baeldung on Computer Science
7. Conclusions
In this tutorial, we studied the conceptual bases of first-order logic and
learned how to derive it as a generalization from propositional logic.
We’ve also studied well-formed formulas and their elementary
components, plus the rules according to which we can connect them
into valid formulas.
CATEGORIES
ALGORITHMS (/CS/CATEGORY/ALGORITHMS)
ARTIFICIAL INTELLIGENCE (/CS/CATEGORY/AI)
CORE CONCEPTS (/CS/CATEGORY/CORE-CONCEPTS)
DATA STRUCTURES (/CS/CATEGORY/DATA-STRUCTURES)
GRAPH THEORY (/CS/CATEGORY/GRAPH-THEORY)
LATEX (/CS/CATEGORY/LATEX)
https://www.baeldung.com/cs/first-order-logic 13/14
6/17/23, 2:21 PM First-Order Logic | Baeldung on Computer Science
NETWORKING (/CS/CATEGORY/NETWORKING)
SECURITY (/CS/CATEGORY/SECURITY)
SERIES
ABOUT
ABOUT BAELDUNG (HTTPS://WWW.BAELDUNG.COM/ABOUT)
THE FULL ARCHIVE (/CS/FULL_ARCHIVE)
EDITORS (HTTPS://WWW.BAELDUNG.COM/EDITORS)
https://www.baeldung.com/cs/first-order-logic 14/14