First–Order Logic
Total Page:16
File Type:pdf, Size:1020Kb
(LMCS, p. 317) V.1 First{Order Logic This is the most powerful, most expressive logic that we will examine. Our version of ¯rst-order logic will use the following symbols: ² variables ² connectives (_; ^; !; $; : ) ² function symbols ² relation symbols ² constant symbols ² equality (¼) ² quanti¯ers (8; 9) (LMCS, p. 318) V.2 Formulas for a ¯rst-order language L are de¯ned inductively as follows: ² There are two kinds of atomic formulas: (s ¼ t) , where s and t are terms, and (rt1 ¢ ¢ ¢ tn) , where r is an n{ary relation symbol and t1; ¢ ¢ ¢ ; tn are terms. ² If F is a formula, then so is (: F) . ² If F and G are formulas, then so are (F _ G) , (F ^ G) , (F ! G) , (F $ G) . ² If F is a formula and x is a variable, then (8x F) and (9x F) are formulas. (LMCS, p. 318) V.3 Notational Conventions ² Drop outer parentheses ² Adopt the previous precedence conventions for the propositional connectives. ² Quanti¯ers bind more strongly than any of the connectives. Thus 8y (rxy) _ 9y (rxy) means (8y (rxy)) _ (9y (rxy)) . (LMCS, p. 318) V.4 The subformulas of a formula F : ² The only subformula of an atomic formula F is F itself. ² The subformulas of : F are : F itself and all the subformulas of F. ² The subformulas of F ¤ G are F ¤ G itself and all the subformulas of F and all the subformulas of G: ( ¤ is any of _, ^, !, r $). ² The subformulas of 8x F are 8x F itself and all the subformulas of F. ² The subformulas of 9x F are 9x F itself and all the subformulas of F. (LMCS, p. 318-319) V.5 An occurrence of a variable x in a formula F is: ² bound if the occurrence is in a subformula of the form 8x G or of the form 9x G (such a subformula is called the scope of the quanti¯er that begins the subformula). ² Otherwise the occurrence of the variable is said to be free. ² A formula with no free occurrences of variables is called a sentence. (LMCS, p. 318-319) V.6 Given a bound occurrence of x in F, we say that x is bound by an occurrence of a quanti¯er Q if (i) the occurrence of Q quanti¯es the variable x, and (ii) subject to this constraint the scope of this occurrence of Q is the smallest in which the given occurrence of x occurs. (LMCS, p. 319) V.7 It is easier to explain scope, and quanti¯ers that bind variables, with a diagram: An occurrence of the variable x bound by A E A x ( ( r x y ) ( y (( x ( r z x)) ( r x z))) Scopes of quantifiers are underlined (LMCS, p. 319) V.8 The following ¯gure indicates all the bound and free variables in the previous formula: free occurrences A E A x ( ( r x y ) ( y (( x ( r z x)) ( r x z))) bound occurrences (LMCS, p. 322-323) V.9 Examples b. 2 + 2 < 3 is also an atomic sentence, which says \four is less than three." False in N. c. 8x9y (x < y) says that \for every number there is a larger number." True in N. d. 9y8x (x < y) says that \there is a number that is larger than every other number." False in N. (LMCS, p. 323-324) V.10 f. 8x (0 < x) ! 9y (y ¢ y ¼ x) says that ³ ´ \every positive number is a square." False in N. h. 8x8y (x < y) ! 9z (x < z) ^ (z < y) µ ³ ´¶ says that \if one number is less than another, then there is a number properly between the two." False in N. (LMCS, p. 323-324) V.11 We will use the shorthand notation Fi 1·^i·n to mean the same as the notation F1 ^ ¢ ¢ ¢ ^ Fn: Likewise, we will use the notations Fi 1·_i·n and F1 _ ¢ ¢ ¢ _ Fn: (LMCS, p. 324-325) V.12 English to First-order Given a ¯rst{order formula F(x) we can ¯nd ¯rst{order sentences to say a. There is at least one number such that F(x) is true in N. 9x F(x) b. There are at least two numbers such that F(x) is true in N. 9x9y : (x ¼ y) ^ F(x) ^ F(y) ³ ´ (LMCS, p. 324-325) V.13 c. There are at least n numbers (n ¯xed) such that F(x) is true in N. 9x1 ¢ ¢ ¢ 9xn 1·i<j·n : (xi ¼ xj) ^ 1·i·n F(xi) ³³V ´ ³V ´´ d. There are in¯nitely many numbers that make F(x) true in N. 8x9y (x < y) ^ F(y) ³ ´ e. There is at most one number such that F(x) is true in N. 8x8y (F(x) ^ F(y)) ! (x ¼ y) ³ ´ (LMCS, p. 325) V.14 De¯nable Relations To better understand what we can express with ¯rst{order sentences we need to introduce de¯nable relations. Given a ¯rst{order formula F(x1; : : : ; xk) we say F is \true" at a k{tuple (a1; : : : ; ak) of natural numbers if the expression F(a1; : : : ; ak) is a true statement about the natural numbers. (LMCS, p. 325) V.15 Example Let F(x; y) be the formula x < y. Then F is true at (a; b) i® a is less than b. Example Let F(x; y) be 9z (x ¢ z ¼ y). Then F is true at (a; b) i® a divides b, written ajb. a [Note: Don't confuse ajb with . b The ¯rst is true or false. The second has a value. Check that aj0 for any a, including a = 0.] (LMCS, p. 325) V.16 De¯nition N For F(x1; : : : ; xk) a formula let F be the set of k{tuples (a1; : : : ; ak) of natural numbers for which F(a1; : : : ; ak) is true in N. FN is the relation on N de¯ned by F. De¯nition A k{ary relation r ⊆ N k is de¯nable in N if there is a formula F(x1; : : : ; xk) such that r = FN : (LMCS, p. 325-326) V.17 Example (De¯nable Relations) ² x is an even number is de¯nable in N by 9y (x ¼ y + y) ² x divides y is de¯nable in N by 9z (x ¢ z ¼ y) ² x is prime is de¯nable in N by (1 < x) ^ 8y (yjx) ! (y ¼ 1) _ (y ¼ x) µ ³ ´¶ ² x ´ y modulo n is de¯nable in N by 9z (x ¼ y + n ¢ z) _ (y ¼ x + n ¢ z) ³ ´ (LMCS, p. 326) V.18 We will adopt the following abbreviations: ² xjy for the formula 9z (x ¢ z ¼ y) ² prime(x) for the formula (1 < x) ^ 8y (yjx) ! (y ¼ 1) _ (y ¼ x) : µ ³ ´¶ Note that in the de¯nition of prime(x) we have used the previous abbreviation. To properly write prime(x) as a ¯rst{order formula we need to replace that abbreviation; doing so gives us (1 < x) ^ 8y 9z (y ¢ z ¼ x) ! (y ¼ 1) _ (y ¼ x) µ ³ ´¶ (LMCS, p. 326) V.19 Abbreviations are not a feature of ¯rst{order logic, but rather they are a tool used by people to discuss ¯rst{order logic. Why do we use abbreviations? Without them, writing out the ¯rst{order sentences that we ¯nd interesting would ¯ll up lines with tedious, hard{to{read symbolism. (LMCS, p. 326) V.20 Given: xjy abbreviates 9z (x ¢ z ¼ y . Then (u + 1)j(u ¢ u + 1) is an abbreviation for 9z ((u + 1) ¢ z ¼ u ¢ u + 1) Now let us write out zj2 to obtain 9z (z ¢ z ¼ 1 + 1) Unfortunately, this last formula does not de¯ne the set of elements in N that divide 2. It is a ¯rst{order sentence that is simply false in N|the square root of 2 is not a natural number. (LMCS, p. 326) V.21 We have stumbled onto one of the subtler points of ¯rst{order logic, namely, we must be careful with substitution. The remedy for de¯ning \z divides 2" is to use another formula, like 9w (x ¢ w ¼ y); for \x divides y." (LMCS, p. 326) V.22 We obtain such a formula by simply renaming the bound variable z in the formula for xjy. With this formula we can correctly express \z divides 2" by 9w (z ¢ w ¼ 2). The danger in using abbreviations in ¯rst{order logic is that we forget the names of the bound variables in the abbreviation. (LMCS, p. 327) V.23 Our solution: add a ? to the abbreviation to alert the reader to the necessity for renaming the bound variables that overlap with the variables in the term to be substituted into the abbreviation. For example, prime?(y + z) alerts the reader to the need to change the formula for prime(x), say to (1 < x) ^ 8v (vjx) ! (v ¼ 1) _ (v ¼ x) ; µ ³ ´¶ so that when we substitute y + z for x in the formula, no new occurrence of y or z becomes bound. (LMCS, p. 327) V.24 Thus we could express prime(y + z) by (1 < y + z) ^ 8v (vj?(y + z)) ! (v ¼ 1) _ (v ¼ y + z) : ³ ¡ ¢´ Examples [Expressing statements in ¯rst-order logic.] a. The relation \divides" is transitive. 8x8y8z (xjy) ^ (yj?z) ! (xj?z) µ³ ´ ¶ b. There are an in¯nite number of primes. 8x9y (x < y) ^ prime?(y) ³ ´ (LMCS, p. 327) V.25 d. There are an in¯nite number of pairs of primes that di®er by the number 2. (Twin Prime Conjecture) 8x9y (x < y) ^ prime?(y) ^ prime?(y + 2) ³ ´ e. All even numbers greater than two are the sum of two primes.