# Applications of Relations

(関係の応用)

## Discrete Mathematics I

### 10th lecture, December 13, 2019

https://www.sw.it.aoyama.ac.jp/2019/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 and composition of relations

# Last Week's Homework Examples of Relations

Comment: Homework can also be submitted in Japanese

Describe three relations from the real world that can be expressed as mathematical relations.
For each relation, describe the sets used (including their size), the conditions for a tuple to be a member of the relation, the size of the Cartesian product, and the size of the relation, and give three examples of tuples belonging to the relation.

1. A binary relation on a single set.

Example solution: Relation on set of train stations (size ~1'000 for Kanto region), tuples of stations that can be reached from each other without changing trains, size of Cartesian product: ~1'000'000, size of relation ~50'000.
Examples of tuples: (Fuchinobe, Nagatsuta), (Nagatsuta, Shibuya), (Hashimoto, Shinjuku); counterexample: (Fuchinobe, Shibuya)

2. A binary relation between two different sets.

Example solution: Marriage: Relation between a set of men and a set of women, for both sets, the size is ~4·109, size of Cartesian product is ~16·1018, size of relation is ~2·109
Examples of tuples: (Daigo, Keiko Kitagawa), (Yoshitomo Tani, Ryoko Tani (née Tamura)), (Tom Brady, Giselle Bündchen)

3. A relation between more than two sets.

Example solution: Baseball: Relation between set of teams (~100), set of players (~10000), set of positions (9), and set of numbers in batting order (9), size of Cartesian product is ~81'000'000, size of relation is ~900
Example (outdated): (Miami Marlins, Ichiro Suzuki, right field, 1st),...

# 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 (for ℕ+), 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.

• 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 composing 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;
}```

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

• An equivalece relation allows to define the set of all elements related to a given element a
• 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
• 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

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 17, 2019 (Monday), 17: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 an example relation on the minimum size set possible, or explain why such a combination is impossible. Present the 16 combinations in a table similar to the tables used in the homework of lecture 4. In the table, also include a column with the minimum size of the set on which the example relation is formed. Use {b}, {b, c}, and {b, c, d} for sets with one, two, and three elements, respectively.

Hint: Two combinations are impossible. One combination is possible with a relation on an empty set. One combination is possible with a relation on a set of size one. Four combinations are possible with a relation on a set of size two. The other combinations need a relation on a set of size three.

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)