Connecting Elements
You’ve seen functions. A function connects each input to exactly one output.
But what if we want more flexibility?
- A person can be friends with many people
- A number can divide many other numbers
- A city can be connected to several other cities
This is where relations come in.
What is a Relation?
Remember Cartesian products? If you have sets and , then is all ordered pairs .
A relation from to is a subset of .
That’s it. Pick some pairs from , and you have a relation.
Example: Let and .
The Cartesian product has all 6 pairs:
A relation is any subset of this. For instance:
This relation connects 1 to a, 2 to b, and 3 to a.
Relations on a Single Set
Most often, we study relations from a set to itself.
A binary relation on is a subset of .
These are the interesting ones. They describe how elements of a set relate to each other.
Examples
“Less than” on :
Which pairs satisfy ?
“Divides” on :
Which pairs satisfy ” divides “?
| divides… | |
|---|---|
| 1 | 1, 2, 3, 4, 6 |
| 2 | 2, 4, 6 |
| 3 | 3, 6 |
| 4 | 4 |
| 6 | 6 |
So the relation is:
“Equality” on any set:
The pairs where both elements are the same:
On , this is .
Notation
If is a relation and , we write:
This reads: ” is related to ” or ” R “.
Examples:
| Relation | Notation | Meaning |
|---|---|---|
| Less than | is in the “less than” relation | |
| Divides | is in the “divides” relation | |
| Equality | is in the “equals” relation |
You’ve been using relations all along. Now you know what they really are.
Relations vs Functions
A function is a special kind of relation.
| Relation | Function | |
|---|---|---|
| Each input can connect to… | Any number of outputs | Exactly one output |
| and both in ? | Allowed | Not allowed |
Every function is a relation. But not every relation is a function.
Example: “Is a parent of”
- Alice is a parent of Bob
- Alice is a parent of Carol
The pairs and are both in the relation.
This is not a function, since Alice maps to two people.
But it’s a perfectly valid relation.
Why Relations Matter
Relations let us describe:
- Orderings: less than, divides, subset of
- Equivalences: same age as, congruent to, equivalent to
- Connections: is friends with, is adjacent to, links to
The next step is understanding what properties a relation can have.