Logic - Outline
Total Page:16
File Type:pdf, Size:1020Kb
Logic - Outline Modeling with Propositional logic Normal forms Deductive proofs and resolution 1 Before we solve this problem... Q: Suppose we can solve the satisfiability problem... how can this help us? A: There are numerous problems in the industry that are solved via the satisfiability problem of propositional logic Logistics... Planning... Electronic Design Automation industry... Cryptography... ... (every NP-P problem...) 2 Example 1: placement of wedding guests Three chairs in a row: 1,2,3 We need to place Aunt, Sister and Father. Constraints: Aunt doesn’t want to sit near Father Aunt doesn’t want to sit in the left chair Sister doesn’t want to sit to the right of Father Q: Can we satisfy these constraints? 3 Example 1 (cont’d) Denote: Aunt = 1, Sister = 2, Father = 3 Introduce a propositional variable for each pair (person, place). xij = person i is sited in place j, for 1 · i,j · 3 Constraints: Aunt doesn’t want to sit near Father: ((x1,1 Ç x1,3) → :x3,2) Æ (x1,2 → (:x3,1 Æ :x3,3)) Aunt doesn’t want to sit in the left chair :x1,1 Sister doesn’t want to sit to the right of Father x3,1 → :x2,2 Æ x3,2 → :x2,3 4 Example 1 (cont’d) More constraints: Each person is placed: (x1,1 Ç x1,2 Ç x1,3) Æ (x2,1 Ç x2,2 Ç x2,3) Æ (x3,1 Ç x3,2 Ç x3,3) Or, more concisely: Not more than one person per chair: Overall 9 variables, 23 conjoined constraints. 5 Example 2: assignment of frequencies n radio stations For each assign one of k transmission frequencies, k < n. E -- set of pairs of stations, that are too close to have the same frequency. Q: which graph problem does this remind you of ? 6 Example 2 (cont’d) xi,j – station i is assigned frequency j, for 1 · i · n, 1 · j · k. Every station is assigned at least one frequency: Every station is assigned not more than one frequency: Close stations are not assigned the same frequency. For each (i,j) 2 E, 7 Definitions…Normal Form Definition: A literal is either an atom or a negation of an atom. Let = :(A Ç :B). Then: Atoms: AP() = {A,B} Literals: lit() = {A, :B} Equivalent formulas can have different literals = :(A Ç :B) = :A Æ B Now lit() = {:A, B} 8 Definitions… Definition: a term is a conjunction of literals Example: (A Æ :B Æ C) Definition: a clause is a disjunction of literals Example: (A Ç :B Ç C) 9 Conjunctive Normal Form (CNF) Definition: A formula is said to be in Conjunctive Normal Form (CNF) if it is a conjunction of clauses. In other words, it is a formula of the form where li,j is the j-th literal in the i-th term. Examples = (A Ç :B Ç C) Æ (:A Ç D) Æ (B) is in CNF 10 Converting to CNF Every formula can be converted to CNF: in exponential time and space with the same set of atoms 11 Converting to CNF: the exponential way CNF() { case is a literal: return is 1 Æ 2: return CNF(1) Æ CNF(2) is 1 Ç 2: return Dist(CNF(1),CNF(2)) } Dist(1,2) { case 1 is 11 Æ 12: return Dist(11,2) Æ Dist(12 ,2) 2 is 21 Æ 22: return Dist(1,21) Æ Dist(1,22) else: return 1 Ç 2 12 Converting to CNF: the exponential way Consider the formula = (x1 Æ y1) Ç (x2 Æ y2) CNF()= (x1 Ç x2) Æ (x1 Ç y2) Æ (y1 Ç x2) Æ (y1 Ç y2) Now consider: n = (x1 Æ y1) Ç (x2 Æ y2) Ç Ç (xn Æ yn) Q: How many clauses CNF() returns ? n A: 2 13 Proof The sequence of wffs (w1, w2, …, wn) is called a proof (or deduction) of wn from a set of wffs Δ iff each wi in the sequence is either in Δ or can be inferred from a wff (or wffs) earlier in the sequence by using a valid rule of inference. If there is a proof of wn from Δ, we say that wn is a theorem of the set Δ. Δ├ wn (read: wn can be proved or inferred from Δ) The concept of proof is relative to a particular set of inference rules used. If we denote the set of inference rules used by R, we can write the fact that wn can be derived from Δ using the set of inference rules in R: Δ├ R wn (read: wn can be proved from Δ using the inference rules in R) Valid Arguments An argument is a sequence of propositions. The final proposition is called the conclusion of the argument while the other propositions are called the premises or hypotheses of the argument. An argument is valid whenever the truth of all its premises implies the truth of its conclusion. How to show that q logically follows from the hypotheses (p1 p2 …pn)? Show that (p1 p2 …pn) q is a tautology One can use the rules of inference to show the validity of an argument. 15 Valid? Assume the truth of the of the following three wff: P implies Q• Q implies R• R implies P.• Can we conclude, ``Thus P, Q, and R are all true.'' Proposed argument: assumption (PQQRRP ), ( ), ( ) Is it valid? PQR conclusion Valid Argument? Is it valid? assumptions conclusion P Q R OK? T T T T T T T yes T T F T F T F yes T F T F T T F yes T F F F T T F yes F T T T T F F yes F T F T F T F yes F F T T T F F yes (F PQQRRPF F ), ( T ),T ( T ) F no To prove an argumentPQR is not valid, we just need to find a counterexample. Valid Arguments? assumptions conclusion p q p→q q p T T T T T If p then q. q T F F F T p F T T T F F F T F F Assumptions are true, but not the conclusion. If you are a fish, then you drink water. You drink water. You are a fish. Valid Arguments? assumptions conclusion p q p→q ~p ~q T T T F F If p then q. ~p T F F F T ~q F T T T F F F T T T If you are a fish, then you drink water. You are not a fish. You do not drink water. Exercises More Exercises Valid argument True conclusion True conclusion Valid argument Deduction requires axioms and Inference rules Inference rules: Antecedents (rule-name) Consequent Examples: A ! B B ! C (trans) A ! C A ! B A (M.P.) B 22 Propositional logic: Rules of Inference or Method of Proof Rule of Inference Tautology (Deduction Theorem) Name P P (P Q) Addition P Q P Q (P Q) P Simplification P P [(P) (Q)] (P Q) Conjunction Q P Q P [(P) (P Q)] (P Q) Modus Ponens PQ Q Q [(Q) (P Q)] P Modus Tollens P Q P P Q [(PQ) (Q R)] (PR) Hypothetical Syllogism Q R (“chaining”) P R P Q [(P Q) (P)] Q Disjunctive syllogism P Q P Q [(P Q) (P R)] (Q R) Resolution P R Q R Axioms Axioms are inference rules with no antecedents, e.g., (H1) A ! (B ! A) We can turn an inference rule into an axiom if we have ‘→’ in the logic. So the difference between them is not sharp. 24 Proofs A proof uses a given set of inference rules and axioms. This is called the proof system. Let H be a proof system. `H φ means: there is a proof of φ in system H whose premises are included in `H is called the provability relation. 25 Example Let H be the proof system comprised of the rules Trans and M.P. that we saw earlier. Does the following relation holds? a ! b,b ! c, c ! d , d ! e, a `H e 26 Deductive proof: example a ! b, b ! c, c ! d, d ! e, a `H e 1. a ! b premise 2. b ! c premise 3. a ! c 1,2,Trans 4. c ! d premise 5. d ! e premise 6. c ! e 4,5, Trans 7. a ! e 3,6, Trans 8. a premise 9. e 7,8.M.P. 27 Length of Proofs Why bother with inference rules? We could always use a truth table to check the validity of a conclusion from a set of premises. But, resulting proof can be much shorter than truth table method. Consider premises: p_1, p_1 p_2, p_2 p_3 … p_(n-1) p_n To prove conclusion: p_n n Inference rules: n - 1 P steps Truth table: 2 Key open question: Is there always a short proof for any valid conclusion? Probably not. The NP vs. co-NP question. Proof graph (DAG) a ! b b ! c c ! d d ! e (trans) (trans) a ! c c ! e (trans) a a ! e (M.P.) e Roots: premises 29 Proofs The problem: ` is a relation defined by syntactic transformations of the underlying proof system. For a given proof system H, does ` conclude “correct” conclusions from premises ? Can we conclude all true statements with H? Correct with respect to what ? With respect to the semantic definition of the logic. In the case of propositional logic truth tables gives us this. 30 Soundness and completeness Let H be a proof system Soundness of H: if `H φ then ² φ ( provable implies valid) Completeness of H : if ² φ then `H φ ( valid implies provable) How to prove soundness and completeness ? Note: P `H Q Means Q can be derived from P 31 Soundness and Completeness Definition [soundness]: A procedure for the decision problem is sound if when it returns “Valid”..