Successfully reported this slideshow.
Upcoming SlideShare
×

# Section1-1

1,641 views

Published on

Published in: Education, Technology
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

### Section1-1

1. 1. . Preface 目標 這門課應該教導同學如何用邏輯與數學 來思考 (how to think logically and mathematically)。 內容 包括五個部份：mathematical reasoning(數學推理)、combinatorial analysis(組合分析)、discrete structure(離散結構)、algorithmic thinking(演算法的思考)、applications and modeling(應用與模型) . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 1 / 41
2. 2. . 教材 課本 Discrete Mathematics and its Applications(sixth edition), Kenneth H. Rosen 參考書籍 離散數學 (Discrete Mathematics and its Applications 中譯本) sixth edition, 謝良 瑜陳志賢譯 . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 2 / 41
3. 3. . 自我介紹 姓名 洪春男 email spring@mail.dyu.edu.tw 電話 04-8511888 轉 2410 辦公室 工學院 H311 Homepage http://www.dyu.edu.tw/ spring . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 3 / 41
4. 4. . 評分標準 期中考 20% 期末考 30% 平常分數 50%(點名與隨堂測驗、作業、平常考 大約各佔 1/3) . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 4 / 41
5. 5. . Contents 1. The Foundations: Logic and Proofs(1.1-1.7) . 2 Basic Structures: Sets, Functions, Sequences, and Sums(2.1-2.4) 3. The Fundamentals: Algorithms, the Integers, and Matrices(3.1-3.5, 3.8) 4. Induction and Recursion(4.1-4.3) . 5 Counting(5.1-5.3) 6. Discrete Probability(6.1) . 7 Advanced Counting Techniques(7.1, 7.5) . 8 Relations(8.1, 8.3, 8.5) 9. Graphs(9.1-9.5) . 10 Trees(10.1) . Boolean Algebra 11 . 12 Modeling Computation . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 5 / 41
6. 6. . 1. The Foundations: Logic and Proofs Logic is the basis of all mathematical reasoning, and of all automated reasoning. 邏輯是所有數 學推理與自動推理的基礎。 To understand mathematics, we must understand what makes up a correct mathematical argument, that is, a proof. 要了 解數學，必須了解建構正確的數學論證，也 就是證明。 . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 6 / 41
7. 7. . 1.1 Propositional Logic 命題邏輯 A proposition is a declarative sentence(that is, a sentence that declares a fact) that is either true or false, but not both. 命題是一個述句 (宣告事實的句子)，它可能是真、也可能是 假，但不能旣真又假。 . Example 1 . 1. Washington, D.C., is the capital of the United States of America. 華盛頓特區是美國首都。 2. Toronto is the capital of Canada. 多倫多是加 拿大首都。 3. 1 + 1 = 2. 4. 2 + 2 = 3. . 洪春男 . . 1. The Foundations: Logic and Proofs . . . March 1, 2011 . 7 / 41
8. 8. . 1.1 Propositional Logic 命題邏輯 . Example 2 . 下列是錯誤的 propositions 1. What time is it? 現在幾點？ 2. Read this carefully. 小心閱讀。 3. x + 1 = 2. . . x + y = z. 4 . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 8 / 41
9. 9. . 1.1 Propositional Logic 命題邏輯 propositional variables 命題變數, p, q, r, s, · · · truth value: T(真)、F(假) The area of logic that deals with propositions is called the propositional calculus or propositional logic. 專門處理命題的邏輯稱 為命題演算或命題邏輯，亞里斯多德 (Aristotle) 最早開始使用。 New propositions, called compound propositions, are formed from existing propositions using logical operators. 由已存在 的命題加上邏輯運算子形成新的命題，稱為 複合命題。 . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 9 / 41
10. 10. . 1.1 Propositional Logic 命題邏輯 . Deﬁnition 1 . Let p be a proposition. The negation of p, denoted by ¬p(also denoted by p), is the statement “It is not the case that p.” The proposition ¬p is read “not p”. The truth value of the negation of p, ¬p, is the opposite of the truth value of p. 令 p 為一命題， p 的否定句為「p 不成立」 ，以 ¬p 表示 (有時也用 p 表示)。 ¬p 讀作「非 p」 ， 其真假值與 p 的真假值剛好相反。 . . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 10 / 41
11. 11. . 1.1 Propositional Logic 命題邏輯 . Example 3 . Find the negation of the proposition “Today is Friday.” and express this in simple English. 找出「今天是星期五」的否定命題，且用簡單的 英文表示。 “It is not the case that today is Friday.” “Today is not Friday.” “It is not Friday today.” 「今天是星期五不成立」或「今天不是星期五」 . . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 11 / 41
12. 12. . 1.1 Propositional Logic 命題邏輯 . Example 4 . Find the negation of the proposition “At least 10 inches of rain fell today in Miami.” and express this in simple English. 找出「邁阿密今天至少下 10 英吋的雨」的否定 命題，且用簡單的英文表示。 “It is not the case that at least 10 inches of rain fell today in Miami.” “Less than 10 inches of rain fell today in Miami.” 「邁阿密今天至少下 10 英吋的雨不成立」或 「邁阿密今天下不到 10 英吋的雨」 . 。 . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 12 / 41
13. 13. . 1.1 Propositional Logic 命題邏輯 . Deﬁnition 2 . Let p and q be propositions. The conjunction of p and q, denoted by p ∧ q, is the proposition “p and q.”. The conjunction p ∧ q is true when both p and q are true and is false otherwise. 令 p 與 q 都是命題， p 與 q 同時發生為「p 和 q」 ，記成 p ∧ q，當 p 與 q 都是真時 p ∧ q 為真， 否則為假。 . . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 13 / 41
14. 14. . 1.1 Propositional Logic 命題邏輯 . Example 5 . Find the conjunction of the propositions p and q where p is the proposition “Today is Friday” and q is the proposition “It is raining today”. 令命題 p 為「今天是星期五」 ，命題 q 為「今天 下雨」 ，請找出 p 與 q 的 conjunction。 “Today is Friday and it is raining today.” 「今天是星期五且下雨」 . . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 14 / 41
15. 15. . 1.1 Propositional Logic 命題邏輯 . Deﬁnition 3 . Let p and q be propositions. The disjunction of p and q, denoted by p ∨ q, is the proposition “p or q.”. The disjunction p ∨ q is false when both p and q are false and is true otherwise. 令 p 與 q 都是命題， p 與 q 的分裂為「p 或 q」 ，記成 p ∨ q，當 p 與 q 都是假時 p ∨ q 為假， 否則為真。 . or 有 inclusive 與 exclusive 的分別， ∨ 是 inclusive。 . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 15 / 41
16. 16. . 1.1 Propositional Logic 命題邏輯 . Example 6 . What is the disjunction of the propositions p and q where p and q are the same propositions as in Example 5. 令命題 p 為「今天是星期五」 ，命題 q 為「今天 下雨」 ，請問 p 與 q 的 disjunction。 “Today is Friday or it is raining today.” 「今天是星期五或今天下雨」 . . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 16 / 41
17. 17. . 1.1 Propositional Logic 命題邏輯 . Deﬁnition 4 . Let p and q be propositions. The exclusive or of p and q, denoted by p ⊕ q, is the proposition that is true when exactly one of p and q is true and is false otherwise. 令 p 與 q 都是命題， p 與 q 的互斥或，記成 p ⊕ q，當 p 與 q 恰為一真一假時 p ⊕ q 為真，否 則為假。 . . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 17 / 41
18. 18. . 1.1 Propositional Logic 命題邏輯 The truth table 真值表 p q ¬p p ∧ q p ∨ q p ⊕ q T T F T T F T F F F T T F T T F T T F F T F F F . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 18 / 41
19. 19. . 1.1 Propositional Logic 命題邏輯 . Deﬁnition 5 . Let p and q be propositions. The conditional statement p → q is the proposition “if p, then q.” The conditional statement p → q is false when p is true and q is false, and true otherwise. In the conditional statement p → q, p is called the hypothesis(or antecedent or premise) and q is called the conclusion(or consequence). 令 p 與 q 都是命題，條件句 p → q 代表「若 p 則 q」的命題。當 p 真 q 假時，條件句 p → q 為 假，否則為真。其中 p 稱為假設 (或前提)、而 q 稱為結論。 . . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 19 / 41
20. 20. . 1.1 Propositional Logic 命題邏輯 A conditional statement is also called an implication. 條件句有時也稱為隱涵。 下列都是「若 p 則 q」的寫法： p, then 「if q」 「p implies q」 「if p, q」, 「p only if q」, 、 、 「p is suﬃcient for q」, 「a suﬃcient condition for q is p」, 「q if p」, 「q whenever p」, 「q when p」 「q is necessary for p」 「a necessary 、 、 condition for p is q」 「q follows from p」 「q 、 、 unless ¬p」 “If I am elected, then I will lower taxes.” 若我當 選就減稅。 “If you get 100% on the ﬁnal, then you will get an A.” 期末考 100 分就得 A。 . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 20 / 41
21. 21. . 1.1 Propositional Logic 命題邏輯 . Example 7 . Let p be the statement “Maria learns discrete mathematics” and q the statement “Maria will ﬁnd a good job.” Express the statement p → q as a statement in English. 令 p 是「瑪麗亞學離散數學」 q 為「瑪麗亞將 ， 找到好工作」 ，請用英文表達 p → q。 “If Maria learns discrete mathematics, then she will ﬁnd a good job.”，「若瑪麗亞學離散數學，她將 找到好工作」 ，“Maria will ﬁnd a good job when she learns discrete mathematics.”，“Maria will ﬁnd a good job unless she does not learn discrete mathemathics.” . . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 21 / 41
22. 22. . 1.1 Propositional Logic 命題邏輯 “If it is sunny today, then we will go to the beach.” 若今天出太陽，我們將去海邊玩。 “If today is Friday, then 2 + 3 = 5.” 若今天是 星期五，則 2 + 3 = 5。 “If today is Friday, then 2 + 3 = 5.” 若今天是 星期五，則 2 + 3 = 6。 前題與結果未必需要有因果關係。 . Example 8 . if 2 + 2 = 4 then x := x + 1. 若在這個 statement 之前 x = 0 的話，執行之後 x 的值是多少？ . . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 22 / 41
23. 23. . 1.1 Propositional Logic 命題邏輯 The proposition q → p is called the converse (相反) of p → q. The contrapositive (對換) of p → q is the proposition ¬q → ¬p. The proposition ¬p → ¬q is called the inverse (相反) of p → q. When two compound propositions always have the same truth value we call them equivalent. . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 23 / 41
24. 24. . 1.1 Propositional Logic 命題邏輯 . Example 9 . What are the contrapositive, the converse, and the inverse of the conditional statement “The home team wins whenever it is raining.”? 每 當下雨時地主隊獲勝。 contrapositive “If the home team doesn’t win, then it is not raining.” 若地主隊沒贏就沒有下雨。 converse “If the home team wins, then it is raining.” 若地主隊贏就下雨 inverse “If it is not raining, then the home team doesn’t win.” 若沒下雨地主隊就沒贏。 . . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 24 / 41
25. 25. . 1.1 Propositional Logic 命題邏輯 . Deﬁnition 6 . Let p and q be propositions. The biconditional statement p ↔ q is the proposition “p if and only if q.” The biconditional statement p ↔ q is true when p and q have the same truth values, and is false otherwise. Biconditional statements are also called bi-implications. 令 p 與 q 都是命題，雙條件句 p ↔ q 代表「p 若 且唯若 q」的命題。當 p 與 q 有相同真假值時， 雙條件句 p ↔ q 為真，否則為假。雙條件句又稱 為雙蘊涵。 . . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 25 / 41
26. 26. . 1.1 Propositional Logic 命題邏輯 當 p → q 與 q → p 都是 true 時 p ↔ q 才為 true。 「p is necessary and suﬃcient for q」 「if p 、 then q, and conversely」 「p iﬀ q」都是 p ↔ q 、 的意思。iﬀ 是 if and only if 的縮寫。 . Example 10 . Let p be the statement “You can take the ﬂight” and let q be the statement “You buy a ticket.” Then p ↔ q is the statement “You can take the ﬂight if and only if you buy a ticket.” . . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 26 / 41
27. 27. . 1.1 Propositional Logic 命題邏輯 The truth table 真值表 p q p → q q → p ¬q → ¬p ¬p → ¬q p ↔ q T T T T T T T T F F T F T F F T T F T F F F F T T T T T . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 27 / 41
28. 28. . 1.1 Propositional Logic 命題邏輯 . Example 11 . Construct the truth table of the compound proposition (p ∨ ¬q) → (p ∧ q). . p q ¬q p ∨ ¬q p ∧ q (p ∨ ¬q) → (p ∧ q) T T F T T T T F T T F F F T F F F T F F T T F F . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 28 / 41
29. 29. . 1.1 Propositional Logic 命題邏輯 Precedence of Logical Operators 邏輯運算子的優先順序 Operator Precedence ¬ 1 ∧ 2 ∨ 3 → 4 ↔ 5 . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 29 / 41
30. 30. . 1.1 Propositional Logic 命題邏輯 . Example 12 . How can this 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.” 只有當你主修電腦或不是新鮮人，才能在校園中 使用網路 a 代表 “You can access the Internet from campus.” c 代表 “You are a computer science major.” f 代表 “You are a freshman.” 前面的句字可翻譯為 a → (c ∨ ¬f) . . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 30 / 41
31. 31. . 1.1 Propositional Logic 命題邏輯 . Example 13 . How can this English sentence be translated into a logical expression? “You cannot ride the roller coaster if you are under 4 feet tall unless you are older than 16 years old.” 若你不到 4 英呎高就不能坐雲霄飛車，除非你超 過 16 歲。 q 代表 “You can ride the roller coaster.” r 代表 “You are under 4 feet tall.” s 代表 “You are older than 16 years old.” 前面的句字可翻譯為 (r ∧ ¬s) → ¬q . . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 31 / 41
32. 32. . 1.1 Propositional Logic 命題邏輯 . Example 14 . Express the speciﬁcation “The automated reply cannot be sent when the ﬁle system is full” using logical connectives. 使用邏輯連詞表達下列規 定： 「當檔案系統滿了，自動回覆功能不能被送 出」 。 p 代表 “The automated reply can be sent.” q 代表 “The ﬁle system is full.” 前面的句字可翻譯為 q → ¬p . . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 32 / 41
33. 33. . 1.1 Propositional Logic 命題邏輯 . Example 15 . Determine whether these system speciﬁcations are consistent: “The diagnostic message is stored in the buﬀer or it is retransmitted.” “The diagnostic message is not stored in the buﬀer.” “If the diagnostic message is stored in the buﬀer, then it is retransmitted.” p 代表 “The diagnostic message is stored in the buﬀer.” q 代表 “The diagnostic message is retransmitted.” 前面三個句字為 p ∨ q, ¬p, p → q，當 p 為 F 而 q 為 T 時，三個句子都成立，因此 consistent。 . . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 33 / 41
34. 34. . 1.1 Propositional Logic 命題邏輯 . Example 16 . Do the system speciﬁcations in Example 15 remain consistent if the speciﬁcation “The diagnostic message is not retransmitted” is added? p 代表 “The diagnostic message is stored in the buﬀer.” q 代表 “The diagnostic message is retransmitted.” 四個句字為 p ∨ q, ¬p, p → q, ¬q，顯然無法使四 個句子都為 true，因此不 consistent。 . . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 34 / 41
35. 35. . 1.1 Propositional Logic 命題邏輯 - boolean searches 可在搜尋引擎中輸入下列關鍵字，看看結果如何 . Example 17 . New and Mexico and University「New Mexico University」 (New and Mexico or Arizona) and University (Mexico and Universities) not New 「Mexico Universities -New」 大葉 -高島屋 大葉資訊 -資管 -會計 . . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 35 / 41
36. 36. . 1.1 Propositional Logic 命題邏輯 - Logic Puzzles . Example 18 . An island that has two kinds of inhabitants(居民), knights(騎士),who always tell the truth, and their opposites, knaves(無賴), who always lie. You encounter two people A and B. What are A and B if A says “B is a knight” and B says “The two of us are opposite types”? . . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 36 / 41
37. 37. . 1.1 Propositional Logic 命題邏輯 - Logic Puzzles 答案：Both A and B are knaves. . Example 19 . 兩個兄妹在後院玩，兩人的前額都沾了泥巴，父 親說： 「你們兩人中至少一人前額有泥巴。 」父親 問： 「你知道你自己的前額有沒有沾泥巴呢？」 父親問兩次，請問兩個小朋友會如何回答？假設 小朋友可看到另一人的前額、看不到自己的前 額，且都說實話，兩人只能回答 Yes / No。 . . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 37 / 41
38. 38. 1.1 Propositional Logic 命題邏輯 - Logic and Bit. Operations 答案：第一次都回答 NO，第二次都是 Yes。 A bit is a symbol with two possible values, namely, 0(zero) and 1(one). 可代表 true(1) 與 false(0)。 A variable is called a Boolean variable if its value is either true or false. . Deﬁnition 7 . A bit string is a sequence of zero or more bits. The length of this string is the number of bits in the string. . . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 38 / 41
39. 39. 1.1 Propositional Logic 命題邏輯 - Logic and Bit. Operations . Example 20 . 101010011 is a bit string of length nine. . We deﬁne the bitwise OR, bitwise AND, and bitwise XOR of two strings of the same length to be the strings that have as their bits the OR, AND, and XOR of the corresponding bits in the two strings, respectively. . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 39 / 41
40. 40. 1.1 Propositional Logic 命題邏輯 - Logic and Bit. Operations . Example 21 . Find the bitwise OR, bitwise AND, and bitwise XOR of the bit strings 0110110110 and 1100011101. 0110110110 1100011101 bitwise OR 1110111111 bitwise AND 0100010100 . bitwise XOR 1010101011 . . . . . . 洪春男 1. The Foundations: Logic and Proofs March 1, 2011 40 / 41
41. 41. 謝謝大家的聆聽！ . . . . . .洪春男 1. The Foundations: Logic and Proofs March 1, 2011 41 / 41