Sunteți pe pagina 1din 25

Unit 2: Relations, diagraphs and lattices

Product sets and partitions, relations and diagraphs, paths in relations and diagraphs, properties of relations, equivalence
and partially ordered relations, computer representation of relations and diagraphs, manipulation of relations, Transitive
closure and Warshall’s algorithm, Posets and Hasse Diagrams, Lattice.

Product sets and partitions,


Product Sets:

∈ ∈
Let A and B be two nonempty sets. The product set or Cartesian product A x B is the set of all ordered pairs (a,

∈ ∈
b) with a A and b B, that is,
A x B ={(a, b)| a A and b B} .
Example: Let A ={1, 2, 3} and B = {r, s}.
A x B = {1, r), (1, s), (2, r), (2, s), (3, r), (3, s)}.
|A x B| = |A||B|

Example: Let A = B = R. Then A x B = R2.

∈A , k = 1, . . . ,m}
Cartesian Product:
A1 x A2 x … Am ={a1, . . . , am)| ak k

2. Partitions
A partition or a quotient set of a nonempty set A is a collection P of nonempty subsets of A such that

(1) Each element of A belongs to one of the sets of P.


(2) If A1 and A2 are distinct elements of P, then A1 ∩ A2 = φ.
The sets in P are called the blocks or cells of the partition.

Example : Let A = {a, b, c, d, e, f, g, h}. Consider subsets of A:

A1 ={a, b, c, d}, A2 = {a, c, e, f, g, h}, A3 ={a, c, e, g},


A4 = {b, d}, A5 ={f, h}
Then {A1, A2} is not a partition because A1 ∩ A2 = φ.
{A1, A5} is not a partition because e, g ∉ A1 and A5.
{A2, A4} and {A3, A4, A5} are partitions of A.

Relations and diagraphs, Paths in relations and diagraphs,


Relations on a Set

Definition: A relation on a set A is a relation from A to A. In other words, a relation on a set A is a subset of A
X A.

Composite of relations

Definition: Let R be a relation from a set A to a set B and S a relation from B to a set C. The composite of R
and S is the

Page No.1
∈ ∈ ∈ B such that
∈ ∈
relation consisting of the ordered pairs (a,c) where a A and c C, and for which there is a b
(a,b) R and (b,c) S. We denote the composite of R and S by S o R.

Representing binary relations with graphs

• We can graphically represent a binary relation R from A to B as


follows:

Relation Rdiv on A={1,2,3,4}Relation


Rdiv = {(1,1), (1,2), (1,3), (1,4), (2,2), (2,4), (3,3), (4,4)}

Definition: A directed graph or digraph consists of a set of vertices (or nodes) together with a set E of
ordered pairs of elements of V called edges (or arcs). The vertex a is called the initial vertex of the edge (a,b)
and vertex b is the terminal vertex of this edge. An edge of the form (a,a) is called a loop.
Example
• Relation Rdiv ={(1,1), (1,2), (1,3), (1,4), (2,2), (2,4), (3,3), (4,4)}

Page No.2
Powers of R

Definition: Let R be a relation on a set A. The powers Rn, n =


1,2,3,... is defined inductively by

• R1 = R and Rn+1 = Rn o R.

Examples
• R = {(1,2),(2,3),(2,4), (3,3)} is a relation on A = {1,2,3,4}.

R1 = R = {(1,2),(2,3),(2,4), (3,3)}
R2 = {(1,3), (1,4), (2,3), (3,3)}
What does R2 represent Paths of length 2
R 3 = {(1,3), (2,3), (3,3)} path of length 3
R 4 = {(1,3), (2,3), (3,3)}
R k = {(1,3), (2,3), (3,3)} k>3

Powers of R

Examples

• R = {(1,2),(2,3),(2,4), (3,3)} is a relation on A = {1,2,3,4}.

• R1 = R = {(1,2),(2,3),(2,4), (3,3)}
• R 2 = {(1,3), (1,4), (2,3), (3,3)}
• R 3 = {(1,3), (2,3), (3,3)}
• R 4 = {(1,3), (2,3), (3,3)}
• R k = {(1,3), (2,3), (3,3)} k>3

Q.1 Represent each of these relations on {1,2,3} with a matrix (with the elements of this set listed in
increasing order).

Page No.3
Q.2

Page No.4
Q. 3.Let R be the relation represented by the matrix

Find the matrix representing

Q.4Draw the directed graphs representing each of the relations

Page No.5
Q.5. Draw the directed graph that represents the relation {(a,a), (a, b),(b, c), (c, b), (c, d), (d, a), (d, b)} We draw
the directed graph with the vertex set being {a, b, c, d} and an edge from i to j whenever (I, j) is in the relation.

Q.6 List the ordered pairs in the relations represented by the directed graph.

Page No.6
Q.7 List the ordered pairs in the relations represented by the directed graph.

Properties of relations,

1. The Empty Relation between sets X and Y, or on E, is the empty set ∅

2. The Full Relation between sets X and Y is the set X×Y

3. The Identity Relation on set X is the set {(x,x) | x ∈ X}

4. The Inverse Relation R' of a relation R is defined as: R’= {(b,a) | (a,b) ∈R}
Example: If R = {(1, 2), (2,3)} then R’ will be {(2,1), (3,2)}

5. A relation R on set A is called Reflexive if ∀a∈A is related to a (aRa holds).

Example: The relation R = {(a,a), (b,b)} on set X={a,b} is reflexive

Example, if A= {1,2,3,4}, then the relation R1= {(1,1), (2,2), (3,3), (4,4)} in A is reflexive because for x ∈ A,
(x,x) ∈ R1. However, R2= {(1,1), (2,1), (4,4)} is not reflexive since 2 ∈ A, but (2,2) ∉R2.

Every vertex has a self-loop.

“Everyone likes themselves.” Every node in G has a loop.

6. A relation R on set A is called Irreflexive if no a∈A is related to a (aRa does not hold).
Example: The relation R = {(a,b), (b,a)} on set X={a,b} is irreflexive

“No one likes themselves.” There are no loops in G.

7. A relation R on set A is called Symmetric if xRy implies yRx, ∀x∈A and ∀y∈A.

Page No.7
Example: The relation R = {(1, 2), (2, 1), (3, 2), (2, 3)} on set A={1, 2, 3} is symmetric.

A relation R on a set A is called a symmetric relation if (a,b) ∈R ⇒(b,a) ∈R.Thus, R is symmetric if bRa
holds whenever aRb holds.

If there is an edge from one vertex to another, there is an edge in the opposite direction.
“If a likes b, then b likes a.”
8 Antisymmetric: A relation R on a set A such that for all a, b ∈ A, if (a, b) ∈ R and (b, a) ∈ R, then a = b is
called antisymmetric

There is at most one edge between distinct vertices.


“No people like pair of distinct each other.”
There are no loops and there is at most one directed edge between any pair of nodes.

9. Transitive: A relation R on a set A is called transitive if whenever (a,b) ∈ R and (b, c) ∈ R, then (a, c) ∈ R,
for all a, b, c ∈ A. Transitive:

For example, if L is the set of all straight lines in a plane and R is the relation on L defined by ‘x is parallel to y’
then if a is parallel to b and b is parallel to c, then a is parallel to c. Hence R is transitive.

Combining Relations
Since relations from A to B are subsets of A X B, two relations from A to B can be combined in any way two
sets can be combined. Such as union, intersection, and set difference.
Composition

Definition: Let R be a relation from a set A to a set B and S a relation from B to a set C. The composite of R
and S is the relation consisting of ordered pairs (a, c), where a ∈ A, c ∈ C, and for which there exists an element
b ∈ B such that (a, b) ∈ R and (b, c) ∈ S. We denote the composite of R and S by S o R.

Page No.8
Equivalence

A relation is an Equivalence Relation if it is reflexive, symmetric, and transitive.

Example: The relation R = {(1, 1), (2, 2), (3, 3), (1, 2),(2,1), (2,3), (3,2), (1,3), (3,1)} on set A= {1, 2, 3} is an
equivalence relation since it is reflexive, symmetric, and transitive. One of the most trivial examples of an
equivalence relation is that of ‘equality’. For any elements a,b,c in a set A,


(i) a = a, i.e., reflexivity


(ii) a = b b = a, i.e., symmetricity
(iii) a = b and b = c a = c , i.e., transitivity.

Now let us see if ‘xRy iff ’ ‘x ≤ y’ gives an equivalence relation on R.

Page No.9
The power of the concept of equivalence class is that operations can be defined on the equivalence classes using
representatives from each equivalence class. In order for these operations to be well defined it is necessary that
the results of the operations be independent of the class representatives selected.

Equivalence classes of a equivalence relation :


Suppose there is an equivalence relation, R, on a certain set. If a is any particular element of the set, then one
can ask, “What is the set of elements that are R-related to a?” This set is called the equivalence class of a.

When several equivalence relations on a set are under discussion, the notation [a]R is often used to denote the
equivalence class of a under R. The procedural version of this definition is

Let A = {0, 1, 2, 3, 4} and define a relation R on A as follows:


R = {(0, 0), (0, 4), (1, 1), (1, 3), (2, 2), (3, 1), (3, 3), (4, 0), (4, 4)}.
The directed graph for R is as shown below. As can be seen by inspection, R is an equivalence relation on A.
Find the distinct equivalence classes of R.

First find the equivalence class of every element of A. Note that [0] = [4] and [1] = [3]. Thus the distinct
equivalence classes of the relation are {0, 4}, {1, 3}, and {2}.

and partially ordered relations,

In order theory, the concept of partially ordered set is a very useful concept. A set which follows partial order
relation, is known as a partially ordered set. The relation "≤" defined on a set is known as partially ordered
relation and the set is called partially ordered set Partially ordered set is also abbreviated as poset for
convenience. It generalizes and formalizes the concept of ordering or arranging of the elements of a set. A
partially ordered set or a poset is defined as a set along with a binary relation ≤ which satisfies three properties
of sets - reflexivity, antisymmetry and transitivity.

Page No.10
According to more formal definition of partially ordered set :
Poset is an ordered pair of binary relation "≤" defined over a set S, i.e. (≤, S) that satisfies following
properties (Lets say a, b, c ∈ S):
1) Reflexivity: i.e. a ≤ a

2) Antisymmetry: i.e. if a ≤ b and b ≤ a ⇒ a = b

3) Transitivity: i.e. a ≤ b and b ≤ c ⇒a ≤ c.

Strong and Weak Partial Orders A relation R on a set A is a weak partial order if it is transitive,
antisymmetric, and reflexive. The relation is said to be a strong partial order if it is transitive, antisymmetric,
and irreflexive.

Some authors defined partial orders to be what we call weak partial orders, but we’ll use the phrase partial order
to mean either a weak or a strong partial order. The difference between a weak partial order and a strong one
has to do with the reflexivity property: in a weak partial order, every element is related to itself, but in a strong
partial order, no element is related to itself. Otherwise, they are the same in that they are both transitive and
antisymmetric.

Total Orders

A partial order is “partial” because there can be two elements with no relation between them. For example, in
the “divides” partial order on (1,2, …….. 12), there is no relation between 3 and 5 (since neither divides the
other).

Definition :. A total order is a partial order in which every pair of distinct elements is comparable

and Computer representation of relations diagraphs,

The notions of directed graphs, relations, and Boolean matrices are fundamental in computer science and
discrete mathematics. These notions are quite similar or even identical, only the languages are different. In
some cases the language of graph theory is preferable because of its visual nature. The graph theoretic approach
to a problem enables us to think geometrically about the problem. Computers use Boolean matrices, which
provide algebraic versions of the problem, and finally, logical content can be reflected easier on the language of
relations.

First, the digraph model emphasizes the geometry. Its useful because we can draw pictures and reason
geometrically. The second is the matrix formulation. You’ll see that this is the best model for computational
purposes. The third model is the relational model (the ordered pair model). This representation is useful because
it is most easily generalized. First, the digraph model emphasizes the geometry. Its useful because we can draw
pictures and reason geometrically. The second is the matrix formulation. You’ll see that this is the best model
for computational purposes. The third model is the relational model (the ordered pair model). This
representation is useful because it is most easily generalized.

(1). Directed Graphs (digraphs). A graph Ѓ consists of a finite number of points A = (a1, a2, ..., an), which are
called vertices and a set E of directed lines between some pairs of vertices. These directed lines are called edges
(or links, or bonds) of the graph. For example, we could let A = {1, 2, 3, 4} and E = {(1, 1), (1, 2), (2, 3), (3, 2),
(3, 3), (4, 1), (4, 2), (4, 3)}. This digraph is drawn in figure below. One can draw small circles for each element

Page No.11
of A with its corresponding number inside and a system of edges. This provides a geometrical representation of
the graph.

An edge can connect the vertex ai with itself. Such an edge is called a loop. If two vertices are connected in
both directions, as a2 and a3 are in figure, we use only one line between, but with two arrows. A typical
example of a graph with two directions to each edge is a map of cities with lines between some of them
indicating the existence of a direct flight between the corresponding sites.

II. For a directed graph Ѓ , one can construct the Boolean matrix Mr containing complete information about Ѓ
in the numerical form. If Ѓ has n vertices A = {a1, ..., an} and directed edge set E, the corresponding adjacency
matrix Mr is the n × n matrix of numbers mij , i, j,= 1, 2, ...n (elements or entries of Mr) such that
(a) All entries mij are either 0 or 1.
(b) mij = 1 , there exists edge from ai to aj and mij = 0 otherwise. Matrices with only 0,1 elements are called
Boolean matrices. They are extremely important in logic and computer sciences. They are related to binary
representation.

Example 1. For the graph Ѓ presented in figure. the corresponding Boolean matrix is

Page No.12
Examples.

Page No.13
Fig. 3 (Inequality relation)

And

Page No.14
For example

It is clear now that Boolean matrices corresponding to union and intersection of two relations R and S have a
form

Manipulation of relations, Transitive closure

Transitive closure of the relation.: A relation fails to be transitive because it fails to contain certain ordered
pairs. For example, if (1, 3) and (3, 4) are in a relation R, then the pair (1, 4) must be in R if R is to be transitive.
To obtain a transitive relation from one that is not transitive, it is necessary to add ordered pairs the relation
obtained by adding the least number of ordered pairs to ensure transitivity is called the transitive closure of the
relation. In a sense made precise by the formal definition, the transitive closure of a relation is the smallest
transitive relation that contains the relation.

Let A = {0, 1, 2, 3} and consider the relation R defined on A


as follows:


R = {(0, 1), (1, 2), (2, 3)}. Find the transitive closure of R.
Every ordered pair in R is in Rt so {(0, 1), (1, 2), (2, 3)} Rt Thus the directed graph of Rt contains the arrows
shown at the right.

Page No.15
Since there are arrows going from 0 to 1 and from 1 to 2, Rt must have an arrow going from 0 to 2.Hence (0, 2)
∈ ∈ ∈ ∈ ∈
Rt. Then (0, 2) Rt and (2, 3) Rt, so since Rt is transitive, (0, 3) Rt. Also, since (1, 2) Rt and (2, 3) ∈
R , then (1, 3) Rt.
t

Thus Rt contains at least the following ordered pairs:
{(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)}.

But this relation is transitive; hence itequals Rt. Note that the directed graph of Rt is as shown at the right.

and Warshall’s algorithm,


Transitive Closure
By Warshall’s Algorithm

Set A = {(a,b,c)}
(a,b),
(b,c)
Then transitive is (a,c)

Set A= {(1,2,3)}
R ={(1,1),(1,3),(2,2),(3,1),(3,2)} because of the three elements the matrix is 3x3

1 2 3

1 0 1
0 1 0
1 1 0

I II III
C {1,3} {2,3} {1}

R {1,3} {2} {1,2}


--------------------------------------------------------------

Cartesian Product
(1.1) (2,2) (1,1)
(1,3) (3,2) (1,2)
(3,1)
(3,3)

Set (3,3) and (1,2) is not in the relation R so the relation does not satisfy the transitive property .

Page No.16
Warshall’s Algorithm to find Transitive Closure

Definition Let S be the finite set {v1 , ..., v n }, R a relation on S. The adjacency matrix A of R is an n
x n Boolean (zero-one) matrix defined by

Warshall’s algorithm is an efficient method of finding the adjacency matrix of the transitive closure
of relation R on a finite set S from the adjacency matrix of R. It uses properties of the digraph D, in
particular, walks of various lengths in D.

Definition : We let A be the adjacency matrix of R and T be the adjacency matrix of the transitive
closure of R. T is called the reachability matrix of digraph D due to the property that T i, j = 1 if and
only if j v can be reached from i v in D by a sequence of arcs (edges).

Digraph Implementation

Get the transitive closure of the relation represented by the digraph below. Use the method described
above. Indicate what arcs must be added to this digraph to get the digraph of the transitive closure, and
draw the digraph of the transitive closure.

Page No.17
Page No.18
Posets and Hasse Diagrams,Lattice.
Partial Ordering: A relation 'R' on a set 'A' is said to be a partial ordering relation if 'R' is reflexive,
antisymmetric & transitive.
Example:
A = {1, 2, 3}
R = {(1,1), (2,2), (3,3), (1,2)} is a partial ordering relation.

• Consider a reflexive relation: ≤


– One which every element is related to itself
– Let A = { 1, 2, 3, 4, 5 }

If the center (main) diagonal is all 1’s, a relation is reflexive

• Consider a reflexive relation: <


– One which every element is not related to itself
– Let A = { 1, 2, 3, 4, 5 }

If the center (main) diagonal is all 0’s, a relation is irreflexive

Page No.19
• Consider an symmetric relation R
– One which if a is related to b then b is related to a for all (a,b)
Let A = { 1, 2, 3, 4, 5 }

• If, for every value, it is the equal to the value in its transposed position, then the relation
is symmetric

• Consider an asymmetric relation: <


• One which if a is related to b then b is not related to a for all (a,b)
• Let A = { 1, 2, 3, 4, 5 }

• If, for every value and the value in its transposed position, if they are not both 1, then the
relation is asymmetric
• An asymmetric relation must also be irreflexive
• Thus, the main diagonal must be all 0’s

Antisymmetry

• Consider an antisymmetric relation: ≤


– One which if a is related to b then b is not related to a unless a=b for all (a,b)
• Let A = { 1, 2, 3, 4, 5 }Consider an antisymmetric relation: ≤
– One which if a is related to b then b is not related to a unless a=b for all (a,b)
Let A = { 1, 2, 3, 4, 5 }

Page No.20
• If, for every value and the value in its transposed position, if they are not both 1, then the
relation is antisymmetric
• The center diagonal can have both 1’s and 0’s

Posets Are Acyclic: the combination of the transitivity and asymmetry properties imply that the
digraph for any poset is an acyclic graph (that is, a DAG), at least if we don’t count loops as cycles.

We have shown the graph form of the poset for the “<”-relation on {1, 2, 3, 4 } in Figure below

Figure: [ poset for the “<”-relation on {1, 2, 3, 4 } ] [The Hasse diagrams for the posets]

The Hasse Diagram : One problem with viewing a poset as a digraph is that there tend to be lots of
edges due to the transitivity property. Fortunately, we do not necessarily have to draw all the edges if
we know that the digraph corresponds to a poset. For example, we could choose not to draw any edge
which would be implied by the transitivity property, knowing that it is really there by implication.

The Hasse diagram of a poset is a simpler version of the digraph representing the partial order relation.
The properties of a partial order assure us that its digraph can be drawn in an oriented plane so that
each element lies below all other elements it precedes in the order. Once this has been done, all
redundant information can be removed from the digraph and the result is the Hasse diagram.

To obtain a Hasse diagram, proceed as follows:

Start with a directed graph of the relation, placing vertices on the page so that all arrows point
upward.

Page No.21
The last figure in the above diagram contains sufficient information to find the partial ordering. This
diagram is called a Hasse Diagram.

Extremums in Posets : Elements of posets that have certain extremal properties are important for
many applications.

Maximal and Minimal elements are easy to find in Hasse diagrams. They are the topmost and
bottommost elements respectively. For example, in the hasse diagram described above, “1” is the
minimal element and “4” is the maximal element. Since maximal and minimal are unique, they are
also the greatest and least element of the poset.

Important Note : If the maximal or minimal element is unique, it is called the greatest or least
element of the poset respectively.

Page No.22
Page No.23
Example:

LUB (2,3) = 6 GLB (2,3) = 1


LUB (6,9) = 18 GLB (6,9) = 3

Page No.24
Consider the poset ( { 1, 2, 3, 4 }, ≤)

original representation Hasse diagram

Exercise: Draw a Hasse diagram for (A, ) (divisibility relation), where


(i) A = {1, 2, 3, 4, 5, 6, 7, 8}; (iii) A = {2, 3, 4, 5, 6, 30, 60}; (v) A = {1, 2, 4, 8, 16, 32, 64};
(ii) A = {1, 2, 3, 5, 11, 13}; (iv) A = {1, 2, 3, 6, 12, 24}; (vi) A = {2, 4, 6, 12, 24, 36}.

Exercise: Consider the poset ({3, 5, 9, 15, 24, 45},), that is, the divisibility relation. (i) Draw its Hasse
diagram. (ii) Find its maxima, minima, greatest and least elements when they exist. (iii) Find maxima,
minima, greatest and least elements of the set M = {3, 9, 15}, when they exist.

(i)

Page No.25

S-ar putea să vă placă și