1. What is a set

What is a set?

Set

A set is a collection of things, any things, called its elements.

Link to original

If is a set and is an element in , then . If is not an element in , then . If both and , then .

To describe a set:

  • We can explicitly name its elements.

    We can form the set by collecting three things:

    Minecraft, League, ETS2

    Any set defined this way is denoted by listing its elements, separated by commands, surrounded by braces:

  • Anything can be an element of a set.

    A set can be an element of another set.

    For example, the set has two elements:

    • One element is .
    • The other element is the set .

    In this case we can write and .

Important Features of Sets

The only thing we consider is what is in and isn’t in the set.

  • Repeated occurrences don’t matter and describe the same set. It is more ergonomic to only display each once.

  • Order of listing doesn’t matter and describe the same set.

Special sets

Empty set

An empty set is a set with no elements, it is denoted by $\{\}$ or more commonly referred to by the symbol $\boxed \emptyset$.

The empty set has no elements so no matter what denotes, .

Although, an empty set can be an element of another set, or .

Link to original

Singleton

A singleton is any set with only one element. For example, $\{a\}$ and $\{Monday\}$ are both singletons.

Link to original

Equality of sets

Two sets are equal if they contain the same elements.

We can denote this by . If two sets are not equal, we write .

Link to original

2. Describing sets by properties

Describing sets by properties

Finite set

A finite set is a set that has a finite number of elements. We can informally define it as a set which one could count and finish counting.

Link to original

Infinite set

An infinite set is a set which is not a [[Finite set|finite set]], there is no definitive end.

Examples include:

  • Set of all integers

    is the set of all integers.

    Link to original
  • Set of natural numbers

    is the set of all natural numbers.

    Link to original
  • Set of positive natural numbers

    is the set of all positive natural numbers, or otherwise all positive integers.

    Link to original
  • Set of rational numbers

    is the set of rational numbers, any number that can be expressed as $\frac{m}{n}$ for some integers $m$ and $n \ne 0$.

    Link to original
  • Set of real numbers

    is the set of real numbers, which includes all rational and irrational numbers.

    Link to original
  • Set of positive real numbers

    is the set of positive real numbers.

    Link to original
Link to original

Set builder notation

Describing a set by listing is not ideal, we can instead describe a property that the elements of the set satisfy.

If is a property, then the set whose elements hold this property is denoted by:

is the set of all such that has property .

If we know that all elements in come from a larger set :

For example, let be the set of all odd integers, we can describe this in a number of different ways:

Link to original

4. Describing sets by recursion

Describing sets by recursion

Recursive set description

A recursive description of a set consists of three steps: ?

  • Basis step: Specify one or more elements of .
  • Recursive step: Give one or more rules to construct new elements of from existing elements of .
  • Exlusion rule: State that consists only of the elements that are specified by the basis step, or generated by successive applications of the recursive step. Nothing else is in the . (This step is usually assumed rather than explicitly stated)
Link to original

title: Example 1
The set $\mathbb N$ of natural numbers can be defined recursively:
- **Basis step**: $0 \in \mathbb N$
- **Recursive step**: If $n \in \mathbb N$ then $n + 1 \in \mathbb N$
 
Eventually, by this rule, we will find each and every number in the set.
title: Example 2
The set $\text{Odd}$ of odd numbers can be defined recursively:
- **Basis step**: $813 \in \mathbb N$
- **Recursive step**: If $n \in \text{Odd}$ then $n + 2 \in \text{Odd}$ and $n - 2 \in \text{Odd}$
title: Example 3
The set $A = \{ 3k + 1 | k \in \mathbb N \}$ can be defined recursively:
- **Basis step**: $1 \in A$
- **Recursive step**: If $x \in A$ then $x + 3 \in A$
 
This is processed as so:
- $k = 0 \rightarrow 1 \in A$
- $k = 1 \rightarrow 4 \in A$
- $k = 2 \rightarrow 7 \in A$
title: Example 4
The set $F$ of all formulas of propositional logic can be defined recursively:
- **Basis step**: every propositional variable is in $F$
- **Recursive step**: If $p \in F$ and $q \in F$, then $(\neg p) \in F$, $(p \land q) \in F$, $(p \lor q) \in F$, $(p \rightarrow q) \in F$ and $(p \iff q) \in F$.
Link to original

5. Subsets

Subsets

Subset

A set is a subset of a set if every element of $B$ is also an element of $A$. Notation is $\boxed{B \subseteq A}$.

Venn diagram of
Link to original

For example:

We always have, for every set : and

Proper subset

is a proper subset of , , if $B$ is a subset of $A$ and there is some element in $A$ that is not in $B$. Essentially, $B \subset A$ if $B \subseteq A$ but $B \neq A$.

Link to original

title: Example 1
Let $A = \{ x | x \text{ is a prime number and } 42 \leq x \leq 51 \}$.
Let $B = \{ x | x = 4k + 3 \text{ and } k \in \mathbb N \}$.
 
**Show that $A \subseteq B$.**
We need to show that every element in $A$ is also in $B$.
Prove that $\forall x(x \in A \rightarrow x \in B)$
 
Take an **arbitrary** $x \in A$, then $x$ is a prime number and $42 \leq x \leq 51$,
so we either have $x = 43$ or $x = 47$.
 
- We can have $43 = 4 \times 10 + 3$, so $k = 10$ shows that $43 \in B$.
- We can have $47 = 4 \times 11 + 3$, so $k = 11$ shows that $47 \in B$.
 
$\therefore A \subseteq B$
title: Example 2
Using $A$ and $B$ from above.
 
**Show that $A \subset B$.**
We know that $A \subseteq B$, so we just need to find an element $x \in B$ that $x \notin A$.
For example, $x = 3$:
- As $0 \in \mathbb N$ and $3 = 4 \times 0 + 3$, we have $3 \in B$.
- Although $42 \nleq 3$, so we have $3 \notin A$.
 
$\therefore A \subset B$
title: Example 3
Let $A = \{ 3k + 1 | k \in \mathbb N \}$.
Let $B = \{ 4k + 1 | k \in \mathbb N \}$.
 
**Show that $A \nsubseteq B$.** ($A$ is not a subset of $B$)
Prove that $\neg \forall x (x \in A \rightarrow x \in B)$
 
We need to find a counterxample: an element $x \in A$ such that $x \notin B$.
For example, $x = 4$:
- $4 = 3 \times 1 + 1$ so $k = 1$ shows $4 \in A$.
- We need to show that $4 \notin B$, that is, there is no $k \in \mathbb N$ such that $4 = 4k + 1$.
  If $k = 0$, then $4k + 1 = 4 \times 0 + 1 = 1 \neq 4$.
  If $k \geq 1$, then $4k + 1 \geq 4 \times 1 + 1 = 5 \ge 4$.
  So it is not possible to fina a $k \in \mathbb N$ such that $4 = 4k + 1$, and so $4 \notin B$.
 
$\therefore A \nsubseteq B$
Link to original

6. Equality of sets, powersets

Equality of sets

How to prove or

means that the sets and have the same elements. This is the statement of the form .

If we need to show that then:

  • We need to show both and .

If the task is to show that then:

  • We either need to find an element in that is not in or an element in that is not in .

Powersets

Power set

The power set, , is the set of all subsets of a set $S$. So $P(S) = \{ A | A \subseteq S \}$.

As every set will always have and , then and will always be true.

Link to original

Examples:

  • We can say , or . But , and .
Link to original

7. Set operations

Set operations

Union

Set operation (Union)

The union of sets and , , is the set $$ A \cup B = \{ x | x \in A \text{ (inclusive)} \text{ or } x \in B \} $$

consists of elements in either or or both.

Venn diagram of

For example, let and . Hence, .

Properties of union

  • Identity law (Sets)

    The identity law is that $A$.

    Link to original
Link to original

Intersection

Set operation (Intersection)

The intersection of sets and , , is the set $$ A \cap B = \{ x | x \in A \text{ and } x \in B \} $$

consists of elements in both and .

Venn diagram of

For example, let B = { 10, 4, 9 }. Hence .

Disjoint

Disjoint sets are sets with no common elements, $A \cap B = \emptyset$.

Link to original

Properties of intersection

  • The domination law states that .
Link to original

Difference / Complement

Set operation (Difference)

The difference of sets and , , is the set $$ A - B = \{ x | x \in A \text{ and } x \notin B \} $$

consists of those elements that are in but not in . This can also be called the complement of with respect to .

Venn diagram of

For example, let and . Hence and .

Properties of complementation

  • Complementation laws (Sets)

    There are complementation laws that say that:

    Link to original
  • De Morgan's law (Sets)

    The De Morgan’s law can be represented in sets as so: ?

    Link to original
Link to original

Absolute complement

Set operation (Absolute complement)

Sometimes we may consider all sets as being subsets of some given universal set, .

Given a universal set and , the complement of , , is the set $$ \begin{aligned} \bar A &= U - A \\ &= \{ x \in U | x \notin A \} \end{aligned} $$

Venn diagram of
Link to original

Common Laws

  • Commutative law (Sets)

    The commutative law says that $B \cup A$ and $A \cap B = B \cap A$.

    Link to original
  • Associative law (Sets)

    The associative law says that and that .

    We can meaningfully write, or .

    Similarly, we can also write, or .

    Link to original
  • Idempotent law (Sets)

    The idempotent law says that $A$ and $A \cap A = A$.

    Link to original
  • Distributive laws (Sets)

    There are two distributive laws: ?

    Link to original
Link to original

8. Two exercises about sets

Two exercises about sets

title: Example 1: Prove that, for any $X$, $Y$ and $Z$, we always have $X \cap (Y \cup Z) = (X \cap Y) \cup (X \cap Z)$.
 
We need to show both:
1. $X \cap (Y \cup Z) \subseteq (X \cap Y) \cup (X \cap Z)$
1. $(X \cap Y) \cup (X \cap Z) \subseteq X \cap (Y \cup Z)$
 
We need to show both of these using no assumptions on the sets and their elements, using only properties of set properties union and intersection.
 
Hence:
1. We need to show every element of $X \cap (Y \cup Z)$ is also an element of $(X \cap Y) \cup (X \cap Z)$.
 
   Take an arbitrary element $x \in X \cap (Y \cup Z)$.
   This element is both $x \in X$ and $x \in Y \cup Z$.
   So the element can either be $x \in X \cap Y$ or $x \in X \cup Z$.
   Hence, $x \in (X \cap Y) \cup (X \cap Z)$.
 
2. We need to show every element of $(X \cap Y) \cup (X \cap Z)$ is also an element of $X \cap (Y \cup Z)$.
 
   Take an arbitrary element $x \in (X \cap Y) \cup (X \cap Z)$.
   This element can either be $x \in X \cap Y$ or $x \in X \cap Z$.
   In both cases, $x \in X$ but it can either be $x \in Y$ or $x \in Z$.
   Hence, $x \in X \cup (Y \cap Z)$.
title: Example 2: Show that there are sets $A$ and $B$ such that $A \cup \bar B \neq \bar A \cup B$.
 
We can have an infinite amount of solutions here, we just need to pick any two partially overlapping sets of numbers.
 
Let the universal set, $U = \{ 1, 2, 3 \}$.
Let $A = \{ 1 \}$ and $B = \{ 2 \}$.
 
Hence:
- $\bar A = \{ 2, 3 \}$
- $\bar B = \{ 1, 3 \}$
- $A \cup \bar B = \{ 1, 3 \}$
- $\bar A \cup B = \{ 2, 3 \}$
 
Therefore there are sets $A$ and $B$ such that $A \cup \bar B \neq \bar A \cup B$.
Link to original

9. Sequences, Cartesian product of sets

Sequences

Sequence

A sequence is a list of things, taken in a certain order. $$ \begin{array}{c} (1, 2, 3, -3, 8) \\ (\text{Among, Us, Impostor}) \end{array} $$

Unlike sets, they are instead denoted using brackets instead of braces.

Important features of sequences: ?

  • Order of list matters. and are different sequences.
  • Repeated occurrences matter. and are different sequences.
Link to original

Tuple

A tuple is a finite [[Sequence|sequence]].

Two tuples are equal if they have the same length and their corresponding elements are the same:

Link to original

k-Tuple

A is a sequence with $k$ elements, the number $k$ is called the length of the tuple.

Ordered pair

An ordered pair is another name for a $2\text{-tuple}$, $$ \boxed{(a, b) = (c, d)} \text{ means that } a = c \text{ and } b = d $$

Link to original

Link to original

Cartesian product of sets

Cartesian product of sets

The Cartesian product of sets and is the set $$ A \times B = \{ (x, y) | x \in A \text{ and } y \in B \} $$

consists of ordered pairs where and .

For example, let and . Hence, .

Generic Format

The Cartesian product of sets is the set $$ A_1 \times A_2 \times ... \times A_k = \{ (x_1, x_2, ..., x_k) | x_i \in A \text{ for } i = 1, 2, ..., k \} $$

consists of those where

Link to original

Link to original

10. Relations

Relations

Binary relation

Binary relation

For sets and , a (binary) relation from to is any subset $R$ of the [[Cartesian product of sets|Cartesian product]] $A \times B$ or otherwise a set consisting of some ordered pairs.

We use notation to denote that , and say that is -related to . If , then we right .

Link to original

For example, let be the set of people, and be the set of Among Us crewmates. Define a relation by taking

If I am suspicious of Red but think Blue is a crewmate, then

This can also be written as

Relations on a set

Relation on a set

A relation from a set $A$ to $A$ itself is called a relation on .

It can also be said that:

  • a relation on a set is a subset of
  • a relation on a set is a set consisting some ordered pairs of elements from
Link to original

For example, let be the set of all people in the class.

Will is 180cm tall and likes Jill who is 165cm. But Jill does not like Will. Hence, , , and .

Relations on the set of integers

  • ‘smaller than’:
    • is smaller than , so or more commonly
    • is not smaller than so or more commonly
  • ‘smaller than or equal to’:
  • ‘divisibility’:
Link to original

11. Representing relations

Representing relations

Let and take the following relation on :

can be represented by a directed graph:

digraph G {
  1->1,2,3,4
  2->1,2,4
  3->3
}

Alternatively we can use a 0-1 matrix:

Link to original

12-15,17. Properties of relations

Properties of relations

Reflexive relations

Reflexive relation

A relation on a set is called a reflexive, if $(a, a) \in R$ for every element $a \in A$, in effect everything loops.

For example:

  • Reflexive: on Each element refers to itself.

    digraph G {
    	1->1
      1->2
      3->1
      2->2
      3->3
    }
  • Reflexive: , , Each and every number is lesser than or equal to, greater than or equal or equal to itself.

  • Reflexive: ‘divisibility’ on Each and every number is divisible by itself.

  • Not reflexive: on Not every element refers to itself.

    digraph G {
    	1->1
      1->2
      3->1
    }
Link to original

Irreflexive relations

Irreflexive relation

A relation on a set is called irreflexive if $(a,a) \notin R$ for every element $a \in A$, in effect there are no loops.

For example:

  • Irreflexive: , , on or on Elements do not refer to themselves.

  • Irreflexive: on

    digraph G {
    	1->2
      1->3
      2->1
      3->2
    }
title: Not all "not reflexive" relations are irreflexive!
**Not irreflexive**: $R_2 = \{ (1,1), (1,2), (3,1) \}$ on $\{ 1,2,3 \}$
Some elements refer to themselves.
 
```graphviz
digraph G {
  1->1
  1->2
  3->1
}
Link to original

Symmetric relations

Symmetric relation

A relation on a set is called symmetric, if for all elements $a, b \in A$, $(b,a) \in R$ whenever $(a, b) \in R$. In effect, all relations must be mirrored.

For example:

  • Symmetric: on All pairs of elements have the same properties in both directions.

    digraph G {
    	1->1
      1->2
      2->1
      2->3
      3->2
      3->3
    }
  • Symmetric: on All pairs of elements have the same properties in both directions.

    digraph G {
    	1->1
      2->2
      3->3
    }
  • Symmetric: on

  • Not symmetric: on Not all pairs of elements have the same properties in both directions.

    digraph G {
    	1->1
      1->2
      2->1
      3->1
      3->3
    }
Link to original

Antisymmetric relations

Antisymmetric relation

A relation on a set is called antisymmetric, if $(a, b)$ and $(b, a)$ cannot both be in $R$ unless $a = b$.

(it also does not mean should be in )

This is also not opposite to symmetric, instead it means that you can go one way but you cannot come back unless if you’re going from an element to itself.

For example:

  • Antisymmetric: , , , on , , or .

  • Antisymmetric: on You can go one way but not the other.

    digraph G {
    	1->1
      1->3
      2->3
      3->3
    }
  • Antisymmetric (also symmetric): on You can go one way but not the other.

    digraph G {
    	1->1
      2->2
      3->3
    }
  • Not antisymmetric: on There are bi-directional paths here.

    digraph G {
      1->1
    	1->2
      2->1
    }
Link to original

Transitive relations

Transitive relation

A relation on a set is called transitive, if the following hold, for all elements : $$ \text{If both } (a, b) \in R \text{ and } (b, c) \in R \text{ then } (a, c) \in R $$

In the directed graph representing , is transitive, if every two-step journey along arrows can be done in one step. For example:

  • The following graphs are not transitive:

    digraph A {
    	x->y
      y->z
      z->w
      x->z
    }
     
    digraph B {
    	x->y
      y->z
      z->w
      x->z
      x->w
    }
  • The following graph is transitive:

    digraph B {
    	x->y
      y->z
      z->w
      x->z
      x->w
      y->w
    }
  • Transitive: , , , on , , , or For example, if then and so on…

  • Transitive: on

    digraph B {
    	1->1
      1->2
      1->3
      2->2
      2->3
      3->3
    }
  • Transitive: on We cannot show it’s not transitive, since we only have one one-step journey.

    digraph B {
      3->4
    }
  • Not transitive: on

    digraph B {
      1->1
      1->2
      2->1
    }
Link to original

Transitive closure

Transitive closure

Given that is a relation on a set . The transitive closure of is the smallest transitive relation on $A$ containing $R$. We denote the transitive closure of $R$ by $\boxed {R^*}$.

If is already transitive, then .

For example, given the following definition of , we find :

digraph A {
	label="R"
	x->y
	y->z
	z->w
	x->z
}
digraph B {
	label="R*"
	x->y
	y->z
	z->w
	x->z
	x->w
	y->w
}

Given , we can define the transitive closure, , recursively: ?

  • Basis step: The pairs in are all in .
  • Recursive step: If and then . We add the missing pairs step by step.

Warshall’s algorithm

Warshall's algorithm

Algorithm

An algorithm is a finite sequence of precise step-by-step instructions.

Link to original

Warshall’s algorithm computes the matrix of the transitive closure of . ?

  • Given a relation on a set with elements, we begin with its matrix.
  • There are rounds. For each, we mutate the matrix. is the matrix of the transitive closure of .
    • 1st rule: never change to
    • 2nd rule: for the round, we select the th row and the th column, we look at all of the values not in this row or column. From the position of the value we are looking at, we check to see if the corresponding cells in the th row and column are , if they are, we change to otherwise we don’t do anything.
Link to original

Example

Let be a relation on .

We first construct our starting matrix.

Round 1.

Round 2.

Round 3.

Round 4.

Hence this is our final relation.

digraph A {
	label = "R"
	a->d
	b->a
	b->c
	c->a
	c->d
	d->c
}
 
digraph B {
	label = "R*"
	a->a
	a->c
	a->d
	b->a
	b->c
	b->d
	c->a
	c->c
	c->d
	d->a
	d->c
	d->d
}
Link to original

Equivalence relation

Equivalence relation

A relation on a set is called an equivalence relation if it is: ?

For example:

  • on any set
  • on
Link to original

Partial Order

Partial order

A relation on a set is called an partial order if it is: ?

For example:

  • , , and ‘divisibility’ on
  • Prove that is a partial order on the power set of a set .
    • is reflexive because for every set .
    • is antisymmetric because if and , then holds.
    • is transitive because if and , then holds.
Link to original

Linear Order

Linear order

A relation on a set is called a linear order if: ?

  • It is also a partial order.
  • For all , either or .

For example:

on on

Graph of less than or equal to on natural numbers

  	graph G {
		2--1
		1--0
	}
Link to original

Graph of greater than or equal to on integer numbers

  	graph G {
		{
			m [label="-1"]
		}
	
  		m--0
		0--1
  	}
Link to original

Example

Let be a set with more than one element. Show that is not a linear order on .

If has more than one element, then there are at least two different elements, say and :

  • so and so
  • so and so
  • Neither or hold as .

So and are two elements in such that either or , so so is not a linear order. (It does not form a line.)

graph G {
	{
		a [label="P(s)"]
		x [label="{x}"]
		y [label="{y}"]
	}
	
	x,y--a
}
Link to original

Link to original

16. Hasse diagrams

Hasse diagrams

If we know that a relation is a partial order, then we can use a simplified representation rather than using a directed graph.

Example Diagram

For example, take the ‘divisibility’ relation on the set .

digraph G {
	{
		a [label="1"]
		b [label="2"]
		c [label="3"]
		d [label="5"]
		e [label="10"]
		f [label="11"]
		g [label="15"]
		h [label="25"]
	}
 
	a->a
	a->b
	a->c
	a->d
	a->e
	a->f
	a->h
	b->b
	b->e
	c->c
	c->g
	d->d
	d->e
	d->g
	d->h
	e->e
	f->f
	g->g
	h->h
}

As partial orders are always reflexive, a loop is always present at every point, so we can remove these loops without losing information:

digraph G {
	{
		a [label="1"]
		b [label="2"]
		c [label="3"]
		d [label="5"]
		e [label="10"]
		f [label="11"]
		g [label="15"]
		h [label="25"]
	}
 
	a->b
	a->c
	a->d
	a->e
	a->f
	a->h
	b->e
	c->g
	d->e
	d->g
	d->h
}

Partial orders are always transitive, so we don’t lose any information by only indicating ‘one-step’ arrows.

digraph G {
	{
		a [label="1"]
		b [label="2"]
		c [label="3"]
		d [label="5"]
		e [label="10"]
		f [label="11"]
		g [label="15"]
		h [label="25"]
	}
 
	a->b
	a->c
	a->d
	a->f
	b->e
	c->g
	d->e
	d->g
	d->h
}

Partial orders are also antisymmetric, which means that between any two points there can only be an arrow one way, not both. We can remove the arrows and ensure everything stems from bottom to top.

graph G {
	rankdir = BT
 
	{
		a [label="1"]
		b [label="2"]
		c [label="3"]
		d [label="5"]
		e [label="10"]
		f [label="11"]
		g [label="15"]
		h [label="25"]
	}
 
	a--b
	a--c
	a--d
	a--f
	b--e
	c--g
	d--e
	d--g
	d--h
} 

Example 2

The Hasse diagram of on the power set of :

graph G {
	{
		e [label="0"]
		x [label="{x}"]
		y [label="{y}"]
		z [label="{z}"]
		a [label="{x,y}"]
		s [label="{y,z}"]
		d [label="{x,z}"]
		f [label="{x,y,z}"]
	}
	
	x,y,z--e
	a--x,y
	s--y,z
	d--x,z
	f--a,s,d
}
Link to original