Discrete Mathematic Chapter 1: Logic and Proof 1.1 Propositional Logic 1.2 Propositional Equivalences Yutaka HAA, IEEE ellow University of Hyogo, JAPAN his material was made by Dr. Patrick Chan School of Computer Science and Engineering South China University of echnology Agenda Ch1.1 Propositional Logic Proposition Propositional Operator Compound Proposition Applications Ch1.2 Propositional Equivalences Logical Equivalences Using De Morgan's Laws Constructing New Logical Equivalences Chapter 1.1 & 1.2 2
Warm Up John is a cop. John knows first aid. herefore, all cops know first aid Chapter 1.1 & 1.2 3 Warm Up Human walks by two legs. Human is mammal. Mammal walks by two legs. Chapter 1.1 & 1.2 4
Warm Up he clock alarm of my iphone does not work today. he clock alarm of iphone does not work on 1-1-2011. So, today is 1-1-2011 Chapter 1.1 & 1.2 5 Warm Up Some students work hard to study. Some students fail in examination. So, some work hard students fail in examination. Chapter 1.1 & 1.2 6
Small Quiz Next few pages contain 4 questions Write down the answer of each question on a paper Remember No Discussion Do not modify answers you written down Chapter 1.1 & 1.2 7 Small Quiz: Question 1 According to the law, only a person who is elder than 21-year-old can have alcoholic drink You are a police. Which person(s) you need to check? Drink ea Drink Beer 23-year-old 19-year-old Chapter 1.1 & 1.2 8
Small Quiz: Question 2 According to a policy of a company, if someone surf the Internet longer than 2 hours, he/she has to earn more than 300k You are the boss of this company. Which staff(s) you need to check? 1h Surfing 3h Surfing Earned 200k Earned 400k Chapter 1.1 & 1.2 9 Small Quiz: Question 3 A company publishes a desk Each card has two sides: a character and a number If one side of a card is a vowel, the number on the other side should be even number You are a QC staff. Which card(s) you need to check? E 4 7 Chapter 1.1 & 1.2 10
Small Quiz: Question 4 A company publishes another desk: each card has two sides: a shape and a color If one side of a card is a circle, the color on the other side should be yellow You are a QC staff. Which card(s) you need to check? Chapter 1.1 & 1.2 11 Small Game: Answer Q1: Only a person who is elder than 21-year-old can have alcoholic drink Q2: If someone surf the Internet longer than 2 hours, he/she has to earn more than 300k Q3: If one side of a card is a vowel, the number on the other side is even number ea Beer 23 19 1h 3h 200k 400k E 4 7 Q4: If one side of a card is a circle, the color on the other side is yellow Chapter 1.1 & 1.2 12
Introduction In this chapter, we will explain how to make up a correct mathematical argument prove the arguments Chapter 1.1 & 1.2 13 Propositions Proposition (also called statement) is a declarative sentence (declares a fact) that is either true or false, but not both ruth value of a proposition is either rue/alse (/) to indicate its correctness Example: Keep quite 1 hour has 50 minutes 1 + 1 = 3 x + 2 = 4 alse Not declarative alse Can be either true or false Can be turned into proposition when x is defined Chapter 1.1 & 1.2 14
Propositions Proposition Variable is letters denote propositions Conventional letters are p,q,r,s, P,Q, Example: r : Peter is a boy Proposition Logic is the area of logic that deals with propositions Logic Operators NO AND OR XOR If then (Conditional Statement ) If and Only If (Biconditional Statement) Chapter 1.1 & 1.2 15 Proposition Logic Negation Operator (Not) Definition Let p be a proposition Negation of p is the statement It is not the case that p Notation: p, ~p, p Read as not p ruth value Opposite of the truth value of p Example: p: you are a student p: You are not a student Chapter 1.1 & 1.2 16
Proposition Logic Conjunction Operator (AND) Definition Let p and q be propositions Conjunction of p and q is p andq Notation: p q points up like an A, which means ND ruth value rue when both p and q are true alse otherwise Example: p: Peter likes to play, q: Peter likes to read p q: Peter likes to play and Peter likes to read Chapter 1.1 & 1.2 17 Proposition Logic Disjunction Operator (OR) Definition Let p and q be propositions Disjunction of p and q is p orq Notation: p q points up like an r, means O ruth value alse when both p and q are false rue otherwise Example: p: Peter likes to play, q: Peter likes to read p q: Peter likes to play or Peter likes to read Chapter 1.1 & 1.2 18
Proposition Logic Disjunction Operator (OR) In English, ORhas more than one meanings Example: Jackie is a singer ORJackie is an actor Either one or both (inclusive) Disjunction operation (OR, ) Jackie is a man ORJackie is a woman Either one but no both (exclusive) Exclusive OR operation( ) Chapter 1.1 & 1.2 19 Proposition Logic Exclusive OR Operator (XOR) Definition Let pand qbe propositions Notation: p q, p q, p +q ruth value rue whenexactly one ofpandqistrue alse otherwise Example: p: You can have a tea, q: You can have a coffee p q: You can have a tea ora coffee, but not both (exclusive or) Chapter 1.1 & 1.2 20
Small Exercise Given p: oday is riday q: It is raining today What is? p oday is not riday Which is correct? Why? omorrow is Wednesday Yesterday is riday oday is not Monday hey provide more information than p p q oday is riday and it is raining today p q oday is riday or it is raining today p q Either today is riday or it is raining today, but not both Chapter 1.1 & 1.2 21 Small Exercise Given p: x > 50 q: x < 100 What is? p p q p q p q x 50 x 100 or x 50 100 > x > 50 x can be any number Both qand pis Only qis Only pis qis pis 50 100 Chapter 1.1 & 1.2 22
Proposition Logic ruth able ruth able displays the relationships between the truth values of propositions Example: ruth able of Negation Operation P P Operand Column Result Column Chapter 1.1 & 1.2 23 Proposition Logic ruth able NO AND OR XOR p q p p q p q p q Chapter 1.1 & 1.2 24
Proposition Logic Conditional Statement (imply) Definition Let pand qbe propositions Conditionalstatement is if p, then q Notation: p q p is called the hypothesis(or antecedent or premise) q is called the conclusion(or consequence) ruth value alsewhen pistrue and qisfalse rue otherwise Example p q p q p: you work hard, q: you will pass this subject p q: If you work hard, then you will pass this subject Chapter 1.1 & 1.2 25 Proposition Logic Conditional Statement (imply) Example: p: You give me twenty dollars q: We are the best friends What is p q? If you give me twenty dollars, then we are the best friends Assume p q is true, what does you do not give me twenty dollars ( p) mean? Does it mean We are not the best friend ( p q)? Chapter 1.1 & 1.2 26
Proposition Logic Conditional Statement (imply) Example: Given p q If it rains, the floor is wet Situation 1 ( p q) If it does not rain, the floor is not wet Situation 2 (q p) If the floor is wet, it rains Situation 3 ( q p) p q and its Contrapositive are equivalent Converse and Inverse are equivalent Inverse Converse Contrapositive If the floor is not wet, it does not rain Chapter 1.1 & 1.2 27 Proposition Logic: Conditional Statement Necessary Condition o say that pis anecessary conditionfor q, it is impossible to have q without p Example Breathing is necessary condition for human life You cannot find a non-breathing human who is alive aking a flight is not necessary condition to go to Beijing You can go to Beijing by train, bus Chapter 1.1 & 1.2 28
Proposition Logic: Conditional Statement Sufficient Condition o say that pis asufficientconditionfor q, the presence of p guarantees the presence of q Example Being divisible by 4 is sufficient for being an even number Working hard is not sufficient for having a good examination result Chapter 1.1 & 1.2 29 Proposition Logic: Conditional Statement Necessary / Sufficient Condition Relation between conditional statement and necessary / sufficient condition Necessary Condition E.g. Breathing is necessary condition for human life P is necessary P Q condition of Q Sufficient Condition E.g. Being divisible by 4 is sufficient for being an even number P Q P is sufficient condition of Q p q p q p q is equivalent to: p is sufficient condition of q q is necessary condition of p Chapter 1.1 & 1.2 30
Proposition Logic Conditional Statement (imply) Other equivalent forms for P Q: Pis a sufficient condition for Q Qis a necessary condition for P Pimplies Q If P, then Q If P, Q Qif P Qwhenever P Ponly if Q P cannot be true when Q is not true Q is necessary condition for P Chapter 1.1 & 1.2 31 Proposition Logic Conditional Statement (imply) Remark: No causalityis implied in P Q P may not cause Q or example: If I have more money than Bill Gates, then a rabbit lives on the moon Chapter 1.1 & 1.2 32
Proposition Logic Conditional Statement (imply) Example: A mother tells her child that If you finish your homework, then you can eat the ice-cream What does it mean? Case 1 (p q) Homework is finished, p q p q you can eat the ice-cream Homework is not finished, you can/cannot eat the ice-cream Case 2 Homework is finished, you can eat the ice-cream Homework is not finished, you cannot eat the ice-cream Chapter 1.1 & 1.2 33 Proposition Logic Biconditional Statement (equivalent) Definition Let pand qbe propositions Biconditional statement is p if and only if q (iff) Notation: p q, p =q, p q Also called bi-implications, equivalence Equivalent to(p q) (q p) ruth value ruewhen pand qhave thesame truth values alseotherwise p q p q Chapter 1.1 & 1.2 34
Proposition Logic Biconditional Statement (equivalent) Example: p: You take the flight q: you buy a ticket What is p q? You take the flight if and only if you buy a ticket No ticket, no flight No flight, no ticket Chapter 1.1 & 1.2 35 Proposition Logic: Conditional Statement Necessary / Sufficient Condition p is necessarybut notsufficientfor q q p p is sufficientbut not necessaryfor q p q p is both necessary and sufficientfor q q p p q p q q is also both necessary and sufficientfor p Chapter 1.1 & 1.2 36
Proposition Logic Remarks: In ordinary speech, words like or and if-then may have multiple meanings In this technical subject, we assume that or means inclusive or ( ) if-then means implication ( ) Chapter 1.1 & 1.2 37 Proposition Logic Summary ormal Name Nickname Symbol Negation Operator NO Conjunction Operator AND Disjunction Operator OR Exclusive-OR Operator XOR Conditional Statement Imply Biconditional Statement Equivalent Chapter 1.1 & 1.2 38
Proposition Logic Summary p q p p q p q p q p q p q Chapter 1.1 & 1.2 39 Compound Proposition Compound Propositions are formed from existing propositions using proposition logical operators Example: Beijing is the capital of China and 1+1=2 How can we determine the truth values of the complicated compound propositions involving any number of propositional variables? Example: What is the truth value for every situations? p q s q p Chapter 1.1 & 1.2 40
Compound Proposition Precedence of Logical Operator Precedence Operator 1 NO 2 AND 3 OR XOR 4 Imply 5 Equivalent Example: p q r p (q r) (p q) r s f ( s) f (s f) a f b (a f) b a (f b) Chapter 1.1 & 1.2 41 Compound Proposition Example: 1. p q s q p 2. p ( q) s q p 3. p ( q) (s q) p 4. p ( q) ((s q) p) 5. (p ( q)) ((s q) p) Precedence Operator 1 2 3 4 5 herefore, p q s q p is equal to (p ( q)) ((s q) p) Chapter 1.1 & 1.2 42
Compound Proposition ruth tables can be used to determine the truth values of the complicated compound propositions Algorithm: 1. Write down all the combinations of the compositional variables 2. ind the truth value of each compound expression that occurs in the compound proposition according to the operator precedence Chapter 1.1 & 1.2 43 Compound Proposition Example: (p q) (s q) p 1 2 3 4 5 p q s Chapter 1.1 & 1.2 44
Compound Proposition Example: (p q) (s q) p 1 2 3 4 5 p q s Chapter 1.1 & 1.2 45 Compound Proposition Example: (p q) (s q) p 1 2 3 4 5 p q s q Chapter 1.1 & 1.2 46
Compound Proposition Example: (p q) (s q) p 1 2 3 4 5 p q s q s q Chapter 1.1 & 1.2 47 Compound Proposition Example: (p q) (s q) p 1 2 3 4 5 p q s q s q (s q) p Chapter 1.1 & 1.2 48
Compound Proposition Example: (p q) (s q) p 1 2 3 4 5 p q s q s q (s q) p p q Chapter 1.1 & 1.2 49 Compound Proposition Example: (p q) (s q) p 1 2 3 4 5 p q s q s q (s q) p p q (p q) (s q) p Chapter 1.1 & 1.2 50
Small Exercise Write down the truth table for the following compound statement: p r q p r p q p p q p q p q p q p q 1 2 3 4 5 Chapter 1.1 & 1.2 51 Small Exercise p r q p r (p (r q)) (p ( r)) 1 2 3 4 5 p q r r r q p (r q) p ( r) (p (r q)) (p ( r)) Chapter 1.1 & 1.2 52
ranslating English Sentences Human language is often ambiguous ranslating human language into compound propositions (logical expression) removes the ambiguity Chapter 1.1 & 1.2 53 ranslating English Sentences Algorithm: 1. Remove the connective operators 2. Let a variable for each complete concept 3. Use the operators to connect the variables 4. Adding brackets in suitable positions will be helpful Example: p: You can access the Internet from campus q: You are a computer science major s: You are a freshman You can access the Internet from campus only if you are a computer science major or you are not a freshman p ( q s) Chapter 1.1 & 1.2 54
Applications System Specifications Specifications are the essential part of the system and software engineering Specifications should be consistent, otherwise, no way to develop a system that satisfies all specifications Consistence means all specifications can be true Chapter 1.1 & 1.2 55 Applications System Specifications Example: here are three specifications for a particular system, are they consistent? he diagnostic message is stored in the buffer or it is retransmitted. he diagnostic message is not stored in the buffer. If the diagnostic message is stored in the buffer, then it is retransmitted. Chapter 1.1 & 1.2 56
Applications System Specifications he diagnostic message is stored in the buffer or it is retransmitted. he diagnostic message is not stored in the buffer. 1. Remove the connective operators 2. Let a variable for each complete concept 3. Use the operators to connect the variables 4. Adding brackets in suitable positions will be helpful If the diagnostic message is stored in the buffer, then it is retransmitted. P Q P P Q P: he diagnostic message is stored in the buffer Q: he diagnostic message is retransmitted hese specifications are consistent P Q P Q P P Q (P Q) ( P) (P Q) Chapter 1.1 & 1.2 57 Applications Logic and Bit Operations Information stored in a computer is represented by bits E.g. A = 0100 0001 Bit = Binary Digit, i.e. 0 or 1 ( or ) Logic connectives can be used as bit operation Bitwise OR ( ) the OR of the corresponding bits in the two strings Bitwise AND ( ) the AND of the corresponding bits in the two strings Bitwise XOR ( ) the XOR of the corresponding bits in the two strings Chapter 1.1 & 1.2 58
Applications Logic and Bit Operations Example: A B Bit-wise OR Bit-wise AND Bit-wise XOR 1011 0110 0001 1101 1011 1111 0001 0100 1010 1011 Chapter 1.1 & 1.2 59 Applications Logic Puzzles Puzzles that can be solved using logical reasoning are known as logic puzzles Can be solved by using rules of logic Example: here are two kinds of peopleon an island Batman: Always tell the truth Joker: Always lie One day, you encounter two peoples A and B. A says B is a Batman B says he two of us are opposite types What are A and B? Chapter 1.1 & 1.2 60
Applications Logic Puzzles Batman: Always tell the truth Joker: P Q Always lie A says B is a Batman B says he two of us are opposite types A B P Q 61 Chapter 1.1 & 1.2 ypes of Proposition autology A compound proposition which is always true Example: P P P P P P Contradiction A compound proposition which is always false Example: P P P P P P Contingency A compound proposition which is neither a tautology nor a contradiction P P P P (P P) Example: P (P P) Chapter 1.1 & 1.2 62
ypes of Proposition Example Are they autology, Contradiction or Contingency? P P P P P P P Q P Q (P Q) Q autology Contradiction autology Contingency Contingency Contradiction Chapter 1.1 & 1.2 63 Logically Equivalence An importanttype of step used in a mathematical argument is the replacement of a statement with another statementwith the same truth value We would like to discuss about the equivalences of arguments Chapter 1.1 & 1.2 64
Logically Equivalence Definition wo propositions Pand Qare logically equivalentif P Qis a tautology Notation: P Q or P Q Chapter 1.1 & 1.2 65 Logically Equivalence ruth able can be used to testif compositions are logically equivalent Example: if p q and p q are logically equivalent? p q ~p q p q p q p q Chapter 1.1 & 1.2 66
Logically Equivalence Example: Show p (q r) (p q) (p r) p q r q r p (q r) p q p r (p q) (p r) Chapter 1.1 & 1.2 67 Logically Equivalence Characteristic of ruth able Assume nis the number of variables, Raw of tables = 2 n E.g. 20 variables, 2 20 = 1048576 Not efficient Besides the ruth able, we will introduce a series of logical equivalences p q p p q s p q s Chapter 1.1 & 1.2 68
Logically Equivalence Example: Show (p q) (p r) p (q r) (p q) (p r) ( p q) ( p r) ( p p) (q r) p (q r) p (q r) Logical Equivalences P Q P Q P P P P (Q R) (P Q) R p q r q r p (q r) p q p r (p q) (p r) Chapter 1.1 & 1.2 69 Important Equivalences Identify Laws p p p p p p p p Domination Laws p p p p p p Chapter 1.1 & 1.2 70
Important Equivalences Idempotent Laws p p p p p p p p p p p p Double Negation Law ( p) p p p ( p) Chapter 1.1 & 1.2 71 Important Equivalences Negation Laws p p p p p p p p p p p p Chapter 1.1 & 1.2 72
Important Equivalences Commutative Laws p q q p p q q p p q q p q p p q q p q p Chapter 1.1 & 1.2 73 Important Equivalences Associative Laws p (q r) (p q) r p (q r) (p q) r p q r q r p (q r) p q (p q) r p q r q r p (q r) p q (p q) r Chapter 1.1 & 1.2 74
Important Equivalences Distributive Laws p (q r) p (q r) (p q) (p r) (p q) (p r) p q r q r p (q r) p q p r (p q) (p r) p q r q r p (q r) p q p r (p q) (p r) Chapter 1.1 & 1.2 75 Important Equivalences How about p (p q)? (p p) (p q) p (p q) p (p q)? (p p) (p q) p (p q) Distributive Laws p (q r) (p q) (p r) p (q r) (p q) (p r) Chapter 1.1 & 1.2 76
Important Equivalences Absorption Laws p q p q p (p q) p (p q) p (p q) p p p q p q p (p q) Chapter 1.1 & 1.2 77 Important Equivalences De Morgan s Laws (p q)? p q (p q)? p q p q p q (p q) p q p q p q p q (p q) p q p q Chapter 1.1 & 1.2 78
Recall, De Morgan s Laws Important Equivalences (p q) p q De Morgan s Laws Extension (p 1 p 2... p n )? Assume q= p 2... p n (p 1 p 2... p n ) = (p 1 q) According to De Morgan s Law... (p I q)= p 1 q= p 1 (p 2... p n ) Chapter 1.1 & 1.2 79 Recall, De Morgan s Laws Important Equivalences Assume s = p 3... p n (p 2 p 3... p n ) = (p 2 s) According to De Morgan s Law (p 2 s) = p 1 s = p 2 (p 3... p n ) herefore, (p q) p q (p 1 p 2... p n ) = p 1 p 2 p n Chapter 1.1 & 1.2 80
Important Equivalences De Morgan s Laws Extension herefore, (p q) p q (p 1 p 2... p n ) = p 1 p 2 p n Similarly, (p q) p q (p 1 p 2... p n ) = p 1 p 2 p n Chapter 1.1 & 1.2 81 Identify Laws Domination Laws Idempotent Laws Double Negation Law Commutative Laws Associative Laws p p p p p p p p p p p p ( p) p p q q p p q q p p (q r) (p q) r p (q r) (p q) r Distributive Laws p (q r) (p q) (p r) p (q r) (p q) (p r) De Morgan s Laws (p q) p q (p q) p q Absorption Laws Negation Laws p (p q) p p (p q) p p p p p Chapter 1.1 & 1.2 82
Some Important Equivalences Important equivalences about Implication P Q Q P Q You only need to memorize this P Q Q P P Q P Q P Q (P Q) (P Q) P Q (P Q) (P R) P (Q R) (P R) (Q R) (P Q) R (P Q) (P R) P (Q R) (P R) (Q R) (P Q) R Chapter 1.1 & 1.2 83 P Q Q P Let P = S and Q = P Q P Q ** ( S) Substitution S Double Negation Law S ** Q P Substitution (P Q) P Q (P Q) ( P Q) ** P Q De Morgan s Laws P Q P Q Let P = S P Q S Q Substitution S Q ** P Q Substitution P Q (P Q) P Q ( P Q) De Morgan s Laws (P Q) ** **P Q P Q Chapter 1.1 & 1.2 84
(P Q) (P R) P (Q R) (P R) (Q R) (P Q) R (P Q) (P R) ( P Q) ( P R) P (Q R) Distributive Laws P (Q R) ** (P R) (Q R) ** ( P R) ( Q R) ** ( P Q) R Distributive Laws (P Q) R De Morgan slaws (P Q) R ** (P Q) (P R) P (Q R) (P R) (Q R) (P Q) R (P Q) (P R) ( P Q) ( P R) ** ( P R) ( Q R) ** P P (Q R) Associative Laws ( P Q) R R Associative Laws P (Q R) P (Q R) ** **P Q P Q Idempotent Laws (P R) (Q R) ( P Q) R Idempotent Laws (P Q) R De Morgan s Laws (P Q) R ** Chapter 1.1 & 1.2 85 Some Important Equivalences Important equivalences about if and only if: P Q Q (P Q) (Q P) You only need to memorize this P Q (P Q) ( P Q) P Q P Q (P Q) P Q P Q (P Q) (Q P) ( P Q) ( Q P) **P Q P Q Chapter 1.1 & 1.2 86
Some Important Equivalences P Q (P Q) ( P Q) P Q ** P Q P Q ## P Q (P Q) (Q P) ( P Q) ( Q P) ( P Q) ( Q P) ## (( P Q) Q) (( P Q) P) Distributive Laws (( P Q) (Q Q)) (( P P) (Q P)) Distributive Laws (( P Q) ) ( (Q P)) Negation Laws ( P Q) (Q P) Identify Laws Chapter 1.1 & 1.2 87 Some Important Equivalences P Q P Q Let P= S and Q= P Q ** P Q P Q ## P Q (P Q) (Q P) ( P Q) ( Q P) ( P Q) ( Q P) ## (S ) ( S) Substitution S ## P Q Substitution Chapter 1.1 & 1.2 88
Some Important Equivalences (P Q) P Q (P Q) (( P Q) ( Q P)) ## ( P Q) ( Q P) (P Q) (Q P) ((P Q) Q) ((P Q) P) ((P Q) ( Q Q)) ((P P) ( Q P)) (P Q) ( Q P) (P Q) ( Q P) P Q ## De Morgan s Laws De Morgan s Laws Identify Laws ** P Q P Q ## P Q (P Q) (Q P) ( P Q) ( Q P) Distributive Laws Negation Laws Distributive Laws Chapter 1.1 & 1.2 89 End of 1.1 and 1.2 Chapter 1.1 & 1.2 90