Computational Logic Chapter 2. Propositional Logic

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

Linear-time Temporal Logic

Propositional Logic Language

Chapter 7 R&N ICS 271 Fall 2017 Kalev Kask

LOGIC PROPOSITIONAL REASONING

COMP219: Artificial Intelligence. Lecture 20: Propositional Reasoning

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

Part 1: Propositional Logic

Advanced Topics in LP and FP

Deductive Systems. Lecture - 3

Propositional Logic: Models and Proofs

Propositional Logic: Evaluating the Formulas

3 Propositional Logic

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

Propositional Logic. Logic. Propositional Logic Syntax. Propositional Logic

Propositional Reasoning

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

Intelligent Agents. Pınar Yolum Utrecht University

Introduction to Artificial Intelligence. Logical Agents

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

Logical Agents. Chapter 7

7. Propositional Logic. Wolfram Burgard and Bernhard Nebel

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

6. Logical Inference

CS156: The Calculus of Computation

Logic and Inferences

Propositional logic. Programming and Modal Logic

Natural Deduction for Propositional Logic

Logical agents. Chapter 7. Chapter 7 1

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

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

CS 380: ARTIFICIAL INTELLIGENCE

Logic: Propositional Logic (Part I)

Propositional Logic: Deductive Proof & Natural Deduction Part 1

Comp487/587 - Boolean Formulas

Inference in Propositional Logic

Foundations of Artificial Intelligence

Lecture 11: Measuring the Complexity of Proofs

Propositional Logic: Methods of Proof (Part II)

Propositional logic (revision) & semantic entailment. p. 1/34

Language of Propositional Logic

15414/614 Optional Lecture 1: Propositional Logic

Propositional logic. Programming and Modal Logic

Proof Methods for Propositional Logic

A brief introduction to Logic. (slides from

CS:4420 Artificial Intelligence

Foundations of Artificial Intelligence

Foundations of Artificial Intelligence

Kecerdasan Buatan M. Ali Fauzi

Propositional Logic Sequent Calculus

Artificial Intelligence Chapter 7: Logical Agents

Logical agents. Chapter 7. Chapter 7 1

Chapter 3: Propositional Calculus: Deductive Systems. September 19, 2008

02 Propositional Logic

Propositional Logic: Methods of Proof (Part II)

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

Přednáška 12. Důkazové kalkuly Kalkul Hilbertova typu. 11/29/2006 Hilbertův kalkul 1

Logic in AI Chapter 7. Mausam (Based on slides of Dan Weld, Stuart Russell, Subbarao Kambhampati, Dieter Fox, Henry Kautz )

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

COMP9414: Artificial Intelligence Propositional Logic: Automated Reasoning

TDT4136 Logic and Reasoning Systems

Foundations of Artificial Intelligence

Marie Duží

Logical Agents. Outline

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

Classical Propositional Logic

Formal Verification Methods 1: Propositional Logic

Propositional and Predicate Logic - V

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

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

Logic for Computer Science - Week 4 Natural Deduction

Inference Methods In Propositional Logic

Logical Agent & Propositional Logic

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

Part 1: Propositional Logic

Artificial Intelligence

Propositional logic II.

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

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

Deliberative Agents Knowledge Representation I. Deliberative Agents

Logic. proof and truth syntacs and semantics. Peter Antal

Logical Agents (I) Instructor: Tsung-Che Chiang

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

Lecture 2 Propositional Logic & SAT

Tecniche di Verifica. Introduction to Propositional Logic

Conjunctive Normal Form and SAT

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

Lecture 1: Logical Foundations

Class Assignment Strategies

ECE473 Lecture 15: Propositional Logic

Propositional Logic Part 1

Classical Propositional Logic

Logical Agents. Chapter 7

On the Complexity of the Reflected Logic of Proofs

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

CHAPTER 10. Gentzen Style Proof Systems for Classical Logic

Conjunctive Normal Form and SAT

Inference Methods In Propositional Logic

Propositional Logic: Methods of Proof (Part II)

Conjunctive Normal Form and SAT

Transcription:

Computational Logic Chapter 2. Propositional Logic Pedro Cabalar Dept. Computer Science University of Corunna, SPAIN December 14, 2010 P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 1 / 64

Outline 1 Syntax and Semantics 2 Semantic proof 3 Syntactic proof Hilbert s Axiomatic Method Gnetzen s Natural Deduction Gentzen s Sequent Calculus P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 2 / 64

Syntax and Semantics 1 Syntax and Semantics 2 Semantic proof 3 Syntactic proof Hilbert s Axiomatic Method Gnetzen s Natural Deduction Gentzen s Sequent Calculus P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 3 / 64

Syntax and Semantics Syntax Def. Propositional Signature Σ: set of propositions or atoms. E.g. Σ = {p, q, r, s}. Def. Propositional language L Σ, set of well formed formulae (wff). Any of the expressions: i) vi) α β ii) vii) α β iii) p viii) α β iv) α ix) α β v) (α) wtih p Σ y α, β L Σ. Precedence:,,,, (left associative). Alternative notations: implication,, ; equivalence, =,, Def. theory: is a set of formulae Γ L Σ. P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 4 / 64

Semantics Syntax and Semantics Def. interpretation is a function I : Σ {T, F} We can also use I Σ so that, for instance, I = {p, r} means I(p) = T, I(q) = F, I(r) = T, etc. We extend its use I : L Σ {T, F}. I(α) = replace each p Σ in α by I(p) and apply: I( ) = T I( ) = F T F F T F F F F T T F T F T T F T F F T F F T T T T T T P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 5 / 64

Semantics Syntax and Semantics Def. I satisfies α, written I = α, iffi(α) = T. i) I = T and I = F. ii) I = p iff I(p) = T. iii) I = α iff I = α. iv) I = α β iff I = α and I = β. v) I = α β iff I = α or I = β (or both). vi) I = α β iff (I = α iff I = β). I is a model of Γ, written I = Γ, iff it satisfies all its formulae. Def. inconsistency or unsatisfiable formula: a formula that has no models. Def. α is a tautology or is valid iff any interpretation is a model of α. Examples: T, p p, b c d (d b) α is a logical consequence of or is entailed by Γ, written Γ = α, iff any model of Γ satisfies α. Therefore, when Γ =, what does = α mean? P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 6 / 64

Syntax and Semantics Semantics Alternative viewpoint: think about the set of models of a given formula α, call it M(α). M( ) = M( ) = S (all the possible ones) M(a b) = {{a, b}, {a}, {b}} We will usually identify α with M(α) and vice versa. From a set S of interpretations: How can we get a formula α s.t. M(α) = S? Does this formula α always exist? How many theories (modulo equivalence) can we build with n atoms? P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 7 / 64

Semantics Syntax and Semantics Definition (Weaker/stronger formula) If = α β, that is, if M(α) M(β), then α is stronger than β (or β is weaker α). Which are the strongest and weakest possible formulae? Examples: p p q p p q p q p q p (q p) p q p q. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 8 / 64

Syntax and Semantics From human to formal language... A B A B A B A B A implies B A is a sufficient condition for B B is a necessary condition for A if A then B B if A A only if B no A unless B B given that A B provided that A A is equivalent to B A if and only if (iff) B A or B (inclusive or) A or B (exclusive or) P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 9 / 64

Syntax and Semantics Del lenguaje humano al formal... A B A B A B A B A implica B A es suficiente para B B es necesario para A si A entonces B B si A A sólo si B no A a no ser que B no A a menos que B B siempre que A A equivale a B A si y sólo si B A ó B (inclusivo) A ó B (exclusivo) P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 10 / 64

Propositional Logic Syntax and Semantics Nice but... can you really do anything practical using propositional logic? You can explain in a simple way most fundamental concepts of the different existing logics. We will focus on this next, but also... SAT problem: decide whether a propositional formula has at least one model. It is an NP-complete problem. Furthermore, it was the first problem identified problem in this class, and crucial for proving that other problems belong to it. SAT keypoint: instead of designing an ad hoc search algorithm, encode the problem into propositional logic and use SAT as a backend. Nowadays, SAT is an outstanding state-of-the-art research area for search algorithms. There exist many efficient tools and commercial applications. See www.satlive.com. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 11 / 64

Syntax and Semantics Small Remark on Complexity 0 0 0 0 1 A B 2 0 0...... q 4 A Turing Machine (TM) is a theoretical device that operates on an infinite tape with cells containing symbols in a finite alphabet (including the blank or 0 ) The TM has a current state S i among a finite set of states (including Halt ), and a head pointing to the current cell in the tape. It has an associated transition function that describes the next step. P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 12 / 64

Syntax and Semantics Small Remark on Complexity Example: with scanned symbol 0 and state q 4, write 1, move Left and go to state q 2. That is: 0 0 0 0 1 A B 2 0 0...... q 4 0 t(0, q 4 ) = (1, Left, q 2 ) 0 0 1 1 A B 2 0 0...... q 2. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 13 / 64

Syntax and Semantics Small Remark on Complexity A decision problem consists in providing a given tape input and asking the Turing Machine for a final output symbol answering Yes or No. Example: SAT = given (an encoding of) a propositional formula, does it have at least one model? A decision problem is in complexity class P iff the number of steps carried out by the TM is polynomial on the size n of the input.. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 14 / 64

Syntax and Semantics Small Remark on Complexity Now, a non-deterministic Turing Machine (NDTM) is such that the transition function is replaced by a transition relation. We may have different possibilities for the next step. Example: t(0, q 4, 1, Left, q 2 ), t(0, q 4, 0, Right, q 3 ) 0 0 0 0 1 A B 2 0 0...... q 4 0 0 0 1 1 A B 2 0 0...... 0 0 0 0 1 A B 2 0 0..... q 2 q 3 P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 15 / 64

Syntax and Semantics Small Remark on Complexity Keypoint: an NDTM provides an affirmative answer to a decision problem when at least one of the executions for the same input answers Yes. A decision problem is in class NP iff the number of steps carried out by the NDTM is polynomial on the size n of the input. For SAT, we can build an NDTM that performs two steps: 1 For each atom, generate 1 or 0 nondeterministically. This provides an arbitrary interpretation in linear time. 2 Test whether the current interpretation is a model or not. The sequence of these two steps takes polynomial time. P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 16 / 64

Syntax and Semantics Small Remark on Complexity Unsolved problem P? = NP The most accepted conjecture is that P NP. But remains unproved. It is one of the 7 Millenium Prize Problems http://www.claymath.org/millennium/p_vs_np/ The Clay Mathematics Institute designated $1 million prize for its solution!. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 17 / 64

Syntax and Semantics Small Remark on Complexity A problem X is C-complete, for some complexity class C, iff any problem Y in C is reducible to X in polynomial-time. A complete problem is a representative of the class. Example: if an NP-complete problem happened to be in P then P = NP. SAT was the first problem to be identified as NP-complete (Cook s theorem, 1971). SAT is commonly used nowadays for showing that a problem X is at least as complex as NP. To this aim, just encode SAT into X. P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 18 / 64

Syntax and Semantics Exercise Programming the satisfaction relation = in Prolog: :- op(210, yfx, &). :- op(220, yfx, v). :- op(1060, yfx, <->). sat(_i, false) :-!, fail. sat(_i, true) :-!. sat(i, P) :- atom(p),!,member(p,i),!. sat(i, -A) :- \+ sat(i, A). sat(i, A & B) :- sat(i, A), sat(i, B). sat(i, A v B) :- sat(i,a),! ; sat(i, B). sat(i, A -> B) :- sat(i,-a v B). sat(i, A <-> B) :- sat(i,(a -> B)&(B -> A)). P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 19 / 64

Syntax and Semantics Exercise Testing whether a formula is a tautology: tautology(s, F) :- \+ (subset(s,i), \+ sat(i,f)). subset([],[]) :-!. subset([x Xs],S) :- subset(xs,s). subset([x Xs],[X S]) :- subset(xs,s). P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 20 / 64

Syntax and Semantics Using propositional logic: an example From Lady or the Tiger? And Other Logic Puzzles Including a Mathematical Novel That Features Godel s Great Discovery (Raymond M. Smullyan) Behind each door we may have either a lady or a tiger. One sign tells the truth but the other one no. Which door shall we open? 1. A lady is in this room and a tiger is in the other 2. There is a lady in one room and a tiger in the other P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 21 / 64

Another variation Syntax and Semantics There are one lady and two tigers. At most, one sign tells the truth. Which door shall we open? 1. There is a tiger in this room 2. There is a lady in this room 3. There is a tiger in room 2 P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 22 / 64

Semantic proof 1 Syntax and Semantics 2 Semantic proof 3 Syntactic proof Hilbert s Axiomatic Method Gnetzen s Natural Deduction Gentzen s Sequent Calculus P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 23 / 64

Semantic proof Semantic proof How can you know whether = α? direct option: try with all possible interpretations. The truth table Example: α = b c d (d b) b c d b c d d b α F F F F T T F F T F F T F T F F T T F T T F F T T F F F T T T F T F T T T T F F T T T T T T T T. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 24 / 64

Semantic proof Semantic Proof The truth table is brute force: 2 n interpretations. Unfeasible as a practical method but... in the worst case that complexity can t be avoided! Semantic Tableaux: between semantic and syntactic method. Goal: prove whether a formula is inconsistent Can be easily automatized Well behaved when α has a low connective (operator) nesting degree It is frequently used in modal logics (mainly, to guarantee its decidability). We define a literal as any atom p or its negation p.. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 25 / 64

Semantic tableaux Semantic proof Unfolding rules: Formula Branch 1 Branch 2 α β α β α β α, β (α β) α, β (α β) α β α β α β (α β) α, β α β α, β α, β (α β) α, β α, β α α P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 26 / 64

Semantic proof Semantic tableaux To know whether = α we build a tree with α in its root. We expand the tree applying all the possible unfoldings. How would the leaves look like? They ll just contain literals. If a tree path contains both p and p we say that the path is closed. The root is inconsistent iff all the paths in the tree are closed. Additional advantages: An open branch points out a counterexample. The resulting formula is in Disjunctive Normal Form (DNF). The literals in each branch from a clause. Try with the examples: p (p q) p, (p q) (p q p), (p q) p q. P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 27 / 64

Exercise Semantic proof Prolog program :- op(210, yfx, &). :- op(220, yfx, v). :- op(1060, yfx, <->). valid(f) :- openbranch([-f],[],m),!, write(m),nl,fail. valid(_). openbranch(_fs,ls,_m) :- member(-x,ls), member(x,ls),!,fail. openbranch([f Fs],Lits,M) :- unfold(f,gs),!, member(g,gs), append(g,fs,hs), openbranch(hs,lits,m),! ; openbranch(fs,[f Lits],M). openbranch([],lits,lits). P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 28 / 64

Semantic proof Exercise Prolog program unfold( - - A, [ [A] ]). unfold( A & B, [ [A,B] ]). unfold( -(A v B), [ [-A,-B] ]). unfold( A v B, [ [A], [B] ]). unfold( -(A & B), [ [-A], [-B] ]). unfold( (A -> B), [ [-A], [B] ]). unfold(-(a -> B), [ [A,-B] ]). unfold((a <-> B), [ [A,B],[-A,-B] ]). unfold(-(a <-> B), [ [A,-B],[-A,B] ]). P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 29 / 64

Syntactic proof 1 Syntax and Semantics 2 Semantic proof 3 Syntactic proof Hilbert s Axiomatic Method Gnetzen s Natural Deduction Gentzen s Sequent Calculus P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 30 / 64

Inference Methods Syntactic proof Inference or formal proof: we make syntactic manipulation of formulae. To do so, we use: An initial set of formulae: axioms. Syntactic manipulation rules: inference rules. As a result of applying these rules, we go obtaining new formulae: theorems Best known proof methods: Axiomatic Method (Hilbert) Resolution Natural Deduction / Sequent Calculus (Gentzen) P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 31 / 64

Syntactic proof Inference methods Notation: Γ α means that formula α can be derived or inferred from theory Γ. Usually, axioms are not represented inside Γ. Thus, α means that α is a theorem (from logic L). Given a language L, a logic L is a subset of L. It can be defined: Semantically: L = {α L = α}. Syntactically: L = {α L α}. What should we expect from an inference method? Soundness (or correctness): if α then = α Completeness: if = α then α All methods we ll see for classical propositional calculus are sound and complete. P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 32 / 64

Syntactic proof Hilbert s Axiomatic Method Hilbert s Axiomatic Method Put the emphasis on the set of axioms. The simplest axiomatisation (Jan Łukasziewick) just uses these 3 axioms: α (β α) (α (β γ)) ((α β) (α γ)) ( α β) (β α) plus the inference rule of Modus Ponens {α, α β} β. Uncomfortable for direct use. P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 34 / 64

Syntactic proof Hilbert s Axiomatic Method Hilbert s Axiomatic Method Example: prove that p p is a theorem. α (β α) (1) (α (β γ)) ((α β) (α γ)) (2) ( α β) (β α) (3) 1. p ((p p) p) (1) 2. (p ((p p) p)) (p (p p)) (p p)) (2) 3. (p (p p)) (p p) MP 1, 2 4. p (p p) (1) 5. p p MP3, 4 P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 35 / 64

Syntactic proof Hilbert s Axiomatic Method Hilbert s Axiomatic Method Normally, we handle other derived axioms and inference rules. Examples: Modus tollens { β, α β} α, Hypothetical Syllogism {α β, β γ} α γ,... Deduction (meta)theorem: if Γ {α} β then Γ α β. (The opposite also holds).. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 36 / 64

Resolution Syntactic proof Hilbert s Axiomatic Method Allows deciding whether α is inconsistent. As a first step, we obtain an equivalent conjunctive normal form (CNF) representation. CNF is a conjunction of disjunctions of literals. Each disjunction is called a clause. To get CNF: (1) replace, by their definitions in terms of,, ; (2) move la negation until only applied to atoms (Negation Normal Form, NNF); (3) apply distributivity,. See PROLOG example. Warning: transformation into CNF may have an exponential cost.. Example (a b) (c d) (e f ) (h i) Some techniques [Egly96] allow generating a CNF in polynomial time but introducing new auxiliary atoms. P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 37 / 64

Syntactic proof Hilbert s Axiomatic Method Example: we first describe how to get the NNF :- op(210, yfx, &). :- op(220, yfx, v). nnf(-(a & B),NA v NB):-!,nnf(-A,NA),nnf(-B,NB). nnf(-(a v B),NA & NB):-!,nnf(-A,NA),nnf(-B,NB). nnf(-(a -> B), A1 & NB):-!,nnf(A,A1),nnf(-B,NB). nnf(- - A,A1):-!,nnf(A,A1). nnf(a,a). P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 38 / 64

Syntactic proof Hilbert s Axiomatic Method... and then the CNF cnf(a -> B,Zs):-!, cnf(-a v B,Zs). cnf(a & B,Zs):-!, cnf(a,xs),cnf(b,ys), merge_set(xs,ys,zs). cnf(a v B,Zs):-!, cnf(a,xs),cnf(b,ys), findall(z, (member(x,xs),member(y,ys), merge_set(x,y,z) ), Zs). cnf(a,[ [A] ]). P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 39 / 64

Resolution Syntactic proof Hilbert s Axiomatic Method The resolution rule is defined as: {α p, β p} α β The resulting clause α β is called the resolvent. An empty disjunction (or empty clause) corresponds to. Main result [Robinson65]: α is unsatisfiable iff there exists a derivation of from CNF[α] applying resolution. P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 40 / 64

Resolution Syntactic proof Hilbert s Axiomatic Method Example: prove that α : ( p q) (q r) ( r p) is a theorem. We first negate the formula and get its CNF ( ( p q) (q r) ( r p) ) ( (( p q) ( q r)) ( r p) ) ((p q) ( q r)) (r p) (p q) ( q r) }{{}}{{}}{{} r p }{{} C 1 C C 2 3 C 4. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 41 / 64

Resolution Syntactic proof Hilbert s Axiomatic Method A possible application of resolution... C 1 : p q C 2 : q r C 5 : p r C 3 : r C 6 : p C 4 : p C 7 : P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 42 / 64

Syntactic proof Hilbert s Axiomatic Method Resolution Problem: generating all possible resolvents is unfeasible. Important: heuristics to explore only a part of the search tree. Small optimisations... Removing tautologies: p p α Subsumption: seeing clauses as sets of literals, if C 1 C 2 we say that C 1 subsumes C 2 and we can remove the latter. Pure literals: a literal is pure iff its complement does not occur in any clause. A pure literals does not affect satisfiability: we can arbitrarily fix a truth value for its associated atom. Unit propagation: a unit clause is such that it just contains one literal. Its atom has a fixed truth value which can be simplified in the rest of clauses.. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 43 / 64

Resolution Syntactic proof Hilbert s Axiomatic Method Davis-Putnam: choose some atom p and apply resolution on it in all possible ways. The resulting set of clauses will not contain atom p any more. Davis-Putnam-Logemann-Loveland (DPLL): backtracking on an atom value (assume first true and then backtrack to false). Used by most SAT provers. P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 44 / 64

Resolution: strategies Syntactic proof Hilbert s Axiomatic Method Linear Resolution: in each application, one of the clauses must be the last obtained resolvent. If α is unsatisfiable, there exists some clause C in CNF(α) such that we can derive from C exclusively using linear resolution. Input Resolution: we always use one of the original clause in CNF (α) (it is not a complete method). Unit resolution: we always use a unit clause (it is not complete).. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 45 / 64

Resolution: strategies Syntactic proof Hilbert s Axiomatic Method Set of support: fix some S CNF (α) s.t. CNF(α) \ S is satisfiable. Typical example: we want to know whether γ follows from β, while we know β consistent. That is: β γ inconsistent? When negated CNF(β) CNF( γ). }{{} support Resolution with set of support S: we use at least one clause C S. It is a complete methods. P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 46 / 64

Resolution Syntactic proof Hilbert s Axiomatic Method Horn clause: it contains at most one positive literal. It s the basis for Prolog. We can see each Horn clause as a rule: p q 1 q 2 q 3 p q 1 q 2 q 3 p:- q 1, q 2, q 3. (a rule) p (a fact) q 1 q 2 q 3 q 1 q 2 q 3?- q 1, q 2, q 3. (the goal or query) P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 47 / 64

Resolution Syntactic proof Hilbert s Axiomatic Method If CNF (α) exclusively contains Horn clauses, deciding its satisfiability (HORNSAT) is a polynomial problem (in fact, P-complete). Unit, input and linear strategies are all complete for Horn clauses. Furthermore, the set of negative clauses (goals) can be used as a set of support. P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 48 / 64

Natural Deduction Syntactic proof Gnetzen s Natural Deduction We reason about judgements like Γ α. No axioms. Instead, several inference rules per each connective. We have rules for connective introduction: α β α β I α α β I1 β α β I2 and elimination: α β α E1 α β β E2 α α E α α β β E a.k.a. Modus Ponens. P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 50 / 64

Natural Deduction Syntactic proof Gnetzen s Natural Deduction Simple example: prove that {A B} B A. A B A B B E2 A B A E1 I Another example {P Q R, Q P, Q} R 1. P Q R premise 2. Q P premise 3. Q premise 4. P E on 2, 3 5. P Q I on 4, 3 6. R E on 5, 1 P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 51 / 64

Natural Deduction Syntactic proof Gnetzen s Natural Deduction Other rules use hypothetical reasoning: they use derivations α β as conditions of an inference rule. α β α β I α β α γ γ β γ E α β β respectively called conditional reasoning, reasoning by cases and Reductio Ad Absurdum. For their application, we introduce hypotheses: these are local w.r.t. a given subderivation. α I. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 52 / 64

Natural Deduction Syntactic proof Gnetzen s Natural Deduction Example : {P (Q R)} Q (P R). 1 P (Q R) 2 Q 3 P 4 Q R E, 1, 3 5 R E, 4, 2 6 P R I, 3 5 7 Q (P R) I, 2 6 P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 53 / 64

Sequent Calculus Syntactic proof Gentzen s Sequent Calculus Instead of handling formulae, we transform expressions (judgements) like Γ that become metalanguage objects. Γ and are sets of formulae: intuitively Γ represents a conjunction of its elements and a disjunction. Created by Gentzen to prove properties of Natural Deduction. Very useful for Type Theory; it also allows a nice characterisation of Intuitionistic Logic. We have one axiom and rules that work on the left (L) or the right (R) side of plus logical and structural rules.. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 55 / 64

Sequent Calculus Syntactic proof Gentzen s Sequent Calculus Rules: Γ, α, α (ax) Γ, α α, Γ Γ, Γ, (cut) Logical rules: Γ, α Γ, α β L 1 Γ, β Γ, α β L 2 Γ α, Γ α β, R 1 Γ β, Γ α β, R 2 P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 56 / 64

Sequent Calculus Syntactic proof Gentzen s Sequent Calculus More logical rules: Γ, α Γ, β Γ, Γ, α β, L Γ α, Γ, β Γ, Γ, α β, L Γ α, Γ β, Γ, Γ α β,, R Γ, α Γ β, Γ, Γ α β,, R Γ α, Γ, α L Γ, α Γ α, R P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 57 / 64

Sequent Calculus Syntactic proof Gentzen s Sequent Calculus Structural rules (Weakening, Contraction, Permutation): Γ Γ, α WL Γ Γ α, WR Γ, α, α Γ, α CL Γ α, α, Γ α, Γ, α, β Γ, β, α PL Γ α, β, Γ β, α, CR PR P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 58 / 64

Sequent Calculus Syntactic proof Gentzen s Sequent Calculus Example A A (tertium non datur): P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 59 / 64

Sequent Calculus Syntactic proof Gentzen s Sequent Calculus A proof is said to be analytical iff it doesn t make use of cut. Main Theorem (Hauptsatz) cut elimination: any judgement with a non-analytical proof, also has an analytical one. Still, in the general case, an analytical sequent calculus can be exponentially worse in proving some sequents than an equivalent one allowing cut.. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 60 / 64

Sequent Calculus Syntactic proof Gentzen s Sequent Calculus Another example { A B} (A B): A A A, A A B, A B B B, B A B, B A B, A B A B (A B) P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 61 / 64

Syntactic proof Sequent Calculus vs Tableaux Gentzen s Sequent Calculus Any analytical cut-free sequent calculus has a dual tableaux method. Idea: reverse the sequent proof from bottom to top. This can be seen as a tableau tree. Given Γ we think about its refutation. We define an associated set Γ, i.e., Γ { α α }. Different judgements may have the same associated set: both A B and A, B are associated to { A, B}. To obtain the tableaux, take the sequent proof, replace judgements by associated sets, and reverse the diagram. P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 62 / 64

Syntactic proof Sequent Calculus vs Tableaux Gentzen s Sequent Calculus Example becomes what?... A A A, A A B, A B B B, B A B, B A B, A B A B (A B) A B, (A B) A B, A B A B, A A B, B A, A B, B. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 63 / 64

Syntactic proof Sequent Calculus vs Tableaux Gentzen s Sequent Calculus There exist non-analytical tableaux systems, counterpart of non-analytical sequent calculi. They don t satisfy the subformula property, i.e., each node in the tableaux need not be a subformula of the root. P. Cabalar ( Dept. Ch2. Computer Propositional ScienceLogic University of Corunna, SPAIN December ) 14, 2010 64 / 64