SlideShare a Scribd company logo
PROLOG
P R I N C I P L E S O F P R O G R A M M I N G L A N G U A G E S
PRESENTED BY:
H A S S A A N A H M A D ( 0 7 )
A Z E E M A S H R A F ( 1 4 )
M U H A M M A D U S A M A I Q B A L ( 1 5 )
S Y E D B A Q A R A B B A S ( 1 9 )
WHAT IS PROLOG?
• Prolog stands for programming in logic (PROgrammation en LOGique).
• Prolog is the most widely used language to have been inspired by logic
programming research.
• Prolog is the only successful example of the family of logic
programming languages.
CONT..
• Prolog is a declarative programming language.
• In the case of prolog, it will tell you whether a prolog sentence is true or not.
• if it contains variables, what the values of the variables need to be.
• Prolog is declarative. A Prolog programmer concentrates on what the program
needs to do, not on how to do it.
A LITTLE HISTORY
• Prolog was invented by Alain Colmerauer, a professor of computer science at
the university of Aix-Marseille in France, in 1972.
• The first application of Prolog was in natural language processing.
• Its theoretical underpinning are due to Donald Loveland of Duke university
through Robert Kowalski (formerly) of the university of Edinburgh
ANATOMY OF PROLOG PROGRAM
• Prolog programs are made up of facts and rules.
• A fact asserts some property of an object, or relation between two or more
objects.
e.g. parent(jane,alan).
Can be read as “Jane is the parent of Alan.”
• Rules allow us to infer that a property or relationship holds based on
preconditions.
e.g. parent(X,Y) :- mother(X,Y).
= “Person X is the parent of person Y if X is Y‟s mother.”
DATA TYPES
• Prolog single data type is the term. Terms are either atoms, numbers or
variables.
• An Atom is a general-purpose name with no inherent meaning.
Examples of atoms include
– X
– Red
– Taco
• Numbers can be floats or integers.
• Variables are denoted by a string consisting of letters, numbers and
underscore characters, and beginning with an upper-case letter or
underscore.
WHY LEARN PROLOG?
• Learning prolog will certainly not always be as fruitful as learning C++,
Java or Python.
• Prolog is most useful in the areas related to Artificial Intelligence
research, such as problem solving, (path) planning or natural language
interpretation.
• As prolog uses certain programming techniques that are considered
difficult or advanced
• prolog programmer will certainly have an in-depth understanding of
such concepts as recursion, searching problem trees etc.
CONT..
• Very complex programs have been written in prolog.
• Most of all prolog is a complex, powerful, and elegant language that
can inspire great satisfaction in its users.
• learning prolog is not easy because Prolog doesn't work as naturally as
procedural languages and therefore requires a specific way of thinking.
INTRODUCTION TO LOGIC
• Since Prolog is based heavily on formal logic, it's useful to have some
experience with it.
• There are two types of logical languages:
– propositional logic
– first-order logic.
PROPOSITIONAL LOGIC
• Propositional logic has two basic elements:
– terms
– Connectives
• Terms are represented by letters (usually upper-case), and represent
the values true and false.
• Connectives, like the word suggests, connect two terms.
• Connectives are usually represented by symbols rather than words.
FIRST ORDER LOGIC
• First Order Logic (also known as predicate logic) expands on
propositional logic, by using predicates, variables and objects.
• In first order logic the atomic sentences are predicates.
• Predicates have a name (starting with a capital) which is followed
by several variables (starting with a lowercase letter).
CONT..
• The following are examples of predicates:
– Predicate(variable1, variable2)
– BrotherOf(sibling, brother)
– MotherOf(child, mother)
– HasWheels(thing)
• these variables can be instantiated with objects.
CONT..
• Objects are elements represented by words that start with a capital
letter.
• Such a collection of sentences that are true is called a knowledge base.
• Such a knowledge base could, for instance contain the following
sentences:
– HasWheels(Car)
– MotherOf(Charles, Elizabeth)
• The sentences tell us that the HasWheels predicate is true
PREDICATE DEFINITIONS
• Both facts and rules are predicate definitions.
• ‘Predicate’ is the name given to the word occurring before the bracket in
a fact
or rule:
– parent (jane,alan).
• By defining a predicate you are specifying which information needs to
be
known for the property denoted by the predicate to be true.
CLAUSES
• Predicate definitions consist of clauses.
• An individual definition (whether it be a fact or rule).
e.g. mother(jane, alan). = Fact
parent(P1,P2):- mother(P1,P2). = Rule
• A clause consists of a head And sometimes a body.
• Facts don't have a body because they are always true.
• Clauses with empty bodies are called facts.
• Clauses with bodies are called rules.
ARGUMENTS
• A predicate head consists of a predicate name and sometimes some
arguments
contained within brackets and separated by commas.
mother(jane, alan).
Predicate name Arguments
• A body can be made up of any number of subgoals (calls to other
predicates) and terms.
CONT..
• Arguments also consist of terms, which can be:
– Constants e.g. jane,
– Variables e.g. Person1, or
– Compound terms
TERMS
CONSTANTS
Constants can either be:
• Numbers:
– integers are the usual form (e.g. 1, 0, -1, etc), but
– floating-point numbers can also be used (e.g. 3.9)
• Symbolic constants:
– always start with a lower case alphabetic character and contain any
mixture of
letters, digits, and underscores (but no spaces, punctuation, or an initial
capital).
– e.g. abc, big_long_constant, x4_3t.
• String constants:
VARIABLES
• Variables always start with an upper case alphabetic character or an
underscore.
• Other than the first character they can be made up of any mixture of letters,
digits, and underscores.
e.g. X, ABC, _89two5, _very_long_variable
• There are no “types” for variables (or constants) – a variable can take any
value.
• All Prolog variables have a “local” scope:
They only keep the same value within a clause; the same variable used
outside
of a clause refers as “global” scope.
NAMING TIPS
• Use real English when naming predicates, constants, and variables.
– e.g. “John wants to help Somebody.”
– Could be: wants(john, to_help , Somebody).
– Not: x87g(j,_789).
• Use a Verb-Subject-Object structure:
– wants(john, to_help).
• BUT do not assume Prolog Understands the meaning of your chosen
names
RUNNING
PROLOG
O N W I N D O W S .
After SWI-Prolog has been installed on a Windows system, the following
important new things are available to the user:
• A folder (in program files) called swipl containing the executable, libraries, etc.,
of the system.
• No files are installed outside this directory.
• Program swipl-win.exe, providing a window for interaction with Prolog.
• The program swipl.exe is a version of SWI-Prolog that runs in a console
window.
• The file extension .pl is associated with the program swipl-win.exe.
EXECUTING A QUERY
After loading a program, one can ask Prolog queries about the program.
?- likes (sam, x) .
X = biryani ;
X = tandoori ;
……
X = chips ;
?-
PROLOG EXECUTION
• Most Prolog clauses have both a declarative reading and a procedural
reading.
• Whenever possible, the declarative reading is to be preferred.
– mother (X, Y) :- parent (X, Y), female (X) .
• Declarative reading: x is the mother of y
– if x is parent of y and x is female
CONT..
Procedural reading :
• To show that x is the mother of y, first show that x is a parent of y, then
show that x is female.
Clauses:
oparent (john, bill) .
oparent (jane, bill) .
ofemale(jane) .
Query:
o| ?- mother (M, bill) .
CONT..
• The clause of mother will be checked, and the unification X=M, Y=bill will occur.
• Then parent (M, bill) will be attempted, resulting in the unification M=john.
• Next, female (john) will be attempted, but will fail.
• Prolog will backtrack to parent (M, bill) and look for another solution for this; it will
succeed and unify M=jane.
• Finally, it will attempt female (jane), and succeed; so the inquiry will succeed,
having performed the unification M=jane.
ADVANTAGES
• Ease of representing knowledge.
• Natural support of pattern-matching.
• Natural support of meta-programming.
• Meaning of programs is independent of how they are executed.
• Simple connection between programs and computed answers and
specifications.
• No need to distinguish programs from databases.
LIMITATIONS
• Although Prolog is widely used in research and education, Prolog and other logic
programming languages have not had a significant impact on the computer
industry in general.
• Most applications are small by industrial standards, with few exceeding 100,000
lines of code.
• Programming in the large is considered to be complicated because not all Prolog
compilers support modules
• because there are compatibility problems between the module systems of the
major Prolog compilers.
• Prolog is not purely declarative because of constructs like the cut operator,
• a procedural reading of a Prolog program is needed to understand it.
EXTENSIONS
• Various implementations have been developed from Prolog to extend logic
programming capabilities
• these include:
– types,
– modes,
– constraint logic programming (CLP),
– object-oriented logic programming (OOLP),
– linear logic (LLP),
– functional and higher-order logic programming capabilities,
– interoperability with knowledge bases
TYPES
• Prolog is an untyped language.
• Attempts to introduce types date back to the 1980s and as of 2008
there are still attempts to extend Prolog with types.
MODES
• The syntax of Prolog does not specify which arguments of a predicate
are inputs and which are outputs.
• Modes provide valuable information when reasoning about Prolog
programs and can also be used to accelerate execution.
EXAMPLE # 1:
EXAMPLE # 2:
GRAPHICS
• Prolog systems that provide a graphics library are:
– SWI-Prolog
– Visual Prolog WIN-PROLOG
– B-Prolog
• SWI also support server-side web programming with support for web
protocols, HTML and XML.
THANK
YOU

More Related Content

What's hot

Introduction to prolog
Introduction to prologIntroduction to prolog
Introduction to prolog
Harry Potter
 
PROLOG: Introduction To Prolog
PROLOG: Introduction To PrologPROLOG: Introduction To Prolog
PROLOG: Introduction To Prolog
DataminingTools Inc
 
Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language Processing
Geeks Anonymes
 
NLP Project Full Cycle
NLP Project Full CycleNLP Project Full Cycle
NLP Project Full Cycle
Vsevolod Dyomkin
 
RuleML2015 PSOA RuleML: Integrated Object-Relational Data and Rules
RuleML2015 PSOA RuleML: Integrated Object-Relational Data and RulesRuleML2015 PSOA RuleML: Integrated Object-Relational Data and Rules
RuleML2015 PSOA RuleML: Integrated Object-Relational Data and Rules
RuleML
 
Lec4slides
Lec4slidesLec4slides
Lec4slidesshawiz
 
Representing and Reasoning with Modular Ontologies (2007)
Representing and Reasoning with Modular Ontologies (2007)Representing and Reasoning with Modular Ontologies (2007)
Representing and Reasoning with Modular Ontologies (2007)Jie Bao
 
Lecture 2: Computational Semantics
Lecture 2: Computational SemanticsLecture 2: Computational Semantics
Lecture 2: Computational Semantics
Marina Santini
 
NLP_KASHK:Text Normalization
NLP_KASHK:Text NormalizationNLP_KASHK:Text Normalization
NLP_KASHK:Text Normalization
Hemantha Kulathilake
 
Propositional logic(part 2)
Propositional logic(part 2)Propositional logic(part 2)
Propositional logic(part 2)
SURBHI SAROHA
 
Why Java is not a purely object oriented language?
Why Java is not a purely object oriented language?Why Java is not a purely object oriented language?
Why Java is not a purely object oriented language?
NexSoftsys
 
Introduction to Ontology Engineering with Fluent Editor 2014
Introduction to Ontology Engineering with Fluent Editor 2014Introduction to Ontology Engineering with Fluent Editor 2014
Introduction to Ontology Engineering with Fluent Editor 2014
Cognitum
 
Semantics and Computational Semantics
Semantics and Computational SemanticsSemantics and Computational Semantics
Semantics and Computational Semantics
Marina Santini
 
Eswc2012 ss ontologies
Eswc2012 ss ontologiesEswc2012 ss ontologies
Eswc2012 ss ontologiesElena Simperl
 
Towards advanced data retrieval from learning objects repositories
Towards advanced data retrieval from learning objects repositoriesTowards advanced data retrieval from learning objects repositories
Towards advanced data retrieval from learning objects repositoriesValentina Paunovic
 
Crash Course in Natural Language Processing (2016)
Crash Course in Natural Language Processing (2016)Crash Course in Natural Language Processing (2016)
Crash Course in Natural Language Processing (2016)
Vsevolod Dyomkin
 
Lecture 1: Semantic Analysis in Language Technology
Lecture 1: Semantic Analysis in Language TechnologyLecture 1: Semantic Analysis in Language Technology
Lecture 1: Semantic Analysis in Language Technology
Marina Santini
 
Lidia Pivovarova
Lidia PivovarovaLidia Pivovarova
Lidia Pivovarova
Lidia Pivovarova
 
Lect6-An introduction to ontologies and ontology development
Lect6-An introduction to ontologies and ontology developmentLect6-An introduction to ontologies and ontology development
Lect6-An introduction to ontologies and ontology development
Antonio Moreno
 

What's hot (20)

Introduction to prolog
Introduction to prologIntroduction to prolog
Introduction to prolog
 
PROLOG: Introduction To Prolog
PROLOG: Introduction To PrologPROLOG: Introduction To Prolog
PROLOG: Introduction To Prolog
 
Prolog
PrologProlog
Prolog
 
Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language Processing
 
NLP Project Full Cycle
NLP Project Full CycleNLP Project Full Cycle
NLP Project Full Cycle
 
RuleML2015 PSOA RuleML: Integrated Object-Relational Data and Rules
RuleML2015 PSOA RuleML: Integrated Object-Relational Data and RulesRuleML2015 PSOA RuleML: Integrated Object-Relational Data and Rules
RuleML2015 PSOA RuleML: Integrated Object-Relational Data and Rules
 
Lec4slides
Lec4slidesLec4slides
Lec4slides
 
Representing and Reasoning with Modular Ontologies (2007)
Representing and Reasoning with Modular Ontologies (2007)Representing and Reasoning with Modular Ontologies (2007)
Representing and Reasoning with Modular Ontologies (2007)
 
Lecture 2: Computational Semantics
Lecture 2: Computational SemanticsLecture 2: Computational Semantics
Lecture 2: Computational Semantics
 
NLP_KASHK:Text Normalization
NLP_KASHK:Text NormalizationNLP_KASHK:Text Normalization
NLP_KASHK:Text Normalization
 
Propositional logic(part 2)
Propositional logic(part 2)Propositional logic(part 2)
Propositional logic(part 2)
 
Why Java is not a purely object oriented language?
Why Java is not a purely object oriented language?Why Java is not a purely object oriented language?
Why Java is not a purely object oriented language?
 
Introduction to Ontology Engineering with Fluent Editor 2014
Introduction to Ontology Engineering with Fluent Editor 2014Introduction to Ontology Engineering with Fluent Editor 2014
Introduction to Ontology Engineering with Fluent Editor 2014
 
Semantics and Computational Semantics
Semantics and Computational SemanticsSemantics and Computational Semantics
Semantics and Computational Semantics
 
Eswc2012 ss ontologies
Eswc2012 ss ontologiesEswc2012 ss ontologies
Eswc2012 ss ontologies
 
Towards advanced data retrieval from learning objects repositories
Towards advanced data retrieval from learning objects repositoriesTowards advanced data retrieval from learning objects repositories
Towards advanced data retrieval from learning objects repositories
 
Crash Course in Natural Language Processing (2016)
Crash Course in Natural Language Processing (2016)Crash Course in Natural Language Processing (2016)
Crash Course in Natural Language Processing (2016)
 
Lecture 1: Semantic Analysis in Language Technology
Lecture 1: Semantic Analysis in Language TechnologyLecture 1: Semantic Analysis in Language Technology
Lecture 1: Semantic Analysis in Language Technology
 
Lidia Pivovarova
Lidia PivovarovaLidia Pivovarova
Lidia Pivovarova
 
Lect6-An introduction to ontologies and ontology development
Lect6-An introduction to ontologies and ontology developmentLect6-An introduction to ontologies and ontology development
Lect6-An introduction to ontologies and ontology development
 

Similar to Prolog final

ARTIFICIAL INTELLIGENCE---UNIT 4.pptx
ARTIFICIAL INTELLIGENCE---UNIT 4.pptxARTIFICIAL INTELLIGENCE---UNIT 4.pptx
ARTIFICIAL INTELLIGENCE---UNIT 4.pptx
RuchitaMaaran
 
Prolog,Prolog Programming IN AI.pdf
Prolog,Prolog Programming IN AI.pdfProlog,Prolog Programming IN AI.pdf
Prolog,Prolog Programming IN AI.pdf
CS With Logic
 
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
qasim ali
 
Plc part 4
Plc  part 4Plc  part 4
Plc part 4
Taymoor Nazmy
 
Iccs presentation 2k17 : Predicting dark triad personality traits using twit...
Iccs presentation  2k17 : Predicting dark triad personality traits using twit...Iccs presentation  2k17 : Predicting dark triad personality traits using twit...
Iccs presentation 2k17 : Predicting dark triad personality traits using twit...
Ravi Agrawal
 
Working with big biomedical ontologies
Working with big biomedical ontologiesWorking with big biomedical ontologies
Working with big biomedical ontologies
robertstevens65
 
Foundations of Knowledge Representation in Artificial Intelligence.pptx
Foundations of Knowledge Representation in Artificial Intelligence.pptxFoundations of Knowledge Representation in Artificial Intelligence.pptx
Foundations of Knowledge Representation in Artificial Intelligence.pptx
kitsenthilkumarcse
 
Family Tree on PROLOG
Family Tree on PROLOGFamily Tree on PROLOG
Family Tree on PROLOG
Abdul Rafay
 
Python Training
Python TrainingPython Training
Python Training
softcrayons3
 
ICS1019.pdf
ICS1019.pdfICS1019.pdf
ICS1019.pdf
Matt Montebello
 
Logic in Predicate and Propositional Logic
Logic in Predicate and Propositional LogicLogic in Predicate and Propositional Logic
Logic in Predicate and Propositional Logic
ArchanaT32
 
Jarrar: ORM in Description Logic
Jarrar: ORM in Description Logic  Jarrar: ORM in Description Logic
Jarrar: ORM in Description Logic
Mustafa Jarrar
 
Artificial Intelligence Notes Unit 4
Artificial Intelligence Notes Unit 4Artificial Intelligence Notes Unit 4
Artificial Intelligence Notes Unit 4
DigiGurukul
 
Prolog
Prolog Prolog
Formal Logic in AI
Formal Logic in AIFormal Logic in AI
Formal Logic in AI
Dr. C.V. Suresh Babu
 
Ics1019 ics5003
Ics1019 ics5003Ics1019 ics5003
Ics1019 ics5003
Matt Montebello
 
Ai lab manual
Ai lab manualAi lab manual
Ai lab manual
Shipra Swati
 
predicateLogic.ppt
predicateLogic.pptpredicateLogic.ppt
predicateLogic.ppt
MUZAMILALI48
 
Ics1019 ics5003
Ics1019 ics5003Ics1019 ics5003
Ics1019 ics5003
Matt Montebello
 

Similar to Prolog final (20)

ARTIFICIAL INTELLIGENCE---UNIT 4.pptx
ARTIFICIAL INTELLIGENCE---UNIT 4.pptxARTIFICIAL INTELLIGENCE---UNIT 4.pptx
ARTIFICIAL INTELLIGENCE---UNIT 4.pptx
 
Prolog,Prolog Programming IN AI.pdf
Prolog,Prolog Programming IN AI.pdfProlog,Prolog Programming IN AI.pdf
Prolog,Prolog Programming IN AI.pdf
 
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
 
Chaps 1-3-ai-prolog
Chaps 1-3-ai-prologChaps 1-3-ai-prolog
Chaps 1-3-ai-prolog
 
Plc part 4
Plc  part 4Plc  part 4
Plc part 4
 
Iccs presentation 2k17 : Predicting dark triad personality traits using twit...
Iccs presentation  2k17 : Predicting dark triad personality traits using twit...Iccs presentation  2k17 : Predicting dark triad personality traits using twit...
Iccs presentation 2k17 : Predicting dark triad personality traits using twit...
 
Working with big biomedical ontologies
Working with big biomedical ontologiesWorking with big biomedical ontologies
Working with big biomedical ontologies
 
Foundations of Knowledge Representation in Artificial Intelligence.pptx
Foundations of Knowledge Representation in Artificial Intelligence.pptxFoundations of Knowledge Representation in Artificial Intelligence.pptx
Foundations of Knowledge Representation in Artificial Intelligence.pptx
 
Family Tree on PROLOG
Family Tree on PROLOGFamily Tree on PROLOG
Family Tree on PROLOG
 
Python Training
Python TrainingPython Training
Python Training
 
ICS1019.pdf
ICS1019.pdfICS1019.pdf
ICS1019.pdf
 
Logic in Predicate and Propositional Logic
Logic in Predicate and Propositional LogicLogic in Predicate and Propositional Logic
Logic in Predicate and Propositional Logic
 
Jarrar: ORM in Description Logic
Jarrar: ORM in Description Logic  Jarrar: ORM in Description Logic
Jarrar: ORM in Description Logic
 
Artificial Intelligence Notes Unit 4
Artificial Intelligence Notes Unit 4Artificial Intelligence Notes Unit 4
Artificial Intelligence Notes Unit 4
 
Prolog
Prolog Prolog
Prolog
 
Formal Logic in AI
Formal Logic in AIFormal Logic in AI
Formal Logic in AI
 
Ics1019 ics5003
Ics1019 ics5003Ics1019 ics5003
Ics1019 ics5003
 
Ai lab manual
Ai lab manualAi lab manual
Ai lab manual
 
predicateLogic.ppt
predicateLogic.pptpredicateLogic.ppt
predicateLogic.ppt
 
Ics1019 ics5003
Ics1019 ics5003Ics1019 ics5003
Ics1019 ics5003
 

Recently uploaded

2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 

Recently uploaded (20)

2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 

Prolog final

  • 1. PROLOG P R I N C I P L E S O F P R O G R A M M I N G L A N G U A G E S
  • 2. PRESENTED BY: H A S S A A N A H M A D ( 0 7 ) A Z E E M A S H R A F ( 1 4 ) M U H A M M A D U S A M A I Q B A L ( 1 5 ) S Y E D B A Q A R A B B A S ( 1 9 )
  • 3. WHAT IS PROLOG? • Prolog stands for programming in logic (PROgrammation en LOGique). • Prolog is the most widely used language to have been inspired by logic programming research. • Prolog is the only successful example of the family of logic programming languages.
  • 4. CONT.. • Prolog is a declarative programming language. • In the case of prolog, it will tell you whether a prolog sentence is true or not. • if it contains variables, what the values of the variables need to be. • Prolog is declarative. A Prolog programmer concentrates on what the program needs to do, not on how to do it.
  • 5. A LITTLE HISTORY • Prolog was invented by Alain Colmerauer, a professor of computer science at the university of Aix-Marseille in France, in 1972. • The first application of Prolog was in natural language processing. • Its theoretical underpinning are due to Donald Loveland of Duke university through Robert Kowalski (formerly) of the university of Edinburgh
  • 6. ANATOMY OF PROLOG PROGRAM • Prolog programs are made up of facts and rules. • A fact asserts some property of an object, or relation between two or more objects. e.g. parent(jane,alan). Can be read as “Jane is the parent of Alan.” • Rules allow us to infer that a property or relationship holds based on preconditions. e.g. parent(X,Y) :- mother(X,Y). = “Person X is the parent of person Y if X is Y‟s mother.”
  • 7. DATA TYPES • Prolog single data type is the term. Terms are either atoms, numbers or variables. • An Atom is a general-purpose name with no inherent meaning. Examples of atoms include – X – Red – Taco • Numbers can be floats or integers. • Variables are denoted by a string consisting of letters, numbers and underscore characters, and beginning with an upper-case letter or underscore.
  • 8. WHY LEARN PROLOG? • Learning prolog will certainly not always be as fruitful as learning C++, Java or Python. • Prolog is most useful in the areas related to Artificial Intelligence research, such as problem solving, (path) planning or natural language interpretation. • As prolog uses certain programming techniques that are considered difficult or advanced • prolog programmer will certainly have an in-depth understanding of such concepts as recursion, searching problem trees etc.
  • 9. CONT.. • Very complex programs have been written in prolog. • Most of all prolog is a complex, powerful, and elegant language that can inspire great satisfaction in its users. • learning prolog is not easy because Prolog doesn't work as naturally as procedural languages and therefore requires a specific way of thinking.
  • 10. INTRODUCTION TO LOGIC • Since Prolog is based heavily on formal logic, it's useful to have some experience with it. • There are two types of logical languages: – propositional logic – first-order logic.
  • 11. PROPOSITIONAL LOGIC • Propositional logic has two basic elements: – terms – Connectives • Terms are represented by letters (usually upper-case), and represent the values true and false. • Connectives, like the word suggests, connect two terms. • Connectives are usually represented by symbols rather than words.
  • 12.
  • 13. FIRST ORDER LOGIC • First Order Logic (also known as predicate logic) expands on propositional logic, by using predicates, variables and objects. • In first order logic the atomic sentences are predicates. • Predicates have a name (starting with a capital) which is followed by several variables (starting with a lowercase letter).
  • 14. CONT.. • The following are examples of predicates: – Predicate(variable1, variable2) – BrotherOf(sibling, brother) – MotherOf(child, mother) – HasWheels(thing) • these variables can be instantiated with objects.
  • 15. CONT.. • Objects are elements represented by words that start with a capital letter. • Such a collection of sentences that are true is called a knowledge base. • Such a knowledge base could, for instance contain the following sentences: – HasWheels(Car) – MotherOf(Charles, Elizabeth) • The sentences tell us that the HasWheels predicate is true
  • 16. PREDICATE DEFINITIONS • Both facts and rules are predicate definitions. • ‘Predicate’ is the name given to the word occurring before the bracket in a fact or rule: – parent (jane,alan). • By defining a predicate you are specifying which information needs to be known for the property denoted by the predicate to be true.
  • 17. CLAUSES • Predicate definitions consist of clauses. • An individual definition (whether it be a fact or rule). e.g. mother(jane, alan). = Fact parent(P1,P2):- mother(P1,P2). = Rule • A clause consists of a head And sometimes a body. • Facts don't have a body because they are always true. • Clauses with empty bodies are called facts. • Clauses with bodies are called rules.
  • 18. ARGUMENTS • A predicate head consists of a predicate name and sometimes some arguments contained within brackets and separated by commas. mother(jane, alan). Predicate name Arguments • A body can be made up of any number of subgoals (calls to other predicates) and terms.
  • 19. CONT.. • Arguments also consist of terms, which can be: – Constants e.g. jane, – Variables e.g. Person1, or – Compound terms
  • 20. TERMS
  • 21. CONSTANTS Constants can either be: • Numbers: – integers are the usual form (e.g. 1, 0, -1, etc), but – floating-point numbers can also be used (e.g. 3.9) • Symbolic constants: – always start with a lower case alphabetic character and contain any mixture of letters, digits, and underscores (but no spaces, punctuation, or an initial capital). – e.g. abc, big_long_constant, x4_3t. • String constants:
  • 22. VARIABLES • Variables always start with an upper case alphabetic character or an underscore. • Other than the first character they can be made up of any mixture of letters, digits, and underscores. e.g. X, ABC, _89two5, _very_long_variable • There are no “types” for variables (or constants) – a variable can take any value. • All Prolog variables have a “local” scope: They only keep the same value within a clause; the same variable used outside of a clause refers as “global” scope.
  • 23. NAMING TIPS • Use real English when naming predicates, constants, and variables. – e.g. “John wants to help Somebody.” – Could be: wants(john, to_help , Somebody). – Not: x87g(j,_789). • Use a Verb-Subject-Object structure: – wants(john, to_help). • BUT do not assume Prolog Understands the meaning of your chosen names
  • 24. RUNNING PROLOG O N W I N D O W S .
  • 25. After SWI-Prolog has been installed on a Windows system, the following important new things are available to the user: • A folder (in program files) called swipl containing the executable, libraries, etc., of the system. • No files are installed outside this directory. • Program swipl-win.exe, providing a window for interaction with Prolog. • The program swipl.exe is a version of SWI-Prolog that runs in a console window. • The file extension .pl is associated with the program swipl-win.exe.
  • 26. EXECUTING A QUERY After loading a program, one can ask Prolog queries about the program. ?- likes (sam, x) . X = biryani ; X = tandoori ; …… X = chips ; ?-
  • 27. PROLOG EXECUTION • Most Prolog clauses have both a declarative reading and a procedural reading. • Whenever possible, the declarative reading is to be preferred. – mother (X, Y) :- parent (X, Y), female (X) . • Declarative reading: x is the mother of y – if x is parent of y and x is female
  • 28. CONT.. Procedural reading : • To show that x is the mother of y, first show that x is a parent of y, then show that x is female. Clauses: oparent (john, bill) . oparent (jane, bill) . ofemale(jane) . Query: o| ?- mother (M, bill) .
  • 29. CONT.. • The clause of mother will be checked, and the unification X=M, Y=bill will occur. • Then parent (M, bill) will be attempted, resulting in the unification M=john. • Next, female (john) will be attempted, but will fail. • Prolog will backtrack to parent (M, bill) and look for another solution for this; it will succeed and unify M=jane. • Finally, it will attempt female (jane), and succeed; so the inquiry will succeed, having performed the unification M=jane.
  • 30. ADVANTAGES • Ease of representing knowledge. • Natural support of pattern-matching. • Natural support of meta-programming. • Meaning of programs is independent of how they are executed. • Simple connection between programs and computed answers and specifications. • No need to distinguish programs from databases.
  • 31. LIMITATIONS • Although Prolog is widely used in research and education, Prolog and other logic programming languages have not had a significant impact on the computer industry in general. • Most applications are small by industrial standards, with few exceeding 100,000 lines of code. • Programming in the large is considered to be complicated because not all Prolog compilers support modules • because there are compatibility problems between the module systems of the major Prolog compilers. • Prolog is not purely declarative because of constructs like the cut operator, • a procedural reading of a Prolog program is needed to understand it.
  • 32. EXTENSIONS • Various implementations have been developed from Prolog to extend logic programming capabilities • these include: – types, – modes, – constraint logic programming (CLP), – object-oriented logic programming (OOLP), – linear logic (LLP), – functional and higher-order logic programming capabilities, – interoperability with knowledge bases
  • 33. TYPES • Prolog is an untyped language. • Attempts to introduce types date back to the 1980s and as of 2008 there are still attempts to extend Prolog with types.
  • 34. MODES • The syntax of Prolog does not specify which arguments of a predicate are inputs and which are outputs. • Modes provide valuable information when reasoning about Prolog programs and can also be used to accelerate execution.
  • 37. GRAPHICS • Prolog systems that provide a graphics library are: – SWI-Prolog – Visual Prolog WIN-PROLOG – B-Prolog • SWI also support server-side web programming with support for web protocols, HTML and XML.

Editor's Notes

  1. You create meaning by specifying the body (i.e. preconditions) of a clause.
  2. Sociaal-Wetenschappelijke Informatica ("Social Science Informatics")