0% found this document useful (0 votes)
22 views41 pages

AI Lab Manual

The document outlines the course structure and objectives for the Artificial Intelligence Lab (KIT-751A) at Meerut Institute of Engineering and Technology, detailing the course outcomes, teaching methodologies, and evaluation criteria. It emphasizes the vision and mission of the institute and department, aiming to produce competent professionals in the field of Information Technology. Additionally, it includes a lesson plan, lab experiments, and resources for students to enhance their understanding of Prolog and AI concepts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views41 pages

AI Lab Manual

The document outlines the course structure and objectives for the Artificial Intelligence Lab (KIT-751A) at Meerut Institute of Engineering and Technology, detailing the course outcomes, teaching methodologies, and evaluation criteria. It emphasizes the vision and mission of the institute and department, aiming to produce competent professionals in the field of Information Technology. Additionally, it includes a lesson plan, lab experiments, and resources for students to enhance their understanding of Prolog and AI concepts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

MEERUT INSTITUTE OF ENGINEERING &

TECHNOLOGY MEERUT

DR. A.P.J. ABDUL KALAM TECHNICAL


UNIVERSITY LUCKNOW

Subject Name: Artificial Intelligence Lab


Subject Code: (KIT-751A)
Course Name: B.Tech

Department of Information Technology


Meerut Institute of Engineering and Technology, Meerut
Coursefile Checklist : 2023-24
Subject Name : Artificial Intelligence Lab Subejct Code : KIT 751A
Faculty Name : Mr. Rahul Singh Theory / Lab : Lab
Course Handout covers the Course File Contents as per S. No. 01 to 06.
S. Observation /
Parameter / Description Completion Status
No. Remarks
1 Basic Course Details
Vision and Mission of the Institute, Vision and Mission of the
2
Department, PEOs, POs, PSOs
Teaching and Evaluation Scheme, Syllabus of Subject (List of
3 Experiments - as prescribed by AKTU), List of standard / text /
reference books, other study material / web links / Virtual Lab
Statements of COs, CO-wise Syllabus (List of Experiments), CO-
4
PO Mapping, CO-PSO Mapping, Course End Survey (Blank Form)

5 Lab Performance Plan


Attainment Levels and Assessment Tools (direct and indirect
6
methods both)
7 Lab Playout, List of Equipment / Machines / Experiment Setup
8 Basic Course / Study Material / Notes (related to Lab Course)
9 Lab Manuals
10 Quiz / Viva Questions

To be prepared during / after the classes (not prior to the commencement of the classes)
11 Students Lists
12 Personal and Class Time-table
13 Lab Performance Record (Continuous Evaluation)
Record of CO-Attainment (as per OBE-06B) and Actions taken / to
14
be taken to improve attainment / academic performance
Attendance Register with Lab Plan / Performance Record
15
(completed)
16 Sessional Marks (AM-09 and Marks Uploaded to AKTU)
Record of Evaluated Lab Records (all tests, all sheets, Jobs),
17
Quizzes / Viva, Duly filled Course End Survey etc.
18 Any Other
Meerut Institute of Engineering and Technology, Meerut
Department of Information Technology
Lab Manual Artificial Intelligence Lab 2023-24

1 Name of the Course / Subject B.Tech (Artificial Intelligence Lab)


2 Subject / Course Code Artificial Intelligence (KCS-071)
3 To be Taught in (Program / Branch Name) Information Technology
4 Semester of Teaching / Course Offering Mr. Rahul Singh
5 Theory / Lab Lab
6 Rubrcis Based Evaluation (Yes / No) YES
7 Core / Elective Elective
Total No. of Lectures / Lab Turns Required to
8 15
complete the entire Syllabus
AKTU Prescribed L T P Extra Total Credits Int. Marks Ext. Marks
9
Teaching Load 2 0 1 1 25 25
10 Faculty Name Mr. Rahul Singh
11 Designation Assistant Professor
12 Department Information Technology
COLLEGE VISION, MISSION AND OBJECTIVE

Vision
To be an outstanding institution in the country imparting technical education, providing need-
based, value-based and career-based programmes and producing self-reliant, self-sufficient
technocrats capable of meeting new challenges.

Mission
The mission of the institute is to educate young aspirants in various technical fields to fulfill
global requirement of human resources by providing sustainable quality education, training
and invigorating environment besides molding them into skilled competent and socially
responsible citizens who will lead the building of a powerful nation.

Objectives
The objective of the institute is to have necessary instruments and resources to deliver
technical manpower that not only meets the local industry requirements but is also an
acceptable human resource for the global job market in Management & Technology as well
as Master in Computer Application and other technological sectors. We aim to provide
quality technical education facilities to every student admitted to the institute along with the
development of all round personality of the students. To be a technically high and
professional institute, we ensure to provide most competent staff and excellent support
facilities like well-equipped library, lecture theaters, computer and scientific laboratories
fitted with high quality equipment. The institute organizes in-house and outside training
programmes, seminars, conferences and workshops on continuous basis and encourages
participation of staff and students to improve its Academic Pedagogy through innovative
ideas and techniques in order to impart quality education. To fill the perception gap between
expectation of industry and preferences of academia through industry institute cell, we
organize interactive sessions in the campus. To produce competitive professionals for
meeting the upcoming demand of the nation, the institute will always remain dedicated to the
social causes of the public of this region.
DEPARTMENT VISION AND MISSION

Vision

To become a prominent department in nation which provides quality education,


keeping pace with rapidly changing technologies, and to create technical
graduates of global standards, who develop capabilities of accepting new
challenges in the field of Information Technology.

Mission

M1: To provide quality education in the core and applied areas of information
technology, and develop students from all socio-economic levels into globally
competent professionals.

M2: To impart professional ethics, social responsibilities, moral values and


entrepreneur skills to the students.

M3: To invigorate students skills so that deploy their potential in research and
development, and inculcate the habit of lifelong learning.
Program Educational Objectives, Program Outcomes, Program
Specific Outcome, Course Outcomes and Mapping with POs

Program Educational Objectives


PEO 1: Students will have successful careers in IT and allied sectors with high quality
technical skills for global competence.

PEO 2: To bring the physical, analytical and computational approaches of IT to solve real
world Engineering problems and provide innovative solutions by applying appropriate
models, tools and evaluations.

PEO 3: Be adaptable to rapidly changing technological advancements through continuous


learning and research to meet the diversified needs of the industry.

PEO 4: Students to imbibe professional attitudes, team spirit, effective communication and
contribute ethically to the needs of the society with moral values.

PEO 5: Encourage students for higher studies and entrepreneurial skills by imparting the
quality of lifelong learning in emerging technologies and work in multidisciplinary roles and
capacities.

Program Outcomes

1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering


fundamentals, and an engineering specialization to the solution of complex engineering
problems.

2. Problem analysis: Identify, formulate, review research literature, and analyse complex
engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineering sciences.

3. Design/development of solutions: Design solutions for complex engineering problems


and design system components or processes that meet the specified needs with appropriate
consideration for the public health and safety, and the cultural, societal, and environmental
considerations
4. Conduct investigations of complex problems: Use research-based knowledge and
research methods including design of experiments, analysis and interpretation of data, and
synthesis of the information to provide valid conclusions.

5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and
modern engineering and IT tools including prediction and modeling to complex engineering
activities with an understanding of the limitations.

6. The engineer and society: Apply reasoning informed by the contextual knowledge to
assess societal, health, safety, legal and cultural issues and the consequent responsibilities
relevant to the professional engineering practice.

7. Environment and sustainability: Understand the impact of the professional engineering


solutions in societal and environmental contexts, and demonstrate the knowledge of, and need
for sustainable development.

8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the engineering practice.

9. Individual and team work: Function effectively as an individual, and as a member or


leader in diverse teams, and in multidisciplinary settings.

10. Communication: Communicate effectively on complex engineering activities with the


engineering community and with society at large, such as, being able to comprehend and
write effective reports and design documentation, make effective presentations, and give and
receive clear instructions.

11. Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a member and
leader in a team, to manage projects and in ltidisciplinary environments.

12. Life-long learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the broadest context of technological change
Program Specific Outcomes

1. PSO 1: Ability to understand, apply and analyze computational concepts in the areas
related to algorithms, machine learning, multimedia, web designing, Data Science, and
networking on the systems having different degree of complexity.

2. PSO 2: Ability to apply standard practices and methodologies in software development


and project management using learned concepts and skills to deliver a quality product.

3. PSO 3: Ability to employ contemporary computer languages, environment and platforms


towards enriched career opportunities and zeal for higher studies.
Department of Information Technology

Artificial Intelligence Lab


KIT-751A
Course Outcome
CO1: Understand the fundamental of knowledge representation and inference using prolog.
CO2: Understand the fundamental of knowledge representation theorem proving using
prolog.
CO3: Demonstrate working knowledge of reasoning in the presence of incomplete and / or
uncertain information.
Meerut Institute of Engineering & Technology, Meerut
Lesson Plan / Teaching Plan / Lecture Plan with Progress : B Tech - IT, Semester : VII, Session 2023-24
Course Name (Code) : Artificial Intelligence Lab (KIT-751A) Faculty : Rahul Singh
Experiments (title) are arranged in sequence - same - as to be conducted in the Lab. Maintain data related to "Date" in its hard copy.
Lab Turn Date
S. CO Teaching Reference
Sequence Experiment (Title) to be conducted Actual Remarks, if any
No. (No) Pedagogy Material Planned
No Delivery
1 1 CO1 Write about Prolog PPT Notes
Write a program using Arithmetic operators in
2 2 CO1 PPT Notes
Prolog.
3 2 CO2 Write a program to implement family tree. PPT Notes
4 3 CO2 Write program of lists PPT Notes

5 4 CO2 Write a program of prolog for DFS and BFS PPT Notes

6 4 CO2 Write a program of prolog for Tower of Hanoi. PPT Notes

Write a program in Prolog for Water jug


7 5 CO2 PPT Notes
Problem
Write a program for expert system by using
8 6 CO3 PPT Notes
forward chaining.

9 7 CO3 Write a program to solve 8 puzzle problem PPT Notes

Write a program to solve monkey banana


10 8 CO3 PPT Notes
problem.

Course Outcomes (COs)


COx Statement
1 Understand the fundamentals of knowledge representation and inference using prolog
2 Understand the fundamentals of knowledge representation, inference and theorem proving using prolog
3 Demonstrate working knowledge of reasoning in the presence of incomplete and / or uncertain informaiton

Study Material / Books / Web-resources / Online Courses Links etc.


S. No. Description
1 S. Russell and P. Norvig, “Artificial Intelligence: A Modern Approach, Prentice Hall Third Edition, 2009.

2 I. Bratko, “Prolog: Programming for Artificial Intelligence”, Fourth edition, Addision-Wesley Educational Publishers Inc., 2011

M.Tim Jones, Artificial Intelligence: A Systems Approach(Computer Science), Jones and Bartlett Publishers, Inc. First Edition,
3
2008.
4 Nils J. Nilsson, The Quest for artificial intelligence, Cambridge University press, 2009

5 William F. Clocksin and Christopher S. Mellish, Programming in Prolog: Using the ISO standard, Fifth Edition, Springer, 2003.

6 Gerhard Weiss, Multi Agent Systems, Second Edition, MIT Press, 2003
Meerut Institute of Engineering and Technology, Meerut
Statements of Course Outcomes (COs) and Mapping with Program Outcomes (POs) and Program Specific Outcomes (PSOs)
BKL # K1 – Remember, K2 – Understand, K3 – Apply, K4 – Analyze, K5 – Evaluate, K6 – Create
Subject / Course Name : B.Tech (AI Lab) Name of Faculty / Subject Head : Mr. Rahul Singh Theory / Lab
PO PO PO PO PO PO PO PO PO PO PO PO PSO PSO PSO PSO
Statement of Course Outcomes (COs) Kx
1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4

Environment & sustainability


The Engineer and Society
Blooms Knowledge Level

Project management and


Conduct investigations of

Individual and team work


Engineering knowledge

Design/development of

Modern tool usage

Life Long Learning


complex problems
Problem Analysis

Communications
S. No. Sub Code COx Statement of Course Outcomes (COs)

solutions

finance
Ethics
Upon completion of topic concerned, students will be
able to :

Understand the Concepts of AI an dClassify the different


CO-1 K2 1 1 2 1
types of AI agents.

CO-2 Recognize and Evaluate Different AI Search Algorithms K3 2 1 2 2 2 2 1.00 1.00


KIT-751A

1
Formulate the Necessity of Knowledge representiaon and
CO-3 experiment the presence of incomplete or Uncertain K2 1 1 1 1 1 2 1.00
informaiton
KIT 751A K3 1.33 1.00 2.00 1.50 1.00 1.30 1.00 2.00 2 1.00 1.00

S. No. COx - POx / PSOx Reason / Justification for Mapping


1 CO-1 => PO-1
2
3
4
5
Meerut Institute of Engineering and Technology, Meerut
Course End Survey # 2023-24 (Odd / Even Sem)

Name of the Course : B.Tech Session : 2023-24


Course Code : KIT 751A Semester : VII
Name of the Faculty : Mr. Rahul Singh Student Roll No (Optional) :
Department : Information Technology Student Name (Optional) :
Tick in appropriate column
S. Partially
Statement Agree Disagree
No. Agree
1 Excel in understanding and implementing prolog concept and programming
2 Understand in tools and Framework
3 Develop and implement creative AI solutions to solve complex programming
4 Adeptly apply in collaborative setting to address real-world issues.
EXPERIMENT: 1
WRITE ABOUT PROLOG
OBJECTIVE
Write about Prolog.
INTRODUCTION
Programming Logic, Prolog is a high-level programming language based on formal logic.
Unlike traditional programming languages that are based on performing sequences of
commands, Prolog is based on defining and then solving logical formulas. Prolog is
sometimes called a declarative language or a rule-based language because its programs
consist of a list of facts and rules. Prolog is used widely for artificial intelligence applications,
particularly expert systems.

Areas in which prolog programming language is used


Following are some areas in which prolog are used:
1. 1intelligent data base retrieval
2. natural language understanding
3. expert systems
4. specification language
5. machine learning
6. robot planning
7. automated reasoning
8. problem solving

Importance of Prolog Programming Language


Following are some points for using prolog more:
1. SWI-Prolog is free, open-source, and very well maintained.
2. It is much easier to distribute SWI-Prolog applications than Java ones
3. Prolog allows one to define any word or collection of "symbol characters" (e.g. >>, +,
/,,//,=====:) as an infix, postfix, or prefix operator.
4. In Prolog, you can treat data as programs.
5. Prolog is interactive.
Data types used in prolog programming language
Following are the data types supported by prolog:
Prolog's single data type is the term. Terms are atoms, numbers, variables or compound
terms.
1. ATOM: An atom is a general-purpose name with no inherent meaning.
2. NUMBERS: Numbers are like integers, float etc.
3. VARIABLES: Are denoted string consisting of letters, numbers, underscore
characters, and beginning with an upper-case letter or underscore.
4. COMPOUND TERMS: A compound term is composed of an atom called a
"functor" and a number of "arguments", which are again terms. They are written by
separating them by commas.
Variables are used in prolog as
Suppose we want to ask, "What course does ROBIN teach"?, then we can write it in prolog as
"Is there a course x, that ROBIN teaches? "
here x stands for an object that the questioner does not know about yet, so to answer the
prolog has to find the value of x. If we know the value of variable then it is known as
BOUND, if we don't know then known as UNBOUND.

Platform: Windows 7/ SWI- prolog


Program:
Clauses are:
likes(mary,food).
likes(mary, wine).
likes(john, wine).
likes (john,mary).

The following queries yield the specified answers.


| ?-likes(mary,food).
yes.
| ?- likes(johin,wine).
yes.
| ?-likes(john,food).
no.
How do you add the following facts?
1. John likes anything that Mary likes
2. John likes anyone who likes wine
3. John likes anyone who likes themselves
In prolog facts and rules are used as follows:
Facts
Facts English Meanings
Food (Burger) // burger is a food
Food(sandwich) // sandwich is a food
Food(Pizza) // pizza is a food
Lunch(sandwich) // sandwich is a lunch
Dinner(Pizza) // pizza is a dinner

Rules
Meal(X):- food (X) // Every food is a meal OR anything is a meal if it is food

Queries/ Goal
?- food(pizza) // Is pizza a food?
?- meal(X), lunch(X) // Which food is meal and lunch?
?-dinner(Sandwich). // Is sandwich a dinner?
EXPERIMENT: 2
WRITE A PROGRAM OF USING ARITHMETIC OPERATORS IN PROLOG

AIM
Write a program of using arithmetic operators in prolog.
Platform: Windows 7/ SWI- Prolog.
Program.
?-X is 10+5
X=15
Yes

?-X is 10-5
X=5
Yes

?-X is 10*5
X= 50
Yes

?-X is 10/5
X=2
Yes
?-X is 10+5*6/3
X=20
Yes

?-power(3,2,P)
P=8
Yes

?-R is mod(7,2)
R=1
yes
EXPERIMENT: 3
WRITE A PROGRAM TO IMPLEMENT FAMILY TREE WITH PREDICATES
LIKE FATHER, MOTHER, SON, DAUGHTER, GRANDFATHER, AUNT, UNCLE,
COUSIN, ANCESTOR FOR FACTS LIKE MALE, FEMALE, PARENT, BROTHER,
SISTER.

AIM-Write a program to Implement family tree with predicates like father, mother, son,
daughter, grandfather, aunt, uncle, cousin, ancestor for facts like male, female, parent,
brother, sister.
Platform: Window 7/ SWI- Prolog
Program:
male(shankar).
male(ulhas).
male(satish).
male(saurabh).
male(prashant).

female(umabai).
female(mrunal).
female(sadhana).
female(swati).

parent(shankar,umabai,ulhas).
parent(shankar,umabai,satish).
parent(ulhas,mrunal,prashant).
parent(satish,sadhana,saurabh).
parent(satish,sadhana,swati).

brother(ulhas,satish).
brother(satish,ulhas).
brother(prashant,saurabh).
brother(saurabh,prashant).

sister(swati,saurabh).
sister(swati,prashant).

father(X,Y):- parent(X,Z,Y).
mother(X,Y):- parent(Z,X,Y).

son(X,Y,Z):-male(X), father(Y,X), mother(Z,X).


daughter(X,Y,Z):- female(X), father(Y,X), mother(Z,X).

wife(X,Y) :- female(X),parent(Y,X,Z).

grandfather(X,Y) :- male(X), father(X,Z), father(Z, Y).

uncle(X,Y):- male(X), brother(X,Z), father(Z,Y)

aunt(X,Y):- wife(X,Z), uncle(Z,Y).

cousin (X,Y):- father(Z,X), brother(Z, W), father(W,Y).

ancestor(X,Y,Z):-parent(X,Y,Z).
ancestor(X,Y,Z):- parent(X,Y,W), ancestor(W,U,Z).
**********************Output**********************
I ?- father(X,Y).
X=shankar
Y = ulhas;
X=shankar
Y = satish;
X=ulhas
Y = prashant ;
X=satish
Y = saurabh ;
X=satish
Y = swati ;
No
**************************************************************
2 ?- mother(X,Y).
X=umabai
Y = ulhas;
X=umabai
Y = satish;
X=mrunal
Y = prashant ;
X=sadhana
Y = saurabh ;
X=sadhana
Y = swati ;
No
*************************************
3 ?- parent(X,Y,Z).
X=shankar Y=umabai
Z = ulhas;
X=shankar Y=umabai
Z = satish;
X=ulhas Y=mrunal
Z = prashant ;
X=satish Y=sadhana
Z = saurabh ;
X=satish
Y=sadhana
Z = swati ;
No
*******************************************
4?- son(prashant,X,Y).
X=ulhas
Y = mrunal
Yes
*******************************************
5?- daughter(swati,X,Y).
X=satish
Y = sadhana
Yes
*********************************************
7?- grandfather(X,Y).
X=shankar
Y = prashant ;

X=shankar
Y = saurabh ;
X=shankar
Y = swati ;
No
************************
7?- aunt(X,Y).
X=mrunal
Y = saurabh ;
X=mrunal
Y = swati ;
X=sadhana
Y = prashant ;
X=sadhana
Y = prashant ;
No
************************
8 ?- uncle(ulhas,X).
X = saurabh ;
X = swati ;
No
*************************
9 ?- cousin(X,Y).
X=prashant
Y = saurabh ;
X=prashant Y = swati ;
X=saurabh
Y = prashant ;
X=swati Y = prashant ;
**********************************

No
*******************************
10 ?- ancestor(X,Y,prashant).
X=ulhas
Y = mrunal;
X=shankar Y = umabai ;
No
EXPERIMENT: 4
WRITE A PROGRAM OF LISTS.

AIM
Write a program of lists.
Platform: Windows 7/ SWI- prolog
Program:
There is an empty list as [ ].
Head and Tail of the lists:
head the 1st element of the list.
tail: all elements of the list except the 1stone

Syntax: [HT]
(a) length of a list
size([],0).
size([HT],N):- size(T,N1), N is N1+1.
% or size([T],N) :- size(T,N1), N is N1+1.
|?- size([1,2,3,4],N).
N=4
yes
| ?-size([bill,ted,ming,pascal,nat,ron],N).
N=6
yes
| ?- size([a, [b, c, d], e, [f| g], h], N).
N=5
Yes

(b) summing elements of a list of numbers


sumlist([],0).
ssumlist([HT],N) :- sumlist(T,N1), N is N1+H.
(c) list membership

member(X,[X]).
member(X,[T]):- member(X,T).
(d) reversing a list
reverse(List, Reversed) :-
reverse(List, [], Reversed).
reverse([], Reversed, Reversed).
reverse([Head Tail], SoFar, Reversed) :-
reverse(Tail, [Head|SoFar], Reversed).
| ?- myreverse([a,b,c,d],X).
X = [d,c,b,a];
<- note semicolon (more solns?)
no
!?- myreverse([a,b,c,d],[d,b,c,a]).
no
!?- myreverse([a,b,c,d],[d,c,b,a]).
yes
- note difference between reverse/2 and reverse/3 - reverse/3 probably should be called
reverseHelper or something else for clarity
EXPERIMENT: 5
WRITE A PROGARM IN PROLOG FOR DEPTH FIRST SEARCH

AIM
Write a program in prolog for Depth first search.
Platform: Windows 7/ SWI- Prolog
Program:
Child(a,b) /* b is child of a*/
Child(a,c) /* c is child of a*/
Child(a,d) /* d is child of a*/
Child(b,e) /* e is child of b*/
Child(b,f) /* f is child of b*/
Child(c,g) /* g is child of c*/
Childnode(A,G,[G]:- child(A,G))
Childnode(A,G,[X|L]):-child(A,X), childnode(X,G,L)
Path(A,G,[A|Z]):- childnode(A,G,Z) /* to find path between root to leaf*/

Result:
?_path(a,e,L)
L=[a,b,e]
EXPERIMENT: 6
WRITE A PROGRAM IN PROLOG TO SOLVE TOWER OF HANOI

AIM
Write a program in prolog to solve Tower of Hanoi.
Platform: Windows 7/ SWI- prolog
Program:
The 3-disk setup is like this:
XXX
XXXXX
XXXXXXX
Here's a sample:
% move(N,X,Y,Z) - move N disks from peg X to peg Y, with peg Z being the % auxilliary
peg%
% Strategy:
% Base Case: One disc - To transfer a stack consisting of 1 disc from
% peg X to peg Y, simply move that disc from X to Y
% Recursive Case: To transfer n discs from X to Y, do the following:
Transfer the first n-1 discs to some other peg X
Move the last disc on X to Y
Transfer the n-1 discs from X to peg Y
move(1,X,Y,_):-
write('Move top disk from '),
write(X),
write(' to '),
write(Y),
nl.
move(N,X,Y,Z):-
N>1,
M is N-1,
move(M,X,Z,Y),
move(1,X,Y,_),
move(M,Z,Y,X).
- note the use of "anonymous" variables
Here is what happens when Prolog solves the case N=3.

?- move(3,left,right,center)
Move top disk from left to right
Move top disk from left to center
Move top disk from right to center
Move top disk from left to right
Move top disk from center to left
Move top disk from center to right
Move top disk from left to right
Yes
EXPERIMENT: 7
WRITE A PROGRAM IN PROLOG FOR JUG PROBLEM
USING HEURISTIC FUNCTION

AIM
Write a program in prolog for Water jug problem using heuristic function.
Platform: Windows 7/ SWI- prolog
Program:
database
visited_state(integer, integer)
predicates
state(integer, integer)
clauses
state(2,0).
state(X,Y):- X<4,
not(visited_state(4,Y)),
assert(visited_state(X,Y)),
write("Fill the 4-Gallon Jug: (",X,",",Y,") - -->(", 4,",",Y,")\n"), state(4,Y).
state(X,Y):- Y<3,
not(visited_state(X,3)),
assert(visited_state(X,Y)),
write("Fill the 3-Gallon Jug: (", X,",",Y,") --> (", X,",",3,")\n"), state(X,3).
state(X,Y):- X>0,
not(visited_state(0,Y)),
assert(visited_state(X,Y)),
write("Empty the 4-Gallon jug on ground: (", X,",",Y,") --> (", 0,",",Y,")\n"), state(0,Y).
not(visited_state(X,0)),
assert(visited_state(X,0)),
state(X,Y):- Y> 0,
write("Empty the 3-Gallon jug on ground: (", X,",",Y,") --> (", X,",",0,")\n"), state(X,0).
state(X,Y):- X + Y >= 4,
Y > 0,
NEW_YY - (4 - X),
not(visited_state(4,NEW_Y)),

assert(visited_state(X,Y)),
write("Pour water from 3-Gallon jug to 4-gallon until it is full: (", X,",",Y,") --> (",
4,",",NEW_Y,")\n"),
state(4,NEW_Y).
state(X,Y):- X + Y >=3,
X > 0,
NEW X-X-(3 - Y), not(visited_state(X,3)), assert(visited_state(X,Y)),
write("Pour water from 4-Gallon jug to 3-gallon until it is full: (", X,",",Y,") --> (", NEW
X,",",3,")\n"),
state(NEW_X,3).
state(X,Y):- X + Y <=4,
Y > 0,
NEW X=X+Y,
not(visited_state(NEW_X,0)),
assert(visited_state(X,Y)),
write("Pour all the water from 3-Gallon jug to 4-gallon: (", X,",",Y,") --> (",
NEW_X,",",0,")\n"),
state(NEW_X,0).
state(X,Y):- X+Y<=3, X > 0,
NEW Y=X+Y,
not(visited_state(0,NEW_Y)),
assert(visited_state(X,Y)),
write("Pour all the water from 4-Gallon jug to 3-gallon: (", X,",",Y,") --> (",
0,",",NEW_Y,")\n"),
state(0,NEW_Y).
state(0,2):- not(visited_state(2,0)),
assert(visited_state(0,2)),
write("Pour 2 gallons from 3-Gallon jug to 4-gallon: (", 0,",",2,") --> (", 2,",",0,")\n"),
state(2,0).
state(2,Y):- not(visited_state(0,Y)),
assert(visited_state(2,Y)),
write("Empty 2 gallons from 4-Gallon jug on the ground: (", 2,",",Y,") --> (",
0,",",Y,")\n"),
goal
state(0,Y).
makewindow(1,2,3,"4-3 Water Jug Problem",0,0,25,80),
state(0,0).

OUTPUT
Fill the 4-Gallon Jug: (0,0)(4,0)
Fill the 3-Gallon Jug: (4,0) (4,3)
Empty the 4-Gallon Jug on Ground: (4,3)(0,3)
Pour all the water from 3-Gallon jug to 4-Gallon: (0,3)(4,2)
Empty the 4-Gallon jug on ground: (4,2) (0,2)
Pour all the water from 3-Gallon jug to 4-Gallon: (0,2)(2,0)
EXPERIMENT: 8
WRITE A PROGRAM IN FOR EXPERT SYSTEM BY USING
FORWARD CHAINING AND ALSO WRITE PROBLEMS OF AI
DOMAIN AND AI TECHNIQUES

AIM
Write a program for expert system by using forward chaining and also write
problems of AI domain and AI techniques.

Artificial Intelligence And Expert System


 Al is a study of how to make computers do things at which, at the moment People are
better
 To Attempt any problem that is complex enough for the computer, we require to learn
new methods to solve problems then to use conventional methods.
 AI and ES teaches us the same

Problems of AI Domain
1. Mundane Tasks
2. Formal Tasks
3. Expert Tasks

Mundane Tasks
- Perception
-Vision
- Speech
Natural Language
-Understanding
- Generation
- Translation
- Commonsense reasoning
- Robot Control

Formal Tasks
Games
-Chess, Backgammon, Checkers, Go
Mathematics
- Geometry, Logic, Integral Calculus, Proving properties of programs

Expert Tasks
Engineering
Design, Fault Finding, Manufacturing Planning
Scientific Analysis
Medical Diagnosis
Financial Analysis

The Underlying Assumption

 The Physical Symbol System Hypothesis


 Symbols as part of expressions
 System containing symbol structures
 Expressions producing other expressions
 A physical symbol system produces, through time, an evolving collection of SS
 PSS has necessary and sufficient means for general intelligent action
 Only empirical way to prove (or Disprove!)
Using Computer For It
 Lady Lovelace and 'Using computers for other things then number crunching'
 Computers to test the PSS hypothesis
 Sophistication in programming to solve more complex problems
 Sub-symbolic systems like visual perception provide evidences in favor
 Psychologists to test the theory of intelligence and building programs that behave live
Humans

The AI Technique
Intelligence requires knowledge
 Voluminous
 Hard to characterize accurately
 Constantly changing
 To be organized in a way to be used
AI Methods should exploit knowledge
 Generalization
 Input comes as 'human understandable form'
 Modifiable with meta-knowledge
 Usable even when incomplete or not totally accurate
Medical diagnosis
Platform: Windows 7/ SWI- prolog
Program:
domains
disease, indication,name = symbol

predicates
hypothesis(name,disease)
symptom(name,indication)
clauses
symptom(amit,fever).
symptom(amit,rash).
symptom (amit,headache).
symptom(amit,runn_nose).

symptom (kaushal,chills).
symptom(kaushal,fever).
symptom(kaushal,hedache).

symptom(dipen,runny_nose).
symptom(dipen,rash).
symptom(dipen,flu).

hypothesis(Patient,measels):-
symptom(Patient, fever),
symptom(Patient,cough),
symptom(Patient,conjunctivitis),
symptom(Patient,rash).

hypothesis(Patient,german_measles) :-
symptom(Patient,fever),
symptom(Patient, headache),
symptom(Patient,runny_nose),
symptom(Patient,rash).

hypothesis (Patient,flu) :-
symptom (Patient,fever),
symptom(Patient,headache),
symptom (Patient,body_ache),
symptom(Patient,chills).

hypothesis(Patient,common_cold) :-
symptom(Patient,headache),
symptom(Patient,sneezing),
symptom(Patient,sore_throat),
symptom(Patient,chills),
symptom(Patient,runny_nose).

hypothesis(Patient,mumps) :-
symptom(Patient,fever),
symptom(Patent, swollen_glands).

Hypothesis(patient,chicken_pox):-
Symptom(patient,fever),
Symptom(patient,rash),
Symptom(patient,body_ache),
Symptom(patient,chills),
EXPERIMENT: 9
WRITE A PROGRAM TO SOLVE 8-PUZZLE PROBLEM

AIM
Write a program to solve 8-Puzzle problem.

The title of this section refers to a familiar and popular sliding tile puzzle that has been
around for at least forty years. The most frequent older versions of this puzzle have numbers
or letters an the sliding tiles, and the player is supposed to slide tiles into new positions in
order to realign a scrambled puzzle back into a goal alignment. For illustration, we use the 3
x 3 8-tile version, which is depicted here in goal configuration
7 2 3
4 6 5
1 8

To represent these puzzle "states" we will use a Prolog term representation employing '/' as a
separator. The positions of the tiles are listed (separated by '/') from top to bottom, and from
left to right. Use "O" to represent the empty tile (space). For example, the goal is
goal(1/2/3/8/0/4/7/6/5).
Production Rules :-
n_function(Puzz,H) p_fcn (Puzz,P), s_fcn(Puzz,S), H is P + 3*S.

The 'move' productions are defined as follows.


move(P,C,left) left(P,C). move(P,C,up)
up(P,C). move(P,C,right) right(P,C).
move(P,C,down) down(P,C).
p_fcn(A/B/C/D/E/F/G/H/I, P)
g(G,Pg), h(H,Ph), i(l,Pi),
a(A, Pa), b(B,Pb), c(C,Pc), d(D,Pd), e(E,Pe), f(F,Pf),
P is Pa+Pb+Pc+Pd+Pe+Pf+Pg+Ph+Pg+Pi.
s_fcn(A/B/C/D/E/F/G/H/I, S) 1 s_aux(A,B,S1), s_aux(B,C,S2),
s_aux(C,F,S3), s_aux (F,I,S4),
s_aux(0,0) cut s_aux(X,Y,O)
Y is X+1, !. s_aux(8,1,0):-
s_aux(I,H,S5), s_aux(H,G,S6), s_aux(G,D,S7), s_aux(D,A,S8), s_aux(E,S9),
S is S1+S2+S3+S4+S5+S6+S7+S8+S9.
!.

The heuristic function we use here is a combination of two other estimators: p_fcn, the
Manhattan distance function, and s_fcn, the sequence function, all as explained in Nilsson
(1980), which estimates how badly out-of-sequence the tiles are (around the outside).
h_function(Puzz,H):- p_fcn (Puzz,P),
H is P + 3*S.
s_fcn(Puzz,S),
The 'move' predicate is defined as follows. move(P,C,left)-left(P,C). move(P,C,up) :-
up(P,C). move(P,C,right) :- right(P,C). move(P,C,down) :- down(P,C). Here is the code for p
and s. %%% Manhattan distance p_fcn(A/B/C/D/E/F/G/H/I, P) :- a(A,Pa), b(B,Pb), c(C,Pc),
d(D,Pd), e(E,Pe), f(F,Pf),
g(G,Pg), h(H,Ph), i(l,Pi),
P is Pa+Pb+Pc+Pd+Pe+Pf+Pg+Ph+Pg+Pi.
a(0,0). a(1,0). a(2,1). a(3,2). a(4,3). a(5,4). a(6,3). a(7,2). a(8,1). b(0,0). b(1,0). b(2,0). b(3,1).
b(4,2). b(5,3). b(6,2). b(7,3). b(8,2). c(0,0). c(1,2). c(2,1). c(3,0). c(4,1). c(5,2). c(6,3). c(7,4).
c(8,3). d(0,0). d(1,1). d(2,2). d(3,3). d(4,2). d(5,3). d(6,2). d(7,2). d(8,0). e(0,0). e(1,2). e(2,1).
e(3,2). e(4,1). e(5,2). e(6,1). e(7,2). e(8,1). f(0,0). f(1,3). f(2,2). f(3,1). f(4,0). f(5,1). f(6,2).
f(7,3). f(8,2). g(0,0). g(1,2). g(2,3). g(3,4). g(4,3). g(5,2). g(6,2). g(7,0). g(8,1). h(0,0). h(1,3).
h(2,3). h(3,3). h(4,2). h(5,1). h(6,0). h(7,1). h(8,2). (0,0). (1,4). i(2,3). i(3,2). i(4,1). i(5,0).
i(6,1). i(7,2). i(8,3).
%%% the out-of-cycle function s_fcn (A/B/C/D/E/F/G/H/I, S) :-
s_aux(A,B,S1), s_aux(B,C,S2), s_aux(C,F,S3),
s_aux(F,I,S4), s_aux(I,H,S5), s_aux(H,G,S6),
s_aux(G,D,S7), s_aux(D,A,S8), s_aux(E,S9),
S is S1+S2+S3+S4+S5+S6+S7+S8+S9.
s_aux(0,0):- !. s_aux(_,1).
s_aux(X,Y,O) :- Y is X+1, !.
s_aux(8,1,0):- !. s_aux(__2).
The Prolog program from the previous section and the program outlined in this section can be
used as an 8-puzzle solver. ?- solve(0/8/1/2/4/3/7/6/5, S).
7 2 3
A 4 6 5
1 8 0

step 1 7 2 3 7 2 3
B 4 6 0 C 4 6 5
1 8 5 1 0 8

step 2 7 2 3 7 2 0 7 2 3
D 4 6 5 E 4 6 3 F 4 0 6
1 8 0 1 8 5 1 8 5

step 3 7 2 3 7 0 2
G 4 6 0 H 4 6 3
1 8 5 1 8 5

Solution:
left(A/O/C/D/E/F/H/I/J, O/A/C/D/E/F/H/I/J).
left(A/B/C/D/O/F/H/I/J, A/B/C/O/D/F/H/I/J).
left( A/B/C/D/E/F/H/O/J, A/B/C/D/E/F/O/H/J).
left(A/B/O/D/E/F/H/I/J, A/O/B/D/E/F/H/I/J).
left( A/B/C/D/E/O/H/1/J, A/B/C/D/O/E/H/I/J).
left( A/B/C/D/E/F/H/I/O, A/B/C/D/E/F/H/0/1).
up(A/B/C/O/E/F/H/I/J, O/B/C/A/E/F/H/I/J).
up(A/B/C/D/O/F/H/I/J, A/O/C/D/B/F/H/I/J).
up( A/B/C/D/E/O/H/I/J, A/B/O/D/E/C/H/I/J).
up(A/B/C/D/E/F/O/1/J, A/B/C/O/E/F/D/I/J).
up( A/B/C/D/E/F/H/O/J, A/B/C/D/O/F/H/E/J).
up( A/B/C/D/E/F/H/I/O, A/B/C/D/E/O/H/I/F).
right(A/O/C/D/E/F/H/I/J, A/C/O/D/E/F/H/I/J).
right(A/B/C/D/O/F/H/I/J, A/B/C/D/F/O/H/I/J).
right(A/B/C/D/E/F/H/O/J, A/B/C/D/E/F/H/J/O).
right(O/B/C/D/E/F/H/I/J, B/O/C/D/E/F/H/I/J).
right(A/B/C/O/E/F/H/I/J, A/B/C/E/O/F/H/I/J).
right(A/B/C/D/E/F/0/1/J, A/B/C/D/E/F/1/0/J).
down(A/B/C/O/E/F/H/I/J, A/B/C/H/E/F/O/I/J).
down(A/B/C/D/O/F/H/I/J, A/B/C/D/I/F/H/O/J).
down(A/B/C/D/E/O/H/I/J, A/B/C/D/E/J/H/I/O).
down(U/B/C/D/E/F/H/I/J, D/B/C/O/E/F/H/I/J).
down(A/O/C/D/E/F/H/I/J, A/E/C/D/O/F/H/I/J).
down( A/B/O/D/E/F/H/I/J, A/B/F/D/E/O/H/I/J).
EXPERIMENT: 10
WRITE A PROGRAM TO SOLVE MONKEY BANANA PROBLEM

AIM
Write a program to solve monkey banana problem
Platform: Window 7/ SWI-prolog
Program:
push(P1, P2).
walk(P1,P2).
grasp.
climb.
state(MH,MV,BP,HB).
move(State),Move,State2).
move( State(P, onfloor, P,H),
climb,
state(P, onbox, P, H)).
move(State(P1,onfloor, P1,H),
push(P1,P2),
state(P2,onfloor,P2,H)).
move(state(P1,onfloor,B,H),
walk(P1,P2),
state(P2,onfloor,B,H)).
move(State(middle,onbox,middle,hasnot), /*before move*/
grasp,
state(middle,onbox,middle,has)).
canget(state(_,_,__,has)).
canget(State):-
move(Statel,Move,State2),
canget(State2).
/* get it now*/
Result:
?-canget(atdoor, at floor,window,hasnot).
No solution.
IT Final Year Student List

ROLL NO. NAME OF STUDENTS


2000680130001 ABHINAV TYAGI
2000680130002 AKANSHA YADAV
2000680130003 ANKUR SAXENA
2000680130004 ARIF
2000680130005 AYUSH KUMAR
2000680130006 HARSH KUMAR
2000680130007 HARSH PATHAK
2000680130008 HARSH SHARMA
2000680130009 HARSH SOAM
2000680130010 HARSH VARDHAN DIXIT
2000680130011 HIMANSHI ARORA
2000680130012 KANISHK CHAUDHARY
2000680130013 KAUSHIK PRATIK
2000680130014 LAKHAN BHARDWAJ
2000680130015 LALIT CHAUHAN
2000680130016 MADHUR KUMAR JHA
2000680130017 MANAN MANGLIK
2000680130020 MUDIT GOEL
2000680130021 NEHA TALIYAN
2000680130022 NIKHIL CHAUDHARY
2000680130023 PRADEEP KUSHWAHA
2000680130024 PRADYUMNA CHAUHAN
2000680130025 PRAFUL JAIN
2000680130026 PRINCE BRAR
2000680130027 PRIYANKA TYAGI
2000680130028 PURVI RASTOGI
2000680130029 RAHUL PANDEY
2000680130030 RAKSHIT RANA
2000680130031 RITIK KUSHWAHA
2000680130032 SANYAM SHARMA
2000680130033 SHASHWAT SHARMA
2000680130034 SHIVA SINGH
2000680130035 SHIVAM
2000680130036 SHIVAM PUNDIR
2000680130037 SHIVAM SOAM
2000680130038 SHIVANSH RASTOGI
2000680130039 SHREYA CHAUDHARY
2000680130040 TUSHAR MAHESHWARI
2000680130041 UJJAWAL JAIN
2000680130042 VIJAY SAXENA
2000680130043 VISHAL DHAMA
2000680130044 VISHWAJEET REDHU

You might also like