Relations
Tuples
A tuple is an ordered list of items. A tuple with two items is called a pair, and a tuple with three items is called a triple.
Cartesian Product
The Cartesian product of two sets
(see set builder notation)
More generally, the Cartesian product of
(see if and only if)
Relations
In the most general form, a relation over sets may or may not hold between respective members of each set.
Formally, a relation
We say
A unary relation is a relation over 1 set.
A binary relation is a relation over 2 sets. An example would be
A ternary relation is a relation over 3 sets. An example would be if three points are collinear, or congruency. However, we usually treat congruency as a binary relation, holding the modulo constant.
A finitary relation is a relation over a finite number of sets.
Note that number of sets does not refer to number of distinct sets. That is to say, we may have a binary relation over
Binary Relations
A binary relation over two sets may or may not hold between respective members of each set.
Formally, a relation
We say
We assign special symbols to certain binary relations, such as
Also see Properties of Binary Relations
The relation "equals" over
and we say two numbers
The relation "less than or equal to" over
and we say two numbers
This extreme formalization is useful for understanding further sections IMO.
An example to show that
Given sets:
some example relations are:
Homogeneous Binary Relation
A homogeneous binary relation is a special case of a heterogeneous binary relation (which we just called "binary relation"). Instead of the relation
Domain, Range
For a binary relation, the domain is all the first elements in the pairs of the relation. The range is all the second elements in the pairs of the relation.
For the relation
For the relation
- People who own cars
- Cars of people who both own and fix the car
- Everyone who fixes a car fixes a car fixes at least one car that they don't own
\op{dom}(\text{fix}) & \subseteq \op{dom}(\text{fix} - \text{own}) \
\op{dom}(\text{fix}) & = \op{dom}(\text{fix} - \text{own}) \
\end
For two relations
Domain properties:
Range properties (nearly identical):
Inverse Relation
For a binary relation
Think about inverse functions. We switch the
Pretty self evident
Identity Relation
The identity relation over a set
Relational Composition
For three sets
Think about function composition:
For
- Assosiative:
- Inverse distributive:
- Domain identity:
- Range identity:
- Identity:
,
I was confused about why it was a subset. Given
Domains:
| Syntax | Meaning |
|---|---|
Relational Image
For sets
Think about this almost like indexing a hashmap/dictionary.
Restrictions and Subtractions
For
Domain restriction retains only the pairs whose first elements are part of a set.
Range restriction retains only the pairs whose second elements are part of a set.
Domain subtraction retains the pairs whose first elements are not part of a set.
Range subtraction retains the pairs whose second elements are not part of a set.
For
Relational Overriding
Relational overriding allows us to "update" a relation
For
For
- Idempotent:
- Associative: