Processing & Properties of Floor and Wall Tiles.pptx
Artificial Intelligence Lab File
1. INDEX
S. No. Program Page No. Signature Remarks
1.
Given the following information as a
database:
WAP in PROLOG for supports(book, cup)
1
2.
WAP to define the family member
relationship.
2
3. WAP for monkey banana problem. 4
4. WAP for Tower of Hanoi problem. 6
5.
WAP for Depth First Search using suitable
example.
7
6.
WAP for Breadth First Search using
suitable example.
8
7.
WAP for login so that user can attempt 3
times. After 3rd attempt program must
terminate with message “NOT
PERMITTED FOR LOGIN”.
9
8.
WAP to check whether graph is connected
or not. If connected then whether
unidirectional or bidirectional.
10
9.
WAP to see all elements are present in list
or not.
12
10.
Mini project on any expert system using
PROLOG.
13
2. 1
EXPERIMENT NO.: 01
AIM: Given following information as a database:
A1: If x is on top of y then y supports x.
A2: If x is above y then they touching each other than x is on top of y.
A3: A cup is above book.
A4: A cup is touching book
Write a program in PROLOG for supports(book, cup).
OBJECTIVE:To study basic of PROLOG commands.
LOGIC:
In domain side declare the variables say x and y of type string as mentioned in the
problem statement.
In predicate section define four statement A1 to A4 in form of predicates like:
support(string, string)
on_top(string, string)
above(string, string)
touch(string, string)
In clause section clauses defined are:
on_top(x, y): -
above(x, y)
touch(x, y)
supports(y, x): -
on_top(x, y)
above(cup, book)
Touch(cup, book)
CONCLUSION:Successfulcompletion of goal.
3. 2
EXPERIMENT NO.: 02
AIM: Write program to define family member relationship.
If x is father of y or x is mother of y, then x is parent of y.
If x is parent of z and z is parent of y, then x is grandparent of y.
Y is parent of x and x is male then x is sonof y.
Cousins.
Grandchild
Uncle
Brother and sister.
LOGIC:
In domain section declare variable say x, y, z, A, N of type string. Establish the
relationship as below:
1) parent(x, y): -
father(x, y).
parent (x, y): -
mother(x, y).
2) grandparent(x, y): -
parent(x, z).
parent(z, y).
3) son(x, y): -
male(x).
parent(y, x).
4) uncle (x, y): -
parent(z, y).
brother(x, y).
5) brother(x, y): -
male(X).
parent(z, x).
parent(z, y).
4. 3
6) cousins(x, y): -
uncle(z, y).
parent(z, x).
7) grandchild(x, y): -
son(x, z).
son(z, y).
8) sister(x, y): -
female(x).
parent(z, x).
parent(z, y).
Now create database in the form of the fact as below:
father(john, smith).
father(mohit, meera).
mother(sheela, suni1).
mother(reeta, meera).
male(john).
male(smith).
male(mohit).
male(suni1).
female(sheela).
female(meera).
female(reeta).
CONCLUSION:The goal is successfully-achieved for family relationship
5. 4
EXPERIMENT NO.: 03
AIM: Write a program for monkey banana problem.
OBJECTIVE:To study the monkey banana problem.
THEORY:
Monkey banana is the real life problem which can be solved with the AI concept.
In monkey banana problem it is stated that a room is containing a chair, a room,
and some banana that have been hung from a centre of ceiling, out of reach from
monkey. If a monkey clever enough the he can reach banana by placing the chair
directly below the banana and climbing on chair. The problem is to use FOPL
(First Order Predicate logic) to represent this monkey banana world and using
resolution, prove the monkey can reach the banana.
In creating the knowledge base, it is essential first to identify all relevant objects
which will play some role in anticipated inference. Irrelevant object should be
removed, E.g. In this problem, monkey, banana and chair are essential. Other
object such door, windows and wall of the room can be omitted.
Next step is to establish the important properties of the objects, relation between
objects, these include such as the chair is tall enough to raise the monkey within
reach of the banana and so on.
All the items needed for actual knowledge base are listed as axioms. These are
essential facts and rules. All variables are universally quantified.
RELEVENT FACTORS FOR THE PROBLEM
Constants
{floor, chair, banana, monkey}
Variables
{x, y, z}
Predicates
6. 5
{can_reach(x, y); x can reach y
dexterous(x); x is dexterous animal
close(x, y); x is close to y
get_on(x, y); x can get on y
under(x, y); x is under y
tall(x); x is tall
in_room(x); x is room
can_move(x, y, z); x can move y near z
can_climb(x, y); x can climb on y
Axioms
{in_room(bananas)
In_room(chair)
In_room(monkey)
dexterous(monkey)
tall(chair)
close(banana, floor)
can_move(monkey, chair, bananas)
can_climb(monkey, chair(dexterous(x)&
close(x, y)->can_reach(x, y((get_on(x, y)
&under(y, bananas)&tall(y)>close
(x, bananas)(in_room(x)
CONCLUSION:Monkey banana problem has been studied.
7. 6
EXPERIMENT NO.: 04
AIM: Write a program for Tower of Hanoi problem.
OBJECTIVE: To solve the Tower of Hanoi problem using the programming logic.
RULES:
1) Only one disc can move at a time.
2) Larger disc cannot be placed over smaller disc.
3) For n number of disc there is 2n-1 moves.
ALGORITHM:
1) N-Number of discs to be moved.
2) A, B, C are the pegs on which the discs are to be moved.
3) Hanoi(N, A, B, C, moves)
Hanoi is the allows to perform the sequence of moves for solving this problem.
The Tower of Hanoi is consisting of three rods and a number of disc of different
sizes slid onto any rod. The puzzle starts with the discs neatly stacked in ordered of
size on one rod, smaller at top and making the conical shape. The objective of the
puzzle is to move the entire disc to another rod obeying the following rule:
1) Only one disc can move at a time.
2) Each move consists of taking upper disc from a rod and moving it to another
rod, on top other disc that may already be present on the rod.
3) No larger disc is to be placed on the top of smaller disc.
CONCLUSION:The goal is successfully-achieved for Tower of Hanoi
8. 7
EXPERIMENT NO.: 05
AIM: Write a program for Depth First Search using the suitable example.
OBJECTIVE:To study depth first search using PROLOG.
DFS (Depth First Search) is an algorithm for traversing or searching a tree, tree
structure or graph.one starts at root (selecting any node at the root of the graph
case) and explore as far along each branch before backtracking. DFS is the
uniformed search that progress by expanding the first child node of search tree that
appears and thus going deeper and deeper until a goal node is found, or until it hit
the node which has no children. Then search backtracks, returning to the most
recent node it hadn't finished exploring. In a non-recursive implementation, all
freshly expanded nodes are added to LIFO stack for exploration. Space complexity
of DFS is much lower than BFS. Depth First Search are performed by dividing
downward into a tree as quickly as possible. It does not always generate a child
node from most recently expanded node and generates anther of its children this
process continues until goal is found.
ALGORITHM:
1) Place starting node in the queue.
2) If queue is empty, then failure and stop.
3) If first node in queue is goal node g, return success and stop.
Otherwise
1) Remove and expand the first element and place the children at front of the
queue.
2) Return to step 2.
CONCLUSION:Depth First Search has been achieved.
9. 8
EXPERIMENT NO.: 06
AIM: Write the program for Breadth First Search using the suitable example.
THEORY:
Breadth first searches are performed by exploring all the node at given depth
before processing to the next level. All immediate children of node at given depth
before any of the children's children are considered. It always finds the minimal
path solution when one exists. Algorithm uses a queue structure to hold all
generated but still unexplored nodes. The order in which node are placed in the
queue for removal and exploration determines the type of search.
ALGORITHM:
1) Place the starting node in the queue.
2) If queue is empty, then return failure and stop.
3) If first node on the queue is the goal node g, return success and stop.
4) Remove and expand the first element from the queue and place all the
children at end of queue in any order.
5) Return to step 2.
CONCLUSION:
Breadth First Search has been implemented successfully.
10. 9
EXPERIMENT NO.: 07
AIM: Write a program for login so that user can attempt 3 times. After 3rd attempt
program should with message-"NOT PERMITTED TO LOGIN".
LOGIC:
Domains
NAME, PASSWORD=symbol
Predicates
getentry(NAME, PASSWORD)
logon(integer)
user(NAME, PASSWORD)
go
Clauses
go: -
logon(3)
write("you are now logged on"0, nl.
logon(0): -
write("sorry you cannot logon"), nl, fail.
logon(-): -
getentry(NAME, PASSWORD)
user(NAME, PASSWORD)
logon(x): -
write("illegal entry"), nl
xx=x-1
logon(xx)
getentry(NAME, PASSWORD):-
write("please enter your name:"), nl.
readln(PASSWORD), nl
user(smith, abc)
11. 10
EXPERIMENT NO.: 08
Aim: Write a program to determine whether the graph is connected or not, if
connected then whether it unidirectional or bidirectional.
Objective: To study kinds of graphs using PROLOG.
Theory:
Graph G= (V, E) is a set of vertices and edges. A normal graph in which the edges
are undirected is said to be unidirectional. Otherwise if arrow may be placed on
one or both end point of the edge of a to indicate directedness. The graph is said to
be directed. A directed graph in which each edge is given a unique direction (i.e.
the edges may not be bidirectional and point on both directions at once) is called an
oriented graph. An undirected graph is said to be connected if for any pair of nodes
of graph, the two nodes reachable from each other. This definition cannot be
applied for directed graphs without some further modifications. Because in
directed graph if node u is reachable from another node v, the node v may not be
reachable from u hence we call digraph weakly connected. If for any pairs of the
node of the graph both the nodes are reachable from each other then it is called
strongly connected graph. If the direction of graph is omitted, then graph is
connected.
LOGIC:
Domains
x, y, z = symbol
Predicates
edge(string, string)
pathuni(string, string)
pathbi(string, string)
pathpresent(string, string)
Clauses
pathpresent(x, y): -
pathuni(x, y)
12. 11
pathbi(x, y)
pathuni(x, y): -
edge(x, y)ni
write("path is unidirectional"), n!
write("path is present from "x" "to" y),
edge(x, z)
edge(z, y), n!
write(path is present from "x" to "z" and from "z" to "y"),
x<>y
pathbi(x, y): -
edge (x, y),
edge(y, x), n!
write("path is bidirectional"), n!
write("path is present from "x" "to" y and vice versa),
x<>y
edge(a, b)
edge(a, c)
edge(b, a)
edge(a, b)
edge(c, a)
edge(d, b)
edge(b, c)
edge(d, a)
edge(d, e)
edge(d, f)
CONCLUSION:Graph has been studied and implemented.
13. 12
EXPERIMENT NO.:09
AIM: Write to see all element are present in the list or not.
OBJECTIVE:To study the conceptof list using PROLOG.
THEORY:
Link list is a sequence of the nodes. Each node has two part viz. node data and
pointer field. Pointer field points to the next node in the list. The last node's pointer
field contains NULL indicating that pointing to nothing. If first node pointer
consist field consist NULL it means that the link list consists of a single node.
LOGIC:
Domains
List=symbol*
Predicates
list(symbol, list)
Clauses
list(x, [H|-]): -
x=H
write("Element “, x," is present in the list"), nl
list(x, [-|T])
list(x, T),
list(x, T)
list(x, |]): write(x, "is not in the list"), fail.
CONCLUSION:Goal is successfulfor above mentioned aim.
14. 13
EXPERIMENT NO.:10
AIM: Mini project on expert system.
EXPERT SYSTEM:
Expert system is set of program which manipulates encoded knowledge to solve
the problems in a specialized domain that normally require human expertise. An
expert system's knowledge is obtained from expert sources and coded in a form
suitable for the system to use in its inference or reasoning process. Expert
knowledge require much training and experience in some specialized field such as
machine.
CHARACTERISTICS:
1) Expert system uses the knowledge rather than data to control solution of
process.
2) The knowledge is encoded and maintained as an entity separate from the
control program.
3) Expert systems are capable of explaining how a particular conclusion was
reached why requested information is need during consultation.
4) These are the symbolic representations for knowledge and perform their
inferences through symbolic computation.
5) These often reasons with meta knowledge. Meta knowledge is knowledge
about data.
APPLICATION:
1) Different type medical diagnosis.
2) Diagnosis of complex electronic and electromechanical systems.
3) Diagnosis of diesel electric locomotion systems.
4) Diagnosis of software development projects.
5) Forecasting the crop damage.
6) Identification of chemical compound structures.
7) Location of fault in the computer and communication systems.
8) Evaluation of loan application for lending institutions.
9) Assessment of geological structure from dip meter logs.
10) Estate planning for minimal tax.
11) Design of VLNI system.
12) Spaceplanning.