SlideShare uma empresa Scribd logo
1 de 10
Baixar para ler offline
Logic - 04                                                                 CSC1001 Discrete Mathematics             1

 CHAPTER
                                                          ตรรกศาสตร์
       4                                                    (Logic)

  1       Propositional Logic
1. Propositions
    The rules of logic give precise meaning to mathematical statements. These rules are used to distinguish
between valid and invalid mathematical arguments. We usually start our study of discrete mathematics with
logic. 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 proposition
please 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 - Logic


Table: Truth Table for the Negation of a Proposition
                            p                                                       ¬p
                            T                                                       F
                            F                                                       T
Example 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                                       F
Example 5 (2 points) Find the conjunction of the propositions p and q where p is the proposition “Nut’s PC has
more 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                                      F
Example 7 (2 points) Find the disjunction of the propositions p and q where p is the proposition “Students who
have taken calculus in this class.” and q is the proposition “Students who have taken computer science in this
class.”



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 - Logic


Table: The Truth Table for the Conditional Statement p   →   q.
                   p                                     q                               p   →   q
                   T                                     T                                   T
                   T                                     F                                   F
                   F                                     T                                   T
                   F                                     F                                   T
Example 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 “It
is 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           5
Example 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 contrapositive



The converse



The inverse




Example 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 contrapositive



The converse



The inverse




Example 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 contrapositive



The converse




มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555)                             เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
6         CSC1001 Discrete Mathematics                                                                  04 - Logic


The 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                                   T
Example 16 (2 points) Let p be the statement “You can take the flight,” and let q be the statement “You buy a
ticket.” Then p ↔ q is the statement




Example 17 (2 points) Let p be the statement “You can get “A” in discrete mathematics,” and let q be the
statement “You come to class before teacher.” Then p ↔ q is the statement




Example 18 (2 points) Let p be the statement “a + 5 = 11,” and let q be the statement “a = 6.” Then p ↔ q is
the statement




Example 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            7
2. 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 to
determine 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                           ↔                                 5

Example 20 (5 points) Construct the truth table of the compound proposition ¬ p ∨ (p ∧ q)
    p             q




Example 21 (5 points) Construct the truth table of the compound proposition (p ∨ ¬ q) → (p ∧ q)
    p             q




Example 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 - Logic


Example 23 (5 points) Construct the truth table of the compound proposition (p → q) ↔ ( ¬ q → ¬ p)
    p             q




Example 24 (5 points) Construct the truth table of the compound proposition (p ↔ q) ⊕ ( ¬ p ↔ ¬ r)
    p             q              r




Example 25 (6 points) Express each of these propositions as an English sentence. Let p, q, and r be the
propositions
p : You have the flu.
q : You miss the final examination.
r : You pass the course.
1) p ∨ q ∨ r




2) (p → ¬ r) ∨ (q → ¬ r)




3) (p ∧ q) ∨ ( ¬ q ∧ r)




มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555)                           เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
Logic - 04                                                                  CSC1001 Discrete Mathematics             9
Example 26 (16 points) Write these propositions using p, q, and r and logical connectives which are including
negations. Let p, q, and r be the propositions
p : 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 - Logic


3. 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 used
in binary representations of numbers.
    Computer bit operations correspond to the logical connectives. By replacing true by a one and false by a
zero 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 and
11 0001 1101. (Here, and throughout this book, bit strings will be split into blocks of four bits to make them
easier to read.)
1) Bitwise AND




2) Bitwise OR




3) Bitwise XOR




มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555)                                      เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี

Mais conteúdo relacionado

Mais procurados

Disrete mathematics and_its application_by_rosen _7th edition_lecture_1
Disrete mathematics and_its application_by_rosen _7th edition_lecture_1Disrete mathematics and_its application_by_rosen _7th edition_lecture_1
Disrete mathematics and_its application_by_rosen _7th edition_lecture_1taimoor iftikhar
 
Logic and proof
Logic and proofLogic and proof
Logic and proofSuresh Ram
 
CMSC 56 | Lecture 5: Proofs Methods and Strategy
CMSC 56 | Lecture 5: Proofs Methods and StrategyCMSC 56 | Lecture 5: Proofs Methods and Strategy
CMSC 56 | Lecture 5: Proofs Methods and Strategyallyn joy calcaben
 
Discrete mathematics Ch2 Propositional Logic_Dr.khaled.Bakro د. خالد بكرو
Discrete mathematics Ch2 Propositional Logic_Dr.khaled.Bakro د. خالد بكروDiscrete mathematics Ch2 Propositional Logic_Dr.khaled.Bakro د. خالد بكرو
Discrete mathematics Ch2 Propositional Logic_Dr.khaled.Bakro د. خالد بكروDr. Khaled Bakro
 
Chapter 1 Logic of Compound Statements
Chapter 1 Logic of Compound StatementsChapter 1 Logic of Compound Statements
Chapter 1 Logic of Compound Statementsguestd166eb5
 
Method of direct proof
Method of direct proofMethod of direct proof
Method of direct proofAbdur Rehman
 
Boolean Programs and Quantified Propositional Proof System -
Boolean Programs and Quantified Propositional Proof System - Boolean Programs and Quantified Propositional Proof System -
Boolean Programs and Quantified Propositional Proof System - Michael Soltys
 
Lecture 2 predicates quantifiers and rules of inference
Lecture 2 predicates quantifiers and rules of inferenceLecture 2 predicates quantifiers and rules of inference
Lecture 2 predicates quantifiers and rules of inferenceasimnawaz54
 
Lecture 3 qualtifed rules of inference
Lecture 3 qualtifed rules of inferenceLecture 3 qualtifed rules of inference
Lecture 3 qualtifed rules of inferenceasimnawaz54
 
Unit I discrete mathematics lecture notes
Unit I  discrete mathematics lecture notesUnit I  discrete mathematics lecture notes
Unit I discrete mathematics lecture notesGIRIM8
 
A Unifying theory for blockchain and AI
A Unifying theory for blockchain and AIA Unifying theory for blockchain and AI
A Unifying theory for blockchain and AILonghow Lam
 
Realizations, Differential Equations, Canonical Quantum Commutators And Infin...
Realizations, Differential Equations, Canonical Quantum Commutators And Infin...Realizations, Differential Equations, Canonical Quantum Commutators And Infin...
Realizations, Differential Equations, Canonical Quantum Commutators And Infin...vcuesta
 
Logic (slides)
Logic (slides)Logic (slides)
Logic (slides)IIUM
 

Mais procurados (19)

Discrete Math Lecture 02: First Order Logic
Discrete Math Lecture 02: First Order LogicDiscrete Math Lecture 02: First Order Logic
Discrete Math Lecture 02: First Order Logic
 
Disrete mathematics and_its application_by_rosen _7th edition_lecture_1
Disrete mathematics and_its application_by_rosen _7th edition_lecture_1Disrete mathematics and_its application_by_rosen _7th edition_lecture_1
Disrete mathematics and_its application_by_rosen _7th edition_lecture_1
 
Discrete mathematics
Discrete mathematicsDiscrete mathematics
Discrete mathematics
 
Logic and proof
Logic and proofLogic and proof
Logic and proof
 
CMSC 56 | Lecture 5: Proofs Methods and Strategy
CMSC 56 | Lecture 5: Proofs Methods and StrategyCMSC 56 | Lecture 5: Proofs Methods and Strategy
CMSC 56 | Lecture 5: Proofs Methods and Strategy
 
Propositional Logic and Pridicate logic
Propositional Logic and Pridicate logicPropositional Logic and Pridicate logic
Propositional Logic and Pridicate logic
 
Discrete mathematics Ch2 Propositional Logic_Dr.khaled.Bakro د. خالد بكرو
Discrete mathematics Ch2 Propositional Logic_Dr.khaled.Bakro د. خالد بكروDiscrete mathematics Ch2 Propositional Logic_Dr.khaled.Bakro د. خالد بكرو
Discrete mathematics Ch2 Propositional Logic_Dr.khaled.Bakro د. خالد بكرو
 
Chapter 1 Logic of Compound Statements
Chapter 1 Logic of Compound StatementsChapter 1 Logic of Compound Statements
Chapter 1 Logic of Compound Statements
 
Method of direct proof
Method of direct proofMethod of direct proof
Method of direct proof
 
Logic
LogicLogic
Logic
 
Boolean Programs and Quantified Propositional Proof System -
Boolean Programs and Quantified Propositional Proof System - Boolean Programs and Quantified Propositional Proof System -
Boolean Programs and Quantified Propositional Proof System -
 
Mathematical Logic
Mathematical LogicMathematical Logic
Mathematical Logic
 
Lecture 2 predicates quantifiers and rules of inference
Lecture 2 predicates quantifiers and rules of inferenceLecture 2 predicates quantifiers and rules of inference
Lecture 2 predicates quantifiers and rules of inference
 
Lecture 3 qualtifed rules of inference
Lecture 3 qualtifed rules of inferenceLecture 3 qualtifed rules of inference
Lecture 3 qualtifed rules of inference
 
Math
MathMath
Math
 
Unit I discrete mathematics lecture notes
Unit I  discrete mathematics lecture notesUnit I  discrete mathematics lecture notes
Unit I discrete mathematics lecture notes
 
A Unifying theory for blockchain and AI
A Unifying theory for blockchain and AIA Unifying theory for blockchain and AI
A Unifying theory for blockchain and AI
 
Realizations, Differential Equations, Canonical Quantum Commutators And Infin...
Realizations, Differential Equations, Canonical Quantum Commutators And Infin...Realizations, Differential Equations, Canonical Quantum Commutators And Infin...
Realizations, Differential Equations, Canonical Quantum Commutators And Infin...
 
Logic (slides)
Logic (slides)Logic (slides)
Logic (slides)
 

Destaque (20)

Discrete-Chapter 03 Matrices
Discrete-Chapter 03 MatricesDiscrete-Chapter 03 Matrices
Discrete-Chapter 03 Matrices
 
Discrete-Chapter 02 Functions and Sequences
Discrete-Chapter 02 Functions and SequencesDiscrete-Chapter 02 Functions and Sequences
Discrete-Chapter 02 Functions and Sequences
 
Introduction to management
Introduction to managementIntroduction to management
Introduction to management
 
Discrete-Chapter 01 Sets
Discrete-Chapter 01 SetsDiscrete-Chapter 01 Sets
Discrete-Chapter 01 Sets
 
Discrete-Chapter 08 Relations
Discrete-Chapter 08 RelationsDiscrete-Chapter 08 Relations
Discrete-Chapter 08 Relations
 
Discrete-Chapter 07 Probability
Discrete-Chapter 07 ProbabilityDiscrete-Chapter 07 Probability
Discrete-Chapter 07 Probability
 
Discrete-Chapter 09 Algorithms
Discrete-Chapter 09 AlgorithmsDiscrete-Chapter 09 Algorithms
Discrete-Chapter 09 Algorithms
 
Discrete-Chapter 06 Counting
Discrete-Chapter 06 CountingDiscrete-Chapter 06 Counting
Discrete-Chapter 06 Counting
 
Tenerife airport disaster klm flight 4805 and pan
Tenerife airport disaster klm flight 4805 and panTenerife airport disaster klm flight 4805 and pan
Tenerife airport disaster klm flight 4805 and pan
 
Set Operations
Set OperationsSet Operations
Set Operations
 
Set Theory Presentation
Set Theory PresentationSet Theory Presentation
Set Theory Presentation
 
Bab 5
Bab 5Bab 5
Bab 5
 
Discrete Structures. Lecture 1
 Discrete Structures. Lecture 1  Discrete Structures. Lecture 1
Discrete Structures. Lecture 1
 
Bab 3
Bab 3Bab 3
Bab 3
 
Bab 3 Tamadun Melayu Baru
Bab 3  Tamadun Melayu BaruBab 3  Tamadun Melayu Baru
Bab 3 Tamadun Melayu Baru
 
Bab 4
Bab 4Bab 4
Bab 4
 
Bab 2
Bab 2Bab 2
Bab 2
 
Konsep Tamadun islam
Konsep Tamadun islamKonsep Tamadun islam
Konsep Tamadun islam
 
Bab 6
Bab 6Bab 6
Bab 6
 
Tamadun Islam dan Tamadun Asia (TITAS)
Tamadun Islam dan Tamadun Asia (TITAS)Tamadun Islam dan Tamadun Asia (TITAS)
Tamadun Islam dan Tamadun Asia (TITAS)
 

Semelhante a Discrete-Chapter 04 Logic Part I

Semelhante a Discrete-Chapter 04 Logic Part I (20)

L01.ppt
L01.pptL01.ppt
L01.ppt
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Nature of Logic.pptx
Nature of Logic.pptxNature of Logic.pptx
Nature of Logic.pptx
 
Discrete mathematics Chapter1 presentation.ppt
Discrete mathematics Chapter1 presentation.pptDiscrete mathematics Chapter1 presentation.ppt
Discrete mathematics Chapter1 presentation.ppt
 
Slide subtopic 1
Slide subtopic 1Slide subtopic 1
Slide subtopic 1
 
dm-logic.pdf
dm-logic.pdfdm-logic.pdf
dm-logic.pdf
 
Slide subtopic 2
Slide subtopic 2Slide subtopic 2
Slide subtopic 2
 
Slide subtopic 2
Slide subtopic 2Slide subtopic 2
Slide subtopic 2
 
Logic2.pptx
Logic2.pptxLogic2.pptx
Logic2.pptx
 
Logic
LogicLogic
Logic
 
UGC NET Computer Science & Application book.pdf [Sample]
UGC NET Computer Science & Application book.pdf  [Sample]UGC NET Computer Science & Application book.pdf  [Sample]
UGC NET Computer Science & Application book.pdf [Sample]
 
Inductive reasoning & logic
Inductive reasoning & logicInductive reasoning & logic
Inductive reasoning & logic
 
Chapter 01 - p1.pdf
Chapter 01 - p1.pdfChapter 01 - p1.pdf
Chapter 01 - p1.pdf
 
Chapter1p1.pdf
Chapter1p1.pdfChapter1p1.pdf
Chapter1p1.pdf
 
DMS UNIT-1 ppt.pptx
DMS UNIT-1 ppt.pptxDMS UNIT-1 ppt.pptx
DMS UNIT-1 ppt.pptx
 
chapter 1 (part 2)
chapter 1 (part 2)chapter 1 (part 2)
chapter 1 (part 2)
 
Chapter1p1
Chapter1p1Chapter1p1
Chapter1p1
 
CSE-203 Lec_1.pptx
CSE-203 Lec_1.pptxCSE-203 Lec_1.pptx
CSE-203 Lec_1.pptx
 
DS Lecture 2.ppt
DS Lecture 2.pptDS Lecture 2.ppt
DS Lecture 2.ppt
 

Mais de Wongyos Keardsri

How to Study and Research in Computer-related Master Program
How to Study and Research in Computer-related Master ProgramHow to Study and Research in Computer-related Master Program
How to Study and Research in Computer-related Master ProgramWongyos Keardsri
 
The next generation intelligent transport systems: standards and applications
The next generation intelligent transport systems: standards and applicationsThe next generation intelligent transport systems: standards and applications
The next generation intelligent transport systems: standards and applicationsWongyos Keardsri
 
SysProg-Tutor 03 Unix Shell Script Programming
SysProg-Tutor 03 Unix Shell Script ProgrammingSysProg-Tutor 03 Unix Shell Script Programming
SysProg-Tutor 03 Unix Shell Script ProgrammingWongyos Keardsri
 
SysProg-Tutor 02 Introduction to Unix Operating System
SysProg-Tutor 02 Introduction to Unix Operating SystemSysProg-Tutor 02 Introduction to Unix Operating System
SysProg-Tutor 02 Introduction to Unix Operating SystemWongyos Keardsri
 
SysProg-Tutor 01 Introduction to C Programming Language
SysProg-Tutor 01 Introduction to C Programming LanguageSysProg-Tutor 01 Introduction to C Programming Language
SysProg-Tutor 01 Introduction to C Programming LanguageWongyos Keardsri
 
Discrete-Chapter 11 Graphs Part III
Discrete-Chapter 11 Graphs Part IIIDiscrete-Chapter 11 Graphs Part III
Discrete-Chapter 11 Graphs Part IIIWongyos Keardsri
 
Discrete-Chapter 11 Graphs Part II
Discrete-Chapter 11 Graphs Part IIDiscrete-Chapter 11 Graphs Part II
Discrete-Chapter 11 Graphs Part IIWongyos Keardsri
 
Discrete-Chapter 11 Graphs Part I
Discrete-Chapter 11 Graphs Part IDiscrete-Chapter 11 Graphs Part I
Discrete-Chapter 11 Graphs Part IWongyos Keardsri
 
Discrete-Chapter 12 Modeling Computation
Discrete-Chapter 12 Modeling ComputationDiscrete-Chapter 12 Modeling Computation
Discrete-Chapter 12 Modeling ComputationWongyos Keardsri
 
Java-Chapter 14 Creating Graphics with DWindow
Java-Chapter 14 Creating Graphics with DWindowJava-Chapter 14 Creating Graphics with DWindow
Java-Chapter 14 Creating Graphics with DWindowWongyos Keardsri
 
Java-Chapter 13 Advanced Classes and Objects
Java-Chapter 13 Advanced Classes and ObjectsJava-Chapter 13 Advanced Classes and Objects
Java-Chapter 13 Advanced Classes and ObjectsWongyos Keardsri
 
Java-Chapter 11 Recursions
Java-Chapter 11 RecursionsJava-Chapter 11 Recursions
Java-Chapter 11 RecursionsWongyos Keardsri
 
Java-Chapter 10 Two Dimensional Arrays
Java-Chapter 10 Two Dimensional ArraysJava-Chapter 10 Two Dimensional Arrays
Java-Chapter 10 Two Dimensional ArraysWongyos Keardsri
 
Java-Chapter 09 Advanced Statements and Applications
Java-Chapter 09 Advanced Statements and ApplicationsJava-Chapter 09 Advanced Statements and Applications
Java-Chapter 09 Advanced Statements and ApplicationsWongyos Keardsri
 
Java-Chapter 07 One Dimensional Arrays
Java-Chapter 07 One Dimensional ArraysJava-Chapter 07 One Dimensional Arrays
Java-Chapter 07 One Dimensional ArraysWongyos Keardsri
 
Java-Chapter 06 File Operations
Java-Chapter 06 File OperationsJava-Chapter 06 File Operations
Java-Chapter 06 File OperationsWongyos Keardsri
 
Java-Chapter 05 String Operations
Java-Chapter 05 String OperationsJava-Chapter 05 String Operations
Java-Chapter 05 String OperationsWongyos Keardsri
 

Mais de Wongyos Keardsri (20)

How to Study and Research in Computer-related Master Program
How to Study and Research in Computer-related Master ProgramHow to Study and Research in Computer-related Master Program
How to Study and Research in Computer-related Master Program
 
The next generation intelligent transport systems: standards and applications
The next generation intelligent transport systems: standards and applicationsThe next generation intelligent transport systems: standards and applications
The next generation intelligent transport systems: standards and applications
 
IP address anonymization
IP address anonymizationIP address anonymization
IP address anonymization
 
SysProg-Tutor 03 Unix Shell Script Programming
SysProg-Tutor 03 Unix Shell Script ProgrammingSysProg-Tutor 03 Unix Shell Script Programming
SysProg-Tutor 03 Unix Shell Script Programming
 
SysProg-Tutor 02 Introduction to Unix Operating System
SysProg-Tutor 02 Introduction to Unix Operating SystemSysProg-Tutor 02 Introduction to Unix Operating System
SysProg-Tutor 02 Introduction to Unix Operating System
 
SysProg-Tutor 01 Introduction to C Programming Language
SysProg-Tutor 01 Introduction to C Programming LanguageSysProg-Tutor 01 Introduction to C Programming Language
SysProg-Tutor 01 Introduction to C Programming Language
 
Discrete-Chapter 11 Graphs Part III
Discrete-Chapter 11 Graphs Part IIIDiscrete-Chapter 11 Graphs Part III
Discrete-Chapter 11 Graphs Part III
 
Discrete-Chapter 11 Graphs Part II
Discrete-Chapter 11 Graphs Part IIDiscrete-Chapter 11 Graphs Part II
Discrete-Chapter 11 Graphs Part II
 
Discrete-Chapter 11 Graphs Part I
Discrete-Chapter 11 Graphs Part IDiscrete-Chapter 11 Graphs Part I
Discrete-Chapter 11 Graphs Part I
 
Discrete-Chapter 10 Trees
Discrete-Chapter 10 TreesDiscrete-Chapter 10 Trees
Discrete-Chapter 10 Trees
 
Discrete-Chapter 12 Modeling Computation
Discrete-Chapter 12 Modeling ComputationDiscrete-Chapter 12 Modeling Computation
Discrete-Chapter 12 Modeling Computation
 
Java-Chapter 14 Creating Graphics with DWindow
Java-Chapter 14 Creating Graphics with DWindowJava-Chapter 14 Creating Graphics with DWindow
Java-Chapter 14 Creating Graphics with DWindow
 
Java-Chapter 13 Advanced Classes and Objects
Java-Chapter 13 Advanced Classes and ObjectsJava-Chapter 13 Advanced Classes and Objects
Java-Chapter 13 Advanced Classes and Objects
 
Java-Chapter 11 Recursions
Java-Chapter 11 RecursionsJava-Chapter 11 Recursions
Java-Chapter 11 Recursions
 
Java-Chapter 10 Two Dimensional Arrays
Java-Chapter 10 Two Dimensional ArraysJava-Chapter 10 Two Dimensional Arrays
Java-Chapter 10 Two Dimensional Arrays
 
Java-Chapter 09 Advanced Statements and Applications
Java-Chapter 09 Advanced Statements and ApplicationsJava-Chapter 09 Advanced Statements and Applications
Java-Chapter 09 Advanced Statements and Applications
 
Java-Chapter 08 Methods
Java-Chapter 08 MethodsJava-Chapter 08 Methods
Java-Chapter 08 Methods
 
Java-Chapter 07 One Dimensional Arrays
Java-Chapter 07 One Dimensional ArraysJava-Chapter 07 One Dimensional Arrays
Java-Chapter 07 One Dimensional Arrays
 
Java-Chapter 06 File Operations
Java-Chapter 06 File OperationsJava-Chapter 06 File Operations
Java-Chapter 06 File Operations
 
Java-Chapter 05 String Operations
Java-Chapter 05 String OperationsJava-Chapter 05 String Operations
Java-Chapter 05 String Operations
 

Discrete-Chapter 04 Logic Part I

  • 1. Logic - 04 CSC1001 Discrete Mathematics 1 CHAPTER ตรรกศาสตร์ 4 (Logic) 1 Propositional Logic 1. Propositions The rules of logic give precise meaning to mathematical statements. These rules are used to distinguish between valid and invalid mathematical arguments. We usually start our study of discrete mathematics with logic. 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 proposition please 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. 2 CSC1001 Discrete Mathematics 04 - Logic Table: Truth Table for the Negation of a Proposition p ¬p T F F T Example 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 F Example 5 (2 points) Find the conjunction of the propositions p and q where p is the proposition “Nut’s PC has more 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) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
  • 3. 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 F Example 7 (2 points) Find the disjunction of the propositions p and q where p is the proposition “Students who have taken calculus in this class.” and q is the proposition “Students who have taken computer science in this class.” 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. 4 CSC1001 Discrete Mathematics 04 - Logic Table: The Truth Table for the Conditional Statement p → q. p q p → q T T T T F F F T T F F T Example 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 “It is 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) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
  • 5. Logic - 04 CSC1001 Discrete Mathematics 5 Example 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 contrapositive The converse The inverse Example 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 contrapositive The converse The inverse Example 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 contrapositive The converse มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
  • 6. 6 CSC1001 Discrete Mathematics 04 - Logic The 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 T Example 16 (2 points) Let p be the statement “You can take the flight,” and let q be the statement “You buy a ticket.” Then p ↔ q is the statement Example 17 (2 points) Let p be the statement “You can get “A” in discrete mathematics,” and let q be the statement “You come to class before teacher.” Then p ↔ q is the statement Example 18 (2 points) Let p be the statement “a + 5 = 11,” and let q be the statement “a = 6.” Then p ↔ q is the statement Example 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) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
  • 7. Logic - 04 CSC1001 Discrete Mathematics 7 2. 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 to determine 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 ↔ 5 Example 20 (5 points) Construct the truth table of the compound proposition ¬ p ∨ (p ∧ q) p q Example 21 (5 points) Construct the truth table of the compound proposition (p ∨ ¬ q) → (p ∧ q) p q Example 22 (5 points) Construct the truth table of the compound proposition (p → ¬ r) ∨ (q → ¬ r) p q r มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
  • 8. 8 CSC1001 Discrete Mathematics 04 - Logic Example 23 (5 points) Construct the truth table of the compound proposition (p → q) ↔ ( ¬ q → ¬ p) p q Example 24 (5 points) Construct the truth table of the compound proposition (p ↔ q) ⊕ ( ¬ p ↔ ¬ r) p q r Example 25 (6 points) Express each of these propositions as an English sentence. Let p, q, and r be the propositions p : You have the flu. q : You miss the final examination. r : You pass the course. 1) p ∨ q ∨ r 2) (p → ¬ r) ∨ (q → ¬ r) 3) (p ∧ q) ∨ ( ¬ q ∧ r) มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
  • 9. Logic - 04 CSC1001 Discrete Mathematics 9 Example 26 (16 points) Write these propositions using p, q, and r and logical connectives which are including negations. Let p, q, and r be the propositions p : 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. 10 CSC1001 Discrete Mathematics 04 - Logic 3. 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 used in binary representations of numbers. Computer bit operations correspond to the logical connectives. By replacing true by a one and false by a zero 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 and 11 0001 1101. (Here, and throughout this book, bit strings will be split into blocks of four bits to make them easier to read.) 1) Bitwise AND 2) Bitwise OR 3) Bitwise XOR มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี