fundamentals\SetTheory

Set Theory

目录

Set Theory

Definiion:集合定义

附:集合的定义的发展历程

Sets 集合

SubSets 子集

Set Operations 集合的基本运算

集合基本运算的栗子:

Counting 基于集合的统计

Indexed Sets 索引集

Probability集合与求解概率


Definiion:集合定义

Gut feelinga well defined collection of objects

very often set concept provides an underlying structure for a concise formulation of the mathematical topic being investigated

集合概念通常为所研究的数学主题的简明表述提供了一个基础结构

如果一个数学主题是一盘棋的话,那么集合就是棋盘(棋盘结构在数学上叫“格”,属于比集合高很多级的数学概念)。他是一个数学结构:这个结构,足够简单足够基础,以至于代数、几何、组合数学、概率论等其他所有的领域都基于集合论 (\mu, A, B, ...),或者说基于集合论的这套符号表示法。

We use capital letters, such as A、B、C… to represent sets,And lowercase letters to represent elements.

集合的表示
图:集合的表示

集合的无序性、确定性、互异性。常见集合:\mathbb{N} = \{ 0, 1, 2, 3,... \}、 \mathbb{Z} = \{ ...,-2, -1, 0, 1, 2,... \}\mathbb{Q} = \{ \frac{1}{2}, \frac{1}{3}, \frac{2}{3},... \}2\mathbb{Z} = \{...,-4,-2,0,2,4,...\} = \{2n | n \in \mathbb{Z} \}  Desk = \{drink, laptop, microphone\} = \{x | x \, is \, on \, my \, desk\}

|A| is denotes the number of elements in A and is refered to as the cardinality, or size of A.

集合的度
图:cardinality  | {Ø,a,{b}} | = 3

附:集合的定义的发展历程

1845,a set was defined as “any collection” into a whole of definite and separate objects of our intuition or our thought.

1845,集合被定义为:我们的直觉或思想的一整套明确的、独立的对象的任意集合。

Unfortunately, in 1901, this definition led Bertrand Russell to the discovery of a contradiction

不幸的是,在1901年,这个定义使伯特兰·罗素发现了一个矛盾。

Known as Russell’s paradox , and this struck at the very heart of the theory of sets.

这就是著名的罗素悖论,它击中了集合理论的核心

Russell’s paradox arises when we concern ourselves with whether a set can be an element of itself.

当我们关心一个集合是否可以是它自身的一个元素时,罗素悖论就出现了。

For example, the set of all positive integers is not a positive integer or Z+ ∉ Z+. But the set of all abstractions is an abstraction.

例如,所有正整数的集合不是一个正整数或Z +Z +。但是所有抽象的集合任然是这个抽象本身。

Now in order to develop the paradox let S be the set of all sets A that are not members of themselves ---—— that is , S = {A | A is a set A A}

现在为了发展这个悖论,让S成为 不包含自身元素的集合(A)的集合

论证:

Show that if S ∈ S, then S S

Show that if S S, then S ∈ S

证明:

If S ∈ S , then since S ={A | A A } we have S S.

If S S , then by the definition of S it follows that S ∈ S.

The result show us that we must avoid trying to define sets like S. To do so we must restrict the types of elements that can be members of a set.

这个结果告诉我们,我们必须避免尝试定义像s这样的集合,因此我们必须限制元素的类型,让这些元素可以是集合的成员。

设性质P(x)表示“x x”,现假设由性质P确定了一个类A——也就是说“A={x|x x}”。那么现在的问题是:A A是否成立?首先,若A A,则AA的元素,那么A具有性质P,由性质PA A;其次,若A A,也就是说A具有性质P,而A是由所有具有性质P的类组成的,所以A A

世界文学名著《唐·吉诃德》中有这样一个故事:

唐·吉诃德的仆人桑乔·潘萨跑到一个小岛上,成了这个岛的国王。他颁布了一条奇怪的法律:每一个到达这个岛的人都必须回答一个问题:“你到这里来做什么?”如果回答对了,就允许他在岛上游玩,而如果答错了,就要把他绞死。对于每一个到岛上来的人,或者是尽兴地玩,或者是被吊上绞架。有多少人敢冒死到这岛上去玩呢?一天,有一个胆大包天的人来了,他照例被问了这个问题,而这个人的回答是:“我到这里来是要被绞死的。”请问桑乔·潘萨是让他在岛上玩,还是把他绞死呢?如果应该让他在岛上游玩,那就与他说“要被绞死”的话不相符合,这就是说,他说“要被绞死”是错话。既然他说错了,就应该被处绞刑。但如果桑乔·潘萨要把他绞死呢?这时他说的“要被绞死”就与事实相符,从而就是对的,既然他答对了,就不该被绞死,而应该让他在岛上玩。小岛的国王发现,他的法律无法执行,因为不管怎么执行,都使法律受到破坏。他思索再三,最后让卫兵把他放了,并且宣布这条法律作废。这又是一条悖论。

由著名数学家伯特兰·罗素(Russel18721970)提出的悖论与之相似:

在某个城市中有一位理发师,他的广告词是这样写的:“本人的理发技艺十分高超,誉满全城。我将为本城所有不给自己刮脸的人刮脸,我也只给这些人刮脸。我对各位表示热诚欢迎!”来找他刮脸的人络绎不绝,自然都是那些不给自己刮脸的人。可是,有一天,这位理发师从镜子里看见自己的胡子长了,他本能地抓起了剃刀,你们看他能不能给他自己刮脸呢?如果他不给自己刮脸,他就属于“不给自己刮脸的人”,他就要给自己刮脸,而如果他给自己刮脸呢?他又属于“给自己刮脸的人”,他就不该给自己刮脸。

理发师悖论与罗素悖论是等价的:

因为,如果把每个人看成一个集合,这个集合的元素被定义成这个人刮脸的对象。那么,理发师宣称,他的元素,都是城里不属于自身的那些集合,并且城里所有不属于自身的集合都属于他。那么他是否属于他自己?这样就由理发师悖论得到了罗素悖论。反过来的变换也是成立的。

We say C is a subset of D and write C ⊆ D, or D C, if every element of C is an elment of D.

A ⊆ B & C ⊆ B
图:A ⊆ B & C ⊆ B

If, in addition, D contains an elements that is not in C, then C is called a proper subset of D, and this is denoted by C D or D C.

∀x [x C => x D ]

For a given universe μ, the sets C and D (taken from μ) are said to be equal, and we write C = D, when C D and D C.

Let A, B, C ⊆ μ

If A ⊆ B and B ⊆ C, then A ⊆ C

Let x ∈ A;

    Since A ⊆ B and x ∈ A => x ∈ B

Then x ∈ B

    Since B ⊆ C and x ∈ B => x ∈ C

Then x ∈ C

If A ⊂ B and B ⊂ C, then A ⊂ C

If A ⊆ B and B ⊂ C, then A ⊂ C

If A ⊂ B and B ⊆ C, then A ⊂ C

The null set, or empty set, is the (unique) set containing no elements. It is denoted by ∅ or {}

For any universe μ, let A ⊆ μ. Then ∅ ⊆ A, and if A ≠ ∅, thn ∅ ⊂ A.

If A is a set from universe μ, the power set of A, denoted \rho (A), is the collection (or set) of all subsets of A.

幂集的构建
图:幂集的构建

\rho (A) | = 2^ | A | = 4, |\rho (\oslash )| = {∅} = {{}},\rho (\rho (\oslash )) = \{ \oslash , \{ \oslash \} \}

For any finite set A with |A| = n >= 0, we find that A has 2n subsets and that |p(A)| = 2n. For any 0 <= k <= n, there are C(n,k) subsets of size k. Counting the subsets of A according to the number, k, of elements in a subset, we have the combinatorial identity:

C \left( \tfrac{n}{0} \right ) + C \left( \tfrac{n}{1} \right ) + ... + C \left( \tfrac{n}{n} \right ) = \sum _{k=0}^{n} \left( \tfrac{n}{k} \right ) = 2^{n} for \; n \geq 0 

幂集与空指针
图:幂集与空指针

空指针的问题就在于 \rho (\rho (\oslash )) = \{ \oslash , \{ \oslash \} \} 于是,在引入了null 空集之后,对象的包装对象,包装对象的包装对象都需要判空,导致新手编码过程中频频出现空指针异常,国外已经有人提议放弃NULL来避免这个问题。

内置对象比如 String, Integer, Byte, Short, Double, Boolean, Float 加上基本的流程控制:loop,if  <==> 可以求解一些集合论的基本问题了:而 ( 语法【内置对象,loop, if, ...】,实践问题【集合元素,如求素数...】,理论【集合论,基本逻辑】 ) 可以组成一个完整的适合程序员语法入门的课程。为啥提这个,当年我就这么入坑了。

SubSets 子集

For any finite set A with |A| = n >= 0, we find that A has 2n subsets and that |P(a)| = 2n. For any 0 <= k <=n, there are (n/k) subsets of size k.

For each Gray code in parts of the figure, as we go from one binary string (in a column) to the next binary string (in that column). There is exactly one bit that changes.

This technique, for constructing a Gray code for the strings of length 2 from those of length 1 and the strings of length 3 from those of length 2, is an example of a recursive construction.(递归).

(a subset is a selection from a colletion, then do composite on that collection)

Correspondence(通信) between the compositions and the subsets

                   任意组合元素任取出元素=子集

 

Composition

SubSet

1

1+1+1+1+1+1+1

2

1+2+1+1+1+1

{2}

3

1+1+3+1+1

{3,4}

4

2+3+2

{1,3,4,6}

5

4+3

{1,2,3,5,6}

6

7

{1,2,3,4,5,6}

打通计数组合与子集之间的桥梁:

将7个苹果分成七份1+1+1+1+1+1+1={1,2,3,4,5,6,7}=A 。任意一个子集可以映射为某个组合 S = {x|x ∈ A 的子集},C = {x | x ∈ A 的组合},则 f(S) = C。其中,f(x) = 将x位置的元素组合到前一个位置的元素。

Pascal’s triangle :C \left ( \tfrac{n+1}{r} \right ) = C \left ( \tfrac{n}{r} \right ) + C \left ( \tfrac{n}{r - 1} \right )

a correspondence between the compositions of a number n and the subsets of the set {1,2,3,…,n} C \left ( \tfrac{n+1}{r} \right ) = C \left ( \tfrac{n}{r} \right ) + C \left ( \tfrac{n}{r - 1} \right )

(使用子集思想验证组合C \left ( \tfrac{n+1}{r} \right ) = C \left ( \tfrac{n}{r} \right ) + C \left ( \tfrac{n}{r - 1} \right ))we build a set A ={x, a1,a2,a3,…,an}

C(n+1, r) = all subsets of size r of A; C(n, r)= all subsets of size r of A without element x; C(n, r-1)= all subsets of size r-1(minus x) of A with elment x.

(使用子集思想验证组合C \left ( \tfrac{n+1}{r} \right ) = C \left ( \tfrac{n}{r} \right ) + C \left ( \tfrac{n}{r - 1} \right )):make C(n+1, r) be the paths in the xy-plane from (0, 0) to (n + 1 - r, r); C(n, r), C(n, r-1) are the two points before arrive the end point(n + 1 – r, r).

Closed operationthere are two operands, namely, a and b. Hence the operation is called binary. And since a+b ∈Z+ when a, b ∈Z+, we say that the binary operation of addition(on Z+) is closed.

子集的构建过程:

GrayCode.见:GrayCode虾扯蛋

子集构建:

Program List_subsets4(Input, Output);

Const

    Size = 10;

Type

    Memeber.type = 1..Size;

    Set_type = set of Member_type;

Var

    n: 1..Size;

    S: Set_type;

   

Procedure Write_set(S: Set_type);

Var

    i: 1..Size;

Begin

    Write('{');

    For i := 1 to Size do

        If i in S then

            Begin

                S := S - [i];

                If S <> [], then

                    Write (i:3, ',')

                Else Write (i:3);

            End;

    Writeln('}');

End

 

Procedure Subsets (L, R : Set_type; i: Member_type);

Begin

    If i <= n then

        Begin

            Subsets (L + [i], R, i + 1);

            Subsets (L, R + [i], i + 1);

        End

    Else

        Begin

            Write_set(L);

            Write_set(R);

        End;

End

 

Begin

    Write('What is the value of n ?');

    Readln(n);

    Subsets([1],[], 2);

End

Set Operations 集合的基本运算

The addition and multiplication of ositive integers are said to be closed binary operations on Z+

For A, B, ⊆ U we define the following:

  1. A∪B (the union of A and B) = {x | x∈ A ∨ x ∈ B}.
  2. A∩B (the intersection of A and B) = {x | x∈ A ∧ x ∈ B}.
  3. A△B (the symmetric difference of A and B) = {x | (x∈ A ∨ x ∈ B) ∧ x ∉ A∩B}.

Consequently, ∪, ∩, △ are closed binary operations.

Let S, T ⊆ U. The sets S and T are called disjoint, or mutually disjoint, when S∩T = {}.

If S, T ⊆ U. then S and T are disjoint, if and only if S∪T = S△T.

For a set A⊆ U, the complement of A, denoted U-A, or \overline{A}, is given by {x | x ∈U ∧ x ∉ A}.

For A, B, ⊆ U, the (relative) complement of A in B, denoted B – A, is given by {x | x∈B∧x ∉ A }.

For any universe U and any set A, B ⊆ U, the following statement are equivalent: a) A ⊆ B  b)  A∪B=B   c)  A∩B=A   d)  \overline{B} \subseteq \overline{A}

The Laws of Set Theory

\overline{\overline{A}}= A

Law of Double Complement 两次补集

\overline{A \cup B} = \overline{A} \cap \overline{B}

\overline{A \cap B} = \overline{A} \cup \overline{B}

DeMorgan’s Laws 德摩根律

A ∪ B = B ∪ A

A ∩ B = B ∩ A

Commutative Law 交换律

A ∪ ( B ∪ C )  =  ( A ∪ B ) ∪ C

A ∩ ( B ∩ C )  =  ( A ∩ B ) ∩ C

Associative Laws 结合律

A ∪ ( B ∩ C ) = ( A ∪ B ) ∩ ( A ∪ C )

A ∩ ( B ∪ C ) = ( A ∩ B ) ∪ ( A ∩ C )

Distributive Laws 分配律

A ∪ A = A

A ∩ A = A

Idempotent Laws 等幂律

A ∪ ∅ = A

A ∩ U = A

Identity Laws 恒等律

A \cup \overline{A} = \mu

A \cap \overline{A} = \oslash

Inverse Laws 反转律

A ∪ U = U

A ∩ ∅ = ∅

Domination Laws 控制律

A ∪ ( A ∩ B )  =  A

A ∩ ( A ∪ B )  =  A

Absorption Laws 合并律(合并无关因素)

公理都是成对存在的:

The dual of S, Sd , is obtained from s by replacing (1) each occurrence of {} and U by U and {}, respectively; and (2) each occurrence of ∩ and ∪ by ∪ and ∩, respectively.

Let s denote a theorem dealing with equality of two set expressions. The it’s dual of s, is also a theorem. It is only true in general not particular.

Then Venn: U is depicted as the interior of a rectangle, while subsets of U are represented by the interiors of circles and other closed cruves.

One more technique for establishing set equalities is the membership table.

Let I be a nonempty set and U a universe. For each i ∈I let AI ⊆U. then I is called an index set(or set of indices), and each i∈I is called an index.

If A and B are finite sets, then |A∪B| = |A| + |B| - | A∩B |. Consequently, finite sets A and B are(mutually) disjoint if and only if | A∪B | = |A| + |B|.

In addition, when U is finite, from DeMorgan’s Law we have | \overline{A} \cap \overline{B} | = | \overline{A \cup B}| = |\mu | - | A \cup B| = |\mu| - |A| - |B| + |A \cap B| 

If A ,B and C are finite sets, then |A∪B∪C| = |A| + |B| + |C| - | A∩B | -| A∩C |- | B∩C | + | A∩B∩C |…..

集合基本运算的栗子:

The dual of the statement A ⊆ B is the statement B ⊆ A

            For sets A, B, C μ ,[(A ∩ C = B ∩ C) ∧ (A ∪ C = B ∪ C)] ⇒ A = B

证明
x ∈ A
⇒ x ∈ A ∪ C
⇒ x ∈ B ∪ C
⊢  x ∈ B⊢ x ∈ C
⇒ A ⊆ B
⇒ x ∈ A ∩ C = B ∩ C
⇒ x ∈ B
⇒ A ⊆ B
⇒ In other wise B ⊆ A
⇒ A = B

            For sets, A, B, C ⊆ μ, A △ C = B △ C ⇒ A = B

证明
x ∈ A
⊢ x ∈ C⊢ x ∉ C
⇒ x ∉ A △ C
⇒ x ∉ B △ C
⇒ x ∈ B
⇒ x ∈ A △ C
⇒ x ∈ B △ C
⇒ x ∈ B

集合运算解题思路:

  1. 基于集合结构的基本运算有且仅有:和、差、并、交、补、异或、同或、以及元素属于集合
  2. 集合A中的任意元素x属于集合B ⇒ A ⊆ B.

Counting 基于集合的统计

栗1:电路 integrated circuit.(复用线路)

线路A 和线路B 复用7个元件

一个AND gate(与门)元件包含{输入I1, 输入I2, 以及输出O}

其中三个端口中的任意一个都可能stuck(被卡住)

栗2:某个大学的,一年级新生, showing1计数,showing2计数(college2, 二年级计数….)

栗3:加工1,terminals 出错,plates出错,计数 (加工2计数….)

栗4:string is made up of 12 bits[0,1],start with 1 or ends with 0000

栗5:计数 |A ∪ B ∪ C|

if A ⊆ B ⊆ C

if A ∩ B = B ∩ C = A ∩ C = ∅

if |A ∩ B| = |B ∩ C| = |A ∩ C| = 3

up 主基于多年echarts经验总结的图表数据模型(用集合的思想画一维柱状关系图):

统计计数
图:图表中的集合论

 

 计数解题思路:

  1. 确定count原数据的集合 (eg: a string made up of 12 bits[0,1])
  2. 确定输出的Legend (eg: 计数 |A ∪B∪C|)
  3. 确定特殊element的关系(eg: 要求 E在T前面,则先排列E,T之外的元素,再插入E,T两个特殊元素)
  4. 确定所有元素elements之间的关系(eg:⊆, ∩, ….)

Indexed Sets 索引集

\bigcap_{i=0}^{n} A_{i} = A_{0} \cap A_{1} \cap A_{2} \cap ... \cap A_{n}

\bigcap_{i=0}^{n + m} A_{i} = \bigcap_{k=0}^{n} A_{k} \cap \bigcap_{j=0}^{m} A_{i}

索引集有点像编程语言中的数组,,编程语言中的数组就是一个 Indexed Sets (索引集)

Probability集合与求解概率

概率是典型的建立在集合论基础上的数学分支

A set of all possible outcomes for each situation is called a sample space. Each of the six possible outcomes ha22s the same, or equal, likelihood of occurrence.

Analytic Theory of Probability:

Under the assumption of equal likelihood, let φ(fai Phi) be the sample space for an experiment ξ(克西). Each subset A of φ, including the empty subset, is called an event. Each element of φ determines an outcome, so if |φ|=n and a∈φ, A⊆φ, then

Pr({a}) = The probability that {a} (or , a) occurs = |{a}|/φ = 1/n, and

Pr(A)=The probability that A occurs = |A|/|φ| = |A|/n.

Eg: about φ : to take care of the class rabbit, she may make her selection in C(20, 2) = 190 ways. So |φ| = 190.

For sets A, B, the Cartesian product, or cross product, of A and B is denoted by A X B and equals {(a, b) | a∈A, b∈B}.

The sample space can be represented pictorially with a tree diagram that exhibits all the possible outcomes of experiment ξ.

Each element a∈φ is called an outcome or elementary event, we let Pr({a}) = Pr(a) denote the probability that this outcome occurs.

Let φ be the sample space for an experiment ξ. If A, B are any events---that is, {}⊆A,B⊆φ (so we now allow the empty set to be an event), then

  1. Pr(A) >=0
  2. Pr(φ) = 1
  3. If A, B are disjoint( or, mutually disjoint) then Pr(A∪B) = Pr(A) + Pr(B).

The Rule of Complement. Let φ be the sample space for an experiment ξ. If A is an event(that is , A⊆φ), then

Pr(A(___)) = 1 – Pr(A).

Independent of the outcome .Such two-outcome occurrence is called a Bernoulli trial. If there are n such trials and each trial has probability p of success and probability q (=1-p) of failure, then the probability that there are (exactly) k successes among these n trials is

C(n, k) pkqn-k, 0<=k<=n.

The Additive Rule: If φ is the sample space for an experiment ξ, and A, B⊆φ, then Pr(A∪B) = Pr(A∩B(___)) + P(B) = Pr(A) + Pr(B) – Pr(A∩B).

If φ is the sample space for an experiment ξ and A, B ⊆φ, then the conditional probability of B given A = Pr(B|A) = Pr(B∩A)/Pr(A), so long as Pr(A) <> 0.

Law of Total Probability. Pr(B) = Pr(A)Pr(B|A) + Pr(A(___))Pr(B|A(___))

Given a sample space φ with events A,B ⊆φ, we call A, B independent when Pr(A∩B) = Pr(A)Pr(B).

Decide when A, B are independent:

  1. Pr(A∩B) = Pr(A)Pr(B)
  2. Pr(A|B) = Pr(A) or
  3. Pr(B|A) = Pr(B)

Let A, B be events taken from a sample space φ, If A, B are independent, then A,B(___) are independent; A(___), B are independent; and A(___), B(___) are independent.

For a sample space φ and events A, B, C ⊆φ, we say that A, B, C are independent if

  1. Pr(A∩B) = Pr(A)Pr(B);
  2. Pr(A∩C) = Pr(A)Pr(C);
  3. Pr(B∩C) = Pr(B)Pr(C);
  4. Pr(A∩B∩C) = Pr(A)Pr(B)Pr(C);

We define the random variable X as  X(x1x2x3x4) counts the number of ? that appear among the four components x1,, x2, x3, x4.

E(x) = ∑x·Pr(X=x)(期望)

Among n Bernoulli trials.

E(x) = ∑x(x=0,n)·Pr(X=x) = ∑x(x=0,n) C(n,x)pxqn-x = np.

Eg:一次性摇6个色子,摇到6点的期望是6*1/6=1;

The variance of X, Var(X)

Var(X) = E(X – E(X))2 = ∑x (x – E(x))2 · Pr(X = x)

Among n independent Bernoulli trials. The Var(X) = npq;

未完待续…….

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值