Unit 1 Ai PDF
Unit 1 Ai PDF
INTELLIGENCE
Introduction to AI
Artificial intelligence refers to the simulation of
human intelligence in machines that are
programmed to think like humans and mimic their
actions.
Artificial intelligence (AI) is a wide-ranging branch
of computer science concerned with building
smart machines capable of performing tasks that
typically require human intelligence.
Types of AI
Types of AI
AI type-1: Based on Capabilities
1. Weak AI or Narrow AI:
• Narrow AI is a type of AI which is able to perform a dedicated task with
intelligence. The most common and currently available AI is Narrow AI in the
world of Artificial Intelligence.
• Narrow AI cannot perform beyond its field or limitations, as it is only trained
for one specific task. Hence it is also termed as weak AI. Narrow AI can fail in
unpredictable ways if it goes beyond its limits.
• Apple Siri is a good example of Narrow AI, but it operates with a limited pre-
defined range of functions.
• IBM's Watson supercomputer also comes under Narrow AI, as it uses an Expert
system approach combined with Machine learning and natural language
processing.
• Some Examples of Narrow AI are playing chess, purchasing suggestions on e-
commerce site, self-driving cars, speech recognition, and image recognition.
Types of AI
2. General AI:
• General AI is a type of intelligence which could perform any intellectual task
with efficiency like a human.
• The idea behind the general AI to make such a system which could be smarter
and think like a human by its own.
• Currently, there is no such system exist which could come under general AI and
can perform any task as perfect as a human.
• The worldwide researchers are now focused on developing machines with
General AI.
• As systems with general AI are still under research, and it will take lots of efforts
and time to develop such systems.
3. Super AI:
• Super AI is a level of Intelligence of Systems at which machines could surpass
human intelligence, and can perform any task better than human with cognitive
properties. It is an outcome of general AI.
• Some key characteristics of strong AI include capability include the ability to
think, to reason,solve the puzzle, make judgments, plan, learn, and
communicate by its own.
• Super AI is still a hypothetical concept of Artificial Intelligence. Development of
such systems in real is still world changing task.
Types of AI
Artificial Intelligence type-2: Based on functionality
1. Reactive Machines
• Purely reactive machines are the most basic types of Artificial Intelligence.
• Such AI systems do not store memories or past experiences for future actions.
• These machines only focus on current scenarios and react on it as per possible
best action.
• IBM's Deep Blue system is an example of reactive machines.
• Google's AlphaGo is also an example of reactive machines.
2. Limited Memory
• Limited memory machines can store past experiences or some data for a short
period of time.
• These machines can use stored data for a limited time period only.
• Self-driving cars are one of the best examples of Limited Memory systems.
These cars can store recent speed of nearby cars, the distance of other cars,
speed limit, and other information to navigate the road.
Types of AI
3. Theory of Mind
• Theory of Mind AI should understand the human emotions, people, beliefs,
and be able to interact socially like humans.
• This type of AI machines are still not developed, but researchers are making
lots of efforts and improvement for developing such AI machines.
4. Self-Awareness
• Self-awareness AI is the future of Artificial Intelligence. These machines will
be super intelligent, and will have their own consciousness, sentiments, and
self-awareness.
• These machines will be smarter than human mind.
• Self-Awareness AI does not exist in reality still and it is a hypothetical
concept.
Importance of AI
• With the help of AI, you can create such software or devices which can solve
real-world problems very easily and with accuracy such as health issues,
marketing, traffic issues, etc.
• With the help of AI, you can create your personal virtual Assistant, such as
Cortana, Google Assistant, Siri, etc.
• With the help of AI, you can build such Robots which can work in an
environment where survival of humans can be at risk.
• AI opens a path for other new technologies, new devices, and new
Opportunities.
Goals of AI
Replicate human intelligence
Solve Knowledge-intensive tasks
An intelligent connection of perception and action
Building a machine which can perform tasks that requires human intelligence
such as:
Proving a theorem
Playing chess
Plan some surgical operation
Driving a car in traffic
Creating some system which can exhibit intelligent behavior, learn new things
by itself, demonstrate, explain, and can advise to its user.
Applications of AI
Applications of AI
1. AI in Astronomy
• Artificial Intelligence can be very useful to solve complex universe problems. AI
technology can be helpful for understanding the universe such as how it works,
origin, etc.
2. AI in Healthcare
• In the last, five to ten years, AI becoming more advantageous for the
healthcare industry and going to have a significant impact on this industry.
• Healthcare Industries are applying AI to make a better and faster diagnosis than
humans. AI can help doctors with diagnoses and can inform when patients are
worsening so that medical help can reach to the patient before hospitalization.
3. AI in Gaming
• AI can be used for gaming purpose. The AI machines can play strategic games
like chess, where the machine needs to think of a large number of possible
places.
4. AI in Finance
• AI and finance industries are the best matches for each other. The finance
industry is implementing automation, chatbot, adaptive intelligence, algorithm
trading, and machine learning into financial processes.
Applications of AI
5. AI in Data Security
• The security of data is crucial for every company and cyber-attacks are growing very
rapidly in the digital world. AI can be used to make your data more safe and secure.
Some examples such as AEG bot, AI2 Platform, are used to determine software bug and
cyber-attacks in a better way.
6. AI in Social Media
• Social Media sites such as Facebook, Twitter, and Snapchat contain billions of user
profiles, which need to be stored and managed in a very efficient way. AI can organize
and manage massive amounts of data. AI can analyze lots of data to identify the latest
trends, hashtag, and requirement of different users.
7. AI in Travel & Transport
• AI is becoming highly demanding for travel industries. AI is capable of doing various
travel related works such as from making travel arrangement to suggesting the hotels,
flights, and best routes to the customers. Travel industries are using AI-powered
chatbots which can make human-like interaction with customers for better and fast
response.
8. AI in Automotive Industry
• Some Automotive industries are using AI to provide virtual assistant to their user for
better performance. Such as Tesla has introduced TeslaBot, an intelligent virtual
assistant.
• Various Industries are currently working for developing self-driven cars which can make
your journey more safe and secure.
Applications of AI
9. AI in Robotics:
• Artificial Intelligence has a remarkable role in Robotics. Usually, general robots are programmed
such that they can perform some repetitive task, but with the help of AI, we can create
intelligent robots which can perform tasks with their own experiences without pre-programmed.
• Humanoid Robots are best examples for AI in robotics, recently the intelligent Humanoid robot
named as Erica and Sophia has been developed which can talk and behave like humans.
10. AI in Entertainment
• We are currently using some AI based applications in our daily life with some entertainment
services such as Netflix or Amazon. With the help of ML/AI algorithms, these services show the
recommendations for programs or shows.
11. AI in Agriculture
• Agriculture is an area which requires various resources, labor, money, and time for best result.
Now a day's agriculture is becoming digital, and AI is emerging in this field. Agriculture is
applying AI as agriculture robotics, solid and crop monitoring, predictive analysis. AI in
agriculture can be very helpful for farmers.
12. AI in E-commerce
• AI is providing a competitive edge to the e-commerce industry, and it is becoming more
demanding in the e-commerce business. AI is helping shoppers to discover associated products
with recommended size, color, or even brand.
13. AI in education:
• AI can automate grading so that the tutor can have more time to teach. AI chatbot can
communicate with students as a teaching assistant.
• AI in the future can be work as a personal virtual tutor for students, which will be accessible
easily at any time and any place.
Advantages of AI
• High Accuracy with less errors: AI machines or systems are prone to less errors
and high accuracy as it takes decisions as per pre-experience or information.
• High-Speed: AI systems can be of very high-speed and fast-decision making,
because of that AI systems can beat a chess champion in the Chess game.
• High reliability: AI machines are highly reliable and can perform the same action
multiple times with high accuracy.
• Useful for risky areas: AI machines can be helpful in situations such as defusing a
bomb, exploring the ocean floor, where to employ a human can be risky.
• Digital Assistant: AI can be very useful to provide digital assistant to the users
such as AI technology is currently used by various E-commerce websites to show
the products as per customer requirement.
• Useful as a public utility: AI can be very useful for public utilities such as a self-
driving car which can make our journey safer and hassle-free, facial recognition
for security purpose, Natural language processing to communicate with the human
in human-language, etc.
Disadvantages of AI
• High Cost: The hardware and software requirement of AI is very costly as it
requires lots of maintenance to meet current world requirements.
• Can't think out of the box: Even we are making smarter machines with AI, but
still they cannot work out of the box, as the robot will only do that work for which
they are trained, or programmed.
• No feelings and emotions: AI machines can be an outstanding performer, but
still it does not have the feeling so it cannot make any kind of emotional
attachment with human, and may sometime be harmful for users if the proper
care is not taken.
• Increase dependency on machines: With the increment of technology, people
are getting more dependent on devices and hence they are losing their mental
capabilities.
• No Original Creativity: As humans are so creative and can imagine some new
ideas but still AI machines cannot beat this power of human intelligence and
cannot be creative and imaginative
Sub-fields Of Artificial Intelligence
Sub-fields Of Artificial Intelligence
1) Machine Learning
Machine learning is a feature of artificial intelligence that provides the computer
with the capability to automatically gather data and learn from the experience of
the problems or cases they have encountered rather than specially programmed to
perform the given task or work.
Pattern recognition is a sub-category of machine learning. It can be described as
the automatic recognition of the blueprint from the raw data using computer
algorithms.
The pattern recognition process includes several steps. These are explained as
follows:
(i) Data acquisition and sensing: This includes the collection of raw data like
physical variables etc and measurement of frequency, bandwidth, resolution, etc.
The data is of two types: training data, and learning data.
(ii) Pre-processing of input data: This includes filtering out the unwanted data
like noise from the input source and it is done through signal processing. At this
stage, the filtration of pre-existing patterns in the input data is also done for
further references.
(iii) Feature extraction: Various algorithms are carried out like a pattern
matching algorithm to find the matching pattern as required in terms of features.
(iv) Classification: Based on the output of algorithms carried out and various
models learned to get the matching pattern, the class is assigned to the pattern.
(v) Post-processing: Here the final output is presented and it will be assured that
the result achieved is almost as likely to be needed.
Sub-fields Of Artificial Intelligence
Model for pattern recognition
The feature extractor will derive the features from the input raw data, like audio, image, video,
sonic, etc.
Now, the classifier will receive x as input value and will allocate different categories to the
input value like class 1, class 2 …. class C. based on the class of the data, further recognition
and analysis of the pattern are done.
Take decisions based on how far they are currently from their goal.
Their every action is intended to reduce its distance from the goal.
Choose among multiple possibilities, selecting the one which reaches a goal state.
The knowledge that supports its decisions is represented explicitly and can be modified.
Agents are more flexible.
They usually require search and planning.
The goal-based agent’s behavior can easily be changed.
3) Goal-based agents
4) Utility-based agents
When there are multiple possible alternatives, then to decide which one is best.
They choose actions based on a preference (utility) for each state.
Sometimes achieving the desired goal is not enough. We may look for a quicker, safer, cheaper trip to
reach a destination.
Agent happiness should be taken into consideration. Utility describes how “happy” the agent is.
a utility agent chooses the action that maximizes the expected utility.
A utility function maps a state onto a real number which describes the associated degree of happiness.
4) Utility-based agents
5) Learning Agent
A learning agent in AI is the type of agent that can learn from its past experiences or it has learning
capabilities.
It starts to act with basic knowledge and then is able to act and adapt automatically through learning.
A learning agent has mainly four conceptual components, which are:
1. Learning element: It is responsible for making improvements by learning from the environment
2. Critic: The learning element takes feedback from critics which describes how well the agent is doing
with respect to a fixed performance standard.
3. Performance element: It is responsible for selecting external action
4. Problem Generator: This component is responsible for suggesting actions that will lead to new and
informative experiences.
5) Learning Agent
State Space Search
State Space Search is the most commonly used technique in AI for problem solving.
State Space means the number of states a problem can go into. It is the set of all states
reachable from initial state by executing any sequence of actions.
State space specifies the relation among various problems states thereby forming directed
network of graphs in which the nodes are states and links between nodes represent actions
State space search is a method used widely in artificial intelligence and computer science to
find a solution to a problem by searching through the set of possible states of the problem.
Start State – Initial state where we start solving problem
Intermediate States – All the states between Start and Final state
Final State – Goal state where we find final solution
The steps of a typical state space search algorithm
State Space Search
8 puzzle without heuristics
8 puzzle with heuristics
I. How can you get exactly 2 liter of water into the 4-liter jug.
Solution:
The state space for this problem can be described as the set of ordered pairs of integers (x,y)
Where,
In the above figure, the buying of a car may be broken down into smaller problems
or tasks that can be accomplished to achieve the main goal in the above figure,
which is an example of a simple AND-OR graph. The other task is to either steal a
car that will help us accomplish the main goal or use your own money to purchase a
car that will accomplish the main goal. The AND symbol is used to indicate the AND
part of the graphs, which refers to the need that all subproblems containing the AND
to be resolved before the preceding node or issue may be finished.
The start state and the target state are already known in the knowledge-based
search strategy known as the AO* algorithm, and the best path is identified by
heuristics. The informed search technique considerably reduces the algorithm’s time
complexity. The AO* algorithm is far more effective in searching AND-OR
trees than the A* algorithm.
AO* Algorithm
Working of AO* algorithm:
The evaluation function in AO* looks like this:
f(n) = g(n) + h(n)
f(n) = Actual cost + Estimated cost
here,
f(n) = The actual cost of traversal.
g(n) = the cost from the initial node to the current node.
h(n) = estimated cost from the current node to the goal state.
Difference between the A* Algorithm and AO* algorithm
• A* algorithm and AO* algorithm both works on the best first search.
• They are both informed search and works on given heuristics values.
• A* always gives the optimal solution but AO* doesn’t guarantee to give the optimal
solution.
• Once AO* got a solution doesn’t explore all possible paths but A* explores all paths.
• When compared to the A* algorithm, the AO* algorithm uses less memory.
• opposite to the A* algorithm, the AO* algorithm cannot go into an endless loop.
AO* Algorithm
ALGORITHM:
1. Initialize the graph to start node
2. Traverse the graph following the current path accumulating nodes that
have not yet been expanded or solved
3. Pick any of these nodes and expand it and if it has no successors call this
value FUTILITY otherwise calculate only f' for each of the successors.
4. If f' is 0 then mark the node as SOLVED
5. Change the value of f' for the newly created node to reflect its
successors by back propagation.
6. Wherever possible use the most promising routes and if a node is
marked as SOLVED then mark the parent node as SOLVED.
7. If starting node is SOLVED or value greater than FUTILITY, stop, else
repeat from 2.
AO* Algorithm
Example
2. Plateau: A plateau is the flat area of the search space in which all the neighbor states of the
current state contains the same value, because of this algorithm does not find any best
direction to move. A hill-climbing search might be lost in the plateau area.
Solution: The solution for the plateau is to take big steps or very little steps while searching, to
solve the problem. Randomly select a state which is far away from the current state so it is
possible that the algorithm could find non-plateau region.
Problems in Hill Climbing
3. 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.
Types of Hill Climbing Algorithm
1. Simple Hill Climbing:
Simple hill climbing is the simplest way to implement a hill climbing algorithm. It only
evaluates the neighbor node state at a time and selects the first one which optimizes
current cost and set it as a current state. It only checks it's one successor state, and if it finds
better than the current state, then move else be in the same state. This algorithm has the
following features:
• Less time consuming
• Less optimal solution and the solution is not guaranteed
2. Steepest-Ascent hill climbing:
The steepest-Ascent algorithm is a variation of simple hill climbing algorithm. This algorithm
examines all the neighboring nodes of the current state and selects one neighbor node which is
closest to the goal state. This algorithm consumes more time as it searches for multiple
neighbors
3. Stochastic hill climbing:
Stochastic hill climbing does not examine for all its neighbor before moving. Rather, this search
algorithm selects one neighbor node at random and decides whether to choose it as a current
state or examine another state.
Types of Hill Climbing Algorithm
Algorithm for Simple Hill Climbing:
• Step 1: Evaluate the initial state, if it is goal state then return success and
Stop.
• Step 2: Loop Until a solution is found or there is no new operator left to apply.
• Step 3: Select and apply an operator to the current state.
• Step 4: Check new state:
• If it is goal state, then return success and quit.
• Else if it is better than the current state then assign new state as a current
state.
• Else if not better than the current state, then return to step2.
• Step 5: Exit.
Types of Hill Climbing Algorithm
Algorithm for Steepest-Ascent hill climbing:
• Step 1: Evaluate the initial state, if it is goal state then return success and stop, else make
current state as initial state.
• Step 2: Loop until a solution is found or the current state does not change.
• Let SUCC be a state such that any successor of the current state will be better than it.
• For each operator that applies to the current state:
• Apply the new operator and generate a new state.
• Evaluate the new state.
• If it is goal state, then return it and quit, else compare it to the SUCC.
• If it is better than SUCC, then set new state as SUCC.
• If the SUCC is better than the current state, then set current state to SUCC.
• Step 5: Exit.
Constraint Satisfaction Problem (CSP)
CSP uses a factored representation for each state: a set of variables, each of which has
a value.
A problem is solved when each variable has a value that satisfies all the constraints in
the variable.
A problem described this way is called a constraint satisfaction problem.
A CSP consists of 3 components V,D and C:
• V is a set of variables {V1,V2,V3,……,Vn}.
• D is a set of domains {D1,D2,D3,……,Dn},one for each variable.
• C is a set of constraints that specify allowable combinations of values.
Here,
• Each domain Di consists of a set off allowable values for each variable Vi.
• Each constraint Ci consists of a pair (scope,rel)
where, scope is a tuple of variables that participate in the constraint and rel is a relation
that defines the values that those variables can take on.
Coloring Map/Node Problem CSP
When coloring a map – or any other drawing consisting of distinct regions –
adjacent countries/nodes cannot have the same color. We might also want to
use as few different colors as possible.
V ={1,2,3,4}
D = {RED, GREEN, BLUE}
C = {(1!=2), (1!=3), (1!=4), (2!=4), (3!=4)}
1 2 3 4
Initial Domain RED, GREEN, BLUE RED, GREEN, BLUE RED, GREEN, BLUE RED, GREEN, BLUE
1 = RED RED GREEN, BLUE GREEN, BLUE GREEN, BLUE
2 = GREEN RED GREEN GREEN, BLUE GREEN, BLUE
3 = BLUE RED GREEN BLUE EMPTY
Backtracking
3 = GREEN RED GREEN GREEN BLUE done here
Crypt Arithmetic Problem CSP
The Crypt-Arithmetic problem in Artificial Intelligence is a type of encryption
problem in which the written message in an alphabetical form which is easily
readable and understandable is converted into a numeric form which is neither
easily readable nor understandable. In simpler words, the crypt-arithmetic
problem deals with the converting of the message from the readable plain text
to the non-readable ciphertext. The constraints which this problem follows
during the conversion is as follows:
1. A number 0-9 is assigned to a particular alphabet.
2. Each different alphabet has a unique number.
3. All the same, alphabets have the same numbers.
4. The numbers should satisfy all the operations that any normal number does.
Crypt Arithmetic Problem CSP
Example
We first look for the MSB in the last word which is 'M' in the word 'MONEY' here. It is the letter which is
generated by carrying. So, carry generated can be only one. SO, we have M=1.
Now, we have S+M=O in the second column from the left side. Here M=1. Therefore, we have, S+1=O. So, we
need a number for S such that it generates a carry when added with 1. And such a number is 9. Therefore, we
have S=9 and O=0.
Now, in the next column from the same side we have E+O=N. Here we have O=0. Which means E+0=N which is
not possible. This means a carry was generated by the lower place digits. So we have:
1+E=N ----------(i)
Next alphabets that we have are N+R=E -------(ii)
So, for satisfying both equations (i) and (ii), we get E=5 and N=6.
Now, R should be 9, but 9 is already assigned to S, So, R=8 and we have 1 as a carry which is generated from
the lower place digits.
Now, we have D+5=Y and this should generate a carry. Therefore, D should be greater than 4. As 5, 6,
8 and 9 are already assigned, we have D=7 and therefore Y=2.
Therefore, the solution to the given Crypt-Arithmetic problem is:
S=9; E=5; N=6; D=7; M=1; O=0; R=8; Y=2
Missionaries and Cannibal Problem
On one bank of a river are three missionaries and three cannibals. There is one boat available
that can hold up to two people and that they would like to use to cross the river. If the cannibals
ever outnumber the missionaries on either of the river’s banks, the missionaries will get eaten.
How can the boat be used to safely carry all the missionaries and cannibals across the river?
Solution: Step Ending State Starting
Side Side
State Representation : <R,M,C> <2,0,0> Initial <1,3,3>
A B C D
Possible Routes
A 0 20 40 22
B 20 0 13 30
C 40 13 0 12
D 22 30 12 0
Tower of Hanoi
Tower of Hanoi is a mathematical puzzle where we have three rods (P1,P2 and P3) and 3 disks. Initially, all
the disks are stacked in decreasing value of diameter i.e., the smallest disk is placed on the top and they are
on rod P1. The objective of the puzzle is to move the entire stack to another rod (here considered P3),
obeying the following simple rules:
• Only one disk can be moved at a time.
• Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack i.e.
a disk can only be moved if it is the uppermost disk on a stack.
• No disk may be placed on top of a smaller disk.