Logic 1 Outline • Basics • TruthTablesofOperators • LogicFormulae – Evalua:on;TruthTables • Equivalence – Laws;Proving • Inferences CSE 215: Logic 2 Logic • AllaboutwhatisTRUEandwhatisFALSE. • Proposi:on/Statements: – “Sentences”thatareeitherTorF,andneverboth. – E.g.,(a)TodayisSunday.(b)IftodayisSunday, thenitwillraintoday. – NOTproposi:ons:(a)“x+y=5”sincexandyare unknown,(b)“Howfaristhenexttown?” CSE 215: Logic 3 LogicVariablesandOperators LogicVariables: • Ofunknownvalue(buts:llTorF). • p,q,r,tarecommonlyusedaslogicvariables. LogicOperators 1. NOT(~) E.g.,~p 2. AND(∧) E.g.,p∧q 3. OR (∨) E.g.,p∨q 4. IMPLIES(→) E.g.,p→q CSE 215: Logic 4 CompoundStatements Formedofvariablesandlogicoperators. E.g., • ~p • ~(pV~q) CSE 215: Logic 5 Outline • Basics • TruthTablesofOperators • LogicFormulae – Evalua:on;TruthTables • Equivalence – Laws;Proving • Inferences CSE 215: Logic 6 TruthTablefor~ Whenis(~p)TRUE? WhenpisFALSE. CSE 215: Logic 7 TruthTablefor∧ Whenis(p∧q)TRUE? Whenbothpandqaretrue. CSE 215: Logic 8 TruthTablefor∨ Whenis(p∨q)true? Wheneitheroneistrue. CSE 215: Logic 9 TruthTablefor“→” Whenis(p→q)true? = “ifpthenq” Always,unlesspistrueand qisfalse. CSE 215: Logic 10 p→q • Whyis(p→q)alwaystruewhenpisF. • Letp=“Skyisblue” • Letq=“itsday:me”. p→qis“If(skyisblue)then(itsday:me). • Consideranight.Here,pisFandqisF. • Or,consideracloudyday.Here,pisF,qisT. • Shouldp→qhold,atnightsorcloudydays? • Yes,p→qisavalidclaim(evenatnightor cloudydays). CSE 215: Logic 11 Outline • Basics • TruthTablesofOperators • LogicFormulae – Evalua:on;TruthTables • Equivalence – Laws;Proving • Inferences CSE 215: Logic 12 LogicFormulae (~(~p ∧ ~q)) ∧ (~(p ∧ q)) • When is the above true? • Can the above be simplified? Construct its truth table. Parentheses used to avoid ambiguity. CSE 215: Logic 13 TruthTableforLogicFormulae (~(~p ∧ ~q)) ∧ (~(p ∧ q)) • Evaluate the above for all combination of values of variables (in this case, p and q). • Thus, p q (~(~p ∧ ~q)) ∧ (~(p ∧ q)) T T ? T F ? F T ? F F ? CSE 215: Logic 14 (1)Enumera:ngallcombina:ons • ConsideraformulacomposedofNvariables. • Howdoyouenumerateallcombina:onof values? – Binarymethod: – Forloop: – Recursive: Thereare2Ncombina:ons. CSE 215: Logic 15 (2)Evalua:ngaFormula (~(~p ∧ ~q)) ∧ (~(p ∧ q)) • What is its value, when p is TRUE and q is FALSE? è(~(~T ∧ ~F)) ∧ (~(T ∧ F)) = (~(F ∧T)) ∧ (~F) = (~F) ∧ (T) = T. CSE 215: Logic 16 TruthTableforFormula (~(~p ∧ ~q)) ∧ (~(p ∧ q)) p q (~(~p ∧ ~q)) ∧ (~(p ∧ q)) T T F T F T F T T F F F CSE 215: Logic 17 Outline • Basics • TruthTablesofOperators • LogicFormulae – Evalua:on;TruthTables • Equivalence – Laws;Proving • Inferences CSE 215: Logic 18 Equivalence • Twoformulaeareequivalent,iftheyhavethe sametruthtable. • E.g.,(p→q)and(~p∨q)areequivalent. • Nota:on:X≡Y,whereXandYareformulae. CSE 215: Logic 19 EquivalenceLaws–I 1. ∧ and ∨ are commutative. § p ∧ q ≡ q ∧ p § p ∨ q ≡ q ∨ p 2. ∧ and ∨ are associative. § p ∧ (q ∧ r) ≡ (p ∧ q) ∧ r § p ∨ (q ∨ r) ≡ (p ∨ q) ∨ r 3. ∧ and ∨ are distributive. § p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r) § p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r) CSE 215: Logic 20 EquivalenceLaws–II 1. De Morgan’s Laws. § ~(p ∧ q) ≡ ~p ∨ ~q § ~(p ∨ q) ≡ ~p ∧ ~q CSE 215: Logic 21 ProvingEquivalence 1. Showthetruthtablesaresame.(Obvious) 2. Proveusinglaws.E.g.,(p ∨ ~q) ∧ q ≡ p ∧ q Proof: (p ∨ ~q) ∧ q ≡ q ∧ (p ∨ ~q) ≡ (q ∧ p) ∨ (q ∧ ~q) ≡ (q ∧ p) ∨ F ≡ (q ∧ p) ≡p∧q CSE 215: Logic 22 MoreFactsabout(p→q) (p→q)isequivalenttoallofthebelow: • (~q→~p) • (~pVq) • ~(p∧~q) Easytoconfirmusingtruthtables. Toseeintui:vely,try: p=Alexisafather q=Alexisamale Here,(p→q)holds.Dotheothersmeanthesame? CSE 215: Logic 23 OtherConcepts • Tautology:Aformulathatisalwaystrue. – E.g.,(p∨~p),(p∧q)∨(~p∨~q). • Contradic:on:Aformulathatisalwaysfalse. • Bi-condi:onal(p↔q) – Equivalentto:(p→q)∧(q→p). – (p↔q)istrueifandonlyifpandqhavethesame values(check). CSE 215: Logic 24 NecessaryandSufficient 1. “pissufficientforq”means(p→q). 2. “pisnecessaryforq”means(~p→~q).Right? abovealsoimpliesthat: “pisnecessaryforq”means(q→p).Why? Thus,p↔qmeanspisnecessaryandsufficientforq. CSE 215: Logic 25 Ifandonlyif • (p→q)means“ifpthenq”OR“qistrueifpis true” • Whatdoes“qistrueonlyifpistrue”mean? – pisnecessaryforq. – (~pà~q) – (qàp) CSE 215: Logic 26 Interesting Implication Example • Prosecutor: – "If the defendant is guilty, then he had an accomplice." • Defense Attorney: – "That's not true!!" • What did the defense attorney just claim?? ~(p → q) ≡ ~(~p ∨ q) ≡ ~~(p∧~q) ≡ p ∧ ~q CSE 215: Logic 27 Outline • Basics • TruthTablesofOperators • LogicFormulae – Evalua:on;TruthTables • Equivalence – Laws;Proving • Inferences CSE 215: Logic 28 Arguments;MakingInferences • • • • Wedon’tknowthevaluesofpandq. But,weknow(p∨q)and~paretrue. Canwesayanythingaboutp,q? Yes. – pisfalse. – qistrue. • How? CSE 215: Logic 29 Inferences Given(astrue)formulaeXandY.Canweinfer (deduceastrue)Z?Wrilenas: X,Y Z When: • Wecanshowthat(X∧Y)→Zisalwaystrue (i.e.,isaTautology).How?Truthtable! CSE 215: Logic 30 InferenceExample Given(p→(qV~r))and(q→(p∧r)) Canweinfer(p→r)? CSE 215: Logic 31 CommonInferenceRules CSE 215: Logic 32 InferenceExample–I 1. IfIwasreadinginthekitchen,thenmyglasseswouldbeonthe kitchentable. 2. Ifglassesareonthekitchentable,thenIsawthematbreakfast. 3. Ididnotseemyglassesatbreakfast. 4. Iwasreadingthenewspaperinthelivingroomorthekitchen. 5. IfIwasreadingthenewspaperinthelivingroom,thenmyglasses areonthecoffeetable. Wherearetheglasses? 6. Glassesnotonkitchentable [From2,3,ModusTollens]. 7. Iwasnotreadinginthekitchen [From1,6,ModusTollens] 8. Readinginthelivingroom [From4,7,Elimina:on] 9. Glassesonthecoffeetable. [From5,8,ModusPonens] 33 InferenceExample–II Knights and Knaves: knights always tell the truth and knaves always lie A says: B is a knight. B says: A and I are of opposite type. Suppose A is a knight. ∴ What A says is true. by definition of knight ∴ B is also a knight. That’s what A said. ∴ What B says is true. by definition of knight ∴ A and B are of opposite types. That’s what B said. ∴ We have arrived at the following contradiction: A and B are both knights and A and B are of opposite type. ∴ The supposition is false. by the contradiction rule ∴ A is not a knight. negation of supposition ∴ A is a knave. since A is not a knight. ∴ What A says is false. by definition of knave ∴ B is not a knight. ~(what A said). ∴ B is also a knave. by elimination 34 Useofcontradic:onRule • • • • • • • • Givensomefacts. P(supposi:on) Q(inferred/givenfromabove). ~Q(inferred/givenfromabove). False(fromQ∧~Q). Thus,wehaveshown(Facts∧P)àFalse. Thus,~(Facts∧P). Thus,~p. CSE 215: Logic 35 UseofTransi:vity • • • • • • • • GivenXandY,weinferZ. Now,fromYandZ,weinferW. CanwesaythatWcanbeinferredfromXandY? (X∧Y)àZ. (X∧Y)àY. (trivial) Thus,(X∧Y)à(Y∧Z) Also,(Y∧Z)àW. Thus,(X∧Y)àW(bytransi:vity) CSE 215: Logic 36
© Copyright 2026 Paperzz