Resolution and Refutation

Similar documents
Logic Programming in Prolog Part II Substitutions, SLD Resolution Prolog Execution. Raj Sunderraman

Chapter 3. SLD-Resolution. 3.1 Informal Introduction

Deductive Systems. Lecture - 3

Convert to clause form:

Definite Logic Programs: Derivation and Proof Trees. CSE 505 Computing with Logic Stony Brook University

Top-Down Execution CS240B Notes

Propositional and Predicate Logic - V

Strong AI vs. Weak AI Automated Reasoning

Foundations of Logic Programming

Propositional Logic: Models and Proofs

COMP9414: Artificial Intelligence First-Order Logic

Logic. Knowledge Representation & Reasoning Mechanisms. Logic. Propositional Logic Predicate Logic (predicate Calculus) Automated Reasoning

Prolog. Resolution (for beginners?) Resolution (cont.) Resolution (cont.) Unification. Resolution (still cont.) Resolution & Unification

COMP9414: Artificial Intelligence Propositional Logic: Automated Reasoning

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

cse 311: foundations of computing Fall 2015 Lecture 6: Predicate Logic, Logical Inference

Propositional Logic. Logic. Propositional Logic Syntax. Propositional Logic

First-Order Logic. Resolution

Resolution for Predicate Logic

Advanced Topics in LP and FP

Computational Logic Automated Deduction Fundamentals

Resolution: Motivation

Closed Book Examination. Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. M.Sc. in Advanced Computer Science

1 Introduction to Predicate Resolution

Propositional Resolution Introduction

Predicate Logic: Syntax

Logic and Inferences

Logic and Resolution Representation and Reasoning

Lecture 10: Even more on predicate logic" Prerequisites for lifted inference: Skolemization and Unification" Inference in predicate logic"

Computational Logic Fundamentals (of Definite Programs): Syntax and Semantics

Inf2D 13: Resolution-Based Inference

Logic as a Tool Chapter 4: Deductive Reasoning in First-Order Logic 4.4 Prenex normal form. Skolemization. Clausal form.

3. The Logic of Quantified Statements Summary. Aaron Tan August 2017

CS2742 midterm test 2 study sheet. Boolean circuits: Predicate logic:

Propositional Reasoning

173 Logic and Prolog 2013 With Answers and FFQ

Propositional Logic: Bottom-Up Proofs

Exercises 1 - Solutions

Propositional Logic: Review

Propositional and First-Order Logic

CS 4700: Artificial Intelligence

α-formulas β-formulas

6. Logical Inference

CS 730/830: Intro AI. 3 handouts: slides, asst 6, asst 7. Wheeler Ruml (UNH) Lecture 12, CS / 16. Reasoning.

Handout Proof Methods in Computer Science

AI Programming CS S-09 Knowledge Representation

6.825 Techniques in Artificial Intelligence. Logic Miscellanea. Completeness and Incompleteness Equality Paramodulation

Outline. Logic. Definition. Theorem (Gödel s Completeness Theorem) Summary of Previous Week. Undecidability. Unification

CSC242: Intro to AI. Lecture 11. Tuesday, February 26, 13

MATH 501: Discrete Mathematics

Computational Logic. Recall of First-Order Logic. Damiano Zanardini

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

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

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

Artificial Intelligence: Methods and Applications Lecture 3: Review of FOPL

Logical reasoning - Can we formalise our thought processes?

Artificial Intelligence Chapter 9: Inference in First-Order Logic

Part I: Propositional Calculus

Chapter 7. Negation: Declarative Interpretation

Logic (3A) Young W. Lim 12/5/13

Logic: Propositional Logic (Part I)

Inference in first-order logic

Proof Methods for Propositional Logic

CogSysI Lecture 8: Automated Theorem Proving

Advanced DB CHAPTER 5 DATALOG

CS 380: ARTIFICIAL INTELLIGENCE

Lecture Notes in Machine Learning Chapter 3: Languages for learning

First-Order Logic (FOL)

Introduction to Logic in Computer Science: Autumn 2007

Syntax of FOL. Introduction to Logic in Computer Science: Autumn Tableaux for First-order Logic. Syntax of FOL (2)

Inference Methods In Propositional Logic

Announcements. Project 1 underway... Second midterm Friday. discuss ideas with TAs check out wiki

Predicate Logic - Semantic Tableau

An Early (1971) Conversation. Logic Programming (PLP 11.3) Horn Clauses Introduction to Prolog: Resolution, Unification.

Logical Agent & Propositional Logic

ILP = Logic, CS, ML Stop counting, start reasoning

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

Comp487/587 - Boolean Formulas

Knowledge Representation, Reasoning, and Planning

CPSC 121: Models of Computation. Module 6: Rewriting predicate logic statements

Resolution for Predicate Logic

To every formula scheme there corresponds a property of R. This relationship helps one to understand the logic being studied.

Logic and Reasoning. Foundations of Computing Science. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

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

Artificial Intelligence Chapter 7: Logical Agents

Preliminaries. Introduction to EF-games. Inexpressivity results for first-order logic. Normal forms for first-order logic

Version January Please send comments and corrections to

Logical Agent & Propositional Logic

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

Inference in first-order logic

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

Logical Agents (I) Instructor: Tsung-Che Chiang

Inference Methods In Propositional Logic

Propositional Resolution

CSC384: Intro to Artificial Intelligence Knowledge Representation II. Required Readings: 9.1, 9.2, and 9.5 Announcements:

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

Definite Logic Programs

Inference in first-order logic

7.5.2 Proof by Resolution

COMP4418: Knowledge Representation and Reasoning First-Order Logic

Transcription:

Resolution and Refutation York University Department of Computer Science and Engineering York University- CSE 3401- V. Movahedi 04_Resolution 1

Propositional Logic Resolution Refutation Predicate Logic Substitution Unification Resolution Refutation Search space Overview [ref. Nilsson- Chap.3] [Prof. Zbigniew Stachniak s class notes] 2

Theorems from Logic [from Mathematical Logic, George Tourlakis] Modus Ponens Cut Rule Transitivity of Proof by Contradiction 3

By A. Robinson (1965) Example Prove Resolution in Logic We need to show that the following set is inconsistent 4

Resolution in Logic Programming Program P (facts and rules in clause form) Goal G negated and added to program P To prove G, we need to show Complementary literals P { G} is inconsistent q; t - p., p- s. Parent clauses Resolving upon p, being on different sides of - q; t - s. Resolvent 5

Program P={q-., p-q.} Example (1) Query -p. This is already the negated form of our goal! q-. p- q. -p. -q. - empty clause, inconsistency therefore p is satisfiable true 6

Refutation When resolution is used to prove inconsistency, it is also called refutation. (refute=disprove) The above binary tree, showing resolution and resulting in the empty clause, is called a refutation tree. NOTE To avoid potential mistakes, DO NOT RESOLVE UPON MORE THAN ONE LITERAL SIMULTANEOUSLY. 7

Example (2) A1. If Henry has two days off, then if the weather is bad, Henry is not fishing. A2. if Henry is not fishing and is not drinking in a pub with his friends, then he is watching TV at home. A3. If Henry is working, then he is neither drinking in a pub with his friends nor watching TV at home. Q. If Henry is not watching TV at home and he has two days off, then he is drinking in a pub with his friends provided that the weather is bad. 8

Example (2) (cont.) From logical point of view, we want to prove Q, given A1, A2, A3. { A 1, A2, A3} Q. By refutation principle, the consistency of is examined. C { A1, A2, A3} { Q} Step 1 Represent as propositional formulas Step 2 Represent as clauses Step 3 Determine the consistency of C If C is consistent, answer NO (false) If C is inconsistent, answer YES (true) 9

Example (2) (cont.) A1. If Henry has two days off, then if the weather is bad, Henry is not fishing. A2. if Henry is not fishing and is not drinking in a pub with his friends, then he is watching TV at home. A3. If Henry is working, then he is neither drinking in a pub with his friends nor watching TV at home. Q. If Henry is not watching TV at home and he has two days off, then he is drinking in a pub with his friends provided that the weather is bad. p H has two days off q weather is bad r H is fishing s H is drinking in a pub with his friends t H is watching TV at home u H is working A1. p ->(q ->~r) A2. (~r & ~s) -> t A3. u -> (~s & ~t) Q. (~t & p) -> (q->s) 10

Example (2) (cont.) Conversion to clause form York University- CSE 3401 11. is. q is. p is. is ) ( ) ( ) ( ) (., is., is ) ( ) ( ) ( ) ( 3. ; ; is ) ( ) ( 2.,, is ) ( 1 8 7 6 5 4 3 2 1 s C C C t C s q p t s q p t s q p t Q t u C s u C t u s u t s u t s u A t s r C t s r t s r t s r A r q p C r q p r q p A 04_Resolution

Example (2) (cont.) Determining the consistency of {C 1, C 2,..., C 8 } York University- CSE 3401 12.. q. p..,.,. ; ;.,, C C C C 8 7 6 5 4 3 2 1 s t t u s u t s r r q p C C C C -. s r;., r q -. r r.. 04_Resolution

Example (2) (cont.) C={C1, C2,..., C8} is inconsistent (by resolution/ refutation) Therefore Q is provable (deducible) Answer YES (true) This is how Prolog answers Queries. If the empty string is deduced, Prolog answers YES (or TRUE). 13

Resolution in Predicate Logic A literal in Predicate Logic (PL) is either A positive literal in the form of p(tp ( t 1,,..., tt k k ) where p is a predicate and t i are terms Or a negative literal in the form of p t,..., t ) ( 1 k Two clauses in PL can be resolved upon two complementary unifiable literals Two literals are unifiable if a substitution can make them identical. Example study_hard(x) and study_hard(john) date(d, M, 2001) and date(d1, may, Y1) 14

Substitution Substitution is a finite set of pairs of terms denoted as [X 1 /t 1,..., X n /t n ] where each t i is a term and each X i is a variable. Every variable is mapped to a term; if not explicitly mentioned, it maps to itself. For example date(d, M, 2001) and date(d1, may, Y1) Substitution e= [D/D1, M/may, Y1/2001] 15

Applying substitution to clauses Substitution of a clause is defined by applying substitution to each of its literals e( p - q 1,..., q k.) = e(p) - e(q 1 ),..., e(q k ). Example C pass_3401(x)- student(x, Y), study_hard(x). e=[x/ john, Y/ 3401] e(c)= pass_3401(john)- student(john, 3401), study_hard(john). 16

Applying substitution to literals Example p(x, f(x, 2, Z), 5) e= [X/5, Z/h(a,2+X)] e(p(x, f(x, 2, Z), 5))= p(5, f(5, 2, h(a, 2+X)), 5) Note Simultaneous substitution X in h(a,2+x) is not substituted Example r(x, Y) e=[x/y, Y/X] e(r(x, Y))= r(y, X) Example r(x, f(2, Y)) e=[f(2, Y) / Z] illegal substitution- only variables can be substituted 17

Unifier Let p 1 and p 2 be two literals and let e be a substitution. We call e a unifier of p 1 and p 2 if e(p 1 )=e(p 2 ). Two literals are unifiable if such a unifier exists. Example p 1 date(d, M, 2001) and p 2 date(d1, may, Y1) e=[d/15, D1/ 15, M/may, Y1/2001] e(p 1 )= date(15, may, 2001) e(p 2 )= date(15, may, 2001) e(p 1 )=e(p 2 ) e is a unifier of p 1 and p 2 p 1 and p 2 are unifiable 18

Most General Unifier (mgu) A unifier e is said to be a most general unifier (mgu) of two literals/terms iff e is more general than any other unifier of the terms. Example date(d, M, 2001) and date(d1, may, Y1) e 1 =[D/15, D1/ 15, M/may, Y1/2001] not the most general e 2 =[ D1/D, M/may, Y1/2001] mgu 19

Unification Called matching in Prolog Rules for matching two terms, S and T [Bratko] If S and T are constants, then S and T match only if they are the same object. If S is a variable (and T is anything), then they match and S is substituted by T (instantiated to T). Conversely, if T is a variable, then T is substituted by S. If S and T are structures, then they match iff S and T have the same principal functor All their corresponding components match 20

Examples Are the following literals unifiable? What is their mgu? 1. triangle(point(1,2), X, point(2,4) ) and triangle(a, point(5, Y), point(2, B)) unifiable mgu=[a/point(1,2), X/point(5,Y), B/4] 2. horizontal(point(1,x), Y) and vertical(z, A) not unifiable horizontal vertical 3. plus(2,2) and 4 not unifiable 4. seg(point(1,2), point(3,4)) and seg(f(1,2), Y) not unifiable point f 21

Unification vs. Matching Are p(x) and p(f(x)) unifiable? e=[x/f(x)] X=f(f(f(f(f(...?! This is not allowed in unification. Proper unification requires occurs check a variable X can not be substituted by a term t if X occur in t. This is not done in Prolog s matching for efficiency reasons. Therefore it is referred to as matching in Prolog, and not unification. 22

The resolution rule Given two clauses in the form A 0..A i..a m -B 1...B n. and C 1...C k - D 1..D j..d l. If e is a unifier of A i and D j (i.e. e(a i )=e(d j )) Then the resolvent of the above two clauses is e(a 0 ).. e(a i-1 )e(a i+1 ).. e(a m ) e(c 1 )..e(c k ) - e(b 1 ).. e(b n ) e(d 1 ).. e(d j-1 )e(d j+1 ).. e(d l ). Example C 1 p(y)- r(x, Y), q(y, Z). C 2 - p(f(1)). Unifier of p(f(1)) and p(y) e=[y/f(1)] The resolvent of C 1 and C 2 - r(x, f(1)), q(f(1), Z). 23

Example [Nilsson] C0 proud(x) - parent(x, Y), newborn(y). C1 parent(x, Y) - father (X, Y). C2 parent(x, Y) - mother(x, Y). C3 father(adam, mary). C4 newborn(mary). G0 - proud(z). Unifier of proud(..) in C0 and G0 e=[x/z], resolvent G1 - parent(z,y), newborn(y). Unifier of parent(..) in C1 and G1 e=[x/z, Y/Y], resolvent G2 - father(z,y), newborn(y). To prevent mistakes, we rename the variables whenever we use a fresh copy of a clause. 24

Example (cont.) [Nilsson] G0 - proud(z). (copy of) C0 proud(x 1 ) - parent(x 1, Y 1 ), newborn(y 1 ). Resolve with G0 e=[x 1 /Z] G1 - parent(z,y 1 ), newborn(y 1 ). (copy of) C1 parent(x 2,Y 2 ) - father (X 2, Y 2 ). Resolve with G1 e=[x 2 /Z, Y 2 /Y 1 ] G2 - father(z, Y 1 ), newborn(y 1 ). (copy of) C3 father(adam, mary). Resolve with G2 e=[z/adam, Y 1 /mary] G3 -newborn(mary). (copy of) C4 newborn(mary). Resolve with G3 e=[] G4 - Empty clause answer to query true if Z=adam 25

Example (cont.) [Nilsson] Just a different notation for - 1 1 1 1 1 1 2 2 2 2 1 1 Refutation Tree for G0 26

Linear Refutation We can resolve with different clauses and keep adding new clauses forever! To prevent this, Linear Refutation always starts with a goal (as the example showed previously). Prolog s computation rule Always selects the leftmost subgoal, although logically there is no order for the subgoals. Example When resolving G1 - parent(z,y 1 ), newborn(y 1 )., parent(..) was selected to resolve upon. Prolog also starts from the top of knowledge base and goes down the list of facts and rules. 27

Search Space Based on linear refutation and Prolog s computation rule, we know the search tree of Prolog. Search tree The root in the search tree is the main goal G 0. A child node is a new goal G i obtained through resolution. A link is labelled with the clause resolved with and the substitution. Example C0 grandfather(x,z) - father(x,y), parent(y,z). C1 parent(x,y) - father(x,y). C2 parent(x,y) - mother(x,y). C3 father(a,b)-. C4 mother(b,c)-. C5 mother(b,d)-. G0 - grandfather(a,x). 28

Search Space (example) C0, [Z/X, X 0 /a] 0 C3, [Y 0 /b] C0 grandfather(x,z) - father(x,y), parent(y,z). C1 parent(x,y) - father(x,y). C2 parent(x,y) - mother(x,y). C3 father(a,b)-. C4 mother(b,c)-. C5 mother(b,d)-. G0 - grandfather(a,x). C1, [X 1 /b, Y 1 /X] C2, [X 2 /b, Y 2 /X] Nothing to resolve with, backtrack! C4, [X/c] TRUE, X=c ; (backtrack!) C5, [X/d] TRUE, X=d 29

Search Space What is the search strategy used by Prolog for searching the tree? Depth First Search or Breadth First Search Prolog uses DFS 30

Questions 1. Why is it ok to rename the variables every time we use a fresh copy of a clause (slide #24)? Doesn t that change the clause?! Note that each variable X in our clause is actually bound by a universal quantifier (X). In the last step of converting to CNF, we removed the quantifiers for simpler notation. Renaming the variable bound by a quantifier (dummy renaming) does not alter the semantics of the formula. 31

Questions 2. Why do we always have goals in each node of Prolog s search tree? Why don t we have facts and rules as resolvents?! Each goal is a clause with no head and several literals in the body. On the other hand, each clause in the knowledge base is a fact or a rule, having exactly one literal in the head and zero or more literals in the body. Based on linear refutation, Prolog always resolves the goal with its set of facts and rules. The one literal in the head of the facts and rules, is always cut (resloved) with a subgoal, leaving no literals in the head. Therefore after each resolution step, the resolvent is always a goal. 32

Examples for resolution rule (Slide #23) Example 1 Consider two clauses student(john, 3401)-. - student(john, 3401). We can resolve these two clauses upon the literal student(john,3401), since 1. It is unifiable in both clauses after no substitution (e=[]). 2. It apears on the right side (of - ) in one clause and on the left side in the other clause. The resolvent (cutting the literal in both clauses, and writing what is left from both clauses) is therefore - (the empty clause) 33

Examples for resolution rule (Slide #23) Example 2 Consider two clauses student(john, 3401)-. - student(x, 3401). We can resolve these two clauses upon the literals student(john,3401) and student(x,3401), since 1. These literals are unifiable after substitution e=[x/john]. e(student(john,3401))= e(student(x,3401)) 2. One apears on the right side (of - ) in one clause and the other on the left side in the other clause. The resolvent (cutting the literal in both clauses, and writing what is left from both clauses) is therefore - (the empty clause) 34

Examples for resolution rule (Slide #23) Example 3 Consider two clauses pass(x)- student(x, 3401), study (X). - pass(john). We can resolve these two clauses upon the literals pass(john) and pass(x), since 1. These literals are unifiable after substitution e=[x/john]. e(pass(john))= e(pass(x)) 2. One apears on the right side (of - ) in one clause and the other on the left side in the other clause. The resolvent (cutting the literal in both clauses, and writing what is left from both clauses) is therefore - e(student(x,3401)), e(study(x)). After applying the substitution, it will simplify to - student(john, 3401), study(john). 35