SlideShare a Scribd company logo
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

PPTX
Functions as models
PPT
stacks in algorithems and data structure
PDF
Response to uspto on the first topic v5
PDF
Csit77406
PPTX
Pa1 session 1_recap
PPTX
Data Structure and Algorithms –Introduction.pptx
PDF
L7
PPTX
5 cs xii_python_functions _ passing str list tuple
Functions as models
stacks in algorithems and data structure
Response to uspto on the first topic v5
Csit77406
Pa1 session 1_recap
Data Structure and Algorithms –Introduction.pptx
L7
5 cs xii_python_functions _ passing str list tuple

What's hot (11)

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

Similar to Artificial intelligence - Prolog (20)

PPTX
Introduction to Artificial Intelligence...pptx
PDF
MODELLING OF INTELLIGENT AGENTS USING A–PROLOG
PDF
Turbo prolog 2.0 basics
PPTX
Unit 3 Prolog.pptxUnit 3 Prolog.pptxUnit 3 Prolog.pptxUnit 3 Prolog.pptxUnit
PPTX
Prolog (present)
PPTX
Presentation1
PPTX
ARTIFICIAL INTELLIGENCE---UNIT 4.pptx
PDF
Prolog,Prolog Programming IN AI.pdf
PPTX
UOS-BSIT-3811-Artificial-Intelligence-Introduction-to-prolog-PDF.pptx
DOCX
AI Lab Manual.docx
PPTX
AI: Logic in AI
PPTX
AI: Logic in AI
PDF
IDENTIFYING THE SEMANTIC RELATIONS ON UNSTRUCTURED DATA
PDF
IDENTIFYING THE SEMANTIC RELATIONS ON UNSTRUCTURED DATA
PDF
Identifying the semantic relations on
PDF
THE PERFORMANCE COMPARISON OF A BRUTEFORCE PASSWORD CRACKING ALGORITHM USING ...
PDF
data base nd analystics slybysss for the students to improbvr
PDF
The Performance Comparison of a Brute-Force Password Cracking Algorithm using...
PDF
CPPDS Slide.pdf
PPTX
Data Science Using Python.pptx
Introduction to Artificial Intelligence...pptx
MODELLING OF INTELLIGENT AGENTS USING A–PROLOG
Turbo prolog 2.0 basics
Unit 3 Prolog.pptxUnit 3 Prolog.pptxUnit 3 Prolog.pptxUnit 3 Prolog.pptxUnit
Prolog (present)
Presentation1
ARTIFICIAL INTELLIGENCE---UNIT 4.pptx
Prolog,Prolog Programming IN AI.pdf
UOS-BSIT-3811-Artificial-Intelligence-Introduction-to-prolog-PDF.pptx
AI Lab Manual.docx
AI: Logic in AI
AI: Logic in AI
IDENTIFYING THE SEMANTIC RELATIONS ON UNSTRUCTURED DATA
IDENTIFYING THE SEMANTIC RELATIONS ON UNSTRUCTURED DATA
Identifying the semantic relations on
THE PERFORMANCE COMPARISON OF A BRUTEFORCE PASSWORD CRACKING ALGORITHM USING ...
data base nd analystics slybysss for the students to improbvr
The Performance Comparison of a Brute-Force Password Cracking Algorithm using...
CPPDS Slide.pdf
Data Science Using Python.pptx
Ad

More from Sunjid Hasan (10)

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

Recently uploaded (20)

PDF
Basic Mud Logging Guide for educational purpose
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Pharma ospi slides which help in ospi learning
PDF
Sports Quiz easy sports quiz sports quiz
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Complications of Minimal Access Surgery at WLH
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Cell Types and Its function , kingdom of life
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
RMMM.pdf make it easy to upload and study
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
Basic Mud Logging Guide for educational purpose
O5-L3 Freight Transport Ops (International) V1.pdf
Pharma ospi slides which help in ospi learning
Sports Quiz easy sports quiz sports quiz
Anesthesia in Laparoscopic Surgery in India
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
human mycosis Human fungal infections are called human mycosis..pptx
TR - Agricultural Crops Production NC III.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Complications of Minimal Access Surgery at WLH
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
Cell Types and Its function , kingdom of life
Microbial diseases, their pathogenesis and prophylaxis
Supply Chain Operations Speaking Notes -ICLT Program
RMMM.pdf make it easy to upload and study
01-Introduction-to-Information-Management.pdf
Final Presentation General Medicine 03-08-2024.pptx

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?