Propositional Logic. Testing, Quality Assurance, and Maintenance Winter Prof. Arie Gurfinkel

Similar documents
Propositional Logic. Methods & Tools for Software Engineering (MTSE) Fall Prof. Arie Gurfinkel

Knowledge base (KB) = set of sentences in a formal language Declarative approach to building an agent (or other system):

Propositional Logic: Models and Proofs

02 Propositional Logic

Tecniche di Verifica. Introduction to Propositional Logic

Deductive Systems. Lecture - 3

Part 1: Propositional Logic

Propositional Logic Basics Propositional Equivalences Normal forms Boolean functions and digital circuits. Propositional Logic.

Logic. Introduction to Artificial Intelligence CS/ECE 348 Lecture 11 September 27, 2001

A brief introduction to Logic. (slides from

Logic: Propositional Logic (Part I)

Description Logics. Foundations of Propositional Logic. franconi. Enrico Franconi

Language of Propositional Logic

Inference in Propositional Logic

Comp487/587 - Boolean Formulas

7. Propositional Logic. Wolfram Burgard and Bernhard Nebel

The Calculus of Computation: Decision Procedures with Applications to Verification. Part I: FOUNDATIONS. by Aaron Bradley Zohar Manna

Propositional and Predicate Logic - II

Advanced Topics in LP and FP

Logic and Inferences

Knowledge representation DATA INFORMATION KNOWLEDGE WISDOM. Figure Relation ship between data, information knowledge and wisdom.

Propositional Logic Language

Propositional logic. Programming and Modal Logic

COMP9414: Artificial Intelligence Propositional Logic: Automated Reasoning

Artificial Intelligence Chapter 7: Logical Agents

Knowledge based Agents

Agenda. Artificial Intelligence. Reasoning in the Wumpus World. The Wumpus World

Chapter 7 R&N ICS 271 Fall 2017 Kalev Kask

Price: $25 (incl. T-Shirt, morning tea and lunch) Visit:

Propositional logic. First order logic. Alexander Clark. Autumn 2014

CS 380: ARTIFICIAL INTELLIGENCE PREDICATE LOGICS. Santiago Ontañón

Foundations of Artificial Intelligence

Foundations of Artificial Intelligence

COMP3702/7702 Artificial Intelligence Week 5: Search in Continuous Space with an Application in Motion Planning " Hanna Kurniawati"

CS 380: ARTIFICIAL INTELLIGENCE

Introduction to Artificial Intelligence. Logical Agents

Foundations of Artificial Intelligence

Natural Deduction. Formal Methods in Verification of Computer Systems Jeremy Johnson

Announcements. CS243: Discrete Structures. Propositional Logic II. Review. Operator Precedence. Operator Precedence, cont. Operator Precedence Example

Computation and Logic Definitions

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

NP-Complete Reductions 2

Intelligent Agents. Pınar Yolum Utrecht University

Logical Agents. Knowledge based agents. Knowledge based agents. Knowledge based agents. The Wumpus World. Knowledge Bases 10/20/14

CS156: The Calculus of Computation

Propositional logic. Programming and Modal Logic

Artificial Intelligence

Propositional Logic: Review

Logical Agent & Propositional Logic

Intelligent Systems. Propositional Logic. Dieter Fensel and Dumitru Roman. Copyright 2008 STI INNSBRUCK

Introduction to Solving Combinatorial Problems with SAT

Logical Agents. Chapter 7

Propositional logic II.


Introduction to Intelligent Systems

Artificial Intelligence. Propositional Logic. Copyright 2011 Dieter Fensel and Florian Fischer

Logical Agent & Propositional Logic

Logical agents. Chapter 7. Chapter 7 1

Learning Goals of CS245 Logic and Computation

COMP219: Artificial Intelligence. Lecture 20: Propositional Reasoning

Introduction to Intelligent Systems

CS:4420 Artificial Intelligence

CS 188: Artificial Intelligence Spring 2007

Title: Logical Agents AIMA: Chapter 7 (Sections 7.4 and 7.5)

PROPOSITIONAL LOGIC. VL Logik: WS 2018/19

Logical agents. Chapter 7. Chapter 7 1

Normal Forms of Propositional Logic

CS 7180: Behavioral Modeling and Decision- making in AI

ECE473 Lecture 15: Propositional Logic

Class Assignment Strategies

Revised by Hankui Zhuo, March 21, Logical agents. Chapter 7. Chapter 7 1

Syntax of propositional logic. Syntax tree of a formula. Semantics of propositional logic (I) Subformulas

22c:145 Artificial Intelligence

Propositional Logic: Part II - Syntax & Proofs 0-0

The Wumpus Game. Stench Gold. Start. Cao Hoang Tru CSE Faculty - HCMUT

Logic: Propositional Logic Truth Tables

Artificial Intelligence

Propositional Logic and Semantics

Automated Program Verification and Testing 15414/15614 Fall 2016 Lecture 2: Propositional Logic

LOGIC PROPOSITIONAL REASONING

Lecture 2. Logic Compound Statements Conditional Statements Valid & Invalid Arguments Digital Logic Circuits. Reading (Epp s textbook)

Inference Methods In Propositional Logic

Conjunctive Normal Form and SAT

Description Logics. Deduction in Propositional Logic. franconi. Enrico Franconi

Lecture #14: NP-Completeness (Chapter 34 Old Edition Chapter 36) Discussion here is from the old edition.

CS 512, Spring 2017, Handout 10 Propositional Logic: Conjunctive Normal Forms, Disjunctive Normal Forms, Horn Formulas, and other special forms

A Resolution Method for Modal Logic S5

Critical Reading of Optimization Methods for Logical Inference [1]

Computational Logic. Davide Martinenghi. Spring Free University of Bozen-Bolzano. Computational Logic Davide Martinenghi (1/30)

TDT4136 Logic and Reasoning Systems

Logical Agents. Outline

CSCE 222 Discrete Structures for Computing. Propositional Logic. Dr. Hyunyoung Lee. !!!!!! Based on slides by Andreas Klappenecker

Warm-Up Problem. Is the following true or false? 1/35

Natural Deduction for Propositional Logic

Decision Procedures for Satisfiability and Validity in Propositional Logic

Propositional Logic Part 1

Logical Agents: Propositional Logic. Chapter 7

Inf2D 06: Logical Agents: Knowledge Bases and the Wumpus World

CS154, Lecture 15: Cook-Levin Theorem SAT, 3SAT

Proof Methods for Propositional Logic

Transcription:

Propositional Logic Testing, Quality Assurance, and Maintenance Winter 2018 Prof. Arie Gurfinkel

References Chpater 1 of Logic for Computer Scientists http://www.springerlink.com/content/978-0-8176-4762-9/ 2 2

What is Logic According to Merriam-Webster dictionary logic is: a (1) : a science that deals with the principles and criteria of validity of inference and demonstration d :the arrangement of circuit elements (as in a computer) needed for computation; also: the circuits themselves 3 3

What is Formal Logic Formal Logic consists of syntax what is a legal sentence in the logic semantics what is the meaning of a sentence in the logic proof theory formal (syntactic) procedure to construct valid/true sentences Formal logic provides a language to precisely express knowledge, requirements, facts a formal way to reason about consequences of given facts rigorously 4 4

Propositional Logic (or Boolean Logic) Explores simple grammatical connections such as and, or, and not between simplest atomic sentences A = Paris is the capital of France B = mice chase elephants The subject of propositional logic is to declare formally the truth of complex structures from the truth of individual atomic components A and B A or B if A then B 5 5

Syntax and Semantics Syntax MW: the way in which linguistic elements (such as words) are put together to form constituents (such as phrases or clauses) Determines and restricts how things are written Semantics MW: the study of meanings Determines how syntax is interpreted to give meaning 6 6

Syntax of Propositional Logic An atomic formula has a form A i, where i = 1, 2, 3 Formulas are defined inductively as follows: All atomic formulas are formulas For every formula F, F (called not F) is a formula For all formulas F and G, F G (called and) and F G (called or) are formulas Abbreviations use A, B, C, instead of A 1, A 2, use F 1 F 2 instead of F 1 F 2 use F 1 F 2 instead of (F 1 F 2 ) (F 2 F 1 ) (implication) (iff) 7 7

Syntax of Propositional Logic (PL) truth symbol ::= >(true)?(false) variable ::= p, q, r,... atom ::= truth symbol variable literal ::= atom atom formula ::= literal formula formula ^ formula formula _ formula formula! formula formula $ formula 8 8

Example F = ((A 5 ^ A 6 ) _ A 3 ) Sub-formulas are F, ((A 5 ^ A 6 ) _ A 3 ), A 5 ^ A 6, A 3, A 5,A 6,A 3 9 9

Semantics of propositional logic For an atomic formula A i in D: A (A i ) = A(A i ) A (( F G)) = 1 if A (F) = 1 and A (G) = 1 = 0 otherwise A ((F G)) = 1 if A (F) = 1 or A (G) = 1 = 0 otherwise A ( F) = 1 if A (F) = 0 = 0 otherwise 10 10

Example F = (A ^ B) _ C A(A) =1 A(B) =1 A(C) =0 11 11

Truth Tables for Basic Operators A(F ) A(G) A((F ^ G)) 0 0 0 0 1 0 1 0 0 1 1 1 A(F ) A( F ) 0 1 1 0 A(F ) A(G) A((F _ G)) 0 0 0 0 1 1 1 0 1 1 1 1 12 12

F = (A ^ B) _ C A(A) =1 A(B) =1 A(C) =0 13 13

Propositional Logic: Semantics An assignment A is suitable for a formula F if A assigns a truth value to every atomic proposition of F An assignment A is a model for F, written A F, iff A is suitable for F A(F) = 1, i.e., F holds under A A formula F is satisfiable iff F has a model, otherwise F is unsatisfiable (or contradictory) A formula F is valid (or a tautology), written F, iff every suitable assignment for F is a model for F 14 14

Determining Satisfiability via a Truth Table A formula F with n atomic sub-formulas has 2 n suitable assignments Build a truth table enumerating all assignments F is satisfiable iff there is at least one entry with 1 in the output 15 15

An example F =( A! (A! B)) A B A (A! B) F 0 0 1 1 1 0 1 1 1 1 1 0 0 0 1 1 1 0 1 1 16 16

Validity and Unsatisfiability Theorem: A formula F is valid if and only if F is unsatifsiable Proof: F is valid ó every suitable assignment for F is a model for F ó every suitable assignment for F is not a model for F ó F does not have a model ó F is unsatisfiable 17 17

Normal Forms: CNF and DNF A literal is either an atomic proposition v or its negation ~v A clause is a disjunction of literals e.g., (v1 ~v2 v3) A formula is in Conjunctive Normal Form (CNF) if it is a conjunction of disjunctions of literals (i.e., a conjunction of clauses): e.g., (v1 ~v2) && (v3 v2) n^ _ m i ( L i,j ) i=1 j=1 A formula is in Disjunctive Normal Form (DNF) if it is a disjuction of conjunctions of literals n_ ^m i i=1 ( j=1 L i,j ) 18 18

From Truth Table to CNF and DNF ( A ^ B ^ C) _ (A ^ B ^ C) _ (A ^ B ^ C) (A _ B _ C) ^ (A _ B _ C) ^ (A _ B _ C) ^ ( A _ B _ C) ^ ( A _ B _ C) A B C F 0 0 0 1 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 1 1 0 1 1 1 1 0 0 1 1 1 0 19 19

Normal Form Theorem Theorem: For every formula F, there is an equivalent formula F 1 in CNF and F 2 in DNF Proof: (by induction on the structure of the formula F) 20 20

ENCODING PROBLEMS INTO CNF-SAT 21 21

Graph k-coloring Given a graph G = (V, E), and a natural number k > 0 is it possible to assign colors to vertices of G such that no two adjacent vertices have the same color. Formally: does there exists a function f : V à [0..k) such that for every edge (u, v) in E, f(u)!= f(v) Graph coloring for k > 2 is NP-complete Problem: Encode k-coloring of G into CNF construct CNF C such that C is SAT iff G is k- colorable https://en.wikipedia.org/wiki/graph_coloring 22 22

k-coloring as CNF Let a Boolean variable f v,i denote that vertex v has color i if f v,i is true if and only if f(v) = i Every vertex has at least one color _ 0applei<k f v,i (v 2 V ) No vertex is assigned two colors ^ 0applei<j<k No two adjacent vertices have the same color ^ 0applei<k ( f v,i _ f v,j ) (v 2 V ) ( f v,i _ f u,i ) ((v, u) 2 E) 23 23

Propositional Resolution Pivot C p D p C D Res({C, p}, {D,!p}) = {C, D} Resolvent Given two clauses (C, p) and (D,!p) that contain a literal p of different polarity, create a new clause by taking the union of literals in C and D 24 24

Resolution Lemma Lemma: Let F be a CNF formula. Let R be a resolvent of two clauses X and Y in F. Then, F {R} is equivalent to F 25 25

Proof System P 1,...,P n ` C An inference rule is a tuple (P 1,, P n, C) where, P 1,, P n, C are formulas P i are called premises and C is called a conclusion intuitively, the rules says that the conclusion is true if the premises are A proof system P is a collection of inference rules A proof in a proof system P is a tree (or a DAG) such that nodes are labeled by formulas for each node n, (parents(n), n) is an inference rule in P 26 26

Propositional Resolution C p D p C D Propositional resolution is a sound inference rule Proposition resolution system consists of a single propositional resolution rule 27 27

Example of a resolution proof 28 28

Resolution Proof Example Show by resolution that the following CNF is UNSAT b ^ ( a _ b _ c) ^ a ^ ( a _ c) a _ b _ c a b _ c b a a _ c c c? 29 29

Entailment and Derivation A set of formulas F entails a set of formulas G iff every model of F and is a model of G F = G A formula G is derivable from a formula F by a proof system P if there exists a proof whose leaves are labeled by formulas in F and the root is labeled by G F `P G 30 30

Soundness and Completeness A proof system P is sound iff (F `P G) =) (F = G) A proof system P is complete iff (F = G) =) (F `P G) 31 31

Completeness of Propositional Resolution Theorem: Propositional resolution is sound and complete for propositional logic 32 32

Proof by resolution Notation: positive numbers mean variables, negative mean negation Let j = (1 3) (-1 2 5) (-1 4) (-1-4) We ll try to prove j (3 5) (1 3) (-1 2 5) (2 3 5) (1-2) (1 3 5) (-1 4) (-1-4) (-1) (3 5) http://www.decision-procedures.org/slides/ 33 33

Resolution Resolution is a sound and complete inference system for CNF If the input formula is unsatisfiable, there exists a proof of the empty clause http://www.decision-procedures.org/slides/ 34 34

Example: UNSAT Derivation Notation: positive numbers mean variables, negative mean negation Let j = (1 3) (-1 2) (-1 4) (-1-4) (-3) (1 3) (-1 2) (2 3) (1-2) (1 3) (-1 4) (-1-4) (-1) (3) (-3) () http://www.decision-procedures.org/slides/ 35 35

Logic for Computer Scientists: Ex. 33 Using resolution show that A ^ B ^ C is a consequence of A _ B B _ C A _ C A _ B _ C 36 36

Logic for Computer Scientists: Ex. 34 Show using resolution that F is valid F =( B ^ C ^ D) _ ( B ^ D) _ (C ^ D) _ B F =(B _ C _ D) ^ (B _ D) ^ ( C _ D) ^ B 37 37