CS100: DISCREE SRUCURES Lecture 5: Logic (Ch1)
Lecture Overview 2 Statement Logical Connectives Conjunction Disjunction Propositions Conditional Bio-conditional Converse Inverse Contrapositive Laws of Logic Quantifiers Universal Existential
What is a Statement? 3 A statement is a sentence having a form that is typically used to express acts Examples: My name is Rawan I like orange 4 2 = 3 Do you live in Riyadh?
1.1 Propositional Logic 4 A proposition is a declarative sentence (a sentence that declares a fact) that is either true or false, but not both. Are the following sentences propositions? Riyadh is the capital of K.S.A. Read this carefully. 2+2=3 (Yes) x+1=2 What time is it ake two books. he sun will rise tomorrow. (Yes) (No à Because it is not declarative sentence) (No à Because it is neither true or false) (No à Because it is not declarative sentence) (No à Because it is not declarative sentence) (Yes)
Logical Connectives and Compound Statement 5 In mathematics, the letters x, y, z, are used to donate numerical variables that can be replaced by real numbers. hose variables can then be combined with the familiar operations +, -, x,. In logic, the letters p, q, r, s, denote the propositional variables; that can be replaced by a statements.
1.1 Propositional Logic 6 Propositional Logic: the area of logic that deals with propositions Propositional Variables: variables that represent propositions: p, q, r, s E.g. Proposition p oday is riday. ruth values:,
1.1 Propositional Logic 7 DEINIION 1 Examples ind the negation of the following propositions and express this in simple English. n Let p be a proposition. he negation of p, denoted by p, is the statement It is not the case that p. he proposition p is read not p. he truth value of the negation of p, p is the opposite of the truth value of p. oday is riday. Solution: he negation is It is not the case that today is riday. In simple English, oday is not riday. or It is not riday today. n At least 10 inches of rain fell today in Miami. Solution: he negation is It is not the case that at least 10 inches of rain fell today in Miami. In simple English, Less than 10 inches of rain fell today in Miami.
1.1 Propositional Logic 8 Exercise.. Give the negation of the following: p: 2 + 3 > 1 p: 2 + 3 1 q: It is cold. q: It is not cold. r: 2+3 5 r: 2 + 3 = 5 g: 2 is a positive integer g: 2 is not a positive integer. OR g: 2 is a zero or negative integer.
1.1 Propositional Logic 9 ruth table: he ruth able for the Negation of a Proposition. p p Logical operators are used to form new propositions from two or more existing propositions. he logical operators are also called connectives.
1.1 Propositional Logic 10 DEINIION 2 Let p and q be propositions. he conjunction of p and q, denoted by p Λ q, is the proposition p and q. he conjunction p Λ q is true when both p and q are true and is false otherwise. he ruth able for the Conjunction of wo Propositions. p q p Λ q
1.1 Propositional Logic 11 Example ind the conjunction of the propositions p and q where p is the proposition oday is riday. and q is the proposition It is raining today., and the truth value of the conjunction. Solution: he conjunction is the proposition oday is riday and it is raining today OR oday is riday but it is raining. he proposition is: RUE à on rainy ridays. ALSE à on any day that is not a riday and on ridays when it does not rain.
1.1 Propositional Logic 12 DEINIION 3 Let p and q be propositions. he disjunction of p and q, denoted by p ν q, is the proposition p or q. he disjunction p ν q is false when both p and q are false and is true otherwise. Note: inclusive or : he disjunction is true when at least one of the two propositions is true. E.g. Students who have taken calculus or computer science can take this class. those who take one OR both classes. he ruth able for the Disjunction of wo Propositions. p q p ν q
1.1 Propositional Logic 13 Example ind the disjunction of the propositions p and q where p is the proposition oday is riday. and q is the proposition It is raining today., and the truth value of the conjunction. Solution: he conjunction is the proposition oday is riday or it is raining today he proposition is: RUE à whether today is ridays or a rainy day including rainy ridays ALSE à on days that are not a ridays and when it does not rain.
1.1 Propositional Logic 14 exclusive or : he disjunction is true only when one of the proposition is true. E.g. Students who have taken calculus or computer science, but not both, can take this class. only those who take ONE of them.
1.1 Propositional Logic 15 DEINIION 4 Let p and q be propositions. he 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. he ruth able for the Exclusive Or (XOR) of wo Propositions. p q p q Å
1.1 Propositional Logic 16 DEINIION 5 Conditional Statements Let p and q be propositions. he conditional statement p q, is the Å proposition if p, then q. he conditional statement is false when p is true and q is false, and true otherwise. In the conditional statement p q, p is called the hypothesis (or antecedent or premise) and q is called the conclusion (or consequence). l A conditional statement is also called an implication. l Example: If I am elected, then I will lower taxes. implication: p q p q elected, lower taxes. not elected, lower taxes. not elected, not lower taxes. elected, not lower taxes.
1.1 Propositional Logic 17 Example: Let p be the statement Maria learns discrete mathematics. and q the statement Maria will find a good job. Express the statement p q as a statement in English. Solution: Any of the following - If Maria learns discrete mathematics, then she will find a good job. Maria will find a good job when she learns discrete mathematics. or Maria to get a good job, it is sufficient for her to learn discrete mathematics. Maria will find a good job unless she does not learn discrete mathematics.
1.1 Propositional Logic 18 Other conditional statements: Converse of p q : q p Contrapositive of p q : q p Inverse of p q : p q Equivalent Statements: Statements with the same truth table values. Converse and Inverse are equivalents. Contrapositive and p q are equivalents.
1.1 Propositional Logic 19 p q has the same truth value as (p q) Λ (q p) DEINIION 6 Let p and q be propositions. he biconditional statement p q is the proposition p if and only if q. he 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. if and only if can be expressed by iff Example: Let p be the statement You can take the flight and let q be the statement You buy a ticket. hen p q is the statement You can take the flight if and only if you buy a ticket. Implication: If you buy a ticket you can take the flight. If you don t buy a ticket you cannot take the flight.
1.1 Propositional Logic 20 he ruth able for the Biconditional p q. p q p q
1.1 Propositional Logic 21 Exercise.. Let p and q be the propositions p : I bought a lottery ticket this week. q : I won the million dollar jackpot on riday. Express each of these propositions as an English sentence. 1) p 2) p q 3) p q I did not buy a lottery ticket this week. If I did not buy a lottery ticket this week, then I did not win the million dollar jackpot on riday. I did not buy a lottery ticket this week, and I did not win the million dollar jackpot on riday.
1.1 Propositional Logic 22 ruth ables of Compound Propositions We can use connectives to build up complicated compound propositions involving any number of propositional variables, then use truth tables to determine the truth value of these compound propositions. Example: Construct the truth table of the compound proposition (p ν q) (p Λ q) he ruth able of (p ν q) (p Λ q). p q q p ν q p Λ q (p ν q) (p Λ q)
ypes of statements 23 A statements that is true for all possible values of its propositional variables is called tautology (p q) (q p) p p Examples of a autology and a Contradiction. p p p ν p p Λ p A statement that is always false is called contradiction p p A statement that can be either true or false, depending of the values of its propositional variables, is called a contingency (p q) (p q)
1.1 Propositional Logic 24 Precedence of Logical Operators We can use parentheses to specify the order in which logical operators in a compound proposition are to be applied. o reduce the number of parentheses, the precedence order is defined for logical operators. Precedence of Logical Operators. Operator Precedence 1 Λ ν 2 3 4 5 E.g. p Λ q = ( p ) Λ q p Λ q ν r = (p Λ q ) ν r p ν q Λ r = p ν (q Λ r)
1.1 Propositional Logic 25 Exercise.. find the truth table of the following proposition p ( ( q p)) p q p q p ( q p) p ( ( q p))
1.1 Propositional Logic 26 ranslating English Sentences English (and every other human language) is often ambiguous. ranslating sentences into compound statements removes the ambiguity. Example: How can this English sentence be translated into a logical expression? You cannot ride the roller coaster if you are under 4 feet tall and you are not older than 16 years old. Solution: Let q, r, and s represent You can ride the roller coaster, You are under 4 feet tall, and You are older than 16 years old. he sentence can be translated into: (r Λ s) q.
1.1 Propositional Logic 27 Example: How can this English sentence be translated into a logical expression? You can access the Internet from campus only if you are a computer science major or you are not a freshman. Solution: Let a, c, and f represent You can access the Internet from campus, You are a computer science major, and You are a freshman. he sentence can be translated into: a (c ν f ).
1.1 Propositional Logic 28 Exercise.. Write the following statement in logic : If I do not study discrete structure and I go to movie, then I am in a good mood. Solution : p: I study discrete structure, q: I go to movie, r: I am in a good mood ( p q ) r
1.1 Propositional Logic 29 Logic and Bit Operations Computers represent information using bits. A bit (Binary Digit) is a symbol with two possible values, 0 and 1. By convention, 1 represents (true) and 0 represents (false). A variable is called a Boolean variable if its value is either true or false. Bit operation replace true by 1 and false by 0 in logical operations. able for the Bit Operators OR, AND, and XOR. x y x y x y x y 0 0 0 0 0 0 1 1 0 1 1 0 1 0 1 1 1 1 1 0
1.1 Propositional Logic 30 DEINIION 7 A bit string is a sequence of zero or more bits. he length of this string is the number of bits in the string. Example: ind the bitwise OR, bitwise AND, and bitwise XOR of the bit string 01 1011 0110 and 11 0001 1101. Solution: 01 1011 0110 11 0001 1101 ------------------- 11 1011 1111 bitwise OR 01 0001 0100 bitwise AND 10 1010 1011 bitwise XOR
1.2 Propositional Equivalences 31 Introduction DEINIION 1 A compound proposition that is always true, no matter what the truth values of the propositions that occurs 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 or a contradiction is called a contingency. Examples of a autology and a Contradiction. p p p ν p p Λ p
1.2 Propositional Equivalences 32 DEINIION 2 Logical Equivalences he compound propositions p and q are called logically equivalent if p q is a tautology. he notation p q denotes that p and q are logically equivalent. Compound propositions that have the same truth values in all possible cases are called logically equivalent. Example: Show that p ν q and p q are logically equivalent. ruth ables for p ν q and p q. p q p p ν q p q
1.2 Propositional Equivalences 33 Exercise.. Show that this statements ((p q) (p q)) is tautology, by using he truth table : p q q p p q (p q) (p q)
Laws of Logic 34 Identity Laws Ø p v p Ø p ^ p Domination Laws Ø p v Ø P ^
Laws of Logic 35 Idempotent Laws Ø p v p p Ø p ^ p p Double Negation Law Ø ( p) p Commutative Laws Ø p v q q v p Ø p ^ q q ^ p
Laws of Logic 36 Association Laws Ø (p v q ) v r p v (q v r) Distributive Laws Ø p v (q ^ r ) (p v q) ^ (p v r) Ø p ^ (q v r) (p ^ q) v (p ^ r) Ø
Contd. 37 De Morgan s Laws Ø Ø ~ (p v q) ~p ^ ~q Ø ~ (p ^ q) ~p v ~q Absorption Laws Ø p v (p ^ q) Ø p ^ (p v q) p p
Contd. 38 Complement Laws Ø p v ~p p ^ ~p Ø ~ ~p p ~, ~ p q p q (p q ) p Λ q Note: See tables 7 & 8 page 25
1.2 Propositional Equivalences 39 Constructing New Logical Equivalences Example: Show that (p q ) and p Λ q are logically equivalent. Solution: (p q ) ( p ν q) ( p) Λ q p Λ q (by the second De Morgan law) (by the double negation law)
1.2 Propositional Equivalences 40 Example: Show that (p Λ q) (p ν q) is a tautology. Solution: o show that this statement is a tautology, we will use logical equivalences to demonstrate that it is logically equivalent to. (p Λ q) (p ν q) (p Λ q) ν (p ν q) ( p ν q) ν (p ν q) (by the first De Morgan law) ( p ν p) ν ( q ν q) (by the associative and communicative law for disjunction) ν Note: he above examples can also be done using truth tables.
Exercises 41 v Simplify the following statement (p v q ) ^ ~p v Show that ~p ^ (~q ^ r) v (q ^ r) v (p ^ r) r (p q) v (p r) p q v r
Exercises Continue 42 (p v q ) ^ ~p ~p ^ ( p v q ) ( ~p ^ p ) v ( ~ p ^ q ) v ( ~p ^ q ) ~p ^ q
Exercises Continue 43 ~p ^ (~q ^ r) v (q ^ r) v (p ^ r) r ~p ^ r ^ (~q v q) v (p ^ r) ~p ^ r ^ v (p ^ r) ~p ^ r v (p ^ r) (~p ^ r) v (p ^ r) r ^ (~p v p) r ^ r
Exercises Continue 44 (p q) v (p r) p q v r p q ( p r ) p q p r p p q r p q r p ( q r ) p ( q r )
Exercises Continue 45 Show that this statements ( q (p q ) p is tautology, by using he laws of logic : ( q (p q ) p ( q ( p q ) p q ( p q ) p ( p q ) ( p q )
Exercises Continue 46 Without using truth tables prove the statement (P ( P q)) q is tautology. (P ( P q)) q p p q q p ( p q q p q p q
1.5 Rules of Inference page 63 47 Valid Arguments in Propositional Logic: DEINIION 1 An argument in propositional logic is a sequence of propositions. All but the final proposition in the final argument are called premises and the final proposition is called the conclusion.. An argument is valid of the truth of all its premises implies that the conclusion is true. An argument form in propositional logic is a sequence of compound propositions involving propositional variables. 25-Mar-17
1.5 Rules of Inference page 63 48 Example: If you have access to the network, then you can change your grade You have access to the network -------------------------------------------------- You can change your grade Valid Argument 25-Mar-17
Rules of Inference for Propositional Logic: 49 We can always use a truth table to show that an argument form is valid. his is a tedious approach. when, for example, an argument involves 9 different propositional variables. o use a truth table to show this argument is valid. It requires 2⁹= 512 different rows!!!!!!! 25-Mar-17
Rules of Inference: 50 ortunately, we do not have to resort to truth tables. Instead we can first establish the validity of some simple argument forms, called rules of inference. hese rules of inference can then be used to construct more complicated valid argument forms. 25-Mar-17
51 25-Mar-17 Rules of Inference p p q -------------------- q q p q ------------------------ p p q q r ----------------------- p r p v q P --------------------- q p ------------------ (p v q) p ^ q ----------------------- p p q -------------------- (p ^ q) p v q p v r --------------- q v r Rules of Inference autology Name [p ^ (p q)] q [ q ^ (p q)] p [(p q) ^ (q r)] (p r) [(p v q) ^ p] q p (p v q) (p ^ q) p (p) ^ (q) (p ^ q) (p v q) ^ ( p v r) (q v r) Modus ponens Modus tollens Hypothetical syllogism Disjunctive syllogism Addition Simplification Conjunction Resolution
Rules of Inference (Cont.) : 52 EXAMPLE State which rule of inference is the basis of the following statement: it is below freezing now. herefore, it is either freezing or raining now SOLUION: Let p: it is below freezing now q: it is raining now hen this argument is of the form p ------------- (Addition) p v q 25-Mar-17
Rules of Inference (Cont.) : 53 EXAMPLE it is below freezing and it is raining now. herefore, it is below freezing SOLUION: Let p: it is below freezing now q: it is raining now hen this argument is of the form p ^ q ----------- (Simplification) p 25-Mar-17
Rules of Inference (Cont.) : 54 What rule of inference is used in each of these arguments? 25-Mar-17 If it is rainy, then the pool will be closed. It is rainy. herefore, the pool is closed. SOLUION: Let p: It is rainy q: the pool is closed hen this argument is of the form p p q ---------------- (Modus ponens) q
Rules of Inference (Cont.) : 55 What rule of inference is used in each of these arguments? 25-Mar-17 If I go swimming, then I will stay in the sun too long. If I stay in the sun too long, then I will sunburn. herefore, if I go swimming, then I will sunburn. SOLUION: Let p: I go swimming q: I stay in the sun too long r: I will sunburn hen this argument is of the form p q q r ------- (Hypothetical syllogism) p r
Rules of Inference (Cont.) : 56 What rule of inference is used in each of these arguments? 25-Mar-17 If it snows today, the university will close. he university is not closed today. herefore, it did not snow today. SOLUION: Let p: it snows today q: he university is not closed today hen this argument is of the form q p q -------------- (Modus tollens) p
Using Rules of Inference to Build Arguments: 57 When there are many premises, several rules of inference are often needed to show that an argument is valid. 25-Mar-17
58 Using Rules of Inference to Build Arguments (Cont.): ind the argument form for the following argument and determine whether it is valid or invalid. If I try hard and I have talent, then I will become a musician. If I become a musician, then I will be happy. If I will not happy, then I did not try hard or I do not have talent. It's valid, Hypothetical syllogism. 25-Mar-17
59 Using Rules of Inference to Build Arguments (Cont.): If I drive to work, then I will arrive tired. ind the argument form for the following argument and determine whether it is valid or invalid. I do not drive to work. I will not arrive tired. It's invalid 25-Mar-17
60 Using Rules of Inference to Build Arguments (Cont.): ind the argument form for the following argument and determine whether it is valid or invalid. I will become famous or I will become a writer. I will not become a writer. I will become famous Its valid, Disjunctive syllogism 25-Mar-17
61 Using Rules of Inference to Build Arguments (Cont.): If taxes are lowered, then income rises. ind the argument form for the following argument and determine whether it is valid or invalid. Income rises. axes are lowered It's invalid 25-Mar-17
Using Rules of Inference to Build Arguments (Cont.) : 62 EXAMPLE Show that the hypotheses it is not sunny this afternoon and it is colder than yesterday, we will go swimming only if it is sunny, if we do not go swimming, then we will take a canoe trip, and if we take a canoe trip, we will be home by sunset. lead to we will be home by sunset 25-Mar-17
Using Rules of Inference to Build Arguments (Cont.) : 63 Let p: it is sunny this afternoon SOLUION q: it is colder than yesterday r: we will go swimming s: we will take a canoe trip t: we will be home by sunset he hypotheses become p ^ q, r p, r s, s t the conclusion is t 25-Mar-17
Cont d: 64 We construct an argument to show that our hypotheses lead to desired conclusion as follows Step Reason 1. p ^ q Hypothesis 2. p Simplification using (1) 3. r p Hypothesis 4. r Modus tollens (2,3) 5. r s Hypothesis 6. s Modus ponens (4,5) 7. s t Hypothesis 8. t Modus ponens (6,7) Note that if we used the truth table, we would end up with 32 rows!!! 25-Mar-17
Resolution: 65 Computer programs make use of rule of inference called resolution to automate the task of reasoning and proving theorems. his rule of inference is based on the tautology ((p v q) ^ ( p v r)) ( q v r ) 25-Mar-17
Resolution (Cont.): 66 Use resolution to show that the hypotheses Jasmine is skiing or it is not snowing EXAMPLE and it is snowing or Bart is playing hockey imply that Jasmine is skiing or Bart is playing hockey 25-Mar-17
Resolution (Cont.): 67 p: it is snowing, q: Jasmine is skiing, r: Bart is playing hockey SOLUION We can represent the hypotheses as p v q and p v r, respectively Using Resolution, the proposition q v r, Jasmine is skiing or Bart is playing hockey follows 25-Mar-17
1.3 Quantifiers page 33 68 v So far we have discussed the propositions in which each statement has been about a particular object. In this section we shall see how to write propositions that are about whole classes of objects. v Consider the statement: p: x is an even number v he truth value of p depends on the value of x. e.g. p is true when x = 4, and false when x = 7
1.Universal Quantifiers 69 DEINIION 1 he universal quantification of p(x) is the statement P(x) for all values of x in the domain. he notation x P(x) denotes the universal quantification of P(x). Here is called the universal quantifier. We read x P(x) as for all x P(x) or for every x P(x). An element for which P(x) is false called counterexample of x P(x) or all values of x, P(x) is true. or every x or any x x Every x We assume that only values of x that make sense in P(x) are considered. x P(x)
1.Universal Quantifiers 70 Example 8.. Let P(X) be the statement x+1>x. What is the truth value of the quantification x P(x), where the domain consists of all real numbers? Solution he quantification x P(x),is true because P(x) is true for all real numbers.
1.Universal Quantifiers 71 Example 9.. Let Q(X) be the statement x < 2. What is the truth value of the quantification x Q(x), where the domain consists of all real numbers? Solution Q(x) is not true for every real number x, because Q(3) is false. hat is, x=3 is a counterexample for the statement x Q(x), thus x Q(x) is false
1.Universal Quantifiers 72 Example 11.. What is the truth value of the quantification x P(x), where P(X) is the statement x 2 < 10 and the domain consists of the positive integers not exceeding 4? Solution he statement x P(x) is the same as the conjunction P(1) ^ P(2) ^ P(3) ^ P(4) Because the domain consists of the positive integers 1,2,3 and 4. Because P(4), which the statement 4 2 < 10 is false, it follows that x P(x) is false.
2.Existential Quantifiers 73 DEINIION 2 he essential quantification of p(x) is the proposition here exists an element x in the domain such that P(x). We use the notation x P(x) for the essential quantification of P(x). Here is called the essential quantifier. In some situations, we only require that there is at least one value for which the predicate is true. he existential quantification of a predicate P(x) is the statement there exists a value of x, for which P(x) is true. x P(x) here is a dog without tail ( a dog) (a dog without tail)
2.Existential Quantifiers 74 Example 16.. What is the truth value of x P(x), where P(X) is the statement x 2 > 10 and the universe of discourse consists of the positive integers not exceeding 4? Solution Because the domain is {1, 2, 3, 4}, the proposition x P(x) is the same as the disjunction P(1) v P(2) v P(3) v P(4) Because P(4), which the statement 4 2 > 10 is true, it follows that x P(x) is true.
Quantifiers - Negation 75 Rule: x p(x) à x p(x) x p(x) à x p(x) Negate the following: ( integers x) (x > 8) à ( an integer x) (x 8) Negate the following; ( an integer x) (0 x 8) à ( integers x) (x < 0 OR x > 8)
Quantifiers 76 Exercise.. p(x): x is even q(x): x is a prime number r(x,y): x+y is even. Write an English sentence that represent the following : A. x P(x) B. x Q(x) C. x y R(x,y) ind negation for a. and b. for every x where x is even there is exists x where x is a prime number for all x there exists y where x+y is even x p(x) x q(x) there is exist x where x is odd for every x where x not prime number
Any Questions 77 Refer to chapter 1 of the book for further reading