πŸ“š CS285: Discrete Mathematics

Chapter 9: Relations - Comprehensive Study Guide

1. Introduction to Binary Relations

Definition: Binary Relation

A binary relation R from a set A to a set B is a subset R βŠ† A Γ— B.

In other words, a binary relation from A to B is a set of ordered pairs where the first element comes from A and the second element comes from B.

Key Point: Relations are MORE GENERAL than functions. A function is a special type of relation where exactly one element of B is related to each element of A.

Notation

β€’ If (a,b) ∈ R, we write: a R b (read as "a is related to b")
β€’ If (a,b) βˆ‰ R, we write: a RΜΈ b (read as "a is not related to b")
β€’ Alternative phrases: "a relates to b under relation R"
Example 1: Student-Course Relation

Let A = {1, 2, 3} represent students

Let B = {a, b} represent courses

R = {(1,a), (1,b), (2,a), (3,b)}

This means:

  • Student 1 is registered in courses a and b
  • Student 2 is registered in course a
  • Student 3 is registered in course b

Special Relation: Identity Relation

Identity Relation (IA)

The identity relation on a set A is: IA = {(a,a) | a ∈ A}

Every element is only related to itself.

Example: Identity Relation

If A = {1, 2, 3, 4}, then:

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

Ways to Represent Relations

  1. Roster Notation: List of ordered pairs {(1,2), (3,4), ...}
  2. Set Builder Notation: {(a,b) | condition}
  3. Graph/Digraph: Visual representation with dots and arrows
  4. Table/Matrix: Zero-one matrix representation

2. Properties of Relations

Relations on a set A (where R: A β†’ A) can have special properties:

Property 1: Reflexivity

Reflexive Relation

A relation R on A is reflexive if (a,a) ∈ R for every element a ∈ A

In other words: Every element is related to itself.

Irreflexive Relation

A relation R on A is irreflexive if (a,a) βˆ‰ R for every element a ∈ A

In other words: No element is related to itself.

Important: "Irreflexive" β‰  "Not Reflexive"
  • A relation can be neither reflexive nor irreflexive
  • Example: R = {(1,2), (2,1), (1,1)} on A = {1,2} is NOT reflexive (missing (2,2)) and NOT irreflexive (has (1,1))
Examples on Integers

R₁ = {(a,b) | a ≀ b} - REFLEXIVE (every number ≀ itself)

Rβ‚‚ = {(a,b) | a > b} - IRREFLEXIVE (no number > itself)

R₃ = {(a,b) | a = b or a = -b} - REFLEXIVE

Rβ‚„ = {(a,b) | a = b} - REFLEXIVE

Property 2: Symmetry

Symmetric Relation

A relation R on A is symmetric if:

(a,b) ∈ R β†’ (b,a) ∈ R for all a, b ∈ A

When (a,b) is present, (b,a) MUST also be present.

Antisymmetric Relation

A relation R on A is antisymmetric if:

(a,b) ∈ R ∧ (b,a) ∈ R β†’ a = b

Alternative: If (a,b) is there with a β‰  b, then (b,a) should NOT be there.

Important: Symmetric and Antisymmetric are NOT opposites!
  • A relation can have both properties (e.g., R = {(a,b) | a = b})
  • A relation can have neither property
  • A relation CANNOT be both symmetric AND antisymmetric if it contains some pair (a,b) where a β‰  b
Examples on Integers

R₁ = {(a,b) | a = b} - SYMMETRIC and ANTISYMMETRIC

Rβ‚‚ = {(a,b) | a > b} - NOT SYMMETRIC, ANTISYMMETRIC

R₃ = {(a,b) | a = b+1} - NOT SYMMETRIC, ANTISYMMETRIC

Property 3: Transitivity

Transitive Relation

A relation R is transitive if:

(a,b) ∈ R ∧ (b,c) ∈ R β†’ (a,c) ∈ R for all a, b, c

If there's a path from a to b and from b to c, there must be a direct connection from a to c.

Example: Checking Transitivity

A = {1, 2}

R₁ = {(1,1), (1,2), (2,1), (2,2)} - TRANSITIVE

Check: (1,2) and (2,1) are in R₁, and (1,1) is in R₁ βœ“

Rβ‚‚ = {(1,1), (1,2), (2,1)} - NOT TRANSITIVE

Why? (1,2) and (2,1) are in Rβ‚‚, but (1,1) is missing... wait, it's there!

Actually, we need to check: (2,1) and (1,2) β†’ need (2,2), which is missing βœ—

Summary Table

Property Definition Visual Check
Reflexive βˆ€a: (a,a) ∈ R All diagonal elements in matrix are 1
Irreflexive βˆ€a: (a,a) βˆ‰ R All diagonal elements in matrix are 0
Symmetric (a,b) ∈ R β†’ (b,a) ∈ R Matrix is symmetric (M = MT)
Antisymmetric (a,b) ∈ R ∧ (b,a) ∈ R β†’ a = b All 1's across diagonal are from 0's
Transitive (a,b) ∈ R ∧ (b,c) ∈ R β†’ (a,c) ∈ R Complete all triangles in digraph

3. Representing Relations

Method 1: Zero-One Matrices

Matrix Representation

To represent a relation R by a matrix MR = [mij]:

mij = 1 if (ai, bj) ∈ R

mij = 0 if (ai, bj) βˆ‰ R

Example: Matrix Representation

A = {1, 2, 3}, B = {1, 2}

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

Matrix MR:

1 2
1 0 0
2 1 0
3 1 1

Identifying Properties from Matrices

Reflexive:

All 1's on the main diagonal (top-left to bottom-right)

Irreflexive:

All 0's on the main diagonal

Symmetric:

Matrix equals its transpose: M = MT

All 1's are mirrored across the diagonal

Antisymmetric:

If mij = 1 and i β‰  j, then mji = 0

All 1's across from each other (not on diagonal) must face 0's

Method 2: Directed Graphs (Digraphs)

Digraph Representation

A directed graph G = (VG, EG) where:

  • VG is the set of vertices (nodes) - represents elements of set A
  • EG is the set of edges (arcs) - represents ordered pairs in R
  • Draw an arrow from vertex a to vertex b if (a,b) ∈ R
Example: Digraph

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

on set {1, 2, 3, 4}

Visual: Each number has a loop to itself (reflexive), plus arrows from 1 to 2, 3, 4 and from 2 to 4.

Identifying Properties from Digraphs

Reflexive:

Every vertex has a loop (self-edge)

Irreflexive:

No vertex has a loop

Symmetric:

Every edge has a corresponding edge in the opposite direction (bidirectional arrows)

Antisymmetric:

No two distinct vertices have edges in both directions

Transitive:

Whenever there's a path from x to y and y to z, there must be a direct edge from x to z

4. Combining Relations

Operation 1: Union and Intersection

Union (R₁ βˆͺ Rβ‚‚):

MR₁βˆͺRβ‚‚ = MR₁ ∨ MRβ‚‚

Element-wise OR: mij = 1 if element is in R₁ OR Rβ‚‚

Intersection (R₁ ∩ Rβ‚‚):

MRβ‚βˆ©Rβ‚‚ = MR₁ ∧ MRβ‚‚

Element-wise AND: mij = 1 if element is in R₁ AND Rβ‚‚

Example: Union and Intersection

A = {1, 2, 3}

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

Rβ‚‚ = {(1,1), (1,2), (1,3), (1,4)}

R₁ βˆͺ Rβ‚‚ = {(1,1), (2,2), (1,2), (3,1), (2,3), (3,2), (1,3), (1,4)}

R₁ ∩ Rβ‚‚ = {(1,1), (1,2)}

Operation 2: Composition

Composition (S ∘ R):

If R: A β†’ B and S: B β†’ C, then S ∘ R: A β†’ C

(a,c) ∈ S ∘ R if there exists b such that (a,b) ∈ R and (b,c) ∈ S

Matrix: MS∘R = MR βŠ™ MS (Boolean product)

Important: MS∘R = MR βŠ™ MS β‰  MS βŠ™ MR

Order matters in composition!

Boolean Product:
Like matrix multiplication, but:
β€’ Use ∨ (OR) instead of + (addition)
β€’ Use ∧ (AND) instead of Γ— (multiplication)
Example: Composition

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

S = {(1,6), (2,1), (4,0)}

S ∘ R:

  • (1,1) in R and (1,6) in S β†’ (1,6) in S∘R
  • (1,2) in R and (2,1) in S β†’ (1,1) in S∘R
  • (3,4) in R and (4,0) in S β†’ (3,0) in S∘R

S ∘ R = {(1,6), (1,1), (3,0)}

Operation 3: Powers of Relations

Powers:

RΒΉ = R

Rn+1 = Rn ∘ R

Matrix: MRn = MR[n] (Boolean power)

Example: Powers

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

R² = R ∘ R = {(1,1), (2,1), (3,1), (4,2)}

R³ = R² ∘ R = {(1,1), (2,1), (3,1), (4,1)}

5. Closure of Relations

Closure Concept:

For any property X, the "X closure" of a set A is the smallest superset of A that has property X.

We add the minimum number of elements to R to make it satisfy the property.

1. Reflexive Closure

Reflexive Closure of R:

Add (a,a) to R for each a ∈ A not already in R

Formula: R βˆͺ IA

where IA = {(a,a) | a ∈ A} is the identity relation

Example: Reflexive Closure

R = {(1,1), (1,2), (2,1), (3,2)} on A = {1, 2, 3}

Missing: (2,2) and (3,3)

Reflexive Closure = {(1,1), (1,2), (2,1), (3,2), (2,2), (3,3)}

2. Symmetric Closure

Symmetric Closure of R:

Add (b,a) to R for each (a,b) in R where (b,a) is not already in R

Formula: R βˆͺ R-1

where R-1 = {(b,a) | (a,b) ∈ R} is the inverse relation

Example: Symmetric Closure

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

Missing reverse pairs: (2,1) and (1,3)

Symmetric Closure = {(1,1), (2,2), (1,2), (3,1), (2,3), (3,2), (2,1), (1,3)}

3. Transitive Closure

Transitive Closure of R:

Repeatedly add (a,c) to R for each (a,b) and (b,c) in R where (a,c) is not already present

Formula: R* = R βˆͺ RΒ² βˆͺ RΒ³ βˆͺ ... βˆͺ Rn

where n = |A| (size of set A)

Matrix: MR* = MR ∨ MR[2] ∨ ... ∨ MR[n]

Example: Transitive Closure

R = {(1,1), (1,2), (2,1), (3,2)} on A = {1, 2, 3}

R² = R ∘ R = {(1,1), (1,2), (2,1), (2,2), (3,1)}

R³ = R² ∘ R = {(1,1), (1,2), (2,1), (2,2), (3,1), (3,2)}

Transitive Closure R* = R βˆͺ RΒ² βˆͺ RΒ³

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

Summary: Computing Closures

Closure Type Formula What to Add
Reflexive R βˆͺ IA All (a,a) pairs
Symmetric R βˆͺ R-1 Reverse of each pair
Transitive R βˆͺ RΒ² βˆͺ ... βˆͺ Rn All paths of length β‰₯ 2

6. Equivalence Relations

Equivalence Relation:

An equivalence relation on a set A is any binary relation on A that is:

  1. Reflexive
  2. Symmetric
  3. Transitive
Key Concept: Equivalence relations partition a set into groups where elements in each group are "equivalent" to each other.
Example 1: Equivalence on Real Numbers

R = {(a,b) | a - b is an integer} on the set of real numbers

Check Reflexive: a - a = 0, which is an integer βœ“

Check Symmetric: If a - b is an integer, then b - a = -(a-b) is also an integer βœ“

Check Transitive: If a - b and b - c are integers, then a - c = (a-b) + (b-c) is also an integer βœ“

Conclusion: R is an equivalence relation!

Example 2: Congruence Modulo n

R = {(a,b) | a ≑ b (mod n)} - "a congruent to b modulo n"

This means n divides (a - b)

This is an equivalence relation and partitions integers into n equivalence classes:

  • [0] = {..., -6, -3, 0, 3, 6, ...} (for mod 3)
  • [1] = {..., -5, -2, 1, 4, 7, ...}
  • [2] = {..., -4, -1, 2, 5, 8, ...}

Applications of Equivalence Relations

Common Examples:

  • Equality (=): The most basic equivalence relation
  • Same age: People with the same age are equivalent
  • Same birthday: People born on the same day
  • Congruence modulo n: Numbers with same remainder when divided by n
  • Similar triangles: Triangles with same angles

Quick Check for Equivalence Relations

Checklist:
β˜‘ Reflexive: (a,a) for all a?
β˜‘ Symmetric: If (a,b) then (b,a)?
β˜‘ Transitive: If (a,b) and (b,c) then (a,c)?

If ALL THREE are YES β†’ Equivalence Relation!

πŸ“ Quick Reference Guide

Property Quick Check

To Check If... Matrix Check Graph Check
Reflexive All 1's on diagonal Loop at every vertex
Symmetric M = MT All edges bidirectional
Transitive Check M[2] βŠ† M Complete all triangles
Equivalence Reflexive + Symmetric + Check RΒ² βŠ† R All three properties

Common Mistakes to Avoid

⚠️ Warning:
  • Don't confuse "not reflexive" with "irreflexive"
  • Don't confuse "not symmetric" with "antisymmetric"
  • Remember: Composition order matters! S ∘ R β‰  R ∘ S
  • For transitive closure, you may need multiple powers (up to Rn)
  • Boolean operations: ∨ is OR, ∧ is AND (not regular +, Γ—)

Formulas to Remember

Key Formulas:
β€’ Reflexive Closure: R βˆͺ IA
β€’ Symmetric Closure: R βˆͺ R-1
β€’ Transitive Closure: R* = R βˆͺ RΒ² βˆͺ RΒ³ βˆͺ ... βˆͺ Rn
β€’ Composition: MS∘R = MR βŠ™ MS
β€’ Union: MR₁βˆͺRβ‚‚ = MR₁ ∨ MRβ‚‚
β€’ Intersection: MRβ‚βˆ©Rβ‚‚ = MR₁ ∧ MRβ‚‚