The first, official version of prolog was developed at the university of Marseilles, France by Alain Colmerauer in the early 1970s as a tool for programming in logic. Today, prolog is an important tool in programming artificial intelligence applications and in the development of customized knowledge bases, expert systems, natural language interfaces, and smart information management systems. Visual prolog addresses the same target market as SQL database systems, C++ development systems and other language tools like visual basic, Borland's Delphi, or IBM's visual age.
Facts are like relations in Database systems, representing the known data. Bill likes Cindy. Cindy likes Bill. Bill likes dogs. In Prolog likes(bill, cindy). likes(cindy, bill). likes(bill, dogs).
Natural Language Cindy likes everything that Bill likes. Caitlin likes everything that is green. Prolog likes(cindy, Something):- likes(bill, Something). likes(caitlin, Something):- green(Something). We call “likes” for a  predicate The predicate has two  clauses . A clause has a  head  and a  body . A predicate has a name and an  arity Like has two  arguments  ( arity=2 ) Read as IF
Variables start with an uppercase letter or underscore. VALID Variables My_first_correct_variable_name _My first quarter Sales_10_11_86 INVALID Variables 1stattempt second_attempt "disaster"
Variables in Prolog get their values by being  unified  with values. Until it gets a value, a variable is said to be  free ; when it gets a value, it becomes  bound . When backtracking; variables becomes free again. Variables are used as part of the pattern-matching, process, not as a kind of information storage.
PREDICATES nondeterm likes(symbol,symbol) CLAUSES likes(ellen,reading). likes(john,computers). likes(john,badminton). likes(leonard,badminton). likes(eric,swimming). likes(eric,reading). Consider this query: Is there a person who likes both reading and swimming? likes(Person, reading), likes(Person, swimming). The solutions are found through Searching, Matching/Unification and Backtracking
Basic types: Integer, Real, char, Strings, Symbols List’s [1,2,3,4] Compound structures: person(“leo”,39)  font(“arial”,b,21) Special types like binary (an array of byte values) In natural language, we ask you: Does Bill like Cindy? In Prolog syntax, we ask Prolog: likes(bill, cindy). Given this query, Prolog would answer yes
Predicates and their arguments MUST be declared. They are declared in the  PREDICATES  sections. Compound domains and sub domains can be declared in the  DOMAINS  sections. Clauses for the predicates are given in the  CLAUSES  section. Dynamic facts can be given in the  FACTS  sections (Former name was DATABASE). Execution starts in the  GOAL  Section.
We could ask you in natural language: What does Bill like? In Prolog syntax, we ask Prolog: likes(bill, What). Prolog will return  What=cindy What=dogs 2 Solutions
/* This is an example of a comment */ % This is also a comment /***************************************/ /* and so are these three lines  */ /***************************************/ /*You can also nest a  comment /*within a comment*/ like this */ CONSTANTS restricted = 1 ifdef  restricted savebase(_):- write("\nBase cannot be saved in demo version"), readchar(_). elsedef savebase(Name):- write("\nSaving ",Name), save(Name). enddef
domains mydom = i(integer); s(string) predicates procedure wr(mydom) - (i) clauses wr(i(Int)):- write("Was integer: ",Int). wr(s(Str)) :- write("Was String: ",Str). GOAL wr(i(88)). Passing input to the predicate The variable will be bound to 88 Procedure means no fail! Only input flow accepted! Case/switch statement!
Factorial of 1 is 1 Factorial of N is N multiplied with factorial of N-1 PREDICATES factorial(integer,integer) CLAUSES factorial(1,1):-!. factorial(X,FactX):- Y=X-1, factorial(Y,FactY), FactX = X*FactY.
Erroneous - Always exit failure - Always fail procedure - Always success determ - succeed or fails multi - 1 or more solutions (never fail) nondeterm - 0 or more solutions predicates   append(list,list,list)- procedure (i,i,o), determ (i,i,i) nondeterm (o,i,i)
write(Param1, Param2, Param3, ..., ParamN) readln(Line) readchar(CharParam) file_str(Filename, Text)  - file_str("t.dat", My_text) openread(SymbolicFileName, OSFileName) openwrite(SymbolicFileName, OSFileName) closefile(SymbolicFileName)
Result = cast(returndomain,Expr) LongVal = cast(LONG,”This was a text”) save(fileName) /* (i) */ save(fileName, databaseName) /* (i, i) */
Stack: the stack is used for transferring arguments and return addresses for predicate calls. The stack also holds the information for backtrackpoints. Heap:  the heap holds all objects that are more or less permanent, such as database facts, window buffers, file buffers etc. Gstack:  the global stack, normally called gstack, is the place where lists, compound structures and strings are placed. The Gstack is only released during backtracking. Trail:  the trail is only used when the program uses reference variables. It holds information about which reference variables must be unbound during backtracking. The trail is allocated in the heap.
http://rigaux.org/language-study/syntax-across-languages-per-language/Prolog.html http://en.wikipedia.org/wiki/Prolog http://en.wikipedia.org/wiki/Prolog#Data_types www.g prolog .org/manual/g prolog .html www.csci.csusb.edu/dick/samples/ prolog . predicates .html boklm.eu/ prolog /page_9.html

More Related Content

PPTX
PROLOG: Introduction To Prolog
PPTX
Prolog Programming : Basics
PPTX
Introduction to Prolog
PPT
Prolog basics
PPTX
ProLog (Artificial Intelligence) Introduction
PPTX
Introduction on Prolog - Programming in Logic
PPT
prolog ppt
PPT
Introduction to prolog
PROLOG: Introduction To Prolog
Prolog Programming : Basics
Introduction to Prolog
Prolog basics
ProLog (Artificial Intelligence) Introduction
Introduction on Prolog - Programming in Logic
prolog ppt
Introduction to prolog

What's hot (20)

PPTX
PROLOG: Arithmetic Operations In Prolog
PPTX
Asymptotic Notation
PPT
Branch and bound
PPTX
Dynamic programming
PPT
Dinive conquer algorithm
PPTX
Theory of automata and formal language
PDF
Ai lab manual
PPTX
Design and Analysis of Algorithms.pptx
PPTX
Inference in First-Order Logic
PPTX
First order logic
PPTX
Asymptotic Notations
PPTX
PROLOG: Recursion And Lists In Prolog
PPT
Randomized algorithms ver 1.0
DOCX
Artificial Intelligence Lab File
PPTX
Asymptotic notations
PPTX
Greedy Algorithms
PDF
Lecture: Word Sense Disambiguation
PPTX
Natural Language Processing: Parsing
PROLOG: Arithmetic Operations In Prolog
Asymptotic Notation
Branch and bound
Dynamic programming
Dinive conquer algorithm
Theory of automata and formal language
Ai lab manual
Design and Analysis of Algorithms.pptx
Inference in First-Order Logic
First order logic
Asymptotic Notations
PROLOG: Recursion And Lists In Prolog
Randomized algorithms ver 1.0
Artificial Intelligence Lab File
Asymptotic notations
Greedy Algorithms
Lecture: Word Sense Disambiguation
Natural Language Processing: Parsing
Ad

Similar to Artificial intelligence Prolog Language (20)

DOCX
AI Lab Manual.docx
PDF
PROLOG in artificial intelligence(Basic of pprolog)).pdf
PPTX
Unit 3 Prolog.pptxUnit 3 Prolog.pptxUnit 3 Prolog.pptxUnit 3 Prolog.pptxUnit
PDF
ICS1019.pdf
PPT
Prolog 01
PPTX
Ics1019 ics5003
PPTX
Prolog language programming in the facts.pptx
PPT
PROLOGPROLOGPROLOGPROLOGPROLOGPROLOGPROLOGPROLOGPROLOG
PPT
________ ________1.ppt
PPTX
UOS-BSIT-3811-Artificial-Intelligence-Introduction-to-prolog-PDF.pptx
PPTX
PPTX
Prolog 7-Languages
PPTX
Prolog & lisp
PPT
Chaps 1-3-ai-prolog
PPT
Chaps 1-3-ai-prolog
PPTX
Prolog final
PDF
Prolog,Prolog Programming IN AI.pdf
PPTX
Ics1019 ics5003
PDF
Turbo prolog 2.0 basics
PPTX
Lisp_Artificial Intelligence Language.pptx
AI Lab Manual.docx
PROLOG in artificial intelligence(Basic of pprolog)).pdf
Unit 3 Prolog.pptxUnit 3 Prolog.pptxUnit 3 Prolog.pptxUnit 3 Prolog.pptxUnit
ICS1019.pdf
Prolog 01
Ics1019 ics5003
Prolog language programming in the facts.pptx
PROLOGPROLOGPROLOGPROLOGPROLOGPROLOGPROLOGPROLOGPROLOG
________ ________1.ppt
UOS-BSIT-3811-Artificial-Intelligence-Introduction-to-prolog-PDF.pptx
Prolog 7-Languages
Prolog & lisp
Chaps 1-3-ai-prolog
Chaps 1-3-ai-prolog
Prolog final
Prolog,Prolog Programming IN AI.pdf
Ics1019 ics5003
Turbo prolog 2.0 basics
Lisp_Artificial Intelligence Language.pptx
Ad

More from REHMAT ULLAH (20)

PPTX
Poker Game
PPTX
Men's clothing at style war
PPTX
software project management Software development life cycle
PPTX
Software project management Improving Team Effectiveness
PPTX
software project management Software inspection
PPTX
Improving of software processes
PPT
software project management Elaboration phase
PPTX
software project management Improvement in size
PPTX
Software development life cycle Construction phase
PPTX
software project management Artifact set(spm)
PPTX
software project management Waterfall model
PPTX
Software project management Software economics
PPTX
Introduction of software project management
PPTX
software project management Cocomo model
PPTX
software project management Assumption about conventional model
PPT
Usability engineering Usability testing
PPTX
Usability engineering Usability issues(iphone)
PPTX
Usability engineering Usability issues in mobile web
PPTX
Usability engineering Usability issues in firefox
PPT
Software Quality Assurance(Sqa) automated software testing
Poker Game
Men's clothing at style war
software project management Software development life cycle
Software project management Improving Team Effectiveness
software project management Software inspection
Improving of software processes
software project management Elaboration phase
software project management Improvement in size
Software development life cycle Construction phase
software project management Artifact set(spm)
software project management Waterfall model
Software project management Software economics
Introduction of software project management
software project management Cocomo model
software project management Assumption about conventional model
Usability engineering Usability testing
Usability engineering Usability issues(iphone)
Usability engineering Usability issues in mobile web
Usability engineering Usability issues in firefox
Software Quality Assurance(Sqa) automated software testing

Recently uploaded (20)

PDF
Horaris_Grups_25-26_Definitiu_15_07_25.pdf
PPTX
What’s under the hood: Parsing standardized learning content for AI
PDF
Compact First Student's Book Cambridge Official
DOCX
Cambridge-Practice-Tests-for-IELTS-12.docx
PDF
The TKT Course. Modules 1, 2, 3.for self study
PDF
PUBH1000 - Module 6: Global Health Tute Slides
PDF
Nurlina - Urban Planner Portfolio (english ver)
PDF
Hospital Case Study .architecture design
PDF
Solved Past paper of Pediatric Health Nursing PHN BS Nursing 5th Semester
PDF
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
PDF
M.Tech in Aerospace Engineering | BIT Mesra
PDF
Disorder of Endocrine system (1).pdfyyhyyyy
PDF
Literature_Review_methods_ BRACU_MKT426 course material
PPTX
Macbeth play - analysis .pptx english lit
PPTX
2025 High Blood Pressure Guideline Slide Set.pptx
PDF
Journal of Dental Science - UDMY (2021).pdf
PPTX
CAPACITY BUILDING PROGRAMME IN ADOLESCENT EDUCATION
PDF
LIFE & LIVING TRILOGY- PART (1) WHO ARE WE.pdf
PPTX
Thinking Routines and Learning Engagements.pptx
PDF
MICROENCAPSULATION_NDDS_BPHARMACY__SEM VII_PCI Syllabus.pdf
Horaris_Grups_25-26_Definitiu_15_07_25.pdf
What’s under the hood: Parsing standardized learning content for AI
Compact First Student's Book Cambridge Official
Cambridge-Practice-Tests-for-IELTS-12.docx
The TKT Course. Modules 1, 2, 3.for self study
PUBH1000 - Module 6: Global Health Tute Slides
Nurlina - Urban Planner Portfolio (english ver)
Hospital Case Study .architecture design
Solved Past paper of Pediatric Health Nursing PHN BS Nursing 5th Semester
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
M.Tech in Aerospace Engineering | BIT Mesra
Disorder of Endocrine system (1).pdfyyhyyyy
Literature_Review_methods_ BRACU_MKT426 course material
Macbeth play - analysis .pptx english lit
2025 High Blood Pressure Guideline Slide Set.pptx
Journal of Dental Science - UDMY (2021).pdf
CAPACITY BUILDING PROGRAMME IN ADOLESCENT EDUCATION
LIFE & LIVING TRILOGY- PART (1) WHO ARE WE.pdf
Thinking Routines and Learning Engagements.pptx
MICROENCAPSULATION_NDDS_BPHARMACY__SEM VII_PCI Syllabus.pdf

Artificial intelligence Prolog Language

  • 1.  
  • 2. The first, official version of prolog was developed at the university of Marseilles, France by Alain Colmerauer in the early 1970s as a tool for programming in logic. Today, prolog is an important tool in programming artificial intelligence applications and in the development of customized knowledge bases, expert systems, natural language interfaces, and smart information management systems. Visual prolog addresses the same target market as SQL database systems, C++ development systems and other language tools like visual basic, Borland's Delphi, or IBM's visual age.
  • 3. Facts are like relations in Database systems, representing the known data. Bill likes Cindy. Cindy likes Bill. Bill likes dogs. In Prolog likes(bill, cindy). likes(cindy, bill). likes(bill, dogs).
  • 4. Natural Language Cindy likes everything that Bill likes. Caitlin likes everything that is green. Prolog likes(cindy, Something):- likes(bill, Something). likes(caitlin, Something):- green(Something). We call “likes” for a predicate The predicate has two clauses . A clause has a head and a body . A predicate has a name and an arity Like has two arguments ( arity=2 ) Read as IF
  • 5. Variables start with an uppercase letter or underscore. VALID Variables My_first_correct_variable_name _My first quarter Sales_10_11_86 INVALID Variables 1stattempt second_attempt "disaster"
  • 6. Variables in Prolog get their values by being unified with values. Until it gets a value, a variable is said to be free ; when it gets a value, it becomes bound . When backtracking; variables becomes free again. Variables are used as part of the pattern-matching, process, not as a kind of information storage.
  • 7. PREDICATES nondeterm likes(symbol,symbol) CLAUSES likes(ellen,reading). likes(john,computers). likes(john,badminton). likes(leonard,badminton). likes(eric,swimming). likes(eric,reading). Consider this query: Is there a person who likes both reading and swimming? likes(Person, reading), likes(Person, swimming). The solutions are found through Searching, Matching/Unification and Backtracking
  • 8. Basic types: Integer, Real, char, Strings, Symbols List’s [1,2,3,4] Compound structures: person(“leo”,39) font(“arial”,b,21) Special types like binary (an array of byte values) In natural language, we ask you: Does Bill like Cindy? In Prolog syntax, we ask Prolog: likes(bill, cindy). Given this query, Prolog would answer yes
  • 9. Predicates and their arguments MUST be declared. They are declared in the PREDICATES sections. Compound domains and sub domains can be declared in the DOMAINS sections. Clauses for the predicates are given in the CLAUSES section. Dynamic facts can be given in the FACTS sections (Former name was DATABASE). Execution starts in the GOAL Section.
  • 10. We could ask you in natural language: What does Bill like? In Prolog syntax, we ask Prolog: likes(bill, What). Prolog will return What=cindy What=dogs 2 Solutions
  • 11. /* This is an example of a comment */ % This is also a comment /***************************************/ /* and so are these three lines */ /***************************************/ /*You can also nest a comment /*within a comment*/ like this */ CONSTANTS restricted = 1 ifdef restricted savebase(_):- write("\nBase cannot be saved in demo version"), readchar(_). elsedef savebase(Name):- write("\nSaving ",Name), save(Name). enddef
  • 12. domains mydom = i(integer); s(string) predicates procedure wr(mydom) - (i) clauses wr(i(Int)):- write("Was integer: ",Int). wr(s(Str)) :- write("Was String: ",Str). GOAL wr(i(88)). Passing input to the predicate The variable will be bound to 88 Procedure means no fail! Only input flow accepted! Case/switch statement!
  • 13. Factorial of 1 is 1 Factorial of N is N multiplied with factorial of N-1 PREDICATES factorial(integer,integer) CLAUSES factorial(1,1):-!. factorial(X,FactX):- Y=X-1, factorial(Y,FactY), FactX = X*FactY.
  • 14. Erroneous - Always exit failure - Always fail procedure - Always success determ - succeed or fails multi - 1 or more solutions (never fail) nondeterm - 0 or more solutions predicates append(list,list,list)- procedure (i,i,o), determ (i,i,i) nondeterm (o,i,i)
  • 15. write(Param1, Param2, Param3, ..., ParamN) readln(Line) readchar(CharParam) file_str(Filename, Text) - file_str("t.dat", My_text) openread(SymbolicFileName, OSFileName) openwrite(SymbolicFileName, OSFileName) closefile(SymbolicFileName)
  • 16. Result = cast(returndomain,Expr) LongVal = cast(LONG,”This was a text”) save(fileName) /* (i) */ save(fileName, databaseName) /* (i, i) */
  • 17. Stack: the stack is used for transferring arguments and return addresses for predicate calls. The stack also holds the information for backtrackpoints. Heap: the heap holds all objects that are more or less permanent, such as database facts, window buffers, file buffers etc. Gstack: the global stack, normally called gstack, is the place where lists, compound structures and strings are placed. The Gstack is only released during backtracking. Trail: the trail is only used when the program uses reference variables. It holds information about which reference variables must be unbound during backtracking. The trail is allocated in the heap.