CPT107笔记

Number Systems

Natural Numbers

N = {0, 1, 2, 3, . . .}
  • 从0开始的表达式,S(n) = n + 1

  • 每两个自然数相加,永远得到另一个自然数 u take any two numbers in N and add them, you always get another number in N.

证明数时首先考虑数的性质

Integers

Z = {. . . , −2, −1, 0, 1, 2, . . .}
Z + = {1, 2, 3, . . .}正整数
  • 两个整数x+y的和与差依然是整数,以此判断等号右边数的性质,例如x+3y=1/3则不符合

Rationals

  • can be written as x/y where x and y are integers and y is not 0

  • A real number that is not rational is called irrational.

  • Irrational:不可以写作x/y,xy为整数,能被写成x/y整数形式的数一定是有理数,用这个逻辑判断是否为有理数

  • 有理数证明经常涉及开方,开方后不影响数的性质

Real Numbers

所有数(有理数,无理数)

Prime Numbers

  • a integer greater than 1 which has exactly two divisors that are positive integers: 1 and itself

  • 常见质数:2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43,(1不是)

  • Every integer greater than 1 can be written as a unique product of prime numbers

  • A positive integer is even if it has 2 as a factor. Otherwise, it is odd.用于判断

  • P(n) = P(n − 2) + P(n − 3)

Proof Techniques

contradiction

步骤

  • 首先假定命题反面

  • 利用命题性质得到表现形式

  • 用数的性质反驳

  • 最后结论,不成立,有矛盾

例题

1,√2 is irrational

Let √2 be a rational number then
√2 = p/q
squaring both the sides we get
2=p2/q2 (2p)2=q2 {equation 1}
this implies that q32 is divisible by 2 and then can also be said that q is divisible by 2
hence can be written as
q=2k where k is an integer
squaring both sides
q2 = (2k)2
from equation 1
(2k)2=(2p)2 and p2 = 2k2
hence we can say 2 is the common factor in p and q and this is a contradiction to the fact that p and q are co prime numbers
hence √2 cannot be expressed as p/q
hence √2 is an irrational number.

2,For all integers x and y, if x and y are odd integers, then there does not exist an integer z such that x^2 + y^2 = z^2.

If 𝑛=2𝑘n=2k, then 𝑛2=4𝑘2n2=4k2 is a multiple of 44.
Likewise, if 𝑛=2𝑘+1n=2k+1, then 𝑛2=4(𝑘2+𝑘)+1n2=4(k2+k)+1.
Therefore, a square is congruent to either 00 or 1(mod4)1(mod4). In other words, a square is never of the form 4𝑘+24k+2, for some 𝑘k.
More specifically, since you've seen that 𝑥2+𝑦2≡2(mod4)x2+y2≡2(mod4) when 𝑥x and 𝑦y are odd, and since squares are never congruent to 2(mod4)2(mod4), this shows that 𝑥2+𝑦2x2+y2 is never a square when 𝑥x and 𝑦y are both odd.

3.No integers y and z exist for which 24y + 12z = 1

To prove this false, we take the position that we can find integers y and z to make the equation work out
24y + 12z = 1 The original equation
Divide both sides by 12, the greatest common factor
2y + z = 112
Immediately we are struck by the nonsense created by dividing both sides by the greatest common factor of the two integers. The sum of the integers is a fraction!
That is a contradiction: two integers cannot add together to yield a non-integer (a fraction). The two integers will, by the closure property of addition, produce another member of the set of integers. This contradiction means the statement cannot be proven false. It must therefore be true!

Induction

步骤

  • Base Case:一般取要迭代的数为1,或者题目限制的最小值

  • Induction Step:Assume that the property holds for n = m for any mb. Show that it holds for n = m + 1

  • Conclusion: You can now conclude that the property holds for every integer nb.

例题

更多例题:https://calcworkshop.com/proofs/proof-by-induction/

Set Theory

大部分为高中知识,此处只补充高中没有的内容

A∆B = {x | (x ∈ A and x < B) or (x < A and x ∈ B)}.

集合常用公式

Distributive laws:

A ∩(BC) = (AB)∪(AC), A ∪(BC) = (AB)∩(AC)

Complement laws:

A∪ ∼ A = U, ∼ U = ∅, ∼ (∼ A) = A, A∩ ∼ A = ∅, ∼ ∅ = U

De Morgan’s laws:

∼ (AB) =∼ A∩ ∼ B, ∼ (AB) =∼ A∪ ∼ B

三个集合问题

|ABC| = |A|+|B|+|C| − |AB| − |AC| − |BC|+|ABC|

补充

常用公式证明

一个套路:取任意x,简化到x对于每一个集合的关系,之后用逻辑语言运算

例:分配律证明

Power Set

The power set Pow(A) of a set A is the set of all subsets of A. In other words,

Pow(A) = {C | C ⊆ A}

.Example:

Let A = {1, 2, 3}.

Then Pow(A) = {∅, {1}, {2}, {3}, {1, 2}, {2, 3}, {1, 3}, {1, 2, 3}}.

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

Ordered pairs

Defifinition

The cartesian product A × B of sets A and B is the setconsisting of all pairs (a, b) with aA and bB, i.e.,

A × B = {(a, b) | aA and bB}.

(a, b) = (c, d) if and only if a = c and b = d.

Example

{1, 2} = {2, 1} but (1, 2) , (2, 1).

characteristic vector

Let S = {1, 2, 3, 4, 5}, A = {1, 3, 5} and B = {3, 4}.

The characteristic vector of A is (1, 0, 1, 0, 1).

The characteristic vector of B is (0, 0, 1, 1, 0).

The characteristic vector of AB is (0, 0, 1, 0, 0).

The characteristic vector of AB is (1, 0, 1, 1, 1).

Relations

binary relations

If R is a binary relation then we write xRy whenever (x, y) ∈ R.The predicate xRy is read as x is R-related to y

  • reflexive自反性 when xRx for all x ∈ A.

reflflexive if there is always an arrow from every vertex to itself;

如果每个顶点都有一个箭头指向自身

  • symmetric对称性 when xRy implies yRx for all x, y ∈ A;

symmetric if whenever there is an arrow from x to y there is also an arrow from y to x;

如果有一个从xy的箭头,也有一个从yx的箭头

  • antisymmetric反对称性 when xRy and yRx imply x = y for all x, y ∈ A;

antisymmetric if whenever there is an arrow from x to y andx , y, then there is no arrow from y to x;

如果有从xyx, y的箭头,则没有从yx的箭头

  • transitive when xRy and yRz imply xRz for all x, y, z ∈ A.

transitive if whenever there is an arrow from x to y and from yto z there is also an arrow from x to z

如果有一个从xy和从yz的箭头,也有一个从xz的箭头

equivalence relation

Reflexivity && Transitivity && Symmetry

表现形式

关系矩阵

Equivalence Relations

Defifinition A binary relation R on a set A is called an equivalence relation if it is reflflexive, transitive, and symmetric.

Examples:

the relation R on the non-zero integers given by xRy if xy > 0;

the relation has the same age on the set of people.

Partial orders

Defifinition A binary relation R on a set A which is reflflexive,transitive and antisymmetric is called a partial order.

Partial orders are important in situations where we wish tocharacterise precedence.

Examples:

the relation ≤ on the the set R of real numbers;

the relation ⊆ on Pow(A);

is a divisor of” on the set Z+ of positive integers

例题

A relation "<" is a partial order on a set S if it has:

  1. Reflexivity: a ≤ a for all a € S.

  1. Antisymmetry: a <= b and b <= a implies a = b.

  1. Transitivity: a <= band b <= c implies a <= c.

Predecessors in partial orders

  • If R is a partial order on a set A and xRy, x , y we call x a predecessor of y.

  • If x is a predecessor of y and there is no z < {x, y} for which xRzand zRy, we call x an immediate predecessor of y.

  • Let (Z,≤) be a partially ordered set. If x ≤ y but x != y, we write x < y and say that x is a predecessor of y or y is a successor of x.

  • A given y may have many predecessors, but if x< y and there is no z with x< z< y, then x is an immediate predecessor of y

例题

Consider the relation “x divides y” on {1,2,3,6,12,18}.

• Write the ordered pairs (x,y) of this relation.

(1,1),(1,2),(1,3),(1,6),(1,12),(1,18),(2,2),(2,6),(2,12),(2,18),(3,3),(3,6),(3,12),(3,18),(6,6),(6,12),(6,18),(12,12),(18,18).

• Write all the predecessors of 6.

1,2,3

• Write all the immediate predecessors of 6.

2,3

Total orders

Defifinition

A binary relation R on a set A is a total order if it is apartial order such that for any x, yA, xRy or yRx.

The Hasse diagram of a total order is a chain.

  1. Antisymmetry

  1. Transitivity

  1. Totality - either a <= b or b <= a

Examples

the relation ≤ on the set R of real numbers;

the usual lexicographical ordering on the words in a dictionary;

the relation “is a divisor of” is not a total order.

Hasse Diagram

If x is an immediate predecessor of y, then the nodefor y is placed above the node for x and the twonodes are connected by a straight-line segment

如果x是y的直接前任,则y的节点位于x的节点之上,两个节点由一条直线段连接

Hasse Diagram for (A = {1, 2, 3, 4}, ≤)

Functions

Composition of Relations

Defifinition Let RA × B and SB × C. The composition of Rand S, denoted by SR, is the binary relation between A and C

given by

SR = {(a, c) | exists bB such that aRb and bSc}

单射(injection): F是单根的

f(a1) = f(a2) ⇒ a1 = a2 for all a1, a2 ∈ A.

不能一个x对应多个y值,例如二次函数就不是

eg

f : Z → Z given by f(x) = x2 is not injective.

h : Z → Z given by h(x) = 2x is injective

满射(surjection, onto): ranF=B

定义域和值域一致

AB is surjective (or onto) if the range of fcoincides with the codomain of f. This means that for every bBthere exists aA with b = f(a)

This means that for every b ∊ B there exists a ∊ A with b = f(a).

eg

f : Z → Z given by f(x) = x2 is not surjective.

h : Z → Z given by h(x) = 2x is not surjective.

h0 : Q → Q given by h0 (x) = 2x is surjective.

双射(bijection), 一一对应(1-1 mapping) :

F既是单射又是满射

f : AB is surjective (or onto) if the range of f

coincides with the codomain of f. This means that for every bB

there exists aA with b = f(a).

We call f bijective if f is both injective and surjective.

A function f is invertible if and only if it is a bijection.

eg

f : Z → Z given by f(x) = x2 is not surjective.

h : Z → Z given by h(x) = 2x is not surjective.

h0 : Q → Q given by h0 (x) = 2x is surjective

Inverse functions

Since any function f : AB is a relation we can form the inverse

relation f−1 . If this inverse relation is itself a function, we say that f

is an invertible function and write

f*−1 : BA

for the inverse function.

If f(a) = b then (a, b) is a pair in the function, so (b, a) is a pair in

the inverse, so f−1(b) = a

  • Theorem A function f is invertible if and only if it is a bijection

Composition of functions

If f : AB and g : BC are functions, then the compositionrelation gf between A and C consists of all pairs (a, c) where,for some bB, (a, b) ∈ f and (b, c) ∈ g. gf is a function as well.It is given by

(gf)(x) = g(f(x))

The pigeonhole principle

Consider a function f : AB where A and B are finite sets and

|A| > k 𝐵 for some natural number k.

Then, there is a value of f which occurs at least k + 1 times.

  • Example 1:

If (Kn+1) pigeons are kept in n pigeon holes where K is a positive integer, what is the average no. of pigeons per pigeon hole?

Solution: average number of pigeons per hole = (Kn+1)/n

= K + 1/n

Therefore there will be at least one pigeonhole which will contain at least (K+1) pigeons i.e., ceil[K +1/n] and remaining will contain at most K i.e., floor[k+1/n] pigeons.

i.e., the minimum number of pigeons required to ensure that at least one pigeon hole contains (K+1) pigeons is (Kn+1).

  • Example 2:

A bag contains 10 red marbles, 10 white marbles, and 10 blue marbles. What is the minimum no. of marbles you have to choose randomly from the bag to ensure that we get 4 marbles of same color?

Solution: Apply pigeonhole principle.

No. of colors (pigeonholes) n = 3

No. of marbles (pigeons) K+1 = 4

Therefore the minimum no. of marbles required = Kn+1

By simplifying we get Kn+1 = 10.

Verification: ceil[Average] is [Kn+1/n] = 4

[Kn+1/3] = 4

Kn+1 = 10

i.e., 3 red + 3 white + 3 blue + 1(red or white or blue) = 10

Propositional Logic

Syntax: formulas and formal representations

Propositions命题
  • A proposition is a declarative sentence that is either true or false (but not both

  • 命题是一个陈述句,它不是真就是假

  • 在命题逻辑中,“命题”被看作最小单位

  • 命题特征:

陈述句

真假必居其一,且只居其一

不知道不代表不确定:

比如21世纪人类将住在太空,在将来会不会发生是有定论的

propositional logic命题形式

包含

1. atomic formulas / propositional variables(p q)

1. logical connectives: not and or

1. Brackets

逻辑命题定义

  • all atomic formulas are formulas;

  • if P is a formula, then -P is a formula;

  • if P and Q are formulas, then (P and Q) is a formula;

  • if P and Q are formulas, then (P v Q) is a formula;

  • Nothing else is a formula

Semantics: interpretations and truth tables

interpretations

An interpretation I is a function which assigns to any atomic formula pi a truth value

I(pi) ∈ {0, 1}.

  • If I(pi) = 1, then pi is called true under the interpretation I.

  • If I(pi) = 0, then pi is called false under the interpretation I

Truth tables

Tautologies & Contradictions

Tautologies

A tautology is a formula which is true under all interpretations

T = P ∨ ¬P = 1

真值表恒为1

Contradictions

I(P ∧ ¬P) = 0

真值表恒为0

Semantic consequence

If I(Q) = 1 for all Q ∈ Γ, then I(P) = 1

Γ |= P

Logical equivalence

Two formulas P and Q are called equivalent if they have the same truth value under every possible interpretation. In other words, P and Q are equivalent if I(P) = I(Q) for every interpretation I. This is denoted by

P ≡ Q

所有情况都一样

Laws for equivalences
  • Associative laws:

(P ∨(Q ∨R)) ≡ ((P ∨Q)∨R), (P ∧(Q ∧R)) ≡ ((P ∧Q)∧R);

  • Commutative laws:

(P ∨ Q) ≡ (Q ∨ P), (P ∧ Q) ≡ (Q ∧ P);

  • Identity laws:

(P ∨ ⊥) ≡ P, (P ∨ >) ≡ >, (P ∧ >) ≡ P, (P ∧ ⊥) ≡ ⊥

  • Distributive laws:

(P∧(Q∨R)) ≡ ((P∧Q)∨(P∧R)), (P∨(Q∧R)) ≡ ((P∨Q)∧(P∨R));

  • Complement laws:

P ∨ ¬P ≡ >, ¬> ≡ ⊥, ¬¬P ≡ P, P ∧ ¬P ≡ ⊥, ¬⊥ ≡ >;

  • De Morgan’s laws:

¬(P ∨ Q) ≡ (¬P ∧ ¬Q), ¬(P ∧ Q) ≡ (¬P ∨ ¬Q)

  • ≡ is reflexive, since (P ↔ P) is a tautology

  • ≡ is transitive, since P ≡ Q and Q ≡ R implies P ≡ R.

  • ≡ is symmetric, since P ≡ Q implies Q ≡ P.

扩展

Combinatorics

看高中选修排列组合,完全一致

排列组合问题

1 特殊元素和位置优先安排:特殊要求,优先安排

例:ABCD分别去苏州、扬州、杭州、上海4个城市,其中A不能去上海,B必须去扬州

策略:AB有特殊要求,先安排A或B

第一步:B必须去扬州,则B只有1种选择

第二步:A不能去上海,只能在苏州、杭州中2选1,则有2种选择

第三步:C在剩余2个城市中2选1,则有2种选择

第四步:D在剩余1个城市中选,则只有1种选择

分步乘法:1×2×2×1=4种不同的方案

公式计算: C11×C21×C21×C11=1×2×2×1=4C_{1}^{1}×C_{2}^{1}×C_{2}^{1}×C_{1}^{1}=1×2×2×1=4

2 相邻元素:捆绑法:元素相邻,捆绑为一

例:ABCDE站成一排,要求AB站在一起,且A要站首位,有多少种不同的排法?

第一步:A站首位,则B只能站第二位,所以AB捆在一起只有1种排法

第二步:CED在剩余3个位置里排 A33A_{3}^{3}

答案:分步相乘 1×A33=6 1×A_{3}^{3}=6

3 不相邻元素:插空法:元素间隔,分位插入

例:ABCDE站在一排,要求AB不相邻,且E不在最后一位,有多少种不同的排法?

第一步:把AB丢一边,先排E,要求不在最后一位,则E在CDE的3个位置中有2个位置可选

第二步:ED在剩余2个位置选,即 A22A_{2}^{2}

第三步:数一数空隙,得到(_C_E_D_),共有4个_(空隙)

第三步:将A和B在4个空隙位置里依次选2个,即 A42A_{4}^{2}

答案:分步乘法 C21×A22×A42=2×2×12=48C_{2}^{1}×A_{2}^{2}×A_{4}^{2}=2×2×12=48

4 定序元素只选不排:定序元素=相同元素,只选不排

不同元素的定序问题,和相同元素排列是一样的,概括:元素选好座位后不排排列(只选不排),逻辑是:选好座位后,要求是规定的顺序,所以不用再彼此调换顺序

例:AABDC,5个人站一排,要求A在B的前面,且B不在最后一位,有多少种排法?

第一步:AAB先选座,选完就定序了不用再排列,AAB在前面4个位置里选3个即 C43=4 C_{4}^{3}=4

第二步:CD选座和排列 C22×A22=2C_{2}^{2}×A_{2}^{2}=2

答案:分步相乘4×2=8种

5 相同元素分配:挡板法:同元进盒,挡板分隔

例:AAAA放到2个不同的盒子里,每个盒子至少一个球

分类枚举法:AAAA代表相同的元素,两个不同的盒子代表两个不同的位置,每个盒子至少一个球表示可以有如下几种分配方案:(1,3)(3,1)(2,2),所以共有3种不同的分配方案。

挡板法:A_A_A_A,共有3个空隙,要分成2份,所以从3个缝隙里任取1个缝隙即可,即 C31=3C_{3}^{1}=3

例: ,x1+x2+x3=5,x≥0x_{1}+x_{2}+x_{3}=5,x≥0 ,有多少组不同的解?

分类枚举法:0+0+5=5,0+1+4=5,0+2+3=5....

挡板法思路: x1,x2,x3x_{1},x_{2},x_{3} 看做是3个不同的盒子,把5等分成5个1这样相同的元素

第一步: (x1+1)+(x2+1)+(x3+1)=5+3(x_{1}+1)+(x_{2}+1)+(x_{3}+1)=5+3 ,两边各借3,等式依然成立

第二步:把8分成8个1,即11111111,这样8个相同的元素

第三步:数一数8个1之间的空隙,共有7个:1_1_1_1_1_1_1_1

第四步:3个盒子,即要插2个板,将8个1分成3份,每份进一个盒子

答案: C72=7×62×1=21C_{7}^{2}=\frac{7×6}{2×1}=21

Probability

Basic concepts in probability theory

建议看一下高中数学必修三,基本看完完全可以做题,只是需要记一下步骤

概念

  1. Sample Space:一个事件中所有可能的结果,集合形式表示

  1. Events:题目要求的指定事件

  1. Probability:P(E) = n(E)/n(S)

书写步骤

  • The sample space S is given by.

S = {(H,T),(H,H),(T,H),(T,T)}

  • **Let E be the event "two heads are obtained". **

E = {(H,H)}

  • **The probability. **

P(E) = n(E) / n(S) = 1 / 4

Special Events

The Null Event, The empty event c

c = { } = the event that contains no outcomes

The empty event ,

never occurs.

The Entire Event, The Sample Space -Ω

  • the event that contains all outcomes

  • The entire event,Ω, always occurs.

Discrete probability:

simple event

The sample space Ω for a probability model is the set of all possible outcomes. Let event X be a subset of the sample space Ω.

The probability of an event X is:

X’ is the complement of an event X.

The probability that any event X does not occur is P(X’) = 1 − 𝑃(𝑋)

Compound Events

Events are independent events if the occurrence of one event doesnot affect the probability of the other. If the occurrence of Event Adoes not change the probability of Event B, then Events A and B areindependent.

Events are dependent events if the occurrence of one does affect theprobability of the other. If the occurrence of Event A changes theprobability of Event B, then Events A and B are dependent.

independent events

Events are independent events if the occurrence of one event doesnot affect the probability of the other. If the occurrence of Event A does not change the probability of Event B, then Events A and B are independent.

If two events A and B are independent, then the probability of bothevents is the product of the probabilities for each event:

P(A ∩ B) = P(A and B) = P(A) • P(B)

Basic concepts in probability theory

Events

Independent

• Events are independent if the occurrence of one event does notaffect the occurrence of another (sample space is not changed)

• The roll of a six, does not affect the next roll

Dependent

• Events are dependent if the occurrence of one event affects theoccurrence of another event (sample space is changed)

• The chances of pulling a heart from a deck of cards? 13/52. But if youdon’t put the card back, what is the probability that you pull a heart nexttime?

A simple event is an event that describes a single outcome.

A compound event is an event made up of two or more simple events.

Mutually exclusive events you can't get both events at the same time. It is either one or the other, but not both

Inclusive events are events that have one or more outcomes in common.

When you roll a number cube, the outcomes “rolling an even number” and“rolling a prime number” are not mutually exclusive.The number 2 is both prime and even, so the events are inclusive.

Conditional probability

Expected value

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值