งานนำเสนอกำลังจะดาวน์โหลด โปรดรอ

งานนำเสนอกำลังจะดาวน์โหลด โปรดรอ

San Ratanasanya สรร รัตนสัญญา CS, KMUTNB

งานนำเสนอที่คล้ายกัน


งานนำเสนอเรื่อง: "San Ratanasanya สรร รัตนสัญญา CS, KMUTNB"— ใบสำเนางานนำเสนอ:

1 San Ratanasanya สรร รัตนสัญญา CS, KMUTNB
Discrete Mathematics for Computer Science คณิตศาสตร์ไม่ต่อเนื่องสำหรับวิทยาการคอมพิวเตอร์ San Ratanasanya สรร รัตนสัญญา CS, KMUTNB

2 Course Description (คำอธิบายรายวิชา)
พื้นฐานและรากฐานต่างๆ ทางคณิตศาสตร์ที่เกี่ยวข้องกับทางด้านวิทยาการคอมพิวเตอร์ ตรรกะและการพิสูจน์ เซต ฟังก์ชัน ขั้นตอนวิธี การให้เหตุผลแบบอุปนัยความสัมพันธ์แบบเวียนบังเกิด ทฤษฎีกราฟ โครงสร้างแบบทรี [ ระบบเลขฐาน เมตริกซ์ เครื่องจักรทัวริง ] Course Objectives (จุดมุ่งหมายรายวิชา) เพื่อศึกษาเครื่องมือทางคณิตศาสตร์ต่างๆ ที่ใช้ในการแก้ปัญหาทางคอมพิวเตอร์ เพื่อเป็นพื้นฐานในการศึกษา วิเคราะห์และออกแบบโครงสร้างข้อมูลรวมถึงขั้นตอนวิธีการแก้ปัญหาทางคอมพิวเตอร์ เพื่อเป็นพื้นฐานในการออกแบบหน่วยประมวลผลกลาง และ ชุดคำสั่งของคอมพิวเตอร์

3 Course Outline (โครงร่างรายวิชา)
Tentative Logics and Proofs Sets, Functions, Sequences, and Sums Algorithm, the Integers, and Matrices Induction and Recursion Counting and Advance Counting Techniques Discrete Probability Relations Graphs and Trees Boolean Algebra Modeling Computation

4 Textbooks Main Text Supplementary
Kenneth H. Rosen, Discrete Mathematics and Its Applications, 6th edition, McGraw-Hill, 2006 Supplementary Any related textbooks

5 Other Details Office Hours
Instructor: TBA TA: TBA Contact Info Class Agreement Assignments Grading Class webpage See Syllabus

6 What and Why Discrete Math?
Discrete หมายความว่า ไม่ต่อเนื่อง (not continuous) สิ่งที่จับต้องได้ นับได้ วัดได้ เป็นจำนวนเต็มหน่วย รู้ปริมาณแน่ชัด เช่น 1, 2, 3,… หรือ 2.1, 2.2, 2.3,… True, False Computer มีวิธีการทำงานแบบ Discrete เราศึกษาเครื่องมือทางคณิตศาสตร์ที่มีลักษณะเป็น Discrete เพื่อเป็นพื้นฐานในการทำความเข้าใจการทำงาน การวิเคราะห์และออกแบบวิธีการเพื่อแก้ปัญหาการทำงานของ Computer

7 Discrete Math in Real World
Internet Computer Graphics Image Processing and Computer Vision Computer Security Database Compiler Design Computer Networking AI and Robotics Etc.

8 Today’s topics Review of Logics and Proofs (Ch. 1) Propositional Logic
Propositional Equivalences Predicates and Quantifiers Nested Quantifiers [Rules of Inference] [Introduction to Proofs] [Proof Methods and Strategy]

9 Propositional Logic : Overview
Propositional Logic is the logic of compound statements built from simpler statements using Boolean connectives. Applications: Design of digital electronic circuits. Expressing conditions in programs. Queries to databases & search engines.

10 Logic เป็นพื้นฐานของการให้เหตุผลทางคณิตศาสตร์ ใช้สำหรับ
Design of computing machines/circuits Specification of systems Artificial intelligence Construction of computer program Programming languages

11 Proof Makes up a correct mathematical argument
Once we prove a mathematical statement is true, we call it a theorem Knowing the proof of a theorem makes it possible to modify the result to fit new situations Proofs play an essential role in the development of new ideas

12 ความสำคัญของ Proof ใน Computer Science
Plays essential roles when we verify that computer programs produce the correct output for all possible input values when we show that algorithms always produce correct result when we establish the security of a system when we create artificial intelligence Automated reasoning systems have been constructed that allow computers to construct their own proofs

13 Sentence (ประโยค) Declarative Sentence – ประโยคบอกเล่า
เรากำลังเรียนวิชา Discrete Math Exclamatory Sentence – ประโยคอุทาน โอ้! พระเจ้ายอด มันจอร์จมาก Interrogative Sentence – ประโยคคำถาม วันนี้เป็นวันที่เท่าไหร่ Imperative Sentence – ประโยคยืนยัน, คำสั่ง กรุณาปิดเครื่องมือสื่อสาร ห้ามคุย

14 What is Proposition ? Definition
A proposition (p, q, r, …) is simply a statement (i.e., a declarative sentence) with a definite meaning, having a truth value that’s either true (T) or false (F) (never both, neither, or somewhere in between). [In probability theory, we assign degrees of certainty to propositions. For now: True/False only!] สรุปคือ ในตรรกศาสตร์ proposition (ประพจน์) เป็นประโยคที่มีค่าความจริงเป็น จริง หรือ เท็จ เท่านั้น

15 Examples of Proposition
q: 1+1=4 r: นนทบุรีไม่ใช่เมืองหลวงของประเทศไทย Washington, D.C. is the capital of the United State of America

16 Examples of NOT Proposition
ไปกินข้าวกัน 1 + 1 หากพวกเรากำลังสบาย จงปรบมือพลัน ไผเน่ a + b = 10

17 Compound Proposition Compound Proposition คือ ประพจน์ หรือประโยคที่เกิดจากการเชื่อมประพจน์เดี่ยวมากกว่า 1 ประพจน์เข้าด้วยกันโดยใช้ตัวเชื่อมทางตรรกวิทยา

18 Truth Table Has a row for each of the two possible truth values of a proposition

19 Negation Operator (¬) ใช้เป็นตัวขยายประโยค Negation of p : ¬p
not – ไม่ it is not true that… – มันไม่จริงที่ว่า… Negation of p : ¬p ตัวอย่าง p: วันนี้เป็นวันศุกร์ p: มีคนในห้องนี้อย่างน้อย 10 คน

20 Truth Table for Negation

21 Logical Connectives/Operators ตัวเชื่อมทางตรรกวิทยา
Conjunction (٨): and และ Disjunction (٧): or หรือ Exclusive Or (): xor Conditional (): if … then ถ้า … แล้ว Biconditional (): if and only if ถ้าและเพียงแต่ถ้า, เมื่อและต่อเมื่อ

22 Conjunction Definition:
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.

23 Truth Table for Conjunction

24 Example: Conjunction p is the proposition “Today is Friday”.
q is the proposition “It is 6 PM”.

25 Disjunction Definition:
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.

26 Truth Table for Disjunction
p q T T T T F T F T T F F F

27 Example: Disjunction p is the proposition “Today is Friday”
q is the proposition “It is 8 PM”.

28 Exclusive Or Definition:
Let p and q be propositions. The exclusive or of p and q, denoted by , is the proposition that is true when exactly one of p and q is true and is false otherwise.

29 Exclusive Or p q T T F T F T F T T F F F

30 Example – การเลือกใช้ operator ในประโยคภาษาไทย
วันนี้ฝนตกและลมแรง ระบายสีด้วยสีแดงหรือสีเหลือง ห้องนี้สำหรับนักศึกษาภาควิชาคอมพิวเตอร์และคณิตศาสตร์เท่านั้น เสต็กกับ มันอบหรือขนมปัง

31 Conditional Statement
Definition: Let p and q be propositions. The conditional statement p -> q is the proposition “if p, then q.” The condition statement p -> q is false when p is true and q is false, and true otherwise. A conditional statement is also called an “Implication.”

32 Truth Table for Conditional
p q p q T T T T F F F T T F F T

33 Conditional Statement
In the conditional statement p -> q, p is called the hypothesis (or antecedent or premise) and q is called the conclusion (or consequence).

34 Conditional q, if p if p then q q, when p p only if q q, whenever p
p implies q p is sufficient condition for q q is necessary condition for p q, if p q, when p q, whenever p q, provided p

35 Example ถ้าผมได้รับเลือกเป็นหัวหน้าห้อง, ผมจะเลี้ยงข้าวกลางวันเพื่อนในห้องทุกคน ถ้าคุณสอบได้คะแนนเต็ม 100, คุณจะได้เกรด A ถ้าวันนี้เป็นวันเสาร์, พระอาทิตย์จะตกตอนเย็น conclusion is true, truth value of hypothesis does not matters ถ้าวันนี้เป็นวันเสาร์, พระอาทิตย์จะตกตอนเที่ยง F เฉพาะวันเสาร์ Propositional language is an artificial language.

36 Biconditional Statement
Definition: 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 statement is also called bi-implications.

37 Biconditional Statement
p <-> q is true when both the conditional statements p -> q and q -> p are true and is false otherwise.

38 Biconditional Statement
p q q p T T T T F F F T F F F T

39 Biconditional Statement
p is necessary and sufficient for q if p then q, and conversely p iff q

40 ทบทวน Logical Operators

41

42 Discrete Mathematics for Computer Science

43 Discrete Mathematics for Computer Science

44 Discrete Mathematics for Computer Science

45 Discrete Mathematics for Computer Science

46 Discrete Mathematics for Computer Science

47 Precedence of Logical Operators
1 2 3 4 5 6

48 Example วิธีคิด

49 Truth Table for Compound Statement
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

50 Truth Table for Compound Statement - ลองทำเอง
q r T F

51 จำนวนแถวในตารางค่าความจริง (Truth Table)
ตารางค่าความจริง สำหรับ compound proposition ที่มีตัวแปร propositional variables จำนวน n ตัว จะมีจำนวนแถวเป็น 2n แถว

52 ตัวอย่างการแปลงประโยคให้อยู่ในรูป Compound Statement
ถ้าคุณเป็นนักศึกษาภาควิชาคอมพิวเตอร์และลงทะเบียนเรียนวิชาคณิตศาสตร์ไม่ต่อเนื่อง คุณจะสามารถพบอาจารย์ผู้สอนได้ในวันอาทิตย์ กำหนดให้ p คือประพจน์ “คุณเป็นนักศึกษาภาควิชาคอมพิวเตอร์” q คือประพจน์ “คุณลงทะเบียนเรียนวิชาคณิตศาสตร์ไม่ต่อเนื่อง” r คือประพจน์ “คุณสามารถพบอาจารย์ผู้สอนได้ในวันอาทิตย์”

53 ตัวอย่างการนำไปใช้ การระบุ system specification/requirement (hardware/software) for system development Logic and Bit Operations Boolean search: web page searching Logic puzzles

54 Example: Logical Puzzle
บนเกาะแห่งหนึ่งมีคนสองประเภท คือ knights ที่จะพูดแต่ความจริงกับ knaves ที่จะพูดแต่เรื่องโกหก ถ้าเจอคนสองคนที่พูดว่า A: B เป็น knight B: พวกเราทั้งสองคนเป็นคนคนละประเภทกัน ถามว่า A และ B เป็นคนประเภทไหน

55 วิธีคิด กำหนดให้ สมมติว่า p เป็นจริง (A เป็น knight)
q หมายถึง “B เป็น knight” สมมติว่า p เป็นจริง (A เป็น knight) แสดงว่าสิ่งที่ A พูดเป็นความจริงก็คือ B เป็น knight ซึ่งหมายถึง q เป็นจริง เมื่อ q เป็นจริง สิ่งที่ B พูดก็เป็นความจริง (A และ B เป็นคนละประเภทกัน) ซึ่งเป็นไปไม่ได้ ดังนั้น สรุปได้ว่า p จะต้องเป็นเท็จเท่านั้น

56 วิธีคิด (ต่อ) หาก p เป็นเท็จ นั่นคือ A เป็น knave
ดังนั้นสิ่งที่ A พูดไม่เป็นความจริง คือ p หรือ “B เป็น knight” เป็นเท็จ แปลได้ว่า “B เป็น knave” เมื่อ B เป็น knave สิ่งที่ B พูดก็เป็นเท็จ นั่นคือ q หรือ “A และ B เป็นคนละประเภทกัน” เป็นเท็จ ดังนั้น สรุปคำตอบได้ว่า ทั้ง A และ B เป็น knave เหมือนกัน

57 คำตอบ logic puzzle ข้างต้น
ทั้งสองคนเป็น knave

58 1.2 Propositional Equivalences

59 ประเภทของ Compound Propositions
Definition: A compound proposition that is always true, no matter what the truth values of the propositions that occur in it, is called a tautology. A compound proposition that is always false is called a contradiction. A compound proposition that is neither a tautology nor a contradiction is called a contingency

60 Example: Tautology p T F

61 Example: Contradiction
F

62 ความสมมูล Logically Equivalent
Definition: The compound propositions p and q are called logically equivalent if is a tautology. The notation or denotes that p and q are logically equivalent.

63 Logically Equivalent เมื่อ เป็น tautology

64 การตรวจสอบความสมมูลของประพจน์
ใช้ Truth table

65 Example: Logical Equivalence

66 Example: Logical Equivalence

67 Example: Logical Equivalence
Discrete Mathematics for Computer Science

68 Example: Logical Equivalence

69 Example: Logical Equivalence
Discrete Mathematics for Computer Science

70 กฎของการสมมูล

71 De Morgan’s Law พิสูจน์ว่ากฏของ De Morgan เป็นจริง (ใช้ Operation “<-->” แสดงให้เห็นว่าเป็น tautology โดยใช้ truth table)

72 Important Logical Equivalences
Identity Laws Domination Laws

73 Important Logical Equivalences
Idempotent Laws Double Negation Law

74 Important Logical Equivalences
Commutative Laws Associative Law

75 Important Logical Equivalences
Distributive Laws Discrete Mathematics for Computer Science

76 Important Logical Equivalences
Absorption Laws Negation Laws

77 Example1 จงแสดงว่า compound proposition ต่อไปนี้สมมูลกัน

78 Example1 (cont.) De Morgan’s Law Double Negation Law Distributive Law
Commutative Law for Disjunction Identity Law

79 Table 7: Logical Equivalences Involving Conditional Statements
code C1 C2 C3 C4 C5 C6 C7 C8 C9

80 Table 8: Logical Equivalences Involving Biconditionals
code B1 B2 B3 B4

81 Example2 จงแสดงว่า เป็น tautology Table 7: C1 De Morgan’s Law
Associative and Commutative Law for disjunction Commutative Law for disjunction and Negation law Domination law

82 Practice: แสดงว่าประโยคต่อไปนี้สมมูลกัน
และ

83 Homework And quiz next section

84 1.3 Predicate Calculus: Predicates and Quantifiers

85 Predicate Predicate refers to a property that the subject of the statement can have. x is greater than 3 เขียนแทน “x is greater than 3” ว่า P(x) P(x): Propositional function of P at x Subject (Variable) Predicate

86 Example กำหนดให้ P(x) หมายถึง “x>3”
จงบอกค่าความจริงของ P(4) , P(2) ? กำหนดให้ A(x) หมายถึง “Student x is a man.” จงบอกค่าความจริงของ A(สมชาย) , A(ส้มโอ) กำหนดให้ Q(x,y) หมายถึง “x=y+3.” จงบอกค่าความจริงของ Q(1,2) , Q(3,0)

87 Quantifiers Express the value of a predicate over a range of elements on a domain. Universal Quantifiers Existential Quantifiers

88 Definition: Universal Quantifiers
The universal quantification of P(x) is the statement “P(x) for all values of x in the domain.” The notation denotes the universal quantification of P(x). Here is called the universal quantifier. We read as “for all x P(x)” or “for every x P(x).” An element for which P(x) is false is called a counterexample of

89 จำนวนจริง

90 Example: Universal Quantifier
กำหนดให้ P(x) หมายถึง “x+1>x.” จงบอกค่าความจริงของ เมื่อกำหนดโดนเมนเป็นจำนวนจริงทั้งหมด กำหนดให้ Q(x) หมายถึง “x<2.” จงบอกค่าความจริงของ เมื่อกำหนดให้โดเมนคือจำนวนจริงทั้งหมด T F

91 Note Empty Domain: จงหาค่าของ ในโดเมนที่ประกอบด้วยสมาชิกได้แก่ :
มีค่าเป็นจริง เนื่องจากไม่มีสมาชิก x ตัวใดในโดเมนที่ทำให้ค่า P(x) เป็น false. ในโดเมนที่ประกอบด้วยสมาชิกได้แก่ : ค่าของ หมายถึง

92 Example: Universal Quantifier
จงหาค่าความจริงของ เมื่อกำหนดให้ P(x) หมายถึง และโดเมนประกอบด้วยจำนวนเต็มบวกที่มีค่าไม่เกิน 4 F T T T F

93 Definition: Existential Quantifiers
The existential quantification of P(x) is the statement “There exists an element x in the domain such that P(x).” We use the notation for the existential quantification of P(x). Here is called the existential quantifier.

94 Example: Existential Quantifier
กำหนดให้ P(x) หมายถึง “x>3” จงบอกค่าความจริงของ เมื่อกำหนดให้โดเมนเป็นจำนวนจริง กำหนดให้ Q(x) หมายถึง “x=x+1” เมื่อกำหนดโดเมนเป็นจำนวนจริง T F

95 Note Empty Domain: จงหาค่าของ โดเมนที่ประกอบด้วย :
มีค่าเป็น false สำหรับ P(x) ใดๆ เพราะไม่มีสมาชิกใดที่ทำให้ P(x) มีค่าเป็น true โดเมนที่ประกอบด้วย : ค่าของ สามารถหาได้จาก

96 Example: Existential Quantifier
จงหาค่าความจริงของ เมื่อกำหนดให้ P(x) หมายถึง และกำหนดโดเมนประกอบด้วยจำนวนเต็มบวกที่ไม่เกิน 4 T F F F T

97 Truth Value Statement When True When False
P(x) is true for every x. There is an x for which P(x) is false. There is an x for which P(x) is true. P(x) is false for every x.

98 Precedence of Quantifiers
Quantifiers and have higher precedence than all logical operators from propositional calculus

99 Logical Equivalences Involving Quantifiers: Definition
Statement involving predicates and quantifiers are logically equivalent if and only if they have the same truth value no matter which predicates are substituted into these statements and which domain of discourse is used for the variables in these propositional functions. We use the notation S Ξ T to indicate that two statement S and T involving predicates and quantifiers are logically equivalent.

100 Logical Equivalences Involving Quantifiers: Example

101 Negating Quantified Expressions

102 De Morgan’s Laws for Quantifiers

103 De Morgan’s Laws for Quantifiers

104 De Morgan’s Laws for Quantifiers

105 1.4 Nested Quantifiers

106 Nested Quantifiers Q(x)

107 Order of Quantifiers The order of the quantifiers is important, unless all the quantifiers are universal quantifiers or all are existential quantifiers

108 Order of Quantifiers Not equivalent to

109 Example T F กำหนดให้ Q(x,y) หมายถึง “x+y=0”
จงบอกค่าความจริงของ statement ต่อไปนี้ T F

110 Discrete Mathematics for Computer Science
Note Discrete Mathematics for Computer Science

111 Exercise Write truth table for
Find if the following pairs are logically equivalent Using truth table: and Using equivalent rules: and


ดาวน์โหลด ppt San Ratanasanya สรร รัตนสัญญา CS, KMUTNB

งานนำเสนอที่คล้ายกัน


Ads by Google