# Relations

(関係)

## Discrete Mathematics I

### 9th lecture, Nov. 20, 2015

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

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

• Summary and homework for last lecture
• Pascal's triangle and combinations
• Factorial and neutral element
• Relations:
• Tuples
• Cross products
• Relations
• Representations of relations
• This week's homework

# Summary of Last Lecture

• Sets are a central concept of Mathematics
• Representation of sets: Denotation, connotation, Venn diagram
• Member (bA), subset (BA), powerset (P(A)), universal set (U)
• Set operations: Union, intersection, difference, complement, powerset
• Sets of numbers: Natural numbers (ℕ), integers (ℤ), rationals (ℚ), reals (ℝ), complex numbers (ℂ)
• Laws for sets (parallel to laws for Boolean operations)

# Pascal's Triangle

(Pascal's triangle)

Start with a single `1` in the first row, surrounded by zeroes (`(0 ... 0) 1 (0 ... 0)`).
Create row by row by adding the number above and to the left and the number above and to the right.

```                  1
1   1
1   2   1
1   3   3   1
1   4   6   4   1
1   5  10  10   5   1
1   6  15  20  15   6   1
1   7  21  35  35  21   7   1
1   8  28  56  70  56  28   8   1```

# Subsets and Pascal's Triangle

• For a set A with |A| = n, we can write
|{B|BA∧|B|=m}| as nCm
• nCn = 1 (the only subset of size n is A itself)
• nC0 = 1 (the only subset of size 0 is {})
• nCm = n-1Cm-1 + n-1Cm (n>0, 0<m<n)

# Subsets and Combinations

• Combinatorics is very important for Information Technology
• Combinatorics deals with counting the number of different things under various conditions or restrictions
• The word combinations refers to the choices of a given size from a set without repetitions and without considering order
• This is the same as the subsets of a given size
• The number of combinations is written nCm
• There are also permutations (considering order), repeated permutations, and repeated combinations

# Direct Formula for Combinations

• nCm = n!/(m! (n-m)!)

(prove it as a homework)

# Factorial

Notation: n!

Definition: n! = 1 · 2 · ... (n-1) · n = ∏ni=1 i

(∏ is called product)

Question:

1! = 1

0! = 1

# Neutral Element of an Operation

(also unit element, identity element)

• Neutral element of addition: 0
• Neutral element of multiplication: 1
• Neutral element of set union: {}
• Neutral element of set intersection: U
• Neutral element of conjunction: true
(this is the reason why ∀x∈{}: R(x) = true)
• Neutral element of disjunction: false
• Neutral element of substraction:

# Structure of a Program to Calculate Sums, ...

Concrete example (sum):

```int sum = 0;
for (i=0; i<end; i++)
sum += array[i];```

## General Structure

In programming language C:

```type result = 単位元;
for (i=0; i<end; i++)
result = result 演算子 array[i];```

In programming language Ruby:

```array.inject(単位元) do |memo, next|
memo 演算子 next
end```

# Relations

• Importance of relations in IT
• Definition of relation
• Representation of relations

# Importance of Relations for IT

• Relational databases
• Relations and graphs
• Relations and logical operations

# Tuples

• Sets are not ordered. Tuples are ordered.
• An ordered pair is a tuple with two elements.
• The ordered pair of a and b is written (a, b).
• {a, b} = {b, a}. (a, b) ≠ (b, a).
• An n-tuple is an ordered sequence of n elements.
• Tuples with a fixed number of elements are called
triple (3), quadruple (4), quintuple (5), sextuple (6), septuple (7), octuple (8), nonuple (9),...
• Example: Quadruple of (lecture, teacher, room, student)
(Discrete Mathematics I, Martin J. Dürst, E202, Hanako Aoyama)

# Cartesian Product

• The Cartesian product (set) of two sets A and B is the set of all ordered pairs of elements from A and B.
• The Cartesian product of A and B is written A × B.
• A × B = {(x, y) | xA, yB}
Example: A = {2, 3}, B = {5, 6}, A × B = {(2, 5), (2, 6), (3, 5), (3, 6)}
• Size of A × B: |A × B| = |A|·|B|
• Instead of A × A, one often writes A2.
• The Cartesian product is also defined for more than two sets.
Example 1: Cartesian product of A, B, C, D:
A × B × C × D = {(x, y, z, v) | xAy ∈ B ∧ z ∈ C ∧ v ∈ D}
Example 2: Cartesian product of lectures, teachers, rooms, students
(totally about 3000×1000×200×20000 ≅ 1013 quadruples)

# Definition of Relation

• A relation R between two sets A and B is defined as a subset of A × B.
• Example: A = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, B = {3, 4}; R is the relation "is divisible by"
R = {(3, 3), (6, 3), (9, 3), (4, 4), (8, 4)}
• (a, b) ∈ R can be written as aRb.
Examples: a>b,...
• A relation between two sets is called a binary relation.
There are also ternary relations, and so on.
• A binary relation between A and A is called a binary relation on A.
Example: A = {1, 2, 3, 4, 5}, a>b: {(2,1), (3,1), (4,1), (4,2), (5,2), (4,3), (5,1), (3,2), (5,3), (5,4)}

# Representation of Relations

• A relation is a set. We can therefore use set representations:
• Denotation
Example: R = {(3, 3), (6, 3), (9, 3), (4, 4), (8, 4)}
• Connotation
Example: R = {(x, y)| xA, y ∈ B, x mod y = 0}
• Matrix representation
• Table representation
• Graph representation

# Matrix Representation

A relation between sets A and B is represented as a matrix where:

• Each row of the matrix corresponds to an element of A
• Each column of the matrix corresponds to an element of B
• If the row and column elements are related,
the entry is 1 (true), otherwise 0 (false)

Matrix representation is suited for binary relations.

A matrix with only 1 or 0 as entries is called a logical matrix (also binary matrix, relation matrix, or Boolean matrix)

# Table Representation

A relation between several sets is represented in a table as follows:

• Use a column for each set of the relation
(i.e. two columns for a binary relation, three columns for a ternary relation)
• Use a row for each element of the relation (each tuple)

Table representation is suited for relations of any arity.

Table representation is suited for sparse relations
(relations with very few entries).

Table representation is used in relational databases.

# Graph Representation

A relation between sets A and B is represented as a graph as follows:

• The elements of A and B are represented as vertices.
• A relation from an element of A to an element of B is represented as a directed edge between the corresponding vertices.
• If the vertices of A and B are well separated (e.g. A on the left, B on the right), then there may be no need to indicate direction.
• For a binary relation on A, the vertices are often drawn only once.

Graph representation is suited for binary relations.

# Inverse Relation

• The inverse relation of R is written R-1.
• The inverse relation of a binary relation is the relation with the order of the pairs reversed.
• Example: R = {(3, 3), (6, 3), (9, 3), (4, 4), (8, 4)}
R-1 = {(3, 3), (3, 6), (3, 9), (4, 4), (4, 8)}
• xRyyR-1x
• (R-1)-1 = R

# This Week's Homework

Deadline: November 26, 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)

1. Prove nCm = n!/(m! (n-m)!) for n>0, 0<m<n-0 using nCm = n-1Cm-1 + n-1Cm
2. Describe three relations from the real world that can be expressed as mathematical relations, including examples of elements in the relation.
Example: Teachers and lecture halls: The relation is true if a teacher t teaches in lecture hall l. Example elements: (Martin Dürst, E-202), (Martin Dürst, E-203).
There will be a deduction if different students submit the same relation.

# Glossary

Pascal's triangle
パスカルの三角形
combinatorics

combination

permutation

repeated combination

repeated permutation

factorial

product (∏)

neutral element

relational database

tuple
タプル
ordered pair

n-tuple
n 項組、n 字組
triple

quadruple

quintuple

sextuple

septuple

octuple

nonuple

Cartesian product (set)

definition

divisible

binary relation
2項関係
ternary relation
3項関係
(binary) relation on A
A の中の関係、A の上の関係、A における関係
representation

matrix

row
column

correspond to
と対応する
arity
アリティ
sparse
スパース、まばら (な)
vertex (plural: vertices)

edge
directed

opposite

inverse relation