Set TheoryTopic #11 of 40

Relations

Binary relations, properties (reflexive, symmetric, transitive, antisymmetric), and relation composition.

Definition

A binary relation RR from set AA to set BB is a subset of A×BA \times B: RA×BR \subseteq A \times B

If (a,b)R(a, b) \in R, we write aRbaRb or R(a,b)R(a, b).

A relation on AA is a relation from AA to AA: RA×AR \subseteq A \times A.

Representations

Set of Ordered Pairs

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

Matrix Representation

For A={a1,,am}A = \{a_1, \ldots, a_m\} and B={b1,,bn}B = \{b_1, \ldots, b_n\}:

MR[i,j]={1if (ai,bj)R0otherwiseM_R[i,j] = \begin{cases} 1 & \text{if } (a_i, b_j) \in R \\ 0 & \text{otherwise} \end{cases}

Digraph (Directed Graph)

  • Vertices represent elements
  • Directed edge from aa to bb if aRbaRb

Properties of Relations on a Set

Reflexive

Every element is related to itself: aA:(a,a)R\forall a \in A: (a, a) \in R

Matrix: All diagonal entries are 1. Digraph: Every vertex has a self-loop.

Irreflexive

No element is related to itself: aA:(a,a)R\forall a \in A: (a, a) \notin R

Symmetric

If aa is related to bb, then bb is related to aa: a,bA:(a,b)R(b,a)R\forall a, b \in A: (a, b) \in R \rightarrow (b, a) \in R

Matrix: MR=MRTM_R = M_R^T (symmetric matrix). Digraph: Every edge has a reverse edge.

Antisymmetric

If aa is related to bb and bb is related to aa, then a=ba = b: a,bA:((a,b)R(b,a)R)a=b\forall a, b \in A: ((a, b) \in R \land (b, a) \in R) \rightarrow a = b

Equivalently: If aba \neq b and (a,b)R(a, b) \in R, then (b,a)R(b, a) \notin R.

Asymmetric

If aa is related to bb, then bb is not related to aa: a,bA:(a,b)R(b,a)R\forall a, b \in A: (a, b) \in R \rightarrow (b, a) \notin R

Note: Asymmetric implies irreflexive and antisymmetric.

Transitive

If aa is related to bb and bb is related to cc, then aa is related to cc: a,b,cA:((a,b)R(b,c)R)(a,c)R\forall a, b, c \in A: ((a, b) \in R \land (b, c) \in R) \rightarrow (a, c) \in R

Examples

"Less than" on Z\mathbb{Z}

Property<<
ReflexiveNo (aaa \not< a)
SymmetricNo (a<b⇏b<aa < b \not\Rightarrow b < a)
AntisymmetricYes (vacuously)
TransitiveYes

"Divides" on Z+\mathbb{Z}^+

aba \mid b means aa divides bb (i.e., b=kab = ka for some integer kk)

Property\mid
ReflexiveYes (aaa \mid a)
SymmetricNo (242 \mid 4 but 424 \nmid 2)
AntisymmetricYes (on Z+\mathbb{Z}^+)
TransitiveYes

Combining Relations

Union

R1R2={(a,b)(a,b)R1(a,b)R2}R_1 \cup R_2 = \{(a, b) \mid (a, b) \in R_1 \lor (a, b) \in R_2\}

Intersection

R1R2={(a,b)(a,b)R1(a,b)R2}R_1 \cap R_2 = \{(a, b) \mid (a, b) \in R_1 \land (a, b) \in R_2\}

Complement

R={(a,b)(a,b)R}\overline{R} = \{(a, b) \mid (a, b) \notin R\}

Inverse

R1={(b,a)(a,b)R}R^{-1} = \{(b, a) \mid (a, b) \in R\}

Composition of Relations

If RR is from AA to BB and SS is from BB to CC: SR={(a,c)bB:(a,b)R(b,c)S}S \circ R = \{(a, c) \mid \exists b \in B: (a, b) \in R \land (b, c) \in S\}

Matrix Representation

If MRM_R and MSM_S are relation matrices: MSR=MRMSM_{S \circ R} = M_R \odot M_S

where \odot is Boolean matrix multiplication.

Powers of a Relation

R1=RR^1 = R Rn+1=RnRR^{n+1} = R^n \circ R

Closure of Relations

The closure adds the minimum pairs to make a relation have a property.

Reflexive Closure

r(R)=R{(a,a)aA}=RIAr(R) = R \cup \{(a, a) \mid a \in A\} = R \cup I_A

Symmetric Closure

s(R)=RR1s(R) = R \cup R^{-1}

Transitive Closure

t(R)=RR2R3=i=1Rit(R) = R \cup R^2 \cup R^3 \cup \cdots = \bigcup_{i=1}^{\infty} R^i

For finite set with A=n|A| = n: t(R)=i=1nRit(R) = \bigcup_{i=1}^{n} R^i

Warshall's Algorithm

Computes transitive closure efficiently in O(n3)O(n^3):

for k = 1 to n:
    for i = 1 to n:
        for j = 1 to n:
            M[i,j] = M[i,j] OR (M[i,k] AND M[k,j])