COMP2411 Lecture 10: Propositional Logic Programming. Note: This material is not covered in the book. Resolution Applied to Horn Clauses

Similar documents
First Order Logic: Syntax and Semantics

Advanced Topics in LP and FP

Rules Build Arguments Rules Building Arguments

Learning Goals of CS245 Logic and Computation

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

MAI0203 Lecture 7: Inference and Predicate Calculus


Logical reasoning - Can we formalise our thought processes?

Propositional Logic Not Enough

Brief Introduction to Prolog

PROOFS IN PREDICATE LOGIC AND COMPLETENESS; WHAT DECIDABILITY MEANS HUTH AND RYAN 2.3, SUPPLEMENTARY NOTES 2

THE LANGUAGE OF FIRST-ORDER LOGIC (FOL) Sec2 Sec1(1-16)

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

INTRODUCTION TO PREDICATE LOGIC HUTH AND RYAN 2.1, 2.2, 2.4

Stanford University CS103: Math for Computer Science Handout LN9 Luca Trevisan April 25, 2014

Intelligent Agents. First Order Logic. Ute Schmid. Cognitive Systems, Applied Computer Science, Bamberg University. last change: 19.

Introduction to Logic in Computer Science: Autumn 2006

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

Propositional logic. Programming and Modal Logic

Resolution (14A) Young W. Lim 8/15/14

Predicate Logic 1. The Need for Predicate Logic. The Need for Predicate Logic. The Need for Predicate Logic. The Need for Predicate Logic

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

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

06 From Propositional to Predicate Logic

Predicate Logic - Introduction

Section 2.1: Introduction to the Logic of Quantified Statements

First-Order Logic (FOL)

Syntax. Notation Throughout, and when not otherwise said, we assume a vocabulary V = C F P.

Recall that the expression x > 3 is not a proposition. Why?

Chapter 16. Logic Programming. Topics. Logic Programming. Logic Programming Paradigm

Notes on Propositional and First-Order Logic (CPSC 229 Class Notes, January )

Logic and Modelling. Introduction to Predicate Logic. Jörg Endrullis. VU University Amsterdam

Propositional Logic: Review

Introduction to first-order logic:

First-Order Logic. 1 Syntax. Domain of Discourse. FO Vocabulary. Terms

Logic Background (1A) Young W. Lim 12/14/15

Propositional Logic Language

Logic Overview, I. and T T T T F F F T F F F F

THE PREDICATE CALCULUS

02 Propositional Logic

Logic Background (1A) Young W. Lim 5/14/18

Logical Structures in Natural Language: First order Logic (FoL)

Chapter 2: Basic Notions of Predicate Logic

Lecture 10: Predicate Logic and Its Language

Ling 130 Notes: Predicate Logic and Natural Deduction

A Logic Primer. Stavros Tripakis University of California, Berkeley. Stavros Tripakis (UC Berkeley) EE 144/244, Fall 2014 A Logic Primer 1 / 35

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

Propositional Resolution Introduction

Review: Potential stumbling blocks

Chapter 7 R&N ICS 271 Fall 2017 Kalev Kask

Propositional logic. Programming and Modal Logic

First Order Logic Implication (4A) Young W. Lim 4/6/17

Knowledge based Agents

Logic (3A) Young W. Lim 10/29/13

First-Order Logic First-Order Theories. Roopsha Samanta. Partly based on slides by Aaron Bradley and Isil Dillig

A Logic Primer. Stavros Tripakis University of California, Berkeley

Predicate Calculus - Syntax

Logical Structures in Natural Language: Propositional Logic II (Truth Tables and Reasoning

Definite Logic Programs

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

Classical First-Order Logic

4 Quantifiers and Quantified Arguments 4.1 Quantifiers

Propositional Logic: Models and Proofs

COMP2411 Lecture 6: Soundness and Completeness. Reading: Huth and Ryan, Sections 1.4

CS 730/730W/830: Intro AI

GS03/4023: Validation and Verification Predicate Logic Jonathan P. Bowen Anthony Hall

Logic: Propositional Logic (Part I)

Strong AI vs. Weak AI Automated Reasoning

Computational Logic Automated Deduction Fundamentals

First Order Logic (1A) Young W. Lim 11/18/13

Introduction to Intelligent Systems

Automated Reasoning Lecture 5: First-Order Logic

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)

Introduction to Intelligent Systems

Mat 243 Exam 1 Review

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

Lecture 15: Validity and Predicate Logic

Topic #3 Predicate Logic. Predicate Logic

Lecture 1: Logical Foundations

Formal (Natural) Deduction for Predicate Calculus

Inference in first-order logic

Propositional Logic Arguments (5A) Young W. Lim 11/30/16

Logic (3A) Young W. Lim 11/2/13

Predicate Calculus. Lila Kari. University of Waterloo. Predicate Calculus CS245, Logic and Computation 1 / 59

Logic. (Propositional Logic)

Deductive Systems. Lecture - 3

Propositional and Predicate Logic - V

Example. Lemma. Proof Sketch. 1 let A be a formula that expresses that node t is reachable from s

Logic - recap. So far, we have seen that: Logic is a language which can be used to describe:

Logic (3A) Young W. Lim 10/31/13

Artificial Intelligence Chapter 7: Logical Agents

First Order Logic (1A) Young W. Lim 11/5/13

03 Review of First-Order Logic

3/29/2017. Logic. Propositions and logical operations. Main concepts: propositions truth values propositional variables logical operations

Section Summary. Predicate logic Quantifiers. Negating Quantifiers. Translating English to Logic. Universal Quantifier Existential Quantifier

COMP9414: Artificial Intelligence Propositional Logic: Automated Reasoning

Predicate Logic: Syntax

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

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

Transcription:

COMP2411 Lecture 10: Propositional Logic Programming Note: This material is not covered in the book Consider two Horn clauses Resolution Applied to Horn Clauses p p 1... p n and q q 1... q m Suppose these resolve, with p = q 1, say. Then the result is q p 1... p n q 1... q m which is a Horn clause. Thus: resolution applied to Horn clauses produces only Horn clauses. In the book s notation: p 1... p n p q 1... q m q p = q 1 p 1... p n q 2... q m q 1

Definite Horn Clauses A Horn clause is said to be definite if it contains a positive literal. (In the book s notation, a Horn clause L R is definite if R is not.) Example: C EF I (i.e. C EF I) is definite C (i.e. C) is definite D N (i.e. D N ) is not definite. A set of definite Horn clauses is called a logic program. When P is a logic program and G 1... G n is a conclusion such that we we would like to derive P = G 1... G n, the clause G 1... G n (i.e. G 1... G n ) added to P is called a goal. Linear Resolution A resolution proof starting from a set of premises (clauses) {P 1,..., P n } is said to be linear if it can be written in the form of a sequence of clauses P 1,..., P n, Q 1,... Q m such that Q 1 is derived by resolution from some pair of premises, and for every i = 2... m, the clause Q i is derived from Q i 1 and some premise in {P 1,..., P n } (See figure 1 for an example of a linear resolution proof based on the medical database form the last lecture) 2

Theorem: (Completeness of linear resolution for logic programs) Let P be a logic program and let G be a goal. Suppose that P, G =. Then there exists a linear resolution proof of from the clauses P, G in which every clause is descended from the goal. Moreover, we can construct this proof so that, at each step, the last clause generated will have the form L 1... L n and the next step is to resolve this with some rule of the form N L 1, producing N L 2... L n That is: it suffices to always choose the left-most atom in the current descendent of the goal to resolve against. Proofs in this form are called SLD proofs with leftmost selection rule. (S = selection, L= linear, for D = definite clauses) This leaves only one choice to be made at each step: when there are several rules of the form N L 1, which one to use? If we consider all possibilities, we get a tree in which each branch corresponds to an attempted linear proof with leftmost selection. (See figure 2 for the complete tree obtained in the medical database using the left-most slection rule.) 3

Most logic programming systems, like Prolog, search this tree in depth first fashion from left to right. Moreover the input clauses are ordered, and the possibilities are considerd from first to last. Deductive Database Systems, such as Coral use optimized versions of the algorithm from the book. Other systems, such as XSB, use a hybrid approach More on this later... Predicate Calculus Reading: Huth & Ryan, Section 2.1-2.2 4

Declarative sentences in natural language have a lot more structure than we have captured so far. Moreover, this structure plays an essential role in intuitively valid arguments: Margaret is John s supervisor. Thus, John has a supervisor. If we express this in logic as two assertions P, Q, we find that P = Q. More examples... Dilbert is an employee. Every employee except the CEO has a supervisor. Dilbert is not the CEO. Thus, Dilbert has a supervisor. Every employee s supervisor is out of his depth. Dilbert is an employee. Thus, Dilbert s supervisor is out of his depth. Every pixel that is not contained in some window has the background colour. There is a pixel not contained in any window. Thus, there is a pixel that has the background colour. All transactions in the database have been checked. Every transaction made yesterday is in the database. Thus, every transaction made yesterday has been checked. 5

What sorts of structure is there in these sentences that might account for the validity of these arguments? Names for objects: John, Margaret, Dilbert Complex expressions for objects: Dilbert s supervisor Properties of objects: has a supervisor, is in the database Relationships between objects:... is the manager of...,... is contained in... Quantifiers: Every, Somebody, All, there is Predicate Logic or First Order Logic, attempts to formalize these sorts of constructs. Syntax of Predicate Logic, and Intuitive Semantics Predicate Logic deals with some domain of discourse. Terms refer to objects in this domain. Terms are constructed from: Constant terms: a, b, c,... these represent names, such as Dilbert Variables: u, v, w, x, y, z... these act as place holders for expressions referring to objects Function Symbols: f, g, h,... these represent functional operations such as s supervisor Each function symbol has an arity, i.e. the number of arguments it takes. 6

Terms are defined recursively: A terms is a constant c, or a variable x, or an expression f(t 1,..., t n ), where f is an n-ary function symbol and t 1,..., t n are terms. Examples: 1. dilbert 2. supervisor(dilbert) 3. salary(dilbert) 4. sum(salary(dilbert),salary(supervisor(dilbert))) 5. sum(salary(x),salary(supervisor(x))) Intuitively, 1. refers to Dilbert 2. refers to Dilbert s supervisor 3. refers to Dilbert s salary 4. refers to the sum of Dilbert s salary and the salary of his supervisor 5. refers to the sum of the salary of the person referred to as x and the salary of the supervisor of that person. Once we decide what x refers to we can calculate this. 7

Predicates The language of predicate logic also contains a set of predicate symbols: P, Q, R,... Each has an arity, i.e. a number of arguments that it takes. Intuitively, a predicate symbol represents a relationship that may hold between its arguments. Examples: Stingy of arity one Supervises of arity 2 Walked of arity 3 (.. took.. for a walk at place...) An atomic formula of predicate logic has the form P (t 1,..., t n ), where P is a predicate symbol and t 1,..., t n are terms. Intuitively, this states that the relationship referred to by P applies to (is true of) the objects referred to by t 1,..., t n (in that order). Examples: 1. Stingy(supervisor(dilbert)) 2. Tiny(salary(dilbert)) 3. Supervises(snoopy, dilbert) 4. Walked(charlie,snoopy,park) 5. Supervises(snoopy, supervisor(x)) Note that in the last case, x is a variable, so we can t determine a truth value until we say what this refers to. 8

Intuitively, these formulas state that 1. Dilberts supervisor is stingy. 2. Dilberts salary is tiny. 3. Snoopy supervises Dilbert. 4. Charlie took Snoopy for a walk in the park. 5. Snoopy supervises the supervisor of x. From the basis of atomic formulas, we can form more complex formulas using the operators of propositional logic. Examples 1. Supervises(snoopy, dilbert) Snoopy does not supervise Dilbert. 2. Supervises(snoopy, dilbert) Tiny(salary(dilbert)) (If Snoopy supervises Dilbert then Dilbert s salary is tiny.) 3. Walked(charlie,snoopy,park) Walked(snoopy,charlie,park) (Either Charlie took Snoopy for a walk in the park or Snoopy took Charlie for a walk in the park.) 4. Supervises(snoopy, dilbert) Tiny(salary(x)) (If Snoopy supervises Dilbert then... x s salary is tiny.) 9

Universal Quantifier The universal quantifier is used to capture expressions such as All...... and Every....... Formally, if φ is a formula and x is a variable, then x(φ) is a formula. Intuitively, this states that φ holds for every possible value of the variable x. Examples: Every project of Dilbert fails. x(projectof(dilbert, x) Fails(x)) All employees have tiny salaries. x(employee(x) Tiny(salary(x))) Every owner walks all their dogs in the park x(owner(x) y(dogof(x, y) Walks(x, y, park))) Or... x y(owns(x, y) Walks(x, y, park)) 10

Existential Quantifier The quantifier is used to capture expressions such as Some...... There is... that... and There exists... that.... Formally, if φ is a formula and x is a variable, then x(φ) is a formula. Intuitively, this states that φ holds for some possible value of the variable x. Examples: Some project of Dilbert fails. x(projectof(dilbert, x) Fails(x)) There is an employee who has a tiny salary. x(employee(x) Tiny(salary(x))) Someone owns a dog and walks it in the park x(owner(x) y(dogof(x, y) Walks(x, y, park))) Or... x y(owns(x, y) Dog(y) Walks(x, y, park)) Someone walks all their dogs in the park. x(person(x) y(dogof(x, y) Walks(x, y, park))) 11

Note the general pattern for these translations: All A s B is translated as x(a(x) B(x)) Some A B s is translated as x(a(x) B(x)) 12