Prolog Tutorial
Prolog Tutorial
(PROLOG)
Text Book
Prolog Programming, A First Course,
by Paul Brna, 2001
References:
PROLOG A Relational Language and its Applications,
by John Malpas, Prentice Hall
Using Turbo Prolog, QUE Corporation (For PROLOG),
by Yin K. and Solomon D
Course Description
This course will introduce
The theory of functional and logic based
approaches.
Declarative programming will be
introduced using the Prolog programming
language.
Course Objectives
Students should:
Become familiar with the basic syntax of
Prolog language.
Be able to give a declarative and procedural
reading of a Prolog program.
Be able to pursue any course that makes use of
predicate calculus or Prolog.
Introduction
Types of programming languages
Imperative languages: Describe the steps that are
required to solve a given problem. The programmer
must know an algorithm that tells the computer what
to do. That is how to get the output from a given
input. (Examples: C++, C#, Pascal, Algol, … etc.)
Declarative languages: Declare the logic by which the
program solves a problem (the logic of problem
solving is declared in the program). The programmer
must know what relations hold between various
entities. (Examples: LISP, PROLOG, … etc.)
PROLOG
PROLOG: PROgramming in LOGic.
It was developed from a foundation of logical
theorem proving and originally used for research
in natural language processing
Its popularity has been mainly in the artificial
intelligence (AI), where it has been used in expert
systems, natural language, and intelligent
databases.
It is based on First Order Predicate Logic
Elements of a PROLOG program
Facts: A fact is an assertion that a particular
relation holds.
Examples on facts
Ali owns the book.
The relationship between Ali and the book is own.
Abdu likes apples.
The relationship between Abdu and apples is like.
Fatima is female.
The relationship between Fatimaand gender is female.
Every mother loves her children.
The relationship between mother and children is love.
Amina is the mother of Ali.
The relationship between Amina and Ali is mother.
Fact as a Relation
Relationship Object 1 Object 2
Predicate name
owns(ahmed, Y).
female(Fatima).
sister_of(suha, ruba).