 1 Section 1.1 Logic. 2 Proposition Statement that is either true or false –can’t be both –in English, must contain a form of “to be” Examples: –Cate Sheller.

Presentation on theme: "1 Section 1.1 Logic. 2 Proposition Statement that is either true or false –can’t be both –in English, must contain a form of “to be” Examples: –Cate Sheller."— Presentation transcript:

1 Section 1.1 Logic

2 Proposition Statement that is either true or false –can’t be both –in English, must contain a form of “to be” Examples: –Cate Sheller is President of the United States –CS1 is a prerequisite for this class –I am breathing

3 Many statements are not propositions... Give me liberty or give me death ax 2 + bx + c = 0 See Spot run Who am I and why am I here?

4 Representing propositions Can use letter to represent proposition; think of letter as logical variable Typically use p to represent first proposition, q for second, r for third, etc. Truth value of a proposition is T (true) or F(false)

5 Negation Logical opposite of a proposition If p is a proposition, not p is its negation Not p is usually denoted: pp

6 Truth table Graphical display of relationships between truth values of propositions Shows all possible values of propositions, or combinations of propositions p  p T F F T

7 Logical Operators Negation is an example of a logical operation; the negation operator is unary, meaning it operates on one logical variable (like unary arithmetic negation) Connectives are operators that operate on two (or more) propositions

8 Conjunction Conjunction of 2 propositions is true if and only if both propositions are true Denoted with the symbol  If p and q are propositions, p  q means p AND q Remember -  looks like A for And

9 Examples Letp = 2 + 2 = 4 q = “It is raining” r = “ I am in class now” What is the value of: p  q p  r r  q  p  r  p   r  (p  r)

10 Truth table for p  q pq p  q TT T TF F FT F FF F

11 Disjunction Disjunction of two propositions is false only if both propositions are false Denoted with this symbol:  If p and q are propositions, p  q means p OR q Mnemonic:  looks like OAR in the water (sort of)

12 Examples Letp = 2 + 2 = 4 q = “It is raining” r = “ I am in class now” What is the value of: p  q p  r r  q  p  r  p   r  (p  r)

13 Truth table for disjunction pq p  q TT T TF T FT T FF F

14 Inclusive vs. exclusive OR Disjunction means or in the inclusive sense; includes the possibility that both propositions are true, and can be true at the same time For example, you may take this class if you have taken Calculus I or you have the instructor’s permission - in other words, you can take it if you have either, or both

15 Exclusive OR The exclusive or of two propositions is true when exactly one of the propositions is true, false otherwise Exclusive or is denoted with this symbol:  For p and q, p  q means p XOR q Mnemonic:  looks like sideways X inside an O

16 English examples I am either in class or in my office The meal comes with soup or salad You can have your cake or you can eat it

17 Examples Letp = 2 + 2 = 4 q = “It is raining” r = “ I am in class now” What is the value of: p  q p  r r  q  p  r  p   r  (p  r)

18 Truth table for  pq p  q TT F TF T FT T FF F

19 Implication The implication of two propositions depends on the ordering of the propositions The first proposition is calls the premise (or hypothesis or antecedent) and the second is the conclusion (or consequence) An implication is false when the premise is true but the conclusion is false, and true in all other cases

20 Implication Implication is denoted with the symbol  For p and q, p  q can be read as: –if p then q –p implies q –q if p –p only if q –q whenever p –q is necessary for p –p is sufficient for q –if p, q

21 Implication Note that a false premise always leads to a true implication, regardless of the truth value of the conclusion Implication does not necessarily mean a cause and effect relationship between the premise and the conclusion

22 Implications in English If Cate lives in Iowa, then Discrete Math is a 3-credit class Since p (I live in Iowa) and q (this is a 3- credit class) are both true, p  q is true even though p and q are unrelated statements

23 Implications in English If the sky is brown, then 2+2=5 Since p (sky is brown) and q (2+2=5) are both false, the implication p  q is true Remember, you can conclude anything from a false premise

24 If/then vs. implication In programming, the if/then logic structure is not the same as implication, though the two are related In a program, if the premise (if expression) is true, the statements following the premise will executed, otherwise not There is no “conclusion,” so it’s not an implication

25 Examples Letp = 2 + 2 = 4 q = “It is raining” r = “ I am in class now” What is the value of: p  q p  r r  q  p  r  p   r  (p  r)

26 Truth table for  pq p  q TT T TF F FT T FF T

27 Converse & contrapositive For the implication p  q, the converse is q  p For the implication p  q, the contrapositive is  q   p

28 Biconditional A biconditional is a proposition that is true when p and q have the same truth values (both true or both false) For p and q, the biconditional is denoted as p  q, which can be read as: –p if and only if q –p is necessary and sufficient for q –if p then q, and conversely

29 Examples Letp = 2 + 2 = 4 q = “It is raining” r = “ I am in class now” What is the value of: p  q p  r r  q  p  r  p   r  (p  r)

30 Truth table for  pq p  q TT T TF F FT F FF T

31 Compound propositions Can build compound propositions by combining simple propositions using negation and connectives Use parentheses to specify order or operations Negation takes precedence over connectives

32 Examples Letp = 2 + 2 = 4 q = “It is raining” r = “ I am in class now” What is the value of: (p  q)  ( p  r) (r  q)  (  p  r)  (p   r)   (p  r)

33 Logic & Bit Operations A bit string is a sequence of 1s and 0s - the number of bits in the string is the length of the string Bit operations correspond to logical operations with 1 representing T and 0 representing F

34 Bit operation examples Let s1 = 10011100 s2 = 11000110 s1 OR s2 =11011110 s1 AND s2 = 10000100 s1 XOR s2 = 01011010

35 Section 1.1 Logic - ends -

Download ppt "1 Section 1.1 Logic. 2 Proposition Statement that is either true or false –can’t be both –in English, must contain a form of “to be” Examples: –Cate Sheller."

Similar presentations