Reading preferences
Optional display controls need JavaScript. All reading content and navigation work without it.
How to use Read
This page follows the First-order Logic part introduction and the Introduction to First-Order Logic chapter in source order. Equations are native, unflattened MathML, and every source coordinate is available offline.
First-Order Logic
You are probably familiar with first-order logic from your first introduction to formal logic.In fact, we more or less assume you are! If you're not, you could review a more elementary textbook, such as forall x (P. D. Magnus and Tim Button and J. Robert Loftis and Aaron Thomas-Bolduc and Robert Trueman and Richard Zach, 2021). You may know it as “quantificational logic” or “predicate logic.” First-order logic, first of all, is a formal language. That means, it has a certain vocabulary, and its expressions are strings from this vocabulary. But not every string is permitted. There are different kinds of permitted expressions: terms, formulas, and sentences. We are mainly interested in sentences of first-order logic: they provide us with a formal analogue of sentences of English, and about them we can ask the questions a logician typically is interested in. For instance:
Is source 28 logically true, logically false, or contingent?
These questions are primarily questions about the “meaning” of sentences of first-order logic. For instance, a philosopher would analyze the question of whether source 35 follows logically from source 35 as asking: is there a case where source 36 is true but source 36 is false (source 36 doesn't follow from source 37), or does every case that makes source 37 true also make source 38 true (source 38 does follow from source 38)? But we haven't been told yet what a “case” is—that is the job of semantics. The semantics of first-order logic provides a mathematically precise model of the philosopher's intuitive idea of “case,” and also—and this is important—of what it is for a sentence source 42 to be true in a case. We call the mathematically precise model that we will develop a structure. The relation which makes “true in” precise, is called the relation of satisfaction. So what we will define is “source 46 is satisfied in source 46” (in symbols: source 46) for sentences source 47 and structures source 47. Once this is done, we can also give precise definitions of the other semantical terms such as “follows from” or “is logically true.” These definitions will make it possible to settle, again with mathematical precision, whether, e.g., source 51 (Reader correction: The source closes the universal scope only after the entailment. The reader rendering places that bracket before the premise comma and removes the resulting extra final bracket). The answer will, of course, be “yes.” If you've already been trained to symbolize sentences of English in first-order logic, you will recognize this as, e.g., the symbolizations of, say, “All ants are insects, there are ants, therefore there are insects.” That is obviously a valid argument, and so our mathematical model of “follows from” for our formal language should give the same answer.
Another topic you probably remember from your first introduction to formal logic is that there are derivations. If you have taken a first formal logic course, your instructor will have made you practice finding such derivations, perhaps even a derivation that shows that the above entailment holds. There are many different ways to give derivations: you may have done something called “natural deduction” or “truth trees,” but there are many others. The purpose of derivation systems is to provide tools using which the logicians' questions above can be answered: e.g., a natural deduction derivation in which source 69 (Reader correction: The source fragment omits the closing scope bracket of the universal formula. The reader rendering supplies that bracket explicitly) and source 70 are premises and source 70 (Reader correction: The source fragment contains one extra closing scope bracket. The reader rendering removes that extra bracket explicitly) is the conclusion (last line) verifies that source 71 logically follows from source 72 and source 73.
But why is that? On the face of it, derivation systems have nothing to do with semantics: giving a formal derivation merely involves arranging symbols in certain rule-governed ways; they don't mention “cases” or “true in” at all. The connection between derivation systems and semantics has to be established by a meta-logical investigation. What's needed is a mathematical proof, e.g., that a formal derivation of source 80 from premises source 81 and source 82 is possible, if, and only if, source 82 (Reader correction: The source fragment omits the closing scope bracket of the universal formula. The reader rendering supplies that bracket explicitly) and source 83 together entail source 84 (Reader correction: The source fragment contains one extra closing scope bracket. The reader rendering removes that extra bracket explicitly). Before this can be done, however, a lot of painstaking work has to be carried out to get the definitions of syntax and semantics correct.
Syntax
We first must make precise what strings of symbols count as sentences of first-order logic. We'll do this later; for now we'll just proceed by example. The basic building blocks—the vocabulary—of first-order logic divides into two parts. The first part is the symbols we use to say specific things or to pick out specific things. We pick out things using constants, and we say stuff about the things we pick out using predicates. E.g, we might use source 20 as a constant to pick out a single thing, and then say something about it using the sentence source 21. If you have meanings for “source 22” and “source 22” in mind, you can read source 23 as a sentence of English (and you probably have done so when you first learned formal logic). Once you have such simple sentences of first-order logic, you can build more complex ones using the second part of the vocabulary: the logical symbols (connectives and quantifiers). So, for instance, we can form expressions like source 28 or source 29.
In order to provide the precise definitions of semantics and the rules of our derivation systems required for rigorous meta-logical study, we first of all have to give a precise definition of what counts as a sentence of first-order logic. The basic idea is easy enough to understand: there are some simple sentences we can form from just predicates and constants, such as source 36. And then from these we form more complex ones using the connectives and quantifiers. But what exactly are the rules by which we are allowed to form more complex sentences? These must be specified, otherwise we have not defined “sentence of first-order logic” precisely enough. There are a few issues. The first one is to get the right strings to count as sentences. The second one is to do this in such a way that we can give mathematical proofs about all sentences. Finally, we'll have to also give precise definitions of some rudimentary operations with sentences, such as “replace every source 46 in source 46 by source 46.” The trouble is that the quantifiers and variables we have in first-order logic make it not entirely obvious how this should be done. E.g., should source 48 count as a sentence? What about source 50? What should the result of “replace source 51 by source 51 in source 51” be?
Formulas
Here is the approach we will use to rigorously specify sentences of first-order logic and to deal with the issues arising from the use of variables. We first define a different set of expressions: formulas. Once we've done that, we can consider the role variables play in them—and on the basis of some other ideas, namely those of “free” and “bound” variables, we can define what a sentence is (namely, a formula without free variables). We do this not just because it makes the definition of “sentence” more manageable, but also because it will be crucial to the way we define the semantic notion of satisfaction.
Let's define “formula” for a simple first-order language, one containing only a single predicate source 25 and a single constant source 26, and only the logical symbols source 26, source 26, and source 27. Our full definitions will be much more general: we'll allow infinitely many predicates and constants. In fact, we will also consider functions which can be combined with constants and variables to form “terms.” For now, source 30 and the variables will be our only terms. We do need infinitely many variables. We'll officially use the symbols source 32, source 32, …, as variables.
Inductive definition of formulas in the simplified first-order language
The set of formulas source 36 is defined as follows:
the atomic-formula clause tells us that source 54 and source 55 are formulas, for any source 55. These are the so-called atomic formulas. They give us something to start from. The other clauses give us ways of forming new formulas from ones we have already formed. So for instance, by the negation clause, we get that source 59 is a formula, since source 60 is already a formula by the atomic-formula clause. Then, by the existential-quantifier clause, we get that source 62 is another formula, and so on. the limiting clause tells us that only strings we can form in this way count as formulas. In particular, source 65 and source 65 do count as formulas, and source 67 does not, because of the extraneous outer parentheses.
This way of defining formulas is called an inductive definition, and it allows us to prove things about formulas using a version of proof by induction called structural induction. These are discussed in a general way in the section on inductive definitions and the section on structural induction, which you should review before delving into the proofs later on. Basically, the idea is that if you want to give a proof that something is true for all formulas, you show first that it is true for the atomic formulas, and then that if it's true for any formula source 78 (and source 78), it's also true for source 79, source 79, and source 80. For instance, this proves that it's true for source 81: from the first part you know that it's true for the atomic formula source 82. Then you get that it's true for source 83 by the second part, and then again that it's true for source 85 itself. Since all formulas are inductively generated from atomic formulas, this works for any of them.
Satisfaction
We can already skip ahead to the semantics of first-order logic once we know what formulas are: here, the basic definition is that of a structure. For our simple language, a structure source 15 has just three components: a non-empty set source 16 called the domain, what source 17 picks out in source 17, and what source 18 is true of in source 18. The object picked out by source 18 is denoted source 19 and the set of things source 19 is true of by source 20. A structure source 20 consists of just these three things: source 21, source 21 and source 22. The general case will be more complicated, since there will be many predicates and constants, the constants can have more than one place, and Reader correction TR015-SOURCE-PROSE-CORRECTION-001: In the general case there may be many predicates and constants; predicate or relation symbols, not individual constants, can have more than one place. there will also be functions.
This is enough to give a definition of satisfaction for formulas that don't contain variables. The idea is to give an inductive definition that mirrors the way we have defined formulas. We specify when an atomic formula is satisfied in source 30, and then when, e.g., source 31 is satisfied in source 31 on the basis of whether or not source 32 is satisfied in source 32. E.g., we could define:
source 37 is satisfied in source 37 iff source 37 is not satisfied in source 38.
source 39 is satisfied in source 39 iff source 39 is satisfied in source 40, and source 40 is satisfied in source 40 as well.
Let's say that source 43, source 43, and source 44. This definition would tell us that source 45 is satisfied in source 45 (since source 46). It tells us further that source 47 is not satisfied in source 48, and that in turn source 48 is and source 49 is not satisfied, and so on.
The trouble comes when we want to give a definition for the quantifiers: we'd like to say something like, “source 53 is satisfied iff source 54 is satisfied.” But the structure source 55 doesn't tell us what to do about variables. What we actually want to say is that source 57 is satisfied for some value of source 58. To make this precise we need a way to assign elements of source 59 not just to source 59 but also to source 59. To this end, we introduce variable assignments. A variable assignment is simply a function source 61 that maps variables to elements of source 62 (in our example, to one of source 63, source 63, or source 63). Reader correction TR015-SOURCE-PROSE-CORRECTION-002: In this example the assignment values are zero, one, or two, the elements of the domain fixed above. Since we don't know beforehand which variables might appear in a formula we can't limit which variables source 65 assigns values to. The simple solution is to require that source 66 assigns values to all variables source 66, source 67, … We'll just use only the ones we need.
Instead of defining satisfaction of formulas just relative to a structure, we'll define it relative to a structure source 71 and a variable assignment source 71, and write source 72 for short. Our definition will now include an additional clause to deal with atomic formulas containing variables:
Ok, this solves one problem: we can now say when source 83 satisfies source 84 for the value source 84. To get the definition right for source 85 we have to do one more thing: We want to have that source 87 iff source 88 for some way source 88 of assigning a value to source 89. But the value assigned to source 89 does not necessarily have to be the value that source 90 picks out. We'll introduce a notation for that: if source 91, then we let source 92 be the assignment that is just like source 93 (for all variables other than source 93), except to source 94 it assigns source 94. Now our definition can be:
Does it work out? Let's say we let source 99 for all source 99. source 100 iff there is an source 101 so that source 101. And there is: we can choose source 102 or source 103. Note that this is true even if the value source 103 assigned to source 104 by source 104 itself—in this case, source 104—doesn't do the job. We have source 105 but not source 106.
If this looks confusing and cumbersome: it is. But the added complexity is required to give a precise, inductive definition of satisfaction for all formulas, and we need something like it to precisely define the semantic notions. There are other ways of doing it, but they are all equally (in)elegant.
Sentences
Ok, now we have a (sketch of a) definition of satisfaction (“true in”) for structures and formulas. But it needs this additional bit—a variable assignment—and what we wanted is a definition of sentences. How do we get rid of assignments, and what are sentences?
You probably remember a discussion in your first introduction to formal logic about the relation between variables and quantifiers. A quantifier is always followed by a variable, and then in the part of the sentence to which that quantifier applies (its “scope”), we understand that the variable is “bound” by that quantifier. In formulas it was not required that every variable has a matching quantifier, and variables without matching quantifiers are “free” or “unbound.” We will take sentences to be all those formulas that have no free variables.
Again, the intuitive idea of when an occurrence of a variable in a formula source 30 is bound, which quantifier binds it, and when it is free, is not difficult to get. You may have learned a method for testing this, perhaps involving counting parentheses. We have to insist on a precise definition—and because we have defined formulas by induction, we can give a definition of the free and bound occurrences of a variable source 35 in a formula source 35 also by induction. E.g., it might look like this for our simplified language:
If source 38 is atomic, all occurrences of source 38 in it are free (that is, the occurrence of source 39 in source 39 is free).
If source 40 is of the form source 40, then an occurrence of source 40 in source 41 is free iff the corresponding occurrence of source 41 is free in source 42 (that is, the free occurrences of variables in source 42 are exactly the corresponding occurrences in source 43).
If source 44 is of the form source 44, then an occurrence of source 44 in source 45 is free iff the corresponding occurrence of source 45 is free in source 46 or in source 46.
If source 47 is of the form source 47, then no occurrence of source 48 in source 48 is free; if it is of the form source 48 where source 49 is a different variable than source 49, then an occurrence of source 49 in source 50 is free iff the corresponding occurrence of source 50 is free in source 51.
Once we have a precise definition of free and bound occurrences of variables, we can simply say: a sentence is any formula without free occurrences of variables.
Semantic Notions
We mentioned above that when we consider whether source 13 holds, we (for convenience) let source 14 assign values to all variables, but only the values it assigns to variables in source 15 are used. In fact, it's only the values of free variables in source 16 that matter. Of course, because we're careful, we are going to prove this fact. Since sentences have no free variables, source 18 doesn't matter at all when it comes to whether or not they are satisfied in a structure. So, when source 20 is a sentence we can define source 21 to mean “source 21 for all source 21,” which as it happens is true iff source 22 for at least one source 22. We need to introduce variable assignments to get a working definition of satisfaction for formulas, but for sentences, satisfaction is independent of the variable assignments.
Once we have a definition of “source 27,” we know what “case” and “true in” mean as far as sentences of first-order logic are concerned. On the basis of the definition of source 29 for sentences we can then define the basic semantic notions of validity, entailment, and satisfiability. A sentence is valid, source 32, if every structure satisfies it. It is entailed by a set of sentences, source 33, if every structure that satisfies all the sentences in source 34 also satisfies source 34. And a set of sentences is satisfiable if some structure satisfies all sentences in it at the same time.
Because formulas are inductively defined, and satisfaction is in turn defined by induction on the structure of formulas, we can use induction to prove properties of our semantics and to relate the semantic notions defined. We'll collect and prove some of these properties, partly because they are individually interesting, but mainly because many of them will come in handy when we go on to investigate the relation between semantics and derivation systems. In order to do so, we'll also have to define (precisely, i.e., by induction) some syntactic notions and operations we haven't mentioned yet.
Substitution
We'll discuss an example to illustrate how things hang together, and how the development of syntax and semantics lays the foundation for our more advanced investigations later. Our derivation systems should let us derive source 16 from source 16 (Reader correction: The source closes the universal scope before the argument of the atomic formula. The reader rendering keeps that argument inside the atom and the quantified scope). Maybe we even want to state this as a rule of inference. However, to do so, we must be able to state it in the most general terms: not just for source 19, source 19, and source 19, but for any formula source 20, and term source 20, and variable source 21. (Recall that constants are terms, but we'll consider also more complicated terms built from constants and functions.) So we want to be able to say something like, “whenever you have derived source 24 you are justified in inferring source 25—the result of removing source 25 and replacing source 26 by source 26.” But what exactly does “replacing source 26 by source 26” mean? What is the relation between source 27 and source 27? Does this always work?
To make this precise, we define the operation of substitution. Substitution is actually tricky, because we can't just replace all source 32's in source 32 by source 32, and not every source 32 can be substituted for any source 33. We'll deal with this, again, using inductive definitions. But once this is done, specifying an inference rule as “infer source 34 from source 35” becomes a precise definition. Moreover, we'll be able to show that this is a good inference rule in the sense that source 37 entails source 37. But to prove this, we have to again prove something that may at first glance prompt you to ask “why are we doing this?” That source 39 entails source 39 relies on the fact that whether or not source 40 holds depends only on the value of the term source 41, i.e., if we let source 41 be whatever element of source 42 is picked out by source 42, then source 43 iff source 43. This holds even when source 44 contains variables, but we'll have to be careful with how exactly we state the result.
Models and Theories
Once we've defined the syntax and semantics of first-order logic, we can get to work investigating the properties of structures and the semantic notions. We can also define derivation systems, and investigate those. For a set of sentences, we can ask: what structures make all the sentences in that set true? Given a set of sentences source 18, a structure source 18 that satisfies them is called a model of source 19. We might start from source 20 and try to find its models—what do they look like? How big or small do they have to be? But we might also start with a single structure or collection of structures and ask: what sentences are true in them? Are there sentences that characterize these structures in the sense that they, and only they, are true in them? These kinds of questions are the domain of model theory. They also underlie the axiomatic method: describing a collection of structures by a set of sentences, the axioms of a theory. This is made possible by the observation that exactly those sentences entailed in first-order logic by the axioms are true in all models of the axioms.
As a very simple example, consider preorders. A preorder is a relation source 33 on some set source 33 which is both reflexive and transitive. A set source 34 with a two-place relation source 34 on it is exactly what we would need to give a structure for a first-order language with a single two-place relation symbol source 36: we would set source 37 and source 37. Since source 37 is a preorder, it is reflexive and transitive, and we can find a set source 39 of sentences of first-order logic that say this: First-order axioms for a reflexive and transitive relation source 40 These sentences are just the symbolizations of “for any source 44, source 45” (source 45 is reflexive) and “whenever source 45 and source 45 then also source 46” (source 46 is transitive). We see that a structure source 46 is a model of these two sentences source 47 iff source 47 (i.e., source 48), is a preorder on source 48 (i.e., source 48). In other words, the models of source 49 are exactly the preorders. Any property of all preorders that can be expressed in the first-order language with just source 51 as predicate (like reflexivity and transitivity above), is entailed by the two sentences in source 52 and vice versa. So anything we can prove about models of source 53 we have proved about all preorders.
For any particular theory and class of models (such as source 56 and all preorders), there will be interesting questions about what can be expressed in the corresponding first-order language, and what cannot be expressed. There are some properties of structures that are interesting for all languages and classes of models, namely those concerning the size of the domain. One can always express, for instance, that the domain contains exactly source 62 elements, for any source 63. One can also express, using a set of infinitely many sentences, that the domain is infinite. But one cannot express that the domain is finite, or that the domain is nonenumerable. These results about the limitations of first-order languages are consequences of the compactness and Löwenheim–Skolem theorems.
Soundness and Completeness
We'll also introduce derivation systems for first-order logic. There are many derivation systems that logicians have developed, but they all define the same derivability relation between sentences. We say that source 16 derives source 16, source 16, if there is a derivation of a certain precisely defined sort. Derivations are always finite arrangements of symbols—perhaps a list of sentences, or some more complicated structure. The purpose of derivation systems is to provide a tool to determine if a sentence is entailed by some set source 21. In order to serve that purpose, it must be true that source 22 if, and only if, source 22.
If source 25 but not source 25, our derivation system would be too strong, prove too much. The property that if source 26 then source 27 is called soundness, and it is a minimal requirement on any good derivation system. On the other hand, if source 29 but not source 29, then our derivation system is too weak, it doesn't prove enough. The property that if source 31 then source 31 is called completeness. Soundness is usually relatively easy to prove (by induction on the structure of derivations, which are inductively defined). Completeness is harder to prove.
Soundness and completeness have a number of important consequences. If a set of sentences source 37 derives a contradiction (such as source 38) it is called inconsistent. Inconsistent source 39s cannot have any models, they are unsatisfiable. From completeness the converse follows: any source 40 that is not inconsistent—or, as we will say, consistent—has a model. In fact, this is equivalent to completeness, and is the form of completeness we will actually prove. It is a deep and perhaps surprising result: just because you cannot prove source 44 from source 45 guarantees that there is a structure that is as source 46 describes it. So completeness gives an answer to the question: which sets of sentences have models? Answer: all and only consistent sets do.
The soundness and completeness theorems have two important consequences: the compactness and the Löwenheim–Skolem theorem. These are important results in the theory of models, and can be used to establish many interesting results. We've already mentioned two: first-order logic cannot express that the domain of a structure is finite or that it is nonenumerable.
Historically, all of this—how to define syntax and semantics of first-order logic, how to define good derivation systems, how to prove that they are sound and complete, getting clear about what can and cannot be expressed in first-order languages—took a long time to figure out and get right. We now know how to do it, but going through all the details can still be confusing and tedious. But it's also important, because the methods developed here for the formal language of first-order logic are applied all over the place in logic, computer science, and linguistics. So working through the details pays off in the long run.