Table of contents
Relations
Parent: Discrete Mathematics
Subject: Computer Science
Type: Semester
SL#: 2401151836
Status: Current

Cartesian Product

Cartesian Product or cross product of two non-empty sets AA and BB expressed as A×BA\times B is a set of all ordered pairs (a,b)(a,b), where aAa\in A, bBb\in B.

Mathematically it can be written as:

A×B={(a,b)aA,bB}A\times B=\{(a,b)|a\in A,b\in B\}

E.g.: Considering A={1,2}A=\{1,2\}, B={a,b,c}B=\{a,b,c\}. Then the Cartesian Product is, A×B={(1,a),(1,b),(1,c),(2,a),(2,b),(2,c)}A\times B=\{(1,a),(1,b),(1,c),(2,a),(2,b),(2,c)\}.

Figure 1: Relation map for A×BA\times B:

Relation map for A\cross B

Binary Relation

Let AA and BB be two non-empty sets. A binary relation RR is a subset of A×BA\times B, i.e., RA×BR\subseteq A\times B. If (a,b)R(a,b)\in R, then it is written as aRbaRb.

Considering A={1,2,3}A=\{1,2,3\}, B={a,b}B=\{a,b\}, then RR could be, R={(1,a),(1,b),(3,b)}R=\{(1,a),(1,b),(3,b)\}.

Figure 2: Relation map for aRbaRb:

Relation map for aRb

Example 1: Let A={2,3,4,5,6}A=\{2,3,4,5,6\}. Define a relation aRbaRb such that aa divides bb.

Given, A={2,3,4,5,6}A=\{2,3,4,5,6\}. The relation aRbaRb, such that aa divides bb is:

aRb={(2,2),(2,4),(2,6),(3,3),(3,6),(4,4),(5,5),(6,6)}aRb=\{(2,2),(2,4),(2,6),(3,3),(3,6),(4,4),(5,5),(6,6)\}

Example 2: Let A={0,1,2,3,4}A=\{0,1,2,3,4\}. Define a relation aRbaRb such that a+b=4a+b=4.

Given, A={0,1,2,3,4}A=\{0,1,2,3,4\}. The relation aRbaRb such that, a+b=4a+b=4, is:

aRb={(0,4),(1,3),(2,2),(3,1),(4,0)}aRb=\{(0,4),(1,3),(2,2),(3,1),(4,0)\}

Matrix of a relation

The matrix of a relation A×BA\times B, where AA has nn elements, and BB has mm elements, is an n×mn\times m matrix, MRM_R defined as follows:

MR=[mij]M_R=[m_{ij}]

It can be perceived that:

mij=1m_{ij}=1, if (ai,bj)R(a_i,b_j)\in R, and

mij=0m_{ij}=0, if (ai,bj)R(a_i,b_j)\notin R.

E.g.: Considering A={1,2,3}A=\{1,2,3\}, B={a,b,c,d}B=\{a,b,c,d\}, and aRb={(1,a),(2,a),(3,b),(3,d)}aRb=\{(1,a),(2,a),(3,b),(3,d)\}. Then their matrix, MRM_R is:

MR=[100010000101]M_R={\begin{bmatrix} 1&0&0&0\\ 1&0&0&0\\ 0&1&0&1\\ \end{bmatrix}}

While drawing matrix, the first element in the relation is taken as the row, and the second element is taken as the column.

Di-graph

Di-graph stands for directed graph. It is used to map out the relation between elements of sets. Considering a relation aRb={(1,a),(2,a),(3,b),(3,d)}aRb=\{(1,a),(2,a),(3,b),(3,d)\}, we have the following di-graph, for it:

Di-graph for aRb

Example 3: Let A={0,1,2,3,4}A=\{0,1,2,3,4\}. Define a relation aRbaRb, such that a+b=4a+b=4. Define its relation matrix and draw its di-graph.

For the set A={0,1,2,3,4}A=\{0,1,2,3,4\}, we have a relation such that a+b=4a+b=4. Therefore we have, aRb={(0,4),(1,3),(2,2),(3,1),(4,0)}aRb=\{(0,4),(1,3),(2,2),(3,1),(4,0)\}. It's relation matrix MRM_R is:

MR=[0000100010001000100010000]M_R= \begin{bmatrix} 0&0&0&0&1\\ 0&0&0&1&0\\ 0&0&1&0&0\\ 0&1&0&0&0\\ 1&0&0&0&0 \end{bmatrix}

Di-graph for the above relation aRbaRb is:

Di-graph for relation aRb

Example 4: Let A={0,1,2,3,4}A=\{0,1,2,3,4\}. Define a relation aRbaRb such that HCF of (a,b)(a,b) is 11.

Given, A={0,1,2,3,4}A=\{0,1,2,3,4\}. A relation, aRbaRb, such that HCF of (a,b)(a,b) is 11, is:

aRb={(1,1),(1,2),(1,3),(1,4),(2,1),(2,3),(3,1),(3,2),(3,4),(4,1),(4,3)}aRb=\{(1,1),(1,2),(1,3),(1,4),(2,1),(2,3),(3,1),(3,2),(3,4),(4,1),(4,3)\} MR=[0000001111010100110101010]M_R= \begin{bmatrix} 0&0&0&0&0\\ 0&1&1&1&1\\ 0&1&0&1&0\\ 0&1&1&0&1\\ 0&1&0&1&0 \end{bmatrix}
flowchart LR
    A((0))
    B((1))-->B
    B-->C
    B-->D
    B-->E
    C((2))-->B
    C-->D
    D((3))-->B
    D-->C
    D-->E
    E((4))-->B
    E-->D

Properties of Relations

  1. Reflexive: There should be aRaaRa for all aAa\in A.

  2. Symmetric: If aRbaRb exists then bRabRa should also exist for all (a,b)A(a,b)\in A.

  3. Antisymmetric: If aRbaRb exists, then bRabRa must not exist, but bRabRa can exist if a=ba=b and (a,b)A(a,b)\in A.

  4. Asymmetric: If aRbaRb exist, then bRabRa must not exist for all (a,b)A(a,b)\in A,

  5. Transitive: If aRbaRb and bRcbRc exists, then aRcaRc must exist where, (a,b,c)A(a,b,c)\in A.

Equivalence Relation

A binary relation RR on set AA is called an equivalence relation if RR is reflexive, symmetric and transitive.

E.g. Let A={1,2,3}A=\{1,2,3\} and R={(1,1),(1,2),(2,1),(2,2),(3,2)}R=\{(1,1),(1,2),(2,1),(2,2),(3,2)\}. To check whether RR is reflexive or not, the following conditions must hold true:

MR=[110110001]M_R= \begin{bmatrix} 1&1&0\\ 1&1&0\\ 0&0&1 \end{bmatrix}

Test for reflexive:

Since, all elements in the right bearing diagonal are 11, therefore, the relation is reflexive.

Test for symmetric:

MR1=[110110001]M_R^{-1}= \begin{bmatrix} 1&1&0\\ 1&1&0\\ 0&0&1 \end{bmatrix}

Since, MR1=MRM_R^{-1}=M_R, therefore, the relation is symmetric.

Test for transitive:

(MR)2=[110110001][110110001]=[110110001](M_R)^2_\odot= \begin{bmatrix} 1&1&0\\ 1&1&0\\ 0&0&1 \end{bmatrix} \begin{bmatrix} 1&1&0\\ 1&1&0\\ 0&0&1 \end{bmatrix} =\begin{bmatrix} 1&1&0\\ 1&1&0\\ 0&0&1 \end{bmatrix}

Since, (MR)2=MR(M_R)^2_\odot=M_R, therefore, the relation is transitive.

Since the relation RR, is reflexive, symmetric and transitive, therefore, it is an equivalence relation.

Example 5: Let, A=1,2,3A={1,2,3}, and R={(1,1),(2,2),(2,3),(3,2),(3,3)}R=\{(1,1),(2,2),(2,3),(3,2),(3,3)\}. Find out if RR is an equivalence relation or not.

For RR to be an equivalence relation, it must be reflexive, symmetric and transitive.

The matrix for RR, MRM_R is:

MR=[100011011]M_R= \begin{bmatrix} 1&0&0\\ 0&1&1\\ 0&1&1 \end{bmatrix}

Test for reflexive:

Since all the right bearing diagonals are 11, therefore, the relation is reflexive.

Test for symmetric:

MR1=[100011011]M_R^{-1}= \begin{bmatrix} 1&0&0\\ 0&1&1\\ 0&1&1 \end{bmatrix}

Since, MR1=MRM_R^{-1}=M_R, therefore, the relation is symmetric.

Test for transitive:

(MR)2=MR=[100011011][100011011]=[100011011](M_R)^2_\odot= M_R= \begin{bmatrix} 1&0&0\\ 0&1&1\\ 0&1&1 \end{bmatrix} \begin{bmatrix} 1&0&0\\ 0&1&1\\ 0&1&1 \end{bmatrix} = \begin{bmatrix} 1&0&0\\ 0&1&1\\ 0&1&1 \end{bmatrix}

Since, (MR)2=MR(M_R)^2_\odot=M_R, therefore, the relation is transitive.

Since the relation R, is reflexive, symmetric and transitive, therefore, it is an equivalence relation.

Closure

Certain elements added to the relation set to make it obey properties like reflexive, symmetry etc., is known as a relation closure.

E.g.: A={0,1,2,3}A=\{0,1,2,3\}, and R={(0,1),(1,1),(1,2),(2,0),(2,2),(3,0)}R=\{(0,1),(1,1),(1,2),(2,0),(2,2),(3,0)\}.

Matrix of the relation, MRM_R is:

MR=[0100011010101000]M_R= \begin{bmatrix} 0&1&0&0\\ 0&1&1&0\\ 1&0&1&0\\ 1&0&0&0 \end{bmatrix}

Reflexive closure:

In order for RR to be reflexive, all right-bearing diagonal elements should be 11. If (0,0)(0,0) and (3,3)(3,3) is added, the relation will be reflexive. Therefore reflexive closure RR', is:

R={(0,1),(1,1),(1,2),(2,0),(2,2),(3,0),(0,0),(3,3)}R'=\{(0,1),(1,1),(1,2),(2,0),(2,2),(3,0),(0,0),(3,3)\}

Symmetric closure:

To find the symmetric closure, we derive R1R^{-1}, and perform RR1R\cup R^{-1}.

R1={(1,0),(1,1),(2,1),(0,2),(2,2),(0,3)}R^{-1}=\{(1,0),(1,1),(2,1),(0,2),(2,2),(0,3)\}

Therefore, symmetric closure, RR', is:

R=RR1={(0,1),(1,1),(1,2),(2,0),(2,2),(3,0),(1,0),(2,1),(0,2),(0,3)}R'=R\cup R^{-1}=\{(0,1),(1,1),(1,2),(2,0),(2,2),(3,0),(1,0),(2,1),(0,2),(0,3)\}

Transitive closure:

Transitive closure is performed using Warshall's Algorithm.

Considerin a set A={1,2,3,4}A=\{1,2,3,4\}, and R={(2,1),(2,3),(3,1),(3,4),(4,1),(4,3)}R=\{(2,1),(2,3),(3,1),(3,4),(4,1),(4,3)\}. Then, its matrix is:

MR=[0000101010011010]M_R= \begin{bmatrix} 0&0&0&0\\ 1&0&1&0\\ 1&0&0&1\\ 1&0&1&0 \end{bmatrix}
CRC.P.
{2,3,4}\{2,3,4\}{ϕ}\{\phi\}-
{ϕ}\{\phi\}{1,3}\{1,3\}-
{2,4}\{2,4\}{1,4}\{1,4\}{(2,1),(2,4),(4,1),(4,4)}\{(2,1),(2,4),(4,1),(4,4)\}
{3}\{3\}{1,3}\{1,3\}{(3,1),(3,3)}\{(3,1),(3,3)\}
MR=[0000101110111011]M_R'= \begin{bmatrix} 0&0&0&0\\ 1&0&1&1\\ 1&0&1&1\\ 1&0&1&1 \end{bmatrix}
CRC.P.
{2,3,4}\{2,3,4\}{ϕ}\{\phi\}-
{ϕ}\{\phi\}{1,3,4}\{1,3,4\}-
{2,3,4}\{2,3,4\}{1,3,4}\{1,3,4\}{(2,1),(2,3),(2,4),(3,1),(3,3),(3,4),(4,1),(4,3),(4,4)}\{(2,1),(2,3),(2,4),(3,1),(3,3),(3,4),(4,1),(4,3),(4,4)\}
{2,3,4}\{2,3,4\}{1,3,4}\{1,3,4\}{(2,1),(2,3),(2,4),(3,1),(3,3),(3,4),(4,1),(4,3),(4,4)}\{(2,1),(2,3),(2,4),(3,1),(3,3),(3,4),(4,1),(4,3),(4,4)\}
MR=[0000101110111011]M_R''= \begin{bmatrix} 0&0&0&0\\ 1&0&1&1\\ 1&0&1&1\\ 1&0&1&1 \end{bmatrix}

Since, MR=MRM_R'=M_R'', therefore, transitive closure, RR' is:

R={(2,1),(2,3),(2,4),(3,1),(3,3),(3,4),(4,1),(4,3),(4,4)}R'=\{(2,1),(2,3),(2,4),(3,1),(3,3),(3,4),(4,1),(4,3),(4,4)\}

Example 6: Given the set A={a,b,c,d}A=\{a,b,c,d\}, and R={(a,d),(b,a),(b,c),(c,a),(c,d),(d,c)}R=\{(a,d),(b,a),(b,c),(c,a),(c,d),(d,c)\}.

It's matrix is:

MR=[0001101010010010]M_R= \begin{bmatrix} 0&0&0&1\\ 1&0&1&0\\ 1&0&0&1\\ 0&0&1&0 \end{bmatrix}
CRC.P.
{b,c}\{b,c\}{d}\{d\}{(b,d),(c,d)}\{(b,d),(c,d)\}
{ϕ}\{\phi\}{a,c}\{a,c\}-
{b,d}\{b,d\}{a,d}\{a,d\}{(b,a),(b,d),(d,a),(d,d)}\{(b,a),(b,d),(d,a),(d,d)\}
{a,c}\{a,c\}{c}\{c\}{(a,c),(c,c)}\{(a,c),(c,c)\}
MR=[0011101110111011]M_R'= \begin{bmatrix} 0&0&1&1\\ 1&0&1&1\\ 1&0&1&1\\ 1&0&1&1 \end{bmatrix}
CRC.P.
{b,c,d}\{b,c,d\}{c,d}\{c,d\}{(b,c),(b,d),(c,c),(c,d),(d,c),(d,d)}\{(b,c),(b,d),(c,c),(c,d),(d,c),(d,d)\}
{ϕ}\{\phi\}{a,c,d}\{a,c,d\}-
{a,b,c,d}\{a,b,c,d\}{a,c,d}\{a,c,d\}{(a,a),(a,c),(a,d),(b,a),(b,c),(b,d),(c,a),(c,c),(c,d),(d,a),(d,c),(d,d)}\{(a,a),(a,c),(a,d),(b,a),(b,c),(b,d),(c,a),(c,c),(c,d),(d,a),(d,c),(d,d)\}
{a,b,c,d}\{a,b,c,d\}{a,c,d}\{a,c,d\}{(a,a),(a,c),(a,d),(b,a),(b,c),(b,d),(c,a),(c,c),(c,d),(d,a),(d,c),(d,d)}\{(a,a),(a,c),(a,d),(b,a),(b,c),(b,d),(c,a),(c,c),(c,d),(d,a),(d,c),(d,d)\}
MR=[1011101110111011]M_R''= \begin{bmatrix} 1&0&1&1\\ 1&0&1&1\\ 1&0&1&1\\ 1&0&1&1 \end{bmatrix}
CRC.P.
{a,b,c,d}\{a,b,c,d\}{a,c,d}\{a,c,d\}{(a,a),(a,c),(a,d),(b,a),(b,c),(b,d),(c,a),(c,c),(c,d),(d,a),(d,c),(d,d)}\{(a,a),(a,c),(a,d),(b,a),(b,c),(b,d),(c,a),(c,c),(c,d),(d,a),(d,c),(d,d)\}
{ϕ}\{\phi\}{a,c,d}\{a,c,d\}-
{a,b,c,d}\{a,b,c,d\}{a,c,d}\{a,c,d\}{(a,a),(a,c),(a,d),(b,a),(b,c),(b,d),(c,a),(c,c),(c,d),(d,a),(d,c),(d,d)}\{(a,a),(a,c),(a,d),(b,a),(b,c),(b,d),(c,a),(c,c),(c,d),(d,a),(d,c),(d,d)\}
{a,b,c,d}\{a,b,c,d\}{a,c,d}\{a,c,d\}{(a,a),(a,c),(a,d),(b,a),(b,c),(b,d),(c,a),(c,c),(c,d),(d,a),(d,c),(d,d)}\{(a,a),(a,c),(a,d),(b,a),(b,c),(b,d),(c,a),(c,c),(c,d),(d,a),(d,c),(d,d)\}
MR=[1011101110111011]M_R'''= \begin{bmatrix} 1&0&1&1\\ 1&0&1&1\\ 1&0&1&1\\ 1&0&1&1 \end{bmatrix}

Since, MR=MRM_R''=M_R''', therefore, transitive closure, RR' is achieved.

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)}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)\}

Equivalence of class and partition

The general equation for equivalent classes:

[x]={yyA,(x,y)R}[x]=\{y|y\in A,(x,y)\in R\}

E.g.: A={1,2,3,4,5}A=\{1,2,3,4,5\}, and R={(1,1),(2,2),(3,3),(4,4),(5,5),(1,2),(2,1),(4,5),(5,4)}R=\{(1,1),(2,2),(3,3),(4,4),(5,5),(1,2),(2,1),(4,5),(5,4)\}

[1]={1,2},[2]={2,1},[3]={3},[4]={4,5},[5]={5,4}[1]=\{1,2\}, [2]=\{2,1\}, [3]=\{3\}, [4]=\{4,5\}, [5]=\{5,4\}

Therefore, the partitions are:

P1={1,2}P_1=\{1,2\}, P2={3}P_2=\{3\}, P3={4,5}P_3=\{4,5\}

From the above, it can be drawn out that:

P1P2P3=AP_1\cup P_2\cup P_3=A P1P2P3={ϕ}P_1\cap P_2\cap P_3 = \{\phi\}

Example 7: A={1,2,3}A=\{1,2,3\}, and R={(1,1),(1,2),(2,1),(2,2),(3,3)}R=\{(1,1),(1,2),(2,1),(2,2),(3,3)\}.

Equivalence classes:

[1]={1.2},[2]={2,1},[3]={3}[1]=\{1.2\}, [2]=\{2,1\}, [3]=\{3\}

Partitions are:

P1={1,2}P_1=\{1,2\}, P2={3}P_2=\{3\}

Example 8: Let set A={1,2,3,4,5,6}A=\{1,2,3,4,5,6\}, P1={1,3,5}P_1=\{1,3,5\}, P2={2,4,6}P_2=\{2,4,6\}, where P1P_1, and P2P_2 are partitions. Find the relation set of the set AA.

RR could be found by the union of the Cartesian products of the two partitions.

R={(1,1),(1,3),(1,5),(3,1),(3,3),(3,5),(5,1),(5,3),(5,5),(2,2),(2,4),(2,6),(4,2),(4,4),(4,6),(6,2),(6,4),(6,6)}R=\{(1,1),(1,3),(1,5),(3,1),(3,3),(3,5),(5,1),(5,3),(5,5),\\(2,2),(2,4),(2,6),(4,2),(4,4),(4,6),(6,2),(6,4),(6,6)\}

POSET

POSET stands for partial-order set. Let RR be a relation on set AA. The relation RR is called partial order set (POSET), if RR is reflexive, antisymmetric, and transitive. A POSET is symbolically represented as (A,)(A,\le).

E.g.: Let a set be A={1,2,3,4}A=\{1,2,3,4\}, and its relation set be defined by R={(a,b)(a,b)A,ab}R=\{(a,b)|(a,b)\in A, a\ge b\}.

R={(1,1),(2,1),(2,2),(3,1),(3,2),(3,3),(4,1),(4,2),(4,3),(4,4)}R=\{(1,1),(2,1),(2,2),(3,1),(3,2),(3,3),(4,1),(4,2),(4,3),(4,4)\}

It's relation matrix is:

MR=[1000110011101111]M_R= \begin{bmatrix} 1&0&0&0\\ 1&1&0&0\\ 1&1&1&0\\ 1&1&1&1 \end{bmatrix}

Check for reflexive:

Since all diagonal elements are 11, therefore the relation is reflexive.

Check for antisymmetric:

For all non-diagonal elements, [mij]=1[m_{ij}]=1, [mj,i=0][m_{j,i}=0], hence it is antisymmetric.

Check for transitive:

(MR)2=[1000110011101111][1000110011101111]=[1000110011101111](M_R)^2_\odot= \begin{bmatrix} 1&0&0&0\\ 1&1&0&0\\ 1&1&1&0\\ 1&1&1&1 \end{bmatrix} \begin{bmatrix} 1&0&0&0\\ 1&1&0&0\\ 1&1&1&0\\ 1&1&1&1 \end{bmatrix} = \begin{bmatrix} 1&0&0&0\\ 1&1&0&0\\ 1&1&1&0\\ 1&1&1&1 \end{bmatrix}

Since, (MR)2=MR(M_R)^2_\odot=M_R, therefore the relation is transitive.

Since the relation is reflexive, antisymmetric, and transitive, therefore the relation is a POSET.

Docs
AnanyaGB
About
© MIT - 2024