6.关系、偏序与任务调度
介绍如题的内容。
Relations
Relations : A relation from a set
Ex :
Properties
A relation
| 例子 (Ex) | 自反 (Refl) | 对称 (Sym) | 反对称 (Anti-Sym) | 传递 (Transitive) |
|---|---|---|---|---|
| Y | Y | N | Y | |
| Y | N | Y | Y | |
| Y | N | Y | Y |
Equivalence relation
An equivalence relation is reflective, symmetric and transitive.
Ex : equality(=) itself,
The equivalence class of
Ex :
A partition of
Ex :
Theorem
The equivalence class of an equivalence relation on a set
[!Proof] 1.
。 Since is reflexive, every element a is contained in its own equivalence class . Thus, the union of all equivalence classes covers . At the same time, every equivalence class shall be the subset of . Thus, 。 From above, 。 2.
>Since is reflexive, has at least one element . 3.Disjointness If
, let .By definition, .By symmetry, . By transitivity and , . So . This way, . Thus, . By symmetry, we also have [b] ⊆ [a], hence [a] = [b].
A relation is a (weak) partial order if it is (reflexive), antisymmetric and transitive. It is denoted by
A poset is a directed graph with vertex set
Hasse Diagram
A Hasse Diagram for a poset
- all self-loops
- all the edges implied by transitivity
Theorem
A poset has no directed cycles other than self-loops.
[!Proof] By contradiction. Suppose
. By transitivity and obvious induction, we have . Thus by antisymmetry . That is a contradiction. So the original statement is right.
So after deleting self-loops from a poset, we get a DAG(directed acyclic graph).
In poset, there could be
A total order is a partial order in which every pair of elements are comparable. It could give a straight line.
A total order consistent with a partial order is called a topological sort. A topological sort of a poset is formally defined as a total order
Theorem
Every finite poset has a topological sort.
def:
[!Lemma] Every finite poset has a minimal element.
def: chain is a sequence of distinct elements such that
,where is the length of the chain. proof:
Let
be a max length chain. Then should be the minimal. Suppose : case 1: if the chain, then let be the first one we create a longer chain. That’s a contradiction. case 2: the chain. Then we could create a cycle, which could not exist according to the theorem we just proved. So that’s a contradiction. Thus, the original proposition holds.
[!Proof] By strong induction. Let
be a finite poset with . Let be the proposition itself for all integers less than . Base Case:
, is already a topological sort. Inductive step: Assume
>By lemma, with elements has minimal . Consider ${m} =A’ ≼ A’\times A’ ≼’=≼ \cap A’\times A’ P(k) (A’,≼’) a_2,…a_{k-1} m,a_2,…,a_{k-1} A (x,y)\in A x≼y \not \exists k \in A\text{ , s.t. , } k ≼ m x=m y m x\neq m \wedge y\neq m P(k) m,a_2,…,a_{k-1} A $. Finally we find a topological sort for
. So the proposition holds. In practice, we just select with zero indegree as the minimal and do it recursively.
手动翻译:
关系
关系 : 一个从集合
例如 :
性质
自反性 : 如果
| 例子 (Ex) | 自反 (Refl) | 对称 (Sym) | 反对称 (Anti-Sym) | 传递 (Transitive) |
|---|---|---|---|---|
| Y | Y | N | Y | |
| Y | N | Y | Y | |
| Y | N | Y | Y |
等价关系
一个等价关系是自反的,对称的,传递的。例如等号、同余。
一个
Ex :
一个
Ex :
定理
等价类构成
[!证明] 1.
。等价类并是 : 由自反性, 对 有 . 所以每个元素都有他们自己的等价类,因此 >同时每个等价类都是 的子集,所以 。 由上 。 2.
>因为 自反, 至少有元素 . 3.不交 如果
, 设 .由定义, .由对称性, . 由传递性和 , . 所以 . 从而 . 那么 . 同理 .综上有 .
一个关系是偏序关系如果他是自反、反对称、传递的。用
一个偏序集是有着顶点集
哈斯图
哈斯图 是偏序集
- 所有自环
- 所有传递性推出来的边
定理
偏序集对应的有向图除了自环无环。
[!证明] 用反证法。 设
. 利用传递性和简单的归纳, 有 . 从而由传递性 . 矛盾,故原命题成立。
故去掉自环后,他就成了有向无环图(DAG)。
偏序集中可能有不可比较的
全序 是所有元素都可以比较的偏序,对应一条直线。
和偏序相一致的全序叫做 拓扑排序. 偏序集的拓扑排序的正式定义由全序给出:
定理
任意有限偏序集都有拓扑排序。
定义:
[!引理] 任意有限偏序集都有最小值。
定义: 链 是不同元素的序列使得
,其中 是链的长度。 证明:
设
是最长的链. 那么 将是最小值. 设 : case 1: 如果 链, 让 是第一个顶点那么就构造了更长的链. 矛盾. case 2: 链. 那么会出现环,这与前面证明的定理矛盾。 综合可知引理成立。
[!证明] 使用加强的归纳法。 设
是满足 的有限偏序集. 设 是命题对所有 以下的正整数都成立. 奠基步:
, 已经是一个拓扑排序。 归纳步: 设
成立。 利用引理, 有最小值 . 考虑 ${m} =A’ ≼ A’\times A’ ≼’=≼ \cap A’\times A’ P(k) (A’,≼’) a_2,…a_{k-1} m,a_2,…,a_{k-1} A (x,y)\in A x≼y \not \exists k \in A\text{ , s.t. , } k ≼ m x=m y m x\neq m \wedge y\neq m P(k) m,a_2,…,a_{k-1} A $ 的拓扑排序. 我们找到了
的拓扑排序. 所以命题成立. 实际操作上,我们选择入度为 的 即为最小值了,然后删去 重复该过程即可。