First-order Logic
First-order Logic
Up to this point I’ve been pretty dogged in presenting the formal syntax and semantics of each logical system that we consider: First with propositional logic and then with predicate logic.
But now consider a formula like the following.
This has many-place relations, and nested quantifiers. This is a more general instance of a first-order formula.
As you can see below, the rigorous definition of the syntax and semantics for first-order logic is long and complex. I don’t recommend that you actually read the following definition in detail—we will not use it through the rest of the course.
Definition
Syntax
Note that we will use a bold comma: . This is a distinct symbol from our simple comma. We do so in order to tell the difference between a comma used in our regular language, and a comma used inside our first-order syntax.
Let , , and . These, respectively, are the sets of unary connectives, binary connectives, and quantifier symbols.
Let , and be three nonempty sets such that each of the following sets are disjoint: , and . The first four of these are, respectively, the set of object symbols, variable symbols, function symbols, predicate symbols.
The set
is an alphabet of a first-order language.
Let be a function, called the arity function.
Every element of is a term.
Let and , and let be terms. Then is a term.
We define to be the set of terms,
Let and , and let be terms. Then is called an atomic formula. Every atomic formula is a first-order formula.
If are any two first-order formulas, and , and , and , then the following are also first-order formulas.
We define to be the set of first-order formulas,
We define a function recursively. Let and and . Let .
-
If then .
-
If then .
-
If and and if , then
-
If and , and if , then
-
-
-
We call the set of free variables of .
If and , then we say that is a closed formula.
We denote the set of closed formulas,
Definition
Semantics
We use the same sets as above for the syntax.
Let be any nonempty set, called the universe.
Let be a function such that, for each , the expression is the interpretation of , which denotes the element of to which is mapped.
Moreover let and . The expression is the interpretation of , which denotes the function to which is mapped.
Moreover, let and . The expression is the interpretation of , which denotes the subset of to which is mapped.
Let .
Let be a function, which we call a variable assignment.
We define the notation to be the function
We call the function v remapping to .
We now define the extended variable mapping, .
- If then .
- If then .
- If and , and , then
For a formula , model , and variable assignment v, we will define what it means for the model and assignment to satisfy the formula, denoted
We use to express that does not hold.
-
If and and , and if we have
then .
-
If then
- If then .
- If and then .
- If or then .
- If or then .
- If and then .
- Suppose that , and for every we have . Then .
- Suppose that and for some we have . Then .
Finally we can define truth in the model .
Let be a closed formula. Then we say that is true in the model , and write , if for every variable assignment v we have .
Another reason why we will avoid actually using this rigorous definition: In my opinion, these ideas don’t significantly help your understanding of other mathematical topics like algebra and topology. Remember, we’re studying logic because it’s inherently interesting, yes—but also, so that we may apply it to understanding other mathematical subjects.
However, we will need a few ideas, even if we do not emphasize their rigorous definition. We will need to understand the idea of a formula, and free and bound variables. Rather than follow the formal definition, we just gesture at the idea with a few examples.
In the following expression, the variables and are free while and are not.
Functions
We are studying logic, to study math. One of the most central things that we understand in mathematics, is how to solve an equation, like
How are we going to represent such a thing in logic?
We're not entirely ready to address this question in its entirety. But certainly any answer is going to have to say something about functions.
In particular, the part of the expression is a function.
Let's say that we use the symbols for 1 and for 2. Let's now further agree that we use the symbol for the "times two" function. That is to say, we will use to denote the function .
Note
is in the object language, not . Note that we are using the symbol for a symbol in the logical language. is not in the logical language (called the "object language"). is in the function itself, which we say is in the "metalanguage". The metalanguage is the language that I am writing to you in: English, or a mathy version of English.
If this is confusing, note that it is exactly the same distinction as having a symbol like '' in the logical language, but the symbol refers to the person, Adam. It is the distinction between syntax and semantics: is in the syntax, the person to whom it refers, Adam, is in the semantics.
In the current context, is the symbol in the syntax, is the actal function that it refers to, in the semantics.
Then suppose that we want to interpret the object referred to by . Intuitively this should be the function, , applied to the number 1. That is
This is what we will eventually ensure when we define the semantics of functions.
But now notice that we will also need to have a certain collection of symbols that are reserved for functions. It is tradition to use and perhaps more after that. But here, the tradition is not especially clear: Is a constant or function?
Well, luckly, we do not rely on tradition. If there is ever ambiguity, we can always just resolve it by declaring explicitly our symbol sets for constants (recall, ), variables (from now on, ), functions (), and predicates ().
These sets of symbols are allowed to be literally any nonempty sets, with the caveat that they cannot overlap. If any object were both a constant and a function symbol, it would introduce unnecessary and unpleasant ambiguity when trying to read a formula.
Similarly none of these sets are allowed to contain parentheses, since that would create readability issues. For example if the left paren, ), were a constant symbol then we would have annoying difficulty reading "". For similar reasons, none of the sets may contain logical connectives, like or , nor may they contain commas.
Finally let's notice that not all functions have just one input. Consider the function .
We have already discused the concept of "arity" with regard to predicates, and the same idea applies to functions. The function above has arity 2. If it is represented by the symbol , then we also say that has arity 2.
Function Composition
Just as propositions can be "put together" using the connectives, also functions can be "put together". The fundamental way that we put functions together is by "composition".
Consider for example the functions and . You may be familiar with composition from earlier math courses. For example, you may already know that that the composition of with is written , and its definition is given by
In this particular example, this means
This means that if we wanted to evaluate the function at input then we may calculate
It may be gratifying to know that function composition is, in fact, substitution! You already learned about substitution for the purposes of an inference rule in an earlier chapter. Well, happily, your understanding of substitution will now start paying dividends.
Using notation like we previously have for substitution, means the same thing as . That is to say, the composition means
Take and replace every instance of x with .
Therefore
I have highlighted where x has been substituted for above.
Let's see another and more complex example. For instance, let and . We will find an equivalent expression for . Again, the idea is that every instance of x in h is replaced by i.
We will not bother with so-called "simplifcation", and leave this as our representation of .
Exercise
Using h and i as above, find the formula for the composition .
Using f and g above, find .
Terms
"Terms" are a generalization of objects. We have already established that constants are objects. Also variables are objects. Although variables do not name a particular element in the domain, they do refer to various elements in the domain.
Anything that refers to an object, we call a term. So constants and variables are all instances of terms.
But also, functions refer to elements in the domain. For example, suppose we use the domain of natural numbers, and the function . Then refers to the element 3.
If is a function symbol of arity n, and are n object symbols, then
is a term.
Moreover, if and are function symbols with arity 1, and an object symbol (either constant or variable), then is also a term.
Definition
Syntax
Suppose that we have sets of symbols, , which respectively denote the sets of constant symbols, variable symbols, and function symbols. We assume that none of these overlap, and none of them contains parentheses, logical connectives, or commas. Let be an arity function.
Any is called an object symbol and is a term.
Let and assume . Let be a collection of terms.
Then is a term.
Suppose that we have
- ,
- ,
- .
Then is a term, because it is an object symbol.
Likewise is a term.
is not a term. However, since its arity is 1, and since is a term, then
is a term.
is not a term, because the arity of is 2. But
is a term.
Exercise
Decide which of the following are terms and which are not.
First-order Syntax
Definition
Syntax
We assume that we have sets of symbols for
- Constants, ,
- Variables, ,
- Functions, ,
- Predicates,
None of these sets overlap, and none of them contain parentheses, logical connectives, or commas.
Let be a property symbol, and a variable symbol.
The expression is called the universal quantification of over .
The expression is called the existential quantification of over .
Any proposition that is formed as a predicate formula, or a predicate formula with universal or existential quantification over all of its variables, is called a first-order formula (or just formula for short). #TODO
Note
Note, this only defines a narrowly restricted case. The above definition does not define quantification over general predicates. It only defines quantification over properties.
All of these are examples of first-order propositions.
The following are not first-order propositions.
The first is not because it is simply malformed: the existential quantifier requires a variable.
The second is not because the variable is not bounded by a quantifier. All variables must be bounded.
The third is not for the same reason, although this time is the unbounded quantifier.
The fourth is not because it uses a constant symbol in quantification. Quantification requires the use of a variable.
Exercise
Classify each of the following as first-order formulas or not.
Definition
Semantics
Let be the domain of discourse and a model.
We assign if for every choice of we have . Otherwise .
We assign if there is some choice of such that . Otherwise .
To give an example, suppose the domain is the set of these objects:

Let the predicate denote a red object, blue, white, black, cone, sphere, cube, cylinder, tetrahedron, and a rectangular prism.
Then because not all of the objects in the domain are red.
However because some object in the domain is red.
Exercise
Let . Let be the predicate “ is positive”, and is the predicate “ is negative”, and the predicate “ is equal to 1”.
Decide which of the following is true.
Exercise
Let be the predicate “ is even”.
For each choice of universe, decide whether and are true.
- .
- .
- .
- .
Of course we don’t have to live with only simple predicates—we can join them into more complex expressions, using the propositional logic from before.
If we refer back to the colorful shapes in the image above, here are some true quantified statements about them:
Respectively, these say
- Every blue object is not a cone.
- There is a white sphere.
- Every black object is white.
- There does not exist a black object.
- There exists an object which is not red.
Notice that (3) above is kind of funny—but technically true!
Don’t believe me? Test it out using the official semantics!
Pick any object, like say, the red cube. Let’s call it u. Now let’s evaluate . By the semantics of the conditional, this is . Because u is not black, . Because u is not white, . Therefore
So it’s true for the red cube!
Exercise
Now let u be the white cylinder. Evaluate .
Next, explain why .
Exercise
Let’s consider a property, P, and a model, , such that for every choice of u in the domain.
Certain it follows that .
Now prove that .
Also prove that .
Exercise
Consider a property, , and model, , such that for every u in the domain.
It follows immediately by definition that .
Is it necessarily true that ?
Hint: What if the model has domain elements and , such that
Set Properties, Operations, and Relations
There is a direct connection between the familiar set operations, on the one hand, and the logical constructs that we’ve developed so far.
Consider for example the set of all even natural numbers, , which in set-builder notation is
Notice that this set is defined by the “is even” property. If we use the symbol for the “is even” property, then the following proposition is true (in a model with universe ).
The above expression says that “ is an element of if and only if is even”. This is more than just true, it is in fact the definition of the set !
We have previously said that any set, Y, can be defined some property, call it . Specifically, if the universe is U, then Y can be defined as
Well, this is just the same thing as saying
What this demonstrates is that anything which we can express by set-builder notation can also be expressed by quantified logic.
Exercise
Write the quantifier logic expression of the set
Let U be a universal set and .
Then the union, , is the set of all elements in or . Put into a logical expression,
Notice the use of the logical operator, .
In fact, we could even state the definition of the union with quantifier logic instead of set-builder notation:
This expression “says” that is an element of , if and only if is either in or .
So we have seen that the idea of the union of sets is something which has equivalent definitions in set-builder notation, and in quantifier logic.
Exercise
In the same style as above, use set-builder notation and a logical operation to define the intersection, .
That is to say, fill in the blank in the expression below.
Exercise
Now define the intersection using quantifier logic instead of set-builder notation.
Exercise
Define using set-builder notation and logical operations, and then also define it using quantifier logic.
Do likewise for the complement, .
We have now seen that all of the set operations, union, intersection, set minus, and complement, can be expressed in quantifier logic.
What about the
Exercise
What is the relationship between sets and , if the following proposition is true?
Exercise
Choose appropriate symbols to express the sentence “All squares are rectangles, but not all rectangles are squares.”
Exercise
Explain why “all that glisters is not gold” implies “gold does not glister”.
Exercise
Explain why “every integer is even or odd” does not rule out the possibility that some integer is both even and odd.
Write a symbolic expression for “every integer is even or odd but not both”.