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

Similar documents
Contents Chapters 2 & 3

Individuals and Relations

Propositions. c D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 5.1, Page 1

Announcements. Assignment 5 due today Assignment 6 (smaller than others) available sometime today Midterm: 27 February.

Top-Down Execution CS240B Notes

Propositional Logic: Bottom-Up Proofs

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

Foundations of Logic Programming

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

Reasoning Under Uncertainty: Introduction to Probability

Announcements. Solution to Assignment 3 is posted Assignment 4 is available. c D. Poole and A. Mackworth 2017 CPSC 322 Lecture 8 1 / 25

Künstliche Intelligenz

Logic: Bottom-up & Top-down proof procedures

Propositional Logic: Semantics and an Example

Logic: Top-down proof procedure and Datalog

University of Aberdeen, Computing Science CS2013 Predicate Logic 4 Kees van Deemter

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

Logical reasoning - Can we formalise our thought processes?

Logic: Resolution Proofs; Datalog

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

Strong AI vs. Weak AI Automated Reasoning

CS 4700: Artificial Intelligence

Resolution and Refutation

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

COMP9414: Artificial Intelligence First-Order Logic

Definite Logic Programs

Reasoning Under Uncertainty: Introduction to Probability

Computing logical consequences

Introduction to Predicate Logic Part 1. Professor Anita Wasilewska Lecture Notes (1)

Advanced Topics in LP and FP

Chapters 2&3: A Representation and Reasoning System

Propositional Definite Clause Logic: Syntax, Semantics and Bottom-up Proofs

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

COMP9414: Artificial Intelligence Propositional Logic: Automated Reasoning

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

INTRODUCTION TO LOGIC

INTRODUCTION TO LOGIC 8 Identity and Definite Descriptions


07 Equational Logic and Algebraic Reasoning

Propositional Logic Not Enough

Propositional and Predicate Logic - V

8 General first order representation

Inference in First Order Logic

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

Exercises 1 - Solutions

Propositions. c D. Poole and A. Mackworth 2008 Artificial Intelligence, Lecture 5.1, Page 1

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

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

Discrete Mathematics and Its Applications

Convert to clause form:

Logic Programming Theory Lecture 7: Negation as Failure

Propositional Reasoning

The non-logical symbols determine a specific F OL language and consists of the following sets. Σ = {Σ n } n<ω

INTRODUCTION TO LOGIC 8 Identity and Definite Descriptions

Unification and occur check. The programming language Prolog

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

Inf2D 13: Resolution-Based Inference

CPSC 121: Models of Computation

Bachelor/Master Exam Version V3B

Symbolising Quantified Arguments

Inference in first-order logic

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

INTRODUCTION TO LOGIC

A Brief Introduction to Nonmonotonic Reasoning

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

Advanced Topics in LP and FP

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

Predicate Logic: Sematics Part 1

Chapter 5: Propositions and Inference. c D. Poole, A. Mackworth 2010, W. Menzel 2015 Artificial Intelligence, Chapter 5, Page 1

Chapter 7. Negation: Declarative Interpretation

2/2/2018. CS 103 Discrete Structures. Chapter 1. Propositional Logic. Chapter 1.1. Propositional Logic

ICS141: Discrete Mathematics for Computer Science I

Propositional Logic: Review

TDDD08 Tutorial 1. Who? From? When? 6 september Victor Lagerkvist (& Wªodek Drabent)

CSE 20. Final Review. CSE 20: Final Review

COMP4418: Knowledge Representation and Reasoning First-Order Logic

Resolution for Predicate Logic

Announcement. Homework 1

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


Inference in first-order logic

15414/614 Optional Lecture 3: Predicate Logic

Logic: Intro & Propositional Definite Clause Logic

Models. Let our knowledge base KB, consist of a set of formulas. We say that I is a model of KB or that I satisfies KB

Introduction to Sets and Logic (MATH 1190)

Lecture overview. Knowledge-based systems in Bioinformatics, 1MB602. Reasoning. Reasoning cont. Inference in propositional logic.

Computed answer based on fuzzy knowledgebase a model for handling uncertain information

Prolog and Logic Programming. CS152 Chris Pollett Dec. 3, 2008.

Fuzzy Datalog with background knowledge

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

Logical Inference 2 rule based reasoning

First-Order Theorem Proving and Vampire. Laura Kovács (Chalmers University of Technology) Andrei Voronkov (The University of Manchester)

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

Brief Introduction to Prolog

Computational Logic Automated Deduction Fundamentals

Bachelor/Master Exam Version V3B

CogSysI Lecture 8: Automated Theorem Proving

Advanced DB CHAPTER 5 DATALOG

First-Order Logic. Resolution

Formal Logic: Quantifiers, Predicates, and Validity. CS 130 Discrete Structures

Transcription:

Announcements Project 1 underway... discuss ideas with TAs check out wiki Second midterm Friday You may bring on one letter-sized sheet of paper with anything written or drawn or... anywhere on it. It will cover up to as much as we get to today (including unification and top-down proofs with variables, equality and possibly negation as failure) c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 1 / 31

Review Prolog extends propositional logic program by having predicates, constants, variables and function symbols. Triples are universal representations of relations, and are the basis for RDF URIs provide constants that have standard meanings Ontologies define the meaning of symbols used in information systems. Unification is used to extend the top-down proof procedure to include structured atoms (predicates, functions, constants, variables). c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 2 / 31

Clicker Question What does this triple mean: cir, rdfs:domain, http://schema.org/newspaper A cir is a property that applies only to newspapers B cir is a newspaper C cir is a property where some of the values are newspapers D cir is a property which apples to newspapers, and perhaps other things c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 3 / 31

Clicker Question For the atoms foo(x, X, Z) and foo(y, T, W ) The substitution {X /Y, T /Y, W /Y, Z/Y } A is a most general unifier B is a unifier, but not a most-general unifier C is not a unifier c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 4 / 31

Clicker Question For the atoms foo(x, X, Z) and foo(y, T, W ) The substitution {X /V, T /V, Y /V, W /M, Z/M} A is a most general unifier B is a unifier, but not a most-general unifier C is not a unifier c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 5 / 31

Clicker Question For the atoms foo(x, X, Z) and foo(y, b, W ) A most general unifier is A {Y /X, X /b, Z/W } B {X /b, Y /b, Z/X } C {X /b, Y /b, Z/T, W /T } D There are most general unifiers, but none of A-C are most general unifiers. E There are no most general unifiers c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 6 / 31

Top-down Proof procedure A generalized answer clause is of the form yes(t 1,..., t k ) :- a 1, a 2,..., a m, where t 1,..., t k are terms and a 1,..., a m are atoms. The SLD resolution of this generalized answer clause on a 1 with the clause a :- b 1,..., b p, where a i and a have most general unifier θ, is (yes(t 1,..., t k ) :- b 1,..., b p, a 2,..., a m )θ. c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 7 / 31

Top-down Proof Procedure To solve query?b with variables V 1,..., V k : Set ac to generalized answer clause yes(v 1,..., V k ) :- B while body of ac is not empty do Suppose ac is yes(t 1,..., t k ) :- a 1, a 2,..., a m select leftmost atom a i in the body of ac choose clause a :- b 1,..., b p in KB Rename all variables in a :- b 1,..., b p Let θ be the most general unifier of a i and a. Fail if they don t unify Set ac to (yes(t 1,..., t k ) :- b 1,..., b p, a 2,..., a m )θ end while. Answer is V 1 = t 1,..., V k = t k c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 8 / 31

Example append([], L, L). append([h T ], A, [H R]) :- append(t, A, R).? append([a, b, c], [1, 2, 3], L). yes(l) :- append([a, b, c], [1, 2, 3], L). yes([a R1]) :- append([b, c], [1, 2, 3], R1). yes([a, b R2]) :- append([c], [1, 2, 3], R2). yes([a, b, c R3]) :- append([], [1, 2, 3], R3). yes([a, b, c, 1, 2, 3]) :-. Answer is L = [a, b, c, 1, 2, 3] c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 9 / 31

Clicker Question For the answer clause yes(obj) :- noun([sam, likes, cs312], T 2, Obj), vp(t 2, T 3, Obj) and the clause in the knowledge base noun([x R], R, X ) :- person(x ) What is the most general unifier used in the top-down derivation A {R/[likes, cs312], X /sam, T 2/R, Obj/X } B {R/[cs312], X /[sam, likes], T 2/[cs312], Obj/sam} C {R/[likes, cs312], X /sam, T 2/[likes, cs312], Obj/sam} D It doesn t unify as there is no vp in the clause. E None of the above c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 10 / 31

Clicker Question For the answer clause yes(obj) :- noun([sam, likes, cs312], T 2, Obj), vp(t 2, T 3, Obj). and the clause in the knowledge base noun([x R], R, X ) :- person(x ). What is the resulting answer clause (up to renaming of variables): A yes(x ) :- person(x ), vp(t 2, T 3, X ). B yes(sam) :- person(sam), vp([likes, cs312], T 3, sam). C yes(obj) :- noun([sam, likes, cs312], T 2, Obj), person(obj), vp(t 2, T 3, Obj). D yes(obj) :- person(obj), vp(t 2, T 3, Obj). E the proof fails here c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 11 / 31

Clicker Question What is not a reason for renaming variables in the clause when resolving: A The system can forget about the names of variables when compiling clauses B To prevent name clashes for variables in the query and the clauses in the knowledge base C One clause in a program may be used multiple times in a proof with different substitutions D An answer may require multiple different instances of variables E These are all reasons c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 12 / 31

Today Proofs with variables (cont) Equality, unique names assumption Negation as failure c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 13 / 31

Unification with function symbols Consider a knowledge base consisting of one fact: lt(x, s(x )). Should the following query succeed??- lt(y, Y ). What does the top-down proof procedure give? Solution: variable X should not unify with a term that contains X inside. Occurs check E.g., X should not unify with s(x ). Simple modification of the unification algorithm, which Prolog does not do! c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 14 / 31

Complete Knowledge Assumption Often you want to assume that your knowledge is complete. Example: assume that a database of what students are enrolled in a course is complete. We don t want to have to state all negative enrolment facts! The definite clause language is monotonic: adding clauses can t invalidate a previous conclusion. Under the complete knowledge assumption, the system is non-monotonic: adding clauses can invalidate a previous conclusion. c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 15 / 31

Equality Equality is a special predicate symbol with a standard domain-independent intended interpretation. Suppose interpretation I = D, φ, π. t 1 and t 2 are ground terms then t 1 = t 2 is true in interpretation I if t 1 and t 2 denote the same individual. That is, t 1 = t 2 if φ(t 1 ) is the same as φ(t 2 ). t 1 t 2 when t 1 and t 2 denote different individuals. Example: D = {,, }. φ(phone) =, φ(pencil) =, φ(telephone) = What equalities and inequalities hold? phone = telephone, phone = phone, pencil = pencil, telephone = telephone pencil phone, pencil telephone Equality does not mean similarity! c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 16 / 31

Equality Constants/Terms a b c d Individuals f(a) e c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 17 / 31

Properties of Equality Equality is: Reflexive: X = X Symmetric: if X = Y then Y = X Transitive: if X = Y and Y = Z then X = Z For each n-ary function symbol f f (X 1,..., X n ) = f (Y 1,..., Y n ) if X 1 = Y 1 and and X n = Y n. For each n-ary predicate symbol p p(x 1,..., X n ) if p(y 1,..., Y n ) and X 1 = Y 1 and and X n = Y n. c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 18 / 31

Unique Names Assumption Suppose the only clauses for enrolled are enrolled(sam, cs222) enrolled(chris, cs222) enrolled(sam, cs873) To conclude enrolled(chris, cs873), what do we need to assume? All other enrolled facts are false Inequalities: sam chris cs873 cs222 The unique names assumption (UNA) is the assumption that distinct ground terms denote different individuals. c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 19 / 31

Inequality as a subgoal What should the following query return?? X 4. What should the following query return?? X 4, X = 7. What should the following query return?? X 4, X = 4. Prolog has 3 different inequalities that differ on examples like these: \== \= dif() They differ in cases where there are free variables, and terms unify but are not identical. c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 20 / 31

Completion of a knowledge base: propositional case Suppose the rules for atom a are a b 1.. a b n. equivalently a b 1... b n. Under the Complete Knowledge Assumption, if a is true, one of the b i must be true: a b 1... b n. Thus, the clauses for a mean a b 1... b n c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 21 / 31

Clark Normal Form The Clark normal form of the clause p(t 1,..., t k ) B. is the clause where p(v 1,..., V k ) W 1... W m V 1 = t 1,..., V k = t k, B. V 1,..., V k are k variables that did not appear in the original clause W 1,..., W m are the original variables in the clause. When the clause is an atomic clause, B is true. Often can be simplified by replacing W V = W p(w ) with P(V ). c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 22 / 31

Clark normal form For the clauses student(mary). student(sam). student(x ) undergrad(x ). the Clark normal form is student(v ) V = mary. student(v ) V = sam. student(v ) X V = X undergrad(x ). c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 23 / 31

Clark s Completion Suppose all of the clauses for p are put into Clark normal form, with the same set of introduced variables, giving p(v 1,..., V k ) B 1.. p(v 1,..., V k ) B n. which is equivalent to p(v 1,..., V k ) B 1... B n. Clark s completion of predicate p is the equivalence V 1... V k p(v 1,..., V k ) B 1... B n If there are no clauses for p, the completion results in V 1... V k p(v 1,..., V k ) false Clark s completion of a knowledge base consists of the completion of every predicate symbol along the unique names assumption. c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 24 / 31

Completion example p q, \+ r. p s. q \+ s. r \+ t. t. s w. c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 25 / 31

Completion Example Consider the recursive definition: passed each([ ], St, MinPass). passed each([c R], St, MinPass) passed(st, C, MinPass), passed each(r, St, MinPass). In Clark normal form, this can be written as passed each(l, S, M) :- L = [ ]. passed each(l, S, M) C R L = [C R], passed(s, C, M), passed each(r, S, M). Here we renamed the variables as appropriate. Thus, Clark s completion of passed each is L S M passed each(l, S, M) L = [ ] C R L = [C R], passed(s, C, M), passed each(r, S, M). c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 26 / 31

Clark s Completion of a KB Clark s completion of a knowledge base consists of the completion of every predicate. The completion of an n-ary predicate p with no clauses is p(v 1,..., V n ) false. You can interpret negations in the body of clauses. \+ a means a is false under the complete knowledge assumption. \+ a is replaced by a in the completion. This is negation as failure. c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 27 / 31

Defining empty course Given database of: course(c) that is true if C is a course enrolled(s, C) that is true if student S is enrolled in course C. Define empty course(c) that is true if there are no students enrolled in course C. Using negation as failure, empty course(c) can be defined by empty course(c) course(c), has enrollment(c) enrolled(s, C). \+ has enrollment(c). The completion of this is: C empty course(c) course(c), has enrollment(c). C has enrollment(c) S enrolled(s, C). c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 28 / 31

Top-Down negation as failure proof procedure If the proof for a fails, you can conclude \+ a. Failure can be defined recursively: Suppose you have rules for atom a: a b 1. a b n If each body b i fails, a fails. A body fails if one of the conjuncts in the body fails. Note that you need finite failure. Example p :- p. c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 29 / 31

Floundering p(x ) \+ q(x ), r(x ). q(a). q(b). r(d).?- p(x ). What is the answer to the query? How can a top-down proof procedure find the answer? Delay the subgoal until it is bound enough. Sometimes it never gets bound enough floundering. c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 30 / 31

Problematic Cases p(x ) :- \+ q(x ) q(x ) :- \+ r(x ) r(a)?- p(x ). What is the answer? What does delaying do? How can this be implemented? c D. Poole and A. Mackworth 2017 CPSC 312 2017 Lecture 17 31 / 31