Announcements CS243: Discrete Structures Propositional Logic II Işıl Dillig First homework assignment out today! Due in one week, i.e., before lecture next Tuesday 09/11 Weilin s Tuesday office hours are 9-10 AM, not 10-11 AM Işıl Dillig, CS243: Discrete Structures Propositional Logic II 1/32 Işıl Dillig, CS243: Discrete Structures Propositional Logic II 2/32 Review Operator Precedence Propositional logic is simplest kind of logic Building blocks are propositions, i.e., statements that are true or false Formulas in propositional logic are formed using propositional variables and boolean connectives Connectives: negation, conjunction, disjunction, conditional, biconditional Truth table shows truth value of formula under all possible assignments to variables Given a formula p q r, do we parse this as (p q) r or p (q r)? Without settling on a convention, formulas without explicit paranthesization are ambiguous. To avoid ambiguity, we will specify precedence for logical connectives. Operator precedence is a convention that tells us how to parse formulas if they are not explicitly paranthesized. Işıl Dillig, CS243: Discrete Structures Propositional Logic II 3/32 Işıl Dillig, CS243: Discrete Structures Propositional Logic II 4/32 Operator Precedence, cont. Operator Precedence Example Negation ( ) has higher precedence than all other connectives. Question: Does p q mean (i) (p q) or (ii) ( p) q? Conjunction ( ) has next highest predence. Question: Does p q r mean (i) (p q) r or (ii) p (q r)? Disjunction ( ) has third highest precedence. Next highest is precedence is, and lowest precdence is Which is the correct interpretation of the formula p q r q r (A) ((p (q r)) q) ( r) (B) ((p q) r) q) ( r) (C) (p (q r)) (q ( r)) (D) (p ((q r) q)) ( r) Işıl Dillig, CS243: Discrete Structures Propositional Logic II 5/32 Işıl Dillig, CS243: Discrete Structures Propositional Logic II 6/32 1
Validity, Unsatisfiability Interpretations The truth value of a propositional formula depends on truth assignments to variables Example: p evaluates to true under under the assignment p = F and to false under p = T Some formulas evaluate to true for every assignment, e.g., p p Such formulas are called tautologies or valid formulas Some formulas evaluate to false for every assignment, e.g., p p Such formulas are called unsatisfiable formulas or contradictions Concepts of validity, satisfiability are very important in logic! To make them precise, we ll define interpretation of formula An interpretation I for a formula F is a mapping from each propositional variables in F to exactly one truth value I : {p true, q false, } In general, for formula with n propositional variables, there are 2 n interpretations Each interpretation corresponds to one row in the truth table Işıl Dillig, CS243: Discrete Structures Propositional Logic II 7/32 Işıl Dillig, CS243: Discrete Structures Propositional Logic II 8/32 Entailment Examples Consider the formula F : p q p q Under an interpretation, every propositional formula evaluates to T or F Formula F + Interpretation I = Truth value We write I = F if F evaluates to true under I Similarly, I = F if F evaluates to false under I. Theorem: I = F if and only if I = F Let I 1 be the interpretation such that [p true, q false] What does F evaluate to under I 1? Thus, I 1 = F Let I 2 be the interpretation such that [p true, q true] What does F evaluate to under I 2? Thus, I 2 = F Işıl Dillig, CS243: Discrete Structures Propositional Logic II 9/32 Işıl Dillig, CS243: Discrete Structures Propositional Logic II 10/32 Another Example Satisfiability, Validity F is satisfiable iff there exists interpretation I s.t. I = F Let F 1 and F 2 be two propositional formulas Suppose F 1 evaluates to true under interpretation I What does F 2 F 1 evaluate to under I? F is valid iff for all interpretations I, I = F F is unsatisfiable iff for all interpretations I, I = F F is contingent if it is satisfiable, but not valid. Valid formulas also called tautologies Unsatisfiable formulas called contradictions Işıl Dillig, CS243: Discrete Structures Propositional Logic II 11/32 Işıl Dillig, CS243: Discrete Structures Propositional Logic II 12/32 2
True/False Questions Duality Between Validity and Unsatisfiability Are the following statements true or false? If a formula is valid, then it is also satisfiable. Proof: F is valid if and only if F is unsatisfiable If a formula is satisfiable, then its negation is unsatisfiable. By definition, F is valid iff for all interpretations I, I = F If F 1 and F 2 are satisfiable, then F 1 F 2 is also satisfiable. A formula can be both contingent and unsatisfiable By theorem, I = F iff I = F Thus, F is valid iff for all interpretations I, I = F But if for all interpretations I, I = F, then F is unsat Thus, F valid iff F unsat Işıl Dillig, CS243: Discrete Structures Propositional Logic II 13/32 Işıl Dillig, CS243: Discrete Structures Propositional Logic II 14/32 Proving Validity Proving Satisfiability, Unsatisfiability, Contingency Question: How can we prove that a propositional formula is a tautology? Similarly, can prove satisfiability, unsatisfiability, contingency using truth tables: Exercise: Which formulas are tautologies? Prove your answer. 1. (p q) ( q p) Satisfiable: There exists a row where formula evaluates to true Unsatisfiable: In all rows, formula evaluates to false 2. (p q) p Contingent: Exists a row where formula evaluates to true, and another row where it evaluates to false Işıl Dillig, CS243: Discrete Structures Propositional Logic II 15/32 Işıl Dillig, CS243: Discrete Structures Propositional Logic II 16/32 Exercises Implication 1. Prove (p q) ( p q) is unsatisfiable 2. Prove (p q) (q p) is a contingency Formula F 1 implies F 2 (written F 1 F 2 ) iff for all interpretations I, I = F 1 F 2 F 1 F 2 iff F 1 F 2 is valid Caveat: F 1 F 2 is not a propositional logic formula; is not part of PL syntax! Instead, F 1 F 2 is a semantic judgment, like satisfiability! Işıl Dillig, CS243: Discrete Structures Propositional Logic II 17/32 Işıl Dillig, CS243: Discrete Structures Propositional Logic II 18/32 3
Syntax vs. Semantics Checking Implication Syntax: What you are allowed to write, are part of PL syntax, but, are not! p 1 p 2 is a syntactically valid PL formula, p 1 p 2 is not! Semantics: Concerns meaning of what is written Validity, satisfiability semantic notions b/c they concern meaning of the formula Question: How can we check if F 1 F 2? Exercise: Does p q imply p? Prove your answer! Semantics gives meaning to syntax Difference between syntax vs. semantics crucial in CS Comes up in logic, programming languages, theory of computation,... Işıl Dillig, CS243: Discrete Structures Propositional Logic II 19/32 Işıl Dillig, CS243: Discrete Structures Propositional Logic II 20/32 Equivalence Checking Equivalence Consider two propositional formulas F 1 and F 2. Sometimes F 1 and F 2 always have same truth value for every interpretation, e.g., p p and p p Such formulas F 1 and F 2 called equivalent, written F 1 F 2 or F 1 F 2 More precisely, formulas F 1 and F 2 are equivalent iff for all interpretations I, I = F 1 F 2 Question: How can we prove F 1 F 2? Exercise: Prove p q and p q are equivalent F 1 F 2 iff F 1 F 2 is valid, not part of PL syntax; they are semantic judgments! Işıl Dillig, CS243: Discrete Structures Propositional Logic II 21/32 Işıl Dillig, CS243: Discrete Structures Propositional Logic II 22/32 Important Equivalences Commutativity and Distibutivity Laws Some important equivalences are useful to know! Law of double negation: p p Identity Laws: p T p p F p Domination Laws: p T T p F F Idempotent Laws: p p p p p p Commutative Laws: p q q p p q q p Distributivity Law #1: (p (q r)) (p q) (p r) Distributivity Law #2: (p (q r)) (p q) (p r) Associativity Laws: p (q r) (p q) r p (q r) (p q) r Negation Laws: p p F p p T Işıl Dillig, CS243: Discrete Structures Propositional Logic II 23/32 Işıl Dillig, CS243: Discrete Structures Propositional Logic II 24/32 4
De Morgan s Laws Using Equivalences Let cs243 be the proposition John took CS243 and cs303 be the proposition John took CS303 In simple English what does (cs243 cs303) mean? DeMorgan s law expresses exactly this equivalence! De Morgan s Law #1: (p q) ( p q) De Morgan s Law #2: (p q) ( p q) When you push negations in, becomes and vice versa We saw one way to prove two formulas are equivalent: use truth table Another way: use known equivalences to rewrite one formula as the other Examples: Prove following formulas are equivalent using known equivalences. 1. (p ( p q)) and p q 2. (p q) and p q Işıl Dillig, CS243: Discrete Structures Propositional Logic II 25/32 Işıl Dillig, CS243: Discrete Structures Propositional Logic II 26/32 Formalizing English Arguments in Logic Example, cont We can use logic to prove correctness of English arguments. For example, consider the argument: If Joe drives fast, he gets a speeding ticket. Joe did not get a ticket. Therefore, he did not drive fast. : ((f t) t) f If Joe drives fast, he gets a speeding ticket. Joe did not get a ticket. Therefore, Joe did not drive fast. How can we prove this argument is valid? Can do this in two ways: 1. Use truth table to show formula is tautology Let f be the proposition Joe drives fast, and t be the proposition Joe gets a ticket How do we encode this argument as a logical formula? 2. Use known equivalences to rewrite formula to true Let s use equivalences Işıl Dillig, CS243: Discrete Structures Propositional Logic II 27/32 Işıl Dillig, CS243: Discrete Structures Propositional Logic II 28/32 Another Example Example, cont. Can also use to logic to prove an argument is not valid. Suppose your friend George make the following argument: If Jill carries an umbrella, it is raining. Jill is not carrying an umbrella. Therefore it is not raining. If Jill carries an umbrella, it is raining. Jill is not carrying an umbrella. Therefore it is not raining. : ((u r) u) r How can we prove George s argument is invalid? Let s use logic to prove George s argument doesn t hold water. Let u = Jill is carrying an umbrella, and r = It is raining How do we encode this argument in logic? Işıl Dillig, CS243: Discrete Structures Propositional Logic II 29/32 Işıl Dillig, CS243: Discrete Structures Propositional Logic II 30/32 5
Summary A formula is valid if it is true for all interpretations. A formula is satisfiable if it is true for at least one interpretation. A formula is unsatisfiable if it is false for all interpretations. A formula is contingent if it is true in at least one interpretation, and false in at least one interpretation. Two formulas F 1 and F 2 are equivalent, written F 1 F 2, if F 1 F 2 is valid Işıl Dillig, CS243: Discrete Structures Propositional Logic II 31/32 6