SlideShare a Scribd company logo
11/18/2023
1
Artificial Intelligent
Dr Ahmed Al-Arashi
December 2017
PROLOG
11/18/2023
2
Introduction
 Early 1970 in Marseilles, formed by Alain
Colmerauer.
 In 1981 Japanese choose Prolog for the fifth
generation computers.
 PROLOG (PROgraming in LOGic) is widely used
in Europe. Programing
 LISP (LISt Processing).
 Various Prolog compilers/programing environment
are available.
 PDC prolog (previously turbo prolog) is typed.
11/18/2023
3
Prolog Against Other Programing Languages
 Languages such as C, Fortran and Basic are
procedural languages and use algorithms.
 Prolog manipulates the data according to defined
procedures. It uses heuristics solve problems.
 Prolog program is a collection of facts and
relationship. It uses no procedures to solve a
problem, it uses data about objects and relationship
to solve the problems.
 The user defines the goal and the program find the
procedures and solution.
 Prolog is not efficient at numerical processing but it
is most efficient at reasoning.
 Prolog is good at inferring facts from given facts.
11/18/2023
4
Applications of Prolog
It is most useful at AI programing. Application
includes:
 Expert Systems.
 Natural Language Processing.
 Robotics.
 Gamming.
11/18/2023
5
PDC Prolog
 Stand alone programs.
 Some standard predicates.
 Interface with other programing languages.
 Arithmetic operations can be programed.
 It has good working environment. Main windows
includes:
– Editor.
– Dialog.
– Message.
– Trace.
11/18/2023
6
PDC Objects
Most important PDDC Prolog objects include:
 char:
Single character written between quartinos. Example
‘a’, ‘y’ and ‘n’.
 integer: integers of range (-37,368 to 32,767).
 real: floating point number range (e-307
to e308
)
 string: character sequences double written between
quartinos. Example “abc”, “SDF” and “aBc”.
 symbol: character sequences of letters, numbers and
under scores. The first character must be small
character. Examples ali_hassan, page_1, cARS and
city_Sanaa
11/18/2023
7
PDC Basic Sections (1/2)
PDC prolog program are divided into number of
sections. Basic ones will be discussed now, and others
will be introduced in the lap. and/or in the coming
lectures. Below are most basic ones:
 Domains:
All objects type are defined in this section. In this
Domains Examples
person, item = symbol
price = real
replay = char
11/18/2023
8
PDC Basic Sections (2/2)
 Predicates:
In this section all facts and relevant objects are defined
except few built-in predicates.
Predicates Examples
own(person ,item) like(person, food, type)
Built-in Predicates Examples
save(string) write(arg_1, arg_2, arg_3)
 Clauses:
Main PDC prolog program is written in this section. It
can include one or more fact/rule. All the facts that are
in the clauses section must be defined first in domains
and/or predicates sections in terms of relation name,
arguments number and type.
11/18/2023
9
Variables
Objects in prolog can be given a variable name.
Variable names is a sequence of , numbers and under
scores. The first letter must be Capital letter.
Examples
Name
Price
City_1,
Variables is usually used in clauses section and may be
used in goal.
They get their type from the predicates.
11/18/2023
10
How Variables Gets their Values
Variables gets their values by being matched to
constants in facts and/or rules.
When a variable gets a value it said to be bound.
When it is not bound it is said to be free.
It is important to not that, in prolog, variables for only
the time needed to obtain one solution. For this reason
we can not store information by giving a value to a
variable as we normally do in other programming
languages.
Anonymous Variables
Anonymous variable is a variable that is used in place
of any other variable with unknown value.
It is represented by underscore “_”
11/18/2023
11
Prolog Goals (Queries)
To asking prolog a question we use goal section as
follows:
goal
predicate.
When asking prolog a question it tries to find answer.
In other words when prolog is given a query it means
that it is given a goal to accomplish.
Goals can be single or compound.
Single goal is when asking one question using one
predicates only.
Lets start with making single goal clear through an
example.
11/18/2023
12
Example
domains
name, item =symbol
predicates
owns(name,item)
clauses
owns(ahmed,car).
owns(ahmed,house).
owns(ali,book).
owns(ali,pen).
owns(salma,car).
owns(salma,shose).
owns(hassan,pen).
owns(hassan,car).
Lets ask who owns pen?:
goal
owns(Person,pen).
Prolog responds:
Person = ali
Person = hassan
2 solutions
Lets tray
owns(_,car).
What does this means?
Prolog responds:
true (yes).
11/18/2023
13
Compound Goals
Compound goal it means that prolog is asked to answer more
than one query.
Tow types of compound goals are used in prolog conjunction
an disjunction.
Conjunction goal:
When is set of facts separated by comma (,) which means and.
Example
owns(Person, pen), owns(Person, car).
This means is their a Person who owns pen and car.
Disjunction goals
When set of facts separated by semicolon (;) which means or.
Example
owns(Person, pen) ; owns(Person, car).
This means is their a Person who owns pen or a Person who
owns car
11/18/2023
14
Prolog Rules
Prolog rules consists of two parts, head and body.
It takes the form of (if then), but differ totally than what is
used in other conventional programming languages.
The head is a conclusion that can be drawn provided that all
the facts in the body are proven to be true.
As an example look at the following expression:
This is a square if:
- It is a closed shape.
- It has four sides.
- All sides are equal.
- every side is perpendicular on the other
tow sides.
11/18/2023
15
Prolog Rules
In Prolog, the previous example can be written as follows:
this_is(square):-
shape(closed),
- no_of_sides(4),
- all_sides(equal),
- relation_with other_sides(perpendicular)
11/18/2023
16
Internal Goals
domains
name = symbol
predicates
father(name,name)
everybody
clauses
father(khaled, somia).
father(hassan, sami).
father(hassan, maryam).
everybody:-
father(X,Y),
write(X "is ", Y,"'s fathern").
goal
everybody.
11/18/2023
17
Medical Example
See the word file

More Related Content

PPTX
Prolog final
PPTX
ProLog (Artificial Intelligence) Introduction
PPTX
Unit 3 Prolog.pptxUnit 3 Prolog.pptxUnit 3 Prolog.pptxUnit 3 Prolog.pptxUnit
PPT
Chaps 1-3-ai-prolog
PPT
________ ________1.ppt
PPTX
Plc part 4
PDF
Prolog,Prolog Programming IN AI.pdf
PPTX
Prolog language programming in the facts.pptx
Prolog final
ProLog (Artificial Intelligence) Introduction
Unit 3 Prolog.pptxUnit 3 Prolog.pptxUnit 3 Prolog.pptxUnit 3 Prolog.pptxUnit
Chaps 1-3-ai-prolog
________ ________1.ppt
Plc part 4
Prolog,Prolog Programming IN AI.pdf
Prolog language programming in the facts.pptx

Similar to 2 Prolog L 1 V2.ppt (20)

PDF
PROLOG in artificial intelligence(Basic of pprolog)).pdf
PPTX
Ics1019 ics5003
PDF
ICS1019.pdf
PPTX
UOS-BSIT-3811-Artificial-Intelligence-Introduction-to-prolog-PDF.pptx
PPTX
Ics1019 ics5003
PPTX
Introduction to Prolog
PPTX
Artificial Intelligence and Expert System
PPTX
Prolog Programming : Basics
PPTX
Prolog (present)
PDF
Turbo prolog 2.0 basics
PPT
PROLOGPROLOGPROLOGPROLOGPROLOGPROLOGPROLOGPROLOGPROLOG
DOCX
Prolog_Programminvfygugy7gtugbugtg_Notes.docx
PDF
Introduction to Prolog (PROramming in LOGic)
PDF
Introduction to prolog
PPTX
PROLOG: Introduction To Prolog
PPT
Chaps 1-3-ai-prolog
PPTX
An introduction to Prolog language slide
PDF
Prolog PPT_merged.pdf
PDF
Ai lab manual
PROLOG in artificial intelligence(Basic of pprolog)).pdf
Ics1019 ics5003
ICS1019.pdf
UOS-BSIT-3811-Artificial-Intelligence-Introduction-to-prolog-PDF.pptx
Ics1019 ics5003
Introduction to Prolog
Artificial Intelligence and Expert System
Prolog Programming : Basics
Prolog (present)
Turbo prolog 2.0 basics
PROLOGPROLOGPROLOGPROLOGPROLOGPROLOGPROLOGPROLOGPROLOG
Prolog_Programminvfygugy7gtugbugtg_Notes.docx
Introduction to Prolog (PROramming in LOGic)
Introduction to prolog
PROLOG: Introduction To Prolog
Chaps 1-3-ai-prolog
An introduction to Prolog language slide
Prolog PPT_merged.pdf
Ai lab manual
Ad

Recently uploaded (20)

PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Business Ethics Teaching Materials for college
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
master seminar digital applications in india
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Pre independence Education in Inndia.pdf
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Institutional Correction lecture only . . .
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Module 4: Burden of Disease Tutorial Slides S2 2025
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
102 student loan defaulters named and shamed – Is someone you know on the list?
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Business Ethics Teaching Materials for college
PPH.pptx obstetrics and gynecology in nursing
Supply Chain Operations Speaking Notes -ICLT Program
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
master seminar digital applications in india
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
O7-L3 Supply Chain Operations - ICLT Program
Pre independence Education in Inndia.pdf
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Pharma ospi slides which help in ospi learning
Institutional Correction lecture only . . .
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
human mycosis Human fungal infections are called human mycosis..pptx
Ad

2 Prolog L 1 V2.ppt

  • 1. 11/18/2023 1 Artificial Intelligent Dr Ahmed Al-Arashi December 2017 PROLOG
  • 2. 11/18/2023 2 Introduction  Early 1970 in Marseilles, formed by Alain Colmerauer.  In 1981 Japanese choose Prolog for the fifth generation computers.  PROLOG (PROgraming in LOGic) is widely used in Europe. Programing  LISP (LISt Processing).  Various Prolog compilers/programing environment are available.  PDC prolog (previously turbo prolog) is typed.
  • 3. 11/18/2023 3 Prolog Against Other Programing Languages  Languages such as C, Fortran and Basic are procedural languages and use algorithms.  Prolog manipulates the data according to defined procedures. It uses heuristics solve problems.  Prolog program is a collection of facts and relationship. It uses no procedures to solve a problem, it uses data about objects and relationship to solve the problems.  The user defines the goal and the program find the procedures and solution.  Prolog is not efficient at numerical processing but it is most efficient at reasoning.  Prolog is good at inferring facts from given facts.
  • 4. 11/18/2023 4 Applications of Prolog It is most useful at AI programing. Application includes:  Expert Systems.  Natural Language Processing.  Robotics.  Gamming.
  • 5. 11/18/2023 5 PDC Prolog  Stand alone programs.  Some standard predicates.  Interface with other programing languages.  Arithmetic operations can be programed.  It has good working environment. Main windows includes: – Editor. – Dialog. – Message. – Trace.
  • 6. 11/18/2023 6 PDC Objects Most important PDDC Prolog objects include:  char: Single character written between quartinos. Example ‘a’, ‘y’ and ‘n’.  integer: integers of range (-37,368 to 32,767).  real: floating point number range (e-307 to e308 )  string: character sequences double written between quartinos. Example “abc”, “SDF” and “aBc”.  symbol: character sequences of letters, numbers and under scores. The first character must be small character. Examples ali_hassan, page_1, cARS and city_Sanaa
  • 7. 11/18/2023 7 PDC Basic Sections (1/2) PDC prolog program are divided into number of sections. Basic ones will be discussed now, and others will be introduced in the lap. and/or in the coming lectures. Below are most basic ones:  Domains: All objects type are defined in this section. In this Domains Examples person, item = symbol price = real replay = char
  • 8. 11/18/2023 8 PDC Basic Sections (2/2)  Predicates: In this section all facts and relevant objects are defined except few built-in predicates. Predicates Examples own(person ,item) like(person, food, type) Built-in Predicates Examples save(string) write(arg_1, arg_2, arg_3)  Clauses: Main PDC prolog program is written in this section. It can include one or more fact/rule. All the facts that are in the clauses section must be defined first in domains and/or predicates sections in terms of relation name, arguments number and type.
  • 9. 11/18/2023 9 Variables Objects in prolog can be given a variable name. Variable names is a sequence of , numbers and under scores. The first letter must be Capital letter. Examples Name Price City_1, Variables is usually used in clauses section and may be used in goal. They get their type from the predicates.
  • 10. 11/18/2023 10 How Variables Gets their Values Variables gets their values by being matched to constants in facts and/or rules. When a variable gets a value it said to be bound. When it is not bound it is said to be free. It is important to not that, in prolog, variables for only the time needed to obtain one solution. For this reason we can not store information by giving a value to a variable as we normally do in other programming languages. Anonymous Variables Anonymous variable is a variable that is used in place of any other variable with unknown value. It is represented by underscore “_”
  • 11. 11/18/2023 11 Prolog Goals (Queries) To asking prolog a question we use goal section as follows: goal predicate. When asking prolog a question it tries to find answer. In other words when prolog is given a query it means that it is given a goal to accomplish. Goals can be single or compound. Single goal is when asking one question using one predicates only. Lets start with making single goal clear through an example.
  • 12. 11/18/2023 12 Example domains name, item =symbol predicates owns(name,item) clauses owns(ahmed,car). owns(ahmed,house). owns(ali,book). owns(ali,pen). owns(salma,car). owns(salma,shose). owns(hassan,pen). owns(hassan,car). Lets ask who owns pen?: goal owns(Person,pen). Prolog responds: Person = ali Person = hassan 2 solutions Lets tray owns(_,car). What does this means? Prolog responds: true (yes).
  • 13. 11/18/2023 13 Compound Goals Compound goal it means that prolog is asked to answer more than one query. Tow types of compound goals are used in prolog conjunction an disjunction. Conjunction goal: When is set of facts separated by comma (,) which means and. Example owns(Person, pen), owns(Person, car). This means is their a Person who owns pen and car. Disjunction goals When set of facts separated by semicolon (;) which means or. Example owns(Person, pen) ; owns(Person, car). This means is their a Person who owns pen or a Person who owns car
  • 14. 11/18/2023 14 Prolog Rules Prolog rules consists of two parts, head and body. It takes the form of (if then), but differ totally than what is used in other conventional programming languages. The head is a conclusion that can be drawn provided that all the facts in the body are proven to be true. As an example look at the following expression: This is a square if: - It is a closed shape. - It has four sides. - All sides are equal. - every side is perpendicular on the other tow sides.
  • 15. 11/18/2023 15 Prolog Rules In Prolog, the previous example can be written as follows: this_is(square):- shape(closed), - no_of_sides(4), - all_sides(equal), - relation_with other_sides(perpendicular)
  • 16. 11/18/2023 16 Internal Goals domains name = symbol predicates father(name,name) everybody clauses father(khaled, somia). father(hassan, sami). father(hassan, maryam). everybody:- father(X,Y), write(X "is ", Y,"'s fathern"). goal everybody.