MTH 110
Discrete Mathematics I
Review - Relations, Graphs and Functions
c
Peter Danziger
Fall 2020
1
Relations
Definition 1.1. A (binary) relation from a set A to a set B is a subset R
of A × B. The set A is called the domain and B is called the co-domain or
range.
Definition 1.2. Given a binary relation R from A to B the inverse relation,
denoted R−1 , is given by R−1 = {(b, a) ∈ B × A | (a, b) ∈ R}.
Definition 1.3. Given n ∈ Z+ and sets A1 , A2 , . . . , An , an n-ary relation on
A1 , A2 , . . . , An is a subset R of A1 × A2 × . . . × An .
If n = 2 it is called a binary relation. If n = 3 it is called a ternary relation.
If n = 4 it is called a quaternary relation.
Definition 1.4. Given a binary relation, R, on a set A:
• R is called Reflexive if ∀ x ∈ A, xRx.
• R is called Symmetric if ∀ x, y ∈ A, xRy ⇒ yRx.
• R is called Transitive if ∀ x, y, z ∈ A, (xRy ∧ yRz) ⇒ xRz.
• A relation which is reflexive, symmetric and transitive is called an
equivalence relation.
1
Definition 1.5. Given an Equivalence relation R on a set A, for each a ∈ A
we define the equivalence class of a, denoted [a], to be the set of things related
to a.
[a] = {x ∈ A | xRa}.
2
Graphs
Definition 2.1.
• A graph is a pair (V, E), where V is a set of points (also called vertices),
and E is a set of edges.
• Each edge e ∈ E is associated with a pair of points from V . If u and
v are associated with the edge e they are called the endpoints of e, we
often write u v or {u, v} to represent the edge e.
Informally a graph is a set of points joined by lines.
Example 2.2.
v1 t
tv2
@
@
v4 t
@
@tv3
V = {v1 , v2 , v3 , v4 }, E = {{v3 , v4 }, {v2 , v3 }, {v1 , v3 }}
• Two verticies are adjacent if they are both the endpoints of the same
edge.
• An edge is said to be incident on each of its endpoints.
• A graph with no verticies is called empty, otherwise it is called nonempty.
• A vertex which is not the endpoint of aany edge is called an isolated
vertex.
• A loop is an edge which joins a vertex to itself (i.e. e = {v1 , v1 }).
• Two edges with the same set of endpoints are said to be parallel. (i.e.
e1 = {v1 , v2 }, e2 = {v1 , v2 }).
• A graph with no loops or parallel edges is called simple.
2
Definition 2.3. The complete graph on n vertices, Kn is the simple graph
on n vertices, in which every vertex is adjacent to every other.
Definition 2.4. A graph G = (V, E) is bipartite if there is a partition of the
vertex set V into two parts, U and W (U ∩ W = ∅ and U ∪ W = V ) such
that every edge x y ∈ E has x ∈ U and y ∈ W .
Definition 2.5. The Complete Bipartite graph on nm verticies, Kn,m is
a bipartite graph with one part of n verticies, X say, and one part of m
verticies, Y say, and every vertex of X is adjacent to every vertex of Y .
• The degree of a vertex v in a graph G is the number of edges incident
with v.
We denote the degree of a vertex v by deg(v).
• The total degree of a graph G is the sum of the degrees of all of its
vertices.
X
TD(G) =
deg(x).
x∈V (G)
Definition 2.6. Given a graph G the degree sequence of G is the sequence
of degrees of the vertices of G, usually in ascending order.
So, if V = {x1 , x2 , . . . , xn }, the degree sequence is the (finite) sequence di =
deg(xi ).
Theorem 2.7. The total degree of a graph G = (V, E) is twice the number
of edges. ie.
X
deg(v) = 2|E|.
v∈V
Corollary 2.8. The total degree of a graph is even.
Corollary 2.9. In any graph G, there are an even number of vertices of odd
degree.
3
3
Partial Relations
Definition 3.1. A relation R on a set A is called Antisymmetric if and only
if
∀a, b ∈ A, aRb ∧ bRa ⇒ a = b
Definition 3.2. Given a binary relation, R, on a set A, R is called a partial
order if it is reflexive, antisymmetric and transitive.
Definition 3.3. Given a partial order R on a set A.
• For any pair of elements a, b ∈ A they are called comparable if either
aRb or bRa; otherwise they are called noncomparable.
• If R is a partial order and every pair of elements are comparable, then
R is called a total order.
• A subset C ⊆ A is a chain if every pair of elements of C are comparable.
• The length of a chain is one less than the number of elements of the
chain.
Definition 3.4. Given a partial order R on a set A.
• If a, b ∈ A and a is related to b, (so aRb) we say a precedes b and write
a b.
• An element a ∈ A is called maximal if ∀x ∈ A, either x a or x and
a are not comparable.
• An element a ∈ A is called a greatest element (or a maximum) if
∀x ∈ A, x a.
• An element a ∈ A is called minimal if ∀x ∈ A, aRx (a x). or x and
a are not comparable.
• An element a ∈ A is called a least element (or minimum) if ∀x ∈ A, a x.
Definition 3.5. Suppose that R is a partial order relation on a set A. In
order to obtain a Hasse diagram for R, we start with the directed graph for
R and
4
• remove loops at all vertices,
• remove all arrows whose existence is implied by transitivity,
• place vertices so that all arrows point upward,
• remove the direction arrows on all edges.
4
Functions
Definition 4.1. A binary relation from A to B is called a function if for
every element a ∈ A there is a unique element b ∈ B such that aRb.
Functions
A
B
A
B
A
B
Not Functions
A
B
Notation 4.2.
• Given a function, f , from A to B, we write f : A → B.
5
• Given a ∈ A we denote the unique element of B which a is mapped to
by f (a). ie. f (a) is the unique element of B such that a R f (a).
The definition of function says two things:
1. (Existence) ∀ a ∈ A, ∃ b ∈ B such that aRb.
each x ∈ A.
i.e. f (x) is defined for
2. (Uniqueness) ∀a ∈ A, b, c ∈ B, (aRb ∧ aRc) ⇒ b = c.
unique.
i.e. f (x) is
To prove that a relation is a function we must prove 1 and 2 above. To show
that a relation is not a function we must find a counterexample to either 1
or 2 above.
Definition 4.3. Given a function f from A to B (f : A −→ B)
• The domain is all those values x ∈ A where f (x) is defined. dom(f ) =
{a ∈ A | f (x) is defined }.
• The co-domain of f is B.
• The image or range of f is the set of values in y ∈ B for which there is
an a ∈ A such that f (a) = b. im(f ) = {y ∈ B | ∃ x ∈ A such that y =
f (x)}.
• Two functions f and g are equivalent if dom(f ) = dom(g) and ∀x ∈
dom(f ), f (x) = g(x). We write f = g, or f (x) ≡ g(x).
We can also consider inverses of functions. We denote the inverse of a function
f by f −1 .
Definition 4.4. Given a function f : A → B:
• f is called one to one (1-1) or injective if ∀x1 , x2 ∈ A, f (x1 ) = f (x2 ) ⇒
x1 = x2 .
• f is called onto or surjective if ∀y ∈ B, ∃ x ∈ A such that f (x) = y.
• If f is both one to one and onto (injective and surjective) it is called a
one to one correspondence or a bijection.
6
1-1
A
Onto
B
A
Bijection
B
A
B
To show that a function f : A → B is 1-1 Let x1 , x2 ∈ A, with f (x1 ) = f (x2 ).
Show that this implies that x1 = x2 .
To show that a function f : A → B is onto Let y ∈ B. Find an x ∈ A such
that y = f (x).
To show that a function f : A → B is not 1-1 Find x1 , x2 ∈ A (x1 6= x2 )
such that f (x1 ) = f (x2 ).
To show that a function f : A → B is not onto Find y ∈ B such that
6 ∃ x ∈ A with f (x) = y. (≡ ∀x ∈ A, f (x) 6= y.)
Theorem 4.5. If f : X → Y is a bijection, then the inverse of f , f −1 : Y →
X is also a bijection.
Definition 4.6. Let f : A → B be a function, X ⊆ A and Y ⊆ B. The
image of X is defined as
f (X) = {b ∈ B | b = f (a) for some a ∈ X}.
The inverse image of Y is defined as
f −1 (Y ) = {a ∈ A | f (a) ∈ Y }.
7