Week 3 Help desks – Mon 4-5 CO238 Tutor: Su – Wed 1-2 CO238 Tutor: Urvesh – Fri 11-12 CO238 Tutor: Bing Lectures: Mon, Tue, 3-4, HU119 Tutorial: Fri, 3-4,

Slides:



Advertisements
Similar presentations
3. Lists, Operators, Arithmetic. Contents Representation of lists Some operations on lists Operator notation Arithmetic.
Advertisements

Computer Science CPSC 322 Lecture 25 Top Down Proof Procedure (Ch 5.2.2)
1 Knowledge Based Systems (CM0377) Lecture 11 (Last modified 26th March 2001)
EXPERT SYSTEMS AND KNOWLEDGE REPRESENTATION Ivan Bratko Faculty of Computer and Info. Sc. University of Ljubljana.
Introduction to PROLOG ME 409 Lab - 1. Introduction to PROLOG.
Expert Systems Reasonable Reasoning An Ad Hoc approach.
CHAPTER 13 Inference Techniques. Reasoning in Artificial Intelligence n Knowledge must be processed (reasoned with) n Computer program accesses knowledge.
1 Rule Based Systems Introduction to Production System Architecture.
Expert Systems Reasonable Reasoning An Ad Hoc approach.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Prolog COMP 112 #
1 Antecedent-Consequent Rules Rn:IF condition 1 condition 2... THEN consequent 1 consequent 2...
COSC 2006 Chapter 7 Stacks III
Knowledge Representation CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Reasoning Forward and Backward Chaining Andrew Diniz da Costa
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.
Inferences The Reasoning Power of Expert Systems.
Formal Logic Mathematical Structures for Computer Science Chapter 1 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesFormal Logic.
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,
Comp 307 Lecture 4:1 Prolog I, II Prolog was taught as a procedural language Control structures: if, while, recursion Data structures: structured terms,
Intelligent systems Lecture 6 Rules, Semantic nets.
Knowledge Engineering.  Process of acquiring knowledge from experts and building knowledge base  Narrow perspective  Knowledge acquisition, representation,
Artificial Intelligence Lecture No. 16
Chapter 12: Expert Systems Design Examples
Knowledge Representation and Expert Systems by Sujan Pakala Stephen Brown.
Rule Based Systems Alford Academy Business Education and Computing
Expert System Human expert level performance Limited application area Large component of task specific knowledge Knowledge based system Task specific knowledge.
1 Pertemuan 6 RULE-BASED SYSTEMS Matakuliah: H0383/Sistem Berbasis Pengetahuan Tahun: 2005 Versi: 1/0.
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.
© C. Kemke1Reasoning - Introduction COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba.
Production Rules Rule-Based Systems. 2 Production Rules Specify what you should do or what you could conclude in different situations. Specify what you.
EXPERT SYSTEMS Part I.
CPSC 433 Artificial Intelligence CPSC 433 : Artificial Intelligence Tutorials T01 & T02 Andrew “M” Kuipers note: please include.
Artificial Intelligence CSC 361
1 Backward-Chaining Rule-Based Systems Elnaz Nouri December 2007.
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
Data Structures Lecture : Stacks (Infix, Postfix and Prefix Expressions) Azhar Maqsood NUST Institute of Information Technology (NIIT)
CSCI 4310 Lecture 7: Rule Systems. Book Winston Chapter 7.
13: Inference Techniques
1 Lecture Expert Systems &. 2 Operator Notation A programmer can define new operators by inserting into the program special kinds of clauses,
Chapter 13 Artificial Intelligence and Expert Systems.
1 Prolog and Logic Languages Aaron Bloomfield CS 415 Fall 2005.
Rule Based Systems  If then  Rules to solve problems  What is forward chaining?  What is backward chaining?  Expert systems.
Soft Computing Lecture 19 Part 2 Hybrid Intelligent Systems.
CS62S: Expert Systems Based on: The Engineering of Knowledge-based Systems: Theory and Practice, A. J. Gonzalez and D. D. Dankel.
Logical Agents Chapter 7. Outline Knowledge-based agents Logic in general Propositional (Boolean) logic Equivalence, validity, satisfiability.
KNOWLEDGE BASED SYSTEMS
Computer Science CPSC 322 Lecture 22 Logical Consequences, Proof Procedures (Ch 5.2.2)
Chapter 4: Inference Techniques
1 Knowledge Based Systems (CM0377) Introductory lecture (Last revised 28th January 2002)
1 Artificial Intelligence Adina Magda Florea. 2 Lecture No. 6 Prolog Language Rule-based Systems Knowledge representation using rules RBS structure Inference.
Cs774 (Prasad)L4ListProcessing1 List processing in Prolog
Chapter 9. Rules and Expert Systems Fall 2013 Comp3710 Artificial Intelligence Computing Science Thompson Rivers University.
Logic: Proof procedures, soundness and correctness CPSC 322 – Logic 2 Textbook §5.2 March 7, 2011.
Forward and Backward Chaining
Expert System Seyed Hashem Davarpanah University of Science and Culture.
Chapter Three: Operators, Arithmetic 1. Chapter three: 3.3Operator notation 3.4Arithmetic 2.
Artificial Intelligence: Applications
Chapter 13 Artificial Intelligence. Artificial Intelligence – Figure 13.1 The Turing Test.
EXPERT SYSTEMS.
Chapter 9. Rules and Expert Systems
Artificial Intelligence (CS 370D)
Artificial Intelligence CS370D
EXPERT SYSTEMS.
Forward Chaining DFS can supply compatible bindings for forward chaining.
Knowledge Representation and Inference
CPSC 433 : Artificial Intelligence Tutorials T01 & T02
EXPERT SYSTEMS AND KNOWLEDGE REPRESENTATION Ivan Bratko Faculty of Computer and Info. Sc. University of Ljubljana.
Chapter 9. Rules and Expert Systems
Presentation transcript:

Week 3 Help desks – Mon 4-5 CO238 Tutor: Su – Wed 1-2 CO238 Tutor: Urvesh – Fri CO238 Tutor: Bing Lectures: Mon, Tue, 3-4, HU119 Tutorial: Fri, 3-4, HU119 Comp 307Lecture 19:1

Comp 307 Knowledge based systems Reasoning Backward chaining Forward chaining Reasoning implemented in Prolog More on Knowledge representation More on reasoning Challenges

Comp 307 Simple Rule-based System in Prolog mammal:-f(hair). mammal:-f(milk). bird:-f(feathers). bird:-f(eggs), f(flies). carnivore:-mammal, f(meat). classify(tiger):-carnivore, f(tawny), f(striped). classify(puma):-carnivore, f(black). f(hair). f(black). f(meat). |?-classify(X). X=puma.

An example classify.pl – Prolog – Knowledge in a special rule language – Expert system shell/tool – Backward chaining Available on lecture page It will ask questions, just answer “yes” or “no”, can ask “why”. Comp 307Lecture 19:4

Comp 307 Rule Language for the KnowledgeBase Defining the operators :- op(511, xfx, ::). :- op(505, fx, if). :- op(503, xfx, then). :- op(501, xfy, and). rule4:: if eggs and flies then bird. ::(rule4,if(then(and(eggs, flies),bird))).

Comp 307 An animal classifier: The knowledge base rule1:: if hair then mammal. rule2:: if milk then mammal. rule3:: if feathers then bird. rule4:: if eggs and flies then bird. rule5:: if mammal and meat then carnivore. rule6:: if mammal and claws and pointed_teeth and forward_eyes then carnivore. rule9:: if carnivore and tawny and striped then tiger. rule11::if carnivore and black then puma. askable(hair). askable(milk).... hypothesis(tiger). hypothesis(puma)....

Comp 307 Backward chaining classify:- hypothesis(Goal), confirm(Goal). confirm(Goal):- RuleNo:: if Preconds then Goal, confirm(Preconds). confirm(Condition1 and Condition2):- confirm(Condition1),!, confirm(Condition2). confirm(Condition):- askable(Condition), fact(Condition, yes).

Comp 307 Backward Chaining Interpreter Input: Goal G, Set S of rules and facts Output: yes if G is logically implied by S; no otherwise Initialize current goal to G; repeat Choose a goal A from the set of current goals; if A is a fact in S then remove A from current set of goals else if there is no rule in S whose head is A then exit and output no else begin Choose a rule A :-Body in S, where Body is a set of goals Remove A from current set of goals; Add Body to the current set of goals; end until the current set of goals is empty output yes ;

Comp 307 Backward Chaining: Example Goal: u u  w, p. v  n, r. w  r. p  a, b. q  a, c, d. r  e, p. a b e n

Comp 307 Operators in Prolog Examples of operators: :- ?-, ; + - * / is Operator declarations e.g. :- op(1200, fx, ?-). :- op(1200, xfx, :-). :- op(1000, xfy,,). :- op(700, xfx, is). :- op(500, yfx, [+,-]). :- op(400, yfx, [*,/]).

Comp 307 Operators in Prolog Operator precedence is represented as a number (A higher number means a lower precedence.) Operator types: xfx binary, infix, not associative xfy binary, infix, right-associative yfx binary, infix, left-associative fx,fy unary, prefix xf,yf unary, postfix

Comp 307 Operator Precedence and Parse Trees :- op(1200, xfx, :-). :- op(700, xfx, is). :- op(500, yfx, [+,-]). add(X,Y,Z) :- Z is X + Y Internal (term) representation: :- (add(X,Y,Z), is(Z,+(X,Y))). :- (1200) add(X,Y,Z)is (700) + (500)Z XY

Comp 307 Design your own rules in prolog :-op(800, fx, if). :-op(700, xfx, then). :-op(300, xfy, or). :-op(200, xfy, and). If hall_wet and kitchen_dry then leak_in_bathroom. if window_closed or no_rain then no_water_from_outside. fact(hall_wet). fact(bathroom_dry). fact(no_rain).

Comp 307 backward-chaining Pick one hypothesis Find the rule Verify each condition in the body of the rule – Each condition as a new goal

Comp 307 Backward chaining in Prolog is_true(p):- fact(p). is_true(P):- if Condition then P, is_true (Condition). is_true(P1 and P2):- is_true(P1), is_true(P2). is_true(P1 or P2):- is_true(P1) ; is_true(P2).

Comp 307 Forward Chaining Data driving, Data directed reasoning, bottom up – Search from facts to valid conclusions Given database of true facts: – Apply all rules that match facts in the database – Add conclusions to database – Repeat until a goal is reached OR – Repeat until no new facts added

Comp 307 Forward Chaining Interpreter Input: a set of goals G, Set S of rules and facts Output: An element of G logically implied by S Initialize working memory to facts in S; Repeat Choose a rule A:- Body in S; if Body is a subset of working memory then if A is not in working memory then add A to working memory until an element of G is in working memory; output the element of G in working memory

Comp 307 Forward Chaining: Example Goal: u u  w, p. v  n, r. w  r. p  a, b. q  a, c, d. r  e, p. a b e n

Comp 307 Design your own rules in prolog :-op(800,fx,if). :-op(700, xfx, then). :-op(300,xfy,or). :-op(200,xfy,and). If hall_wet and kitchen_dry then leak_in_bathroom. if window_closed or no_rain then no_water_from_outside. fact(hall_wet). fact(bathroom_dry).

Comp 307 Forward Chaining in Prolog :-dynamic fact/1. farward:- new_derived_fact(P),!, assert(fact(P)), farward. farward:-write(‘no more facts’). new_derived_fact(Conclusion):- if Cond then Conclusion, \+ fact(Conclusion), composed_fact(Cond). composed_fact(Cond):-fact(Cond). composed_fact(Cond1 and Cond2):- composed_fact(Cond1), composed_fact(Cond2). composed_fact(Cond1 or Cond2):- composed_fact(Cond1) ; composed_fact(Cond2).

Comp 307 Backward Chaining and Forward Chaining Backward chaining (Goal driving, Goal-directed reasoning, top-down) – Search from hypotheses to relevant facts Good when: – Limited number of hypotheses – Determining truth of facts costs – Very large number of possible facts, mostly irrelevant Forward chaining (Data driving, Data-directed reasoning, bottom-up) – Search from facts to valid conclusions Good when – Very large number of possible conclusions – True facts known at start Bi-directional reasoning

Knowledge Representation and reasoning More Knowledge Representation – Decision trees – Decision tables – Belief nets – Fuzzy logic – Neural networks – … Reasoning – Case based reasoning Knowledge: Cases and modification rules Reasoning: find similar case and adapt – … Comp 307

Decision Tables diethabitat coloranimal meatjungle stripedtiger meathouse stripedtabby grassplains stripedzebra meatjungle brownweasel Example Rules: tiger  meat  jungle  striped jungle<-- meat /\ striped /\ tiger

Comp 307 Decision Tree Diet? grass meat zebra Color? weasel brown Habitat? striped tiger tabby house jungle

Knowledge based systems Challenges and limitations – Knowledge acquisition – Conflict resolution – Uncertainty – Common sense – …… Comp 307