AI Unit I Lecture Notes
AI Unit I Lecture Notes
IT-504(A)
Artificial Intelligence
Faculty Name-
Prof. Shubha Mishra
Unit 1 Syllabus
• Meaning and definition of artificial intelligence,
Production systems, Characteristics of
production systems,
• Study and comparison of breadth first search
and depth first search techniques, other
Search Techniques like hill Climbing, Best first
Search. A* algorithm, AO* algorithms etc, and
various types of control strategies.
AI?
Meaning of AI
• Data(Input) Machine(processing/use
logic(algorithms)) Output
• Common sense
• Rule of thumb- It
allows an individual to
make an approximation
without having to do
exhaustive research.
Example
Why Heuristics
• Heuristics facilitate timely decisions. Analysts
in every industry use rules of thumb such as
intelligent guesswork, trial and error, process
of elimination, past formulas and the analysis
of historical data to solve a problem. Heuristic
methods make decision making simpler and
faster through short cuts and good-enough
calculations.
Heuristics in AI
• A Heuristic is a technique to solve a problem
faster than classic methods, or to find an
approximate solution when classic methods
cannot.
• How is it set?
it can be taken as a mathematical value to solve
any real time AI based problem.
Heuristic Search
• Method
Heuristic Search Function
• A Heuristic (or a heuristic function) takes a
look at search algorithms. At each branching
step, it evaluates the available information
and makes a decision on which branch to
follow. It does so by ranking alternatives. The
Heuristic is any device that is often effective
but will not guarantee work in every case.
Heuristic Search Techniques
• Direct- use entire state space to perform
search of next possible move
• BFS
• DFS
• Weak-These are effective if applied correctly
to the right types of tasks and usually demand
domain-specific information. We need this
extra information to compute preference
among child nodes to explore and expand.
Searching Algorithms
• Best-First Search
• A* Search
• AO* Search
• Bidirectional Search
• Simulated Annealing
• Hill Climbing
• Constraint Satisfaction Problems
Why AI?
• Problem Solving
• Retail
• AI provides virtual shopping capabilities that
offer personalized recommendations and
discuss purchase options with the consumer.
Stock management and site layout
technologies will also be improved with AI.
Scope & Applications
• Banking
• Artificial Intelligence enhances the speed,
precision and effectiveness of human efforts.
In financial institutions, AI techniques can be
used to identify which transactions are likely
to be fraudulent, adopt fast and accurate
credit scoring, as well as automate manually
intense data management tasks.
Scope & Applications
• Manufacturing
• AI can analyze factory IoT data as it streams
from connected equipment to forecast
expected load and demand using recurrent
networks, a specific type of deep learning
network used with sequence data.
Challenges of using AI
• Simplicity
• Modularity
• Modifiability
• Knowledge Intensive
Types
• Monotonic Production System: It’s a
production system in which the application of
a rule never prevents the later application of
another rule, that could have also been
applied at the time the first rule was selected.
Types
• Non-Monotonic Production Systems are useful
for solving ignorable problems. These systems
are important for man implementation
standpoint because they can be implemented
without the ability to backtrack to previous
states when it is discovered that an incorrect
path was followed. This production system
increases the efficiency since it is not
necessary to keep track of the changes made
in the search process.
Types
• Partially Commutative Production System: It’s
a type of production system in which the
application of a sequence of rules transforms
state X into state Y, then any permutation of
those rules that is allowable also transforms
state x into state Y. Theorem proving falls
under the monotonic partially communicative
system.
Types
• Commutative Systems are usually useful for
problems in which changes occur but can be
reversed and in which the order of operation is
not critical for example the, 8 puzzle problem.
Production systems that are not usually not
partially commutative are useful for many
problems in which irreversible changes occur, such
as chemical analysis. When dealing with such
systems, the order in which operations are
performed is very important and hence correct
decisions must be made at the first time itself.
Advantages of Production System
• The system uses pattern directed control which is
more flexible than algorithmic control
• Provides opportunities for heuristic control of
search
• Tracing and Explanation – Simple Control,
Informative rules
• Language Independence
• A plausible model of human problem solving -
SOAR, ACT
• A good way to model the state-driven nature of
intelligent machines
Advantages of Production System
• Provides excellent tools for structuring AI programs
• The system is highly modular because individual
rules can be added, removed or modified
independently
• Expressed in natural form.
• Separation of knowledge and Control – Recognises
Act Cycle
• A natural mapping onto state space research –
data or goal-driven
• Modularity of production rules
Disadvantages
• It’s very difficult to analyse the flow of control
within a production system
• It describes the operations that can be performed in
a search for a solution to the problem. They can be
classified as follows-
• There is an absence of learning due to a rule-based
production system which does not store the result
of the problem for future use.
• The rules in the production system should not have
any type of conflict resolution as when a new rule is
added to the database it should ensure that it does
Eg. Inference rule
• It is a type of rule that consists of a logical
form used for transformation.
• Deductive Inference Rule
It consists of a logic that helps reasoning with
the help of multiple statements to reach a
conclusion.
Example
If it is given that ‘A implies B,’ then we can infer
the conclusion as ‘B.’
• A: B ⇒ B
Where,
• A: The students are studying well.
• B: If the students are studying well, then all
the students will pass the exam.
Example
• Output:
• return to step2.
5. Exit.
Steepest-Ascent hill climbing
• Ridges: A ridge is a
special form of the local
maximum. It has an
area which is higher
than its surrounding
areas, but itself has a
slope, and cannot be
reached in a single
move.
Solution
• With the use of bidirectional search, or by moving in
different directions, we can improve this problem.
A* Algorithm
• A* Algorithm is one of
the best and popular
techniques used for
path finding and graph
traversals.
• A lot of games and web-
based maps use this
algorithm for finding
the shortest path
efficiently.
Description of A*
• When A* enters into a • Here ‘n’ denotes the
problem, firstly it neighbouring nodes.
calculates the cost to
travel to the neighbouring
nodes and chooses the
node with the lowest cost.
• If The f(n) denotes the
cost, A* chooses the node
with the lowest f(n) value.
Working mechanism
• It maintains a tree of f(n) = g(n) + h(n)
paths originating at the Here,
start node. • ‘n’ is the last node on the
• It extends those paths path
one edge at a time. • g(n) is the cost of the path
• It continues until its from start node to node ‘n’
termination criterion is • h(n) is a heuristic function
satisfied. that estimates cost of the
• A* Algorithm extends the cheapest path from node
path that minimizes the ‘n’ to the goal node
following function-
Algorithm assumptions
• The implementation of • CLOSED contains those
A* Algorithm involves nodes that have already
maintaining two lists- been visited.
OPEN and CLOSED.
• OPEN contains those
nodes that have been
evaluated by the
heuristic function but
have not been
expanded into
successors yet.
Algorithm Steps
• Define a list OPEN. • Expand node n.
• Initially, OPEN consists • If any successor to n is the
solely of a single node, goal node, return success
the start node S. and the solution by tracing
• If the list is empty, return the path from goal node to
failure and exit. S.
• Remove node n with the • Otherwise, go to next Step.
smallest value of f(n) from • For each successor node,
OPEN and move it to list • Apply the evaluation
CLOSED. function f to the node.
• If node n is a goal state, • Go back to step 2.
return success and exit.
Pros & Cons
• pathfinder algorithms • The disadvantage is that
like A* help you plan it is a bit slower than
things rather than the other algorithms.
waiting until you
discover the problem.
• They act proactively
rather than reacting to
a situation
find the most cost-effective path to
reach from start state A to final state
G using A* Algorithm.
Solution
• Since A is a starting node, • Now from A, we can go to
therefore, the value of point B or point E, so we
g(x) for A is zero and from compute f(x) for each of
the graph, we get the them
heuristic value of A is 11,
therefore
• A→B=2+6=8
• A → E = 3 + 7 = 10
• g(x) + h(x) = f(x)
• Since the cost for A → B
• 0+ 11 =11
is less, we move forward
• Thus for A, we can write with this path and
• A=11 compute the f(x) for the
children nodes of B
Solution contd...
• Since there is no path • A → E → D = (3 + 6) + 1 =
between C and G, the 10
heuristic cost is set infinity
• Comparing the cost of A
or a very high value
→ E → D with all the paths
• A → B → C = (2 + 1) + 99= we got so far and as this
102 cost is least of all we move
• A → B → G = (2 + 9 ) + 0 = forward with this path.
11 And compute the f(x) for
• Here the path A → B → G the children of D
has the least cost but it is • A → E → D → G = (3 + 6 +
still more than the cost of 1) +0 =10
A → E, thus we explore
this path further
Solution
• Now comparing all the paths that lead us to the goal,
we conclude that A → E → D → G is the most cost-
effective path to get from A to G.
PRACTICE PROBLEMS BASED ON A*
ALGORITHM-
Given an initial state of a 8-puzzle problem and final state to
be reached.
Find the most cost-effective path to reach the final state
from initial state using A* Algorithm.
Consider g(n) = Depth of node and h(n) = Number of
misplaced tiles.
Solution
Problem 2