A brief introduction to Logic. (slides from

Similar documents
Comp487/587 - Boolean Formulas

Fundamentals of Programming Languages I Introduction and Logics

Tecniche di Verifica. Introduction to Propositional Logic

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

Part 1: Propositional Logic

CS156: The Calculus of Computation

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

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

Lecture 2 Propositional Logic & SAT

Propositional Logic: Models and Proofs

Advanced Topics in LP and FP

Introduction to Artificial Intelligence Propositional Logic & SAT Solving. UIUC CS 440 / ECE 448 Professor: Eyal Amir Spring Semester 2010

Logic: Propositional Logic (Part I)

02 Propositional Logic

Propositional Calculus: Formula Simplification, Essential Laws, Normal Forms

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

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

Normal Forms of Propositional Logic

LOGIC PROPOSITIONAL REASONING

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

CSE507. Introduction. Computer-Aided Reasoning for Software. Emina Torlak courses.cs.washington.edu/courses/cse507/17wi/

Introduction to Solving Combinatorial Problems with SAT

Propositional and First Order Reasoning

Language of Propositional Logic

Decision Procedures for Satisfiability and Validity in Propositional Logic

Solvers for the Problem of Boolean Satisfiability (SAT) Will Klieber Aug 31, 2011

CS156: The Calculus of Computation Zohar Manna Autumn 2008

Deductive Systems. Lecture - 3

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

Propositional Logic Part 1

COMP9414: Artificial Intelligence Propositional Logic: Automated Reasoning

CS206 Lecture 03. Propositional Logic Proofs. Plan for Lecture 03. Axioms. Normal Forms

ECE473 Lecture 15: Propositional Logic

Conjunctive Normal Form and SAT

Propositional Logic: Evaluating the Formulas

CS250: Discrete Math for Computer Science. L6: CNF and Natural Deduction for PropCalc

SAT Solvers: Theory and Practice

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

Propositional Logic Language

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

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

Clause/Term Resolution and Learning in the Evaluation of Quantified Boolean Formulas

7 LOGICAL AGENTS. OHJ-2556 Artificial Intelligence, Spring OHJ-2556 Artificial Intelligence, Spring

Propositional Logic: Methods of Proof (Part II)

Conjunctive Normal Form and SAT

Chapter 4: Classical Propositional Semantics

Intelligent Agents. Pınar Yolum Utrecht University

CS1021. Why logic? Logic about inference or argument. Start from assumptions or axioms. Make deductions according to rules of reasoning.

A Resolution Method for Modal Logic S5

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

NP and Computational Intractability

CS 380: ARTIFICIAL INTELLIGENCE

Truth-Functional Logic

Logic and Inferences

Quantified Boolean Formulas: Complexity and Expressiveness

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

CDM Propositional Logic

Formal Verification Methods 1: Propositional Logic

Propositional and Predicate Logic - II

Conjunctive Normal Form and SAT

CSE 555 HW 5 SAMPLE SOLUTION. Question 1.

Propositional Resolution

Logical Agents. Chapter 7

Inference in Propositional Logic

Propositional Logic: Methods of Proof (Part II)

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

Learning Goals of CS245 Logic and Computation

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

PROPOSITIONAL LOGIC. VL Logik: WS 2018/19

Part 1: Propositional Logic

Introduction to Artificial Intelligence. Logical Agents

Chapter 4: Computation tree logic

Class Assignment Strategies

Propositional Logic: Methods of Proof. Chapter 7, Part II

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

COMP219: Artificial Intelligence. Lecture 20: Propositional Reasoning

Foundations of Artificial Intelligence

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

A New 3-CNF Transformation by Parallel-Serial Graphs 1

Classical Propositional Logic

INF3170 Logikk Spring Homework #8 For Friday, March 18

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

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

Satisfiability and SAT Solvers. CS 270 Math Foundations of CS Jeremy Johnson

Lecture 4: Proposition, Connectives and Truth Tables

Artificial Intelligence

NP-Complete Reductions 2

(Yet another) decision procedure for Equality Logic

CS 375/CS M75 Logic for Computer Science

Logical Agents (I) Instructor: Tsung-Che Chiang

Propositional and Predicate Logic. jean/gbooks/logic.html

Logical Inference. Artificial Intelligence. Topic 12. Reading: Russell and Norvig, Chapter 7, Section 5

Artificial Intelligence Chapter 7: Logical Agents

Tautologies, Contradictions, and Contingencies

Logical Agent & Propositional Logic

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

CS:4420 Artificial Intelligence

Propositional Logic. Logic. Propositional Logic Syntax. Propositional Logic

Propositional Resolution Part 1. Short Review Professor Anita Wasilewska CSE 352 Artificial Intelligence

Chapter 7 R&N ICS 271 Fall 2017 Kalev Kask

Transcription:

A brief introduction to Logic (slides from http://www.decision-procedures.org/) 1

A Brief Introduction to Logic - Outline Propositional Logic :Syntax Propositional Logic :Semantics Satisfiability and validity Normal forms 2

Propositional logic: Syntax The symbols of the language: Propositional symbols (Prop): A, B, C, Connectives: and or not implies equivalent to xor (different than), > False, True Parenthesis:(, ). 3

Formulas Grammar of well-formed propositional formulas Formula := prop ( Formula) (Formula o Formula).... where prop 2 Prop and o is one of the binary relations 4

Assignments Definition: A truth-values assignment,, is an element of 2 Prop (i.e., 2 Prop ). In other words, is a subset of the variables that are assigned true. Equivalently, we can see as a mapping from variables to truth values: : Prop {0,1} Example: : {A 0, B 1,...} 5

Satisfaction relation (²): intuition An assignment can either satisfy or not satisfy a given formula. ² φ means satisfies φ or φ holds at or is a model of φ We will first see an example. Then we will define these notions formally. 6

Example Let Á = (A Ç (B C)) Let = {A 0, B 0, C 1} Q: Does satisfy Á? (in symbols: does it hold that ² Á? ) A: (0 Ç (0 1)) = (0 Ç 1) = 1 Hence, ² Á. Let us now formalize an evaluation process. 7

The satisfaction relation (²): formalities ² is a relation: ² µ (2 Prop x Formula) Examples: ({a}, a Ç b) // the assignment = {a} satisfies a Ç b ({a,b}, a Æ b) Alternatively: ² µ ({0,1} Prop Formula) Examples: (01, a Ç b) // the assignment = {a 0, b 1} satisfies a Ç b (11, a Æ b) 8

The satisfaction relation (²): formalities ² is defined recursively: ² p if (p) = true ² φ if 2 φ. ² φ 1 φ 2 if ² φ 1 and ² φ 2 ² φ 1 φ 2 if ² φ 1 or ² φ 2 ² φ 1 φ 2 if ² φ 1 implies ² φ 2 ² φ 1 φ 2 if ² φ 1 iff ² φ 2 9

From definition to an evaluation algorithm Truth Evaluation Problem Given φ Formula and 2 AP(φ), does ² φ? Eval(φ, ){ If φ A, return (A). If φ ( φ 1 ) return Eval(φ 1, )) If φ (φ 1 o φ 2 ) return Eval(φ 1, ) o Eval(φ 2, ) } Eval uses polynomial time and space. 10

Set of assignments Intuition: a formula specifies a set of truth assignments. Function models: Formula 2 2Prop (a formula set of satisfying assignments) Recursive definition: models(a) = { (A) = 1}, A Prop models( φ 1 ) = 2 Prop models(φ 1 ) models(φ 1 φ 2 ) = models(φ 1 ) models(φ 2 ) models(φ 1 φ 2 ) = models(φ 1 ) models(φ 2 ) models(φ 1 φ 2 ) = (2 Prop models(φ 1 )) models(φ 2 ) 11

Theorem Let φ Formula and 2 Prop, then the following statements are equivalent: 1. ² φ 2. models(φ) 12

Semantic Classification of formulas A formula φ is called valid if models(φ) = 2 Prop. (also called a tautology). A formula φ is called satisfiable if models(φ) ;. A formula φ is called unsatisfiable if models(φ) = ;. (also called a contradiction). satisfiable valid unsatisfiable 13

Validity, satisfiability... in truth tables p q (p (q q)) (p Æ :p) p Ç :q 0 0 1 0 1 0 1 1 0 0 1 0 1 0 1 1 1 1 0 1 14

Look what we can do now... We can write: ² Á when Á is valid 2 Á when Á is not valid 2 :Á when Á is satisfiable ² :Á when Á is unsatisfiable 15

The decision problem of formulas The decision problem: Given a propositional formula Á, is Á satisfiable? An algorithm that always terminates with a correct answer to this problem is called a decision procedure for propositional logic. 16

Two classes of algorithms for validity Q: Is φ satisfiable (/:φ is valid)? Complexity: NP-Complete (the first-ever! Cook s theorem) Two classes of algorithms for finding out: 1. Enumeration of possible solutions (Truth tables etc). 2. Deduction More generally (beyond propositional logic): Enumeration is possible only in some logics. Deduction cannot necessarily be fully automated. 17

The satisfiability problem: enumeration Given a formula φ, is φ satisfiable? Boolean SAT(φ) { B:=false } for all 2 AP(φ) B = B Eval(φ, ) end return B There must be a better way to do that in practice. 18

A Brief Introduction to Logic - Outline Propositional Logic :Syntax Propositional Logic :Semantics Satisfiability and validity Normal forms 19

Definitions 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} 20

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) 21

Negation Normal Form (NNF) Definition: A formula is said to be in Negation Normal Form (NNF) if it only contains :, Æ and Ç connectives and only atoms can be negated. Examples: 1 = :(A Ç :B) is not in NNF 2 = :A Æ B is in NNF 22

Converting to NNF Every formula can be converted to NNF in linear time: Eliminate all connectives other than Æ, Ç, : Use De Morgan and double-negation rules to push negations to the right Example: = :(A! :B) Eliminate! : = :(:A Ç :B) Push negation using De Morgan: = (::A Æ ::B) Use Double negation rule: = (A Æ B) 23

Disjunctive Normal Form (DNF) Definition: A formula is said to be in Disjunctive Normal Form (DNF) if it is a disjunction of terms. In other words, it is a formula of the form where l i,j is the j-th literal in the i-th term. Examples = (A Æ :B Æ C) Ç (:A Æ D) Ç (B) is in DNF DNF is a special case of NNF 24

Converting to DNF Every formula can be converted to DNF in exponential time and space: Convert to NNF Distribute disjunctions following the rule: ² A Æ (B Ç C) $ ((A Æ B) Ç (A Æ C)) Example: = (A Ç B) Æ (:C Ç D) = ((A Ç B) Æ (:C)) Ç ((A Ç B) Æ D) = (A Æ :C) Ç (B Æ :C) Ç (A Æ D) Ç (B Æ D) 25

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 l i,j is the j-th literal in the i-th term. Examples = (A Ç :B Ç C) Æ (:A Ç D) Æ (B) is in CNF CNF is a special case of NNF 26

Converting to CNF Every formula can be converted to CNF: in exponential time and space with the same set of atoms in linear time and space if new variables are added. In this case the original and converted formulas are equisatisfiable. This technique is called Tseitin s encoding. 27

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 28

Converting to CNF: the exponential way Consider the formula = (x 1 Æ y 1 ) Ç (x 2 Æ y 2 ) CNF( )= (x 1 Ç x 2 ) Æ (x 1 Ç y 2 ) Æ (y 1 Ç x 2 ) Æ (y 1 Ç y 2 ) Now consider: n = (x 1 Æ y 1 ) Ç (x 2 Æ y 2 ) Ç Ç (x n Æ y n ) Q: How many clauses CNF( ) returns? A: 2 n 29

Converting to CNF: Tseitin s encoding Consider the formula = (A! (B Æ C)) The parse tree:! a 1 A Æ a 2 B C Associate a new auxiliary variable with each gate. Add constraints that define these new variables. Finally, enforce the root node. 30

Converting to CNF: Tseitin s encoding Need to satisfy: (a 1 $ (A! a 2 )) Æ (a 2 $ (B Æ C)) Æ! a 1 (a 1 ) A Æ a 2 B C Each such constraint has a CNF representation with 3 or 4 clauses. 31

Converting to CNF: Tseitin s encoding Need to satisfy: (a 1 $ (A! a 2 )) Æ (a 2 $ (B Æ C)) Æ (a 1 ) First: (a 1 Ç A) Æ (a 1 Ç :a 2 ) Æ (:a 1 Ç :A Ç a 2 ) Second: (:a 2 Ç B) Æ (:a 2 Ç C) Æ (a 2 Ç :B Ç :C) 32

Converting to CNF: Tseitin s encoding Let s go back to n = (x 1 Æ y 1 ) Ç (x 2 Æ y 2 ) Ç Ç (x n Æ y n ) With Tseitin s encoding we need: n auxiliary variables a 1,,a n. Each adds 3 constraints. Top clause: (a 1 Ç Ç a n ) Hence, we have 3n + 1 clauses, instead of 2 n. 3n variables rather than 2n. 33

What now? Time to solve the decision problem for propositional logic. The only algorithm we saw so far was building truth tables. 34

Two classes of algorithms for validity Q: Is φ valid? Equivalently: is :φ satisfiable? Two classes of algorithm for finding out: 1. Enumeration of possible solutions (Truth tables etc). 2. Deduction In general (beyond propositional logic): Enumeration is possible only in some theories. Deduction typically cannot be fully automated. 35

The satisfiability Problem: enumeration Given a formula φ, is φ satisfiable? Boolean SAT(φ) { } B:=false for all 2 AP(φ) B = B Eval(φ, ) end return B NP-Complete (the first-ever! Cook s theorem) 36

A Brief Introduction to Logic - Outline Propositional Logic :Syntax Propositional Logic :Semantics Satisfiability and validity Normal forms 37