# Applications of Relations

(関係の応用)

## Discrete Mathematics I

### 10th lecture, December 7, 2018

http://www.sw.it.aoyama.ac.jp/2018/Math1/lecture10.html

### Martin J. Dürst # Today's Schedule

• Leftovers, summary, and homework for last lecture
• Composition of relations
• Classification of relations: Reflexive, symmetric, antisymmetric, transitive
• Equivalence relations, equivalence classes, and partitions
• Partial and total orders
• This week's homework

# Summary of Last Lecture

• Definition of a relation: Subset of Cartesian product, set of tuples
• Representations of relations: Denotation, connotation, matrix, table, graph
• Inverse relations

# Last Week's Homework Examples of Relations

Comment: Homework can also be submitted in Japanese

Sorry, it was removed! :)

# Properties of Relations

A binary relation on A can be:

1. Reflexive: xA:xRx; ∀xA: (x, x) ∈ R
2. Symmetric: ∀x, yA: xRyyRx;
x, yA: (x, y) ∈ R ⇔ (y, x) ∈ R
3. Antisymmetric: ∀x, yA: xRyyRxx=y
4. Transitive: ∀x, y, zA: xRyyRzxRz

# Reflexive Relation

• Definition: In a reflexive relation R, ∀xA: (x, x) ∈ R
• Examples: =, ≤, ≧, divisible, subset, knows (people know themselves), ...
• How to check: In the matrix representation, check that all entries on the (main) diagonal are 1

# Symmetric Relation

• Definition: In a symmetric relation R, ∀(x, y)∈R: (y, x) ∈ R; R = R-1
• Examples: =, sibling (brother or sister), spouse (husband or wife), friend??, ...
• How to check: The matrix representation is identical with its transposition.
(The transposition of a matrix is its rotation or mirroring along the (main) diagonal.)

# Antisymmetric Relation

• Definition: A relation R is antisymmetric if ∀x, yA: xRyyRxx=y.
Alternative: ∀x, yA, xy: (x, y)∈R → (y, x)∉R
• Examples: =, <, ≤, >, ≧, divisible, parent, child, anchestor, descendant, ...
• How to check: In the matrix representation, check that for each entry 1 not on the (main) diagonal, the entry in the opposite position (mirrored along the (main) diagonal) is 0. In other words, of the two opposite entries, at most one can be 1.
• Antisymmetric relation is not the opposite of symmetric relation.
• The opposite of symmetric relation (i.e. a relation that is not symmetric) is called asymmetric relation.

# Transitive Relation

• Definition: If and only if for all x, y, and z, xRyyRzxRz, then R is transitive.
(∀x, y, z: xRyyRzxRz) ⇔ R is transitive
• Examples: =, <, >, ≤, ≥, descendant, anchestor, divisible, ...
• How to check: Compose R with itself. If the result is in R (i.e. if RRR), then R is transitive.

# Additional Observations

• A relation for which RR = R is called idempotent
• All idempotent relations are transitive
• Relations that are reflexive and transitive are idempotent
• There are some idempotent relations that are not reflexive

# Transitive Closure

• The transitive closure of a relation R is the result of repeatedly concatenating R with itself until the result does not change anymore
RR∘R∘...
• "Repetition until there is no change anymore" is a frequent concept in Information Technology
• In the programming language C, this is the general structure:
```int change = 1;
while (change) {
change = 0;
/* process data */
if (/* data changed */)
change = 1;
}```

# Cautions about Transitive Closure

Calculating the transitive closure of a relation may not be possible.

The calculation may not converge to a fixpoint.

Relations on sets of size 2:

• 11 relations are transitive
• 4 relations reach transitive closure at RR
• 1 relation alternates between two states [R = (0 1, 1 0) = R2n+1; (1, 0, 0, 1) = R2n)]

# Relations and Functions

• An n-ary relation is a function f from n arguments to a Boolean value (T/F)
R = {(x, y, z) | f(x, y, z)=T }
• A function returns only one result for each input
• An n-ary relation can be seen as a function g with n-1 arguments and a set as a return value
g(x, y) = {z | (x, y, z) ∈ R}
• A function with n-1 arguments can be expressed as an n-ary relation
f(x, y) = zR = {(x, y, z) | f(x, y) = z}

# Relations and Predicates

• Example of function: parent (x) = y (the parent of x is y)
• Example of predicate: parent (y, x) (y is the parent of x)
• Predicates express properties (mainly predicates with 1 argument) and relations (predicates with 2 or more arguments)
• Relations and predicates are very closely related concepts
• The difference is mostly in field of use:
predicates: logic
relations: structure, databases

# Equivalence Relation

• Examples: People with the same birthday, the same month of birth, the same year of birth, the same zodiac sign; people from the same prefecture/country, cities in the same prefecture/country
• An equivalence relation is a relation that is reflexive, symmetric, and transitive
• An equivalece relation allows to define the set of all elements related to a given element a
• Such sets are called equivalence classes, and written [a]
([a] = {x|xRa})
• a is a representative (element) of [a]
• An equivalence relation creates a partition of the original set A
• A partition is a set of sets so that:
• The union of these sets is the original set A
• The intersection of any two distinct sets in the partition is {}
(∀a, b: a∈[b] ∨[a]∩[b]={})
• The Cartesian product is also an equivalence relation
(where the partition consists of a single set, namely A itself)

# Partial Order

• If a relation is reflexive, antisymmetric, and transitive, then it is called a partial order relation
• This is also often just called an order relation
• The set on which the relation is defined is called a partially ordered set or just an ordered set
• The symbol ≤ is often used for order relations
• For any order relation ≤, the order relation ≥ and the relations > and < are also defined
• In any order relation, two elements x and y can be in any of four mutually exclusive relationships:
1. x < y
2. x = y
3. x > y
4. There is no relationship between x and y

# Examples of Order Relations

• The divisible by relation on the set of integers ≥1, or a subset thereof
• The subset relation on a set of sets

Some examples need a careful definition:

• The relation on a set of tasks, where some tasks need be done before or at the same time as others
• The relation "stronger than or as strong as" in a Tennis tournament, defined by (the transitive closure of) the tournament results

# Hasse Diagram

An order relation can be represented by a Hasse diagram.

How to convert a directed graph of an order relation to a Hasse diagram:

1. Remove arrows that indicate reflexivity
2. Rearange the vertices of the graph so that all arrows point upwards (or downwards)
3. Remove the arrows that can be reconstructed using transitive closure
4. Remove the arrowheads

Example: The relation "divisible by" on the set {12, 6, 4, 3, 2, 1}

# Equivalence Relations and Order Relations in Matrix Representation

• The elements in a set A are not ordered
• Therefore, we can exchange (permute) the rows and the columns in the matrix representation of a relation on A if and only if we use the same permutation for both rows and columns.
• A relation on a set A is an equivalence relation if and only if we can permute the rows and columns so that we obtain the following:
• The areas of 1s form squares
• The centers of the squares are on the (main) diagonal of the matrix
• The squares do not overlap
• The entries on the (main) diagonal are all 1
• A relation on a set A is an order relation only if we can permute the rows and columns so that we obtain the following:
• All entries below the (main) diagonal [or above] are 0
• All entries on the (main) diagonal are 1
• The relation is transitive (separate check needed)

# Total Order

If for all elements b and c in a set A,

if either bc or cb, then

≥ is a total order (relation) or linear order (relation)

(∀b, cA: bccb ⇔ ≥ is a total order on A)

The Hasse diagram of a total order is a single line, without branches

Examples: ≥ for integers or rational; dates or time; order of words in a dictionary

# Summary

• Binary relations on a set can be: Reflexive, symmetric, antisymmetric, transitive
• Transitive closure is an operation often used in Information Technology
• Equivalence relations define a partition into equivalence classes
• (Partial) order relations can be represented with Hasse diagrams

# This Week's Homework

Deadline: December 12, 2018 (Thursday), 19:00.

Format: A4 single page (using both sides is okay; NO cover page), easily readable handwriting (NO printouts), name (kanji and kana) and student number at the top right

Where to submit: Box in front of room O-529 (building O, 5th floor)

Investigate all combinations of the four properties of relations introduced in this lecture (reflexive, symmetric, antisymmetric, transitive). For each combination, give a minimal example or explain why such a combination is impossible.

Hint: There are 16 combinations. Two combinations are impossible. One combination needs a set of four elements for a minimal example. Three combinations need a set of two elements for a minimal example. Two combinations need a set of one element for a minimal example. The other combinations need a set of three elements for a minimal example.

Hint: Use {a, b, c} for a set with three elements.

Hint: Start with small sets and check properties.

Hint: Present the 16 combinations in a table similar to the tables used in the homework of lecture 4.

Additional homework: Bring some small scissors to the next lecture.

# Glossary

reflexive relation

(main) diagonal
(主) 対角線
symmetric relation

(matrix) transposition
(行列) 転置
sibling

antisymmetric relation

opposite

asymmetric relation

transitive relation

descendant

anchestor

transitive closure

converge

fixpoint

equivalence relation

equivalence class

representative (element)

partition

partial order

partial order relation

order relation

partially ordered set

ordered set

mutually exclusive

Hasse diagram
ハッセ図
vertex (plural vertices)
(グラフの) 節、頂点
reconstruct

square

overlap

total order (relation)