Sets

Basic Definition

Definition

A set is an unordered collection of distinct objects.

  • 无序
  • 唯一

The objects in a set are called the elements / members of the set.

A={2,3,4,5}={5,3,2,4}
Definition

Power set is set of all subsets of A
Let A={x,y}

  • pow(A)={∅,{x},{y},{x,y}}
  • |pow(A)|=2|A|

Defining Sets by Properties

背景: 有时候只靠列出所有 elements 来定义一个 sets 是不可能的,因此我们可以用公式来定义 sets,只要 element 符合公式,则为 set 的元素

Define the set by {x∈A|P(x)}.

e.g. S={x∈R|−2<x<5} means S is a real number which is in (−2,5).
e.g. S={x∈Z|x≥0} means S is non-negative integer

Definition

|S| is the size of S
e.g. |∅|=0

Membership

Definition

  • x∈A: x is an element of A
  • x∉A: x is not an element of A
  • A⊆B: A is a subset of B
    • For any x∈A, we have x∈B
    • 通俗来说: A 在 B 里面,A 可能等于 B
  • A=B: A⊆B and B⊆A
  • A⊂B: A is proper subset of B
    • A⊆B and A≠B
    • 通俗来说: A 在 B 里面,但是 A 不等于 B


Operations on Sets

A∩B={x∈U⏟Universe|x∈A and x∈B}

- Two sets are disjoint if A∩B=∅

A∪B={x∈U|x∈A or x∈B}

- |A∪B|=|A|+|B|−|A∩B|

A¯=Ac={x∈U|x∉A}

- If A⊆B, then B¯⊆A¯

A−B={x∈U|x∈A and x∉B}

- |A−B|=|A|−|A∩B|
Basic Operations on Sets.png

Indexed Collection of Sets

Tip

Indexed collection of sets 跟上文的 intersection 和 union 无异。
区别在于其支持批量运算,可以求一大堆 sets 的 intersection 和 union。

⋃i=0nAi={x∈U∣x∈Ai for at least one i=0,1,2,…,n}⋃i=0∞Ai={x∈U∣x∈Ai for at least one nonnegative integer i}⋂i=0nAi={x∈U∣x∈Ai for all i=0,1,2,…,n}⋂i=0∞Ai={x∈U∣x∈Ai for all nonnegative integers i}
Tip

  • Union 是至少任一一个 set 里面有
  • Intersection 是每一个 set 里面都有

Example

For each positive integer i, let Ai={x∈R|−1i<x<1i}
Equivalently, Ai=(−1i,1i)
a. Find A1∪A2∪A3 and A1∩A2∩A3
b. Find ⋃i=1∞Ai and ⋂i=1∞Ai

A1∪A2∪A3=(−1,1)∪(−12,12)∪(−13,13)=(−1,1)A1∩A2∩A3=(−1,1)∩(−12,12)∩(−13,13)=(−13,13)⋃i=1∞Ai=(−1,1)∪(−12,12)∪(−13,13)∪⋯=(−1,1)⋂i=1∞Ai=(−1,1)∩(−12,12)∩(−13,13)∩⋯={0}

Partitions of Sets

Definition

A collection of non-empty sets {A1,⋯,An} is a partition of a set A⟺

  • A=A1∪A2∪⋯∪An
  • A1,A2,⋯,An are mutually disjoint / pairwise disjoint

partitions of sets.png

Cartesian Products

Definition

Given 2 sets A and B, the Cartesian product A×B is the set of all ordered pairs (a,b), where a∈A,b∈B

A×B={(a,b)|a∈A,b∈B}

It can be generalized to any number of sets

A×B×C={(a,b,c)|a∈A,b∈B,c∈C}
Tip

For ordered pairs, the ordering is important, i.e. (1,2)≠(2,1)

Important

  • If |A|=n and |B|=m,
    • then |A×B|=nm
    • If |C|=l, then |A×B×C|=nml
  • |A1×A2×⋯×Ak|=|A1|×|A2|×⋯×|Ak|
  • ∅×A=∅
    • |∅×A|=0

Example

Let A={a,b},B={0,1}A×A={(a,a),(a,b),(b,a),(b,b)}A×B={(a,0),(a,1),(b,0),(b,1)}B×B={(0,0),(0,1),(1,0),(1,1)}

Set Identities

Example

  1. Prove A−(A∩B)=A−B
L.H.S.=A−(A∩B)=A∩A∩B―Set Difference Law=A∩(A―∪B―)De Morgan’s Law=(A∩A―)∪(A∩B―)Distributive Law=∅∪(A∩B―)=A∩B―Identity Law=A−BSet Difference Law=R.H.S.
  1. Prove (A∪B)−C=(A−C)∪(B−C)
L.H.S.=(A∪B)−C=(A∪B)∩C―=(A∩C―)∪(B∩C―)=(A−C)∪(B−C)=R.H.S.
  1. Prove (A∪B∪C)―=A―∩B―∩C―
L.H.S.=(A∪B∪C)―=(A∪B)―∩C―=A―∩B―∩C―=R.H.S.

Russell's Paradox 罗素悖论

Caution

以下内容由 AI 基于 Lecture Note 撰写,作者仅进行小幅度的修改。

W:={S∈Sets∣S∉S}

即 “W 是所有"不包含自己"的集合的集合”。
现在问: W 在不在 W 里?

用"理发师悖论"帮助理解

一个理发师声称:“我给所有不自己剃头的人剃头,但我不给那些自己剃头的人剃头。”
问:理发师给不给自己剃头?
如果他给自己剃头,那按规矩他就不该给自己剃头——矛盾。
如果他不给自己剃头,那按规矩他就应该给自己剃头——矛盾。

只需记住:不能把"任意满足性质的全体"都默认成集合。

一点延伸:与停机问题的关系

罗素悖论和 Propositional Logic 中所提到的停机问题 (Halting Problem) 在推理结构上非常相似。