Relations
Tuples
The notation is an ordered pair. And the order matters.
Paris:
- - repetition is allowed.
- (cat, dog)
("Dan", 19)
Cartesian Product
Given sets and we define the Cartesian Product to be the set
The size of is given by
A x B
-----size: 12
- ["a","b","c","D"]
- [1,2,3]
[["a",1],["a",2],["a",3],["b",1],["b",2],["b",3],["c",1],["c",2],["c",3],["D",1],["D",2],["D",3]]
A x A
-----size: 16
- ["a","b","c","D"]
- ["a","b","c","D"]
[["a","a"],["a","b"],["a","c"],["a","D"],["b","a"],["b","b"],["b","c"],["b","D"],["c","a"],["c","b"],["c","c"],["c","D"],["D","a"],["D","b"],["D","c"],["D","D"]]
bit strings
size: 4
- ["0","1"]
- ["0","1"]
[["0","0"],["0","1"],["1","0"],["1","1"]]
bit strings of length 3
size: 8
- ["0","1"]
- ["0","1"]
- ["0","1"]
[["0","0","0"],["0","0","1"],["0","1","0"],["0","1","1"],["1","0","0"],["1","0","1"],["1","1","0"],["1","1","1"]]
Random
size: 16
- [1,2,3,4]
- [5,6,7,8]
[[1,5],[1,6],[1,7],[1,8],[2,5],[2,6],[2,7],[2,8],[3,5],[3,6],[3,7],[3,8],[4,5],[4,6],[4,7],[4,8]]
More Cartesian Products
More generally we have:
- (n copies of ) - e.g.
- The size
Some Examples
- describes points on a 2-dimensional plane.
- is the set of bit strings of length .
- encodes (x,y) coordinates on a 1080p screen.
Relations
Let and be sets. A binary relation from to is a subset of .
A relation over is a subset of .
If is a binary relation then we write to mean . So is shorthand for .
Properties of Relations
Here are some special properties that a binary relation can have:
- symmetric
- reflexive
- transitive
- anti-symmetric
- irreflexive
properties of relations
Symmetric
We say a binary relation is symmetric if
That is whenever we have (a,b) we also have (b,a)
Anti-Symmetric
A relation on a set is anti-symmetric if if and , then .
- - e.g.,
- - e.g.,
- - cannot find any pair that satisfies the condition. So
\implies
will always returnTrue
.
Not anti-symmetric:
This returns False
, so is not anti-symmetric.
Reflexive
A binary relation is reflexive iff for every
Irreflexive
A binary relation is irreflexive if
Transitive
A relation on a set is transitive if
-
- let
- ✅
-
- let
- ✅
-
- let
- ✅
-
- let
- ❌
Find a counter example where it is not true.
Example
Find whether the following relation is reflexive, symmetric, anti-symmetric or transitive on
- ✅reflexive.
- ✅symmetric.
- ❌anti-symmetric.
- but
- ✅transitive. ,
- ,
- ,
Equivalence Relation
An equivalence relation is a binary relation that is:
- symmetric
- reflexive
- transitive
Let be the relation on the set of real numbers such that iff is an integer. Is this an equivalence relation?
- symmetric? -
- reflexive? -
- transitive? -
Equivalence Classes
Equivalence relation & classes
Partial Ordering
A partial ordering on a set is a binary relation over which is:
- reflexive
- transitive
- anti-symmetric
If the relation is irreflexive instead of reflexive, it is called a strict partial ordering. (without the equal sign)
Total Ordering
A total ordering is a partial ordering over that also has the property:
This means that we can always compare any two elements of .
- lexicographical ordering
If the relation is irreflexive instead of reflexive, it is called a strict total ordering. (without the equal sign)