Lecture 3 Dr. Sarah M.Eljack In Propositional Logic, we assume a collection of atomic propositions are given: p, q, r, s, t, …. Then we form compound propositions by using logical connectives (logical operators) to form propositional “molecules”. Lecture 1 2 Operator Negation Conjunction Disjunction Exclusive or Conditional Biconditional Symbol Usage Java not ! and && or || xor (p||q)&&(!p||!q) if,then p?q:true iff (p&&q)||(!p&&!q) Lecture 1 3 p = “Cruise ships only go on big rivers.” q = “Cruise ships go on the Hudson.” r = “The Hudson is a big river.” r = “The Hudson is not a big river.” pq = “Cruise ships only go on big rivers and go on the Hudson.” p q r = “If cruise ships only go on big rivers and go on the Hudson, then the Hudson is a big river.” Lecture 1 4 This just turns a false proposition to true and the opposite for a true proposition. EG: p = “23 = 15 +7” p happens to be false, so p is true. In Java, “!” plays the same role: !(23 == 15+7) has the boolean value true whenever evaluated. Lecture 1 5 Logical operators are defined by truth tables – tables which give the output of the operator in the right-most column. Here is the truth table for negation: p F T p T F Lecture 1 6 Conjunction is a binary operator in that it operates on two propositions when creating compound proposition. On the other hand, negation is a unary operator (the only nontrivial one possible). Lecture 1 7 Conjunction is supposed to encapsulate what happens when we use the word “and” in English. I.e., for “p and q ” to be true, it must be the case that BOTH p is true, as well as q. If one of these is false, than the compound statement is false as well. Lecture 1 8 EG. p = “Clinton was the president.” q = “Monica was the president.” r = “The meaning of is is important.” Assuming p and r are true, while q false. Out of pq, pr, qr only pr is true. Java: x==3 && x!=3 Evaluates to false for any possible value of x. Lecture 1 9 p q p q T T F F T F T F T F F F Lecture 1 10 Conversely, disjunction is true when at least one of the components is true: p q p q T T F F T F T F T T T F Lecture 1 11 Note: English version of disjunction “or” does not always satisfy the assumption that one of p/q being true implies that “p or q ” is true. Q: Can someone come up with an example? Lecture 1 12 A: The entrée is served with soup or salad. Most restaurants definitely don’t allow you to get both soup and salad so that the statement is false when both soup and salad is served. To address this situation, exclusive-or is introduced next. Lecture 1 13 p q p q T T F F T F T F F T T F Note: in this course any usage of “or” will connote the logical operator as opposed to the exclusive-or. Lecture 1 14 This one is probably the least intuitive. It’s only partly akin to the English usage of “if,then” or “implies”. DEF: p q is true if q is true, or if p is false. In the final case (p is true while q is false) p q is false. Semantics: “p implies q ” is true if one can mathematically derive q from p. Lecture 1 15 p q p q T T F F T F T F T F T T Lecture 1 16 Q: Does this makes sense? Let’s try examples for each row of truth table: 1. If birds can fly then birds can fly. 2. If birds can fly then birds like meats 3. If birds like meats then birds can fly. 4. If birds like meats then birds like meats We make the assumption that “birds can fly” is a true propositions, while “birds like meats ” is a false propositions. Lecture 1 17 A: 1. 2. 3. 4. If birds can fly then birds can fly. True: nothing about this statement is false. If birds can fly then birds like meats False: seems to assert falsehood If birds like meats then birds can fly. True: argument for –only care about end-result. Argument against –counters common English hyperbole. If birds like meats then birds like meats True. WAIT! By first reasoning in 3, when “if” part is false, should only care about “then” part!!!!! On other hand, standard English hyperbole. Lecture 1 18 Remember, all of these are mathematical constructs, not attempts to mimic English. Mathematically, p should imply q whenever it is possible to derive q by from p by using valid arguments. For example consider the mathematical analog of no. 4: If 0 = 1 then 3 = 9. Q: Is this true mathematically? Lecture 1 19 A: YES mathematically and YES by the truth table. Here’s a mathematical proof: 1. 0 = 1 (assumption) Lecture 1 20 A: YES mathematically and YES by the truth table. Here’s a mathematical proof: 1. 0 = 1 (assumption) 2. 1 = 2 (added 1 to both sides) Lecture 1 21 A: YES mathematically and YES by the truth table. Here’s a mathematical proof: 1. 0 = 1 (assumption) 2. 1 = 2 (added 1 to both sides) 3. 3 = 6 (multiplied both sides by 3) Lecture 1 22 A: YES mathematically and YES by the truth table. Here’s a mathematical proof: 1. 2. 3. 4. 0 1 3 0 = = = = 1 2 6 3 (assumption) (added 1 to both sides) (multiplied both sides by 3) (multiplied no. 1 by 3) Lecture 1 23 A: YES mathematically and YES by the truth table. Here’s a mathematical proof: 1. 2. 3. 4. 5. 0 1 3 0 3 = = = = = 1 2 6 3 9 (assumption) (added 1 to both sides) (multiplied both sides by 3) (multiplied no. 1 by 3) (added no. 3 and no. 4) QED Lecture 1 24 As we want the conditional to make sense in the semantic context of mathematics, we better define it as we have! Other questionable rows of the truth table can also be justified in a similar manner. Lecture 1 25 There are many ways to express the conditional statement p q : If p then q. p implies q. If p, q. p only if q. p is sufficient for q. Some of the ways reverse the order of p and q but have the same connotation: q if p. q whenever p. q is necessary for p. To aid in remembering these, I suggest inserting “is true” after every variable: EG: “p is true only if q is true” Lecture 1 26 For p q to be true, p and q must have the same truth value. Else, p q is false: p q pq T T F F T F T F T F F T Q : Which operator is the opposite of? Lecture 1 27 A: has exactly the opposite truth table as . This means that we could have defined the bi-conditional in terms of other previously defined symbols, so it is redundant. In fact, only really need negation and disjunction to define everything else. Extra operators are for convenience. Q: Could we define all other logical operations using only negation and exclusive or? Lecture 1 28 A: No. Notice that negation and exclusive-or each maintain parity between truth and false: No matter what combination of these symbols, impossible to get a truth table with four output rows consisting of 3 T’s and 1 F (such as implication and disjuction). Lecture 1 29 Electronic computers achieve their calculations inside semiconducting materials. For reliability, only two stable voltage states are used and so the most fundamental operations are carried out by switching voltages between these two stable states. In logic, only two truth values are allowed. Thus propositional logic is ideal for modeling computers. High voltage values are modeled by True, which for brevity we call the number 1, while low voltage values are modeled by False or 0. Lecture 1 30 Thus voltage memory stored in a computer can be represented by a sequence of 0’s and 1’s such as 01 1011 0010 1001 Another portion of the memory might look like 10 0010 1111 1001 Each of the number in the sequence is called a bit, and the whole sequence of bits is called a bit string. Lecture 1 31 It turns out that the analogs of the logical operations can be carried out quite easily inside the computer, one bit at a time. This can then be transferred to whole bit strings. For example, the exclusive-or of the previous bit strings is: 01 1011 0010 1001 10 0010 1111 1001 11 1001 1101 0000 Lecture 1 32 Worked out on the black-board. 1.1.6.c, 1.1.22.d, 1.1.39: 1. q = “You miss the final exam.” r = “You pass the course.” Express q r in English. 2. Construct a truth table for p q. 3. Can one determine relative salaries of F (Fannie), J (Janice) and M (Maggie) from the following? 1. If F is not highest paid, then J is. 2. If J is not lowest paid, then M is highest paid. Lecture 1 33 Thank Any you questions ???