SlideShare uma empresa Scribd logo
1 de 18
Facts, Rules and Queries in Prolog
overview Introduction Simple examples Prolog Syntax Atoms Numbers Variables Complex terms
Facts Roles and Queries There are only three basic constructs in Prolog: facts, rules, and queries.  Prolog programming is all about writing knowledge bases. A collection of facts and rules is called a knowledge base (or a database)
Knowledge Base 1 Knowledge Base 1 (KB1) is simply a collection of facts.  Facts are used to state things that are unconditionally true of the domain of interest. Ex: woman(mia).         woman(jody).         woman(yolanda).         playsAirGuitar(jody).  state that Mia, Jody, and Yolanda are women, and Jody plays air guitar.
Knowledge Base 1  KB1 can be used by posing queries. Ex:  We can ask Prolog whether Mia is a woman by posing the query: ?- woman(mia). Yes we can ask whether Jody plays air guitar by posing the following query: ?- playsAirGuitar(jody). Yes
Knowledge Base 2  Ex:listensToMusic(mia).       happy(yolanda).       playsAirGuitar(mia) :- listensToMusic(mia).      playsAirGuitar(yolanda) :- listensToMusic(yolanda).      listensToMusic(yolanda):- happy(yolanda). ,[object Object]
The last three    items are rules. Rules state information that is conditionally true of the domain of interest.
Knowledge Base 2  :- should be read as ``if'', or``is implied by''. The part on the left hand side of the :- is called the head of the rule. The part on the right hand side is called the body. Ex: We can ask Prolog whether Mia plays air guitar: ?- playsAirGuitar(mia) Yes
Knowledge Base 3  KB3 consists of five clauses: happy(vincent). listensToMusic(butch). playsAirGuitar(vincent):-         listensToMusic(vincent),         happy(vincent). playsAirGuitar(butch):-         happy(butch). playsAirGuitar(butch):-        listensToMusic(butch). There are two facts, namely happy(vincent) and listensToMusic(butch), and three rules.
Knowledge Base 4 KB4 contains no rules, only a collection of facts. woman(mia). woman(jody). woman(yolanda). loves(vincent,mia). loves(marcellus,mia). loves(pumpkin,honey_bunny). loves(honey_bunny,pumpkin).
Knowledge Base 4 Ex: if we query ?- woman(X). Prolog reports back to us as follows: X = mia  The first item in the knowledge base is woman(mia).  So, Prolog matches X to mia, thus making the query agree perfectly with this first item.
Knowledge Base 5 Ex: loves(vincent,mia). loves(marcellus,mia). loves(pumpkin,honey_bunny). loves(honey_bunny,pumpkin). jealous(X,Y) :- loves(X,Z),loves(Y,Z). ,[object Object],[object Object]
Prolog syntax There are four kinds of terms in Prolog:  atoms, numbers, variables, and complex terms (or structures).  Atoms and numbers are lumped together under the heading constants, and constants and variables together make up the simple terms of Prolog. The upper-case letters are A, B, ..., Z;  The lower-case letters are a, b, ..., z;  The digits are 1, 2, ..., 9; The special characters are +, -, *, /, <, >,=, :, ., &, ~, and _. The _ character is called underscore.  A string is an unbroken sequence of characters.
ATOMS An atom is either: ,[object Object]
An arbitrary sequence of character enclosed in single quotes. Ex: 'Vincent','The Gimp', ' A string of special characters. Five_Dollar_Shake', '&^%&#@$ &*', and ' '. ,[object Object],[object Object]
Integers (that is: ... -2, -1, 0, 1, 2, 3, ...) are useful for such tasks as counting the elements of a list.,[object Object]
COMPLEX TERMS Complex terms are build out of a functor followed by a sequence of arguments.  The arguments are put in ordinary brackets, separated by commas, and placed after the functor. The functor must be an atom. That is, variables cannot be used as functors.  Arguments can be any kind of term. Ex: in the previous examples playsAirGuitar(jody) is a complex term:  its functor is playsAirGuitar and its argument is jody.
Visit more self help tutorials Pick a tutorial of your choice and browse through it at your own pace. The tutorials section is free, self-guiding and will not involve any additional support. Visit us at www.dataminingtools.net

Mais conteúdo relacionado

Mais procurados

10 logic+programming+with+prolog
10 logic+programming+with+prolog10 logic+programming+with+prolog
10 logic+programming+with+prologbaran19901990
 
Prolog Programming : Basics
Prolog Programming : BasicsProlog Programming : Basics
Prolog Programming : BasicsMitul Desai
 
Introduction to logic and prolog - Part 1
Introduction to logic and prolog - Part 1Introduction to logic and prolog - Part 1
Introduction to logic and prolog - Part 1Sabu Francis
 
Introduction to prolog
Introduction to prologIntroduction to prolog
Introduction to prologHarry Potter
 
Logic programming (1)
Logic programming (1)Logic programming (1)
Logic programming (1)Nitesh Singh
 
Logic
LogicLogic
LogicH K
 
Lesson 03 Arbitrarily Recursive Data Definitions
Lesson 03 Arbitrarily  Recursive Data DefinitionsLesson 03 Arbitrarily  Recursive Data Definitions
Lesson 03 Arbitrarily Recursive Data DefinitionsMitchell Wand
 
Erlang Concurrency
Erlang ConcurrencyErlang Concurrency
Erlang ConcurrencyBarry Ezell
 
Mathematical Logic Part 2
Mathematical Logic Part 2Mathematical Logic Part 2
Mathematical Logic Part 2blaircomp2003
 
Artificial Intelligence Lab File
Artificial Intelligence Lab FileArtificial Intelligence Lab File
Artificial Intelligence Lab FileKandarp Tiwari
 
Predicate logic_2(Artificial Intelligence)
Predicate logic_2(Artificial Intelligence)Predicate logic_2(Artificial Intelligence)
Predicate logic_2(Artificial Intelligence)SHUBHAM KUMAR GUPTA
 
Regular expression
Regular expressionRegular expression
Regular expressionRajon
 
Predicate calculus
Predicate calculusPredicate calculus
Predicate calculusRajendran
 
Knowledge representation and Predicate logic
Knowledge representation and Predicate logicKnowledge representation and Predicate logic
Knowledge representation and Predicate logicAmey Kerkar
 
L03 ai - knowledge representation using logic
L03 ai - knowledge representation using logicL03 ai - knowledge representation using logic
L03 ai - knowledge representation using logicManjula V
 

Mais procurados (20)

10 logic+programming+with+prolog
10 logic+programming+with+prolog10 logic+programming+with+prolog
10 logic+programming+with+prolog
 
Prolog Programming : Basics
Prolog Programming : BasicsProlog Programming : Basics
Prolog Programming : Basics
 
Introduction to logic and prolog - Part 1
Introduction to logic and prolog - Part 1Introduction to logic and prolog - Part 1
Introduction to logic and prolog - Part 1
 
Prolog 7-Languages
Prolog 7-LanguagesProlog 7-Languages
Prolog 7-Languages
 
Introduction to prolog
Introduction to prologIntroduction to prolog
Introduction to prolog
 
Logic programming (1)
Logic programming (1)Logic programming (1)
Logic programming (1)
 
Prolog
PrologProlog
Prolog
 
Logic
LogicLogic
Logic
 
Lesson 03 Arbitrarily Recursive Data Definitions
Lesson 03 Arbitrarily  Recursive Data DefinitionsLesson 03 Arbitrarily  Recursive Data Definitions
Lesson 03 Arbitrarily Recursive Data Definitions
 
Erlang Concurrency
Erlang ConcurrencyErlang Concurrency
Erlang Concurrency
 
Fol
FolFol
Fol
 
Mathematical Logic Part 2
Mathematical Logic Part 2Mathematical Logic Part 2
Mathematical Logic Part 2
 
Ai lab manual
Ai lab manualAi lab manual
Ai lab manual
 
Bab 1 proposisi
Bab 1 proposisiBab 1 proposisi
Bab 1 proposisi
 
Artificial Intelligence Lab File
Artificial Intelligence Lab FileArtificial Intelligence Lab File
Artificial Intelligence Lab File
 
Predicate logic_2(Artificial Intelligence)
Predicate logic_2(Artificial Intelligence)Predicate logic_2(Artificial Intelligence)
Predicate logic_2(Artificial Intelligence)
 
Regular expression
Regular expressionRegular expression
Regular expression
 
Predicate calculus
Predicate calculusPredicate calculus
Predicate calculus
 
Knowledge representation and Predicate logic
Knowledge representation and Predicate logicKnowledge representation and Predicate logic
Knowledge representation and Predicate logic
 
L03 ai - knowledge representation using logic
L03 ai - knowledge representation using logicL03 ai - knowledge representation using logic
L03 ai - knowledge representation using logic
 

Semelhante a PROLOG: Fact Roles And Queries In Prolog

Prolog -Cpt114 - Week3
Prolog -Cpt114 - Week3Prolog -Cpt114 - Week3
Prolog -Cpt114 - Week3a_akhavan
 
Chaps 1-3-ai-prolog
Chaps 1-3-ai-prologChaps 1-3-ai-prolog
Chaps 1-3-ai-prologsaru40
 
Lesson 1.1 basic ideas of sets part 1
Lesson 1.1   basic ideas of sets part 1Lesson 1.1   basic ideas of sets part 1
Lesson 1.1 basic ideas of sets part 1JohnnyBallecer
 
BCA_Semester-I_Mathematics-I_Set theory and function
BCA_Semester-I_Mathematics-I_Set theory and functionBCA_Semester-I_Mathematics-I_Set theory and function
BCA_Semester-I_Mathematics-I_Set theory and functionRai University
 
Artificial intelligence Prolog Language
Artificial intelligence Prolog LanguageArtificial intelligence Prolog Language
Artificial intelligence Prolog LanguageREHMAT ULLAH
 
Algorithms presentation on Path Matrix, Bell Number and Sorting
Algorithms presentation on Path Matrix, Bell Number and SortingAlgorithms presentation on Path Matrix, Bell Number and Sorting
Algorithms presentation on Path Matrix, Bell Number and SortingRishabh Mehan
 
CBSE Class X - Mathematics Set Theory Topic
CBSE Class X  - Mathematics Set Theory TopicCBSE Class X  - Mathematics Set Theory Topic
CBSE Class X - Mathematics Set Theory TopicEdvie
 
Basics of Probability Theory ; set definitions about the concepts
Basics of Probability Theory ; set definitions about the conceptsBasics of Probability Theory ; set definitions about the concepts
Basics of Probability Theory ; set definitions about the conceptsps6005tec
 
introduction to Genifer -- Deduction
introduction to Genifer -- Deductionintroduction to Genifer -- Deduction
introduction to Genifer -- DeductionYan Yin
 
Theory of first order logic
Theory of first order logicTheory of first order logic
Theory of first order logicDevaddd
 

Semelhante a PROLOG: Fact Roles And Queries In Prolog (17)

Prolog -Cpt114 - Week3
Prolog -Cpt114 - Week3Prolog -Cpt114 - Week3
Prolog -Cpt114 - Week3
 
Prolog PPT_merged.pdf
Prolog PPT_merged.pdfProlog PPT_merged.pdf
Prolog PPT_merged.pdf
 
Sets-newest.pptx
Sets-newest.pptxSets-newest.pptx
Sets-newest.pptx
 
Set
SetSet
Set
 
Chaps 1-3-ai-prolog
Chaps 1-3-ai-prologChaps 1-3-ai-prolog
Chaps 1-3-ai-prolog
 
Lesson 1.1 basic ideas of sets part 1
Lesson 1.1   basic ideas of sets part 1Lesson 1.1   basic ideas of sets part 1
Lesson 1.1 basic ideas of sets part 1
 
BCA_Semester-I_Mathematics-I_Set theory and function
BCA_Semester-I_Mathematics-I_Set theory and functionBCA_Semester-I_Mathematics-I_Set theory and function
BCA_Semester-I_Mathematics-I_Set theory and function
 
Artificial intelligence Prolog Language
Artificial intelligence Prolog LanguageArtificial intelligence Prolog Language
Artificial intelligence Prolog Language
 
Pl vol1
Pl vol1Pl vol1
Pl vol1
 
Algorithms presentation on Path Matrix, Bell Number and Sorting
Algorithms presentation on Path Matrix, Bell Number and SortingAlgorithms presentation on Path Matrix, Bell Number and Sorting
Algorithms presentation on Path Matrix, Bell Number and Sorting
 
lect14-semantics.ppt
lect14-semantics.pptlect14-semantics.ppt
lect14-semantics.ppt
 
Pptmath
PptmathPptmath
Pptmath
 
Integers
IntegersIntegers
Integers
 
CBSE Class X - Mathematics Set Theory Topic
CBSE Class X  - Mathematics Set Theory TopicCBSE Class X  - Mathematics Set Theory Topic
CBSE Class X - Mathematics Set Theory Topic
 
Basics of Probability Theory ; set definitions about the concepts
Basics of Probability Theory ; set definitions about the conceptsBasics of Probability Theory ; set definitions about the concepts
Basics of Probability Theory ; set definitions about the concepts
 
introduction to Genifer -- Deduction
introduction to Genifer -- Deductionintroduction to Genifer -- Deduction
introduction to Genifer -- Deduction
 
Theory of first order logic
Theory of first order logicTheory of first order logic
Theory of first order logic
 

Mais de PROLOG CONTENT

PROLOG: Database Manipulation In Prolog
PROLOG: Database Manipulation In PrologPROLOG: Database Manipulation In Prolog
PROLOG: Database Manipulation In PrologPROLOG CONTENT
 
Prolog: Cuts And Negation In Prolog
Prolog: Cuts And Negation In PrologProlog: Cuts And Negation In Prolog
Prolog: Cuts And Negation In PrologPROLOG CONTENT
 
PROLOG: Clauses Grammer In Prolog
PROLOG: Clauses Grammer In PrologPROLOG: Clauses Grammer In Prolog
PROLOG: Clauses Grammer In PrologPROLOG CONTENT
 
Prolog: Arithmetic Operations In Prolog
Prolog: Arithmetic Operations In PrologProlog: Arithmetic Operations In Prolog
Prolog: Arithmetic Operations In PrologPROLOG CONTENT
 
PROLOG: Matching And Proof Search In Prolog
PROLOG: Matching And Proof Search In PrologPROLOG: Matching And Proof Search In Prolog
PROLOG: Matching And Proof Search In PrologPROLOG CONTENT
 
PROLOG: Recursion And Lists In Prolog
PROLOG: Recursion And Lists In PrologPROLOG: Recursion And Lists In Prolog
PROLOG: Recursion And Lists In PrologPROLOG CONTENT
 

Mais de PROLOG CONTENT (6)

PROLOG: Database Manipulation In Prolog
PROLOG: Database Manipulation In PrologPROLOG: Database Manipulation In Prolog
PROLOG: Database Manipulation In Prolog
 
Prolog: Cuts And Negation In Prolog
Prolog: Cuts And Negation In PrologProlog: Cuts And Negation In Prolog
Prolog: Cuts And Negation In Prolog
 
PROLOG: Clauses Grammer In Prolog
PROLOG: Clauses Grammer In PrologPROLOG: Clauses Grammer In Prolog
PROLOG: Clauses Grammer In Prolog
 
Prolog: Arithmetic Operations In Prolog
Prolog: Arithmetic Operations In PrologProlog: Arithmetic Operations In Prolog
Prolog: Arithmetic Operations In Prolog
 
PROLOG: Matching And Proof Search In Prolog
PROLOG: Matching And Proof Search In PrologPROLOG: Matching And Proof Search In Prolog
PROLOG: Matching And Proof Search In Prolog
 
PROLOG: Recursion And Lists In Prolog
PROLOG: Recursion And Lists In PrologPROLOG: Recursion And Lists In Prolog
PROLOG: Recursion And Lists In Prolog
 

Último

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 

Último (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 

PROLOG: Fact Roles And Queries In Prolog

  • 1. Facts, Rules and Queries in Prolog
  • 2. overview Introduction Simple examples Prolog Syntax Atoms Numbers Variables Complex terms
  • 3. Facts Roles and Queries There are only three basic constructs in Prolog: facts, rules, and queries. Prolog programming is all about writing knowledge bases. A collection of facts and rules is called a knowledge base (or a database)
  • 4. Knowledge Base 1 Knowledge Base 1 (KB1) is simply a collection of facts. Facts are used to state things that are unconditionally true of the domain of interest. Ex: woman(mia). woman(jody). woman(yolanda). playsAirGuitar(jody).  state that Mia, Jody, and Yolanda are women, and Jody plays air guitar.
  • 5. Knowledge Base 1 KB1 can be used by posing queries. Ex: We can ask Prolog whether Mia is a woman by posing the query: ?- woman(mia). Yes we can ask whether Jody plays air guitar by posing the following query: ?- playsAirGuitar(jody). Yes
  • 6.
  • 7. The last three items are rules. Rules state information that is conditionally true of the domain of interest.
  • 8. Knowledge Base 2 :- should be read as ``if'', or``is implied by''. The part on the left hand side of the :- is called the head of the rule. The part on the right hand side is called the body. Ex: We can ask Prolog whether Mia plays air guitar: ?- playsAirGuitar(mia) Yes
  • 9. Knowledge Base 3 KB3 consists of five clauses: happy(vincent). listensToMusic(butch). playsAirGuitar(vincent):- listensToMusic(vincent), happy(vincent). playsAirGuitar(butch):- happy(butch). playsAirGuitar(butch):- listensToMusic(butch). There are two facts, namely happy(vincent) and listensToMusic(butch), and three rules.
  • 10. Knowledge Base 4 KB4 contains no rules, only a collection of facts. woman(mia). woman(jody). woman(yolanda). loves(vincent,mia). loves(marcellus,mia). loves(pumpkin,honey_bunny). loves(honey_bunny,pumpkin).
  • 11. Knowledge Base 4 Ex: if we query ?- woman(X). Prolog reports back to us as follows: X = mia The first item in the knowledge base is woman(mia). So, Prolog matches X to mia, thus making the query agree perfectly with this first item.
  • 12.
  • 13. Prolog syntax There are four kinds of terms in Prolog: atoms, numbers, variables, and complex terms (or structures). Atoms and numbers are lumped together under the heading constants, and constants and variables together make up the simple terms of Prolog. The upper-case letters are A, B, ..., Z; The lower-case letters are a, b, ..., z; The digits are 1, 2, ..., 9; The special characters are +, -, *, /, <, >,=, :, ., &, ~, and _. The _ character is called underscore. A string is an unbroken sequence of characters.
  • 14.
  • 15.
  • 16.
  • 17. COMPLEX TERMS Complex terms are build out of a functor followed by a sequence of arguments. The arguments are put in ordinary brackets, separated by commas, and placed after the functor. The functor must be an atom. That is, variables cannot be used as functors. Arguments can be any kind of term. Ex: in the previous examples playsAirGuitar(jody) is a complex term: its functor is playsAirGuitar and its argument is jody.
  • 18. Visit more self help tutorials Pick a tutorial of your choice and browse through it at your own pace. The tutorials section is free, self-guiding and will not involve any additional support. Visit us at www.dataminingtools.net