• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Discrete-Chapter 04 Logic Part I
 

Discrete-Chapter 04 Logic Part I

on

  • 439 views

 

Statistics

Views

Total Views
439
Views on SlideShare
439
Embed Views
0

Actions

Likes
0
Downloads
11
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Discrete-Chapter 04 Logic Part I Discrete-Chapter 04 Logic Part I Document Transcript

    • Logic - 04 CSC1001 Discrete Mathematics 1 CHAPTER ตรรกศาสตร์ 4 (Logic) 1 Propositional Logic1. Propositions The rules of logic give precise meaning to mathematical statements. These rules are used to distinguishbetween valid and invalid mathematical arguments. We usually start our study of discrete mathematics withlogic. Our discussion begins with an introduction to the basic building blocks of logic—propositions. Definition 1 A proposition is a declarative sentence (that is, a sentence that declares a fact) that is either true or false, but not both. Definition 2 We use letters to denote propositional variables (or statement variables), that is, variables that represent propositions, for example p, q, r, s, … . The truth value of a proposition is denoted by T, if it is a true proposition, and the truth value of a proposition is denoted by F, if it is a false proposition.Example 1 (10 points) All the following declarative sentences are propositions or not? If they are a propositionplease indentify its true or false?1) Yingluck Shinawatra is the 28th Prime Minister of Thailand. ………………….……………………………………2) What time is it? ………………………………………………………..…….……………………………………………3) Read this carefully. …………………………………………………………….…………………………………………4) Bangkok is the capital of Laos. …………………………...…………………………………………………………….5) You will get “A” for this course. …………………………………………………………….…………………………..6) 1 + 1 = 2. …………………………………………………………………………………..………………………………7) 2 + 2 = 3. …………………………………………………………….…………………………………………………….8) x + 1 = 2. …………………………………………………………….…………………………………………………….9) x + x = 2x. ……………………………………………….…………….…………………………………………………..10) x2 – 2x + 1 = y. …………………………………………..………………….………………………………………….... Definition 3 Let p be a proposition. The negation of p, denoted by ¬ p is the statement of “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.Theมหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
    • 2 CSC1001 Discrete Mathematics 04 - LogicTable: Truth Table for the Negation of a Proposition p ¬p T F F TExample 2 (2 points) Find the negation of the proposition “To HuaK’s PC runs pornography video”.Example 3 (2 points) Find the negation of the proposition “Paint, he is not gay”.Example 4 (2 points) Find the negation of the proposition “Natee’s iPhone has at least 32GB of memory”. Definition 4 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.Table: The Truth Table for the Conjunction of Two Propositions. p q p ∧ q T T T T F F F T F F F FExample 5 (2 points) Find the conjunction of the propositions p and q where p is the proposition “Nut’s PC hasmore than 16GB free disk space” and q is the proposition “The processor in Nut’s PC runs faster than 1GHz.”Example 6 (2 points) Find the conjunction of the propositions p and q where p is the proposition “Tong is gay.”and q is the proposition “Tong is lesbians.”มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
    • Logic - 04 CSC1001 Discrete Mathematics 3 Definition 5 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.Table: The Truth Table for the Conjunction of Two Propositions. p q p ∨ q T T T T F T F T T F F FExample 7 (2 points) Find the disjunction of the propositions p and q where p is the proposition “Students whohave taken calculus in this class.” and q is the proposition “Students who have taken computer science in thisclass.”Example 8 (2 points) Find the disjunction of the propositions p and q where p is the proposition “Tong is gay.”and q is the proposition “Tong is lesbians.” Definition 6 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.Table: The Truth Table for the Exclusive Or of Two Propositions. p q p ⊕ q T T F T F T F T T F F F Definition 7 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)มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
    • 4 CSC1001 Discrete Mathematics 04 - LogicTable: The Truth Table for the Conditional Statement p → q. p q p → q T T T T F F F T T F F TExample 9 (2 points) Find the conditional statement of the propositions p and q where p is the proposition“You get 100% on the final.” and q is the proposition “You will get an A.”Example 10 (2 points) Find the conditional statement of the propositions p and q where p is the proposition“Champ kisses Natee.” and q is the proposition “Champ will be gay.”Example 11 (2 points) Find the conditional statement of the propositions p and q where p is the proposition“Maria learns discrete mathematics” and q is the proposition “Maria will find a good job.”Example 12 (2 points) Find the conditional statement of the propositions p and q where p is the proposition “Itis sunny” and q is the proposition “We will go to the beach.”Example 13 (2 points) What is the value of the variable x after the statement?if 2 + 2 = 4 then x := x + 1 (if x = 0 before this statement is encountered) Definition 8 The proposition q → p is called the converse of p → q. The proposition ¬ q → ¬ p is called the contrapositive of p → q. The proposition p → ¬ q is called the inverse of p → q.มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
    • Logic - 04 CSC1001 Discrete Mathematics 5Example 13 (6 points) What are the contrapositive, the converse, and the inverse of the conditional statement“Thailand football team wins whenever it is raining?”The contrapositiveThe converseThe inverseExample 14 (6 points) What are the contrapositive, the converse, and the inverse of the conditional statement“If Hongteh is a beautiful boy, then Natee is a beautiful boy too.”The contrapositiveThe converseThe inverseExample 15 (6 points) What are the contrapositive, the converse, and the inverse of the conditional statement“If Yingluk has a smartphone, then she will call to Apisit.”The contrapositiveThe converseมหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
    • 6 CSC1001 Discrete Mathematics 04 - LogicThe inverse Definition 9 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.Table: The Truth Table for the Biconditional p ↔ q. p q p ↔ q T T T T F F F T F F F TExample 16 (2 points) Let p be the statement “You can take the flight,” and let q be the statement “You buy aticket.” Then p ↔ q is the statementExample 17 (2 points) Let p be the statement “You can get “A” in discrete mathematics,” and let q be thestatement “You come to class before teacher.” Then p ↔ q is the statementExample 18 (2 points) Let p be the statement “a + 5 = 11,” and let q be the statement “a = 6.” Then p ↔ q isthe statementExample 19 (2 points) Let p be the statement “a + 5 = 11,” and let q be the statement “a = 6.” Then ¬p ↔¬ q is the statementมหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
    • Logic - 04 CSC1001 Discrete Mathematics 72. Compound Propositions We can use these logical connectives— negations, conjunctions, disjunctions, conditional statements,and biconditional statements to build up complicated compound propositions. We can use truth tables todetermine the truth values of these compound propositions.Precedence of Logical Operators Name Operators Precedence Negations ¬ 1 Conjunctions ∧ 2 Disjunctions ∨ 3 Conditional statements → 4 Biconditional statements ↔ 5Example 20 (5 points) Construct the truth table of the compound proposition ¬ p ∨ (p ∧ q) p qExample 21 (5 points) Construct the truth table of the compound proposition (p ∨ ¬ q) → (p ∧ q) p qExample 22 (5 points) Construct the truth table of the compound proposition (p → ¬ r) ∨ (q → ¬ r) p q rมหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
    • 8 CSC1001 Discrete Mathematics 04 - LogicExample 23 (5 points) Construct the truth table of the compound proposition (p → q) ↔ ( ¬ q → ¬ p) p qExample 24 (5 points) Construct the truth table of the compound proposition (p ↔ q) ⊕ ( ¬ p ↔ ¬ r) p q rExample 25 (6 points) Express each of these propositions as an English sentence. Let p, q, and r be thepropositionsp : You have the flu.q : You miss the final examination.r : You pass the course.1) p ∨ q ∨ r2) (p → ¬ r) ∨ (q → ¬ r)3) (p ∧ q) ∨ ( ¬ q ∧ r)มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
    • Logic - 04 CSC1001 Discrete Mathematics 9Example 26 (16 points) Write these propositions using p, q, and r and logical connectives which are includingnegations. Let p, q, and r be the propositionsp : You get an A on the final exam.q : You do every exercise in this book.r : You get an A in this class.1) I will remember to send you the address only if you send me an e-mail message.2) To be a citizen of this country, it is sufficient that you were born in the United States.3) If you keep your textbook, it will be a useful reference in your future courses.4) The Red Wings will win the Stanley Cup if their goalie plays well.5) That you get the job implies that you had the best credentials.6) The beach erodes whenever there is a storm.7) It is necessary to have a valid password to log on to the server.8) You will reach the summit unless you begin your climb too late.มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
    • 10 CSC1001 Discrete Mathematics 04 - Logic3. Logic and Bit Operations Computers represent information using bits.A bit is a symbol with two possible values, namely, 0 (zero)and 1 (one). This meaning of the word bit comes from binary digit, because zeros and ones are the digits usedin binary representations of numbers. Computer bit operations correspond to the logical connectives. By replacing true by a one and false by azero in the truth tables for the operators ∧ , ∨ , and ⊕ (OR, AND, and XOR).Table: Table for the Bit Operators OR, AND, and XOR. p q p ∧ q p ∨ q p ⊕ q 0 0 0 0 0 0 1 0 1 1 1 0 0 1 1 1 1 1 1 0 Definition 10 A bit string is a sequence of zero or more bits. The length of this string is the number of bits in the string.Example 27 (6 points) Find the bitwise OR, bitwise AND, and bitwise XOR of the bit strings 01 1011 0110 and11 0001 1101. (Here, and throughout this book, bit strings will be split into blocks of four bits to make themeasier to read.)1) Bitwise AND2) Bitwise OR3) Bitwise XORมหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี