Artificial Intelligence Notes
Artificial Intelligence Notes
Artificial Intelligence is composed of two words Artificial and Intelligence, where Artificial
defines “man-made,” and intelligence defines “thinking power”, hence AI means “a man-
made thinking power.”
❖ Definition of AI
It is a branch of computer science by which we can create intelligent machines which can
behave like a human, think like humans, and able to make decisions.”
Artificial Intelligence exists when a machine can have human based skills such as learning,
reasoning, and solving problems.
With Artificial Intelligence you do not need to pre-program a machine to do some work, despite
that you can create a machine with programmed algorithms which can work with own
intelligence, and that is the awesomeness of AI.
It is believed that AI is not a new technology, and some people says that as per Greek myth,
there were Mechanical men in early days which can work and behave like humans.
✓ Proving a theorem
✓ Playing chess
✓ Plan some surgical operation
✓ Driving a car in traffic
• Creating some system which can exhibit intelligent behaviour, learn new things by
itself, demonstrate, explain, and can advise to its user.
• 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.
❖ Applications of AI
Artificial Intelligence has various applications in today's society. It is becoming essential for
today's time because it can solve complex problems with an efficient way in multiple industries,
such as Healthcare, entertainment, finance, education, etc. AI is making our daily life more
comfortable and faster.
Following are some sectors which have the application of Artificial Intelligence:
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.
Artificial Intelligence Notes
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.
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.
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
Artificial Intelligence Notes
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, labour, 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, colour, 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.
• Year 1956: The word "Artificial Intelligence" first adopted by American Computer
scientist John McCarthy at the Dartmouth Conference. For the first time, AI coined as
an academic field.
At that time high-level computer languages such as FORTRAN, LISP, or COBOL were
invented. And the enthusiasm for AI was very high at that time.
❖ A boom of AI (1980-1987)
• Year 1980: After AI winter duration, AI came back with "Expert System". Expert
systems were programmed that emulate the decision-making ability of a human expert.
• In the Year 1980, the first national conference of the American Association of Artificial
Intelligence was held at Stanford University.
• Year 2002: for the first time, AI entered the home in the form of Roomba, a vacuum
cleaner.
• Year 2006: AI came in the Business world till the year 2006. Companies like Facebook,
Twitter, and Netflix also started using AI.
AI (Artificial Intelligence) can be classified into various categories based on different criteria,
such as capabilities, functionality, and techniques. Here's a comprehensive classification:
• Description: AI systems designed and trained for a specific task. They cannot perform
beyond their programming and have a narrow range of abilities.
• Description: Hypothetical AI that has the ability to understand, learn, and apply
knowledge across a wide range of tasks, similar to human intelligence.
• Examples: As of now, General AI does not exist. It represents the goal of creating
machines that can perform any intellectual task a human can do.
c. Super AI
a. Reactive Machines
• Description: These AI systems can only react to current situations based on pre-
programmed rules. They have no memory or ability to use past experiences to inform
present decisions.
b. Limited Memory
• Description: AI systems that can use past experiences to make decisions. They have a
limited memory and can retain some data from previous interactions.
• Examples: Self-driving cars that observe other vehicles and make decisions based on
their observations.
c. Theory of Mind
• Description: This type of AI can understand emotions, beliefs, and intentions. It can
interact with humans on a more personal level by recognizing emotional states.
• Examples: This is still in the research phase and does not exist as a fully realized
technology.
Artificial Intelligence Notes
d. Self-Aware AI
• Description: AI systems with a sense of self. They are aware of their own existence
and can understand their own states, emotions, and potentially the emotions of others.
❖ Expert Systems
• Inference Engine: The component that applies logical rules to the knowledge base
to derive conclusions or make decisions. It mimics the reasoning process of a human
expert.
• User Interface: The interface through which users interact with the expert system.
It allows users to input data and receive advice, explanations, or recommendations
from the system.
• Explanation System: Provides users with explanations about how the expert
system arrived at a particular conclusion or decision, increasing transparency and
trust in the system.
• Legal Advisory: Offering legal advice and assisting in the preparation of legal
documents based on existing laws and regulations.
Expert systems are valuable tools in many fields, offering expert-level decision-making
capabilities in specialized domains, which can enhance productivity, accuracy, and consistency
in problem-solving.
❖ Structure of an AI Agent
To understand the structure of Intelligent Agents, we should be familiar with Architecture and
Agent programs. Architecture is the machinery that the agent executes on. It is a device with
sensors and actuators, for example, a robotic car, a camera, and a PC. An agent program is an
implementation of an agent function. An agent function is a map from the percept sequence
(history of all that an agent has perceived to date) to an action.
Agent = Architecture + Agent Program
There are many examples of agents in artificial intelligence. Here are a few:
• Intelligent personal assistants: These are agents that are designed to help users with
various tasks, such as scheduling appointments, sending messages, and setting
reminders. Examples of intelligent personal assistants include Siri, Alexa, and Google
Assistant.
• Autonomous robots: These are agents that are designed to operate autonomously in
the physical world. They can perform tasks such as cleaning, sorting, and delivering
goods. Examples of autonomous robots include the Roomba vacuum cleaner and the
Amazon delivery robot.
• Gaming agents: These are agents that are designed to play games, either against human
opponents or other agents. Examples of gaming agents include chess-playing agents
and poker-playing agents.
Artificial Intelligence Notes
• Fraud detection agents: These are agents that are designed to detect fraudulent
behaviour in financial transactions. They can analyse patterns of behaviour to identify
suspicious activity and alert authorities. Examples of fraud detection agents include
those used by banks and credit card companies.
• Traffic management agents: These are agents that are designed to manage traffic flow
in cities. They can monitor traffic patterns, adjust traffic lights, and reroute vehicles to
minimize congestion. Examples of traffic management agents include those used in
smart cities around the world.
• A software agent has Keystrokes, file contents, received network packages that act as
sensors and displays on the screen, files, and sent network packets acting as actuators.
• A Human-agent has eyes, ears, and other organs which act as sensors, and hands, legs,
mouth, and other body parts act as actuators.
• A Robotic agent has cameras and infrared range finders which act as sensors and
various motors act as actuators.
❖ Types of Agents
Agents can be grouped into five classes based on their degree of perceived intelligence and
capability:
• Simple Reflex Agents
• Model-Based Reflex Agents
Artificial Intelligence Notes
• Goal-Based Agents
• Utility-Based Agents
• Learning Agent
• Multi-agent systems
It works by finding a rule whose condition matches the current situation. A model-based agent
can handle partially observable environments by the use of a model about the world. The agent
has to keep track of the internal state which is adjusted by each percept and that depends on the
Artificial Intelligence Notes
percept history. The current state is stored inside the agent which maintains some kind of
structure describing the part of the world which cannot be seen.
3. Goal-Based Agents
These kinds of agents take decisions based on how far they are currently from their goal
(description of desirable situations). Their every action is intended to reduce their distance from
the goal. This allows the agent a way to 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, which makes these agents more flexible. They usually require search and
planning. The goal-based agent’s behavior can easily be changed.
4. Utility-Based Agents
The agents which are developed having their end uses as building blocks are called utility-
based agents. When there are multiple possible alternatives, then to decide which one is best,
utility-based agents are used. 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. Because of the uncertainty in the world, 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.
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:
a) Learning element: It is responsible for making improvements by learning from the
environment.
b) Critic: The learning element takes feedback from critics which describes how well the
agent is doing with respect to a fixed performance standard.
c) Performance element: It is responsible for selecting external action.
Artificial Intelligence Notes
d) Problem Generator: This component is responsible for suggesting actions that will lead
to new and informative experiences.
6. Multi-Agent Systems
These agents interact with other agents to achieve a common goal. They may have to coordinate
their actions and communicate with each other to achieve their objective.
A multi-agent system (MAS) is a system composed of multiple interacting agents that are
designed to work together to achieve a common goal. These agents may be autonomous or
semi-autonomous and are capable of perceiving their environment, making decisions, and
taking action to achieve the common objective and can help to solve complex problems.
MAS can be used in a variety of applications, including transportation systems, robotics, and
social networks. They can help improve efficiency, reduce costs, and increase flexibility in
complex systems. MAS can be classified into different types based on their characteristics,
such as whether the agents have the same or different goals, whether the agents are cooperative
or competitive, and whether the agents are homogeneous or heterogeneous.
In a homogeneous MAS, all the agents have the same capabilities, goals, and behaviours. This
can make coordination more challenging but can also lead to more flexible and robust systems.
Cooperative MAS involves agents working together to achieve a common goal, while
competitive MAS involves agents working against each other to achieve their own goals. In
some cases, MAS can also involve both cooperative and competitive behaviour, where agents
must balance their own interests with the interests of the group.
Artificial Intelligence Notes
MAS can be implemented using different techniques, such as game theory, machine learning,
and agent-based modelling. Game theory is used to analyse strategic interactions between
agents and predict their behaviour. Machine learning is used to train agents to improve their
decision-making capabilities over time. Agent-based modelling is used to simulate complex
systems and study the interactions between agents.
Example: Traffic Management System, Autonomous Drones for Delivery, Stock Trading
System, Collaborative Robotics (Cobots), Smart Grid Energy Management etc.
❖ Well-defined Problems
A problem can be defined formally by four components:
▪ The that the agent starts in.
▪ A description of the possible available to the agent.
– Commonly done using a Successor function. Given a particular state x,
SUCCESSOR-FN(x) returns a set of (action_successor) ordered pairs.
– The initial state and success or function implicitly define the state space of the
problem - the set of all states reachable from the initial state.
▪ The determines whether a given state is a goal state.
– Explicit set of possible goal states or specified by an abstract property
▪ A function that assigns a numeric cost to each path.
– Agent chooses a cost function that reflect sits own performance measure
– Agent attempts to minimize the cost function
❖ Problem Formulation
A to a problem is a path from the initial state to a goal state.
• Solution quality is measured by the path cost.
Artificial Intelligence Notes
Initial State
– Description of all pertinent aspects of the state in which the agent starts the search.
Goal Test
– Conditions the agent is trying to meet.
Goal State
– Any state which meets the goal condition.
Problem Formulation
– Describe a general problem as a search problem.
Solution
– Sequence of actions that transitions the world from the initial state to a goal state.
Search
– Process of looking for a solution.
– Search algorithm takes problem as input and returns solution
– We are searching through a space of possible states
Execution
– Process of executing sequence of actions (solution)
Artificial Intelligence Notes
❖ Examples
Artificial Intelligence Notes
1. Breadth-first Search:
• Breadth-first search is the most common search strategy for traversing a tree or graph.
This algorithm searches breadthwise in a tree or graph, so it is called breadth-first
search.
• BFS algorithm starts searching from the root node of the tree and expands all successor
node at the current level before moving to nodes of next level.
• The breadth-first search algorithm is an example of a general-graph search algorithm.
• Breadth-first search implemented using FIFO queue data structure.
Artificial Intelligence Notes
Advantages:
• BFS will provide a solution if any solution exists.
• If there are more than one solution for a given problem, then BFS will provide the
minimal solution which requires the least number of steps.
Disadvantages:
• It requires lots of memory since each level of the tree must be saved into memory to
expand the next level.
• BFS needs lots of time if the solution is far away from the root node.
Example:
In the below tree structure, we have shown the traversing of the tree using BFS algorithm from
the root node S to goal node K. BFS search algorithm traverse in layers, so it will follow the
path which is shown by the dotted arrow, and the traversed path will be:
S---> A--->B---->C--->D---->G--->H--->E---->F---->I---->K
Time Complexity: Time Complexity of BFS algorithm can be obtained by the number of
nodes traversed in BFS until the shallowest Node. Where the d= depth of shallowest solution
and b is a node at every state.
T (b) = 1 + b2 + b3 + ....... + bd= O (bd)
Space Complexity: Space complexity of BFS algorithm is given by the Memory size of
frontier which is O(bd).
Completeness: BFS is complete, which means if the shallowest goal node is at some finite
depth, then BFS will find a solution.
Optimality: BFS is optimal if path cost is a non-decreasing function of the depth of the node.
Artificial Intelligence Notes
More Examples:
Problem 1 Solution
Path Traversed = [A – B – C- D – E – F- G – H]
Problem 2 Solution
Path Traversed = [S - A – B – C- D – G – H - E – F-
I-K]
2. Depth-first Search
• Depth-first search is a recursive algorithm for traversing a tree or graph data structure.
• It is called the depth-first search because it starts from the root node and follows each
path to its greatest depth node before moving to the next path.
• DFS uses a stack data structure for its implementation.
• The process of the DFS algorithm is similar to the BFS algorithm.
Advantage:
• DFS requires very less memory as it only needs to store a stack of the nodes on the path
from root node to the current node.
Artificial Intelligence Notes
• It takes less time to reach to the goal node than BFS algorithm (if it traverses in the
right path).
Disadvantage:
• There is the possibility that many states keep re-occurring, and there is no guarantee of
finding the solution.
• DFS algorithm goes for deep down searching and sometime it may go to the infinite
loop.
Example:
In the below search tree, we have shown the flow of depth-first search, and it will follow the
order as:
Root node--->Left node ----> right node.
It will start searching from root node S, and traverse A, then B, then D and E, after traversing
E, it will backtrack the tree as E has no other successor and still goal node is not found. After
backtracking it will traverse node C and then G, and here it will terminate as it found goal node.
Completeness: DFS search algorithm is complete within finite state space as it will expand
every node within a limited search tree.
Time Complexity: Time complexity of DFS will be equivalent to the node traversed by the
algorithm. It is given by:
T(n)= 1+ n2+ n3 +.........+ nm=O(nm)
Where, m= maximum depth of any node and this can be much larger than d (Shallowest
solution depth)
Space Complexity: DFS algorithm needs to store only single path from the root node, hence
space complexity of DFS is equivalent to the size of the fringe set, which is O(bm).
Artificial Intelligence Notes
Optimal: DFS search algorithm is non-optimal, as it may generate a large number of steps or
high cost to reach to the goal node.
Example:
Problem 1: Solution
Path Traversed = [A - B – D – G - E – C – F - H]
Problem 2: Solution
Path Traversed = [A - B – D – G - E – C – F - H]
Advantages:
Depth-limited search is Memory efficient.
Disadvantages:
o Depth-limited search also has a disadvantage of incompleteness.
o It may not be optimal if the problem has more than one solution.
Example:
Completeness: DLS search algorithm is complete if the solution is above the depth-limit.
Time Complexity: Time complexity of DLS algorithm is O(bℓ).
Space Complexity: Space complexity of DLS algorithm is O(b×ℓ).
Optimal: Depth-limited search can be viewed as a special case of DFS, and it is also not
optimal even if ℓ>d.
Problem Solution
Completeness:
Uniform-cost search is complete, such as if there is a solution, UCS will find it.
Time Complexity:
Let C* is Cost of the optimal solution, and ε is each step to get closer to the goal node. Then
the number of steps is = C*/ε+1. Here we have taken +1, as we start from state 0 and end to
C*/ε.
Hence, the worst-case time complexity of Uniform-cost search is O (b1 + [C*/ε]).
Artificial Intelligence Notes
Space Complexity:
The same logic is for space complexity so, the worst-case space complexity of Uniform-cost
search is O(b1 + [C*/ε]).
Optimal:
Uniform-cost search is always optimal as it only selects a path with the lowest path cost.
Problem 1 Solution
Advantages:
• It combines the benefits of BFS and DFS search algorithm in terms of fast search and
memory efficiency.
Disadvantages:
• The main drawback of IDDFS is that it repeats all the work of the previous phase.
Example:
Following tree structure is showing the iterative deepening depth-first search. IDDFS algorithm
performs various iterations until it does not find the goal node. The iteration performed by the
algorithm is given as:
1'st Iteration-----> A
2'nd Iteration----> A, B, C
Artificial Intelligence Notes
3'rd Iteration------>A, B, D, E, C, F, G
4'th Iteration------>A, B, D, H, I, E, C, F, K, G
In the fourth iteration, the algorithm will find the goal node.
Completeness:
This algorithm is complete is if the branching factor is finite.
Time Complexity:
Let’s suppose b is the branching factor and depth is d then the worst-case time complexity is
O(bd).
Space Complexity:
The space complexity of IDDFS will be O(bd).
Optimal:
IDDFS algorithm is optimal if path cost is a non- decreasing function of the depth of the node.
Problem Solution
2nd Iteration, d = 1, [S – A - C]
3rd Iteration, d = 2, [S – A – D – B – C – E - G]
Performs a depth-limited search by gradually increasing the depth_limit until the goal at the
shallowest depth is found. Usi
1. Perform Depth limited search for depth_limit = 0
2. If solution is found exit, else go to 3
3. Increase depth_limit by 1
4. Go back to 1
starts the search from an initial vertex and other starts from goal vertex. The search stops when
these two graphs intersect each other.
Bidirectional search can use search techniques such as BFS, DFS, DLS, etc.
Advantages:
• Bidirectional search is fast.
• Bidirectional search requires less memory
Disadvantages:
• Implementation of the bidirectional search tree is difficult.
• In bidirectional search, one should know the goal state in advance.
Problem 1 Solution
Problem 2
Solution
Path Traversed = [A – B – D – C – E – F – H – J – L – I – Y – K - G]
[A – B – C - D – F – E - G]