CS 173 Lecture 8: Set Theory (I)
Total Page:16
File Type:pdf, Size:1020Kb
CS 173 Lecture 8: Set Theory (I) Jos´eMeseguer University of Illinois at Urbana-Champaign 1 Preliminary Notions about Sets Intuitively, A set is an unordered collection of objects Given any set, say A, the objects belonging to it are called its elements. The property of an object a being an element of set A is written a P A. Such a property is called set membership, and the simbol P is called the membership predicate. We read a P A as \a belongs to A" or \a in A" or \a is an element of A." Objects Acceptable as Set Elements. Any precisely specified object can be an element of a set. For example, objects such as: { any number is N, Z, Q, or R { a truth value like T or F { any symbol such as an ASCII character, or a standard alphabet letter, or a Greek letter, or a Hebrew letter { any data structure such as, for example, a pair like p2; 3{17q, a triple like pa; b; cq, or an n-tuple like pa1; : : : ; anq { any set 1 is also an object that can be an element of another set. can all be elements of sets. The only general requirements about such objects are: 1. any object should be precisely specified 2. equality between such objects should also be precisely specified. Examples: 1{2 “ 2{4, a “ b, p1{2; 2{10q “ p2{4; 1{5q, a “ pa; 7q. Only Elements Matter. As we shall see, A set A is completely determined by its elements. 1 For set theory buffs: objects that are not sets are technically called urelements, coming from the German for \primitive elements." It turns out that it is possible to do all of set theory without using any such urelements, so that sets are the only objects used: amazingly enough, everything can be built up as a set, literally out of nothing, i.e., out of the empty set H. However, it is more convenient to allow objects we already know, like letters or numbers, as \urelements" instead of encoding them as sets built up from the empty set. 2 J. Meseguer Nothing else matters about A, except which are its elements. This will allow us to precisely define any set of interest by just: { giving it a name or a precise notation, say, FOO, and { precisely specifying its elements, say, x P FOO, by giving a FOL formula 'pxq whose only free variable is x (or with no free variables) such that: x P FOO ô 'pxq: We call such a definition a definitional equivalence, and indicate this by marking ô as ôdef . Let us see this method of defining sets in action by seeing how the empty set and finite sets can be so defined. 2 The Empty Set and Finite Sets The empty set, denoted H, is the set that has no elements (the empty collec- tion of objects). A better, more sugestive notation for H might be tu, because it graphically indicates that, as Gertrude Stein said of her former home in Oakland, California, where she grew up: There is no there there. However, the H notation has prevailed and it is the one we shall use. We can precisely define H by formally specifying its elements as follows: x P H ôdef F Finite Sets. Given any objects a1; : : : ; an we can define the finite set having them as elements, denoted ta1; : : : ; anu, by means of the definitional equivalence: x P ta1; : : : ; anu ôdef x “ a1 _ ::: _ x “ an 3 Subsets, Set Containment and Set Equality Set Containment. We say that a set A is a subset of a set B, or that A is contained in B, or that B contains A, denoted A Ď B, if and only if every element of A is an element of B. Therefore, we can define the property A Ď B by the definitional equivalence: A Ď B ôdef @x P Apx P Bq Note that for any set B we always have HĎ B, because the formula @x P Hpx P Bq is true vacously, since H has no elements. The notation tu for H makes this intuitively clear, since in that notation, say, H Ď ta1; : : : ; anu becomes tu Ď ta1; : : : ; anu. Set Equality. As already mentioned, the only thing that matters about a set A is which are its elements. This exactly means that: Set Theory (I) 3 Two sets are equal if and only if they have the same elements. Set containment then gives as a very easy way of formally defining set equality by means of the definitional equivalence: A “ B ôdef A Ď B ^ B Ď A: This gives us a general method to prove that two sets A and B are equal. We just have to: { assuming x P A, prove that x P B, and { assuming x P B, prove that x P A. Sometimes we can prove A “ B in an even simpler way by just proving the equivalence: x P A ô x P B often by stringing out a chain of simpler equivalences that begin with x P A and end with x P B, or the other way round. Strict Containment. We say that a set A is a strict (or proper) subset of a set B, or that A is strictly (or properly) contained in B, or that B strictly (or properly) contains A, denoted A Ă B, if and only if, by defintion, A Ă B ôdef A Ď B ^ B Ę A where B Ę A abbreviates pB Ď Aq. Or we can give the alternative but logically equivalent definition: A Ă B ôdef A Ď B ^ B “ A: Order and Repetition of Elements do not Matter. This follows imme- diately from the definition of set equality A “ B as A Ď B ^ B Ď A. For example, t7; 3; 3; 7; 2; 2; 1u “ t1; 2; 3; 7u because: t7; 3; 3; 7; 2; 2; 1u Ď t1; 2; 3; 7u and t1; 2; 3; 7u Ď t7; 3; 3; 7; 2; 2; 1u: Singleton Sets. A set A is called a singleton set if and only if it has a single element. We can therefore define: A singleton ôdef A “ H ^ @x; y P Apx “ yq: Cardinality of Finite Sets. Given a finite set A, its cardinality, denoted |A| is the number of different elements belonging to it. That is, |H| “ 0, and |ta1; : : : ; anu| “ n if and only if i “ j ñ ai “ aj, 1 ¤ i ă j ¤ n. 4 J. Meseguer 4 Nested Sets Recall that in Section 1 it was pointed out that Any set is also an object that can be an element of another set. This exactly means that we can have nested sets such as, for example, ta; t7; 1uu, tttHuuu, and t3; a; td; cu; Hu. As pointed out in the slides for this lecture and illustrated there with examples, the best way of thinking about any set ta1; : : : ; anu is as a box (indicated in ta1; : : : ; anu by the curly braces), so that when we open it we find inside whatever its element a1; : : : ; an are. That is why the notation tu would have been such a great notation for the empty set H, since it helps us think of H as an empty box. The elements a1; : : : ; an of a set ta1; : : : ; anu may sometimes be objects that are not sets, like 3 and a in t3; a; td; cu; Hu, or they may be other sets, like td; cu and H in t3; a; td; cu; Hu. But if we think of sets as boxes, then the inner boxes td; cu and H inside t3; a; td; cu; Hu should be regarded as as yet unopened, i.e., as black boxes for the time being (although we still need to know if any such inner boxes are repeated, to avoid counting them more than once). Another way of saying the same thing slightly differently is to obseve that the key thing to keep clearly in mind about such nested sets to avoid getting confused is to identify which are the elements of each such nested set. This is not hard at all to do. As always, just apply the definition! which is this case is: x P ta1; : : : ; anu ôdef x “ a1 _ ::: _ x “ an: Applying such a definition to, for example, t3; a; td; cu; Hu, we get: x P t3; a; td; cu; Hu ôdef x “ 3 _ x “ a _ x “ td; cu _ x “H: Therefore, |t3; a; td; cu; Hu| “ 4. More examples (with pictures) are given in the slides for this lecture. 5 Defining Infinite Sets A set A is infinite if it is not finite. That is, A is infinite if and only if for any finite set F we have A “ F . The simplest possible infinite set is the set of natural numbers: N “ t0; 1; 2; : : : ; n; : : :u Likewise, Z, Q and R are infinite sets. Degrees of Infinity. Infinite sets do not all have the same \degree of infinity." In fact, Some sets (also infinite ones) are bigger than others. Set Theory (I) 5 Infinite sets that have the same degree of infinity than N are called countable. This means that we can count all their elements. Z, for example, is countable: we can use even numbers to count the positive integers, and odd numbers to count the negative integers. As shown in the slides for this lecture, amazingly enough, the rationals Q are also countable.