SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere Àhnliche Inhalte

Was ist angesagt?

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
 
Ai lab manual
Ai lab manualAi lab manual
Ai lab manualShipra Swati
 
Bab 1 proposisi
Bab 1 proposisiBab 1 proposisi
Bab 1 proposisiDhan junkie
 
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
 

Was ist angesagt? (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
 

Ähnlich wie PROLOG: Fact Roles And Queries In Prolog

Prolog -Cpt114 - Week3
Prolog -Cpt114 - Week3Prolog -Cpt114 - Week3
Prolog -Cpt114 - Week3a_akhavan
 
Prolog PPT_merged.pdf
Prolog PPT_merged.pdfProlog PPT_merged.pdf
Prolog PPT_merged.pdf20CE112YASHPATEL
 
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
 
Pl vol1
Pl vol1Pl vol1
Pl vol1Aarsh Ps
 
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
 

Ähnlich wie 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
 

Mehr von 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
 

Mehr von 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
 

KĂŒrzlich hochgeladen

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 

KĂŒrzlich hochgeladen (20)

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 

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