SlideShare uma empresa Scribd logo
1 de 38
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

Mais conteúdo relacionado

Mais procurados

Introduction to prolog
Introduction to prologIntroduction to prolog
Introduction to prologHarry Potter
 
Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language ProcessingGeeks Anonymes
 
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 RulesRuleML
 
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 SemanticsMarina Santini
 
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 2014Cognitum
 
Semantics and Computational Semantics
Semantics and Computational SemanticsSemantics and Computational Semantics
Semantics and Computational SemanticsMarina 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 TechnologyMarina Santini
 
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 developmentAntonio Moreno
 

Mais procurados (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
 

Semelhante a Prolog final

ARTIFICIAL INTELLIGENCE---UNIT 4.pptx
ARTIFICIAL INTELLIGENCE---UNIT 4.pptxARTIFICIAL INTELLIGENCE---UNIT 4.pptx
ARTIFICIAL INTELLIGENCE---UNIT 4.pptxRuchitaMaaran
 
Prolog,Prolog Programming IN AI.pdf
Prolog,Prolog Programming IN AI.pdfProlog,Prolog Programming IN AI.pdf
Prolog,Prolog Programming IN AI.pdfCS 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.pptxqasim ali
 
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 ontologiesrobertstevens65
 
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.pptxkitsenthilkumarcse
 
Family Tree on PROLOG
Family Tree on PROLOGFamily Tree on PROLOG
Family Tree on PROLOGAbdul Rafay
 
Logic in Predicate and Propositional Logic
Logic in Predicate and Propositional LogicLogic in Predicate and Propositional Logic
Logic in Predicate and Propositional LogicArchanaT32
 
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 4DigiGurukul
 
predicateLogic.ppt
predicateLogic.pptpredicateLogic.ppt
predicateLogic.pptMUZAMILALI48
 

Semelhante a 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
 

Último

4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 

Último (20)

4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 

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.

Notas do Editor

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