← Back
CSNotes

SET:

In this course, we will use the following definition of a set:

  • A set is an (unordered) collection of objects, called elements or members of the set. The set is said to contain its elements. The notation a∈Sa\in S means that the object a is an element of the set SS. The notation a∉Sa\notin S means that a is NOT an element of set SS
  • An “object” is never specified. The theory that results from this intuitive definition of a set as a collection of objects is called a naïve set theory. This theory leads to logical inconsistencies (paradoxes)

What are these paradoxes?

RUSSELL’S PARADOX:

The whole point of Russell’s paradox is to show that the above theory is flawed.

Before I explain what it is, let us use an infamous paradox that’ll help us understand this more, called the barber’s paradox:

The barber is the “one who shaves all those, AND ONLY THOSE, who do not shave themselves”, the question is here, who shaves the barber?

  1. The barber cannot shave himself, as he only shaves those who do NOT shave themselves. Thus, if he shaves himself, he is no longer the barber he claims to be
  2. But, if the barber does not shave himself, he then fits in the group of people who the barber said he would shave, and thus, the barber must shave himself

This is a paradox, because then who shaves the barber? (before you fucking geniuses say “erm maybe the barber can be a woman” no its a man filled town its an average cs class bro)

Since we never defined what an object is, this becomes a problem. Two properties emerge from naïve set theory:

  1. A set may contain other sets as elements
  2. A set may contain itself as an element (since sets can contain other sets, what is stopping the set to have itself as an element)

What Russell’s Paradox states it that:

  • Let SS be a set
  • This set contains ALL sets of a specific property
  • The property of these elements it that they don’t contain themselves (i.e for all elements a,a∉aa,a\notin a)

So, the question is, does SS contain itself then

Well, if we assume that S∈SS\in S, this contradicts the third statement, therefore, we reach a contradiction. Then, S∉SS\notin S

Well, what if we assume that S∉SS\notin S, but this contradicts the second statement, because it should have ALL sets, therefore, S∈SS\in S

This set stems due to the naïve set theory, which results in a paradox

AXIOMATIC VS. NAIVE:

There is a more proper axiomatic set theory which gets rid of the known paradoxes of naive set theory

However, since:

  • Naïve set theory is enough for everyday use of set theory, it is much more user-friendly than the axiomatic set theory
  • Naïve set theory is a useful stepping stone towards more formal set theories

So, long story, we will be using the naïve set theory although it results in paradoxes.

REPRESENTING SETS:

The elements of a set SS are listed like this: S={0,1,2,3}S = \lbrace 0,1,2,3 \rbrace, since we said sets are unordered, the order does not matter here

It is better practice to NOT list one element more than once in a set

For larger (infinite or finite) sets, we list enough elements to highlight the pattern and then we use “…” to leave the other implied

So, if we had A={a,b,c,…,x,y,z}A = \lbrace a,b,c, \dots, x,y,z \rbrace, although we did not list every single alphabets in there, we can establish that AA is the set of alphabets in the English language

If we had Z={…,−3−2−1,0,1,2,3,… }\mathbb{Z} = \lbrace \dots, -3-2-1,0,1,2,3, \dots \rbrace, you should be able to tell that Z\mathbb{Z} is just the set of integers

There is also the weirdest way in mankind to define sets as well

S={X ∣ X is an integer between 0 and 3 (incl.)}={x ∣ X∈Z and 0≤X≤3}={0,1,2,3}S = \lbrace X \ | \ X \text{ is an integer between 0 and 3 (incl.)} \rbrace = \lbrace x \ | \ X \in \mathbb{Z} \text{ and } 0 \le X \le 3\rbrace = \lbrace 0,1,2,3 \rbrace

We are basically saying SS is the set of the objects xx such that (which is denoted by | ) xx is an integer and 0≤X≤30\leq X\leq 3

The variable xx is just a placeholder which can be changed to any other symbol to avoid clashes

  • A={x ∣ x is a letter of the English alphabet}A = \lbrace x \ | \ x \text{ is a letter of the English alphabet} \rbrace is not ideal, since XX is an actual character in the English alphabet

SET EQUALITY AND SUBSETS:

Two sets AA and BB are equal IF AND ONLY IF they have exactly the same elements:

A=B   ⟺   ∀x(x∈A  ⟺  x∈B)A=B\ \iff \ \forall x(x\in A\iff x\in B)

A set AA is a subset of a set BB (notation: A⊂BA\subset B) IF AND ONLY IF every element of AA is ALSO an element of BB

A⊂B   ⟺   ∀x(x∈A→x∈B)A\subset B\ \iff\ \forall x(x\in A\rightarrow x\in B)

Example:

A={1,2,3}A = \lbrace 1,2,3 \rbrace and B={1,2,3,4,5,6}B = \lbrace 1,2,3,4,5,6 \rbrace, then we can say that AA is a subset of BB as all the elements in A are in B A⊂BA \subset B

{1,4}⊄{1,2,3}\lbrace 1,4 \rbrace \not \subset \lbrace 1,2,3 \rbrace since {1,4}\lbrace 1,4 \rbrace are not in the second set

EMPTY SET AND UNIVERSAL SET:

As the name states, an empty set is a set that contains no elements. It is usually denoted as ∅\emptyset or {}\lbrace \rbrace

However, if you were to do something like {∅}\lbrace \emptyset \rbrace, this is not the same thing, this is saying a set containing an empty set.

The universal set is the set of all objects under consideration. Often denoted UU

When we use a universal set in terms of Venn Diagram, we usually represent it as a rectangle.

SUBSETS AND POWER SETS:

The empty set is a subset of any set, so ∅⊂A\emptyset\subset A

A set is always a subset of itself A⊂AA\subset A

The power set of a set AA is the set of ALL subsets of AA, including ∅\emptyset and AA. It has various notations, such as: P(A)P(A) and 2A2^A

P(A)={S ∣ S⊂A}P(A) = \lbrace S \ | \ S \subset A \rbrace

Examples:

P({0,1})={∅,{0},{1},{0,1}}P(\lbrace 0,1 \rbrace) = \lbrace \emptyset, \lbrace 0 \rbrace, \lbrace 1 \rbrace, \lbrace 0,1 \rbrace \rbrace

  • The 2A2^A notation should make sense now. We have 2 elements in A, if we do 22=42^2 = 4, which clearly matches our power set. Wow notations (i’m so sleeeep deprived help)

P({0,1,2})={∅,{0},{1},{2},{0,1},{0,2},{1,2},{0,1,2}}P(\lbrace 0,1,2 \rbrace) = \lbrace \emptyset, \lbrace 0 \rbrace, \lbrace 1 \rbrace,\lbrace 2 \rbrace, \lbrace 0,1 \rbrace,\lbrace 0,2 \rbrace,\lbrace 1,2 \rbrace,\lbrace 0,1,2 \rbrace \rbrace

INTERSECTION:

Basically the conjunction of 2 sets. The intersection of 2 sets AA and BB is the set of objects which are elements in both AA and BB (notation: A∩BA\cap B)

A∩B={x ∣ x∈A∧x∈B}A \cap B = \lbrace x \ | \ x \in A \land x \in B \rbrace

Examples:

{0,1,2}∩{1,2,3}={1,2}\lbrace 0,1,2 \rbrace \cap \lbrace 1,2,3 \rbrace = \lbrace 1,2 \rbrace, you only want the elements that are in common between the two sets, so obviously 0 wouldn’t be in there since the second set does not contain 0

{0,1,2}∩{3,4,5}=∅\lbrace 0,1,2 \rbrace \cap \lbrace 3,4,5 \rbrace = \emptyset, since there are no common elements between the two sets, so it is simply the empty set. Sets with empty intersection are said to be disjoint

{x∈N ∣ x odd}∩{x2 ∣ x∈{0,1,2,3}}={x∈N ∣ x odd}∩{0,1,4,9}={1,9}\lbrace x \in \mathbb{N} \ | \ x \text{ odd} \rbrace \cap \lbrace x^2 \ | \ x \in \lbrace 0,1,2,3 \rbrace \rbrace = \lbrace x \in \mathbb{N} \ | \ x \text{ odd} \rbrace \cap \lbrace 0,1,4,9 \rbrace = \lbrace 1,9 \rbrace

So, you want the intersection between xx which is in the set of all natural numbers such that xx is actually odd and x2x^2 such that xx is in the set {0,1,2,3}\lbrace 0,1,2,3 \rbrace. You would need to square the numbers on the right hand side of the intersection, and find the common elements between the two. Hopefully you know what natural numbers are…

PROPERTIES:

If we know that A⊂BA\subset B, then A∩B=AA\cap B=A

  • Take an example to visual this, if we had A={1,2}A = \lbrace 1,2 \rbrace and B={1,2,3}B = \lbrace 1,2,3 \rbrace, it is very obvious that A⊂BA\subset B. Now, if we wanted to find the intersection between the two {1,2}∩{1,2,3}={1,2}\lbrace 1,2 \rbrace \cap \lbrace 1,2,3 \rbrace = \lbrace 1,2 \rbrace which is clearly AA

Now, is this true for the converse? Is it true that if A∩B=AA\cap B = A, then A⊂BA\subset B?

  • Well, naturally, this is also true. Once again, let us take an example. If we had A={1,2}A = \lbrace 1,2 \rbrace and B={1,2,3}B = \lbrace 1,2,3 \rbrace, the intersection would be: {1,2}∩{1,2,3}={1,2}\lbrace 1,2 \rbrace \cap \lbrace 1,2,3 \rbrace = \lbrace 1,2 \rbrace. Then, it is clearly obvious that A⊂BA\subset B

Now is this the correct way for proving theorems? No, but I’m giving an example to make stuff clearer.

UNION:

Basically the disjunction of 2 sets. The union of 2 sets AA and BB is the set of objects which are elements of either AA or of BB (notation: A∪BA\cup B)

A∪B={x ∣ x∈A∨x∈B}A \cup B = \lbrace x \ | \ x \in A \lor x \in B \rbrace

It is important to note, we do not add a duplicate elements when we do the union. This will make more sense in examples

Examples:

{0,1,2}∪{1,2,3}={0,1,2,3}\lbrace 0,1,2 \rbrace \cup \lbrace 1,2,3 \rbrace = \lbrace 0,1,2,3 \rbrace. DO NOT REPEAT THE SAME ELEMENT TWICE.

{0,1,2}∪{4,5,6}={0,1,2,3,4,5,6}\lbrace 0,1,2 \rbrace \cup \lbrace 4,5,6 \rbrace = \lbrace 0,1,2,3,4,5,6 \rbrace

[1,5]∪(2,6]={x∈R ∣ 1≤x≤5 or 2<x≤6}=[1,6][1,5] \cup (2,6] = \lbrace x \in R \ | \ 1 \le x \le 5 \text{ or } 2 \lt x \le 6 \rbrace = [1,6]

  • If this doesn’t make sense, you basically need the union between {1,2,3,4,5}∪{3,4,5,6}={1,2,3,4,5,6}\lbrace 1,2,3,4,5 \rbrace \cup \lbrace 3,4,5,6 \rbrace = \lbrace 1,2,3,4,5,6 \rbrace

PROPERTIES:

If we know that A⊂BA\subset B, then A∪B=BA\cup B=B

  • Okay example time just so this makes things clearer. If we had A={1,2}A = \lbrace 1,2 \rbrace and B={0,1,2,3}B = \lbrace 0,1,2,3 \rbrace, then obviously, we can see that A⊂BA\subset B. Now, if we were to do the union between these two sets: {1,2}∪{0,1,2,3}={0,1,2,3}\lbrace 1,2 \rbrace \cup \lbrace 0,1,2,3 \rbrace = \lbrace 0,1,2,3 \rbrace, which is clearly BB

Now, is this also true for the inverse? Meaning, is it true that if A∪B=BA\cup B=B, then A⊂BA\subset B?

  • Example, once again. If we had A={1,2,3}∪{0,1,2,3,4}={0,1,2,3,4}A=\lbrace1,2,3\rbrace \cup \lbrace 0,1,2,3,4 \rbrace = \lbrace 0,1,2,3,4 \rbrace, we know this is true. Now, is it true that A⊂BA\subset B? Well no shit just look. it is very obvious that A⊂BA\subset B

COMPLEMENT:

Basically elements that are not in a set AA. So, if you are given a universal set UU, the complement of set AA (with respect to UU), is the set of elements of UU that are NOT in AA (notation: ACA^C or Aˉ\bar A)

AC={x[∈U] ∣ x∉A}A^C = \lbrace x \lbrack \in U \rbrack \ | \ x \notin A \rbrace

Examples:

For any universe UU, UC=∅U^C=\emptyset and ∅C=U\emptyset^C=U

In the universe RR of real numbers, [1,5)C={x∈R ∣ ¬(1≤x<5)}={x∈R ∣ x<1∨x≥5}=(−∞,1)∪[5,+∞)\lbrack 1,5)^C = \lbrace x \in R \ | \ \neg(1 \le x \lt 5) \rbrace = \lbrace x \in R \ | \ x \lt 1 \lor x \ge 5 \rbrace =(-\infty, 1) \cup \lbrack 5,+\infty)

For any universe UU and any set A⊂UA\subset U, (AC)C=A(A^C)^C=A, how can we prove this?

  • Let us assume we have an element x∈Ax\in A, if xx is an element in AA, this means xx CANNOT be in ACA^C. So, xx is going to be in the complement of ACA^C
  • x∈A→x∉AC→x∈(AC)Cx\in A\rightarrow x\not\in A^C\rightarrow x\in (A^C)^C, since x∈Ax\in A and x∈(AC)Cx\in (A^C)^C, this means (AC)C=A(A^C)^C=A
  • So, this means x∈A⟷x∉AC⟷x∈(AC)Cx\in A\longleftrightarrow x\not\in A^C\longleftrightarrow x\in(A^C)^C

DIFFERENCE:

Given 2 sets AA and BB, the difference of AA in BB is the set of elements of BB which are NOT in AA (notation: B\A or B−AB\backslash A\text{ or }B-A). It is not necessary that A⊂BA\subset B

{B \ A={x ∣ x∈B∧x∉A}=x∈B ∣ x∉A}}B \ \backslash \ A = \lbrace x \ | \ x \in B \land x \notin A \rbrace = \brace x \in B \ | \ x \notin A \rbrace

Examples:

The difference with respect to the universe is the complement: B\A=B∩ACB\backslash A=B\cap A^C. Let us prove this:

  • Assume element x∈B−Ax\in B-A, this means x∈Bx\in B and x∉Ax\notin A, then, this means that x∈Bx\in B and x∈ACx\in A^C, which can be rewritten as B∩ACB\cap A^C
  • x∈B−A→x∈B∧x∉AC→x∈B∧x∈AC (B∩AC)x\in B-A\rightarrow x\in B\land x\notin A^C\rightarrow x\in B\land x\in A^C \ (B\cap A^C)
  • This can be both ways: x∈B−A⟷x∈B∧x∉AC⟷x∈B∧x∈AC (B∩AC)x\in B-A\longleftrightarrow x\in B\land x\notin A^C\longleftrightarrow x\in B\land x\in A^C \ (B\cap A^C)

{0,1,2,3,4} \ {2,3}={0,1,4}\lbrace 0,1,2,3,4 \rbrace \ \backslash \ \lbrace 2,3 \rbrace = \lbrace 0,1,4 \rbrace, the elements in BB that are NOT in AA

{0,1,2,3,4} \ {5,6,7}={0,1,2,3,4}\lbrace 0,1,2,3,4 \rbrace \ \backslash \ \lbrace 5,6,7 \rbrace = \lbrace 0,1,2,3,4 \rbrace

NOTABLE SET IDENTITIES:

  • Identity laws: A∩U=AA\cap U =A; A∪∅=AA\cup\emptyset=A
  • Domination laws: A∪U=UA\cup U=U; A∩∅=∅A\cap\emptyset =\emptyset
  • Law of disjointness: A∩AC=∅A\cap A^C=\emptyset
  • Law of partition: A∪AC=UA\cup A^C=U
  • Idempotent laws: A∩A=A; A∪A=AA\cap A= A; \ A\cup A= A
  • Complementation laws: (AC)C=A(A^C)^C=A
  • Associative laws: A∩(B∩C)=(A∩B)∩C; A∪(B∪C)=(A∪B)∪CA\cap(B\cap C)=(A\cap B)\cap C; \ A\cup (B \cup C)=(A\cup B)\cup C
  • Commutative laws: A∩B=B∩A; A∪B=B∪AA\cap B= B\cap A;\ A\cup B= B\cup A
  • Distributive laws: A∩(B∪C)=(A∩B)∪(A∩C); A∪(B∩C)=(A∪B)∩(A∪C)A\cap (B\cup C)= (A\cap B)\cup (A\cap C);\ A\cup(B\cap C)=(A\cup B)\cap (A\cup C)
  • De Morgan’s Law: (A∩B)C=AC∪BC; (A∪B)C=AC∩BC(A\cap B)^C=A^C\cup B^C;\ (A\cup B)^C=A^C\cap B^C

If you ever forget, just think of ∩=∧\cap =\land, ∪=∨\cup=\lor, ∅=0\emptyset=0, and U=1U=1

CARTESIAN PRODUCTS:

Let AA and BB be sets. The Cartesian product of AA and BB, denoted by A×BA\times B, is the set of all ordered pairs (a,b)(a,b), where a∈Aa\in A and b∈Bb\in B

A×B={(a,b) ∣ a∈A∧b∈B}A\times B=\lbrace(a,b)\ | \ a\in A\land b\in B\rbrace

Example:

{1,2}×{2,4,5}={(1,2),(1,4),(1,5),(2,2),(2,4),(2,5)}\lbrace1,2\rbrace\times \lbrace2,4,5\rbrace=\lbrace(1,2),(1,4),(1,5),(2,2),(2,4),(2,5)\rbrace

(there is relation here but it makes more sense when we explain functions so wait)

CARDINALITY:

We say that a set if finite if it has nn elements of some natural number nn. Otherwise, we say that the set is infinite.

If you want to dumb it down, this means cardinality is simply the number of elements in the set. It is denoted by the absolute value symbol

Examples:

∣∅∣=0|\emptyset| = 0, ∣{∅}∣=1|\lbrace\emptyset\rbrace| = 1 ∣{0,1,2,3}∣=4|\lbrace0,1,2,3\rbrace| = 4 …\dots and so on

For infinite sets (like all real numbers, all natural numbers, and so on), their cardinality is also infinite. But, there are different types of infinity. We don’t need to know them, but its good to know there are different types

The proper definition of cardinality of infinite sets requires functions, so when we cover functions we will see cardinality again

CARDINALITY OF UNION:

We are often interested in finding the cardinality of a union of two finite sets AA and BB. I hope you know what union means. So, the cardinality of A or B is:

∣A∪B∣=∣A∣+∣B∣−∣A∩B∣| A \cup B | = | A | + | B | - | A \cap B |

Why? I think drawing it out makes a lot of sense:

The reason why we subtract A∩BA\cap B, is because the number of elements A∩BA\cap B is counted twice, once when we are counting AA and another time when we are counting BB

What if we wanted to find the cardinality of union of 3 sets? What would that be? The best way is to draw it out

So, this would be:

∣A∪B∪C∣=∣A∣+∣B∣+∣C∣−∣A∩B∣−∣A∩C∣−∣B∩C∣+∣A∩B∩C∣| A \cup B \cup C | = | A | + | B | + | C | - | A \cap B | - | A \cap C | - | B \cap C | + | A \cap B \cap C |

Why is it like this?

  • When we count the number of elements in AA, we count the number of elements in A∩BA\cap B once
  • When we count the number of elements in BB, we count the number of elements in A∩BA\cap B twice
  • Naturally, in a union, we need to only count the number of elements in A∩BA\cap B once, which is why we need to subtract the number of elements in A∩BA\cap B once
  • Similarly can be said about A∩CA\cap C, when we count AA, the intersection is counted once, when we count CC, the intersection is counted again, so we need to subtract A∩CA\cap C once
  • Also, same said about B∩CB\cap C, when we count BB, the intersection is counted once, when we count CC, the intersection is counted again. So we need to subtract B∩CB\cap C once
  • So, we are naturally counting A∩B∩CA\cap B\cap C 3 times with each time we count A,B,CA,B,C. The problem is, when we subtract A∩C,A∩B,B∩CA\cap C, A\cap B, B\cap C, we are subtracting A∩B∩CA\cap B\cap C 3 TIMES. So, we need to add it back again