Normal Forms of Propositional Logic

Similar documents
Natural Deduction for Propositional Logic

Propositional logic. Programming and Modal Logic

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

Part 1: Propositional Logic

A brief introduction to Logic. (slides from

Propositional logic. Programming and Modal Logic

Decision Procedures for Satisfiability and Validity in Propositional Logic

Tecniche di Verifica. Introduction to Propositional Logic

Language of Propositional Logic

CS720 Class Notes. Steve Revilak

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

Logic: Propositional Logic (Part I)

CS156: The Calculus of Computation

Learning Goals of CS245 Logic and Computation

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

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

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

ECE473 Lecture 15: Propositional Logic

Propositional Logic: Models and Proofs

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

LOGIC PROPOSITIONAL REASONING

Propositional Logic Language

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

CS156: The Calculus of Computation Zohar Manna Autumn 2008

Advanced Topics in LP and FP

Comp487/587 - Boolean Formulas

Deductive Systems. Lecture - 3

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

Supplementary exercises in propositional logic

Propositional Logic: Evaluating the Formulas

Logic and Inferences

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

Tautologies, Contradictions, and Contingencies

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

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

Proof Methods for Propositional Logic

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

Truth-Functional Logic

CS 486: Lecture 2, Thursday, Jan 22, 2009

COMP9414: Artificial Intelligence Propositional Logic: Automated Reasoning

Conjunctive Normal Form and SAT

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

2.2: Logical Equivalence: The Laws of Logic

Conjunctive Normal Form and SAT

Propositional and Predicate Logic - II

Inference in Propositional Logic

Applied Logic. Lecture 1 - Propositional logic. Marcin Szczuka. Institute of Informatics, The University of Warsaw

7. Propositional Logic. Wolfram Burgard and Bernhard Nebel

Proof Calculus for Partial Correctness

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

Lecture 2 Propositional Logic & SAT

Section 1.2 Propositional Equivalences. A tautology is a proposition which is always true. A contradiction is a proposition which is always false.

COMP219: Artificial Intelligence. Lecture 20: Propositional Reasoning

02 Propositional Logic

Conjunctive Normal Form and SAT

Announcements. CS311H: Discrete Mathematics. Propositional Logic II. Inverse of an Implication. Converse of a Implication

Foundations of Artificial Intelligence

Foundations of Artificial Intelligence

Lecture 9: The Splitting Method for SAT

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

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

Logic: First Order Logic

Chapter 4: Classical Propositional Semantics

Propositional Calculus: Formula Simplification, Essential Laws, Normal Forms

Logic and Discrete Mathematics. Section 3.5 Propositional logical equivalence Negation of propositional formulae

Propositional Reasoning

CS 380: ARTIFICIAL INTELLIGENCE

NP and Computational Intractability

Outline. Formale Methoden der Informatik First-Order Logic for Forgetters. Why PL1? Why PL1? Cont d. Motivation

Chapter 2. Reductions and NP. 2.1 Reductions Continued The Satisfiability Problem (SAT) SAT 3SAT. CS 573: Algorithms, Fall 2013 August 29, 2013

INF3170 Logikk Spring Homework #8 For Friday, March 18

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

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

Part 1: Propositional Logic

PROPOSITIONAL LOGIC. VL Logik: WS 2018/19

Introduction to Solving Combinatorial Problems with SAT

NP-Completeness Part II

Quantified Boolean Formulas: Complexity and Expressiveness

Propositional logic II.

Quantified Boolean Formulas Part 1

3 Propositional Logic

Logical Agents (I) Instructor: Tsung-Che Chiang

Knowledge based Agents

The Language. Elementary Logic. Outline. Well-Formed Formulae (wff s)

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

Foundations of Artificial Intelligence

Sec$on Summary. Tautologies, Contradictions, and Contingencies. Logical Equivalence. Normal Forms (optional, covered in exercises in text)

Introduction to Intelligent Systems

Propositional Logic: Semantics

Introduction to Intelligent Systems

Logical agents. Chapter 7. Chapter 7 1

Computation and Logic Definitions

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

INTRODUCTION TO LOGIC. Propositional Logic. Examples of syntactic claims

Lecture Notes on SAT Solvers & DPLL

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

Reasoning with Quantified Boolean Formulas

Propositional Logic: Equivalence

CS:4420 Artificial Intelligence

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

Transcription:

Normal Forms of Propositional Logic Bow-Yaw Wang Institute of Information Science Academia Sinica, Taiwan September 12, 2017 Bow-Yaw Wang (Academia Sinica) Normal Forms of Propositional Logic September 12, 2017 1 / 22

Outline 1 Normal Forms Semantic equivalence, satisfiability, and validity Conjunctive normals forms and validity Horn clauses and satisfiability Bow-Yaw Wang (Academia Sinica) Normal Forms of Propositional Logic September 12, 2017 2 / 22

Semantically Equivalence and Validity Consider two formulae φ 1 φ 2 and φ 2 φ 1. Intuitively, φ 1 φ 2 and φ 2 φ 1 should have the same meaning. More formally, two formulae φ and ψ have the same meaning if their truth tables coincide. Definition Let φ and ψ be propositional logic formulae. φ and ψ are semantically equivalent (written φ ψ) if both φ ψ and ψ φ hold. Examples p q q p p q p q p q p r r p q r p (q r) A formula φ is valid if it is a tautology. Definition Let φ be a propositional logic formula. φ is valid if φ. Bow-Yaw Wang (Academia Sinica) Normal Forms of Propositional Logic September 12, 2017 3 / 22

Semantic Entailment and Validity Lemma Let φ 1, φ 2,..., φ n, ψ be propositional logic formulae. φ 1, φ 2,..., φ n ψ iff φ 1 (φ 2 (φ n ψ)). Proof. Suppose φ 1 (φ 2 (φ n ψ)) Consider any valuation. If φ 1, φ 2,..., φ n evaluate to T under the valuation, φ must evaluate to T since φ 1 (φ 2 (φ n ψ)). Hence φ 1, φ 2,..., φ n ψ. The other direction is proved in Step 1 of the completeness theorem. Bow-Yaw Wang (Academia Sinica) Normal Forms of Propositional Logic September 12, 2017 4 / 22

Conjunctive Normal Form (CNF) Definition A literal L is either an atom p or its negation p. A clause D is a disjunction of literals. A formula C is in conjunctive normal form (CNF) if it is a conjunction of clauses. L = p p D = L L D C = D D C Examples: ( q p r) ( p r) q, (p r) ( p r) (p r) Bow-Yaw Wang (Academia Sinica) Normal Forms of Propositional Logic September 12, 2017 5 / 22

Validity of CNF Formulae Lemma A clause L 1 L 2 L m is valid iff there is a propositional atom p such that L i is p and L j is p for some 1 i, j m. Proof. Without loss of generality, assume L 1 = p and L 2 = p. Then p p L 3 L m evaluates to T for any valuation. The clause is valid. Conversely, consider the valuation where all literals evaluate to F. This is possible since every literal L i has no negation in the clause. The clause evaluates to F under the valuation. Examples: p q q p r is valid; p q r q is not valid (consider {p F, q T, r F}). For any propositional logic formula φ in CNF, the validity of φ can be checked in linear time. Bow-Yaw Wang (Academia Sinica) Normal Forms of Propositional Logic September 12, 2017 6 / 22

Satisfiability of CNF Formulae Definition Let φ be a propositional logic formula. φ is satisfiable if it evaluates to T under some valuation. Example: p q p is satisfiable (consider {p T, q T}); it is not valid (consider {p F, q T}). Proposition Let φ be a propositional logic formula. φ is satisfiable iff φ is not valid. Proof. Suppose φ evaluates to T under a valuation. Then φ evaluates to F under the valuation. φ is not valid. Conversely, suppose φ is not valid. Hence φ evaluates to F under a valuation. Thus φ evaluates to T under the valuation. φ is satisfiable. Bow-Yaw Wang (Academia Sinica) Normal Forms of Propositional Logic September 12, 2017 7 / 22

From Truth Tables to Conjunctive Normal Form Suppose we have the truth table for a formula φ with propositional atoms p 1, p 2,..., p n. For each line l where φ evaluates to F, construct a clause ψ l as follows. ψ l = L l,1 L l,2 L l,n where L l,j = p j if p j is T at line l; otherwise L l,j = p j. Then φ ψ 1 ψ 2 ψ m where ψ l s are contructed for every line evaluating φ to F. Observe that ψ 1 ψ 2 ψ m is F iff ψ l is F for some 1 l m. ψ l = L l,1 L l,2 L l,n is F iff L l,j is F for every 1 j n. L l,j is F iff p j has its truth value at line l. In other words, ψ 1 ψ 2 ψ m is F under a valuation iff the valuation evaluates φ to F in φ s truth table. Bow-Yaw Wang (Academia Sinica) Normal Forms of Propositional Logic September 12, 2017 8 / 22

From Truth Tables to Conjunctive Normal Form Example Translate p q q r into CNF. Proof. p q r p q q r p q r p q q r F F F T T F F F F F T T T F T F F T F T T T F T F T T F T T T F p q r ψ l p q r ψ l F T T p q r T F F p q r T F T p q r T T T p q r p q q r (p q r) ( p q r) ( p q r) ( p q r). Bow-Yaw Wang (Academia Sinica) Normal Forms of Propositional Logic September 12, 2017 9 / 22

Outline 1 Normal Forms Semantic equivalence, satisfiability, and validity Conjunctive normals forms and validity Horn clauses and satisfiability Bow-Yaw Wang (Academia Sinica) Normal Forms of Propositional Logic September 12, 2017 10 / 22

Validity Checking Given a propositional logic formula in conjunctive normal form, we can check the validity of the formula in linear time. Recall that a formula is valid iff it is a theorem. If we can translate any propositional logic formula into conjunctive normal form, we can check the validity of the formula! We know how to translate any logic formula to conjunctive normal form by its truth table. This is not satisfactory. If we have to construct its truth table, we can check validity already. We will give an algorithm CNF(φ) to convert any propositional logic formula into conjunctive normal form without building its truth table. Bow-Yaw Wang (Academia Sinica) Normal Forms of Propositional Logic September 12, 2017 11 / 22

From Formula to Conjunctive Normal Form Any propositional logic formula can be transformed to conjunctive normal form by the following equivalences: φ ψ φ ψ (φ ψ) φ ψ (φ ψ) φ ψ φ (ψ 1 ψ 2 ) (φ ψ 1 ) (φ ψ 2 ) φ (ψ 1 ψ 2 ) (φ ψ 1 ) (φ ψ 2 ) The algorithm CNF(φ) hence consists of three steps: Remove every implication ( ) from φ (Algorithm IMPL FREE(φ)); Push every negation ( ) to literals (Algorithm NNF(φ)); Apply law of distribution (Algorithm CNF(φ)). Bow-Yaw Wang (Academia Sinica) Normal Forms of Propositional Logic September 12, 2017 12 / 22

Algorithm IMPL FREE(φ) Input: φ : a logic formula Output: φ : all implications ( ) in φ are removed and φ φ switch φ do case φ is a literal: do return φ; case φ is φ 1 : do return IMPL FREE(φ 1 ); case φ is φ 1 φ 2 : do return IMPL FREE(φ 1 ) IMPL FREE(φ 2 ); case φ is φ 1 φ 2 : do return IMPL FREE(φ 1 ) IMPL FREE(φ 2 ); case φ is φ 1 φ 2 : do return IMPL FREE( φ 1 φ 2 ); otherwise do assert(0); Algorithm 1: IMPL FREE(φ) Bow-Yaw Wang (Academia Sinica) Normal Forms of Propositional Logic September 12, 2017 13 / 22

Algorithm NNF(φ) Input: φ : a logic formula without implication ( ) Output: φ : only propositional atoms in φ are negated and φ φ switch φ do case φ is a literal: do return φ; case φ is φ 1 : do return NNF(φ 1 ); case φ is φ 1 φ 2 : do return NNF(φ 1 ) NNF(φ 2 ); case φ is φ 1 φ 2 : do return NNF(φ 1 ) NNF(φ 2 ); case φ is (φ 1 φ 2 ): do return NNF( φ 1 φ 2 ); case φ is (φ 1 φ 2 ): do return NNF( φ 1 φ 2 ); otherwise do assert(0); Algorithm 2: NNF(φ) Definition Let φ be a propositional logic formula. If only propositional atoms in φ are negated, φ is in negation normal form. Bow-Yaw Wang (Academia Sinica) Normal Forms of Propositional Logic September 12, 2017 14 / 22

Algorithm CNF(φ) Input: φ : an NNF formula without implication ( ) Output: φ : φ is in CNF and φ φ switch φ do case φ is a literal: do return φ; case φ is φ 1 φ 2 : do return CNF(φ 1 ) CNF(φ 2 ); case φ is φ 1 φ 2 : do return DISTR(CNF(φ 1 ), CNF(φ 2 )); Algorithm 3: CNF(φ) Input: η 1, η 2 : η 1, η 2 are in CNF Output: φ : φ is in CNF and φ η 1 η 2 if η 1 is η 11 η 12 then return DISTR(η 11, η 2 ) DISTR(η 12, η 2 ) ; else if η 2 is η 21 η 22 then return DISTR(η 1, η 21 ) DISTR(η 1, η 22 ) ; else return η 1 η 2 ; Algorithm 4: DISTR(η 1, η 2 ) Bow-Yaw Wang (Academia Sinica) Normal Forms of Propositional Logic September 12, 2017 15 / 22

Satisfiability of Propositional Logic Formulae Let φ be a propositional logic formula. Consider the following algorithm for checking its satisfiability. 1 Compute a CNF formula ψ such that ψ φ. 2 Check the validity of ψ. 3 Return φ is satisfiable if ψ is not valid; Return φ is not satisfiable if ψ is valid. Recall that satisfiability of propositional logic formulae is an NP-complete problem. Is the above algorithm in polynomial time? Why? Bow-Yaw Wang (Academia Sinica) Normal Forms of Propositional Logic September 12, 2017 16 / 22

Outline 1 Normal Forms Semantic equivalence, satisfiability, and validity Conjunctive normals forms and validity Horn clauses and satisfiability Bow-Yaw Wang (Academia Sinica) Normal Forms of Propositional Logic September 12, 2017 17 / 22

Horn Clauses Given a propositional logic formula in CNF, it is easy to check its validity; it is hard to check its satisfiability. We will consider a subclass of CNF formulae whose satisfiability can be checked efficiently. Definition A Horn formula is a propositional logic formula φ of the following form: P = p A = P P A C = A P H = C C H. A clause of the form C is called a Horn clause. Example: (p q s ) (q r p) ( s) Nonexample: (p q s ) (q r p s) (p r s) Bow-Yaw Wang (Academia Sinica) Normal Forms of Propositional Logic September 12, 2017 18 / 22

Satisfiability of Horn Formulae Consider a Horn clause P 1 P 2 P n Q. If P 1, P 2,..., P n are assigned to T, then Q must be T; otherwise, Q can be an arbitrary truth value. We hence have the following (informal) algorithm: 1 Mark if it occurs in the Horn formula φ; 2 If there is a Horn clause P 1 P 2 P n Q in φ such that all P j for 1 j n are marked, mark Q; 3 If is marked, print The Horn formula φ is unsatisfiable. 4 Print The Horn formula φ is satisfiable. Bow-Yaw Wang (Academia Sinica) Normal Forms of Propositional Logic September 12, 2017 19 / 22

Algorithm Horn(φ) Input: φ: φ is a Horn formula Output: unsatisfiable if φ is unsatisfiable; otherwise satisfiable. mark all occurrences of in φ; while there is a Horn clause P 1 P 2 P n Q in φ such that P j are all marked but Q is not do mark Q; if is marked then return unsatisfiable ; else return satisfiable ; Algorithm 5: Horn(φ) Bow-Yaw Wang (Academia Sinica) Normal Forms of Propositional Logic September 12, 2017 20 / 22

Satisfiability of Horn Formulae Theorem Let φ be a Horn formula with n propositional atoms. Horn(φ) runs at most n + 1 iterations and decides the satisfiability of φ correctly. Proof. At each iteration, an unmarked atom will be marked. Since there are n atoms, there are at most n + 1 iterations. By induction on the number of iterations, we show that all marked P are true for all valuations where φ evaluates to T. At iteration 0 (before entering the loop), only are marked. Clearly, must be true for any valuation. At iteration k + 1, consider a Horn clause P 1 P 2 P n Q where P 1, P 2,..., P n are marked but not Q. For a valuation ν where φ evaluates to T, P 1 P 2 P n Q must evaluate to T. Since P 1, P 2,..., P n are true in ν (by IH), Q must be true in ν. Bow-Yaw Wang (Academia Sinica) Normal Forms of Propositional Logic September 12, 2017 21 / 22

Satisfiability of Horn Formulae Proof (cont d). We now prove Horn(φ) answers correctly. When Horn(φ) returns unsatisfiable, there is a Horn clause P 1 P 2 P n where P 1, P 2,..., P n are all marked. Suppose ν is a valuation where φ evaluates to T. Then P 1, P 2,..., P n must be true in ν. Hence P 1 P 2 P n evaluates to F. φ cannot evaluate to T under ν. A contradiction. When Horn(φ) returns satisfiable, define a valuation ν where all marked propositional atoms are assigned to T and all unmarked atoms are F. We claim φ evaluates to T in ν. Suppose not. There is a Horn clause P 1 P 2 P n Q in φ which evaluates to F under ν. That is, P 1, P 2,..., P n are T but Q is F under ν. By the definition of ν, P 1, P 2,..., P n are marked by the algorithm. Hence Q must also be marked by the algorithm. Q cannot be F in ν. A contradiction. Bow-Yaw Wang (Academia Sinica) Normal Forms of Propositional Logic September 12, 2017 22 / 22