Artificial Intelligence Visue: Solution
Artificial Intelligence Visue: Solution
Artificial Intelligence Visue: Solution
SOLUTION (1)
ARTIFICIAL INTELLIGENCE VISUE
Q.1 Explain the term AI and give three important techniques for AI.
Ans. Artificial Intelligence:
Artificial Intelligence is the study of how to make machine computers do things which t the moment
people do better. We can give the artificial intelligence technique as:
It is voluminous
It is hard to characterize accurately
It is constantly changing
It differs from data by being organized in a way that corresponds to the ways it will be used.
Organization of knowledge is situation dependent.
The three important AI Techniques:
Search: Provides a way of solving problems for which no more direct approach is available as well as a frame
work into which any direct techniques that are available can be embedded.
Use of knowledge: Provides a way of solving complex problems by exploiting the structures of the objects that
are involved.
Abstraction: Provides a way of separating important features and variations from unimportant ones that would
otherwise overwhelm any process.
SOLUTION (2)
ARTIFICIAL INTELLIGENCE VISUE
Artificial Intelligence: Artificial Intelligence is the study of how to make machine computers do things which t
the moment people do better. We can give the artificial intelligence technique as:
It is voluminous
It is hard to characterize accurately
It is constantly changing
It differs from data by being organized in a way that corresponds to the ways it will be used.
Organization of knowledge is situation dependent.
SOLUTION (3)
ARTIFICIAL INTELLIGENCE VISUE
4. Reply with the set of answers just collected.
SOLUTION (4)
ARTIFICIAL INTELLIGENCE VISUE
Computer vision: It is a simple task to attach a camera to a computer so that the computer can receive
visual images .it has proven to be a far more difficult task. However to interpret those images so that the
computers can understand exactly what it is seeing. People generally use vision as their primary means of
sensing their environmental .we generally see more than we hear, feel, and smell of taste. The goal of computer
vision research is to give computers this same facility for understanding their surroundings.
Robotics: A robot is an Electro mechanical device that can be programmed to perform manual tasks. The
robotic industries association formally defines a robot as ― a re programmable multi functional manipulator
designed to move material, parts, roots or specialized devices through variable programmed motions for the
performance of a variety of tasks‖. Not at all robotics is considered to be the part of AI .a robot that performs
only the actions it has been preprogrammed to perform is considered to be a ‗dumb‘ robot processing no more
intelligence. An intelligent robot includes some kind of sensory apparatus such as a camera that allows it to
respond to changes in its environment, rather than just to allow instructions ‗mindlessly‘.
Intelligent computer assisted instruction (ICAI): CAI has been in use for many years bringing the
power of the computer to bear on the educational process. Now AI methods are being applied to the
development of intelligent computer –assisted instruction in an attempt to create computerized ―tutors‖ that
shape their teaching techniques to fit the learning patterns o individual students.
Automatic programming: In simple terms programming is the process of telling the computer exactly
what you want it to do Developing a computer program frequently requires a great deal of time. A program
must be designed, written, tested, debugged and evaluated all as part of the program development process. The
goal of automatic programming is to create special programs that act as intelligent ―tool‖ to assist programmers
and expedite each phase of the programming process. The ultimate aim of automatic programming is computer
system that could develop programs by itself, in response to and in accordance with the specifications of a
program developer.
Planning and decision support: When you have a goal, either you rely on luck and providence to
achieve that goal or you design and implement a plan .the realization of a complex goal may require the
construction of a formal and detailed plan. Intelligent planning programs are designed to provide active
assistance in the planning process and are expected to be particularly helpful to managers with decision-making
responsibilities. From the perspective of goals AI can be viewed as part of engineering and part of science.
The engineering goal of AI is to solve real world problems using AI as an armamentarium of ideas about
presenting knowledge; using knowledge and assembling system explain various sorts of intelligence.
Applications of AI should be judged according to whether there is well-defined task, an implemented
program and a set of identifiable principles. AI can help us to solve difficult real world problems, creating new
opportunities in business, engineering and many other application areas.
Q.8 Explain: problem decomposability and can steps be ignore or undo with example.
Ans. Problem Characteristics: Heuristic search is a very general method applicable to a large class of
problems. In order to choose the most appropriate methods for a particular problem it is necessary to analyze the
problem along several key dimensions.
1. Is the problem decomposable?
2. Can solution steps be ignored or undone?
3. Is the problems universe predicate?
4. Is a good solution to the problem obvious without comparison to all other possible solutions? (Is a good
solution absolute or relative?)
5. Is the solution a state or a path?
6. What is the role of knowledge?
7. Does the task require interaction with a person?
SOLUTION (5)
ARTIFICIAL INTELLIGENCE VISUE
SOLUTION (6)
ARTIFICIAL INTELLIGENCE VISUE
Example2:
A Water Jug Problem: You are given two Jugs, a 4-gallon one and a 3-gallon one. Neither have any measuring
markers on it. There is a pump that can be used to fill the jugs with water. How can you get exactly 2 gallons of
water into the 4-gallon jug?
The state space for this problem can be described as the set of ordered pairs of integers (x, y) such that
x=0, 1, 2, 3, or 4 and y = 0, 1, 2, 0r 3; x represents the number of gallons of water in the 4-gallon jug, and y
represents the quality of water in the 3-gallon jug. The Start State is (0, 0). The goal state is (2, n) for any value
of n (since the problem does not specify how many gallons need to be in the 3-gallon jug).
SOLUTION (7)
ARTIFICIAL INTELLIGENCE VISUE
RULE DO Description
1. (X, Y) (4, Y) Fill the 4 – gallon jug.
If X<4
2. (X, Y) (X, 3) Fill the 3 – gallon jug.
If Y<3
3. (X, Y) (X-d, Y) Pour some water out of the 4 – gallon jug.
If X>0
4. (X, Y) (3, Y-d) Pour some water out of the 3 – gallon jug.
If Y>0
5. (X, Y) (0, Y) Empty the 4 gallon jug on the ground.
If X>0
6. (X, Y) (X, 0) Empty the 3 gallon jug on the ground.
If Y>0
7. (X, Y) (4, Y-(4-X)) Pour water from the 3 gallon jug in to 4 gallon jug until
If X+Y>=4 & Y>0 4 gallon jug is full.
8. (X, Y) (X-(3-Y), 3) Pour water from the 4 gallon jug in to 3 gallon jug until
If X+Y>=3 & X>0 3 gallon jug is full.
9. (X, Y) (X+Y, 0) Pour all water from 3 gallon jug to 4 gallon jug.
If X+Y<=4 & Y>0
10. (X, Y) (0, X+Y) Pour all water from 4 gallon jug to 3 gallon jug.
If X+Y<=3 & X>0
11. (0, 2) (2, 0) Pour the 2 gallon water from 3-gallon to 4 gallon jug.
12. (2, Y) (0, Y) Empty the 2 gallon water in the 4 gallon jug on the
ground.
SOLUTION (8)
ARTIFICIAL INTELLIGENCE VISUE
The problem reduction algorithm we just described is a simplification of an algorithm described in Martelli and
Montanari, Martelli and Montanari and Nilson. Nilsson calls it the AO* algorithm, the name we assume.
1. Place the start node s on open.
2. Using the search tree constructed thus far, compute the most promising solution tree T
3. Select a node n that is both on open and a part of T. Remove n from open and place it on closed.
4. If n is a terminal goal node, label n as solved. If the solution of n results in any of n‘s ancestors being
solved, label all the ancestors as solved. If the start node s is solved, exit with success where T is the solution
tree. Remove from open all nodes with a solved ancestor.
5. If n is not a solvable node (operators cannot be applied), label n as unsolvable. If the start node is labeled
as unsolvable, exit with failure. If any of n‘s ancestors become unsolvable because n is, label them unsolvable
as well. Remove from open all nodes with unsolvable ancestors.
6. Otherwise, expand node n generating all of its successors. For each such successor node that contains
more than one sub problem, generate their successors to give individual sub problems. Attach to each newly
generated node a back pointer to its predecessor. Compute the cost estimate h* for each newly generated node
and place all such nodes that do not yet have descendents on open. Next, recomputed the values of h* at n and
each ancestor of n.
7. Return to step 2.
8.
If can be shown that AO* will always find a minimum –cost solution tree if one exists, provided only that
h*(n) <_ h (n), and all are costs are positive. Like A*, the efficiency depends on how closely h* approximates h.
SOLUTION (9)
ARTIFICIAL INTELLIGENCE VISUE
Non-monotonic, partially commutative systems, on the other hand are useful for problems in which changes
occur but can be reversed and in which order of operations is not critical. Commutative production systems are
useful for many problems in which irreversible changes occur. These are likely to produce the same node many
times in the search process.
SOLUTION (10)
ARTIFICIAL INTELLIGENCE VISUE
SOLUTION (11)
ARTIFICIAL INTELLIGENCE VISUE
Q.14 Analyze the following problem with respect to all their characteristics and
also explain in which category they fall.
Ans. 8 Puzzle: The 8-puzzle, an instance of which is shown in Figure 3.4, consists of a 3x3 board with eight
numbered tiles and a blank space. A tile adjacent to the blank space can slide into the space. The object is to
reach the configuration shown on the right of the figure. One important trick is to notice that rather than use
operators such as "move the 3 tile into the blank space," it is more sensible to have operators such as "the blank
space changes places with the tile to its left." This is because there are fewer of the latter kind of operator. This
leads us to the following formulation:
States: a state description specifies the location of each of the eight tiles in one of the nine squares. For
efficiency, it is useful to include the location of the blank.
Operators: blank moves left, right, up, or down.
Goal test: state matches the goal configuration shown in Figure.
Path cost: each step costs 1, so the path cost is just the length of the path. The 8-puzzle belongs to the family of
sliding-block puzzles. This general class is known to be NP-complete, so one does not expect to find methods
SOLUTION (12)
ARTIFICIAL INTELLIGENCE VISUE
significantly better than the search algorithms described in this chapter and the next. The 8-puzzle and its larger
cousin, the 15-puzzle, are the standard test problems for new search algorithms in Al.
The Missionaries and the Cannibals: The missionaries and cannibals problem is usually stated as follows.
Three missionaries and three cannibals are on one side of a river, along with a boat that can hold one or two
people. Find a way to get everyone to the other side, without ever leaving a group of missionaries in one place
outnumbered by the cannibals in that place.
To formalize the problem, the first step is to forget about the rain, the crocodiles, and all the other details
that have no bearing in the solution. The next step is to decide what the right operator set is. We know that the
operators will involve taking one or two people across the river in the boat, but we have to decide if we need a
state to represent the time when they are in the boat, or just when they get to the other side. Because the boat
holds only two people, no "outnumbering" can occur in it; hence, only the endpoints of the crossing are
important. Next, we need to abstract over the individuals. Surely, each of the six is a unique human being, but
for the purposes of the solution, when it comes time for a cannibal to get into the boat, it does not matter if it is
Alice, Bob, or Charles. Any permutation of the three missionaries or the three cannibals leads to the same
outcome. These considerations lead to the following formal definition of the problem:
States: a state consists of an ordered sequence of three numbers representing the number of missionaries,
cannibals, and boats on the bank of the river from which they started. Thus, the start state is (3, 3, 1).
Operators: from each state the possible operators are to take one missionary, one cannibal, two
missionaries, two cannibals, or one of each across in the boat. Thus, there! Are at most five operators, although
most states have fewer because it is necessary to avoid j illegal states? Note that if we had chosen to distinguish
between individual people then j there would be 27 operators instead of just 5.
Goal test: reached state (0, 0, 0).
Path cost: number of crossings.
Robot navigation: Robot navigation is a generalization of the route-finding problem described earlier. Rather
than a discrete set of routes, a robot can move in a continuous space with (in principle) an infinite set of possible
actions and states. For a simple, circular robot moving on a flat surface, the space is essentially two-
dimensional. When the robot has arms and legs that must also be controlled, the search space becomes many-
dimensional. Advanced techniques are required just to make the search space finite. We examine some of these
methods in Chapter 25. In addition to the complexity of the problem, real robots must also deal with errors in
their sensor readings and motor controls.
The traveling salesperson problem (TSP) is a famous touring problem in which each city must be visited
exactly once. The aim is to find the shortest tour. The problem is NP-hard (Karp, 1972), but an enormous
amount of effort has been expended to improve the capabilities of TSP algorithms. In addition to planning trips
for traveling salespersons, these algorithms have been used for tasks such as planning movements of automatic
circuit board drills.
Here we will consider the monkey-and-bananas problem, in which there is a monkey in a room with some
bananas hanging out of reach from the ceiling, but a box is available that will enable the monkey to reach the
bananas if he climbs on it. Initially, the monkey is at A, the bananas at B, and the box at C. The monkey and box
have height Low, but if the monkey climbs onto the box he will have height High, the same as the bananas. The
actions available to the monkey include Go from one place to another, Push an object from one place to another,
Climb onto an object, and Grasp an object. Grasping results in holding the object if the monkey and object are
in the same place at the same height.
SOLUTION (13)
ARTIFICIAL INTELLIGENCE VISUE
Tower of Hanoi: Somewhere near Hanoi, there is a monastery whose monks devote, their lives to a very
important task. In their courtyard there are three tail posts. On these posts is a set of sixty-four disks, each with a
hole in a center and each of a different radius. When the monastery was established, all of the disks where on
one of the posts, each disk is resting on one that just larger than it.
The monk‘s task is to move all of the disks to one of the other posts only one disk may be moved
at a time and cut the other disk must be on one of the posts. In addition, at no time during the process may a disk
be placed on the top of smaller disk. The third post can of course be used as a temporary resting place for the
disks what is the quickest way for the monks to accomplish their mission?
Tic-Tac-Toe: The program of tic-tac-toe in this increase in:
. Their complexity
Their use of generalizations
The clarity of their knowledge
The extensibility of their approach.
Here the nine element vector representing the board. An element contains the value, if squirt is blank.
As discuss all other problem regarding to their categories they are given as 8 puzzle problem satisfy two
problem characteristics:
1) ―Can solution steps be ignored or undone?‖
2) ―Is the universe predictable?‖
Travelling salesman problem satisfy this characteristics:
1) ―Is a good solution absolute or relative?‖
As we discuss the problem towards the water jug problem which satisfies this characteristic:
1) ―Is a good solution absolute or relative?‖
Theorem proving problem: The problem of theorem proving satisfy the following characteristics:
1) ―Can solution steps be ignored or undone?‖
2) ―Does the task require interaction with person?‖
2 8 3 1 2 3
1 6 4 8 4
7 5 7 6 5
In first step we have a simple move 6 downwards. In second one there should be a step in which 8
moves downwards which are given as below:
SOLUTION (14)
ARTIFICIAL INTELLIGENCE VISUE
2 8 3 2 ↓ 3 → 2 3
1 ↓ 4 1 8 4 1 8 4
7 6 5 7 6 5 7 6 5
1 2 3 1 2 3
↑ 8 4 8 4
7 6 5 7 6 5
SOLUTION (15)
ARTIFICIAL INTELLIGENCE VISUE
section.)
Algorithm:
Create a variable called NODE-LIST and set it to the initial state.
Until a goal state s found or NODE is empty do:
o Remove the first element from NODE-LIST and call it E. If NODE-LIST was empty quit.
o For each way that each rule can match the state described in E do:
Apply the rule to generate a new state
If the new state is goal state, quit and return this state.
Otherwise, add the new state to the end of the NODE-LIST.
OR (Second) Algorithm:
Step 1. Put the initial node on a list ―START‖
Step 2. If START is empty or goal terminate the search.
Step 3. Remove the first node from the Start and call this node ―a‖
Step 4. If a =‖GOAL‖ terminate search with success.
Step 5. Else if node ―a‖ has successors generate all of them and add them at the tail of ―START‖
Step 6. Go to step 2.
Advantages:
SOLUTION (16)
ARTIFICIAL INTELLIGENCE VISUE
1. BFS will not get trapped exploring a blind alley.
2. If there is a solution then BFS is guaranteed to find it.
3. The amount of time needed to generate all the nodes is considerable because of the time complexity.
4. Memory constraint is also a major problem because of the space complexity.
5. The searching process remembers all unwanted nodes, which are not practical use for the search process.
Q.21 Explain the DFS technique with its advantages.
Ans. Depth-first search always expands one of the nodes at the deepest level of the tree. Only when
the search hits a dead end (a nongoal node with no expansion) does the search go back and expand nodes at
shallower levels. This strategy can be implemented by GENERAL-SEARCH with a queuing function that
always puts the newly generated states at the front of the queue. Because the expanded node was the deepest, its
successors will be even deeper and are therefore now the deepest. The progress of the search is illustrated in the
given figure that will show this as it is given below.
Depth-first search has very modest memory requirements. As the figure shows, it needs to store only a single
path from the root to a leaf node, along with the remaining unexpanded sibling nodes for each node on the path.
This is a very simple type of brute force searching techniques. The search begins by expanding the initial node
i.e. by using an operator generate all successors of the initial node and test them. This procedure finds whether
the goal can be reached or not but the path it has to follow has not been mentioned. Diving downward into a tree
as quickly as possible performs DFS searches.
Algorithm:
If the initial state is a goal state, quit and return success.
Otherwise, do the following until success or failure is signaled:
o Generate a successor, E, of the initial state. If there are no more successors, signal failure.
o Call Depth-First-Search with E as the initial state.
o If success is returned, signal success otherwise continue in this loop.
Or (Second) Algorithm:
SOLUTION (17)
ARTIFICIAL INTELLIGENCE VISUE
Step1: Put the initial node on a list START.
Step2: If START is empty or START = GOAL terminates search.
Step3: Remove the first node from START. Call this node a.
Step4: If (a= GOAL) terminates search with success.
Step5: Else if node a has successors, generate all of them and add them at the beginning Of START.
Step6: Go to Step 2.
The major draw back of the DFS is the determination of the depth citric with the search has to proceed
this depth is called cut of depth. The value of cutoff depth is essential because the search will go on and on. If
the cutoff depth is smaller solution may not be found. And if cutoff depth is large time complexity will be more.
Advantages:
DFS requires less memory since only the nodes on the current path are stored.
By chance DFS may find a solution with out examining much of the search space at all.
Algorithm:
Compare CURRENT to GOAL. If there are no differences between them then return.
Otherwise, select the most important difference and reduce it by doing the following until success or
failure is signaled.
o Select an as yet untried operator 0 that is applicable to the current difference. If there are no such
operators, they signal failure.
o Attempt to apply 0 to CURRENT. Generate descriptions of two states: 0-START, a state in
which 0‘s preconditions are satisfied and 0-RESULT, the state that would result if 0 was applied in 0-START.
o If (FIRST-PART MEW (CURRENT, 0-START)) and
(LAST-PART MEA (0-RESULT, GOAL)) are success and return the result of concatenating
FIRST PART, 0, and LAST-PART.
SOLUTION (18)
ARTIFICIAL INTELLIGENCE VISUE
Ex: Initial state: ((R & (~P Q) &S)) Goal State: (((Q V P) & R) & ~ S)
SOLUTION (19)
ARTIFICIAL INTELLIGENCE VISUE
There is another representation of this algorithm which is given in the following points:
Evaluate the initial state. If it is also a goal state, then return it and quit. Otherwise continue with the
initial state as the current state.
Initialize BEST-SO-FAR to the current state.
Initialize T according to the annealing schedule.
Loop until a solution is found or until there are no new operators left to be applied to the current state.
o Select an operator that has not yet been applied to the current state and apply it to procedure new
state.
o Evaluate the new state. Compute
∆ E = (Value of current) – (Value of new state)
If the new state is a goal state, then return it and quite.
If it is not a goal state but is better then the current state, then make it the current state
with probability p‘ as defined above. This step is usually implemented by invoking a random number generator
to produce a numbers in the range [0, 1]. If that number is less than p‘, then the move is accepted otherwise do
nothing.
o Revise T as necessary according to the annealing schedule.
Return BEST-SO-FAR as the answer.
The algorithm for the simulated annealing is only slightly different from the simple hill climbing
procedure. The three differences are given below:
The annealing schedule must be maintained.
Moves to worse states may be accepted.
It is a good idea to maintain, in addition to the current state, the best state found so far. Then, if the final
state is worse than that earlier state, the earlier state is still available.
Q.25 Discuss best path and any path problem.
Ans. Best path problems are harder than any path problem. Any path problems can often be solved in
a reasonable amount of time by using heuristics that suggest good paths to explore. If the heuristic are not
perfect, the search for a solution may not be as direct as possible. But that does not matter. For true best path
problems however no heuristic that could possibly miss the best solution can be used.
1. Generate and test: The Generate & test strategy is the simplest of all the approaches. The generate & test
algorithm is a depth first search procedure – since complete solutions must be generated before they can be
tested. In its most systematic form, it is simply an exhaustive search of the problem space, It is also known as
the British museum algorithm. A reference to a method for finding an object in British museums by wandering
randomly.
Algorithm
Step 1: Generate possible solutions. For some problems this means generating a particular point in the problem
space. For others it means generating a path from a start state.
Step 2: Test to see if these actually a solution by comparing the chosen point or the end point of the chosen path
of the set of acceptable good states.
Step 3: If a solution has been found, quit, otherwise, return to step 1.
2. Hill Climbing: It is a variant of generate a test in which feed back from the test in which feed back from the
test procedure is used to help the generator decide which direction to move in the search space. In a pure
generate & test procedure the test function response with only a yes or no. But if the tests function is augmented
with a heuristic function. That provides a estimate of how close given state is to a goal state. Hill climbing is
often used when a good heuristic function is available for evaluating states. But when no other useful
knowledge is available. This algorithm is also discrete optimization algorithm uses a simple heuristic function.
The amount of distance the node is from the goal node in fact there is a practically no difference between
hill climbing & DFS except that the children of the node that has been expanded are shorted by the remaining
distance nodes.
SOLUTION (20)
ARTIFICIAL INTELLIGENCE VISUE
Algorithm:
Step1: Put the initial node on a list START.
Step2: If (START is empty) or (START = GOAL) then terminate the search.
Step3: Remove the first node form the start; call this node ‗a‖.
Step4: If (a = GOAL) terminate search with success.
Step5: ELSE if n ode ―a‖ has successors generate all of them. Find out how form they are from the goal node.
Sort them by the remaining distance from the goal and add them to beginning of the start.
Step6: Go to step 2.
2. It explore level by level 1 st level completes It explore by depth of node. It takes last level’s
all possibilities then go to next level. last node first and then search.
3. We can expand the chosen node by using 3. We can not fence each node in DFS, until
rules to generate successor. If one of them is depth is not complete and process quits at last
solution then quit process. when solution found at any depth.
4. In each node we can apply the heuristic 4. We can not apply heuristic function at each
function. node.
5. With this first search we get the solution 5. Solution is at largest level.
at shortest level.
6. Require more memory and search space 6. Require less memory and search space.
SOLUTION (21)
ARTIFICIAL INTELLIGENCE VISUE
The representation scheme should have a set of well-defined syntax and semantics. This help in
representing various kinds of knowledge.
The knowledge representation scheme should have a good expression capacity. A good expressive
capability will catalyze the inference mechanism in its reasoning process.
From the computer system point of view, the representation must be efficient. By this we mean that it
should use only limited resources with out compromising on the expressive power.
The resolution procedure is a simple iterative process. At each step two clauses, called the parent clause
are compared (resolved) yielding a new clause that has been inferred from them. The new clause represents
ways that the 2 parent‘s clauses interact with each other.
Resolution work on the principle of identity complementary literals in 2 clauses and deleting them there
by forming a new literal. The process is simple and straight forward when one has identical literals . In other
words for clauses containing no variables resolution is easy. When there are variables the problem becomes
complicated and the necessities one to make proper substitutions.
There are 3 major types of substitutions
Substitution of a variable by a constant.
Substitution of a variable by another variable.
Substitution of a variable by a function that does not contain the same variable.
Algorithm:
Convert all the statements of F to clause form.
Negate P and convert the result to clause form. Add it to the set of clauses obtained in 1.
Repeat until a contradiction is found, no progress can be made, or a predetermined amount of effort has
been expended.
o Select 2 clauses. Call these the parent clauses.
o Resolve them together. The resolving will be the disjunction of all the literals of both parent
clauses with appropriate substitution performed & with the following exception. If there is 1 pair of literals T1,
T2 such that one of the parent clause contains T1 and the other contains T2 and if T1,T2 are unifiable then
neither T1,T2 should appear in the resolving. We call T1, T2 complementary literals. use the substitution
produced by the unification top create the resolving if there is more than 1 pair of complementary literals, only
pair should be omitted from the resolvent.
o If the resolvent is the empty clause, then a contradiction has been found. If it is not, then add it to
the set of clauses available to the procedure.
SOLUTION (22)
ARTIFICIAL INTELLIGENCE VISUE
Example in Predicate logic: Suppose we know that ―all Romans who know marcus either hate Caesar or think
that any one who hates any one is crazy‖.
SOLUTION (23)
ARTIFICIAL INTELLIGENCE VISUE
Any substitution that makes 2 or more expressions equal is called a unifier for the expressions. Applying a
substitution to an expression E produces an instance E' of E where E'=E. given 2 expressions are unifiable, such
as expressions c1, c2 with a unifier B with C1B=C2, we say that B is most general unifier (mgu) if any other
unifier & is an existence of B. for ex: 2 unifiers for the literals p(u, b, v) and p(a, x y) are & ={a/u, b/x, c/y} and
B={a/u, b/x, c/v, c/y}.
Unification can sometimes be applied to literals with in the same single clause. When an mgu exists such that 2
or more literals with in a clause are unified, the clause remaining after deletion of all but one of the unified
literals is called a factor of the original clause. The basic idea of unification is very simple. to attempt to unify 2
literals, we first check if their initial predicate symbols are the same, if so we can proceed otherwise there is no
way they can be unified, regardless of their arguments.
Unification has deep mathematical roots and is a useful in many AI programs. for ex: theorem proving and
natural language parser.
Algorithm:
If l1, l2 are both variables or constants then
1. If l1, l2 are identical then return NIL.
2. Else if l1 is a variable the if l1 occurs in l2 then return {fail} , else return (l2/l1}
3. Else if l2 is a variable then if l2 occurs in l1 then return {fail} ,else return (l1/l2}.
4. Else return {fail}.
If the initial predicate symbols in l1, l2 are not identical then return {fail}.
If l1 , l2 have a different no. of arguments then return {fail}
Set subset to Nil (At the end of this procedure, subset will contain all the substitutions use to unify l1 , l2.
For i<-1 to no. of arguments in l1.
a) Call unify with the I th argument of l1 and the I th argument of l2 putting result in s.
b) If s contains fail then return {fail}.
c) If s is not equal to nil then
Apply s to the remainder of both l1, l2
Subset = append (s, subset).
Return subset.
SOLUTION (24)
ARTIFICIAL INTELLIGENCE VISUE
The renaming is valid because Vx Knows(x, Elizabeth) and Vx2 Knows(x2, Elizabeth) have the same
meaning.
There is one more complication: we said that UNIFY should return a substitution that makes the two
arguments look the same. But if there is one such substitution, then there are an infinite number:
UNlFY(Knows(John,x), Knows(y, z)) = {y/John,x/z}
or {ylJohn,xlz,wlFreda}
or {y/John,xlJohn, zlJohn]
or • • •
Thus, we insist that UNIFY returns the most general unifier (or MGU), which is the substitution that makes the
least commitment about the bindings of the variables. In this case it is {y/john, x/z}.
SOLUTION (25)
ARTIFICIAL INTELLIGENCE VISUE
Forward reasoning from initial states:
1. Root: A tree of move sequences, that might be solutions, is built by starting with the initial configuration at
the root of the tree.
2. Generate of the next level: The next level of the tree is generated by building a tree by finding all the rules
whose left sides are matched against the current state (root node) and the right sides are to generate new nodes
by creating new configuration.
Generate next level by taking each node generated at the previous level and continue the above reasoning
forward till a configuration matches the goal state.
Back ward reasoning from the goal states:
1. Root: A tree of move sequences, that might be solutions, is built by starting with the goal configuration at the
root of the tree.
2. Generate the next level: The next level of the tree is generated by finding all the rules whose right sides match
the root node. The left sides are used to use to generate the new nodes, representing new goal states to achieve.
Generate the next level of the tree by taking each node at the previous level and continuing the above reasoning
until a node that matches the initial state is generated. It is often called goal-directed reasoning.
It does not make much difference whether we reason forward or backward, about the same number of
paths will be explored in either case. But this is not always true. Depending on the topology of the problem
space, if may be significantly more efficient to search in one direction rather than the other. Four factors
influence the question of whether it is better to reason forward or backward.
(1) Are there more possible start states or goal states?
Count the number of start states of goal states. Move from the smaller set of states to larger set of states.
(2) In which direction is the branching factor greater?
Find the direction in which the branching facto is low and proceed in that direction.
(3) Will the program be asked to justify its reasoning process to a user?
If the program is asked to justify its reasoning process then proceed in the direction that corresponds more
closely with the way the user think.
(4) If it is the arrival of a new fact, forward reasoning makes sense. If it is a Query to which a response is
desired, backward reasoning is more natural.
Example:
1. To solve the problem of symbolic integration, it is better to reason forward.
2. For the problem of proving theorems, is would be much better to reason backward.
We can also search both forward from the start state and backward from the goal simultaneously until
two paths meet some where in between. This strategy is called bidirectional search. It seems appealing if the
number of nodes at each step grows exponentially with the number of steps that have been taken. In fact, many
successful AI applications have been written using a combination of forward and backward reasoning and most
AI programming environments provide explicit support for such hybride reasoning.
SOLUTION (26)
ARTIFICIAL INTELLIGENCE VISUE
A monotonic reasoning system cannot work effectively in real life environments because Information available
is always incomplete. As process goes by situation change and so are the solutions. Default assumptions are
made in order to reduce the search time and for quick arrival of solutions. Basic concepts of non-monotonic
reasoning systems:
AI systems provide solutions for those problems whose facts and rules of inference are explicitly stored in the
database and knowledge base. But as mentioned above the data and knowledge are incomplete in nature and
generally default assumptions are made. Non-monotonic reasoning systems are more complex then monotonic
reasoning systems. Monotonic reasoning systems generally do not provide facilities for altering facts, deleting
rules it will have an adverse effect on the reasoning process. One of major systems that has been implemented
using non-monotonic reasoning system with dependency. Directed back tracking is the Truth maintenance
system of Doyle. Dependency -directed back tracking helps to great deal in nom monotonic reasoning systems.
A monotonic system evades contradictions .a contradiction occurs when the system finds that the new state
discovered is inconsistent with the existing ones.
SOLUTION (27)
ARTIFICIAL INTELLIGENCE VISUE
natural language understanding, vision, learning, automated reasoning, planning, automatic programming and
expert system as well as many others.
Matching is just process of comparing two structures or patterns for equality. The match fails if the
patterns differ in any aspect.
Different types of matching are:
(1). Indexing
(2). Matching with variables.
(3). Complex and Approximate Matching
(4). Conflict resolution.
(a) Preference Based on Rules: Here we consider the rules in the order they are given or we give some priority
to special case rules. There are two ways in which a matcher will try to decide how one rule is more general
than the others. This allows us in decreasing the search size by more general rules. The two ways are:
1. If one rule contains all the preconditions that another rule has and some additional then Second rule is more
general they the first.
2. If one rule contains preconditions with variables and the other contains the same. A precondition with
constants then the first rule is more general.
(b) Preference based on Object: Here we use keywords to match into the rules consider the example of ELIZA.
It takes specific keywords form the user‘s response and tries to match the keywords with the given rules. Like
previously it uses the ―remember‖ keyword to match the L.H.S. rule.
(c) Preference Based on States: In this case we fire all the rules that are waiting they lead us to some states.
Using a heuristic function we can decide which state is the best.
SOLUTION (28)
ARTIFICIAL INTELLIGENCE VISUE
A turbo prolog program consists of 2 or more sections. The main body of the program, the clause section
contains the clause and consists of facts and rules. The relationships used in the clauses of the clause section are
defined in the predicate section. Each relation in each clause must have a corresponding predicate definition in
the predicates section predicate definition in the pre dicta section does not end with a period. The domains
section also is apart of most turbo prolog programs .If defines the type of each object. The domain section turbo
prolog controls the typing of object.
6 basic object types are available to the user.
Character.
Integer.
Real.
String.
Symbol
File.
Character – single character (enclosed between single quotation marks)
Integer - integer from -32768 to 32767
Real - floating point number (lE-307 to 1E-308)
String – character sequence (enclosed between double quotation marks)
Symbol- character sequences of letters numbers and under series with the first character a lower case letter
File - symbolic file name.
In a turbo prolog program the sections should always be in the following.
1. Domains. 2. Predicates 3. Clauses.
Q.41 Give Reasons: Prolog has been successful as an AI programming language.
Ans. Prolog has been successful as an AI programming language for the following reasons:
1. The syntax and semantics of prolog are very close to formal logic. By this time, it must be clear to you
that most AI program reason using logic.
2. Prolog language has in it a built in inference engine and automatic backtracking facility. This helps in
efficient implementation of various search strategies.
3. This language has high productivity and easy of program maintenance.
4. Prolog language is based on the universal formalism of Horn Clause.
5. Because of the inherent AND parallelism, prolog language can be implemented with ease on parallel
machines.
6. The clauses of prolog have a procedural and declarative meaning. Because of this understanding of the
language is easier.
7. In prolog, each clause can be executed separately as though it is a separate program. Hence modular
programming and testing is possible.
Horn clause consists of a set of statements joined by logical Ands
SOLUTION (29)
ARTIFICIAL INTELLIGENCE VISUE
SOLUTION (30)
ARTIFICIAL INTELLIGENCE VISUE
Cut Predicate: The cut is one of the most important and one of the most complex features of prolog. The
primary purpose of the cut is to prevent or block backtracking based on a specified condition. The cut predicate
is specified as an exclamation point. If has no argument the cut predicate succeeds and once it succeeds, it acts a
fence, effectively blocking any back tracking beyond the cut. If any premise beyond the cut fails, prolog cans
only back track as far as the cut to try another path.
The basic purpose of the cut is to eliminate certain search path is in the problem space, you can think of
the paths through the database as the limbs of a tree. If you get cut on one limb and discover failure, you
normally can move back towards the trunk, find another limb and start moving outward again the cut act like a
fence where it is placed in the program you cannot back beyond the cut.
The cut can be used for any or all of 3 purposes.
To terminate the search for any further solutions to a goal. Once a particular rule has been tested.
To terminate the search for any further solutions to a goal once a particular rule has been forced to fail
with the fail predicate.
To eliminate paths in the database to speed up execution .the cut is not always the best solution.
Types of cuts: there are 2 types of cuts in prolog namely.
Green cut & red cut: the green cut is used to force binding to be retained, once the right abuse is reached green
cuts are used to express determination.
The red type of cut is used to omit explicit conditions. Cuts improve the clarity and efficiency of most programs
of the 2 types of cut, the green cut is the more acceptable type. You can often use the not predicate instead of the
red cut.
EX: state (tamlnadu)
State (kerala)
State (A.P)
State (U.P)
State (karnataka)
State (M.P)
State (S);
Write (―does u belong to‖)
Write (S)
Write (―&‖)
Readln (Reply)
Reply =‖yes‖!
Write (―so u belong to ―)
Write (S)
Output: Does u belong to tamilnadu?
No
Does u belong to kerala?
No
Does u belong to A.P?
No
Does u belong to U.P?
Yes
So u belong to U.P
Quality operator: =
Comparison operator: <, >, =, <=, >=, -, =, <>
Arithmetic operator: +, -, *, %, mod, div, + (positive),-(negative)
Ex: If you specify the goal as count (1) you should see the following output -> 1 2 3 4 5 6 7 8 true
Contains a copy itself.
Count (~)
(Statements)
Count (NN)
SOLUTION (31)
ARTIFICIAL INTELLIGENCE VISUE
Program:
Predicates
Count (integer)
Clauses
Count (9).
Count (N): -
Write (― ―, N).
NN=N+1.
Count (NN).
Basic rules of recursion:
A program must include some method of terminating the recursion loop.
Variable binding in a rule of fact apply only to the current layer.
In most applications the recursive procedure should do its work on the way down.
Recursion is not always the best programming choice. Recursion complex and the flow of execution is
not always easy to follow.
SOLUTION (32)
ARTIFICIAL INTELLIGENCE VISUE
SOLUTION (33)
ARTIFICIAL INTELLIGENCE VISUE
SOLUTION (34)
ARTIFICIAL INTELLIGENCE VISUE
This axiom says that an object x has a color y in state 1. moving x from state 1 to state 2 will not change the
color of the object x. Once a change of state occurs how we undo the changes if we need to back track the two
ways that are provided are
Do not modify the initial state description. At each node, simply store an indication of the specific
change that should be made. In order to refer to the current state, we start from the initial state and look back all
the nodes on the path from start state to current state.
Make the changes to the initial state as they occur but every node where a change takes place, gives
what to do to undo the move or change if we need to back track.
SOLUTION (35)
ARTIFICIAL INTELLIGENCE VISUE
SOLUTION (36)
ARTIFICIAL INTELLIGENCE VISUE
Conceptual graphs offer the means to represent natural language statements accurately and to perform many
forms of inference found in common sense reasoning.
SOLUTION (37)
ARTIFICIAL INTELLIGENCE VISUE
Declarative and Procedural frames: A frame that merely contains description about objects is called a
declarative type/factual/situational frame.
A part from the declarative part in a frame, it is also possible to attach slots, which explain how to
perform things. In other words it is possible to have procedural knowledge represented in a frame. Such frames
which have procedural knowledge embedded in it are called action procedure frames. The action frame has the
following slots.
1. Actor slot: which holds information about who is performing the activity?
2. Object slot: this frame information about the item to be operated on.
3. Source slot: source slot holds information from where the action has to begin.
4. Destination slot: holds information about the place where action has to end.
5. Task slot: This generates the necessary sub-frames required to perform the operation.
SOLUTION (38)
ARTIFICIAL INTELLIGENCE VISUE
The generic frame merely describes that, the expert in order to clean the nozzle of the scooter has to merely
perform, the following operations:
Removing the carburetor from the scooter
Opening it up to expose all parts
Cleaning the nozzle
Refitting it in the scooter.
Here source and destination is scooter.
Reasoning using frames: The task of action frames is to provide facility for procedural attachment and help
transforming from initial to goal state. It also helps in breaking the entire problem in to sub-tasks, which can be
described as top-down methodology. It is possible for one to represent any tasks using these action frames.
Reasoning using frames is done by instantiation. Instantiation process begins when the given situation is batches
with frames that already exist. The reasoning process tries to match the frame with the situation and latter fills
up slots for which values must be assigned. The values assigned to the slot depict a particular situation and but
this reasoning process tries to move from one frame to another to match the current situation. This process
builds up a wide network of frames, there by facilitating one to build a knowledge base for representing
knowledge about common sense.
Frame-based representation language: Frame representations have become popular enough that special high
level frame-based representation languages have been developed. Most of languages use LISP as the host
language. They typically have functions to create access, modify updates and display frames.
Implementation of frame structures: One way to implement frames is with property lists. An atom is used as the
frame name and slots are given as properties. Facets and values with in slots become lists of lists for the slot
property. Another way to implement frames is with an association list (an-a-list), that is, a list of sub lists where
each sub list contains a key and one or more corresponding values. It is also possible to represent frame like
structures using Object oriented programming extensions to LISP languages such as Flavors.
SOLUTION (39)