SlideShare a Scribd company logo
1 of 17
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

Similar to 2 Prolog L 1 V2.ppt

UOS-BSIT-3811-Artificial-Intelligence-Introduction-to-prolog-PDF.pptx
UOS-BSIT-3811-Artificial-Intelligence-Introduction-to-prolog-PDF.pptxUOS-BSIT-3811-Artificial-Intelligence-Introduction-to-prolog-PDF.pptx
UOS-BSIT-3811-Artificial-Intelligence-Introduction-to-prolog-PDF.pptxqasim ali
 
Introduction to prolog
Introduction to prologIntroduction to prolog
Introduction to prologRakhi Sinha
 
Object Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part IObject Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part IAjit Nayak
 
MODELLING OF INTELLIGENT AGENTS USING A–PROLOG
MODELLING OF INTELLIGENT AGENTS USING A–PROLOGMODELLING OF INTELLIGENT AGENTS USING A–PROLOG
MODELLING OF INTELLIGENT AGENTS USING A–PROLOGijaia
 
The Ring programming language version 1.7 book - Part 90 of 196
The Ring programming language version 1.7 book - Part 90 of 196The Ring programming language version 1.7 book - Part 90 of 196
The Ring programming language version 1.7 book - Part 90 of 196Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 82 of 88
The Ring programming language version 1.3 book - Part 82 of 88The Ring programming language version 1.3 book - Part 82 of 88
The Ring programming language version 1.3 book - Part 82 of 88Mahmoud Samir Fayed
 
1Introduction to OOAD
1Introduction to OOAD1Introduction to OOAD
1Introduction to OOAD Shahid Riaz
 
The Ring programming language version 1.6 book - Part 182 of 189
The Ring programming language version 1.6 book - Part 182 of 189The Ring programming language version 1.6 book - Part 182 of 189
The Ring programming language version 1.6 book - Part 182 of 189Mahmoud Samir Fayed
 
Ch.03 - Class Diagram_1 OBJECT ORIENTED ANALYSIS AND DESIGN [O] .pptx
Ch.03 - Class Diagram_1 OBJECT ORIENTED ANALYSIS AND DESIGN [O] .pptxCh.03 - Class Diagram_1 OBJECT ORIENTED ANALYSIS AND DESIGN [O] .pptx
Ch.03 - Class Diagram_1 OBJECT ORIENTED ANALYSIS AND DESIGN [O] .pptxSohagSrz
 
The Ring programming language version 1.5.4 book - Part 178 of 185
The Ring programming language version 1.5.4 book - Part 178 of 185The Ring programming language version 1.5.4 book - Part 178 of 185
The Ring programming language version 1.5.4 book - Part 178 of 185Mahmoud Samir Fayed
 
Labelled Variables in Logic Programming: A First Prototipe in tuProlog
Labelled Variables in Logic Programming: A First Prototipe in tuPrologLabelled Variables in Logic Programming: A First Prototipe in tuProlog
Labelled Variables in Logic Programming: A First Prototipe in tuPrologRoberta Calegari
 

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

UOS-BSIT-3811-Artificial-Intelligence-Introduction-to-prolog-PDF.pptx
UOS-BSIT-3811-Artificial-Intelligence-Introduction-to-prolog-PDF.pptxUOS-BSIT-3811-Artificial-Intelligence-Introduction-to-prolog-PDF.pptx
UOS-BSIT-3811-Artificial-Intelligence-Introduction-to-prolog-PDF.pptx
 
Introduction to prolog
Introduction to prologIntroduction to prolog
Introduction to prolog
 
Object Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part IObject Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part I
 
MODELLING OF INTELLIGENT AGENTS USING A–PROLOG
MODELLING OF INTELLIGENT AGENTS USING A–PROLOGMODELLING OF INTELLIGENT AGENTS USING A–PROLOG
MODELLING OF INTELLIGENT AGENTS USING A–PROLOG
 
OOP
OOPOOP
OOP
 
The Ring programming language version 1.7 book - Part 90 of 196
The Ring programming language version 1.7 book - Part 90 of 196The Ring programming language version 1.7 book - Part 90 of 196
The Ring programming language version 1.7 book - Part 90 of 196
 
The Ring programming language version 1.3 book - Part 82 of 88
The Ring programming language version 1.3 book - Part 82 of 88The Ring programming language version 1.3 book - Part 82 of 88
The Ring programming language version 1.3 book - Part 82 of 88
 
Sam python pro_points_slide
Sam python pro_points_slideSam python pro_points_slide
Sam python pro_points_slide
 
1Introduction to OOAD
1Introduction to OOAD1Introduction to OOAD
1Introduction to OOAD
 
The Ring programming language version 1.6 book - Part 182 of 189
The Ring programming language version 1.6 book - Part 182 of 189The Ring programming language version 1.6 book - Part 182 of 189
The Ring programming language version 1.6 book - Part 182 of 189
 
Oo ps exam answer2
Oo ps exam answer2Oo ps exam answer2
Oo ps exam answer2
 
3 jf h-linearequations
3  jf h-linearequations3  jf h-linearequations
3 jf h-linearequations
 
Ch.03 - Class Diagram_1 OBJECT ORIENTED ANALYSIS AND DESIGN [O] .pptx
Ch.03 - Class Diagram_1 OBJECT ORIENTED ANALYSIS AND DESIGN [O] .pptxCh.03 - Class Diagram_1 OBJECT ORIENTED ANALYSIS AND DESIGN [O] .pptx
Ch.03 - Class Diagram_1 OBJECT ORIENTED ANALYSIS AND DESIGN [O] .pptx
 
The Bund language
The Bund languageThe Bund language
The Bund language
 
The Ring programming language version 1.5.4 book - Part 178 of 185
The Ring programming language version 1.5.4 book - Part 178 of 185The Ring programming language version 1.5.4 book - Part 178 of 185
The Ring programming language version 1.5.4 book - Part 178 of 185
 
Seminar
SeminarSeminar
Seminar
 
SEMINAR
SEMINARSEMINAR
SEMINAR
 
Labelled Variables in Logic Programming: A First Prototipe in tuProlog
Labelled Variables in Logic Programming: A First Prototipe in tuPrologLabelled Variables in Logic Programming: A First Prototipe in tuProlog
Labelled Variables in Logic Programming: A First Prototipe in tuProlog
 
Invitation to Scala
Invitation to ScalaInvitation to Scala
Invitation to Scala
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 

Recently uploaded

HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 

Recently uploaded (20)

HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 

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.