(FO) Inference Methods CPSC 386 Artificial Intelligence Ellen Walker Hiram College.

Slides:



Advertisements
Similar presentations
Some Prolog Prolog is a logic programming language
Advertisements

1 Knowledge Based Systems (CM0377) Lecture 11 (Last modified 26th March 2001)
Inference Rules Universal Instantiation Existential Generalization
Chapter 11 :: Logic Languages
1 Rule Based Systems Introduction to Production System Architecture.
Automated Deduction resolution (Otter) backward-chaining (Prolog)
For Friday No reading Homework: –Chapter 9, exercise 4 (This is VERY short – do it while you’re running your tests) Make sure you keep variables and constants.
COMPUTER PROGRAMMING I Essential Standard 5.02 Understand Breakpoint, Watch Window, and Try And Catch to Find Errors.
Knowledge Representation CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
INTRODUCTION TO PROLOG. PROLOG BASICS Atoms - most primitive terms that the language manipulates start with lower case letter includes strings (‘inside.
Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Logic.
CS 484 – Artificial Intelligence1 Announcements Choose Research Topic by today Project 1 is due Thursday, October 11 Midterm is Thursday, October 18 Book.
The CLIPS Programming Tool History of CLIPS –Influenced by OPS5 and ART –Implemented in C for efficiency and portability –Developed by NASA, distributed.
Expert System Shells - Examples
Conflict Resolution  what to do if there is more than 1 matching rule in each inference cycle? match WM with LHS of rules select one rule (conflict resolution)
B. Ross Cosc 4f79 1 Forward chaining backward chaining systems: take high-level goal, and prove it by reducing it to a null goal - to reduce it to null,
1 01/12/2011Knowledge-Based Systems, Paula Matuszek Intro to CLIPS Paula Matuszek CSC 9010, Spring, 2011.
November 2, 2004AI: CLIPS Language Tutorial1 Artificial Intelligence CLIPS Language Tutorial Michael Scherger Department of Computer Science Kent State.
Simple Rule Based Systems Directly implementing rule based systems in Java Need vocabulary Simplicity sometimes works.
Chapter 7: Introduction to CLIPS
Rule Based Systems Michael J. Watts
For Friday Read “lectures” 1-5 of Learn Prolog Now: prolog-now/
Chapter 12: Expert Systems Design Examples
Expert System Human expert level performance Limited application area Large component of task specific knowledge Knowledge based system Task specific knowledge.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
Introduction to CLIPS (Chapter 7) Fact List (contains data) Knowledge Base (contains rules) Inference Engine (controls execution)
1 Chapter 9 Rules and Expert Systems. 2 Chapter 9 Contents (1) l Rules for Knowledge Representation l Rule Based Production Systems l Forward Chaining.
Rules and Expert Systems
© C. Kemke Control 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba.
CS 561, Session 25 1 Introduction to CLIPS Overview of CLIPS Facts Rules Rule firing Control techniques Example.
INFERENCE IN FIRST-ORDER LOGIC IES 503 ARTIFICIAL INTELLIGENCE İPEK SÜĞÜT.
Formal Models of Computation Part II The Logic Model
1 Programming a Knowledge Based Application. 2 Overview.
Chapter 7: Introduction to CLIPS Expert Systems: Principles and Programming, Fourth Edition.
14/10/04 AIPP Lecture 7: The Cut1 Controlling Backtracking: The Cut Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 7 14/10/04.
Pattern-directed inference systems
For Wednesday Read “lectures” 7-10 of Learn Prolog Now Chapter 9, exs 4 and 6. –6 must be in Horn clause form Prolog Handout 2.
Jess: A Rule-Based Programming Environment Reporter: Yu Lun Kuo Date: April 10, 2006 Expert System.
March 14, 2006AI: Chapter 9: Inference in First- Order Logic 1 Artificial Intelligence Chapter 9: Inference in First- Order Logic Michael Scherger Department.
First Order Predicate Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
1 Prolog and Logic Languages Aaron Bloomfield CS 415 Fall 2005.
Expert System Note: Some slides and/or pictures are adapted from Lecture slides / Books of Dr Zafar Alvi. Text Book - Aritificial Intelligence Illuminated.
Expert Systems Chapter 7 Introduction to CLIPS Entering and Exiting CLIPS A> CLIPS  CLIPS (V6.5 09/01/97) CLIPS> exit exit CLIPS> (+ 3 4)  7 CLIPS>
CPSC 386 Artificial Intelligence Ellen Walker Hiram College
Rule-based Systems: Mechanisms & Efficiency Artificial Intelligence CMSC January 10, 2002.
Artificial Intelligence Lecture No. 24 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
1 Knowledge Based Systems (CM0377) Lecture 10 (Last modified 19th March 2001)
© Copyright 2008 STI INNSBRUCK Intelligent Systems Propositional Logic.
Artificial Intelligence Lecture No. 19 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Knowledge Based Information System
Subtractive Manufacturing Exercise #1 Step #2 Key Fob Project Using Velocity CNC Software for the CNC Milling Machine Note: In order to use this set of.
In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction.
Introduction to Prolog Asst. Prof. Dr. Senem Kumova Metin Revised lecture notes of “Concepts of Programmig Languages, Robert W. Sebesta, Ch. 16”
Forward and Backward Chaining
More Symbolic Learning CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Proof Methods for Propositional Logic CIS 391 – Intro to Artificial Intelligence.
Intelligent systems Lecture 11 Tools for development of Expert Systems.
The CLIPS Expert System Shell Dr Nicholas Gibbins
Artificial Intelligence: Applications
The portion of a Prolog interpreter that executes queries (goals) is known as the inference engine. An inference engine is a kind of theorem prover, using.
Summary for final exam Agent System..
Section 16.5, 16.6 plus other references
EA C461 Artificial Intelligence
Presented By S.Yamuna AP/CSE
Rules: Knowledge Representation & Manipulation
For Wednesday Read “lectures” 7-10 of Learn Prolog Now:
Chapter 7: Introduction to CLIPS
Knowledge Representation and Inference
بسم الله الرحمن الرحیم آموزش نرم افزار CLIPS
Presentation transcript:

(FO) Inference Methods CPSC 386 Artificial Intelligence Ellen Walker Hiram College

Inference Methods Unification (prerequisite) Forward Chaining –Production Systems –RETE Method (OPS) Backward Chaining –Logic Programming (Prolog) Resolution –Transform to CNF –Generalization of Prop. Logic resolution

Forward Chaining Given a new fact, generate all consequences Assumes all rules are of the form –C1 and c2 and c3 and…. --> result Each rule & binding generates a new fact This new fact will “trigger” other rules Keep going until the desired fact is generated (Semi-decidable as is FOL in general)

Efficient Forward Chaining Order conjuncts appropriately –E.g. most constrained variable Don’t generate redundant facts; each new fact should depend on at least one newly generated fact. –Production systems –RETE matching –CLIPS (on CS)

OPS Facts –Type, attributes & values –(goal put-on yellow-block red-block) Rules –If conditions, then action. –Variables (,, etc) can be bound –If (goal put-on ) AND – (clear ) THEN add (goal clear )

RETE Network Based only on Left Sides (conditions) of rules Each condition (test) appears once in the network Tests with “AND” are connected with “JOIN” –Join means all tests work with same bindings

Example Rules 1. If (goal put-on ) AND (clear ) AND (clear ) THEN add (on ) delete (clear ) 2.If (goal clear ) AND (on ) AND (clear ) THEN add (clear ) add (on table) delete (on ) 3.If (goal clear ) AND (on ) THEN add (goal clear ) 4.If (goal put-on ) AND (clear ) THEN add (goal clear ) 5.If (goal put-on ) AND (clear ) THEN add (goal clear )

RETE Network

Using the RETE Network Each time a fact comes in… –Update bindings for the relevant node (s) –Update join(s) below those bindings –Note new rules satisfied Each processing cycle –Choose a satisfied rule

Example (Facts) 1. (goal put-on yellow-block red-block) 2. (on blue-block yellow-block) 3. (on yellow-block table) 4. (on red-block table) 5. (clear red-block) 6. (clear blue-block)

Why RETE is Efficient Rules are “pre-compiled” Facts are dealt with as they come in –Only rules connected to a matching node are considered –Once a test fails, no nodes below are considered –Similar rules share structure In a typical system, when rules “fire”, new facts are created / deleted incrementally –This incrementally adds / deletes rules (with bindings) to the conflict set

CLIPS CLIPS is a forward-chaining production system that uses the RETE method. Important commands –(assert fact) (deffacts fact1 fact2 … ) –(defrule rule-name rule) –(reset) - eliminates all facts except “initial-fact” –(load file) (load-facts file) –(run) –(watch all) –(exit)

CLIPS Rule Example (defrule putting-on ?g <- (goal put-on ?x ?y) (clear ?x) ?bottomclear <- (clear ?y) ==> (assert (on ?x ?y)) (retract ?g) (retract ?bottomclear) )

Blocks example (load “blocks.clp”) (assert (on blue table)) (assert (clear blue)) (assert (on red table)) (assert (on green red)) (assert (clear green) (assert (goal put-on red blue)) (watch all) (run)

Backward Chaining Consider the item to be proven a goal Find a rule whose head is the goal (and bindings) Apply bindings to the body, and prove these (subgoals) in turn If you prove all the subgoals, increasing the binding set as you go, you will prove the item. Logic Programming (gprolog, on CS)

Prolog Rules Rule Example –puton(X,Y) :- cleartop(X), cleartop(Y),takeoff(X,Y). Capital letters are variables Three parts to the rule –Head (thing to prove) –Neck:- –Body (subgoals, separated by,) Rules end with.

Prolog Environment SWI-Prolog on windows – to start, double-click plwin To read a file, consult(‘file’). To enter data directly, consult(user). Type control-D when done. Every statement must end in a period. If you forget, put it on the next line. To prove a fact, enter the fact directly at the command line. gprolog will respond Yes, No, or give you a binding set. If you want another answer, type ; otherwise return. Trace(predicate) or trace(all) will allow you to watch the backward chaining process.

Monkey and Banana in Prolog movedTo(X,Y) :- at(X,Y,Z). movedTo(monkey,Y) :- at(monkey,X,floor), write('Walk to '), write(Y), nl. movedTo(ladder,Y) :- at(ladder,X,floor), movedTo(monkey,X), write('Drag ladder to '), write(Y), nl. reachable(X) :- at(X,Y,ceiling), movedTo(ladder,Y), movedTo(monkey,Y). reach(X) :- reachable(X), write('Reach for '), write(X), nl.

Running the Monkey & Banana consult(user). compiling user for byte code... at(monkey,corner,floor). at(ladder,left,floor). at(banana,center,ceiling). Control-D reach(banana).

In-class assignment Try the following in both Prolog and Clips: –Define the concept of a prerequisite, and at least the following facts: Prerequisite of 172 is 171Prerequisite of 201 is 172 Prerequisite of 400 is 201Prerequisite of 386 is 172 –Create a rule that a course cannot be taken unless its prerequisite has been taken –Create facts to indicate that Mary has taken 172 and 171. –Prove the following in your system: Mary can take 386, Mary cannot take 400