Discrete Mathematics (II) Spring 2017 Lecture 10: Predicate Logic and Its Language Lecturer: Yi Li 1 Predicates and Quantifiers In this action, we show you why a richer language should be introduced than propositional language, PL in brief. 1.1 Expressive power of PL As we learned in the first half semester, propositional logic can express and, or, not, imply, and if and only if. Consider the following example: Example 1. If Socrates is a man then Socrates is mortal. solution. This is a declarative statement. And we know it is true. It can be divided into two parts or two proposition letters. 1. A: Socrates is a man. 2. B: Socrates is mortal. Then we can represent the previous statement as A B. According to our deduction rules, if A is true, then we know B is true. In the last class, we had learned how to apply proposition logic to find suspect of a murder case. Chip design is based on small part of proposition logic. And we also use proposition logic to prove k-colorable graph, any set is able to be totally ordered, and könig lemma. They are hard to prove in their original domain. But once it is transformed into proposition logic form, it is easy to prove by applying compactness theorem. 1.2 Limits of PL Proposition logic is powerful. However there are some cases which it cannot describe. Let s consider the following example. Example 2. Given two statements: All men are mortal and Socrates is a man. What can we do? Solution. We all know the following statement holding, Socrates is mortal. If they are formalized as two propositions, nothing can be implied. Because we cannot express the relationship between Socrates and all men. It means simple way of proposition logic can not represent this statement. 1
Remark 1. We are wondering why propositional language fails here? 1. There is no relation between P and Q. 2. is/in relationship can not be expressed by PL. 3. Similarly, there are there exists..., all..., among..., and only.... The conclusion is that a richer language other than PL is needed to overwhelm the difficulties just faced. Solution(Continue). However, the statements can be abstracted further like 1. P : All As have property B. 2. Q: C is one of As. Follow this way, we could find a solution. 1.3 Predicates and quantifiers In last section, we still leave some unsolved cases, for example, how to express all. Consider the following example. Example 3. Consider a simple sentence, every student is younger than some instructor. Solution. It is a declarative statement, which can be expressed by a proposition letter, say P. Remark 2. However, the statement can not be expressed clearly by just a proposition. 1. It means being a students, being a instructor and being younger than somebody else. 2. P fails to reflect the finer logic structure of it. Solution(Continue). Consider a special instance of this statement. Suppose Andy is a student and Paul is a instructor. Let s introduce some predicates,which asserts something has some property. Now we have 1. S(Andy): Andy is a student. 2. I(P aul):paul is an instructor. 3. Y (Andy, P aul): Andy is younger than Paul. With these propositions, we can represent an instance of our statement. 2
Remark 3. Examining the instance and sentence in detail, we worry about: 1. There are many instances. Too many symbols are needed. 2. How about every/all and some? Solution(Continue). We introduce new concepts: 1. Variable, which can represent any students or instructors. 2. Quantifiers: (a) means there is, which is called existential quantifier. (b) means for all, which is called universal quantifiers. Now it can be written as x(s(x) y(i(y) Y (x, y))). As we pointed out in class, this sentence could be interpreted as there is an instructor who is elder than all students. The logic expression should be written as another one, which is left as an exercise. Example 4. Consider this sentence Bobby s father can beat up the father of any other kid on the block. Solution. Here the point is that how to express the connection between child and father. Function is proper than predicate because a child can determine his father. Let 1. K(x): x is a child on the block and b means Bobby. 2. f(x): x s father, 3. B(x, y): x can beat up y, We have x(k(x) ( (x = b) B(f(b), f(x)))). To enhance the expressive power of PL, we introduce the following symbols. predicates variables constants functions universal quantifier:, for all. 3
existential quantifier:, there exists Now, we expand our language as following: Definition 1 (Language). A language L consists of the following disjoint sets of distinct primitive symbols: 1. Variables: x, y, x 0, x 1,..., y 0, y 1,... (an infinite set) 2. Constants: c, d, c 0, d 0,... (any set of them). 3. Connectives:,,,, 4. Quantifiers:, 5. Predicate symbols: P, Q, R, P 1, P 2,... 6. Function symbols: f, g, h, f 0, f 1,... 7. Punctuation: the comma, and (right and left) parentheses ), ( As predicate is the most important one, it is called predicate logic. It is named first order logic together with proposition logic. In the latter, we will show you that proposition logic can be embedded into predicate logic. In another word, proposition logic is a subset of predicate logic. 1.4 Conclusion In this section, we show some limits of PL and introduce some new tools to overwhelm the troubles. Finally, we extend PL to predicated logic to express much finer statement. This is a typical pattern. In practice, we program code based on existing code other than from scratch. For example, we modify existing data structure or inherit a class by introducing new member and methods. It is important don t try to build your own wheels unless there is no choice. 2 Predicate Logic Language In previous section, predicates, variables, constants, functions and quantifiers are introduced to enhance the capability of logic to express much rich sentences. In this lecture, we will discuss the form of predicate logic in the view of point of syntax. 2.1 Term To formalize the examples shown to introduce predicate logic, we define the following definitions. Term includes constant, variable, and function. As function can be nested, a very complicated term could be constructed. Definition 2 (Term). Terms. 4
1. Every variable is a term 2. Every constants symbol is a term. 3. If f is an n-ary function symbol ( n = 1, 2,... ) and t 1,..., t n are terms, then f(t 1,..., t n ) is also a term. Definition 3 (Ground term). Terms with no variables are called variable-free terms or ground terms. Definition 4 (Atomic formula). An atomic formula is an expression of the form R(t 1,..., t n ) where R is an n-ary predicate symbol and t 1,..., t n are terms. Definition 5 (Formula). Formula is recursively defined: 1. Every atomic formula is a formula. 2. If α, β are formulas, then so are (α β), (α β), (α β), ( α), (α β). 3. If v is a variable and α is a formula, then (( v)α) and (( v)α) are also formulas. With predicate logic, many mathematical statement can be formalized. example. Consider the following Example 5. Let the domain consist of all relational numbers Q. Again φ(x, y) = (x < y), f(x, y) = x + y, g(x, y) = x y and a = 0, b = 1, c = 2 are constants. 1. (φ(x, y) φ(y, z)) 2. (( y)(φ(x, y) φ(y, z))) 3. (( x)(φ(x, z) (( y)(φ(x, y) φ(y, z)))) 4. (( x)(( y)(φ(x, y) (φ(x, g(f(x, y), c)) φ(g(f(x, y), c), y))))) 5. φ(y, f(y, y)) 2.2 Formula Formula is a sequence of symbols of predicated language formed following a specific rules. Similar to proposition logic, we here also introduce subformula to further investigate formula. Definition 6 (Subformula). A subformula of a formula φ is a consecutive sequence of symbols from φ which is itself a formula. Consider the following example. Example 6. Given an formula ((( x)(φ(x) ϕ(x, y))) (( z)σ(z))). 1. Is (( x)φ(x)) a subformula? 5
2. Is σ(x) a subformula? 3. (( x)(φ(x) ϕ(x, y))), (( z)σ(z)),φ(x), ϕ(x, y), and σ(z) all are subformulas. Here, we should pay attention to consecutive. Otherwise, we could take some subsequence wrong as a subformula. Obviously, the first one is not a subformula for it is not a consecutive sub-sequence of the given formula. However, the second one is something special, which depends how rigorous you apply definition. Let s consider the following examples. Example 7. Given the following formulas: 1. ((( x)φ(x, y)) (( x)ψ(x))) 2. ((( x)φ(x, y)) ψ(x)) We have observed that some variable x has relation with a quantifier ( x) or ( x). In order to discuss the relation between variables and quantifiers, we have the following definition. Definition 7 (Occurrence). An occurrence of a variable v in a formula φ is bound if there is a subformula ψ of φ containing that occurrence of v such that ψ begins with (( v) or (( v). An occurrence of v in φ is free if it is not bound. Here, we should pay attention to each occurrence in the definition. Definition 8. A variable v is said to occur free in φ if it has at least one free occurrence there. However, if we say a variable is free if it take place free once. Consider the following examples: Example 8. Given a formula: 1. (( y)(( x)φ(x, y)) ψ(x)) It is obvious that x is free for the first occurrence is bound and the second is free. We have some special formulas. Consider the following example. Example 9. Please observe the following formulas: 1. (( y)(( x)φ(x, y)) ( z)ψ(z)) 2. (( x)((( y)r(x, y)) (( y)t (x, y))). 3. φ(c 0, c 1 ) We can find a common feature that there is no free occurrence of any variable. Definition 9. A sentence of predicate logic is a formula with no free occurrences of any variable. 6
In the most of cases, we only discuss sentences. Contrary to sentence, we have another form of special formulas. Definition 10. An open formula is a formula without quantifiers. Consider the following example. Example 10. 1. All atomic formulas: ϕ(x), R(x, y)... 2. (R(x, y) ϕ(x)). 3. R(c 0, c 1 ). In some case, we may substitute a variable with another term. Definition 11 (Substitution(Instantiation)). If φ is a formula and v a variable, we write φ(v) to denote the fact that v occurs free in φ. 1. If t is a term, then φ(t), or if we wish to be more explicit, φ(v/t), is the result of substituting ( or instantiating) t for all free occurrences of v in φ. We call φ(t) an instance of φ. 2. If φ(t) contains no free variables, we call it a ground instance of φ. Consider the following example. Example 11. Given a formula (( x)r(x, y)) (( y)s(x, y)), 1. It is denoted as φ(x, y). 2. φ(x/s, y/t) = (( x)r(x, t)) (( y)s(s, y)). 3. φ(x/c, y/d) = (( x)r(x, d)) (( y)s(c, y)). Generally, we have the following rules. Example 12. The recursive definition of φ(x/t) with substitution t 0. The recursive definition of t 0 to x in t. 1. t is a constant, t[x/t 0 ] = t 2. t is a variable, 3. t = g(t 1, t 2,..., t k ), t[x/t 0 ] = { t 0 if t = x t o.w. (t x) t[x/t 0 ] = g(t 1 [x/t 0 ], t 2 [x/t 0 ],..., t k [x/t 0 ]) 4. φ(x, y) is an atomic formula, φ[x/t 0 ] = φ(t 0, y) 5. φ = ψ, φ[x/t 0 ] = ψ[x/t 0 ] 7
6. φ = φ 1 φ 2, φ[x/t 0 ] = φ 1 [x/t 0 ] φ 2 [x/t 0 ] 7. φ(x, y) = Q z ψ(x, y, z), φ[x/t 0 ] = { φ, x = z Q z (ψ[x/t 0 ]), x z Consider the following substitution. Example 13. Given a formula φ(x) = ( y)(x+y = 0) and s(x) = x+1. Consider the substitution φ(x/s(y)). We just assume that both variables are integers. It is obvious that it is wrong after substitution. However, some substitution is not correct in the point of view of semantic. We have the following definition. Definition 12. If the term t contains an occurrence of some variable x (which is necessarily free in t) we say that t is substitutable for the free variable v in φ(v) if all occurrences of x in t remain free in φ(v/t). Consider the following example. Example 14. Let φ(x) = ((( y)r(x, y)) (( z) Q(x, z))). 1. If t = f(w, u), then we have φ(t) = φ(x/t) = ((( y)r(f(w, u), y)) (( z) Q(f(w, u), z))). 2. If t = g(y, s(y)), it is not substitutable for x in φ(x). Proposition 13. If a term s is an initial segment of a term t, s t, then s = t. Theorem 14 (Unique readability for terms). Every term s is either a variable or constant symbol or of the form f(s 1,..., s n ) in which case f, n and the s i for 1 i n are all unique determined. Proposition 15. If a formula α is an initial segment of a formula γ, α γ, then α = γ. Theorem 16 (Unique readability for formulas). Each formula ϕ is a precisely one of the following forms: an atomic formula, (α β), (α β), (α β), ( α), (α β). Moreover, the relevant components of ϕ as displayed in each of these formula are uniquely determined. 2.3 Formation tree Definition 17. 1. Term formation trees are ordered, finitely branching tree T labeled with terms satisfying the following conditions: (a) The leaves of T are labeled with variables of constant symbols. (b) Each nonleaf node of T is labeled with a term of the form f(t 1,..., t n ). (c) A node of T that is labeled with a term of the form f(t 1,..., t n ) has exactly n immediate successors in the tree. They are labeled in (lexicographic) order with t 1,..., t n. 2. A term formation tree is associated with the term with which its root node is labeled. 8
Proposition 18. Every term t has a unique formation tree associated with it. Proposition 19. The ground terms are those terms whose formation trees have no variables on their leaves. Definition 20. The atomic formula auxiliary formation trees are the labeled, ordered, finitely branching trees of depth one whose root node is labeled with an atomic formula. If the root node of such a tree is labeled with an n-ary relation R(t 1,..., t n ), then it has n immediate successor which are labeled in order with the terms t 1,..., t n. Definition 21. The atomic formula formation trees are the finitely branching, labeled, ordered trees gotten from the auxiliary trees by attaching at each leaf labeled with a term the rest of the formation tree associated with t. Such a tree is associated with the atomic formula with which its root is labeled. Proposition 22. Every atomic formula is associated with a unique formation tree. Definition 23. The formula auxiliary formation trees are the labeled, ordered, binary branching trees T such that 1. The leaves of T are labeled with atomic formulas. 2. If σ is a nonleaf node of T with one immediate successor σ 0 labeled with a formula φ, then σ is labeled with φ, vφ, or vφ for some variable v. 3. If σ is a nonleaf node with two immediate successors, σ 0 and σ 1 labeled with formulas φ and ψ, then σ is labeled with φ ψ, φ ψ, φ ψ, φ ψ. Definition 24. 1. The formula formation trees are the ordered, labeled trees gotten from the auxiliary ones by attaching to each leaf labeled with an atomic formula the rest of its associated formation tree. Each such tree is again associated with the formula with which its root is labeled. 2. The depth of a formula is the depth of the associated auxiliary formation tree. Proposition 25. Every formula is associated with a unique(auxiliary) formation tree. Proposition 26. The subformulas of a formula φ are the labels of the nodes of the auxiliary formation tree associated with φ. Proposition 27. 1. The occurrences of a variable v in a formula φ are in one-one correspondence with the leaves of the associated formation tree that are labeled with v. We may also refer to the appropriate leaf labeled with v as the occurrence of v in φ. 2. An occurrence of the variable v in φ is bound if there is a formula ϕ beginning with (( v) or (( v) which is the label of a node above the corresponding leaf of the formation tree for φ labeled with v. Proposition 28. If φ is a formula and v a variable, then φ(v/t) is the formula associated with the formation tree gotten by replacing each leaf in the tree for φ(v) which is labeled with a free occurrence of v with the formation tree associated with t and propagating this change through the tree. Proposition 29. The term t is substitutable for v in φ(v) if all occurrences of x in t remain free in φ(t), i.e., any leaf in the formation tree for t which is a free occurrence of a variable x remains in every location in which it appears in the formation tree described in Definition 3.8. 9
2.4 Parsing Algorithm With help of formation tree, we could parse a formula in a relative way. As the definition is an expansion of definition of proposition by introducing variable, function, predicates, and quantifiers. Correspondingly, we can also extend parsing algorithm of proposition to recognize a formula in a direct approach. We first introduce a parsing subroutine for a general term and a atomic formula in the same way. And we then extend proposition s parsing algorithm to recognize a general formula, which is left as an exercise. Exercises 1. Translate the following into predicates formulas: (a) Neither a nor b is a member of every set. (b) If horse are animals, then heads of horse are heads of animals. (c) If some trains are late then all trains are late. (d) There is no set of which every set is a member. 2. Assume that we have a language with the following parameters: N, intended to mean is a number ; I, intended to mean is interesting ; <, intended to mean is less than. Give Translate them back to English. 3. Ex 2(c, e, f)/ page 88 4. Ex 3/ page 88 ( x)(n(x) (I(x) ( y)(n(y) (I(y) (x < y))))). 5. Given formulas in Ex 2 (e),(f) on page 88. Which occurrences of variables are free? Which are bound? 6. Ex 5(b, c)/ page 88. 7. Ex 2(d, e)/ page 94. 8. Ex 13/ page 95. 9. Design an algorithm to make a substitution. 10. Augment parsing algorithm for proposition logic to recognize a formula of predicate logic. Here, we assume that predicates, functions, variables, and constants are represented by a single symbol. 10