<<

Math 4680, Topics in and Computation, Winter 2012 Notice that when we discussed sentential logic, we included the connective “↔” Lecture Notes 3: The of First-Order Logic as a primitive connective of our language. We have dropped this connective now, since it constituted an unnecessary luxury, and it did not mesh well with natural Peter Selinger deduction. However, we do not go as far as Enderton, who drops all connectives except for “→”, “¬”, and “∀”. ∗ 1 The language of first-order logic Let A denote the of finite strings over the alphabet A. If α and β are strings, then we denote their by αβ. 1.1 Signatures 1.3 Well-formed terms Definition. A first-order consists of two disjoint sets F and of func- ∗ tion symbols, respectively, predicate symbols, together with an arity Definition 3. The set T ⊆ A of well-formed terms (or simply terms) over a ∗ ar : F∪P → N. If f ∈ F and ar(f) = n, then we call f an n-ary function given first-order signature is the smallest of A such that . If P ∈ P and ar(P ) = n, then we call P an n-ary predicate symbol. We also use the words “nullary”, “unary”, “binary”, etc., for 0-ary, 1-ary, 2-ary 1. If x is a variable, then x ∈ T . and so on. A nullary function symbol is also called a constant symbol. A nullary 2. If c is a constant symbol, then c . predicate symbol is sometimes called a sentence symbol. ∈ T Example 1. The signature of arithmetic has a constant symbol “0”, 3. If f is an n-ary function symbol, where n > 1, and if t1,...,tn ∈ T , then a unary function symbol “S”, binary function symbols “+”, “·”, and “E”, and a f(t1,...,tn) ∈ T . binary predicate symbol “<”. The intended interpretations of these symbols are Example 4. Relative to the signature of elementary arithmetic, the following are respectively zero, the , addition, multiplication, exponentiation, well-formed terms: and the less than relation. Example 2. The signature of set has at least a binary predicate symbol +(x, y) S(S(S(0))) ·(S(S(0)), +(E(x, 0),S(0))) “∈”. Sometimes one also adds a constant symbol “∅”, binary function symbols “∪” and“∩”, and so forth. We will soon start using a more readable, informal for terms, writing, for instance x + y, 3, and 2 · (x0 +1) for the above three terms. However, the syntax, while cumbersome, has technical advantages because it guarantees us a 1.2 Alphabet unique readability result similar to that proved for well-formed of sen- tential logic. When we use the informal syntax, it will always be understood that First-order terms and formulas will be defined relative to a given signature. Given we actually mean the corresponding well-formed terms of the . a signature, the alphabet of first-order logic consists of the elements of F and P, plus the following symbols (which we assume are not in F and P): ¬∧ ∨ →⊤⊥ ∀ ∃ (connectives) 1.4 Well-formed formulas ≈ (equality) Definition 5. The set W ⊆ A∗ of well-formed formulas (wff’s) over a given ( ) , (auxiliary symbols) first-order signature is the smallest subset of A∗ such that x1 x2 x3 ... (variables) Notice that there is a countable supply of variables. We denote the set of variables 1. If Q is a nullary predicate symbol, then Q ∈W. by V, and we often use lower-case roman letters such as x,y,z to denote variables.

1 2 2. If P is an n-ary predicate symbol, where n > 1, and if t1,...,tn are well- Relative to the signature of , the following are well-formed formulas: formed terms, then P (t1,...,tn) ∈W. 4. ∈(x, y). 3. If t1 and t2 are well-formed terms, then ≈(t1,t2) ∈W. 5. (∃x (∀y ( ¬ ∈(y, x)))). 4. ⊤, ⊥ ∈W. 6. (∀x (∀y 5. If α then ( α) . ∈W ¬ ∈W ((∀z ((∈(z, x)→∈(z,y))∧(∈(z,y)→∈(z, x))))→≈(x, y)))). 6. If α, β ∈W then (α ∧ β) ∈W, (α ∨ β) ∈W, and (α → β) ∈W, 7. If α ∈W and x is a variable, then (∀x α) ∈W and (∃x α) ∈W. 1.6 Backus-Naur Form

The formulas build by rules 1–4 are called atomic formulas. All other well- In , where one needs to define all the time, a useful formed formulas are called composite formulas. notation has emerged for defining sets of strings. The notation is called BNF (for Backus-Naur Form). The BNF notation is nothing but a succinct way of stating the The sets of terms and formulas that arise from a given signature are also called the content of Definitions 3 and 5, and other such similar definitions. The following language of that signature. For instance, we speak of the language of elementary is the BNF for well-formed terms and formulas of first-order logic: arithmetic, or the language of set theory, etc. Remark. In Definitions 3 and 5, we speak of the “smallest” set of strings satisfying Terms: t x c f(t1,...,t ) certain conditions. In order for this to be well-defined, we must prove in each case ::= n that such a smallest set actually exists. The proof is very similar to the case of Formulas: α ::= Q P (t1,...,tn) ≈(t1,t2) ⊤ ⊥ sentential logic, and we omit it here. ( ¬ α) (α1 ∧ α2) (α1 ∨ α2) (α1 → α2) Notice that equality symbol ≈ is automatically included in every first-order lan- (∀x α) (∃x α) guage. We regard ≈ as a logical symbol with a fixed , namely equal- ity. In this, it differs from the other predicate symbols, which are non-logical Here, the symbols t, and α are meta-variables that range over terms and formulas, symbols whose meaning depends on the context. The symbol ≈ is not part of the respectively. Moreover, x ranges over variables, c ranges over constant symbols, signature of a language, since the signature only fixes the non-logical symbols. f ranges over n-ary function symbols with n > 1, Q ranges over nullary predicate > However, we do occasionally refer to ≈ as a binary predicate symbol. symbols, and P ranges over n-ary predicate symbols with n 1. Each clause of the BNF defines a syntactic , such as terms, formulas, etc. The vertical lines in each clause separate the different alternative forms that a string in 1.5 Examples that syntactic class can have. The meaning of a BNF is that it defines the smallest set(s) of strings closed under certain operations. Thus, it is really just a short-hand Relative to the signature of elementary arithmetic, the following are well-formed notation for the inductive clauses spelled out in Definitions3and5. formulas:

1. ≈(x, S(0)). 1.7 Induction, , and unique readability

2. (∀x (∃y ( ¬ ≈(x, y)))). As in the case of sentential logic, there are induction and recursion principles for 3. (∀x (∀y (∀z ((<(x, y) ∧ <(y,z)) → <(x, z))))). terms and formulas of first-order logic. Also, a unique readability result holds.

3 4 Since the proofs are very similar to those of sentential logic, we omit them here, 1.9 Free variables and we will henceforth use induction and recursion without further ado. Definition. The set FV(t) of free variables of a term t, and the set FV(α) of free variables of a α, are recursively defined as follows: 1.8 Informal syntax Terms: FV(x) = {x} We will also adopta moreliberal syntax for writingterms and formulas informally. FV(f(t1,...,tn)) = FV(t1) ∪ ... ∪ FV(tn) (n > 0) For the sentential connectives, we adopt the same precedence rules as before. We Formulas: FV(P (t1,...,t )) = FV(t1) ∪ ... ∪ FV(t ) (n > 0) also write ∀x α or ∀x.α instead of (∀x α), and similar for ∃. The convention is n n FV(t1 ≈ t2) = FV(t1) ∪ FV(t2) that when we use a dot, as in ∀x.α, then the scope of the quantifier extends as far FV(⊤) = ∅ as possible, so that ∀x.α ∧ β means ∀x(α ∧ β) and not (∀x α) ∧ β. FV(⊥) = ∅ For terms, we use the usual infix notation where appropriate. For instance, we FV(( ¬ α)) = FV(α) write x + y · z instead of +(x, ·(y,z)). We do the same for certain binary FV((α1  α2)) = FV(α) ∪ FV(β) predicates, for instance we write x 1 uniformly in case distinctions. With this convention, the atomic sentence if FV(α)= ∅. We sometimes denote sentences by the letters σ and τ. formulas are precisely the formulas of the form P (t1,...,tn), t1 ≈ t2, ⊤, or ⊥. We also adopt certain other conventions,such as writing x 6

5 6 3. For each n-ary predicate symbol P in P, a relation S(S(S(S(S(0))))) ≈ 0. A A B P ⊆ |A|n, The following sentences hold in , but not in :

called the interpretation of P . ∀x∀y∀z(x

Note that we require the carrier to be non-empty. Also note that the interpretation ∀x∀y(x + y ≈ 0 → x ≈ 0 ∧ y ≈ 0). of each function symbol is a total function, i.e., it is everywhere defined. We do In particular, not every structure of elementary arithmetic makes all the sentences not allow function symbols to denote partial functions. So for instance, if we were true that would be true of the natural numbers. If a structure satisfies, say, the to interpret the language of fields, we would be forced to interpret the inversion −1 −1 of , then we call it a model of number theory. Notice the operation (−) by a total function. We handle this situation by interpreting 0 −1 difference in the usage of the words “structure” and “model”: wespeakofa struc- by some dummy value, for instance, we could let 0 =0. ture for a language, but of a model of the axioms. But we are getting ahead of ourselves: axioms and models are discussed in Section 2.5 below. 2.2 Examples

The standard model for the language of elementary arithmetic is the following 2.3 The interpretation of terms and formulas structure: In the previous section, we have given some examples of structures, and we have |A| = N = {0, 1, 2,...} informally spoken of a structure “satisfying” certain sentences but not others. We s : V → |A| which assigns an The following defines another structure for the language of elementary arithmetic: of the carrier to each variable of the language. If s is a valuation, x ∈ V a variable, and a ∈ |A| is an individual, then we denote by s(x|a) the valuation s′ |B| = {0, 1, 2, 3, 4} that behaves like s, except that it assigns a to x:

The structure A satisfies different sentences than the structure B. For example, s¯(x) = s(x) A > the following sentences hold in B, but not in A: s¯(f(t1,...,tn)) = f (¯s(t1),..., s¯(tn)) (n 0)

∀x∃y(x ≈ S(y)).

7 8 If A is a structure, s : V → |A| a valuation, and ϕ a formula, then we define quantifier, for all a ∈ A, we have |=A Qx [s(x|a)], and thus, for all a ∈ A, a ∈ A A whether |A| satisfies ϕ under the valuation s, in symbols |=A ϕ [s], by the fol- Q . In particular, s(y) ∈ Q , and thus |=A Qy [s]. Since A and s were arbitrary, lowing recursive clauses: this shows ∀x. Qx |= Qy. A Example. Prove that Qy 6|= ∀x. Qx. It suffices to give a particular structure and |=A P (t1,...,tn)[s] iff hs¯(t1),..., s¯(tn)i ∈ P |=A t1 ≈ t2 [s] iff s¯(t1)=¯s(t2) a valuation such that the left-hand side is satisfied and the right-hand side is not. A A |=A ⊤ [s] always So let | | = {0, 1}, and let Q = {0}. Let s be a valuation such that s(y)=0. |=A ⊥ [s] never Then |=A Qy [s], but not |=A ∀x. Qx [s]. A ( ϕ) s iff not A ϕ s |= ¬ [ ] |= [ ] Notice that the situation is similar to doing proofs with truth tables: To prove ( ) |=A ϕ1 ∧ ϕ2 [s] iff |=A ϕ [s] and |=A ψ [s] that a logical entailment holds, we need to consider all structures and valuations, A (ϕ1 ϕ2) s iff A ϕ s or A ψ s |= ∨ [ ] |= [ ] |= [ ] whereas to prove that a logical entailment doesn’t hold, it suffices to give a single ( ) |=A ϕ1 → ϕ2 [s] iff |=A ϕ [s] implies |=A ψ [s] counterexample. The difference is that structures, unlike truth tables, need not A ( x ϕ) s iff for all a A , A ϕ s x a |= ∀ [ ] ∈ | | |= [ ( | )] be finite, and thus there is no obvious mechanical method for deciding whether A ( x ϕ) s iff there exists a A such that A ϕ s x a |= ∃ [ ] ∈ | | |= [ ( | )] a given logical entailment holds or not. (In fact, one can prove that there isn’t a Remark. Strictly speaking, the above definition does not fit into the schema of non-obvious method either). our recusion principle, because we are definition a predicate by recursion, and not a function. More formally, one would first define, by recursion, a function 2.5 and models modelsA which assigns a modelsA(ϕ, s) ∈ {T, F } to each pair of a well-formed formula ϕ and a valuation s. One would then define |=A ϕ [s] if and We first observe that the interpretation of a sentence does not depend on the valu- only if modelsA(ϕ, s)= T . ation s. Lemma 6. 1. If s, s′ are valuations which agree on the free variables of a 2.4 Logical entailment ′ term t, then s¯(t)=¯s (t). Definition. Let Γ be a set of well-formed formulas, and ϕ a well-formed formula. 2. If s, s′ are valuations which agree on the free variables of a formula ϕ, then ′ We say that Γ logically implies (or entails) ϕ, in symbols Γ |= ϕ, if for every |=A ϕ [s] if and only if |=A ϕ [s ]. structure A and every valuation s in A: if |=A ψ [s] holds for every ψ ∈ Γ, then |=A ϕ [s]. Proof. Exercise. 

As before in the case of sentential logic, we use certain shorthand notations. Thus Corollary 7. If σ is a sentence and A is a structure, then |=A σ [s] is independent we write ψ1,...,ψn |= ϕ instead of {ψ1,...,ψn} |= ϕ, and |= ϕ instead of of the valuation s (i.e., either it holds for all valuations, or for no valuation).  ∅ |= ϕ. Thus, |= ϕ means that every structure and every valuation satisfies ϕ. In this case, we say that the formula ϕ is valid. We say that two formulas ϕ and ψ We say that A is a model of σ if |=A σ [s] for some s. Since this notion does logically equivalent if ϕ |= ψ and ψ |= ϕ. In this case, we also write ϕ |==| ψ. not depend on s (by the previous corollary), we simply write |=A σ in this case. A Notice that, as compared to our terminology in sentential logic, we have dropped Similarly, if Σ is a set of sentences, then we say that is a model of Σ, in symbols the “tauto” from “tautological entailment” and “tautological equivalence”. One |=A Σ, if |=A σ for all σ ∈ Σ. usually speaks of tautologies only in the case of sentential logic. Let A be a structure. The set of all sentences that are satisfied in A is called the Example. Prove that ∀x. Qx |= Qy. Take an arbitrary structure A and an arbitrary theory of A. It is also denotedTh(A). More generally, if C is a class of structures, valuation s such that |=A ∀x. Qx [s]. Then, by the interpretation of the universal

9 10 the set of those sentences that are satisfied in every structure A ∈ C is called the theory of C , and written Th(C ). We can also take the opposite point of view: starting from a set Σ of sentences, we can ask for the class of structures which satisfy Σ. This class is denoted by Mod(Σ). In this context, the sentences in Σ are often called axioms, and we say that the class Mod(Σ) is axiomatized by Σ. Definition. We say that C is axiomatizable if C = Mod(Σ) for some set Σ of sentences. We say that a class C of structures is finitely axiomatizable if C = Mod(σ) for some sentence σ.

A finitely axiomatizable class is also called an . A general ax- iomatizable class is also called an elementary class in the wider sense.

Remark. Since Mod(σ1,...,σn)= Mod(σ1 ∧ ... ∧ σn), any class that is - atizable by finitely many sentences is already axiomatizable by a single sentence. Thus, no generality is lost in the previous definition by defining an elementary class to be a class axiomatized by a single sentence.

Notice that for any structure A and any sentence σ, the following holds:

σ ∈ Th(A) ⇐⇒ |=A σ ⇐⇒ A ∈ Mod(σ).

Proposition 8. The following hold, for any class C of structures and any set Σ of sentences:

1. Σ ⊆ Th(C ) if and only if C ⊆ Mod(Σ). 2. C ⊆ Mod(Th(C )). 3. Σ ⊆ Th(Mod(Σ)). 4. Th(C )= Th(Mod(Th(C ))). 5. Mod(Σ) = Mod(Th(Mod(Σ))).

6. Mod(Σ) = σ∈Σ Mod(σ). T 7. Th(C )= A∈C Th(A). T Proof. Exercise. 

11