Chapter 9 - Relations¶
约 3029 个字 8 行代码 预计阅读时间 15 分钟
Section 1 Relations and Their Properties¶
Binary relation¶
A binary relation
- A binary relation
is a set Example:
Let
and . Then
n-ary relation¶
Let
Relations On A Set¶
Let
There are
Properties of Binary Relations¶
Reflexive 自反关系¶
A binary relation
Matrix:All the elements on the main diagonal of the matrix of a reflexive relation are 1s.
Digraph: There is a loop at every vertex of a reflexive relation.
Irreflexive 非自反关系¶
A binary relation
Matrix: All the elements on the main diagonal of the matrix of an irreflexive relation are 0s.
Digraph: There is no loop at any vertex of an irreflexive relation.
Symmetric 对称关系¶
A binary relation
Matrix: If
Example:
,
Digraph: If there is an edge from vertex
Antisymmetric 反对称关系¶
A binary relation
Matrix: If
Example:
,
Digraph: If there is an edge from vertex
One relation can be both symmetric and antisymmetric. For example, the relation
Asymmetric 非对称关系¶
A binary relation
Matrix: If
Example:
,
Digraph: If there is an edge from vertex
Transitive 传递关系¶
A binary relation
Matrix: If
Example:
,
Digraph: If there is a path from vertex
The logical operations of matrices¶
Let
Union:
Intersection:
Difference:
Complement:
Inverse Relations¶
Let
More formally,
. Matrix of
is .
Composition of Relations¶
Let
More formally,
. Matrix of
is . 注意:
.
Section 2 Closure of Relations¶
Closure of Relations¶
Definition: Let
人话:
How to proof a relation is the closure of another relation?
- contain
. - have property
. - is the smallest set that contain
and have property .
Reflexive Closure¶
Let
More formally,
, where . Matrix of
is . Digraph of
is the digraph of with a loop at each vertex.
Symmetric Closure¶
Let
More formally,
. Matrix of
is . Digraph of
is the digraph of adding an edge from vertex to vertex whenever there is an edge from vertex to vertex .
Transitive Closure¶
Let
Theorem: Let
be a relation on a set . There is a path of length from to if and only if .
More formally,
. Matrix of
is , until .
Warshall's Algorithm:
for (k = 1 ;k <= n; k++)
{
for (i = 1; i <= n; i++)
{
for (j = 1; j <= n; j++)
w_{ij} = w_{ij} ∨ (w_{ik} ∧ w_{kj});
}
}
The complexity of Warshall's algorithm is
计算方法:关于k,新元素=元素+同列第k行的元素
Section 3 Equivalence Relations¶
Equivalence Relations¶
Definition: A relation
- reflexive
- symmetric
- transitive
Example: The similarity relation on the set of all triangles in the plane is an equivalence relation.
Equivalence Classes¶
Definition: Let
More formally,
. Example:Congruence Modulo
. [0] =
[1] =
[2] =
The set of all equivalence classes of
is denoted by .
Partition of a Set¶
Definition: A partition of a set
for . . for all .
Notation:
Equivalence Relations and Partitions¶
Theorem: Let
Theorem: Let
Q:If
A:
Operations on Equivalence Relations¶
If
is an equivalence relation on . is a reflexive and symmetric relation on . is an equivalence relation on .
Partial Orderings¶
Definition: A relation
- reflexive
- antisymmetric
- transitive
和等价关系的区别:等价关系是对称的,而偏序关系是反对称的。
Notation:
Example:
is a poset.
Notation:
Comparability:
Totally ordered set: If every two elements of a poset are comparable, then the poset is called a totally ordered set or a chain.
Example:
is a totally ordered set. Example:
is a poset but not a totally ordered set.
Well-ordered set: A poset
Example:
is a well-ordered set.
The principle of well-ordering induction:
假设
Lexico-graphic order: Let
Theorem: Let
Hasse Diagrams¶
Hasse diagram: A Hasse diagram of a poset
没有箭头,没有环,没有重复的边。
Example:
, , is the Hasse diagram of .
original digraph:
Hasse diagram:
Maximal element: An element
Minimal element: An element
Greatest element: An element
Least element: An element
In the last example,
are maximal elements, is a minimal element, there is no the greatest element, is the least element.
Upper bound: Let
Least upper bound: Let
Lower bound: Let
Greatest lower bound: Let
此时是对于集合而言的,而不是对于元素而言的。
只要求小于等于,所以该集合中的元素可以是集合的上界,也可以是集合的最小上界。
Example:
, ,
the upper bounds of
: . the lower bounds of
: . the upper bounds of
: . the lower bounds of
: . lub and glb of
: . lub and glb of
: .
Lattices¶
Lattice: A poset
Example:
is a lattice. lub: the larger one.
glb: the smaller one.
Example:
is a lattice. lub: the least common multiple.
glb: the greatest common divisor.
Example:
is a lattice. lub: the union.
glb: the intersection.
Topological Sortings¶
拓扑排序:对于一个有向无环图,将所有的顶点排成一个序列,使得对于每一条边