400 likes | 679 Views
Discrete Mathematics. Chapter 1 The Foundations : Logic and Proofs, Sets, and Functions. 感謝 大葉大學 資訊工程系 黃鈴玲老師 提供. 1-1 Logic. Def : A proposition ( 命題 ) is a statement that is either true or false, but not both. Example 1 : The following statements are propositions.
E N D
Discrete Mathematics Chapter 1 The Foundations : Logic and Proofs, Sets, and Functions 感謝 大葉大學 資訊工程系 黃鈴玲老師 提供
1-1 Logic • Def :A proposition (命題) is a statement that is either true or false, but not both. • Example 1 : The following statements are propositions. (1) Toronto is the capital of Canada. (F) (2) 1 + 1 = 2 (T) • Example 2 : Consider the following sentences. (1) what time is it ? (not statement) (2) Read this carefully. (not statement) (3) x + 1 = 2 (neither true nor false)
Logical operators (邏輯運算子) and truth table (真值表) • Table 1. The truth table for the Negation (not) of a Proposition eg. p : “ Today is Friday.” ﹁p : “ Today is not Friday.” • Def :A truth table displays the relationships between the truth values of propositions. • Table 2. The truth table for the Conjunction (and) of two propositions. eg. p : “ Today is Friday.” q : “ It’s raining today. ” p q : “ Today is Friday and it’s raining today. “
Table 3. The truth table for the Disjunction (or) of two propositions. eg. p : “ Today is Friday. “ q : “ It’s raining today . “ p q : “ Today is Friday or it’s raining today. “ • Table 4. The truth table for the Exclusive or (xor) of two propositions.
Table 5. The truth table for the Implication (p implies q) p → q . (觀念 : 若p對,則q一定要對 若p錯,則對q不做要求) eg. p : “ You make more than $25000 ” q : “ You must file a tax return. “ p → q : “ If you make more … then you must … . “ • Some of the more common ways of expressing this implication are : • (1) if p then q (若p則q,p是q的充分條件) • (2) p implies q • (3) p only if q (只有q是True時,p才可能是True, 若q是False,則p一定是False)
Def :In the implication p → q , p is called the hypothesis (假設)and q is called the conclusion (結論). • Def : Compound propositions (合成命題) are formed from existing propositions using logical operators. (即、、⊕、→等) • Table 6. The truth table for the Biconditionalp ↔ q ( p → q and q → p ) “ p if and only if q “ “ p iff q “ “ If p then q , and conversely.” (若且唯若)
Translating English Sentences into Logical Expression • Example 9 :How can the following English sentence be translated into a logical expression ? “ You can access the Internet from campus only if you are a computer science major or you are not a freshman. ” • Sol : p : “ You can access the Internet from campus. “ q : “ You are a computer science major. “ r : “ You are a freshman. “ ∴ p only if ( q or ( ﹁ r )) => p →( q ( ﹁ r ))
Example 10 : You cannot ride the roller coaster (雲霄飛車 ) if you are under 4 feet tall unless you are older than 16 years old. • Sol : q : “ You can ride the roller coaster. “ r : “ You are under 4 feet tall. “ s : “ You are older than 16 years old. “ ∴ ﹁q if r unless s ∴ ( r ﹁s ) → ﹁q • Table 7. Precedence of Logical Operators eg. (1) p q r means ( p q ) r (2) p q → r means ( p q ) → r (3) p ﹁ q means p ( ﹁ q ) Exercise : 9、13、25、27、30
1-2 Propositional Equivalences • Def :A compound proposition that is always true is called a tautology. (真理) A compound proposition that is always false is called a contradiction. ( 矛盾) • Example 1 : • Def :The propositions p and q that have the same truth values in all possible cases are called logically equivalent.The notation p ≡ q ( or p q ) denotes that p and q are logically equivalent.
Example 2 : Show that ﹁( p q ) ≡ ﹁p ﹁q • pf : • ※ Some important logically equivalences (Table 5) • (1) p q ≡ q p • (2) p q ≡ q p • (3) ( p q ) r ≡ p (q r ) • (4) ( p q ) r ≡ p (q r ) • (5) p ( q r ) ≡ ( p q ) ( p r ) • (6) p ( q r ) ≡ ( p q ) ( p r ) ((5)、(6)的觀念類似於(a + b) x c = (a x c ) + (b x c)) commutative laws. 交換律 associative laws. 結合律 distributive laws 分配律
De Morgan’s laws • (7) ﹁( p q ) ≡ ﹁p ﹁q • (8) ﹁( p q ) ≡ ﹁p ﹁q • (9) p ﹁p ≡ T • (10) p ﹁p ≡ F • (11) p → q ≡ ﹁p q Example 5 : Show that ﹁( p (﹁p q )) ≡ ﹁p ﹁q pf : (也可用真值表証) ﹁( p (﹁p q ) ) ≡ ﹁p ﹁ (﹁p q ) ≡ ﹁p ( p ﹁q ) ≡ (﹁p p ) ( ﹁p ﹁q ) ≡ F ( ﹁p ﹁q ) ≡ ﹁p ﹁q by (8) by (7) by (6) by (10)
By (11) By (7) • Example 6 : Show ( p q ) → (p q) is a tautology. • pf : ( p q ) → (p q) ≡ ﹁( p q ) (p q ) ≡ ( ﹁p ﹁q ) (p q ) ≡ ( ﹁p p ) ( ﹁q q ) ≡ T T ≡ T • Exercise : 7、9、17 By (3)
1-3 Predicates and Quantifiers 屬性 數量詞 • 目標 : 了解 “ ∀“ 及 “ ∃“ 符號 • Def :The statement P(x) is said to be the value of the propositional function P at x . • ex : • P(x) : “ xis greater than 3 “ • ※命題中出現變數 x 時 the universe of discourse (or domain) of x 指的是 x 的範圍 • ※Quantifiers : (數量詞,如 some,any,all 等) • ∀: universal quantifier ( for all ) • ∃ : existential quantifier ( there exist , there is , for some ) variable predicate
+ • Table 1. Quantifiers • Example 13 : Let P(x) : x2 > 10, when x ∈ , x ≤ 4 What is the truth value of ∃x P(x) ? • Sol : x ∈ {1, 2, 3, 4} ∴ 42 = 16 > 10 ∴ ∃x P(x) is true.
Table 2. Negating Quantifiers. • Example 16 : P(x) : x2 > x , Q(x) : x2 = 2 , what is the negations of ∀x P(x) and ∃x Q(x) ? • Sol :﹁∀x P(x) ≡ ∃x ﹁P(x) ≡ ∃x (x2≤ x) ﹁∃x Q(x) ≡ ∀x ﹁Q(x) ≡ ∀x (x2 ≠ x) • Exercise : 11、13、15、49
補充 : 習題48 • “ ∃! ” 表示 “ 存在且唯一 “ • ∃!x P(x) 表示 “ There exists a unique x s.t. P(x) is true. ” • Example : What is the truth values of the statements • (a) ∃! x ( x2 = 1 ) • (b) ∃! x ( x + 3 = 2x ) where the universe of discourse is the set of integers. (即 x ∈ ) • Ans : (a) 12 = 1 , (-1)2=1 (b) True.
1-4 Nested Quantifiers • eg. ∀x ∃y (x + y = 0 ) • Table 2. Quantifications of Two Variables. 例 : ① p(x,y) : x + y ≥0 , x,y ∈ N ③ p(x,y) : xy = 0 , x,y ∈ Z ② p(x,y) : x + y = 2 , x,y ∈ Z ④ p(x,y) : xy = -1 , x,y ∈ Z ⑤ p(x,y) : x + y = ½ , x,y ∈ Z Exercise: 27
1-6 Sets • Def 1 : A set is an unordered collection of objects. • Def 2 : The objects in a set are called the elements , or members of the set. • Example 4 : 常見的重要集合 • N = { 0,1,2,3,…} , the set of natural number (自然數) • Z = { …,-2,-1,0,1,2,…} , the set of integers (整數) • Z+ = { 1,2,3,…} , the set of positive integers (正整數) • Q = { p / q | p ∈ Z , q ∈ Z , q≠0 } , the set of rational numbers (有理數) • R = the set of real numbers (實數) (元素可表示成1.234等小數形式)
Def 4 : A ⊆ B iff ∀x , x ∈ A → x ∈ B 補充: A ⊂ B 表示A ⊆ B 但 A ≠ B • 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 11 : S = {0,1,2} P(S) = {, {0} , {1} , {2} , {0,1} , {0,2} , {1,2} , {0,1,2} } • Def : A , B : sets The Cartesian Product of A and B , denoted by A x B , is the set A x B = { (a,b) | a ∈ A and b ∈ B }
Note. |A x B| = |A|.|B| • Example 14 : A = {1,2} , B = {a, b, c} A x B = {(1,a) , (1,b) , (1,c) , (2,a) , (2,b) , (2,c)} • Exercise : 5、7、8、13、17、19
1-7 Set Operations • Def 1,2,4 : A,B : sets • A∪B = { x | x A or x B } (union) • A∩B = { x | x A and x B } (intersection) • 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 : 稱為 Venn Diagram
Def 6 : A1 , A2 , … , An : sets Let I = {1,3,5} , • Def : (p.95右邊) 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| • Exercise : 10,37
1-8 Functions • Def 1 : A,B : sets A functionf : 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. • eg. A B A B α α 1 1 β β 2 2 γ γ 3 Not a function Not a function
A B A B • Def : (以 f : A→B 為例,右上圖) f (α) = 1 , f (β) = 4 , f (γ) = 2 1 稱為α的image (必唯一) , α稱為1的pre-image(可能不唯一) A : domain of f , B : codomain of f range of f = {f (a) | a ∈ A} = f (A) = {1,2,4} (未必=B) Example 2 :f : Z → Z , f (x) = x2 , 則 f的domain , codomain 及range ? 1 α α 1 2 2 β β 3 γ γ 4 a function a function
Example 4 : Let f1 : R → R and f2 : R → R s.t. f1(x) = x2 , f2(x) = x - x2 , What are the function f1 + f2 andf1 f2 ? • Sol : ( f1 + f2 )(x) = f1(x) + f2(x) = x2 + ( x – x2 ) = x (f1 f2)(x) = f1(x).f2(x) = x2( x – x2 ) = x3 – x4 • Def : A function f is said to be one-to-one , or injective , iff f (x) ≠ f (y) whenever x ≠ y. • Example 6 : f g A B A B 1 a 1 a 2 2 b b 3 3 d c 4 4 5 c 5 d 是 1-1 不是 1-1 , 因 g(a) = g(d) = 4
f f A B a a 1 1 b 2 b 2 c 3 3 d c 4 noto not noto • Example 8 : 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 9 : Note : 當|A| < |B| 時,必定不會onto.
a 1 b 2 c a d 1 3 b 2 a 1 not 1-1 , onto c 3 2 d 4 b 3 c 4 1-1 and onto 1-1 , onto Def 8 : The function f is a one-to-one correspondence , or a bijection , if it is both 1-1 and onto. Examples in Fig 5 ※補充 : 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|.
※Some important functions • Def 12 : • floor function : x : ≤ x 的最大整數,即 [ x ] • ceiling function : x : ≥ x 的最小整數. • Example 21 : ½ = -½ = 7 = ½ = -½ = 7 = • Example 26 : • factorial function : f : N → Z+ , f (n) = n! = 1 x 2 x … x n • Exercise : 1,12,17,19