107 - Lecture3

一. 集合论(Set Theory)

集合运算以及二进制串表示子集的方法。

1. 集合的符号(Notation for sets)和重要集合(important step)

A set is a collection of objects, called the elements of the set
集合是一个包含多个对象的组合,这些对象被称为集合的元素

Notation

• 集合用花括号 {} (braces)表示,元素用逗号分隔。
• 表达某个特定的对象是某个集合的成员时,我们使用符号“∈”

当我们讨论一个非常大的集合,特别是无限集合(infinite set)时,我们无法将所有的元素一一列出。因此,我们会使用一个谓词(predicate)(条件表达式)来定义这个集合。

谓词是一个关于变量的陈述,这个陈述可以是真或假

                   S = {x | P(x)}

Examples: Let S = {1, 3, 5, 7, . . .}. Then

       S = {x | x is an odd positive integer}

      S = {2n − 1 | n is a positive integer }.

denotes the set of objects x for which the predicate P(x) is true.
表示所有使得谓词P为真的对象x的集合。

Important sets

•	常见的集合包括:
empty set has no elements. It is written as ∅ or as {}	
•	自然数集合:N = {0, 1, 2, 3, ……} 
•	整数集合: Z = {……-2, -1, 0, 1, 2, ……} 
•	正整数集合: Z^+ = {1, 2, 3, ……}
•	有理数集合:Q = {x/y|x ∈ Z, y ∈ Z, y , 0} (the rationals)
•	R:(real number)

Subsets子集的定义

集合 B被称为集合A 的子集,如果集合B的每一个元素都属于集合A ,记作 B ⊆ A.

Data types

现代编程语言要求变量必须声明(declared)为属于某种特定(particular)的数据类型。
数据类型是由一组对象组成的集合
a set of objects
以及在这些对象上可以进行的一系列标准操作。
a list of standard operations on those objects
例如,整数集合配合加号(+)和减号(-)操作符就构成了一个数据类型。
指定一个变量的数据类型,相当于(is equivalent to)指明了这个变量的值将取自哪个集合。the set from which the variable is drawn

Equality

set A is called equal to a set B if A ⊆ B and B ⊆ A.This is denoted by A = B.
Examples:
{1} = {1, 1, 1},
{1, 2} = {2, 1}
{5, 4, 4, 3, 5} = {3, 4, 5}

并集(the union of two sets):A ∪ B = {x | x ∈ A or x ∈ B}
交集:(the intersection of two sets):A ∩ B = {x | x ∈ A and x ∈ B}
相对补集:(the relative complement:A − B = {x | x ∈ A and x < B}
补集:(the complement):∼ A = {x | x < A} = U − A
对称差:(the symmetric difference):
A∆B = {x | (x ∈ A and x < B) or (x < A and x ∈ B)}.
A∆B = (A ∪ B)∩ ∼ (A ∩ B)
属于集合A或B,但不同时属于两个集合的元素。

请添加图片描述

The algebra of sets

Commutative laws:
A ∪ B = B ∪ A, A ∩ B = B ∩ A;
Associative laws:
A ∪ (B ∪ C) = (A ∪ B) ∪ C, A ∩ (B ∩ C) = (A ∩ B) ∩ C;
Identity laws:
A ∪ ∅ = A, A ∪ U = U, A ∩ U = A, A ∩ ∅ = ∅;
Distributive laws:
A ∩(B ∪ C) = (A ∩B)∪(A ∩ C), A ∪(B ∩ C) = (A ∪B)∩(A ∪ C);
Complement laws:
A∪ ∼ A = U, ∼ U = ∅, ∼ (∼ A) = A, A∩ ∼ A = ∅, ∼ ∅ = U;
De Morgan’s laws:
∼ (A ∪ B) =∼ A∩ ∼ B, ∼ (A ∩ B) =∼ A∪ ∼ B.

请添加图片描述

•	空集∅是一个没有任何元素的集合,因此没有任何东西是它的元素。
•	空集是所有集合的子集
•	{3, {3}}  是一个包含两个元素的集合:一个是数字 3,另一个是集合  \{3\} 。
•	 {3}  是一个只包含数字 3 的集合。
•	 ∈表示“是集合的元素”,而⊆表示“是集合的子集”

幂集

幂集是指一个集合的所有子集构成的集合。
Pow(A) = {C | C ⊆ A}

Pow(A ∩ B) = Pow(A) ∩ Pow(B)

Pow(A ∪ B) , Pow(A) ∪ Pow(B)

集合的基数(Cardinality of sets)

一个有限(infinite)集合S的基数是S中元素的数量,用|S|表示。 •
9. 集合并集的基数公式
容斥原理公式(两个集合):
principle of inclusion and exclusion
|A U B| = |A| + |B| - |A∩B|

Example
Suppose there are 100 third-year students. 40 of them take the
module “Sequential Algorithms” and 80 of them take the module
“Multi-Agent Systems”. 25 of them took both modules. How many
students took neither modules?
• 设 A 为选了“Sequential Algorithms”课程的学生集合, |A| = 40 ;
• 设 B 为选了“Multi-Agent Systems”课程的学生集合, |B| = 80 ;
• 选了两个课程的学生人数为 |A∩B| = 25 。

我们需要计算的是 没有选这两个课程的学生人数。

  1. 使用容斥原理计算选了任一课程的学生人数:

根据容斥原理,选了至少一个课程的学生人数为:

|A U B| = |A| + |B| - |A∩B|
= 40 + 80 - 25 = 95

这意味着有95名学生至少选了一个课程。

  1. 计算没有选课程的学生人数:

总共有100名学生,因此没有选任何一个课程的学生人数为:

100 - |A U B| = 100 - 95 = 5

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

Ordered pairs

在讨论集合时,元素列出的顺序是不重要的。为了处理有序对象列表(ordered lists of objects,
定义 集合A和B的笛卡尔积(cartesian product)A × B是由所有对(a, b)组成的集合,其中a属于A且b属于B,即,

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

注意,(a, b) = (c, d) 当且仅当 a = c 且 b = d。
例子
{1, 2} = {2, 1} 但是 (1, 2) ≠ (2, 1)。

Cartesian plane

R × R,或者通常写作 R²,代表所有(pairs of real numbers)实数对 (x, y) 的集合。R² 也被称为笛卡尔平面。
R²–所有实数对的集合
R–实数集
2–二维空间

集合A1, A2, …, An的笛卡尔积A1 × A2 × · · · × An定义为
A1 × A2 × · · · × An = {(a1, …, an) | a1 ∈ A1, …, an ∈ An}。
这里(a1, …, an) = (b1, …, bn)当且仅当对于所有的1 ≤ i ≤ n,有ai = bi。
如果A1, …, An都是同一个集合A,那么我们用A^n来表示这个集合
A1 × ··· × An。

Bit strings of Length n

集合B,它包含了两个元素0和1。集合B的n次幂,记为B^n,包含了所有由0和1组成的长度为n的列表。这样的列表被称为长度为n的比特串(bit strings

二进制串表示子集

• 每个子集可以用二进制串(bit string)表示。
Suppose we have a set S = {s1, . . . , sn}.
(I have given the n elements of the set names. s1 is the name of
the first element. s2 is the name of the second element (which is
different from the first element) and so on.)
请添加图片描述

特征向量在集合论中用来表示集合的子集的一种方式
特征向量可以为一表示集合S的某个子集A

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值