SlideShare a Scribd company logo
1 of 12
Prolog :
Prolog is a logic programming language associated with artificial intelligence and
computational linguistics. Prolog is intended primarily as a declarative programming language.
In prolog, logic is expressed as relations (called as Facts and Rules). Core heart of prolog lies at
the logic being applied. Formulation or Computation is carried out by running a query over these
relations. It has important role in artificial intelligence. Prolog facts are expressed in definite
pattern. Facts contain entities and their relation. Entities are written within the parenthesis
separated by comma (, ). Their relation is expressed at the start and outside the parenthesis.
Every fact/rule ends with a dot (.).
Applications :
I. expert systems
II. specification language
III. machine learning
IV. robot planning
V. automated reasoning
VI. problem solving
VII. intelligent data base retrieval
VIII. natural language understanding
1. Designa simple family relationship tree, assign necessary clause and rules to
evaluate the following relationships:
(a) Father
(b) Mother
(c) Sister
(d) Brother
(e) Grandparents
(f) Predecessors
(g) Successors
2. DesignProlog clause and rules to check the membership of an element in an list.
Prolog also has a special facility to split the first part of the list. The Head away from the
rest of the list i.e. the Tail. We can place a special symbol | in the list to distinguish
between the first item in the list and the remaining list.
For example,
[first,second,third] = [A|B] where A = first and B= [second,third]
3. Write a Prolog Program to find a factorial of a number.
Formula for calculating n! (Factorial of n) is: n! = n * (n-1)!
We will use two predicates here,
i. Factorial predicate with one argument N, that will calculate and N!
ii. Factorial predicate with two arguments N and F. This function is recursively used. It will
also calculate N!, but store it in the argument F in the process if recursion.
4. Write a Prolog program to find the maximum between two numbers.
We first check whether the numbers are equal or not. Then we check which number is larger i.e.
the First one or the Second
5. Write a Prolog program to concatenate two lists.
Combining two list into one.
6. Write a Prolog program to delete an element from a list.
7. Create Knowledge Base in Prolog for data given below:
Person Name City Code Phone Number
Kashif 02 544342
Asif 02 112345
Fahad 031 531612
Tareq 031 674245
Noman 081 753232
Aslam 081 812341
Jamil 02 912331
City Name City Code
Dhaka 02
Cumilla 081
Chittagong 031
Find the solutions using the Knowledge Base:
(a) What is the phone number of Kashif?
(b) Does Asif belong to Dhaka?
(c) Where does Noman live?
(d) Do Fahad and Tareq live in the same city?
(e) Who lives in same city where Kashif lives?

More Related Content

What's hot (11)

Application of Stack, Link list , and Queue in Programming .
Application of Stack, Link list , and Queue in Programming .Application of Stack, Link list , and Queue in Programming .
Application of Stack, Link list , and Queue in Programming .
 
LISP: Scope and extent in lisp
LISP: Scope and extent in lispLISP: Scope and extent in lisp
LISP: Scope and extent in lisp
 
Intro to python
Intro to pythonIntro to python
Intro to python
 
Designing A Syntax Based Retrieval System03
Designing A Syntax Based Retrieval System03Designing A Syntax Based Retrieval System03
Designing A Syntax Based Retrieval System03
 
A10
A10A10
A10
 
[計一] Basic r programming final0918
[計一] Basic r programming   final0918[計一] Basic r programming   final0918
[計一] Basic r programming final0918
 
Recursion CBSE Class 12
Recursion CBSE Class 12Recursion CBSE Class 12
Recursion CBSE Class 12
 
Python if for
Python if forPython if for
Python if for
 
Python Fundamentals Class 11
Python Fundamentals Class 11Python Fundamentals Class 11
Python Fundamentals Class 11
 
Relational Algebra Operations
Relational Algebra OperationsRelational Algebra Operations
Relational Algebra Operations
 
Clean code
Clean codeClean code
Clean code
 

Similar to Artificial intelligence - Prolog

Prolog (present)
Prolog (present) Prolog (present)
Prolog (present)
Melody Joey
 
UOS-BSIT-3811-Artificial-Intelligence-Introduction-to-prolog-PDF.pptx
UOS-BSIT-3811-Artificial-Intelligence-Introduction-to-prolog-PDF.pptxUOS-BSIT-3811-Artificial-Intelligence-Introduction-to-prolog-PDF.pptx
UOS-BSIT-3811-Artificial-Intelligence-Introduction-to-prolog-PDF.pptx
qasim ali
 
Coates p: the use of genetic programing in exploring 3 d design worlds
Coates p: the use of genetic programing in exploring 3 d design worldsCoates p: the use of genetic programing in exploring 3 d design worlds
Coates p: the use of genetic programing in exploring 3 d design worlds
ArchiLab 7
 

Similar to Artificial intelligence - Prolog (20)

Introduction to Artificial Intelligence...pptx
Introduction to Artificial Intelligence...pptxIntroduction to Artificial Intelligence...pptx
Introduction to Artificial Intelligence...pptx
 
MODELLING OF INTELLIGENT AGENTS USING A–PROLOG
MODELLING OF INTELLIGENT AGENTS USING A–PROLOGMODELLING OF INTELLIGENT AGENTS USING A–PROLOG
MODELLING OF INTELLIGENT AGENTS USING A–PROLOG
 
Turbo prolog 2.0 basics
Turbo prolog 2.0 basicsTurbo prolog 2.0 basics
Turbo prolog 2.0 basics
 
Prolog (present)
Prolog (present) Prolog (present)
Prolog (present)
 
Presentation1
Presentation1Presentation1
Presentation1
 
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
 
AI Lab Manual.docx
AI Lab Manual.docxAI Lab Manual.docx
AI Lab Manual.docx
 
AI: Logic in AI
AI: Logic in AIAI: Logic in AI
AI: Logic in AI
 
AI: Logic in AI
AI: Logic in AIAI: Logic in AI
AI: Logic in AI
 
IDENTIFYING THE SEMANTIC RELATIONS ON UNSTRUCTURED DATA
IDENTIFYING THE SEMANTIC RELATIONS ON UNSTRUCTURED DATAIDENTIFYING THE SEMANTIC RELATIONS ON UNSTRUCTURED DATA
IDENTIFYING THE SEMANTIC RELATIONS ON UNSTRUCTURED DATA
 
Identifying the semantic relations on
Identifying the semantic relations onIdentifying the semantic relations on
Identifying the semantic relations on
 
THE PERFORMANCE COMPARISON OF A BRUTEFORCE PASSWORD CRACKING ALGORITHM USING ...
THE PERFORMANCE COMPARISON OF A BRUTEFORCE PASSWORD CRACKING ALGORITHM USING ...THE PERFORMANCE COMPARISON OF A BRUTEFORCE PASSWORD CRACKING ALGORITHM USING ...
THE PERFORMANCE COMPARISON OF A BRUTEFORCE PASSWORD CRACKING ALGORITHM USING ...
 
CPPDS Slide.pdf
CPPDS Slide.pdfCPPDS Slide.pdf
CPPDS Slide.pdf
 
Data Science Using Python.pptx
Data Science Using Python.pptxData Science Using Python.pptx
Data Science Using Python.pptx
 
Basic review on topic modeling
Basic review on  topic modelingBasic review on  topic modeling
Basic review on topic modeling
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
Coates p: the use of genetic programing in exploring 3 d design worlds
Coates p: the use of genetic programing in exploring 3 d design worldsCoates p: the use of genetic programing in exploring 3 d design worlds
Coates p: the use of genetic programing in exploring 3 d design worlds
 

More from Sunjid Hasan

More from Sunjid Hasan (10)

Software engineering( sms )
Software engineering( sms )Software engineering( sms )
Software engineering( sms )
 
System analysis design of Fire Service & Civil Defence
System analysis design of Fire Service & Civil DefenceSystem analysis design of Fire Service & Civil Defence
System analysis design of Fire Service & Civil Defence
 
Digital image processing recognition of bengali handwritten digits using co...
Digital image processing   recognition of bengali handwritten digits using co...Digital image processing   recognition of bengali handwritten digits using co...
Digital image processing recognition of bengali handwritten digits using co...
 
Artificial intelligence - python
Artificial intelligence - pythonArtificial intelligence - python
Artificial intelligence - python
 
Cover page sample
Cover page sampleCover page sample
Cover page sample
 
Compiler and symbol table
Compiler and symbol tableCompiler and symbol table
Compiler and symbol table
 
System analysis design of fire service and civil defence
System analysis design of fire service and civil defenceSystem analysis design of fire service and civil defence
System analysis design of fire service and civil defence
 
Online blood sharing application
Online blood  sharing applicationOnline blood  sharing application
Online blood sharing application
 
Messaging application
Messaging applicationMessaging application
Messaging application
 
Estimation for software
Estimation for softwareEstimation for software
Estimation for software
 

Recently uploaded

Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
fonyou31
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
SoniaTolstoy
 

Recently uploaded (20)

Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 

Artificial intelligence - Prolog

  • 1. Prolog : Prolog is a logic programming language associated with artificial intelligence and computational linguistics. Prolog is intended primarily as a declarative programming language. In prolog, logic is expressed as relations (called as Facts and Rules). Core heart of prolog lies at the logic being applied. Formulation or Computation is carried out by running a query over these relations. It has important role in artificial intelligence. Prolog facts are expressed in definite pattern. Facts contain entities and their relation. Entities are written within the parenthesis separated by comma (, ). Their relation is expressed at the start and outside the parenthesis. Every fact/rule ends with a dot (.). Applications : I. expert systems II. specification language III. machine learning IV. robot planning V. automated reasoning VI. problem solving VII. intelligent data base retrieval VIII. natural language understanding
  • 2. 1. Designa simple family relationship tree, assign necessary clause and rules to evaluate the following relationships: (a) Father (b) Mother
  • 8. 2. DesignProlog clause and rules to check the membership of an element in an list. Prolog also has a special facility to split the first part of the list. The Head away from the rest of the list i.e. the Tail. We can place a special symbol | in the list to distinguish between the first item in the list and the remaining list. For example, [first,second,third] = [A|B] where A = first and B= [second,third] 3. Write a Prolog Program to find a factorial of a number. Formula for calculating n! (Factorial of n) is: n! = n * (n-1)! We will use two predicates here, i. Factorial predicate with one argument N, that will calculate and N! ii. Factorial predicate with two arguments N and F. This function is recursively used. It will also calculate N!, but store it in the argument F in the process if recursion.
  • 9. 4. Write a Prolog program to find the maximum between two numbers. We first check whether the numbers are equal or not. Then we check which number is larger i.e. the First one or the Second
  • 10. 5. Write a Prolog program to concatenate two lists. Combining two list into one. 6. Write a Prolog program to delete an element from a list.
  • 11. 7. Create Knowledge Base in Prolog for data given below: Person Name City Code Phone Number Kashif 02 544342 Asif 02 112345 Fahad 031 531612 Tareq 031 674245 Noman 081 753232 Aslam 081 812341 Jamil 02 912331 City Name City Code Dhaka 02 Cumilla 081 Chittagong 031 Find the solutions using the Knowledge Base: (a) What is the phone number of Kashif?
  • 12. (b) Does Asif belong to Dhaka? (c) Where does Noman live? (d) Do Fahad and Tareq live in the same city? (e) Who lives in same city where Kashif lives?