Lecture from: 14.10.2024 | Video: Videos ETHZ
Relations
In essence, a relation is simply a connection or association between elements from two sets. Imagine you have a set of students () and a set of courses they enroll in (). A relation could describe which students take which courses. This connection can be represented as pairs: each pair links a student to the course(s) they are enrolled in.
Formally, we define a relation as:
This means that is a subset of the Cartesian product of sets and . The Cartesian product () is the set of all possible ordered pairs where the first element comes from and the second element comes from .
Example: ≤
Example: School
Let’s say:
- (Set of students)
- (Set of courses)
A relation could represent the following:
We now introduce a new set:
- (Set of teachers)
And a relation that connects subjects with their respective teachers:
Visualizing the Connections:
- Students (A): Alice, Bob, Carol
- Courses (B): Math, Physics, History
- Teachers (T): David, Emily, Frank
And the relations:
- connects students to courses they take (e.g., Alice takes Math).
- connects subjects with teachers who teach them (e.g., David teaches Math).
Inverse
Given a relation , its inverse, denoted as , is defined as:
Example: Inverse of ≤
Example: Inverse of School Example
- — “Subject is taken by Student”
- — “Teacher teaches Subject”
Example: Parent Relationship
Let us define as . Then the inverse is: .
Composition of Relations
The composition of two relations, and , is denoted as . It represents a new relation formed by applying and then .
Formal Definition:
If and , then their composition, , is defined as:
Example: Student-Subject-Teacher
- (Student takes Subject)
- (Subject is taught by Teacher)
Then (Student is taught by Teacher).
Example: Child-Parent
- (is grandparent of)
- (is half-sibling of) — The identity relation (id) is removed to exclude a person being their own half-sibling.
Proof of Lemma 3.8
Lemma 3.8:
Proof:
Visualization using Matrices
Relations can be represented visually using matrices, offering a structured way to understand their connections.
Matrix Representation:
Consider a relation on a set . We can represent this relation as a matrix where:
- The rows and columns of the matrix correspond to the elements in set .
- An entry is 1 if (meaning there’s a connection from to ) and 0 otherwise.
Example:
Let’s say . The matrix representation of would be:
Inverse Relation and Matrix Transposition:
The inverse relation of a relation is defined as: if and only if .
Importantly, the matrix representation of the inverse relation is simply the transpose of the original matrix.
Example (continued):
The inverse relation would be: . The transposed matrix is:
Properties and Rules
1. Associativity:
Composition of relations is associative. If we have three relations , , and (where ⊆ , ⊆ , and ⊆ ), then: ( ∘ ) ∘ = ∘ ( ∘ )
2. Non-Commutativity:
Composition of relations is not commutative. This means that generally, ∘ ≠ ∘ .
3. Identity Relation:
There exists an identity relation for each set, denoted as if A is our set.
- = {(, ) | ∈ } – It connects an element only to itself. Applying the identity relation doesn’t change anything.
Example with Composition: Let be a relation “student takes a subject” and be the identity relation on the set of subjects. Then: ∘ =
This means taking a subject followed by being that same subject doesn’t change anything!
4. Reflexivity, Symmetry, Antisymmetry, Transitivity, Asymmetry:
These are properties that relations can possess. A relation is:
Reflexive
If for every element ‘a’ in set A, (, ) Alternate:
Similarly irreflexive is the opposite: for every ‘a’ in A.
Symmetric
If for every pair (, ) , then (, ) Alternate:
Antisymmetric
If for every pair (, ) and (, ) , then . (If (a, b) and (b, a) are both in the relation, then ‘a’ and ‘b’ must be the same element.) Same as: Alternative: A relation is antisymmetric if it is true for all if
Transitive
If for every triple (, ), (, ) , then (, ) . Same as: Alternative: A relation is transitive if and only if .
Asymmetric
If for every pair (, ) , then (, ) . (In other words, if (a, b) is in the relation, then (b, a) cannot be.)
Transitive Closure
The transitive closure of a relation on a set is the smallest transitive relation containing . In simpler terms, it includes all pairs where there exists a path from to through , even if that path involves multiple steps.
Formalization:
Let be a relation on set . The transitive closure of , denoted as , can be defined recursively as follows:
- (The original relation is included)
- If and , then
Example: “Parent” and “Ancestor” Relationships”
Let’s say our set represents people, and the relation is defined as “is a parent of.” For instance: (John, Mary) (John is Mary’s parent)
Now, we want to find the transitive closure which would represent the “ancestor” relationship.
- Direct Parents: The initial relation includes direct parent-child pairs like (John, Mary).
- Transitive Steps: Since John is Mary’s parent, and Mary could potentially have children who are also descendants of John, we include those relationships in too.
For example:
- If Mary has a child named David, then (John, David) would be in because John is the ancestor of David through his direct relationship with Mary.
The transitive closure can grow quite large for complex relations with many elements. There are algorithms to efficiently compute the transitive closure, but it’s essential to understand its concept and how it extends a relation beyond direct connections.
Continue here: 09 Equivalency Relation and Classes, Partitions, Partially Ordered Sets