Chapter 6: Quantification, Informally and Medium-formally
We have developed propositional logic, and expanded it to predicate logic. We now continue the project. This time we expand predicate logic to what is called first-order logic.
This chapter introduces the intuitions and ideas. In the next chapter we will study the formal syntax and semantics.
Keep in Your Heart
Throughout this chapter it will help to keep in mind how you would develop a language to talk about the real numbers.
Recall that the real numbers can be thought of, roughly, as “every possible decimal expansion”. The decimal expansion, for example, of 3/2 is 1.5. And the decimal expansion of 1/3 is the infinite expansion 0.333…
Later we’ll have more to say about decimal expansions and the formal construction of real numbers. But at least for now, this is a simple start to thinking about the real numbers.
Some examples: Every integer and rational number is a real number. But then there are some real numbers, like and , which are real numbers but not rational. Later in this course we will actually prove that is real but not rational, whereas proving this for is beyond the scope of this course.
Note that doesn’t look like a “decimal expansion”. But there is a sequence of decimal numerals which is equivalent to .
Now what does this have to do with logic?
First of all notice that the “number of real numbers” is enormous. It is clearly infinite. But even more than being infinite, there's just no good way to list all of the real numbers.
Reals cannot be listed.
We will have more to say about the fact that the real numbers cannot be listed. The more professional way to say this is that the real numbers are "uncountable".
Therefore a language cannot, in any practical sense, name every single real number. Therefore we must have some way to manage the fact that our names run out, before we run out of objects that we want to talk about.
In the chapter on predicate logic we had names for objects that we wanted to talk about. In this chapter we discuss the idea of "variables" and "quantifiers" which allow us to speak about infinite sets, since the variables are able to "vary over the infinite set".
“All” and “Some”
Consider a sentence like “every dog deserves pets”.

If we were to express this in predicate syntax, first we would need a name for every dog. That would be a lot of names, like
for each of about a billion doggies. Then we need a predicate, like , to represent " deserves pets".
Then we need to form the very long conjunction
But in English, the sentence is much simpler and shorter—we just use a phrase like “all”.
"All doggies deserve pets."
Much simpler!
Of course there is a parallel idea for disjunction: Consider the sentence “Some chimpanzee deserves pets.” This one might deserve pets:

This one gives me "no pets" vibes.

To express “some chimps deserve pets” we’ll need to name every chimp,
and then assert
The point being that “all” indicates a long conjunction of a predicate, over every individual in the domain. “Some” indicates a long disjunction of a predicate, over every individual in the domain.
The above only considers a finite domain, like the set of all doggies or the set of all chimps.
But in math we’ll often need to discuss an infinite domain, like in the sentence “Every number divisible by 4 is divisible by 2.” The natural domain for this statement is the set of integers, and so we are claiming
“If 0 is divisible by 4 then 0 is divisible by 2, and if 1 is divisible by 4 then 1 is divisible by 2, and if -1 …”
This is like an “infinitely long conjunction”, although an actual infinitely long sentence is not possible. Therefore we need a system of finite expressions, which is able to make claims about an infinite domain.
Of course we could repeat much of this for disjunction. In the sentence “there is an integer larger than ” we are essentially saying “either 0 is larger than , or 1 is larger than , or -1 is larger than , or …”
Whenever we want to make a claim about all objects within the domain, we call this “universal quantification”. This is indicated by words like “all”, “every”, “each”, and so on.
Whenever we want to make a claim that there is some object within the domain, we call this “existential quantification”. This is indicated by words like “there is”, “there exists”, “some”, and so on.
Quantifiers
We are now going to add quantifiers to our predicate logic. The resulting language is called first-order logic, which we officially define later.
To express “every dog deserves pets” in first-order logic, we will write
The upside-down ‘A’ is read as “for all”. So the literal reading of this expression is
For all in the domain, deserves pets.
This expresses that all dogs deserve pets, so long as the "domain of discourse" is the set of all dogs. If the domain were all chimps, then would express that all chimps deserve pets.
Exercise
Suppose that the domain is the set of all real numbers, TODO. Let be a property which means "x is less than 10."
Decide whether the proposition is true.
If the domain is instead all negative numbers, is true?
To express “some chimp deserves pets”, if the domain is all chimps, then we would write
The backwards 'E' is read as "there exists". So the literal reading of this expression is
There exists an in the domain, deserves pets.
The symbols and are called "quantifiers".
Notice that the syntax uses a variable, like above. However, we still want to have constant symbols, as we did with predicate logic. Variables and constants mean very different things! A variable "varies", i.e. takes on the value of several different domain elements. A constant has its meaning fixed to one specified domain element.
For example, suppose that the domain is all integers, denotes the number 1, and the predicate denotes the relation " is divisible by ".
We can continue to use the semantic notation from the previous chapter, and write
Then to express that every number is divisible by 1, we write
Both variables and constants will be represented by lower-case letters, as you see above. And yet our logical language will need two kinds of object symbols, one for variables and one for constants, and we don't want them to get confused for each other.
Traditionally we will use the letters through for constants, and the letters through for variables. Of course we also allow indices, so that and may be constants, and could be a variable.
Exercise
Establish a reasonable domain and symbols to express the proposition
There is some integer greater than .
Note that we can also quantify over formulas, not just simple predicates. For example, suppose that the domain is all integers, denotes 2, denotes 4, and denotes " is divisible by ". Then consider the expression
This expresses that "for every integer , if is divisible by 4, then is divisible by 2".
If expresses "is even" and expresses "is prime" then
expresses that there exists an even prime integer.
Exercise
Choose a reasonable domain and symbols to express that "every differentiable function of a real variable is continuous".
Choose another reasonable domain and symbols to express that "every cat is a mammal".
Not only can we quantify over formulas, but in fact, we can make formulas out of quantified expressions. For example, if the domain is integers, denotes "is even", denotes "is odd", then the expression
expresses that "there is some number which is even, and there is some number which is odd". This is a true proposition, since there does exist an even integer, 2, and there does exist an odd integer, 3.
Note how different this expression is from the seemingly similar expression
This says that there exists an integer, , which is both even and odd. That is not true, of course, since any number which is even cannot also be odd.
Exercise
Choose a domain and symbols to express "All cats are mammals but not all mammals are cats."
Exercise
Suppose that the domain is all polygons in a two dimensional plane. Just for example, this means that one of the elements in the domain is a triangle with vertices at (0,0), and (1,0), and (0,1). The domain also contains many other triangles, quadrilaterals, pentagons, and so on.
Suppose that denotes the equilateral polygons, the rectangles.
Part 1.
Interpret the meaning of the expression
and decide whether it's a true proposition.
Part 2.
Contrast this with the meaning of
{\tt \neg} {\tt \forall} {\tt x}({\tt E}({\tt x}){\tt \land} {\tt R}({\tt x})) $$ and decide wehther this is a true proposition. ***Part 3.*** Come up with symbols that express the proposition: > Every equilateral rectangle is a square. (This is, of course, a true proposition.)
Quantifiers as For-loops
In computer science it is common to have some set of data, and to "loop over" the data in order to perform some computation.
To give an example that is easy to understand, consider a program that looks at a list of numbers and prints a message every time it encounters a prime number.
This example is very simple.
Note that the example that I give here will seem kind of dumb. All it does is print "Found a prime!" every time it finds a prime. That's not very useful.
It may leave you wondering "Why not use an actually useful example?"
Well, any example of code that is actually useful, is always going to be so complicated that a beginner could not understand it. Therefore our earliest examples always have to be so simple that a beginner can understand, but will then necessarily be useless.
Let's assume the computer comes equipped with a function, isPrime, which returns True if the input is prime, and returns False if the input is not prime. So for example isPrime(1) evaluates to False and isPrime(2) evaluates to True.
Here is the program:
listOfNumbers = [1,2,3,4,5,6]
for num in listOfNumbers:
if isPrime(num):
print("Found a prime!")
This program will print the message "Found a prime!" three times. Here is the logic of how it works:
-
The line
listOfNumbers = [1,2,3,4,5,6]creates the list of numbers[1,2,3,4,5,6]and then stores this list into the variablelistOfNumbers. -
The line
for num in listOfNumbers:begins a "for-loop". This means that eventually every value inlistOfNumberswill be placed intonum. It starts by placing1innum. -
Then the line
if isPrime(num):takes the current value innumand inputs it to the functionisPrime. Because1is not prime, this returnsFalse. BecauseisPrime(num)evaluates toFalse.Then this value gets read by the
if. Theifreads a truth-value and, if it isTrue, will cause the later code to execute. But if the truth-value isFalsethen the later code does not execute.Because
isPrime(num)evaluates toFalsethen theifdictates the later code does not execute. Therefore, the commandprint("Found a prime!")is not run. -
Now that we have reached the end of the indented code, the for-loop repeats. We go back to the line
for num in listOfNumbers:but this time the computer puts2intonum. We now repeat the rest of the program. -
Again we evaluate
isPrime(num), but becausenumnow holds 2, this evaluates toTrue. -
The
ifnow reads aTruevalue, and therefore causes the later code to execute. -
The code
print("Found a prime!")now executes, which causes the computer to display this message. -
We have again reached the end. Therefore the for-loop begins again. We go back up, place
3innum. You can now understand why it's called a "loop". -
Since
3is prime,isPrime(num)evaluates toTrue, and the program prints "Found a prime!". -
Do it all over again with 4, since 4 is not prime no message will be printed.
-
Do it all over again with 5, since 5 is prime it will print the message.
-
Do it all over again with 6, since 6 is not prime no message will be printed.
The evaluation of a quantifier is extremely similar.
Consider evaluating where there are only the constants
Nested Quantifiers
Things get more interesting still when we consider multiple quantifiers.
Consider the domain of all humans on the planet, and the relation which represents “ loves ”.
Now consider the different meanings of each of the following propositions.
- "Everybody loves everybody" like a utopia.
- "Everybody loves somebody" like the Dean Martin song.
- "Somebody loves everybody" like a Jesus figure.
- "Somebody loves somebody", a statement that love is not dead.
I hope that the above gives you an intuition for what the quantifiers mean and how their order can impact the meaning of an expression.
But now let's take an example which is more computational. Suppose that our domain contains just four people, {Axel, Benicio, Cici, Dakota}. Moreover suppose that Axel loves Axel, Benicio, Cici, and Dakota. Benicio loves Cici and Dakota. Nobody else loves anyone else.
Then which of the expressions, are true?
Here is how we check : First, run through every choice of assignment to the variable .
-
If is assigned Axel: Now run through every choice of assignment to .
- If is assigned Axel: To evaluate we must decide if Axel loves Axel. Because he does, then this is a true proposition.
- If is assigned Benicio: Because Axel loves Benicio then is true.
- If is Cici: Axel loves Cici so is true.
- If is Dakota: Axel loves Dakota so is true. Because is true for every choice of , therefore is true in the case where is Axel.
-
If is Benicio: Now run through every choice of assignment to .
- If is Axel: To evaluate we decide if Benicio loves Axel. Because he does not, therefore is false.
Because is false for some choice of then is false.
Because is false for some , then is false.
It will help if we have some notation for the idea of a variable being assigned to some individual. It is common in mathematical logic to write, for example, if the variable is assigned to Axel.
Therefore we can summarize what we saw above: was false because, when and the proposition was false.
Notice that, when variables are involved, the truth of a proposition can
Next let's assess the truth of . We iterate through all assignments to .
I won't continue to iterate through all bullet points, since we've seen the process a couple times by now. But you should feel invited to do the explicit iteration on your own paper.
In summary, you should find that when is assigned Axel, then when is Axel is true, and then when is Benicio is true, and when is Cici is true, and when is Dakota is true.
Therefore when denotes Axel, the proposition is true.
Since is true for some assignment to , therefore is true.
Exercise
Complete the last evaluation by showing that is true.
Exercise
Using the same as above, with the same meaning, decide the truth of the propositions and , and .
Exercise
Consider a domain of just two elements. Let be constant symbols such that denotes and denotes . Let be a property.
-
Explain why is equivalent to , regardless of the meaning of . Also explain why is equivalent to .
-
Now let be another property. Then explain why is equivalent to , which is also equivalent to .
-
We could regard the equivalences above as a kind of "expansion" of the propositions. Find the expansion of , and .
-
What changes if the number of domain elements increases to 3, and we have 3 constant symbols that refer to each domain element?
-
Explain why always implies .
Now we check . Just as before, we iterate through every assignment of .
- If is Axel: We now run through every choice of .
- If is Axel: We've seen that in this case is true.
But already we can conclude that is true when is Axel.
- If is Axel: We've seen that in this case is true.
- If is Benicio: Run through every choice of assignment to .
- If is Axel: Here is false.
- If is Benicio: Here is false.
- If is Cici: Here is true. We can conclude that is true when is Benicio.
- If is Cici: Run through every choice of assignment to .
- If is Axel: Here is false.
- If is Benicio: Here is false.
- If is Cici: Here is false.
- If is Dakota: Here is false. Since is false for every choice of , then is false when is Cici.
Because is false for some , then is false.
Let’s use to mean “ is linked to by a road”. So for example is true while is not.
Let’s also use to mean “ is lexically next after ”. Note that is true because is lexically next after . However, is not true.
Here is a sentence that should be true: For any two cities, and , if is lexically next after then is linked to . In a formula, this is
Intuitively this is true because we see four pairs where one city is lexically next: A and B, B and C, C and D, and D and E. In every case, the pair of cities are linked, as you can see in the graph.
To evaluate formally, we need to consider five total possible assignments to .
Let’s consider these each in turn.
With this assignment we now have to evaluate . To do this we again need to consider five possible assignments to .
-
With this assignment we now have to evaluate . Noting that and , then
-
With this assignment
-
-
-
As we see, when is assigned to , then for every possible mapping of , we get a true proposition.
Therefore .
-
Exercise
Perform this assignment and evaluate .
Exercise
Perform this assignment and evaluate the relevant proposition.
-
-
-
With this assignment
-
-
-
As we see, when , then for every possible mapping of , we get a true proposition.
Therefore .
-
-
We should check this case too, but I promise . However, you are invited to check for yourself if you would like more exercise.
The above now confirms that, for every possible assignment to , the resulting proposition is true.
Therefore it demonstrates .
Exercise
Using the same city and road diagram, solve the following exercises.
You don’t always have to make every single assignment. For example, to show is true, you do need to show that it is true for every possible assignment to . So this means that you need to check at least five assignments to .
Now if you were very flat-footed, you would then check five assignments to . If at least one of those assignments is true, then the existential proposition is true.
But this is more effort than you really need to do. When it comes to an existential quantifier, you really just need to exhibit one instance of , not every instance of . So, for each assignment of , if you find one satisfying assignment of , you can stop early!
-
Show that
is true. (Hint: With an appropriate choice of assignments, this only requires evaluating five propositions. Further hint: For any choice of , it is not linked to itself!)
-
Show that
is true. (With an appropriate choice of assignments, this only requires evaluating five propositions.)
-
Show that
is false. (With an appropriate choice of assignments, this only requires evaluating one proposition!)
-
Show that
is false. (With an appropriate choice of assignments, this only requires evaluating one proposition.)
-
Show that
is true. (With an appropriate choice of assignments, this requires only evaluating one proposition.)
-
Show that is false. This requires evaluating five propositions.
Quantifiers and Tables
There is a nice way to display these evaluations in a tabular form. Consider the domain .
Further suppose that and are unary predicates, and the following table summarizes their truth-values.
| ट | ट | ट | ट | |
| ट | फ | फ | फ |
This tells us that, for instance, is true for , and is false for .
Moreover, suppose that is a binary relation, and the following table summarizes its truth values.
| फ | ट | फ | ट | |
| ट | फ | ट | फ | |
| फ | फ | फ | ट | |
| फ | फ | फ | फ |
This tells us that, for example, is false for the pair but is true for the pair . We find the first one by looking at row a and column a, and the second we find in row d column b.
Note
These two tables are structured differently.
Note that the tables for and are "one dimensional". The columns indicate elements from the domain. The row indicates the predicate.
However, the table for is "two dimensional". The columns indicate domain elements, yes, just like before. But now also the rows indicate domain elements too.
Where is the predicate indicated? Well, there's no room for it now that both rows and columns are taken up. So the predicate is indicated by the entire table (not just one row of the table).
So the two tables are not meant to be read in exactly the same way.
Now let's evaluate the proposition . The table makes this immediately obvious: The row for has a ट and therefore is true.
In fact, every cell of this row is ट and therefore we could even say that is true.
How about ? There is some cell (under ) where is true, and therefore the existential claim is true. How about ? For that to be true we we need every cell to hold ट. Since not every cell is ट, therefore the universal claim is false.
Now let's assess each possible way of stacking quantifiers on .
- : This requires every row and every column to hold ट. Since there is some , then this proposition is false.
- : This requires every row to contains some ट. Since there is some row (d) which contains no ट, then this proposition is false.
- : This requires some row to contain only ट. There is no row like this, and therefore this proposition is false.
- : This requires some row and some column to hold ट. This is true, and therefore the proposition is true.
Exercise
Using the same predicates and meaning above, assess the truth of the following propositions.
For more exercise, you can of course create more formulas like these and assess their truth.
Quantification over Infinite Domains
Now we've looked a lot at quantification over finite domains, because it's a good starting place.
However, one of the major motivations for having quantification is so that we can speak and reason about infinite domains.
Let's set the domain to be , and define some predicates.
We could have be the property that an integer, , is greater than 10. Then is true for 11, 12, and so on.
We could have be the property that an integer has no digit 0 (in its standard base-10 representation). Then is true for 1, 2, and so on up to 9. And it is true for 11, 12, and so on.
Exercise
-
Can you find a negative number for which is true? Can you find a negative number for which is true?
-
Can you find a multiple of 10 for which is true? Can you find a number which is true for which is not a multiple of 10?
Also let be the binary relation on integers which is true when has an equal or greater number of 0 digits than in its standard base-10 representation. So is true for the ordered pair because 1 has an equal or greater number of 0 digits than 2. Also is true for .
All and Some with Two Predicates
In the history of the study of logic, there is a famous diagram (called the "Square of Opposition" TODO) due to Aristotle which represents the relationships between "contraries" and "subalterns".
TODO: Diagram
Let A and B be two predicates. The corners of the square represent the propositions
- "All A's are B's."
- "No A's are B's."
- "Some A's are B's."
- "Not all A's are B's."
All
Consider the proposition
All cats are mammals.
This is the same as saying "If anything is a cat then it is a mammal." The direct translation of this into our logical symbols is therefore
where the properties C and M respectively denote cats and mammals. We assume any reasonable domain (could be things, animals, any domain that holds all mammals will suffice).
Exercise
Write the formal symbols for the following propositions. Assume each has some reasonable domain.
- All mammals are cats.
- All primes are not square. (It is unimportant for this exercise, but the "square numbers" are 0, 1, 4, 9, 16, and so on. These are square because they are the square of some integer. 0 is the square of 0, 1 is the square of 1, 4 is the square of 2, and so on.)
- If anything is both triangular and equiangular, then it is equilateral.
- Every animal with a heart has a kidney, and every animal with a kidney has a heart.
Note that this is merely the assertion of a subset! The set of cats is a subset of the set of mammals. The set of primes are a subset of the non-square numbers. The proposition "all mammals are cats" is false because the set of mammals is not a subset of cats.
Therefore, if and are sets, then to state that is the same as the proposition
Of course, to say that any two sets are equal is simply the conjunction of two subset statements. In symbols, if and only if and . In our logical formalism, is equivalent to
It is worth wondering: Is this equivalent to ? Intuitively the answer is "yes". It says that "for all objects in the domain, if it is in then it is in , and if it is in then it is in ". We will see a rigorous proof of this fact later.
Here is another worthwhile observation: Suppose that we set the domain to be all cats, and then want to express "All cats are mammals.". Yes, we could continue to represent this as . However, with the domain being set to all cats, this now just means the same as . For now this is an idle observation, although when we discuss the idea of "types" we will make more use of this idea.
No
Let's turn our attention to a sentence like
No prime is square.
or
No polygon is cicular.
This states, equivalently, that "every prime is not square", or in symbols,
where the domain and meaning of the predicates are reasonable.
Vacuous Quantification
We're now finally in a good position to review something that we discussed much earlier: vacuous quantification. Recall that the empty set is a subset of every set. In formalism, if is any set then .
Recall that, if we translate what "subset" means, it says that
...
Exercise
Let X be a set and S a collection of properties. Define N(S) as the number of elements which satisfy every property. Show that if S = <>mptyset then N(S)=|X|.