Artificial Intelligence AI Notes Chapter3
Artificial Intelligence AI Notes Chapter3
To solve the problem of playing a game, we require the rules of the game and targets for
winning as well as representing positions in the game. The opening position can be
defined as the initial state and a winning position as a goal state. Moves from initial state
to other states leading to the goal state follow legally. However, the rules are far too
abundant in most games— especially in chess, where they exceed the number of
particles in the universe. Thus, the rules cannot be supplied accurately and computer
programs cannot handle easily. The storage also presents another problem but searching
can be achieved by hashing.
The number of rules that are used must be minimized and the set can be created by
expressing each rule in a form as possible. The representation of games leads to a state
space representation and it is common for well-organized games with some structure.
This representation allows for the formal definition of a problem that needs the movement
from a set of initial positions to target positions. It means that the solution involves using
known techniques and a systematic search. This is quite a common method in Artificial
Intelligence.
• A representation of the states the system can be in. For example, in a board game, the
board represents the current state of the game.
• A set of operators that can change one state into another state. In a board game, the
operators are the legal moves from any given state. Often the operators are
represented as programs that change a state representation to represent the new
state.
• An initial state.
• This set is often represented implicitly by a program that detects terminal states.
In this problem, we use two jugs called four and three; four holds a maximum of four
gallons of water and three a maximum of three gallons of water. How can we get two
gallons of water in the four jug?
Ans- A=4L and B=3L Fill up B all the way up to its brim. Now we have 3L in B and no
water in A
The state space is a set of prearranged pairs giving the number of gallons of water in the
pair of jugs at any time, i.e., (four, three) where four = 0, 1, 2, 3 or 4 and three = 0, 1, 2 or
3.
The start state is (0, 0) and the goal state is (2, n) where n may be any but it is limited to
three holding from 0 to 3 gallons of water or empty. Three and four shows the name and
numerical number shows the amount of water in jugs for solving the water jug problem.
The major production rules for solving this problem are shown below:
Initial condition
1. (four, three) if four < 4
10. (2, 0)
11. (four, three) if four < 4 12. (three, four) if three < 3
Goal comment
(4, three) fill four from tap
(0, three) empty four into drain (four, 0) empty three into drain (four + three, 0) empty three
into four
(four-diff, 3) pour diff, 3-three, into three from four and a solution is given below four three
rule
The problem solved by using the production rules in combination with an appropriate
control strategy, moving through the problem space until a path from an initial state to a
goal state is found. In this problem solving process, search is the fundamental concept.
For simple problems, it is easier to achieve this goal by hand but there will be cases
where this is far too difficult.
So, State Space Searching solving a particular problem consist of following 4 steps:
1. Define a state space that contain all the possible states for solving a problem
2. Specify 1 more state (from which the problem solving process may start. They are
called initial states).
3. Specify one or more states that would be acceptable as solution to the problem and
called goal states.
4. Specify a set of rules that describes the actions available (production rules).
➡ CONTROL STRATEGIES
1. The first requirement is that it causes motion. In a game playing program the pieces
move on the board and in the water jug problem water is used to fill jugs.
2. The second requirement is that it is systematic, this is a clear requirement for it would
not be sensible to fill a jug and empty it repeatedly nor in a game would it be
advisable to move a piece round and round the board in a cyclic way.
EXTRA:
1. Monotonic learning is when an agent may not learn any knowledge that contradicts
what it already knows. For example, it may not replace a statement with its negation.
Thus, the knowledge base may only grow with new facts in a monotonic fashion.
2. Non-monotonic learning is when an agent may learn knowledge that contradicts what
it already knows. So it may replace old knowledge with new if it believes there is sufficient
reason to do so.
➡ Problem Characteristics
Here we will discuss about 7-problem characteristics. A problem may have different
aspects of representation and explanation. In order to choose the most appropriate
method for a particular problem, it is necessary to analyze the problem along several key
dimensions.
• ︎Is a good solution to the problem obvious without comparison to all the possible
solutions? ︎ Is the desire solution a state of world or a path to a state?
• ︎Will the solution of the problem required interaction between the computer and the
person?
1. Production System
• The production system is a model of computation that can be applied to implement
search algorithms and model human problem solving. Such problem solving
knowledge can be packed up in the form of little quanta called productions.
• When productions are used in deductive systems, the situation that trigger
productions are specified combination of facts. The actions are restricted to being
assertion of new facts deduced directly from the triggering combination. Production
systems may be called premise conclusion pairs rather than situation action pair.
a) A set of production rules, which are of the form A→B. Each rule consists of left
hand side constituent that represent the current problem state and a right hand
side that represent an output state. A rule is applicable if its left hand side
matches with the current problem state.
b) A database, which contains all the appropriate information for the particular task.
Some part of the database may be permanent while some part of this may
pertain only to the solution of the current problem.
c) A control strategy that specifies order in which the rules will be compared to the
database of rules and a way of resolving the conflicts that arise when several
rules match simultaneously.
d) A rule applier, which checks the capability of rule by matching the content state
with the left hand side of the rule and finds the appropriate rule from database of
rules.
• Architecture:
The production rules operate on the knowledge database. Each rule has a precondition—
that is, either satisfied or not by the knowledge database. If the precondition is satisfied,
the rule can be applied. Application of the rule changes the knowledge database. The
control system chooses which applicable rule should be applied and ceases computation
when a termination condition on the knowledge database is satisfied.
The control system serves as a rule interpreter and sequencer. The database acts as a
context buffer, which records the conditions evaluated by the rules and information on
which the rules act. The production rules are also known as condition – action,
antecedent – consequent, pattern – action, situation – response, feedback – result pairs.
2. Characteristics/Features
Some of the main features of production system are:
a) Expressiveness and intuitiveness: In real world, many times situation comes like “if
this happen-you will do that”, “if this is so-then this should happen” and many more.
The production rules essentially tell us what to do in a given situation.
c) Modularity: This means production rule code the knowledge available in discrete
pieces. Information can be treated as a collection of independent facts which may be
added or deleted from the system with essentially no deleterious side effects.
d) Modifiability: This means the facility of modifying rules. It allows the development of
production rules in a skeletal form first and then it is accurate to suit a specific
application.
3. Disadvantages
a) Opacity: This problem is generated by the combination ofproduction rules. The
opacity is generatedbecause of less prioritization of rules. More priority to a rule has
the less opacity.
b) Inefficiency: During execution of a program several rules may active. A well devised
control strategy reduces this problem. As the rules of the production system are large
in number and they are hardly written in hierarchical manner, it requires some forms of
complex search through all the production rules for each cycle of control program.
c) Absence of learning: Rule based production systems do not store the result of the
problem for future use. Hence, it does not exhibit any type of learning capabilities. So
for each time for a particular problem, some new solutions may come.
d) Conflict resolution: The rules in a production system should not have any type of
conflict operations. When a new rule is added to a database, it should ensure that it
does not have any conflicts with the existing rules.
EXTRA
Algorithm (problem name and specification)
Step 1: Analyze the problem to get the starting state and goal state.
Step 2: Find out the data about the starting state, goalstate
Step 3: Find out the production rules from initial database for proceeding the problem to
goal state.
Step 4: Select some rules from the set of rules that can be applied to data.
Step 5: Apply those rules to the initial state and proceed to get the next state.
Step 6: Determine some new generated states after applying the rules. Accordingly make
them as current state.
Step 7: Finally, achieve some information about the goal state from the recently used
current state and get the goal state.
Step 8: Exit.
After applying the above rules, the user may get the solution of the problem from a given
state to another state. Let us take few examples.
3. Chess Problem
4. 8-Puzzle Problem
7. Cryptarithmatic Problem
SEARCHING
• In the coming age of AI, it will have big impact on the technologies of the robotics and
path finding. It is also widely used in travel planning.
• A search algorithm takes a problem as input and returns the solution in the form of an
action sequence. Once the solution is found, the actions it recommends can be
carried out. This phase is called as the execution phase. After formulating a goal and
problem to solve the agent cells, a search procedure to solve it.
a) The initial state: The state from which agent will start.
c) The current state: The state at which the agent is present after starting from the
initial state.
• The searching algorithms can be various types. When any type of searching is
performed, there may some information about the searching or mayn’t be. Also it is
possible that the searching procedure may depend upon any constraints or rules.
• However, generally searching can be classified into two types i.e. uninformed
searching and informed searching. Also some other classifications of these searches
are given below in the figure .
Search Notes 2
Depth Limited search
Depth First Iterative Deepening Search (DFIDS)
Bi-directional Search
Comparing the Uninformed Search Algorithms:
• Simple BFS and BDS are complete and optimal but expensive with
respect to space and time.
• The best overall is DFID which is complete, optimal and has low
memory requirements, but still exponential time.
(Search Notes 2)
• Forward Checking
• Local Search and Metaheuristics
• Iterative/Iterated Local search
• Tabu Search
• Simulated Annealing
• Real Time A*
• Iterative Deepening A* (IDA*)
• Propositional and Predicate Logic
Algorithm:
1.Generate a possible solution.
2.Test to see if this is the expected solution.
3.If the solution has been found quit else go to step 1.
Potential solutions that need to be generated vary depending on the kinds of problems. For
some problems the possible solutions may be particular points in the problem space and for
some problems, paths from the start state.
Figure: Generate And Test
Generate-and-test, like depth-first search, requires that complete solutions be generated for
testing. In its most systematic form, it is only an exhaustive search of the problem space.
Solutions can also be generated randomly but solution is not guaranteed. This approach is
what is known as British Museum algorithm: finding an object in the British Museum by
wandering randomly.
Systematic Generate-And-Test
While generating complete solutions and generating random solutions are the two extremes
there exists another approach that lies in between. The approach is that the search process
proceeds systematically but some paths that unlikely to lead the solution are not considered.
This evaluation is performed by a heuristic function.
Depth-first search tree with backtracking can be used to implement systematic generate-and-
test procedure. As per this procedure, if some intermediate states are likely to appear often
in the
tree, it would be better to modify that procedure to traverse a graph rather than a tree.
Generate-And-Test And Planning
Exhaustive generate-and-test is very useful for simple problems. But for complex problems
even heuristic generate-and-test is not very effective technique. But this may be made
effective by combining with other techniques in such a way that the space in which to
search is restricted. An AI program DENDRAL, for example, uses plan-Generate-and-test
technique. First, the planning process uses constraint-satisfaction techniques and creates
lists of recommended and contraindicated substructures. Then the generate-and-test
procedure uses the lists generated and required to explore only a limited set of structures.
Constrained in this way, generate-and-test proved highly effective. A major weakness of
planning is that it often produces inaccurate solutions as there is no feedback from the
world. But if it is used to produce only pieces of solutions then lack of detailed accuracy
becomes unimportant.
OR
➡ Mean or Means End Analysis
• Most of the search strategies either reason forward of backward. However, often a
mixture of the two directions is appropriate. Such mixed strategy would make it possible
to solve the major parts of problem first and solve the smaller problems that arise when
combining them together. Such a technique is called "Means - Ends Analysis”.
• The means-ends analysis process centers around finding the difference between current
state and goal state.
• The problem space of means - ends analysis has an initial state and one or more goal
state, a set of operate with a set of preconditions their application and difference
functions that computes the difference between two state a(i) and s(j).
• Consider the example of planing for an office worker. Suppose we have a different table
of three rules:
1. If in out current state we are hungry , and in our goal state we are not hungry , then
either the "visit hotel" or "visit Canteen " operator is recommended.
2. If our current state we do not have money , and if in your goal state we have money,
then the "Visit our bank" operator or the "Visit secretary" operator is recommended.
3. If our current state we do not know where something is , need in our goal state we
do know, then either the "visit office enquiry" , "visit secretary" or "visit co worker "
operator is recommended.
OR
Fig Means-End Analysis in AI
➡ Additional Refinements
Quiescence Search
This involves searching past the terminal search nodes (depth of 0)
and testing all the non-quiescent or 'violent' moves until the situation
becomes calm, and only then apply the evaluator.