9 minute read

1. Relation (Mathmatics)Permalink

Wikipedia 写得挺好,这里总结一下。

1.1 DefinitionPermalink

Given a set X, a relation R over X is a set of ordered pairs of elements from X, formally: R{(x,y)x,yX}.

  • 你也可以扩展成 R{(x,y)(x,y)X×Y},但这么定义就排除了 (y,x) 形式的元素 (类型不匹配)

符号上有:

  • (x,y)R 也可以写作 infix 形式 xRy,意思就是 “x,y 满足 R 关系”
  • 自创用法:我在本文用 xRy 表示 “x,y 不满足 R 关系”
  • 自创用法:我在本文用 xRy 表示 “x,yR 下是 incomparable 的”
    • i.e. xRyxRyyRx

1.2 Representation of RelationsPermalink

如果 X 是一个 discrete 的集合,R 的 size 有限,那么可以 R 可以表示成:

  1. directed graph: 每一组 xRy 都用一条 xy 的 edge 表示
  2. boolean matrix: 每一组 xRy 都表示 Mx,y=1,每一组 xRy 都表示 Mx,y=0
    • 如果 xRy,那么 Mx,y 就是 undefined,此时 M 也不能算是 boolean matrix 了

如果 XR

  • 每一组 xRy 都可以看作是坐标系下的一个点,所以 R 也可以表示成一个 2D plot
    • 比如 R={(x,y)x2+y2=1}

1.3 Properties of RelationsPermalink

1.3.1 ReflexivityPermalink

Reflexive: xX,xRx

Irreflexive: xX,xRx

我们可以完全不用它的英文名字,也不用管中文翻译 (因为后面对称性的命名简直灾难!),结合 boolean matrix representation 来记忆:

  • reflexive 就是主对角线全是 1,比如 M1
  • irreflexive 就是主对角线全是 0,比如 M2
M1=[111]M2=[000]

我们说这组 properties 是 non-exhausitive 的,意思是 R 既不是 reflexive 也不是 irreflexive 的,结合 boolean matrix representation 很容易举出一个反例。

1.3.2 SymmetryPermalink

Symmetric: x,yX, xRyyRx

Asymmetric: x,yX, xRyyRx

Antisymmetric: x,yX, xRyyRxx=y

这个混乱的命名,我觉得背后的逻辑是:

  1. 从定义的形式上来看,symmetric 的定义直接加个否定就变成了 asymmetric,非常的漂亮
  2. 但这么定义下的 asymmetric 暗含了 irreflexive (因为你不可能同时有 xRxxRx),有点过于 strong
  3. relax 一下,不要求 irreflexive 的非对称,就变成了 antisymmetric

还是结合 boolean matrix representation 记忆:

  1. symmetric 就是 Mi,j=Mj,i,主对角线上随意,比如 M1
  2. asymmetric 就是 Mi,jMj,i,主对角线上全是 0,比如 M2
  3. antisymmetric 就是 Mi,jMj,i,但主对角线上随意,比如 M3
M1=[αβαγβγ]M2=[0αβα0γβγ0]M3=[αβαγβγ]

:star2: 定义上有:asymmetric antisymmetric irreflexive

同样,这组 properities 也不是 exhausitive 的,结合 boolean matrix representation 也很容易举出反例。

1.3.3 Transitivity & ConnectednessPermalink

Transitive: x,y,zX, xRyyRzxRz

Connected: x,yX, xy xRy or yRx. Or equivalently x,yX, xRy or yRx or x=y

Strongly Connected: x,yX, xRy or yRx

考虑 transitive 的特殊情况:

  1. if x=y=z,obvious implication
  2. if x=yz,obvious implication
  3. if x=zy,transitive 等价于:如果有 xyx 这样一个 loop,那么就会有 xx 的 self loop
  4. if xy=z, obvious implication
flowchart LR
  node_1(("X"))
  node_2(("Y"))
  node_1 --> node_2
  node_2 --> node_1
  node_1 --> node_1

:star2: 定义上有:transitive irreflexive transitive asymmetric

Proof: (1) 假定 R 是 transitive irreflexive. 假定 x,yX 同时满足 xRyyRx (从而不满足 asymmetric)

根据 transitive 定义,xRyyRxxRx,不满足 irreflexive,矛盾。所以 R 一定满足 asymmetric

(2) 假定 R 是 transitive asymmetric. 因为 asymmetric implies irreflexive,所以 R 一定是 irreflexive.

结合 2D plot representation 考虑 connected 和 strongly connected:

  1. connected 就是指 任意两个 node x,y,至少有一条 edge 连接它们。可以是 xy,可以是 yx,或者 both
  2. connected 并不要求有 self loop
  3. strongly connected 就是 connected 并要求 xX,都要有一个 xx 的 self loop

:star2: 定义上有:connected reflexive strongly connected

1.3.4 UniquenessPermalink

Injective: (a.k.a. left-unique) x,y,zX, xRzyRzx=y

Functional: (a.k.a. right-unique) x,y,zX, xRyxRzy=z

  • Such a relation is also called a partial function

1.3.5 TotalityPermalink

Serial: (a.k.a. left-total, or simply total) xX, 一定 yX such that xRy

  • 注意它并没有限定 y 的个数,可以有多个 yi 都满足 xRyi,至少有一个
  • Such a relation is also called a multivalued function
  • 我觉得 serial 的意思是:从一个起始 x0 出发,不断找 xiRxi+1,能得到一个 x0x1x2 的 sequence
    • The successor function used by Peano to define natural numbers is the prototype for a serial relation.

Surjective: (a.k.a right-total) yY, 一定 xX such that xRy (扩展定义 RX×Y)

1.3.6 Special Relations / Combinations of PropertiesPermalink

Orderings:

Similarity RelationR which is  reflexive  symmetric Equivalence RelationR which is  reflexive  symmetric  transitive Congruence Relationan equivalence relation R which is "compatible" with the associated operation on XPre-orderR which is  reflexive  transitive Partial OrderR which is  reflexive  antisymmetric  transitive Strict Partial OrderR which is  irreflexive  asymmetric  transitive Strict Weak Ordera strict partial order R whose incomparable relation R is an equivalence relation Total OrderR which is  reflexive  antisymmetric  transitive  connected Strict Total OrderR which is  irreflexive  asymmetric  transitive  connected 
  • 我个人认为 equivalence 可以看作是 “没有任何 order”
  • pre-order 的意思是 “almost a partial order” 或者 “one more step and you’ll get a partial order”
  • partial 的意思是 “允许存在两个元素没有 order (i.e. incomparable)”
  • total 的意思是 “任意的两个元素间都有 order (i.e. comparable)”

举例:

  • Similarity Relation: 限定误差范围内的约等于
  • Equivalence Relation: equality =
  • Congruence Relation: “congruent modulo n”, as in ab(modn)
  • Partial Order: subset
  • Strict Partial Order: strict subset
  • Strict Weak Order: 类似赛马、F-1 赛车、或者田径比赛的 ranking <
    • x<y 表示 “xy 排名靠前”
    • x=y 表示 “xy 排名相同” (成绩相同,并列第 X 名)
    • 但存在 “没有完赛” 的情况,所有没有完赛的选手的成绩是 incomparable 的,且是 equivalent 的
  • Total Order: less than or equal to
  • Strict Total Order: less than <

注意 strict subset 不是 strict weak order,原因:

  • 不是 transitive 的,所以不是 equivalence relation
  • 假设 集合 X,Y,Z
    • XYXYYX
    • YZYZZY
    • 但可能有 XZ 或者 ZX
    • e.g. X={1},Y={3},Z={1,2}

:star2: Lemma: An R which is symmetric, transitive, and serial is an equivalence relation.

Proof: 由 serial 可知 xX,y such that xRy.

再加上 symmetric,可知 xX,y such that xRy and yRx.

再加上 transitive,可知 xX,xRx, 得到 reflexive.

Uniqueness 性质的组合:

One-to-oneR which is  injective  functional One-to-manyR which is  injective ¬ functional Many-to-oneR which is ¬ injective  functional Many-to-manyR which is ¬ injective ¬ functional 

Uniqueness + Totality 性质的组合:

FunctionR which is  right-unique (functional)  left-total (serial) InjectionF which is  left-unique (injective) SurjectionF which is  right-total (surjective) BijectionF which is  left-unique (injective)  right-total (surjective) 

where F is a Function.

1.3.7 题外话:Congruence RelationPermalink

Definition: Let (S,) be an algebraic structure. Suppose is a n-ary operation. Let R be an equivalence relation on S. If x1,,xn,y1,,ynS:

x1Ry1,x2Ry2,, and xnRyn(x1x2xn)R(y1y2yn)

we call R compatible with and R is a congruence relation on S.

同理也有 “congruence class”, “x,y are congruent” 这些说法

2. Asymptotic NotationsPermalink

2.1 DefinitionsPermalink

假定有 functions f,g:Z+R+{0}

Big-Oh Notation: f=O(g) if constant c>0 and n0 such that nn0, f(n)cg(n)

  • 这个 n0 是一个 threshold,表示 “f(n)cg(n)” 这个关系是 “当 n 充分大、足够大以后” 才出现的

Big-Omega Notation: f=Ω(g) if constant c>0 and n0 such that nn0, f(n)cg(n)

Big-Theta Notation: f=Θ(g) if f=O(g)f=Ω(g)

  • 换言之,f=Θ(g) if constants c1,c2>0 and n0 such that nn0, c1g(n)f(n)c2g(n)

Little-oh Notation: f=o(g) if constant c>0, n0 such that nn0, f(n)<cg(n)

Little-omega Notation: f=ω(g) if constant c>0, n0 such that nn0, f(n)>cg(n)

2.2 Problem with those NotationsPermalink

Knuth describes such notations as “one-way equalities”, since if the sides could be reversed:

“… we could deduce ridiculous things like n=n2 from the identities n=O(n2) and n2=O(n2).”

“… the equality sign is not symmetric with respect to such notations.”

“… mathematicians customarily use the = sign as they use the word is in English: Aristotle is a man, but a man isn’t necessarily Aristotle.”

所以有的教材会写成 fO(g),也就是把 O(g) 理解成一个 function 的集合 (或者 equivalence class)。但还是不如从 relation 的角度来理解 asymptotic notations (我就是为了这口醋包了前面那么多饺子)。

2.3 Asymptotic RelationsPermalink

:star2: Lemma: Big-Oh is a Partial Order.

Proof: (1) O is reflexive, obviously.

(2) O is antisymmetric, obviously.

(3) O is transitive, obviously.

(4) O is not connected. I.e. f,g such that fOg and gOf.

E.g.

f(n)={1n is evennn is oddg(n)={nn is even1n is odd

E.g.

f(n)=1+n+n×(1)ng(n)=1+nn×(1)n

:star2: Lemma: Big-Omega is a Partial Order.

:star2: Lemma: Big-Theta is an Equivalence Relation.

Proof: (1) Θ is reflexive, obviously.

(2) Θ is symmetric.

If fΘg, then constants c1,c2>0 and n0 such that nn0, c1g(n)f(n)c2g(n).

At the same time, we have 1c2f(n)g(n)1c1f(n), so gΘf.

(3) Θ is transitive.

If fΘg, then constants c1,c2>0 and n0 such that nn0, c1g(n)f(n)c2g(n).

If gΘh, then constants c3,c4>0 and n1 such that nn1, c3h(n)g(n)c4h(n).

Therefore n=max(n0,n1) such that nn, c1c3h(n)f(n)c2c4h(n). I.e. fΘh.

:star2: Lemma: Little-oh is a Strict Partial Order.

:star2: Lemma: Little-omega is a Strict Partial Order.

Categories:

Updated:

Comments