
Propositional Logic Propositional Logic: Contents • Syntax and Semantics of Propositional Logic • Satisfiability (SAT) • Tableau Algorithm for SAT • Structural induction • Semantic consequence and logical equivalence • Conjunctive and disjunctive normal form (CNF and DNF) Logic in Computer Science 2 Formulas of propositional Logic The alphabet of propositional logic consists of • an infinite set p1; p2;::: of atomic formulas; • the logical connectives: – : (‘not’), called negation; – ^ (‘and’), called conjunction; – _ (‘or’), called disjunction; • brackets: ( and ). Remarks: • atomic formulas are also called propositional variables; • we use letters p; q; r and indexed letters q1; q2;::: to denote atomic for- mulas. Logic in Computer Science 3 Formulas of propositional logic The set P of all formulas of propositional logic is defined inductively: • all atomic formulas are formulas; • if P is a formula, then :P is a formula; • if P and Q are formulas, then (P ^ Q) is a formula; • if P and Q are formulas, then (P _ Q) is a formula; • Nothing else is a formula. Remarks: • So, formulas are just strings over a certain alphabet without truth values or meaning. • We use P , Q, R and indexed letters such as P1;P2;:::;Q1;Q2;::: to de- note formulas of propositional logic. Logic in Computer Science 4 Truth Values An interpretation I is a function which assigns to any atomic formula pi a truth value I(pi) 2 f0; 1g: • If I(pi) = 1, then pi is called true under the interpretation I. • If I(pi) = 0, then pi is called false under the interpretation I. Given an assignment I we can compute the truth value of compound formulas step by step using so-called truth tables. Logic in Computer Science 5 Truth tables: negation The negation :P of a formula P is true when P is false and false otherwise: Definition Suppose an interpretation I is given and we know the value I(P ). Then the value I(:P ) is computed by 0 if I(P ) = 1 I(:P ) = 1 if I(P ) = 0 Corresponding truth table: P :P 1 0 0 1 Logic in Computer Science 6 Truth tables: conjunction The conjunction (P ^ Q) is true if and only if both P and Q are true. Definition Suppose an interpretation I is given and we know I(P ) and I(Q). Then 1 if I(P ) = 1 and I(Q) = 1 I(P ^ Q) = 0 if I(P ) = 0 or I(Q) = 0 Corresponding truth table: P Q (P ^ Q) 1 1 1 1 0 0 0 1 0 0 0 0 Logic in Computer Science 7 Truth tables: disjunction The disjunction (P _ Q) is true if and only if P is true or Q is true. Definition Suppose an interpretation I is given and we know I(P ) and I(Q). Then 1 if I(P ) = 1 or I(Q) = 1 I(P _ Q) = 0 if I(P ) = 0 and I(Q) = 0 Corresponding truth table: P Q (P _ Q) 1 1 1 1 0 1 0 1 1 0 0 0 Logic in Computer Science 8 Truth under an interpretation So, given an interpretation I, we can compute the truth value I(P ) of any formula P under I. • If I(P ) = 1, then P is called true under the interpretation I. • If I(P ) = 0, then P is called false under the interpretation I. Logic in Computer Science 9 Example List the Interpretations I such that P = ((p1 _:p2) ^ p3) is true under I. p1 p2 p3 :p2 (p1 _:p2) P 1 1 1 0 1 1 1 1 0 0 1 0 1 0 1 1 1 1 1 0 0 1 1 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 1 1 1 1 0 0 0 1 1 0 P is true under I1;I2, and I3, where • I1(p1) = I1(p2) = I1(p3) = 1, • I2(p1) = I2(p3) = 1 and I2(p2) = 0, • I3(p1) = I3(p2) = 0 and I3(p3) = 1. Logic in Computer Science 10 Truth table for (:P _ Q) P Q :P (:P _ Q) 1 1 0 1 1 0 0 0 0 1 1 1 0 0 1 1 (:P _ Q) represents the assertion ‘if P is true, then Q is true’. Define a ‘new’ connective ! by: (P ! Q) = (:P _ Q): In what follows we use (P ! Q) as an abbreviation for (:P _ Q). Logic in Computer Science 11 Truth table for ((P ! Q) ^ (Q ! P )) P Q (P ! Q) (Q ! P ) ((P ! Q) ^ (Q ! P )) 1 1 1 1 1 1 0 0 1 0 0 1 1 0 0 0 0 1 1 1 ((P ! Q) ^ (Q ! P )) represents the assertion ‘P is true if and only if Q is true’. Define a ‘new’ connective $ by: (P $ Q) := ((P ! Q) ^ (Q ! P )): In what follows we use (P $ Q) as an abbreviation for ((P ! Q) ^ (Q ! P )). Logic in Computer Science 12 Satisfiability Definition A formula P is satisfiable if and only if there exists an interpretation I such that I(P ) = 1. Examples • Every atomic formula p is satisfiable: given p, take the interpretation I with I(p) = 1. • :p is satisfiable: take the interpretation I with I(p) = 0. Then I(:p) = 1. • (p ^ :p) is not satisfiable: for any interpretation I, I(p ^ :p) = 0. • (p ^ :q) is satisfiable: take the interpretation I with I(p) = 1 and I(q) = 0. Logic in Computer Science 13 Satisfiability and Puzzles (1) Isaac and Albert were excitedly describing the result of the Third Annual Inter- national Science Fair Extravaganza in Sweden. There were three contestants, Louis, Rene, and Johannes. Isaac reported that Louis won the fair, while Rene came in second. Albert, on the other hand, reported that Johannes won the fair, while Louis came in second. In fact, neither Isaac nor Albert had given a correct report of the results of the science fair. Each of them had given one true statement and one false statement. What was the actual placing of the three contestants? (Credits: based on slides by Andrei Voronkov) Logic in Computer Science 14 Encoding into SAT We take atomic formulas L1;L2;L3;R1;R2;R3;J1;J2;J3 with the intuitive meaning: • L1: Louis came in first, L2: Louis came in second, L3: Louis came in third. • R1: Rene came in first, R2: Rene came in second, R3: Rene came in third. • J1: Johannes came in first, J2: Johannes came in second, J3: Johannes came in third. We represent the information about Isaac’s report using the formula J: • J = ((L1 ^ :R2) _ (:L1 ^ R2)) We represent the information about Albert’s report using the formula A: • A = ((J1 ^ :L2) _ (:J1 ^ L2)) Logic in Computer Science 15 Encoding into SAT We have to encode additional information. Namely, • everybody comes in at exactly one place: represent this using (P1 ^ P2), where P1 = ((L1 _ L2 _ L3) ^ (R1 _ R2 _ R3) ^ (J1 _ J2 _ J3)) and P2 = (:(L1 ^ L2) ^ :(L1 ^ L3) ^ :(L2 ^ L3) ^ :(R1 ^ R2) ··· ) • Only one person can come in first, etc: represent this using Q, where Q = (:(L1 ^ R1) ^ :(L2 ^ R2) ^ :(L3 ^ R3) ^ (R1 ^ J1) ··· ) Any interpretation I with I(J ^ A ^ P1 ^ P2 ^ Q) = 1 corresponds to a possible placing of the three contestants. Logic in Computer Science 16 Note on Conjunctions and Disjunctions On the previous slide, we have used formulas (P1 ^ · · · ^ Pn) and (P1 _···_ Pn) which we have not defined yet. Note that according to the syntax of proposi- tional formulas we use brackets whenever we form the conjunction/disjunction of two formulas. (P1 ^ · · · ^ Pn) is defined by induction over n as follows: • (P1) = P1; • (P1 ^ · · · ^ Pn+1) = ((P1 ^ · · · ^ Pn) ^ Pn+1); (P1 _···_ Pn) is defined by induction over n as follows: • (P1) = P1; • (P1 _···_ Pn+1) = ((P1 _···_ Pn) _ Pn+1); Logic in Computer Science 17 Checking Satisfiability (SAT) We want an algorithm that checks whether a given propositional formula is satisfiable. In other words, for a given P , we search for an interpretation I such that I(P ) = 1. If this search is successful, then the output of the algorithm should be • “yes, P is satisfiable”. If no such interpretation can be found, then the output of the algorithm should be • “no, P is not satisfiable”. Logic in Computer Science 18 SAT applications SAT has numerous applications in computer and information science. Here are some: • Circuit design: e.g., when are two circuits equivalent? • Model checking: does a program represented as a graph structure satisfy its specification? • Planning in artificial intelligence; • Haplotyping in bioinformatics: derive haplotype data from genotype data. Logic in Computer Science 19 Satisfiability checking based on Truth Tables Here is an algorithm checking satisfiability that is directly based on truth tables: 1. Let P be the input formula; 2. Using truth tables, compute the value I(P ) for all interpretations I; 3. if an I is found such that I(P ) = 1, then output “P is satisfiable”; 4. If no such I is found, output “P is not satisfiable”. If P is not satisfiable, then this algorithms requires the computation of I(P ) for 2n many interpretations I, where n is the number of atomic formulas in P . Thus the running time of this algorithm is exponential. Major open problem in computer science: does there exist an algorithm check- ing satisfiability that runs in polynomial time? This problem is also known as the P=NP problem. Logic in Computer Science 20 Tableau Method Intuition: to check satisfiability of P , we apply tableau rules to P that make explicit the constraints that P imposes on formulas occuring in P (subformulas).
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages81 Page
-
File Size-