Module 1
Module 1
MODULE – 1
1. Introduction to AI
Artificial Intelligence (AI) is the science and engineering of making intelligent machines, especially
AI applications perform specialized tasks by processing large amounts of data and recognizing
patterns in them. Besides learning from experience, AI applications can recognize objects,
understand and respond to language and make decisions to solve real -world problems. AI perform
tasks that normally require human intelligence. The main focus of this technology is to build
machines and algorithms which are capable of performing computational tasks that would
While computers execute certain tasks like sorting, computing, memorizing, indexing , finding
patterns, etc. far better than humans, they still cannot beat human skills for identifying emotions,
recognizing faces, communication and conversation. This is where AI will play a crucial role to
1.1. Definition:
From a layman’s view, artificial intelligence (AI), simply means the intelligence
demonstrated by machines that help them to mimic the actions of humans. AI simulates natural
intelligence in machines that are programmed to learn from experiences, adjust to new inputs
From a researcher’s view, AI is a set of algorithms that generates results without having to
be explicitly instructed to do so, thereby making machines capable of thinking and acting
NITI (National Institution for Transforming India) Aayog: The National Strategy for
Artificial Intelligence has defined AI as follows: AI refers to the ability of machines to perform
cognitive tasks like thinking, perceiving, learning, problem solving and decision-making.
Initially conceived as a technology that could mimic human intelligence, AI has evolved in ways
that far exceed its original conception. With incredible advances made in data collection,
processing and computation power, intelligent systems can now be deployed to take over a
AI systems work effectively when fed with a large amount of labelled training data. This data is
thoroughly analyzed to discover correlations and patterns. These patterns are then used to make
For example, a chatbot fed with examples of text chats can learn to converse with humans in real-
world applications.
AI programs focus on acquiring data and creating rules for turning that data into actionable
specific task.
information or knowledge.
It enables an intelligent agent or human to make decisions, predict outcomes, and solve problems
logically.
There are two main types of reasoning used in Artificial Intelligence and human cognition:
Inductive Reasoning
Deductive Reasoning
Inductive reasoning is the process of deriving general rules or conclusions from specific
observations or examples.
It moves from specific to general — that is, from data or instances to a broader generalization.
Deductive reasoning is the process of deriving specific conclusions from general statements or
known facts.
AI programs are designed to continually enhance their algorithms to provide the most accurate
results.
Milestones:
Turing Test:
The Turing Test, proposed by the British mathematician and computer scientist Alan Turing in
1950, is a method to determine whether a machine can exhibit human-like intelligence. It is one
of the foundational concepts in Artificial Intelligence, showing how close machines can come to
In this test, a human evaluator communicates (through text only) with both a human and a
If the evaluator cannot reliably distinguish between the human and the machine based on their
responses, then the machine is said to have passed the Turing Test.
The test focuses on how naturally and intelligently a machine can respond, rather than how fast
4. Foundations of AI
Artificial Intelligence (AI) is built on several foundational disciplines that provide methods,
models, and theories for understanding intelligent behavior. The three Foundations of AI are Logic,
Probability
Cognitive Science
Logic is the formal study of reasoning — it helps AI systems make conclusions based on facts and
rules. It provides a mathematical framework to represent knowledge and derive new information
from it.
Foundation of Reasoning
2. Knowledge Representation
Example:
4. Transparency
Example:
Fact: It is raining.
uncertainty in real-world environments. It helps AI systems make rational decisions even when
A self-driving car doesn’t know exactly what another driver will do.
A medical diagnosis system may not be 100% sure of a disease given symptoms.
Therefore, probabilistic reasoning helps AI agents make the best possible decision with the
available information.
1. Real-World Uncertainty
But AI must often act when facts are uncertain → probability is essential.
3. Prediction
4. Risk Handling
Cognitive Science is the study of how humans think, learn, and solve problems. AI borrows ideas
from cognitive science to model human-like intelligence in machines. Cognitive Science combines
ideas from Psychology (human behavior and learning), Neuroscience (brain functioning),
1. Human Inspiration
2. Understanding Intelligence
4. Explaining AI Decisions
AI models inspired by cognitive processes are often more interpretable and relatable to
humans.
5.1.1. Narrow AI
It is also known as Weak AI and is specifically designed to perform a specific type of task. These
systems are already trained with appropriate responses to classify things accordingly. These
systems are great at doing one thing really well, but they don’t work outside their specific task.
Weak AI systems operate within a limited context and are the most successful realization of
artificial intelligence to date. Weak AI has helped make many tasks easier and more efficient, and
it is the most common type of AI in use today. Application of narrow AI has resulted in significant
societal benefits.
Google search, Image recognition software, self-driving cars and IBM’s Watson are some examples
of such systems.
5.1.2. Strong AI
Strong AI, also known as artificial general intelligence or artificial super intelligence (ASI) or
superintelligence, makes full attempt to resemble the human brain. It utilizes cognitive skills and
fuzzy logic to perform tasks for which it had not been trained earlier. Such a system needs
capability for visual perception, speech recognition, decision-making and translations between
languages.
Artificial intelligence systems can also be categorized into four groups based on their functionality
Reactive Machines are the simplest type of AI that react to situations based on immediate input,
Reactive machines are very basic machines with no memory to store and thus use past experiences
to determine future actions. They just perceive the world and react to it. Since it lacks capabilities
to store past experiences, a reactive machine cannot improve with practice. Reactive machines can
perform only a limited number of specialized tasks. Such machines are more trustworthy and
reliable as they react the same way to the same stimuli every time.
Examples: IBM’s Deep Blue (chess-playing computer) is a reactive machine. It makes decisions
based on the current state of the game but doesn’t remember past games.
Limited memory AI systems can remember data for a short time and use it to make decisions, but
they don’t keep data permanently. They cannot keep adding data permanently to a library of their
experiences. limited memory AI is more complex and is used for better possibilities than reactive
machines. These machines continuously train a model to analyze and utilize new data. The model
also improves using feedback received from humans or the environment and stored as data.
There are three major machine learning models that applies limited memory artificial intelligence:
Long Short-term Memory (LSTM): Such models use past data to help predict the next item
in a sequence. More recent information is given a higher priority for prediction than past data.
However, this does not mean that past data is not considered while making predictions.
time to explore new ways of utilizing previous experiences to jump formulate new decisions.
The model is continuously striving to discover a better path. It makes use of simulations and
Examples:
Autonomous vehicles use limited memory to track information like speed of nearby cars,
AlphaGo, the AI that defeated the world champion in the game Go, also used limited memory
The Theory of Mind in AI aims to create machines that can understand thoughts, emotions, and
memories—just like humans. However, such systems are only theoretical as of now but they may
become reality very soon. AI would need to understand feelings and emotions that influence
decisions. These machines would make choices by considering both reason and emotional context.
5.2.4. Self-Awareness.
Once Theory of Mind is established, then the next step would be incorporating self-awareness in
can understand their own existence and feelings. They could interpret user’s feelings by learning
not only what they communicate to them but also how they communicate it.
In Artificial Intelligence (AI), an agent is an entity that perceives its environment through sensors
The combination of what the agent perceives and how it acts defines its behavior.
An agent is anything that perceives its environment through sensors and acts upon it through
actuators (effectors). In simple terms, an agent is an intelligent system that makes decisions based
Architecture: The physical platform on which the agent runs (e.g., robot hardware or
computer system).
Program: The logic or code that implements the agent’s behavior (decision-making process).
PEAS stand for Performance Measure, Environment, Actuators, and Sensors. It is used to describe
Each element defines what the agent needs to achieve and how it interacts with its surroundings.
Simple reflex agents choose actions based only on the current percept.
They are rational only if they make a correct decision based on the current precept.
They work using condition-action rule that maps a state (condition) to an action.
However, the problem with a simple reflex agent is that they succeed only when the
If the environment is partially observable, then the agent may get stuck in infinite loops.
In such a situation, the agent can escape the loop only if it can randomize its actions.
Any change in the environment will eventually end up updating the collection of rules
Model-based reflex agents use a model of the world to choose their actions, which requires
The internal state represents aspects of the current situation that are not directly observable
How the world evolves (what happens over time in the environment).
How the agent’s actions affect the world (the consequences of the agent's actions).
3. Goal-Based Agents
Provides more flexibility than reflex agents as the decision-making knowledge is explicitly
4. Utility-Based Agents
These agents choose actions based on a preference (utility) for each state.
They help prioritize goals by choosing actions that lead to the most preferred outcome.
5. Learning Agent
A learning agent learns from past experiences and adapts over time. It begins with basic
environment.
Critic: Provides feedback to the learning element, evaluating how well the agent is
Performance Element: Selects the external action to be taken based on the current
situation.
Problem Generator: Suggests actions that lead to new experiences for the agent, promoting
further learning.
6.2. Environment
The environment is everything that the agent interacts with. It provides inputs (percepts) to the
Example:
For a robot vacuum cleaner, the environment includes walls, floor area, dirt, furniture, and
charging dock.
For a chess-playing agent, the environment is the chessboard and opponent move.
1. Discrete/Continuous:
2. Known vs Unknown:
3. Observable/Partially Observable:
4. Static/Dynamic:
a. Static: Environment does not change while acting (e.g., crossword puzzle).
Multiple Agents: More than one agent, can be competitive or cooperative (e.g., chess, taxi
driving).
6. Accessible/Inaccessible:
Accessible: Agent has full access to environment information (e.g., empty room).
7. Deterministic/Non-deterministic:
Deterministic: Next state can be determined from current state (e.g., chess).
8. Episodic/Non-episodic:
Non-episodic: Current actions affect future actions (e.g., long-term decision making).
7. Problem formulation
Problem formulation is the process of converting the general problem into a search problem by
defining:
It helps in representing the real-world situation in a way that can be solved computationally by
an AI agent.
Search
Solution / Goal
Algorithm (BFS,
Path
DFS, UCS)
8. Problem definition
A problem in AI can be defined as a situation where an agent needs to perform a sequence of actions
Definition:
A problem is defined by the initial state, possible actions, transition model, goal test, and path
cost. In simple terms, problem definition means clearly specifying what the problem is and what
9. Search Strategies
AI agents use search algorithms to solve tasks and make decisions. For example, single-player
games like Sudoku and tile games use search algorithms to find optimal moves or positions.
State Space: The set of all possible states the agent can reach.
Goal Test: A function that checks if the current state is the goal state.
Solution: A sequence of actions (plan) that transforms the start state to the goal state, achieved
Completeness: A search algorithm is complete if it guarantees at least one solution for a given
input.
Optimality: A search algorithm is optimal if it provides the best solution with the lowest path
cost.
Space Complexity: The amount of memory required for the search process.
A good search algorithm should use less time and less memory.
Uninformed search (or blind search) algorithms have no extra information about the goal state
other than what is provided in the problem definition. The algorithm blindly explores the search
Key Concepts:
Problem Graph: Represents the problem, from the start node (S) to the goal node (G).
Fringe: A data structure that stores all possible states (nodes) that can be reached from the
current state.
Tree: The path representation that the algorithm follows while searching for the goal node.
Solution Plan: The sequence of nodes (states) from start node (S) to goal node (G).
Path/Step Cost: Integer values that represent the cost to move from one node to another.
Depth First Search (DFS) is a graph traversal search algorithm used to explore a tree or graph by
starting from the root node and exploring as far as possible along each branch before backtracking.
1. Start from the root node: Begin searching from the root node (node A).
2. Explore each branch: Move from node A to its child node (B), then to the next child (D), and
continue exploring until you reach the leaf node (the last node of that branch).
3. Backtrack: If the key you're looking for isn't found at the leaf node, backtrack to the last node
4. Repeat the process: Continue exploring each branch by backtracking and then moving to the
next unexplored branch, until the entire tree is searched or the goal is found.
Note:
1. Backtracking is a key feature of DFS, meaning it explores as far as possible along each branch
2. DFS uses a stack (Last-In-First-Out or LIFO structure) to keep track of nodes to visit next.
Less Memory Usage: DFS stores only the nodes along the path from the root node to the
Faster to Reach Goal: It often takes less time to find a goal compared to Breadth First Search
Recurring States: Sometimes, many states repeat. In such cases, there’s no guarantee of
Infinite Loops: DFS may get stuck in an infinite loop when it keeps going deeper. This can
Complexity: The algorithm's complexity depends on the number of paths it needs to explore.
Duplicate Nodes: DFS cannot check for duplicate nodes, potentially leading to inefficiency
in the search.
Since h is a leaf and the key aren’t found, backtrack to node b and explore node e, then node i
(leaf node).
Once all branches of node b are explored, move to node c, then node f, node k, and finally node
g.
Path Found: a → b → d → h → e → i → j → c → f → k → g
OR
o Start at a → go to b
o From b → go to d
o From d → go to h
o From d → go to e
o From e → go to i
o From e → go to j
o From a → go to c
o From c → go to f
o From f → go to k
o From c → go to g
Goal is Achieved
Path Found: a → b → d → h → e → i → j → c → f → k → g
Solution:
Step-by-Step Traversal
o Start at S → go to A
o From A → go to B
o From B → go to C
o From C → go to G
Breadth First Search (BFS) is a graph traversal search algorithm that explores all the nodes at
the present depth level before moving on to the nodes at the next depth level.
It starts from the root node and explores all its neighboring nodes first, then moves on to explore
their children.
1. Start from the root node: Begin searching from the root node.
2. Traverse level by level: First, visit the immediate children of the directly connected to the
root node
3. Move to next level: After visiting all neighbors (children) of current level, the search moves
4. Continue level-wise traversal: The algorithm continues this process, exploring all neighbor
Note:
1. BFS explores nodes level by level, ensuring that the shortest path (in terms of number of edges)
2. BFS uses a Queue (First-In-First-Out or FIFO structure) to keep track of nodes that are yet to
be visited.
3. BFS always visits all nodes at a particular depth before moving deeper.
4. BFS is complete (it will always find a solution if one exists) and optimal for equal edge costs.
5. BFS always finds the shallowest solution (fewest number of nodes in path).
Guaranteed to Find the Shortest Path: If all edges have equal cost, BFS finds the shortest
Completeness: BFS is complete; it will always find the goal node if it exists.
Systematic Exploration: Nodes are explored in increasing order of their depth, ensuring no
node is skipped.
High Memory Usage: BFS stores all nodes at the current level and the next level in the queue,
High Time Complexity: BFS may take a long time for deep or large graphs since it explores
Not Suitable for Infinite or Very Large Graphs: If the search space is infinite or extremely
Consider the graph shown below, where the goal is to find Node G starting from Node A.
Path Found: a → c → g
OR
o From b → visit d, e
o From c → visit f, g
Goal is Achieved
Path Found: a → c → g
Solution:
Step-by-Step Traversal
o Start at S → go to A & D
o From A → go to B
o From D → go to G
Path Found: S → D → G
Uniform Cost Search (UCS) is a search algorithm that expands the least-cost node first. It is
similar to Breadth First Search (BFS), but instead of exploring nodes level by level, UCS explores
nodes based on their path cost (g(n)) — the total cost from the start node to the current node.
UCS guarantees finding the optimal (least-cost) path to the goal if all step costs are positive.
1. Start from the root node: Begin at the starting node with a total path cost of 0.
2. Use a Priority Queue: Store nodes in a priority queue (min-heap) based on their cumulative
cost (g(n)). The node with the lowest path cost is expanded first.
3. Expand the lowest-cost node: Select the node with the smallest cost and expand it by
4. Update Costs: For each successor, calculate the new path cost:
If the successor has not been visited or has a lower cost, update its cost in the queue.
5. Goal Check: If the goal node is selected for expansion, the algorithm stops — this path is
Note:
2. It is complete (if step costs are positive) and optimal (finds the minimum-cost path).
Optimal Solution: UCS always finds the path with the lowest total cost from the start node
to the goal.
Complete Algorithm: It will find a solution if one exists, provided all step costs are greater
than zero.
Handles Varying Costs: UCS performs efficiently in problems where edge costs are not
High Memory Usage: The algorithm may need to store multiple paths in the priority queue,
Slow for Large Graphs: As UCS explores many possible paths, it can be slower than other
Sensitive to Cost Differences: If edge costs vary widely, the algorithm may spend more time
Step-by-Step Traversal:
Path Found:
S→A→B→G
Total Cost: 5