Describing a set by listing is not ideal, we can instead describe a property that the elements of the set satisfy.
If P is a property, then the set S whose elements hold this property is denoted by:
S={x∣x has property P}={x∣P(x)}
S is the set of all x such that x has property P.
If we know that all elements in S come from a larger set A:
S={x∈A∣x has property P}
For example, let Odd be the set of all odd integers, we can describe this in a number of different ways:
Odd={...,−5,−3,−1,1,3,5,...}={x∣x is an odd integer}={x∈Z∣x is odd}={x∣x=2k+1 for some integer k}={x∣x=2k+1 for some k∈Z}={2k+1∣k is an integer}={2k+1∣k∈Z}Link to original
4. Describing sets by recursion
Describing sets by recursion
Recursive set description
A recursive description of a setS consists of three steps:
?
Basis step: Specify one or more elements of S.
Recursive step: Give one or more rules to construct new elements of S from existing elements of S.
Exlusion rule: State that S 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 S.
(This step is usually assumed rather than explicitly stated)
title: Example 1The 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 2The 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 3The 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 4The 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$.
B is a proper subset of A, B⊂A, 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$.
title: Example 1Let $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 2Using $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 3Let $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$
Sometimes we may consider all sets as being subsets of some given universal set, U.
Given a universal set U and A⊆U, the complement of A, Aˉ, is the set $$ \begin{aligned} \bar A &= U - A \\ &= \{ x \in U | x \notin A \} \end{aligned} $$
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$.
The Cartesian product of sets A and B is the set $$ A \times B = \{ (x, y) | x \in A \text{ and } y \in B \} $$
A×B consists of ordered pairs (x,y) where x∈A and y∈B.
For example, let A={1,2} and B={a,b,c}.
Hence, A×B={(1,a),(2,a),(1,b),(2,b),(1,c),(2,c)}.
Generic Format
The Cartesian product of setsA1,A2,...,Ak 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 \} $$
A1×A2×...×Ak consists of those k-tuples (x1,x2,...,xk) where x1∈A1,x2∈A2,..
For sets A and B, a (binary) relation from A to B 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 aRb to denote that (a,b)∈R, and say that a is R-related to b.
If (a,b)∈/R, then we right aRb.
For example, let A be the set of all people in the class.
R1R2={(u,v)∈A×A∣u likes v}={(u,v)∈A×A∣u is taller than v}
Will is 180cm tall and likes Jill who is 165cm. But Jill does not like Will.
Hence, (Will, Jill)∈R1, (Will, Jill)∈R2, (Jill, Will)∈R1 and (Jill, Will)∈R2.
Relations on the set Z of integers
‘smaller than’:<={(x,y)∈Z×Z∣x is smaller than y}
5 is smaller than 25, so (5,25)∈< or more commonly 5<25
10 is not smaller than 2 so (10,2)∈/< or more commonly 10≮2
‘smaller than or equal to’:≤={(x,y)∈Z×Z∣x is smaller than or equal to y}
A relation R on a set A is called irreflexive if $(a,a) \notin R$ for every element $a \in A$, in effect there are no loops.
For example:
Irreflexive: <, >, = on N or on Z
Elements do not refer to themselves.
Irreflexive: R3={(1,2),(1,3),(2,1),(3,2)} on {1,2,3}
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.```graphvizdigraph G { 1->1 1->2 3->1}
A relation R on a set A 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: R1={(1,1),(1,2),(2,1),(2,3),(3,2),(3,3)} on {1,2,3}
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: R2={(1,1),(2,2),(3,3)} on {1,2,3}
All pairs of elements have the same properties in both directions.
digraph G { 1->1 2->2 3->3}
Symmetric: {(x,y)∈N×N∣x−y is divisible by 3} on N
Not symmetric: R3={(1,1),(1,2),(2,1),(3,1),(3,3)} on {1,2,3}
Not all pairs of elements have the same properties in both directions.
A relation R on a set A is called antisymmetric, if $(a, b)$ and $(b, a)$ cannot both be in $R$ unless $a = b$.
(it also does not mean (a,a) should be in R)
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: <, >, leq, geq on N, Z, Q or R.
Antisymmetric: R1={(1,1),(1,3),(2,3),(3,3)} on {1,2,3}
You can go one way but not the other.
digraph G { 1->1 1->3 2->3 3->3}
Antisymmetric (also symmetric): R2={(1,1),(2,2),(3,3)} on {1,2,3}
You can go one way but not the other.
digraph G { 1->1 2->2 3->3}
Not antisymmetric: R3={(1,1),(1,2),(2,1)} on {1,2}
There are bi-directional paths here.
A relation R on a set A is called transitive, if the following hold, for all elements a,b,c∈A: $$ \text{If both } (a, b) \in R \text{ and } (b, c) \in R \text{ then } (a, c) \in R $$
In the directed graph representing R, R 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 N, Z, Q, or R
For example, if a<b then b<c and so on…
Transitive: R1={(1,1),(1,2),(1,3),(2,2),(2,3),(3,3)} on {1,2,3,4}
digraph B { 1->1 1->2 1->3 2->2 2->3 3->3}
Transitive: R2={(3,4)} on {3,4}
We cannot show it’s not transitive, since we only have one one-step journey.
Given that R is a relation on a set A. The transitive closure of R is the smallest transitive relation on $A$ containing $R$. We denote the transitive closure of $R$ by $\boxed {R^*}$.
If R is already transitive, then R∗=R.
For example, given the following definition of R, we find R∗:
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 R, we can define the transitive closure, R∗, recursively:
?
Basis step: R⊆R∗
The pairs in R are all in R∗.
Recursive step: If (a,b)∈R∗ and (b,c)∈R∗ then (a,c)∈R∗.
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.
Warshall’s algorithm computes the matrix of the transitive closure R∗ of R.
?
Given a relation R on a set A with n elements, we begin with its n×n matrix. M0
There are n rounds.
For each, we mutate the matrix.
M0⇝round 1M1⇝round 2M2⇝round 3...⇝round nMnMn is the matrix of the transitive closure R∗ of R.
1st rule: never change 1 to 0
2nd rule: for the k round, we select the kth row and the kth column, we look at all of the 0 values not in this row or column. From the position of the 0 value we are looking at, we check to see if the corresponding cells in the kth row and column are 1, if they are, we change 0 to 1 otherwise we don’t do anything.
ikth rowjkth column0↓1→1⇝round kikjk111
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 P({x,y,z}) of {x,y,z}:
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}