Discrete Mathematics Chapter 2 Basic Structures Sets Functions
Discrete Mathematics Chapter 2 Basic Structures : Sets, Functions, Sequences, and Sums 大葉大學 資訊 程系 黃鈴玲
n Example 5 : 常見的重要集合 l N= { 0, 1, 2, 3, …}, the set of natural number (自然數) (注意:有些書不把0視為自然數) l Z = { …, -2, -1, 0, 1, 2, …}, the set of integers (整數) l Z+ = { 1, 2, 3, …}, the set of positive integers (正整數) l Q = { p/q | p ∈ Z, q≠ 0 }, the set of rational numbers (有理數) l R = the set of real numbers (實數) n n (元素可表示成 1. 234等小數形式) Def 3 : A, B: sets. A=B iff ∀x (x ∈ A x ∈ B) Def 4 : A ⊆ B iff ∀x (x ∈ A → x ∈ B) (A是B的子集合) 補充: A B 表示A ⊆ B 但 A ≠ B Ch 2 -3
n n Def 5 : S : a finite set The cardinality (基數, 元素個數) of S, denoted by |S|, is the number of elements in S. Def 7 : S : a set The power set (冪集合) of S, denoted by P(S), is the set of all subsets of S. Example A={1, 2} P(A) = { , {1}, {2}, {1, 2} } Example 13 : S = {0, 1, 2} P(S) = { , {0}, {1}, {2}, {0, 1}, {0, 2}, {1, 2}, {0, 1, 2} } Ch 2 -6
n n n Def 9 : A, B : sets. The Cartesian Product (笛卡 耳積) of A and B, denoted by A B, is the set A B = { (a, b) | a ∈ A and b ∈ B } Example 16 : A = {1, 2} , B = {a, b, c} A B = { (1, a), (1, b), (1, c), (2, a), (2, b), (2, c) } Note: |A B| = |A| |B| Ch 2 -8
n n Def 9 : A 1, A 2, …, An : sets. The Cartesian Product (笛卡耳積) of A 1, A 2, …, An, denoted by A 1 A 2 … An, is the set A 1 A 2 … An = { (a 1, a 2, …, an) | ai ∈ Ai, where i=1, 2, …, n } Example 18: A = {0, 1} , B = {x, y}, C={a, b, c} A B C = { (0, x, a), (0, x, b), (0, x, c), (0, y, a), (0, y, b), (0, y, c), (1, x, a), (1, x, b), (1, x, c), (1, y, a), (1, y, b), (1, y, c)} Ch 2 -9
Exercise 2 -1 23. 令A = {a, b, c, d}與B = {y, z},C={1, 2}求出 (a) A B (b) B A (c) B C A Ch 2 -10
2 -2 Set Operations(集合的運算) n n Def 1, 2, 4 : A, B : sets u A∪B = { x | x A or x B } (union聯集) u A∩B = { x | x A and x B } (intersection交集) u A – B = { x | x A and x B } (差集,也寫成A B) Def 3 : Two sets A, B are disjoint(互斥) if A∩B = Def 5 : Let U be the universal set (宇集). The complement (補集) of the set A , denoted by A , is the set U – A. Example 10 : Prove that A∩B = A∪B pf : U 此種圖稱為 Venn Diagram(范式圖) Ch 2 -11
n Def 6, 7 : A 1 , A 2 , … , An : sets n ∪ Ai =A 1∪A 2∪…∪An i=1 n ∩ i=1 Ai =A 1∩A 2∩…∩An Let I = {1, 3, 5} , ∪ i I Ai =A 1∪A 3∪A 5 n n Def : (習題31) A, B : sets The symmetric difference (對稱差集) of A and B, denoted by A⊕B , is the set { x | x A - B or x B - A } = ( A∪B ) - ( A ∩B ) Inclusion – Exclusion Principle (排容原理) |A ∪ B| = |A| + |B| - |A ∩ B| Ch 2 -12
2 -3 Functions (函數) n Def 1 : A, B : sets n A function f : A → B is an assignment of exactly one element of B to each element of A. We write f (a) = b if b is the unique element of B assigned by f to a ∈ A. Example A f(a)=1 f(b)=2 f(g)=3 B f A 1 a b 2 b g 3 g a Not a function B f 1 2 f(a)=1 f(b)=? f(g)=2 Not a function Ch 2 -14
A g(a)=1 g(b)=2 g(g)=1 A B g a b 1 a 2 b B f 2 3 g g a function 1 4 f(a)=1 f(b)=4 f(g)=2 a function Def 2 : (以 f : A→B 為例,右上圖) A: domain (定義域) of f , B: codomain (對應域) of f f (a) = 1 , f (b) = 4 , f (g) = 2 1稱為a的image (映像, 必定唯一), a稱為 1的pre-image(前像, 可能不唯一) range(�域 ) of f = { f (a) | a ∈ A} = f (A) = {1, 2, 4} (未必=B) Example 4 : f : Z → Z, f (x) = x 2, 則 f 的domain, codomain 及 n range為何? Ch 2 -15
n Def 3 : 令 f 1 與 f 2 為 A 到 R 的函數,則f 1 + f 2 和 f 1 f 2也是 A 到 R 的函數,分別定義為: ( f 1 + f 2 )(x) = f 1(x) + f 2(x) (f 1 f 2)(x) = f 1(x) f 2(x) n Example 6 : Let f 1 : R → R and f 2 : R → R such that f 1(x) = x 2, f 2(x) = x - x 2. What are the function f 1 + f 2 and f 1 f 2? Sol : ( f 1 + f 2 )(x) = f 1(x) + f 2(x) = x 2 + ( x – x 2 ) = x (f 1 f 2)(x) = f 1(x).f 2(x) = x 2( x – x 2 ) = x 3 – x 4 Ch 2 -16
※ 一對一函數與映成函數 n n Def 5: A function f is said to be one-to-one (一對一), or injective (嵌射), iff f (x) ≠ f (y) whenever x ≠ y. Example 8 : A a f b B 1 2 3 4 5 c d 是 1 -1 A a b c d g B 1 2 3 4 5 不是 1 -1 , 因 g(a) = g(d) = 4 Ch 2 -18
n n Example 10: Determine whether the function f (x) = x + 1 is one-to-one? Sol: x ≠ y x + 1 ≠ y + 1 f (x) ≠ f (y) ∴ f is 1 -1 Def 7: A function f : A → B is called onto (映成), or surjective (蓋射), iff for every element b ∈ B, ∃a ∈ A with f (a) = b. (即 B 的所有元素都被 f 對應到) Example 11: f a b c d onto A 1 a 2 b 3 c f B 1 2 3 4 Note : 當|A| < |B| 時, 必定不會onto. not onto Ch 2 -19
n Def 8: The function f is a one-to-one correspondence (一對 一對應關係), or a bijection (雙射), if it is both 1 -1 and onto. n 圖 5 a b c 1 b 1 2 3 c 4 d 3 a 1 -1 , not onto 2 not 1 -1, onto a 1 2 3 4 b c d 1 -1 and onto ※補充 : f : A →B (1) If f is 1 -1 , then |A| ≤ |B| (2) If f is onto , then |A| ≥ |B| (3) if f is 1 -1 and onto , then |A| = |B|. Ch 2 -20
※Some important functions n Def 12: floor function x (底函數): 表示 ≤ x 的最大整數,即 [x] u ceiling function x (頂函數): 表示 ≥ x 的最小整數 u n n Example 24 : ½ = -½ = 7 = Example 29 : factorial function (階乘函數): f : N → Z+ , f (n) = n! = 1 x 2 x … x n Ch 2 -22
2. 4 Sequences and Summations ※Sequence (數列) Def 1. A sequence is a function f from A Z+ (or A N) to a set S. We use an to denote f(n), and call an a term (項) of the sequence. Example 1. {an} , where an = 1/n , n =1, 2, 3, … a 1 =1, a 2 =1/2 , a 3 =1/3, … Example 2. {bn} , where bn= (-1)n, n =0, 1, 2, … b 0 = 1, b 1 = -1 , b 2 = 1, … Ch 2 -24
Example 5. 給定數列的前五項,求序列的公式: (a) 1, 1/2, 1/4, 1/8, 1/16 (b) 1, 3, 5, 7, 9 (c) 1, -1, 1, - 1, 1 Sol : (a) a 0 = 1, a 1 = 1/2, a 2 = 1/22, a 3 = 1/23, a 4 = 1/24, an = 1/2 n, n =0, 1, 2, 3, … (b) a 0 = 1, a 1 = 3, a 2 = 5, a 3 = 7, a 4 = 9 an = 2 n+1, n =0, 1, 2, 3, … (c) a 0 = 1, a 1 = -1, a 2 = 1, a 3 = -1, a 4 = 1 an = (-1)n, n =0, 1, 2, 3, … Ch 2 -26
Example 7. How can we produce the terms of a sequence if the first 10 terms are 5, 11, 17, 23, 29, 35, 41, 47, 53, 59? Sol : (等差數列) a 1 = 5 a 2 =11 = 5 + 6 a 3 =17 = 11 + 6 = 5 + 6 2 : : an= 5 + 6(n-1) = 6 n-1, n =1, 2, 3, … 注意:序列的第一項是 a 0 還是 a 1 會影響 an 的公式, 所以寫公式時一定要標示出 n 從 0 還是 1 開始 Ch 2 -27
Example 8. Conjecture a simple formula for an if the first 10 terms of the sequence {an} are 1, 7, 25, 79, 241, 727, 2185, 6559, 19681, 59047? Sol: 顯然非等差數列 後項除以前項的值接近 3 猜測數列為 3 n … 比較: {3 n} : 3, 9, 27, 81, 243, 729, 2187, … {an} : 1, 7, 25, 79, 241, 727, 2185, … an = 3 n - 2 , n 1 Ch 2 -28
Summations (級數,數列總和) Here, the variable j is call the index of summation, m is the lower limit (下限), and n is the upper limit (上限). Example 10. = 12+22+32+42+52=55 Example 13. (Double summation) Ch 2 -30
Example 14. Table 2. Some useful summation formulae Ch 2 -31
Cardinality(基數) (此部分跳過) Def 4. The sets A and B have the same cardinality (size) if and only if there is a one-to-one correspondence (1 -1, onto 的function) from A to B. Def 5. A set that is either finite or has the same cardinality as Z+ (or N) is called countable (可數). A set that is not countable is called uncountable. Ch 2 -33
Example 18. Show that the set of odd positive integers is a countable set. Pf: (Figure 1) Z+ : 1 2 3 4 5 6 { 正奇數 } : 1 3 5 7 9 11 7 8 … …… 13 15 … f : Z+ {正奇數} f (n) = 2 n – 1 is 1 -1 & onto. Ch 2 -34
Example 19. Show that the set of positive rational number (Q+) is countable. Pf: Q+ = { a / b | a, b Z+ } (Figure 2) 1 1 ∴ Z+ : 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 … Q+ : (注意,因 等於 ,故 不算) ※Note. R is uncountable. (Example 21) Ch 2 -35
- Slides: 35