CPSC 433 Artificial Intelligence Rule Based Systems (Prolog) M. Reza Zakerinasab Please include [CPSC433] in the subject line of any.

Slides:



Advertisements
Similar presentations
This is a template, please replace this with your data This file is at a 4 x 3 resolution This file has a 10 slides On the first slide of your presentation.
Advertisements

Set Based Search Modeling Examples II
Computational Models The exam. Models of computation. –The Turing machine. –The Von Neumann machine. –The calculus. –The predicate calculus. Turing.
Prolog.
Nonstandard Problmes Produced by E. Gretchen Gascon.
(FO) Inference Methods CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
CSE 425: Logic Programming I Logic and Programs Most programs use Boolean expressions over data Logic statements can express program semantics –I.e., axiomatic.
For Friday Read “lectures” 1-5 of Learn Prolog Now: prolog-now/
Logic Programming Language (Natural Language Processing)
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Controlling Backtracking Notes for Ch.5 of Bratko For CSCE 580 Sp03 Marco Valtorta.
C LAUS B RABRAND Inference Systems J AN 27, 2009 I NFERENCE S YSTEMS Claus Brabrand IT University of Copenhagen [
Research on Intelligent Information Systems Himanshu Gupta Michael Kifer Annie Liu C.R. Ramakrishnan I.V. Ramakrishnan Amanda Stent David Warren Anita.
Formal Aspects of Computer Science – Week 12 RECAP Lee McCluskey, room 2/07
Automated Reasoning ARTIFICIAL INTELLIGENCE 6th edition George F Luger
CPSC 433 Artificial Intelligence CPSC 433 : Artificial Intelligence Tutorials T01 & T02 Andrew “M” Kuipers note: please include.
INFERENCE IN FIRST-ORDER LOGIC IES 503 ARTIFICIAL INTELLIGENCE İPEK SÜĞÜT.
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
FATIH UNIVERSITY Department of Computer Engineering Controlling Backtracking Notes for Ch.5 of Bratko For CENG 421 Fall03.
“ A language that doesn’t affect the way you think about programming, is not worth knowing”
CS 2104 – Prog. Lang. Concepts Logic Programming - II Dr. Abhik Roychoudhury School of Computing.
CS 403: Programming Languages Lecture 19 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
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.
For Wednesday No new reading Prolog handout 2 Chapter 9, exercise 4.
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.
Comp Programming Languages Proposal 1 All humans possess a common logical structure which operates independently of language Proposal 2 Language.
CT214 – Logical Foundations of Computing Lecture 8 Introduction to Prolog.
CPSC 433 Artificial Intelligence Search Modeling Practice Problems M. Reza Zakerinasab Please include [CPSC433] in the subject line.
1 Prolog and Logic Languages Aaron Bloomfield CS 415 Fall 2005.
Type your question here. Type Answer Type your question here. Type Answer.
CS4026 Formal Models of Computation Part II The Logic Model Lecture 2 – Prolog: History and Introduction.
Computing & Information Sciences Kansas State University Monday, 25 Sep 2006CIS 490 / 730: Artificial Intelligence Lecture 14 of 42 Monday, 25 September.
For Monday Read “lectures” 1-5 of Learn Prolog Now: prolog-now/
COMP307 Artificial Intelligence Xiaoying Gao Victoria University of Wellington Lecture 2:1 
Logic Programming Dr. Yasser Nada Fall 2010/2011 Lecture 1 1 Logic Programming.
Invitation to Computer Science, Java Version, Second Edition 1 Logic Programming Logic programming  Various facts are asserted to be true  On the basis.
Knowledge Based Information System
CPSC 433 Artificial Intelligence Set Based Search Modeling Examples Andrew Kuipers Please include [CPSC433] in the subject line.
CS182 Intelligent Machines: Reasoning, Actions and Plans Section 4.
In The Name Of Allah Lab 03 1Tahani Aldweesh. objectives Searching for the solution’s. Declaration. Query. Comments. Prolog Concepts. Unification. Disjunction.
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.
CPSC 433 Artificial Intelligence Unification & Resolution Examples Andrew Kuipers Please include [CPSC433] in the subject line.
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.
Pengenalan Prolog Disampaikan Oleh : Yusuf Nurrachman, ST, MMSI.
1 TP #4: Control Facilities n Last TP exercises solved; n Don’t care variables « _ »; n Or « ; »; n Cut.
Calculator Tricks 7 By Brian Carruthers (Please see notes on slide 1)
Chapter 9. Rules and Expert Systems
For Friday No reading Prolog handout 3 Chapter 9, exercises 9-11.
For Wednesday Read “lectures” 7-10 of Learn Prolog Now:
How to Download and Install Windows Live Messenger
Twenty Questions Subject:.
CPSC 433 : Artificial Intelligence Tutorials T01 & T02
Twenty Questions Subject:.
Prolog sword(Lancelot) sword(Arthur) shield(Lancelot) shield(Arthur)
Twenty Questions Subject:.
Twenty Questions Subject:.
Twenty Questions Subject:.
Twenty Questions Subject:.
Twenty Questions Subject:.
Twenty Questions Subject:.
Prolog Concepts.
Logical Inference 4 wrap up
Standard Form – Multiplying & Dividing – Calculator
Standard Form – Multiplying & Dividing – Non-Calculator
Twenty Questions Subject:.
Twenty Questions Subject:.
Standard Form & Ordinary Numbers – Converting
Standard Form & Ordinary Numbers – Converting
Challenge Guide Grade Code Type Slides
Sequences – Introduction – Foundation – GCSE Questions
Presentation transcript:

CPSC 433 Artificial Intelligence Rule Based Systems (Prolog) M. Reza Zakerinasab Please include [CPSC433] in the subject line of any s regarding this course. Slides originally created by Andrew M Kuipers. Some slides adopted from /425 Declarative Methods - J. Eisner

2 Prolog as constraint programming An ordinary constraint between two variables: Person and Food Prolog makes you name this constraint. Here’s a program that defines it: –eats(sam, dal).eats(josie, samosas). –eats(sam, curry).eats(josie, curry). –eats(rajiv, dal). … Now it acts like a subroutine! At the Prolog prompt you can type –eats(Person1, Food1). % constraint over two variables –eats(Person2, Food2). % constraint over two other variables (Person, Food) PersonFood samdal samcurry josiesamosas josiecurry rajivdal CPSC 433 Artificial Intelligence

3 Using Prolog –eats(sam, dal).eats(josie, samosas). –eats(sam, curry).eats(josie, curry). –eats(rajiv, burgers).eats(rajiv, dal). … –eats(Person1, Food), eats(Person2, Food). Person1=sam, Person2=josie, Food=curry Person1=josie, Person2=sam, Food=curry … Your program file (compiled) Sometimes called the “database” “Query” that you type interactively Prolog’s answer CPSC 433 Artificial Intelligence

Adding more rules… eats(sam, dal).eats(josie, samosas). eats(sam, curry).eats(josie, curry). eats(rajiv, burgers).eats(rajiv, dal). compatible(Person1, Person2) :- eats(Person1, Food), eats(Person2, Food). compatible(Person1, Person2) :- watches(Person1, Movie), watches(Person2, Movie). compatible(hal, Person2) :- female(Person2), rich(Person2).

CPSC 433 Artificial Intelligence Basic Prolog Process Negate query, set as current goal. while current goal is non-empty: choose the leftmost subgoal if a rule applies to the subgoal: select the first applicable rule (top-to-bottom) perform resolution on subgoal and selected rule else: backtrack if possible, otherwise fail success

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). Logically sound?!! ?- witch(X). Goals

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). ?- witch(X). Goals  witch(_G0)

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). ?- witch(X). Goals  witch(_G0)

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). ?- witch(X). Goals  witch(_G0)  burns(_G0)   woman(_G0)

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). ?- witch(X). Goals  witch(_G0)  burns(_G0)   woman(_G0)

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). ?- witch(X). Goals  witch(_G0)  burns(_G0)   woman(_G0)  madeofwood(_G0)

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). ?- witch(X). Goals  witch(_G0)  burns(_G0)   woman(_G0)  madeofwood(_G0)

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). ?- witch(X). Goals  witch(_G0)  burns(_G0)   woman(_G0)  madeofwood(_G0)  floats(_G0)

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). ?- witch(X). Goals  witch(_G0)  burns(_G0)   woman(_G0)  madeofwood(_G0)  floats(_G0)

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). ?- witch(X). Goals  witch(_G0)  burns(_G0)   woman(_G0)  madeofwood(_G0)  floats(duck)

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). ?- witch(X). Goals  witch(_G0)  burns(_G0)   woman(_G0)  madeofwood(duck)

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). ?- witch(X). Goals  witch(_G0)  burns(duck)   woman(duck)

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). ?- witch(X). Goals  witch(_G0)  burns(duck)   woman(duck) fail! backtrack...

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). ?- witch(X). Goals  witch(_G0)  burns(_G0)   woman(_G0)  madeofwood(_G0)  floats(_G0)

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). ?- witch(X). Goals  witch(_G0)  burns(_G0)   woman(_G0)  madeofwood(_G0)  floats(_G0)  floats(_G1)   sameweight(_G1, _G0)

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). ?- witch(X). Goals  witch(_G0)  burns(_G0)   woman(_G0)  madeofwood(_G0)  floats(_G0)  floats(_G1)   sameweight(_G1, _G0)

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). ?- witch(X). Goals  witch(_G0)  burns(_G0)   woman(_G0)  madeofwood(_G0)  floats(_G0)  floats(duck)   sameweight(duck, _G0)

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). ?- witch(X). Goals  witch(_G0)  burns(_G0)   woman(_G0)  madeofwood(_G0)  floats(_G0)  floats(duck)   sameweight(duck, _G0)

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). ?- witch(X). Goals  witch(_G0)  burns(_G0)   woman(_G0)  madeofwood(_G0)  floats(_G0)  floats(duck)   sameweight(duck, girl)

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). ?- witch(X). Goals  witch(_G0)  burns(_G0)   woman(_G0)  madeofwood(_G0)  floats(girl)

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). ?- witch(X). Goals  witch(_G0)  burns(_G0)   woman(_G0)  madeofwood(girl)

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). ?- witch(X). Goals  witch(_G0)  burns(girl)   woman(girl)

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). ?- witch(X). Goals  witch(_G0)  burns(girl)   woman(girl) works this time

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). ?- witch(X). Goals  witch(girl)

CPSC 433 Artificial Intelligence Sir Bedevere’s Infamous Deduction witch(X) :- burns(X),woman(X). woman(girl). burns(X) :- madeofwood(X). madeofwood(X) :- floats(X). floats(duck). floats(Y) :- floats(X),sameweight(X,Y). sameweight(duck,girl). ?- witch(X). X = girl