# Applications of Relations

(関係の応用)

## Discrete Mathematics I

### 10th lecture, Nov. 27, 2015

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

# Today's Schedule

• Summary, leftovers, 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

# Video

Often they are already available on Monday.

# Leftovers from Last Lecture

Representations of relations: Matrix, table, graph; inverse relations

# Summary of Last Lecture

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

# Composition of Relations

• For two relations P (from A to B) and Q (from B to C), we can define the composition R of P and Q
• We write the composition R of P and Q as R = PQ
• R = {(x, z) | (x, y) ∈ P, (y, z) ∈ Q}
• The composition of two relations corresponds to the matrix multiplication of their matrix representations
(However, scalar multiplication and addition in the matrix multiplication are replaced by logical conjunction and disjunction)
• Attention: Depending on the field of mathematics, sometimes QP is also used
• PQ is derived from matrix multiplication
• QP is derived from function composition
(the composition of functions p() and q() is q(p())
• In this lecture, we use PQ

# Examples of Composition of Relations

Example 0: P: Set of (player, team) tuples (e.g. soccer or volleyball; (Keisuke Honda, AC Milan)); Q: Set of (team, hometown) tuples (e.g. (AC Milan, Milan)); R = PQ: Set of (player, hometown) tuples (e.g. (Keisuke Honda, Milan)).

Example 1: P: Set of (parent, child) tuples; PP: Set of (grandparent, grandchild) tuples

Example 2: T: Trips made by riding on a single train ((Fuchinobe, Nagatsuta) ∈ T) → trips made by changing trains once (i.e. two train rides): (Fuchinobe, Shibuya) ∈ TT

# 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 knowing each other), ...
• 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
• Examples: =, sibling, spouse, 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.
• Examples: =, <, ≤, divisible, anchestor, descendant, ...
• How to check: In the matrix representation, check that for each entry 1 not on the (main) diagonal, the entry in 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 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 R (i.e. if RR = R), then R is transitive.

# 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;
}```

Trying to calculate 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
• For 4 relations, RR is transitive
• 1 relation alternates between two states [R = (0 1, 1 0) = Rx (odd(x)); (1, 0, 0, 1) = Ry (even(y))]

Relations on sets of size 3:

• 123 relations are transitive
• 252 relations are transitive from R2
• 66 relations are transitive from R3
• 18 relations are transitive from R4
• 6 relations are transitive from R5
• 33 relations alternate between two states
• 12 relations alternate between two states starting with R2
• 2 relations alternate between 3 states

# 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: father (x) = y (the father of x is y)
• Example of predicate: father (y, x) (y is the father 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 (logic: predicates; databases,...: relations)

# Equivalence Relation

• Examples: People with the same birthday, month of birth, year of birth, 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 {}
• 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:
x < y, x = y, x > y, or 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 if and 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

# Total Order

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

either bc or cb, then

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

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

# This Week's Homework

Deadline: December 3, 2015 (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. Two combinations need 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: Present the 16 combinations in a table similar to the tables used in the homework of lecture 4.

# Glossary

composition

matrix multiplication

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)