Relations & Functions
Relations & Functions
◼
When we started to study first order logic and quantification we saw a bit of relations and functions on a set. We actually have a more general notion for these in general. Let us start with Relations
Relations
Relations
Intro and Examples
Intro and Examples
◼
Formally a relation is a tuple where is a set for each and . When the sets are clear by context, we usually just denote the relation by R.
(,,...,,R)
A
1
A
2
A
n
A
i
i∈{1,2,3,...n}
R⊆...=
A
1
A
2
A
n
n
∏
i=1
A
i
◼
For the following assume that
R⊆...
A
1
A
2
A
n
◼
In general if we write
(,...,)∈R
a
1
a
n
R(,...,).
a
1
a
n
◼
We call n the arity of R If n =1 we call R a unary relation, if n = 2 we call R a binary relation.
◼
Sometimes if R is a binary relation we write R instead of . So for example instead of writing we write
a
1
a
2
R(,)
a
1
a
2
<=(3,4)
3<=4
◼
If all are equal to a set A then we sometimes say R is a relation over A.
A
i
◼
Examples:
◼
Even = {n∈: ∃k 2k = n}, a unary relation corresponding to the even numbers in
◼
Disc = , the unit disc. It can be represented as
{(x,y)∈:+<=1}
2
2
x
2
y
Out[]=
◼
Disc(1,0)
◼
Disc(0,0)
◼
Disc(0,1)
◼
Disc(0.5,0.5)
◼
Disc(-1,0)
◼
Disc(-0.5,0.5)
◼
Disc(0.1,0.1), Disc(0.01,0.01), Disc(0.001,0.001))...
◼
D
n
2
cj=k
Out[]=
◼
D
3
D
3
D
3
◼
D
5
◼
Div =
⋃
n∈
D
n
◼
Sum = , partially represented below.
{(x,y,z)∈:x+y=z}
3
Out[]=
◼
Sum(1,1,2)
◼
Sum(3,4.53,7.53)
◼
NK = {(firstName,
lastName)∈=WordsWords:firstNamelastNameisfounderofKibo}
2
Words
a
◼
Leq =
{(n,m)∈:n<=m}
2
◼
Auth = {(x,y)∈ NamesBook Titles: where x is an author of book y}
◼
Desc =
{(x,y)∈:xisy'sdescendant}
2
People
◼
Let X be any set, then Diag =
{(x,x)∈:x=x}
2
X
◼
Let X be any set Subs = {(A,B)∈(X): A⊆B}
◼
Samel = {(x,y) ∈ :xandystartwiththesameletter}
2
Words
◼
Samel(name,number)
◼
Samel(fox,facility)
◼
Almost everything can be represented as a relation, and to some extent Mathematics is the study of relations.
Parts and properties of a Binary Relation
Parts and properties of a Binary Relation
◼
Let R⊆AB be a binary relation, then we have the following:
◼
The Domain of R
Dom(R)={a∈A:Thereisb∈Bwith(a,b)∈R}
◼
So for example,
Dom()={0,1,1,1,2,3}={0,1,2,3}
D
3
◼
Dom(Disc)={x∈:∃y(x^2+y^2)<=1}={x∈:-1<=x<=1}
◼
“J.K. Rowling”∈Dom(Auth)
◼
The Image of R
Img(R)={b∈B:Thereisa∈Awith(a,b)∈R}
◼
Img()={0,1,2,3}
D
3
◼
Img(Disc)={x∈:-1<=x<=1}
◼
“Harry Potter and the prisoner of Azkaban”
∈Img(Auth)
◼
If we consider Dom(R)⋃Img(R) = U then we can interpret R as a relation over U.
◼
We isolate three important properties of binary relations over a set A.
◼
We say that R is reflexive if
{(a,a)∈}⊆R
2
A
◼
Disc is not reflexive because (1,1) is not in Disc
◼
D
n
(n+1,n+1)∉
D
n
◼
Div is reflexive Let n∈. then there is a natural number (in fact n works) where (n,n) so (n,n)∈Div
∈
D
n
◼
We say that R is symmetric if implies that
(a,b)∈R
(b,a)∈R
◼
Disc is symmetric: Let x, y ∈ and assume Disc(x,y). Then +<=1. But this means that +<=1. Then by definition Disc(y,x)
2
x
2
y
2
y
2
x
◼
D
3
D
3
D
3
◼
We say that R is transitive if and implies
(a,b)∈R
(b,c)∈R
(a,c)∈R
◼
Disc is not transitive Because Disc(1,0) and Disc(0,1) but we do not have Disc(1,1)
◼
Leq in is transitive Let n,m,k ∈ such that and . Then we have n.
n<=m
m<=k
<=k
◼
Let X={1,0} and we take (X,X,R) where R = {(0,1),(1,0),(1,1),(0,0)}
◼
Then R is reflexive, symmetric, and transitive
◼
Consider the examples above:
◼
Disc is symmetric and transitive, but not reflexive
◼
D
n
◼
Auth and NK are neither
◼
Desc is transitive but not reflexive or symmetric
◼
Diag, and Samel are all three.
◼
For P. Let a,b,c be words such that aPb, and bPc. So a and b start with the same letter, and b and c start with the same letter. So we can conclude that a and c start with the same letter, so aPc.
Closures
Closures
◼
When we are looking at the properties mentioned before, we can always “extend”the relations to satisfy being either reflexive, symmetric, or transitive, or ay combination of them. Given a relation we define the following
R⊆
2
A
◼
The reflexive closure of R to be the smallest relation (under containment) such that and is reflexive.
R
ref
R⊆
R
ref
R
ref
◼
The symmetric closure of R to be the smallest relation (under containment) such that and is symmetric.
R
sym
R⊆
R
sym
R
sym
◼
The transitive closure of R to be the smallest relation (under containment) such that and is transitive.
R
trans
R⊆
R
trans
R
trans
◼
Notes:
◼
Taking the reflexive closure is equivalent to just adding the “diagonal” to our relation
◼
Examples:
◼
The reflexive closure of the unit disc could be represented as
Out[]=
Equivalence Relations & Partitions
Equivalence Relations & Partitions
◼
We say that a relation is an equivalence relation if it satisfies that is is all three, reflexive, symmetric, and transitive.
◼
Given a set A, a partition of A is a collection of subsets of A that is pairwise disjoint, and whose union is A.
◼
Examples:
◼
A = {1,2,3,4,5,6} a partition of A could be = {{1,2}, {3,4}, {5,6}}
◼
Consider a Partition of could be ={Even, Odd}
◼
Partitions and equivalence relations are closely related. In particular one cannot exist without the other. That is, every equivalence relation gives rise to a partition of a set, and every partition of a set gives rise to an equivalence relation.
◼
Examples:
◼
Examples:
◼
We saw that Samel was an equivalence relation. So for each letter we can group the words that start with that letter and so we naturally get a partition of the set of Words.
Functions
Functions
◼
Common notations include:
◼
In this course we can mostly consider unary functions F:A⟶B
◼
The important condition on a relation to be a function is that every element in the domain is related to a unique element in the codomain.
◼
Examples:
◼
Sum, Diag, NK are examples of functions
Properties of functions
Properties of functions
◼
We say that a function f is injective if f(x)=f(y) x=y. In other words, if (by the contrapositive) different elements map into different images.
◼
We say that a function is bijective if it is both injective and surjective.
◼
Examples
Extra Notes
Extra Notes
◼
Actually for infinite sets we say that they have the same cardinality if there is a bijection from one set to another.
◼
Do the integers and the natural numbers share the same cardinality?
◼
f(0)=0, f(1) = -1, f(2)=1, f(3)=-2, f(4)=2, ... note that f is bijective.
◼
Fact: The Natural numbers and the Real numbers do not have the same cardinality the proof is a diagonalization argument.
Relation Composition
Relation Composition
◼
We can of course then talk about function composition by deriving it from relation composition.