<<

CS 173 Lecture 8: 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 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- 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 buffs: objects that are not sets are technically called , 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 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 , Set Containment and Set Equality

Set Containment. We say that a set A is a 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 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 , 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. The sequence counting the positive rationals is shown in a slide; but we can use the same trick as for Z: we can use the even numbers to count the positive rationals, and the odd numbers to count the negative rationals. Instead the real numbers R are not countable. However, amazingly enough R, R2, R3, ..., Rn,... all have the same degree of infinity, which is called the degree of the continuum. The line R is the 1-dimensional continuum, the plane R2 is the 2-dimensional continuum, 3-space R3 is the 3- dimensional continuum, Rn is the n-dimensional continuum. All these continua have the same degree of infinity. The amazing reason why this happens, is that there are curves, called Peano curves (after the Italian mathematician Giuseppe Peano, who also formalized induction), that fill in the whole plane! So we can fill in the 2-dimensional continuum with the 1-dimensional one! And likewise there are Peano curves that fill in Rn for any n. Furthermore, there are degrees of infinity bigger than the continuum. And there is no ceiling! We can always find infinite sets with a bigger degree of infinity than any other infinite sets we have previously considered. The notion of cardinality as a way of measuring the size of a finite set can be extended to infinite sets. Using this notion we can summarize our dicussion as follows:

|N| “ |Z| “ |Q| ă |R| ă |Inf 3| ă |Inf 4| ă ... |Inf n| ă ... where Inf 3, Inf 4,... Inf n,... are infinite sets all bigger than R and each strictly smaller than the next one in the sequence. Set Builder Construction. Obviously, infinite sets have finite subsets that we can define as before, by gathering them in a finite set ta1, . . . , anu. But how can we precisely describe possibly infinite subsets B of a possibly infinite set A? The way to do so is to use the set builder notation. For any set A (finite or infinite) the set tx P A|ϕpxqu also written as tx P A : ϕpxqu where ϕpxq is a FOL formula whose only free variable is x, intuitively describes the subset of A determined by all elements of A that satisfy the property ϕ. Several examples are given in the slides.

The precise formal definition of the set tx P A|ϕpxqu is, as always, given by giving a condition characterizing its elements:

a P tx P A|ϕpxqu ôdef ϕpaq “ T 6 J. Meseguer

More Flexible Set Builder Notation. It is sometimes more convenient to use a variant of the set-builder notation of the form:

texppxq P A|x P B ^ ϕpxqu where exppxq is an expression with single variable x whose result is an element of A, and B is a set over which x ranges. But this is just a useful abbreviation for the standard set builder notation:

ty P A|Dx P Bpy “ exppxq ^ ϕpxqqu where now the formula ψpyq “ Dx P Bpy “ exppxq ^ ϕpxqq has indeed a single free variable, namely y. For example, the set

3 t|m | P N | m P Z ^ 7|mu abbreviates the set

3 tn P N | Dm P Zpn “ |m | ^ 7|mqu.

6 Set , Set Intersection and Set Difference

Intuitively, the set union A Y B is the set obtained by gathering together the elements of A and the elements of B. Likewise, the set intersection A X B is the set obtained by gathering together the elements that are in both A and B. Finally, the set difference A ´ B is the set obtained by eliminating from A all elements that also belong to B. As always, we should avoid any verbal confusions and precisely define any new set construction. We can do so for A Y B, A X B, and A ´ B as follows:

x P pA Y Bq ôdef x P A _ x P B

x P pA X Bq ôdef x P A ^ x P B

x P pA ´ Bq ôdef x P A ^ x R B where x R B abbreviates px P Bq. Relationship with the Set Builder Construction. It follows directly from the above definitions for A Y B, A X B, and A ´ B that we have:

tx P A|ϕpxqu Y tx P A|ψpxqu “ tx P A|ϕpxq _ ψpxqu

tx P A|ϕpxqu X tx P A|ψpxqu “ tx P A|ϕpxq ^ ψpxqu

tx P A|ϕpxqu ´ tx P A|ψpxqu “ tx P A|ϕpxq ^ pψpxqqu. Set Theory (I) 7

6.1 Disjointness and Cardinality Issues Two sets A and B are called mutually disjoint, or just disjoint, if and only if A X B “H. If A and B are finite sets we have:

|A Y B| “ |A| ` |B| ´ |A X B|

|A ´ B| “ |A| ´ |A X B| minp|A|, |B|q ě |A X B| ě 0. The proof for the first equality can be found in the slides for this lecture. The proofs of the second equality and of the third inequality are similar and are left as exercises.

7 The Powerset PpAq

Given any set A, its powerset PpAq is the set of all its subsets. For example, for A “ ta, bu its subsets are: – H – tau – tbu – ta, bu Therefore, Ppta, buq “ tH, tau, tbu, ta, buu. As always, we must precisely define PpAq for any A by precisely specifying its elements. We can do so thus:

X P PpAq ôdef X Ď A.

The slides show in detail the powersets PpAq for sets A of 0,1,2, and 3. In all these cases we have |PpAq| “ 2|A|. This not a fluke coincidence, but the general fact: Theorem. For any finite set A, |PpAq| “ 2|A|. The proof is by induction on n “ |A|. It is left as a very useful exercise. Powersets of Infinite Sets. The slides for this lecture discuss in detail the powersets for PpNq and PpR2q, and sketch what PpR3q should look like. Of course other possible examples to think about are PpZq, which is quite similar to PpNq, and PpRq, which is also interesting, since it relates to one’s experience about sets of points in the real line in calculus.