Lecture 5: Predicate Calculus ffl Predicate Logic ffl The Language ffl Semantics: Structures 1
Why Predicate Logic? Propositional logic is not powerful enough to express statements such as ffl For every number there is a prime larger than that number. ffl The limit of sin(x)=x as x approaches 0 is 1. ffl The function x 7! x 3 is a bijection. ffl The set of all real numbers is larger than the set of all natural numbers. In order to express such statements we need to enlarge the language of logic a bit. E.g., the first statement has the following structure: for x all there exists y a and x < y y is prime universal quantifier existential quantifier binary relation logical connective unary relation Note that we assume we are dealing with natural numbers. 2
The Language We keep all logical connectives. But we add ffl constants that denote individual objects, ffl variables that range over individual objects, ffl quantifiers that express for all and there exists, ffl function symbols that denote functions, ffl relation symbols that denote relations. Notation: ffl a, b, c, ::: for constants, and x, y, z, ::: for variables, ffl 8 for the universal quantifier, and 9 for the existential quantifier, ffl f, g, h, ::: for function symbols, and R, P, Q, ::: for relation symbols. ffl Always allow = for equality. Last example: 8x9y(R(x; y) ^ P (y)) 3
Example: Arithmetic To express statements in arithmetic, we use the language L(p; t; c 0 ;c 1 ;L)of type (2; 2; 0; 0; 2). ffl binary function symbols p and t (for addition and multiplication) ffl constants c 0 and c 1 (for 0 and 1) a binary relation symbol L (for the less-than relation) ffl Think p of t and as functions taking 2 c inputs, 0 c and 1 as taking no inputs; they all return an element of the domain as output. L takes two inputs, but returns a Boolean value as output. I We always assume that equality = can be used in our language. Now consider formulae such as 8x9y(L(x; y)) 9x8y(x = y _ L(x; y)) How do we make sense out of these? 8x(p(x; c 0 ) = x) 4
Example: Arithmetic (Cont.) We interpret x; y range over natural numbers p; t ordinary addition +, multiplication c 0 ;c 1 the natural numbers 0, 1 L the ordinary less-than relation < Then all these formulae are true. I Induction. Another true formula: 0 ) ^8x(R(x)!R(p(x; c 1 )))! 8xR(x) R(c Here we have added another unary relation R symbol to our language. I A false formula: 8x8y9z(p(x; z) = y) But if we change the variables to range over integers (or rationals, or reals), the last formula would be true! 5
L(p(c 1 ;c 1 );u)^l(c 0 ;x)^l(c 0 ;y)^l(c 0 ;z)! 8x8y8z8u :(p(e(x; u);e(y; u)) = e(z; u)) Example: Arithmetic (Cont.) I Primality. In the next formula, x is a free variable (not quantified over). 1 ;x)^8y; z(x = t(y; z)! x = y _ x = z) L(c If we x replace p(c by ;p(c 1 ;c 1 )) 1 we get a true statement. But if we x replace p(c by ;p(c 1 ;p(c 1 ;c 1 ))) 1 we get a false statement. I An impossibly hard formula. Let s add another binary function to our language: e for exponentiation. True or false? This is Fermat s Last Theorem. 6
Syntax and Semantics Predicate logic is very expressive, but we need to clarify several important items. I First give a precise definition of what a formula in predicate logic is. Same as with programming languages: we have to pin down the syntax exactly. I Then associate a clear definition of truth (usually called validity) with these formulae. Somewhat like the semantics of a programming language. To define validity, we have to define structures, domains over which a formula in predicate logic I can be interpreted. 7
Syntax: Terms and Formulae Every function symbol and relation symbol has a fixed number of arguments, its arity. Terms are defined inductively by Every constant and variable is a term. ffl If f is an n-ary function symbol, and t 1 ;::: ;t n are terms, then f (t 1 ;::: ;t n )is also a term. ffl An atomic formula is an expression of the form 1 ;::: ;t n ) R(t R where is an n-ary relation symbol, t and ;::: ;t n 1 are terms. Lastly, formulae are defined inductively by ffl Every atomic formula is a is a formula. ffl If ' and ψ are formulae, so are (:'), (' ^ ψ), (' _ ψ), and ('! ψ). ffl If ' is a formula and x a variable, then (9x') and (8x') are also formulae. 8
Notation As usual, we omit uneccesary parentheses and write 8x(R(x)! 9y S(x; y)) The intended meaning is: For x,ifx any has property R, then there exists y a such x that y and are related by S. Binary relation and function symbols are often written in infix notation, using standard mathematical symbols. E.g., instead p(x; z) of we might x + write z. One often contracts quantifiers of the same kind into one block. sloppy style 8x8y9z(p(x; z) = y) 8x; y9z(x + z = y) 9
Free Variables A variable that is not in the range of a quantifier is free (as opposed to bound). One often indicates free variables like so: 9x'(x; y) 8y9x'(x; y) only y is free nothing free '(x; y) x and y are free A formula without free variables is closed,orasentence. Let us always avoid clashes between free and bound variables. better: rename bound variable R(x) ^9x8yS(x; y) R(x) ^9z8yS(z; y) Same as in programming languages (global and local variables). 10
Semantics: Structures We need to describe the domain of discourse in predicate logic. I A structure is a set together with a collection of functions and relations on that set. = ha; f 1 ;f 2 ;::: ;R 1 ;R 2 ;:::i A Each function and relation has a fixed arity. A nullary function is just an element of A. A unary function maps element of A to elements of A. A binary function maps pairs of elements of A to elements of A. And so on. Likewise for the relations: A unary relation describes a property of elements of A. A binary relation describes a relationship between pairs of elements of A. I In some sense, mathematics is nothing but the study of various structures. 11
Structures (Cont.) We associate the function and relation symbols in formulae with real functions and relations in a structure (of the same arity). f function symbol ; f A a function in A R function symbol ; R A a relation in A Example: Consider arithmetic: Language L(p; t; c 0 ;c 1 ;L)of type (2; 2; 0; 0; 2). Can interpret I over any structure of (2; 2; 0; 0; type 2). The most important structure for arithmetic is = N ;+; ;0;1;<i N h the set of natural numbers together with the standard operations. So = +, t N =, c N N = 0 p 0, N = c 1 1, =<. L Variables range N over N. 12
Structures (Cont.) Hence, intuitively, N over, the L(c formula ;c 1 0 )is true. As 8x9y(L(x; is y)). But how about the primality formula '(x) L(c 1 ;x)^8y; z(x = t(y; z)! x = y _ x = z) The free variable x does not stand for any particular number, so we can not directly make sense out of this. Could also interpret our formulae over the structure of the real numbers (has same type I 2; 0; 0; 2)): (2; R = h ;+; ;0;1;<i Here, + refers to addition of reals, 0 is the real number zero, and so on. Note that y(l(x; y)! 9z(L(x; z) ^ L(z; y)) 8x; is true over the reals, but not over the natural numbers. On the other '(x) hand, is not interesting over R: there is x no that makes it true (think square root). 13
ffl t = c: then ff(t) = c A The Link: Assignments In propositional logic, we assign a truth value to each propositional variable, and extend the definition of truth value to all formulae. I An assignment (over A) associates variables with elements in A. Given an assignment ff, we can associate an element ff(t) in A with each term t. ffl t = x: then ff(t) = ff(x) ffl t = f (r 1 ;::: ;r n ): then ff(t) = f A (ff(r 1 );::: ;ff(r n )) Example: N,ifff(x) = Over 3, ff(t(x; p(c then ;c 1 ))) = 1 6. But ff(x) = 0 for we ff(t(x; p(c get ;c 1 ))) = 1 0. 14
Definition of Truth Finally, the definition of a truth value ff(') for every formula '. First without quantifiers. ' R(t ;::: ;t n 1 )is an atomic formula: ff(') then is true R iff holds on ff(t A );::: ;ff(t n ) ffl = 1 ψ^χ: then ff(') is true iff both ff(ψ) and ff(χ) are true. = ' ffl ffl ' = ψ _ χ: then ff(') is true iff at least one of ff(ψ) and ff(χ) is true. ffl ' = :ψ: then ff(') is true iff ff(ψ) is false. So far, this is essentially the same as in propositional logic except that we now have atomic formulae instead of propositional variables. Also note that this is a recursive definition, we are really using induction on the size of the formula. 15
Definition of Truth Quantifiers For an assignment ff, let us write ff[x=a] for the assignment that is the same as ff everywhere, except that ff[x=a](x) = a. ' = 9xψ: ffl ff(') Then is true iff there is a an A in such that for the ff assignment = ff[x=a] we have: ff 0 (ψ) is true. 0 ' = 8xψ: ffl ff(') Then is true iff for a all in A, ff assignments = ff[x=a] we have: ff 0 (ψ) is true. 0 Note that ff only needs to be defined on the free variables of ' to produce a value ff('), the values anywhere else do not matter. If ' is a sentence, ff can be totally undefined. 16
Models A formula ' is valid in A under assignment ff, in symbols ff(') iff is true. A ' formula is valid over A, in symbols A j= ff ' iff A j= ff ' for any assignment ff. A is said to be a model for '. A sentence is valid A j= ' iff it is valid over any structure. j= ' A formula is satisfiable iff there is some A structure and some ff assignment such A j= that ff '. In other words, 1 ;::: ;x n '(x 1 ;::: ;x n ) 9x has a model, x where ;::: ;x n 1 are the free variables of '. 17
Isn t this all circular? It looks like we are using for all to define what a universal quantifier means, and there is for existential quantifiers. True, but we are talking about syntactic objects, and define their meaning in terms of structures, which are not syntactic, they are real (in the world of mathematics). Think of this as a program: you can compute the truth value of a formula, as long as you can perform certain operations in the structure (evaluate f A, search over all elements, ::: ) IIf the structure in particular is finite, then we can actually carry out the computations. But over, say, N we cannot in general deal with quantifiers. Consider again the Fermat formula I (in sloppy notation) 8x; y; z; n(n > 2 ^ x; y; z > 0! x n + y n 6= z n ) 18
Valid Sentences Since validity means: holds over all structures one might wonder if there are any interesting valid sentences. Here are some important ones involving quantifiers: 8x8y'(x; y) () 8y8x'(x; y) 9x9y'(x; y) () 9y9x'(x; y) 9x8y'(x; y)! 8y9x'(x; y) Here are some important ones involving equality: 8x(x = x) 8x8y(x = y! y = x) 8x8y8z(x = y ^ y = z! x = z) 8x8y(x = y! (R(x), R(y))) 8x8y(x = y! f (x) = f (y)) 19