Simply Logical – Chapter 3© Peter Flach, 2000 Luc De Raedt and Andreas Karwath (original slides by Peter Flach) Fortgeschrittene Programmierung PROLOG.

Slides:



Advertisements
Similar presentations
CS4026 Formal Models of Computation Part II The Logic Model Lecture 1 – Programming in Logic.
Advertisements

Simply Logical – Chapter 5© Peter Flach, 2000 Agenda-based search % search(Agenda,Goal)
Simply Logical – Chapter 2© Peter Flach, 2000 Clausal logic Propositional clausal logic Propositional clausal logic expressions that can be true or false.
Page 1 Nov 09, 2004CAS 701, McMaster Logic Programming and Prolog Presenter: John Xu Date: Nov 09, 2004.
SLD-resolution Introduction Most general unifiers SLD-resolution
1 Part 1 The Prolog Language Chapter 2 Syntax and Meaning of Prolog programs.
Inference in first-order logic Chapter 9. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
Prolog The language of logic. History Kowalski: late 60’s Logician who showed logical proof can support computation. Colmerauer: early 70’s Developed.
First Order Logic Resolution
We have seen that we can use Generalized Modus Ponens (GMP) combined with search to see if a fact is entailed from a Knowledge Base. Unfortunately, there.
Methods of Proof Chapter 7, second half.. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound)
Solving Problem by Searching
Artificial Intelligence - Prolog Programming - Ryo Hatano JAIST Oct 16, 2012.
13 Automated Reasoning 13.0 Introduction to Weak Methods in Theorem Proving 13.1 The General Problem Solver and Difference Tables 13.2 Resolution.
Methods of Proof Chapter 7, Part II. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound) generation.
1 Knowledge Based Systems (CM0377) Lecture 8 (Last modified 5th March 2001)
2. Syntax and Meaning. Contents Data Objects Matching Declarative meaning of Prolog Procedural meaning Example: monkey and banana Order of clauses and.
Search Strategies Reading: Russell’s Chapter 3 1.
Copyright © 2002 Cycorp Logical Aspects of Inference Incompleteness in Searching Incompleteness from Resource Bounds and Continuable Searches Inference.
2014-T2 Lecture 25 School of Engineering and Computer Science, Victoria University of Wellington  Lindsay Groves, Marcus Frean, Peter Andreae, and Thomas.
Artificial Intelligence Chapter 14. Resolution in the Propositional Calculus Artificial Intelligence Chapter 14. Resolution in the Propositional Calculus.
1 Applied Computer Science II Resolution in FOL Luc De Raedt.
Proof methods Proof methods divide into (roughly) two kinds: –Application of inference rules Legitimate (sound) generation of new sentences from old Proof.
Resolution Refutation Formal Aspects of Computer Science - Week 10 An Automated Theorem Prover Lee McCluskey, room 2/07
1 Automated Reasoning Introduction to Weak Methods in Theorem Proving 13.1The General Problem Solver and Difference Tables 13.2Resolution Theorem.
Inference and Resolution for Problem Solving
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Syntax and Meaning of Prolog Programs Notes for Ch.2 of Bratko For CSCE 580.
Artificial Intelligence Chapter 17 Knowledge-Based Systems Biointelligence Lab School of Computer Sci. & Eng. Seoul National University.
Artificial Intelligence Chapter 14 Resolution in the Propositional Calculus Artificial Intelligence Chapter 14 Resolution in the Propositional Calculus.
Automated Reasoning ARTIFICIAL INTELLIGENCE 6th edition George F Luger
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Monkey and Bananas Exercise Notes on Exercise 3.10 of Bratko For CSCE 580 Sp03.
0 1 Todays Topics Resolution – top down and bottom up j-DREW BU procedure Subsumption – change to procedure Infinite Loops RuleML input – Prolog output.
CS1502 Formal Methods in Computer Science Lecture Notes 10 Resolution and Horn Sentences.
INFERENCE IN FIRST-ORDER LOGIC IES 503 ARTIFICIAL INTELLIGENCE İPEK SÜĞÜT.
Lists in Prolog Sections 3.1, 3.2. Testing a List n Suppose have defined female/1 and male/1 n Check whether a list is all male % all_male(?L) % -- male(X)
Proof Systems KB |- Q iff there is a sequence of wffs D1,..., Dn such that Dn is Q and for each Di in the sequence: a) either Di is in KB or b) Di can.
Slide 1 Logic: Domain Modeling /Proofs + Top-Down Proofs Jim Little UBC CS 322 – CSP October 22, 2014.
CS 403: Programming Languages Lecture 19 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
1 Knowledge Based Systems (CM0377) Lecture 4 (Last modified 5th February 2001)
Conjunctive normal form: any formula of the predicate calculus can be transformed into a conjunctive normal form. Def. A formula is said to be in conjunctive.
1 Chapter 8 Inference and Resolution for Problem Solving.
Logical Inference 2 rule based reasoning
Introduction To PROLOG World view of imperative languages. World view of relational languages. A PROLOG program. Running a PROLOG program. A PROLOG.
1 Knowledge Based Systems (CM0377) Lecture 3 (Last modified 5th February 2001)
CS 363 Comparative Programming Languages Logic Programming Languages.
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Kansas State University Department of Computing and Information Sciences CIS 730: Introduction to Artificial Intelligence Lecture 23 Friday, 17 October.
1 Logic Programming Robert Kowalski’s equation: Algorithm = Logic + Control Definite logic program: A  B 1, B 2, …, B m (program clause) headbody  A.
Web Science & Technologies University of Koblenz ▪ Landau, Germany Procedural Semantics Soundness of SLD-Resolution.
Kansas State University Department of Computing and Information Sciences CIS 730: Introduction to Artificial Intelligence Lecture 18 of 41 Friday, 01 October.
1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;
Negation Chapter 5. Stating Negative Conditions n Sometimes you want to say that some condition does not hold n Prolog allows this –not/1this is a predicate.
© Copyright 2008 STI INNSBRUCK Intelligent Systems Propositional Logic.
1 Knowledge Based Systems (CM0377) Lecture 6 (last modified 20th February 2002)
1 Propositional Logic Limits The expressive power of propositional logic is limited. The assumption is that everything can be expressed by simple facts.
Implementation: General Tree Search
Answer Extraction To use resolution to answer questions, for example a query of the form  X C(X), we must keep track of the substitutions made during.
1 Section 9.2 Logic Programming A logic program is a set of clauses with the restriction that there is exactly one positive literal in each clause. Such.
6/11/2016 Linear Resolution and Introduction to First Order Logic Michael Leuschel Softwaretechnik und Programmiersprachen Lecture 5.
Logic Programming Lecture 2: Unification and proof search.
Resolution in the Propositional Calculus
Logical Inference 2 Rule-based reasoning
Biointelligence Lab School of Computer Sci. & Eng.
Biointelligence Lab School of Computer Sci. & Eng.
Simply Logical – Chapter 5
CSE 3302 Programming Languages
Simply Logical – Chapter 3
Soundness of SLD-Resolution
Logical Inference 4 wrap up
Presentation transcript:

Simply Logical – Chapter 3© Peter Flach, 2000 Luc De Raedt and Andreas Karwath (original slides by Peter Flach) Fortgeschrittene Programmierung PROLOG Teil 3

Simply Logical – Chapter 3© Peter Flach, 2000 SLD Resolution and SLD Trees

Simply Logical – Chapter 3© Peter Flach, 2000 SLD resolution  Resolution in Prolog based on definite clause logic  definite clauses: one atom in the head  Resolution strategy: which literal and which input clause is chosen for resolution?  Strategy in Prolog is called SLD resolution: - S selection rule (in Prolog from left to right) - L linear resolution - D definite clauses  Leftmost literal in query is selected; clauses are selected in textual order  SLD trees: different from proof trees: only show resolvents, but all possible resolution steps  Prolog searches SLD tree depth-first !

Simply Logical – Chapter 3© Peter Flach, 2000 :-teaches(peter,ai_techniques) :-teaches(peter,expert_systems) :-teaches(peter,computer_science) ?-student_of(S,peter) SLD-tree :-follows(S,C),teaches(peter,C) :-teaches(peter,expert_systems) :-teaches(peter,computer_science) :-teaches(peter,ai_techniques) ?-student_of(S,peter) student_of(X,T):-follows(X,C),teaches(T,C). follows(paul,computer_science). follows(paul,expert_systems). follows(maria,ai_techniques). teaches(adrian,expert_systems). teaches(peter,ai_techniques). teaches(peter,computer_science). p.44-5 []

Simply Logical – Chapter 3© Peter Flach, 2000 Infinite SLD-trees brother_of(X,Y):-brother_of(Y,X). brother_of(paul,peter). brother_of(paul,peter). brother_of(peter,adrian). brother_of(X,Y):-brother_of(X,Z), brother_of(Z,Y). ?-brother_of(paul,B) [] :-brother_of(paul,Z),brother_of(Z,B) :-brother_of(paul,Z1),brother_of(Z1,Z),brother_of(Z,B):-brother_of(peter,B) [] :-brother_of(peter,Z),brother_of(Z,B) :-brother_of(B,peter) [] ?-brother_of(peter,B) :-brother_of(peter,B) :-brother_of(B,peter) [] p.45-6

Simply Logical – Chapter 3© Peter Flach, 2000 Depth-first search ?-plist(L) plist([]). plist([H|T]):- p(H),plist(T). p(1).p(2). [] L = [] p.47 :-p(H1),plist(T1) :-plist(T1) [] L = [1] :-p(H1),plist(T1) :-plist(T1) [] L = [1,1] :-plist(T1) [] L = [1,2] [] L = [2] :-p(H1),plist(T1) :-plist(T1) [] L = [2,1] [] L = [2,2] ?-plist(L). L=[]; L=[1]; L=[1,1]; …

Simply Logical – Chapter 3© Peter Flach, 2000 Summary  First problem:  trapped in infinite subtrees  Prolog is incomplete by the way the SLD tree is searched (depth-first; a deliberate design decision for memory efficiency)  if breadth-first search were used, then it would be refutation complete!  Second problem:  looping if no (further) solution for any infinite SLD tree  due to semi-decidability of full clausal logic (infinity of Herbrand base)

Simply Logical – Chapter 3© Peter Flach, 2000 Programming Example: Monkey and banana

Simply Logical – Chapter 3© Peter Flach, 2000 Problem: Monkey and Banana  The Problem  There is a monkey at the door into a room. In the middle of the room a banana is hanging from the ceiling. The monkey is hungry and wants to get the banana, but he cannot stretch high enough from the floor. At the window of the room there is a box that the monkey can use. The monkey can perform the following actions: walk on the floor, climb the box, push the box around (if he is already at it), and grasp the banana if he is standing on the box and directly underneath the banana.  Can the monkey grasp the banana?

Simply Logical – Chapter 3© Peter Flach, 2000 banana Problem: Monkey and Banana door window box mokey middle

Simply Logical – Chapter 3© Peter Flach, 2000 Monkey and Banana: States state( MR, MB, P, B ) Monkey‘s Room Position at_door middle at_window Monkey‘s Box Position on_floor on_box Box Position at_door middle at_window Banana has has_not

Simply Logical – Chapter 3© Peter Flach, 2000 Monkey and Banana: Actions I Possible actions: walk, push, climb, grasp Defined using: move(OldState, Action, NewState) OldStateNewState Action

Simply Logical – Chapter 3© Peter Flach, 2000 Monkey and Banana: Actions II  Grasp Banana: move(state(middle, on_box, middle, has_not), grasp, state(middle, on_box, middle, has) ). move(state(P, on_floor, P, H), climb, state(P, on_box, P, H)).  Climb Box:

Simply Logical – Chapter 3© Peter Flach, 2000 Monkey and Banana: Actions III  Push Box: move(state(P1, on_floor, P1, H), push(P1, P2), state(P2, on_floor, P2, H)). move(state(P1, on_floor, P, H), walk(P1, P2), state(P2, on_floor, P, H)).  Walk:

Simply Logical – Chapter 3© Peter Flach, 2000 Monkey and Banana: Actions Summary move(state(middle, on_box, middle, has_not), grasp, state(middle, on_box, middle, has)). move(state(P, on_floor, P, H), climb, state(P, on_box, P, H)). move(state(P1, on_floor, P1, H), push(P1, P2), state(P2, on_floor, P2, H)). move(state(P1, on_floor, P, H), walk(P1, P2), state(P2, on_floor, P, H)).

Simply Logical – Chapter 3© Peter Flach, 2000 Monkey and Banana: Goals  How can the monkey get the banana? canget(state(_, _, _, has)). canget(OldState) :- move(OldState, Move, NewState), canget(NewState). Can the monkey get the banana from the initial state? ?- canget( state(at_door, on_floor,at_window, has_not)).

Simply Logical – Chapter 3© Peter Flach, 2000 Monkey and Banana: Summary move(state(middle, on_box, middle, has_not), grasp, state(middle, on_box, middle, has)). move(state(P, on_floor, P, H), climb, state(P, on_box, P, H)). move(state(P1, on_floor, P1, H), push(P1, P2), state(P2, on_floor, P2, H)). move(state(P1, on_floor, P, H), walk(P1, P2), state(P2, on_floor, P, H)). canget(state(_, _, _, has)). canget(OldState) :- move(OldState, Move, NewState), canget(NewState).

Simply Logical – Chapter 3© Peter Flach, 2000 Monkey and Banana: Trace | ?- canget(state(at_door,on_floor,at_window,hasnot)). Call: canget(state(at_door,on_floor,at_window,hasnot)) ? Call: move(state(at_door,on_floor,at_window,hasnot),_989,_990) ? Exit: move(state(at_door,on_floor,at_window,hasnot),walk(at_door,_1476),state(_1476,on_floor,at_window,hasnot)) ? Call: canget(state(_1476,on_floor,at_window,hasnot)) ? Call: move(state(_1476,on_floor,at_window,hasnot),_2415,_2416) ? Exit: move(state(at_window,on_floor,at_window,hasnot),climb,state(at_window,on_box,at_window,hasnot)) ? Call: canget(state(at_window,on_box,at_window,hasnot)) ? Call: move(state(at_window,on_box,at_window,hasnot),_3841,_3842) ? Fail: move(state(at_window,on_box,at_window,hasnot),_3841,_3842) ? Fail: canget(state(at_window,on_box,at_window,hasnot)) ? Redo: move(state(at_window,on_floor,at_window,hasnot),climb,state(at_window,on_box,at_window,hasnot)) ? Exit: move(state(at_window,on_floor,at_window,hasnot),push(at_window,_2902),state(_2902,on_floor,_2902,hasnot)) ? Call: canget(state(_2902,on_floor,_2902,hasnot)) ? Call: move(state(_2902,on_floor,_2902,hasnot),_3844,_3845) ? Exit: move(state(_2902,on_floor,_2902,hasnot),climb,state(_2902,on_box,_2902,hasnot)) ? Call: canget(state(_2902,on_box,_2902,hasnot)) ? Call: move(state(_2902,on_box,_2902,hasnot),_5270,_5271) ? Exit: move(state(middle,on_box,middle,hasnot),grasp,state(middle,on_box,middle,has)) ? Call: canget(state(middle,on_box,middle,has)) ? Exit: canget(state(middle,on_box,middle,has)) ? Exit: canget(state(middle,on_box,middle,hasnot)) ? Exit: canget(state(middle,on_floor,middle,hasnot)) ? Exit: canget(state(at_window,on_floor,at_window,hasnot)) ? Exit: canget(state(at_door,on_floor,at_window,hasnot)) ? yes

Simply Logical – Chapter 3© Peter Flach, 2000 Monkey and Banana: Notes  Order of clauses in monkey-banana example: 1. grasp 2. climb 3. push 4. walk  Changing this order can cause Prolog to loop indefinitely !