--------------------------- Propositional Logic (Cont'd) [Chapter 5, sections 5.6-5.11] --------------------------- - Substitution of equals: . If A LEQV B and C' obtained from C by replacing some occurrences of A by B, then C' LEQV C. (Similar to algebra: e.g., x = y means x^2 + x = y^2 + x.) Example: p -> q LEQV ~p \/ q so r \/ (p -> q) LEQV r \/ ~p \/ q. - Replacement of variables: . If A LEQV B, p is a propositional variable in A, B, and C is a formula, then A[C/p] LEQV B[C/p], where A[C/p] obtained from A by replacing every occurrence of p by C. (Similar to algebra: e.g., (x + 1)^2 = x^2 + 2x + 1 means (3y + 1)^2 = (3y)^2 + 2(3y) + 1.) Example: p -> q LEQV ~p \/ q so replacing p with (r /\ p) we get r /\ p -> q LEQV ~(r /\ p) \/ q. - Basic equivalences: . Double negation: ~~p LEQV p . Commutativity of /\, \/, <->. Example: p /\ q LEQV q /\ p . Associativity of /\, \/. Example: p /\ (q /\ r) LEQV (p /\ q) /\ r . Distributivity of /\ over \/, and of \/ over /\. Example: p /\ (q \/ r) LEQV (p /\ q) \/ (p /\ r) . DeMorgan's laws: ~(p /\ q) LEQV ~p \/ ~q; ~(p \/ q) LEQV ~p /\ ~q. . -> law: p -> q LEQV ~p \/ q. . <-> law: p <->q LEQV p /\ q \/ ~p /\ ~q - Basic equivalences can be used to prove others: Example 1: p /\ q -> r LEQV ~(p /\ q) \/ r by "-> law" LEQV (~p \/ ~q) \/ r by DeMorgan's laws LEQV ~p \/ ~q \/ r in associativity of \/ LEQV p -> ~q \/ r by "-> law" LEQV p -> q -> r by "-> law" (Important: each line is justified from a basic equivalence and the equivalence principle used.) Example 2: p -> q LEQV ~p \/ q by "-> law" LEQV ~p \/ ~~q by dobule negation LEQV ~~q \/ ~p by commutative law LEQV ~q -> ~p by "-> law" Proof Techniques ---------------- Use indentation to indicate structure w.r.t. assumptions. Direct proof: - To prove "A -> B", assume A is true, then prove that B is also true under the assumption. Logical justification: if A is false, there is nothing to prove, by the truth table for ->. Example: prove that if n is even then n^2 is even. Indirect proof (or contrapositive): - To prove "A -> B", assume B is false, then prove that A is also false under the assumption. Logical justification: ~B -> ~A LEQV A -> B (contrapositive). Example: prove that if n^2 is even then n is even. Proof by contradiction: - To prove A, assume ~A and derive a contradiction (such as p /\ ~p). (Equivalently, to prove ~A, assume A and derive a contradiction.) Logical justification: ~A -> 0 LEQV A (where "0" represents any unsatisfiable formula, e.g., p /\ ~p). Example: prove that sqrt(2) is irrational. Proof by cases: - To prove "A \/ B -> C", prove A -> C and B -> C. In particular, to prove C, prove A -> C and ~A -> C. Logical justification: A \/ B -> C <=> (A -> C) /\ (B -> C); (A -> C) /\ (~A -> C) <=> A \/ ~A -> C <=> C. Normal forms: - We know how to write a truth table for any formula, but can we find a formula for any truth table? - Def: . A literal is a P.F. that consist only of a P.V. or the negation of a P.V. . A minterm is a formula that is literal, or a conjunction of two or more literals. Example: p /\ ~q /\ r . A maxterm is a formula that is literal, or a disjunction of two or more literals. Example: ~p \/ ~q . A P.F. is in disjunctive normal form (DNF) if it is a minterm, or a disjunction of two or more minterms. Example: (p /\ q /\ ~r) \/ (~p /\ r) \/ ~q . A P.F. is in conjunctive normal form (CNF) if it is a maxterm, or a conjunction of two or more maxterms. Example: p /\ (~q \/ r) /\ (p \/ q \/ ~r) - Propositional (or Boolean) function takes propositional variables as arguments and produces a truth value. Example: f(p,q,r) = 1 if at least 2 of p,q,r are true; 0 otherwise. - For a given boolean function given by its truth table, how can we find a boolean formula which is LEQV to it? Example: p q r | f(p,q,r) ---------------------- 1 1 1 | 1 <== p /\ q /\ r 1 1 0 | 1 <== p /\ q /\ ~r 1 0 1 | 1 <== p /\ ~q /\ r 1 0 0 | 0 0 1 1 | 1 <== ~p /\ q /\ r 0 1 0 | 0 0 0 1 | 0 0 0 0 | 0 Express when the function is true, i.e., for each line in the truth table where f = 1 (for each truth assignment that makes f true), write a conjunction of variables and negated variables that is true for that line and false everywhere else (indicated above). Each conjunction is called a "minterm". Each one only gives part of the truth table; to get the entire truth table, take the disjunction of the minterms: (p /\ q /\ r) \/ (p /\ q /\ ~r) \/ (p /\ ~q /\ r) \/ (~p /\ q /\ r) this formula is in Disjunctive Normal Form (DNF) because it is a disjunction of minterms. By construction, this DNF formula has the same truth table as f(p,q,r). - We can also find a formula in CNF form which has the same truth table as f(p,q,r) given above, and therefore is LEQV to it: p q r | f(p,q,r) ---------------------- 1 1 1 | 1 1 1 0 | 1 1 0 1 | 1 1 0 0 | 0 <== ~p \/ q \/ r 0 1 1 | 1 0 1 0 | 0 <== p \/ ~q \/ r 0 0 1 | 0 <== p \/ q \/ ~r 0 0 0 | 0 <== p \/ q \/ r Express when the function is false, i.e., for each line in the truth table where f = 0 (for each truth assignment that makes f false), write a disjunction of variables and negated variables that is false for that line and true everywhere else (indicated above). Each disjunction is called a "maxterm". Each one only gives part of the truth table; to get the entire truth table, take the conjunction of the maxterms: (~p \/ q \/ r) /\ (p \/ ~q \/ r) /\ (p \/ q \/ ~r) /\ (p \/ q \/ r) this formula is in Conjunctive Normal Form (CNF) because it is a conjunction of maxterms. By construction, this CNF formula has the same truth table as f(p,q,r). - DNF and CNF not the only formulas for the truth table in our example: by thinking about meaning of Boolean function, we can come up with (p /\ q) \/ (q /\ r) \/ (r /\ p) and then verify its truth table. - Theorem: For any boolean function f there is a propositional formula that represents f and uses only connectives in {~, /\, \/}. - We say S= {~, /\, \/} is a complete set of connectives, because any boolean function can be represented by a P.F. that uses only connectives in S. - Theorem: {~, /\} is also a complete set. Proof idea: Since we know that {~, /\, \/} is complete, it is enough to show that any formula written using these connectives can be rewritten using only {~, /\}. By DeMorgan's law, (p \/ q) is LEQV to ~(~p /\ ~q). So we can replace any \/ with a combination of /\ and ~. (see Theorem 5.23 for complete proof). - Theorem: {\/ , /\} is NOT a complete set. Proof idea: we can not write a propositional formula using only \/ and /\ that represents f(p) = ~p.