0% found this document useful (0 votes)
94 views13 pages

011 Intro To Prolog

This document introduces the topic of Prolog. It outlines the learning outcomes which are to understand the Rete algorithm, usage of Prolog, and key terms. Applications of Prolog discussed include intelligent data retrieval, natural language understanding, and robot planning. The document demonstrates getting started with Prolog by asserting facts and rules, and asking questions to determine what is true.

Uploaded by

Rashdeep Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
94 views13 pages

011 Intro To Prolog

This document introduces the topic of Prolog. It outlines the learning outcomes which are to understand the Rete algorithm, usage of Prolog, and key terms. Applications of Prolog discussed include intelligent data retrieval, natural language understanding, and robot planning. The document demonstrates getting started with Prolog by asserting facts and rules, and asking questions to determine what is true.

Uploaded by

Rashdeep Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Introduction to AI

AAPP002-4-2 Ver 1.0

Intro to Prolog
Topic & Structure of The Lesson

• Facts
• Rules

AAPP002-4-2 Intro to AI Intro to Prolog Slide 2 of 13


Learning Outcomes

• At the end of this topic, You should be


able to
• Rete Algorithm
• Usage
• Etc

AAPP002-4-2 Intro to AI Intro to Prolog Slide 3 of 13


Key Terms You Must Be Able To
Use
• If you have mastered this topic, you should be able to use the
following terms correctly in your assignments and exams:

• Prolog
• Fact
• Rules

AAPP002-4-2 Intro to AI Intro to Prolog Slide 4 of 13


What is application of prolog?

Some applications of Prolog are:

• intelligent data base retrieval


• natural language understanding
• expert systems
• specification language
• machine learning
• robot planning
• automated reasoning
• problem solving

AAPP002-4-2 Intro to AI Intro to Prolog Slide 5 of 13


Getting Started with Prolog

• Prolog is a language based on first order predicate logic.


• We can assert some facts and some rules, then ask questions to find out
what is true.
• Facts:

likes(john, mary).
tall(john).
tall(sue).
short(fred).
teaches(alison, artificialIntelligence).

• Note: lower case letters, full stop at end.

AAPP002-4-2 Intro to AI Intro to Prolog Slide 6 of 13


Prolog

• Rules:

likes(fred, X) :- tall(X).
examines(Person, Course) :- teaches(Person, Course).

– John likes someone if that someone is tall.


– A person examines a course if they teach that course.
– NOTE: “:-” used to mean IF. Meant to look a bit like a backwards arrow

– NOTE: Use of capitals (or words starting with capitals) for variables.

AAPP002-4-2 Intro to AI Intro to Prolog Slide 7 of 13


Prolog

• Your “program” consists of a file containing facts and rules.


• You “run” your program by asking “questions” at the prolog prompt.

|?- likes(fred, X).

• John likes who?


• Answers are then displayed. Type “;” to get more answers:

X = john ? ;
X = sue ? ;
no

AAPP002-4-2 Intro to AI Intro to Prolog Slide 8 of 13


Prolog sample

• Assume the following facts are in the database:


1) male(bob).
2) male(john).
3) male(bart).
4) female(mary).
5) parent(bob, john).
6) parent(bob, bart).
7) parent(bob, mary).
8) parent(john, bill).

What is the following answer for the below query


?- parent(bob,X).

AAPP002-4-2 Intro to AI Intro to Prolog Slide 9 of 13


Quick Review Question

parent(bob, ted).
parent(ted, kev).
parent(ted, betty).
parent(betty, meg).

?- parent(ted,betty).
?- parent(betty,ted).
?- parent(ted,X).
?- ancestor(ted,X).

AAPP002-4-2 Intro to AI Intro to Prolog Slide 10 of 13


Summary of Main Teaching Points

• Prolog (Programming in Logic) is a language


used mainly by the artificial intelligence
community, e.g. natural language processing,
knowledge representation, expert systems,
machine learning, and increasingly in software
engineering for program specification.
• Prolog works in a twovalued (yes/no, true/false)
logic where every query given to the program
database either succeeds or fails

AAPP002-4-2 Intro to AI Intro to Prolog Slide 11 of 13


Question and Answer Session

Q&A

AAPP002-4-2 Intro to AI Intro to Prolog Slide 12 of 13


What we will cover next

• Prolog

AAPP002-4-2 Intro to AI Intro to Prolog Slide 13 of 13

You might also like