Module 1: Introduction to AI

Describe four categories of Artificial Intelligence.

Categories of Artificial Intelligence

The four categories of Artificial Intelligence, based on how intelligent systems are designed to think or act, can be described as follows:


1. Systems that Think Like Humans

  • These systems try to mimic the human thought process.

  • The focus is on cognitive modeling — understanding how humans think through psychological experiments and cognitive science.

  • Example: AI models that simulate human decision-making, learning, or problem-solving processes.


2. Systems that Act Like Humans

  • These aim to replicate human behavior, passing the Turing Test.

  • They include capabilities like:

    • Natural Language Processing (understanding human language)

    • Knowledge Representation (storing and managing information)

    • Automated Reasoning (using knowledge to make decisions)

    • Machine Learning, Computer Vision, and Robotics (for adaptive learning, visual perception, and movement).


3. Systems that Think Rationally

  • These systems follow the “laws of thought”, attempting to make logically correct decisions.

  • Inspired by formal logic (e.g., Aristotle’s syllogism), they aim to reason deductively.

  • Challenges:

    • Hard to translate vague human knowledge into formal logic.

    • Real-world problems can become computationally intensive.


4. Systems that Act Rationally

  • These systems focus on behaving in ways that maximize goal achievement — the “rational agent” model.

  • Rational behavior is not about copying human thinking but about making the best possible decision given the available information.

  • Advantage: More flexible and scientifically extendable than purely logic-based systems.

Link to original

Module 2: Intelligent Agent

Explain PEAS descriptor. Also state PEAS description for given object. PYQs:

i. Vacuum cleaner robot ii. Automobile Driver agent iii. Part picking robot iv. Medical diagnosis system v. Online English tutor.

PEAS Descriptor in AI

PEAS Descriptor in AI

PEAS stands for Performance measure, Environment, Actuators, Sensors.
It is a framework used to specify the task environment for an intelligent agent. It helps in designing agents by clearly identifying:

  • P (Performance measure) – Criteria used to judge the success of the agent.

  • E (Environment) – The surroundings or context in which the agent operates.

  • A (Actuators) – The tools or means through which the agent acts upon the environment.

  • S (Sensors) – Devices or input channels that the agent uses to perceive its environment.


PEAS Descriptions for Given Agents:

i. Vacuum Cleaner Robot

ComponentDescription
Performance MeasureCleanliness, electricity usage, time taken, area cleaned
EnvironmentRooms, floors, furniture, dirt, obstacles
ActuatorsWheels, suction mechanism, brush, vacuum motor
SensorsDirt sensor, bump sensor, infrared/ultrasonic sensors, camera

ii. Automobile Driver Agent

ComponentDescription
Performance MeasureSafety, speed compliance, fuel efficiency, travel time, comfort
EnvironmentRoads, traffic, pedestrians, road signs, weather conditions
ActuatorsSteering, accelerator, brakes, horn, indicators
SensorsCameras, radar, lidar, GPS, speedometer, proximity sensors

iii. Part Picking Robot (Industrial)

ComponentDescription
Performance MeasureAccuracy of pick, speed, number of parts picked, minimal damage
EnvironmentConveyor belts, parts bin, factory floor, robotic arm station
ActuatorsRobotic arms, grippers, conveyor belts
SensorsVision system (camera), proximity sensors, touch sensors

iv. Medical Diagnosis System

ComponentDescription
Performance MeasureAccuracy of diagnosis, patient recovery rate, time efficiency
EnvironmentPatient data, medical records, symptoms, lab reports
ActuatorsDisplay screen, report generation system, alerts
SensorsInput from keyboard, mouse, electronic health records, patient monitoring devices

v. Online English Tutor

ComponentDescription
Performance MeasureStudent improvement, engagement level, test scores, feedback
EnvironmentOnline platform, students, internet environment
ActuatorsScreen display, voice output, chat window, animations
SensorsKeyboard input, microphone, webcam, student response data
Link to original

Explain Problem formulation, also give the initial state, goal test, successor function, and cost function for the following. Choose the formulation that is precise enough to be implemented.

PYQs: i. Problem Statement: Autonomous Taxi driver ii. Wumpus world problem iii. Problem statement: A 3-foot-tall monkey is in a room where some bananas are suspended from the 8-foot-tall ceiling. He would like to get bananas. The room contains two stackable, movable, climbable 3-foot-high crates. iv. Formulate the 8-puzzle problem.

Problem Formulation in AI

✅ Problem Formulation in AI

Problem formulation is the process of defining a search problem in terms of:

  1. Initial State – The starting point.

  2. Goal Test – The condition that defines a successful outcome.

  3. Successor Function – All possible actions and resulting states.

  4. Cost Function – The cost associated with each step or path.

Below are the formulations for the given problems:


i. 🚕 Autonomous Taxi Driver

  • Initial State: Taxi is at a certain location, passenger(s) at pickup location(s), destination(s) known.

  • Goal Test: All passengers are dropped off at their respective destinations.

  • Successor Function: Move to adjacent location, pick up a passenger, drop off a passenger.

  • Cost Function: Distance travelled (e.g., number of blocks), fuel consumption, or time taken.


ii. 🕳️ Wumpus World Problem

  • Initial State: Agent in the start square (usually [1,1]), with no knowledge of Wumpus/pit locations.

  • Goal Test: Agent has found the gold and returned safely to the start square.

  • Successor Function: Move forward, turn left/right, grab gold, shoot arrow, climb out.

  • Cost Function: Each action has a cost (e.g., -1 per move, -10 for using arrow, +1000 for gold), minimizing danger and maximizing score.


iii. 🐒 Monkey and Bananas Problem

  • Initial State: Monkey at location A, crates at different locations, bananas hanging from the ceiling.

  • Goal Test: Monkey has bananas in hand.

  • Successor Function: Move monkey, move crates, stack crates, climb crate, grab bananas.

  • Cost Function: Number of actions or time steps taken to obtain bananas.


iv. 🔢 8-Puzzle Problem

  • Initial State: Any random configuration of 8 numbered tiles and 1 blank on a 3x3 grid.

  • Goal Test: Tiles arranged in order:

    1 2 3  
    4 5 6  
    7 8 _
    
  • Successor Function: Move the blank tile (up, down, left, right) to swap with adjacent tile.

  • Cost Function: Each move costs 1; total path cost is the number of moves.


These formulations are designed to be precise and implementable for designing intelligent agents or search algorithms.

Link to original

List down all agent types. Explain each with block diagram.

Types of Agents in AI

In Artificial Intelligence, agent types are classified based on how they perceive their environment and make decisions. The five main types of agents are:


✅ Types of Agents in AI

  1. Simple Reflex Agent

  2. Model-Based Reflex Agent

  3. Goal-Based Agent

  4. Utility-Based Agent

  5. Learning Agent


1. 🧠 Simple Reflex Agent

Explanation

  • Acts only on the current percept.

  • Ignores the history of percepts.

  • Uses condition–action rules (“if condition then action”).

  • Suitable only for fully observable environments.

Block Diagram:


2. 🧠 Model-Based Reflex Agent

Explanation

  • Maintains an internal state based on the history of percepts.

  • Uses a model of the world to handle partially observable environments.

Block Diagram:


3. 🎯 Goal-Based Agent

Explanation

  • Chooses actions by considering future consequences and goals.

  • Uses search and planning to achieve the desired goal.

  • More flexible than reflex agents.

Block Diagram:


4. 📈 Utility-Based Agent

Explanation

  • Chooses the best action among multiple alternatives.

  • Uses a utility function to measure happiness/satisfaction.

  • Balances conflicting goals and handles trade-offs.

Block Diagram:


5. 📚 Learning Agent

Explanation

  • Can learn from experience and improve performance over time.

  • Consists of a learning element, a performance element, a critic, and a problem generator.

Block Diagram:


📌 Summary Table

Agent TypeMemoryUses GoalsUtilityLearning
Simple Reflex
Model-Based Reflex
Goal-Based
Utility-Based
Learning Agent
Link to original

Module 3: Problem Solving

Explain hill climbing algorithm and problems that occur in hill climbing algorithm along with solutions.

Hill Climbing Algorithm

Hill Climbing Algorithm

Hill climbing is a heuristic search algorithm used for mathematical optimization problems. It is an iterative algorithm that starts with an arbitrary solution and then makes incremental changes to the solution, selecting the neighbor with the highest (or lowest, in minimization problems) value. The process continues until no further improvement is possible.


How It Works:

  1. Start with a random initial state.

  2. Evaluate the neighbors of the current state.

  3. Move to the neighbor that has the highest value.

  4. Repeat the process until no better neighbor is found (i.e., a peak or plateau is reached).


Types of Hill Climbing:

  1. Simple Hill Climbing – selects the first neighbor that improves the value.

  2. Steepest-Ascent Hill Climbing – evaluates all neighbors and chooses the best.

  3. Stochastic Hill Climbing – selects a random improving neighbor.


Problems in Hill Climbing and Solutions:

ProblemDescriptionSolution
Local MaximumA peak that is higher than nearby states but lower than the global maximum.Random restarts or simulated annealing.
PlateauA flat area where neighboring states have the same value.Use sideways moves (limited number) or random walk.
RidgesA narrow path to the top that cannot be climbed directly by single moves.Modify algorithm to look in multiple directions or use bidirectional search.
ShouldersA gentle slope that leads to higher peaks but may mislead the algorithm.Add momentum or gradient-based enhancement.

Example Illustration:

Suppose you’re climbing a hill in thick fog, taking steps only in the direction that leads you upwards. If you reach a small peak (local maximum), you might think you’ve reached the top, even if there’s a taller mountain nearby (global maximum).


Advantages:

  • Simple to implement.

  • Uses less memory than other search algorithms.

  • Works well for continuous optimization.

Disadvantages:

  • Can get stuck in local maxima, plateaus, or ridges.

  • Not complete (may not find the optimal solution).

  • Performance depends heavily on the shape of the search space.

Link to original

Differentiate between Informed search and Uninformed search algorithms.

Difference between Informed search and Uninformed search algorithms.

FeatureUninformed SearchInformed Search
Also Known AsBlind SearchHeuristic Search
Uses Heuristic?❌ No✅ Yes (h(n) function used)
GuidanceNo knowledge about goal directionUses domain-specific knowledge to guide search
Goal DirectionExplores blindlyGoal-directed exploration
EfficiencyLess efficient, explores more nodesMore efficient with a good heuristic
OptimalityOnly UCS is optimalA* is optimal with admissible heuristic
CompletenessBFS, UCS are completeA*, Greedy Best-First can be complete (depends on h(n))
Time & SpaceHigh due to exhaustive searchLower (if heuristic is good)
ExamplesBFS, DFS, UCS, DLS, IDDFSA*, Greedy Best-First, RBFS, IDA*
Use CaseWhen no domain knowledge is availableWhen domain knowledge or heuristics are available
Link to original

Depth Limited search and Depth first iterative deepening search.

Depth-Limited Search (DLS)

Definition:

Depth-Limited Search is a variant of Depth-First Search (DFS) where the search is limited to a specific depth l (i.e., the number of levels it can go down in the search tree).

Key Features:

FeatureDescription
Limit (l)Maximum depth the algorithm will explore.
CompletenessNo (if the solution is beyond limit).
OptimalityNo
Time ComplexityO(bl)
Space ComplexityO(l)
Used WhenYou know the depth of the solution.

Example Use:

  • Searching a tree up to depth 3, ignoring all nodes beyond it.

Problems:

  • If the goal lies beyond the depth limit, it won’t be found.

Depth-First Iterative Deepening Search (DFID or IDDFS)

Definition:

IDDFS combines the space-efficiency of DFS and the completeness of BFS. It repeatedly performs DLS with increasing depth limits until the goal is found.

How it Works:

  1. Perform DLS with depth = 0

  2. Then depth = 1, then 2, and so on…

  3. Stop when the goal is found.

Key Features:

FeatureDescription
Completeness✅ Yes
Optimality✅ Yes (if step cost is uniform)
Time ComplexityO(bd)
Space ComplexityO(d)
Used WhenDepth is unknown but memory is limited.

Example Use:

  • Solving puzzles (like 8-puzzle), where depth is unknown.

Advantages:

  • Finds shallowest solution first.

  • Uses less memory than BFS.


DLS vs IDDFS – Comparison Table

FeatureDLSIDDFS
Search StrategyDFS with depth limitRepeated DLS with increasing limits
Depth KnowledgeRequiredNot required
CompletenessNo (if goal > limit)✅ Yes
Optimality❌ No✅ Yes (with uniform cost)
Time ComplexityO(bl)O(bd)
Space ComplexityO(l)O(d)
Use CaseWhen depth is knownWhen depth is unknown and memory is limited
Link to original

Explain Simulated annealing with suitable example.

Simulated Annealing

Simulated Annealing (SA)

Simulated Annealing is a probabilistic optimization algorithm inspired by the annealing process in metallurgy, where materials are heated and then slowly cooled to reduce defects and reach a more stable (minimum energy) state.


Core Idea:

Simulated Annealing allows occasional worse moves (i.e., lower-quality solutions) to escape local optima early in the search. The probability of accepting worse solutions decreases over time (as the “temperature” drops).


Algorithm Steps:

  1. Start with an initial solution and high “temperature” T.

  2. Repeat until system cools:

    • Generate a neighboring solution.

    • Calculate the change in cost (ΔE = new - current).

    • If ΔE < 0 (better), accept the move.

    • If ΔE ≥ 0 (worse), accept with probability:

    • Cool down the temperature:

  3. Return the best solution found.


Why It Works:

  • Allows random exploration initially (due to high temperature).

  • Gradually becomes more selective, like hill climbing.

  • Escapes local optima by occasionally accepting bad moves.


Advantages:

  • Escapes local maxima/minima.

  • Good for large, complex search spaces.

  • Easy to implement.

Disadvantages:

  • Requires careful tuning of temperature and cooling rate.

  • Slower than greedy algorithms.

Link to original

Module 4: Knowledge and Reasoning

Explain forward-chaining and backward-chaining algorithm in detail with suitable example.

Forward-chaining and Backward-chaining

1. Forward-Chaining Algorithm

Definition:

Forward-Chaining is a data-driven inference method.
It starts from known facts and applies rules to infer new facts until the goal is reached (or no more inferences can be made).

How it works:

  1. Start with a set of facts (knowledge base).

  2. Apply all rules whose preconditions match the current facts.

  3. Add the rule’s conclusions (new facts) to the knowledge base.

  4. Repeat until:

    • The goal is inferred, or

    • No more rules can be applied.

Example:

Facts:

  • Sun is shining → Sunny

  • Sunny → Go outside

  • Go outside → Happy

Initial Fact:

  • Sun is shining

Goal:

  • Happy

Inference:

  1. Sun is shining → infer Sunny

  2. Sunny → infer Go outside

  3. Go outside → infer Happy

Goal is reached.

Advantages:

  • Suitable when all data is known upfront.

  • Works well in real-time systems, such as expert systems and diagnostics.


2. Backward-Chaining Algorithm

Definition:

Backward-Chaining is a goal-driven inference method.
It starts with the goal and works backward to determine what facts must be true to satisfy that goal.

How it works:

  1. Start with a goal.

  2. Look for rules that can produce that goal in the conclusion.

  3. Make the preconditions of that rule the new subgoals.

  4. Repeat the process until you reach known facts or fail.

Example:

Rules:

  • Sunny → Go outside

  • Go outside → Happy

  • Sun is shining → Sunny

Goal:

  • Happy

Inference:

  1. To prove Happy, need Go outside

  2. To prove Go outside, need Sunny

  3. To prove Sunny, need Sun is shining

If Sun is shining is known, then the goal Happy is provable.

Advantages:

  • Efficient when the goal is known, and you want to verify if it can be satisfied.

  • Used in logic programming (e.g., Prolog), theorem proving, and question answering systems.


Forward vs Backward Chaining

FeatureForward-ChainingBackward-Chaining
ApproachData-drivenGoal-driven
Starts fromKnown factsDesired conclusion
Stops whenGoal is derivedFacts supporting goal are found
Use CaseExpert systems, diagnosisLogic programming, proof systems
DirectionBottom-up inferenceTop-down reasoning

Summary

  • Forward-Chaining: Pushes known facts forward to derive conclusions.

  • Backward-Chaining: Pulls from the goal backward to verify if facts can support it.

Both are fundamental to AI reasoning, rule-based systems, and knowledge inference.

Link to original

Write a detailed note on Wumpus world environment.

Wumpus world

The Wumpus World in AI is a classic problem demonstrating various ideas such as search algorithms, planning, and decision-making. The wumpus world in AI is a straightforward environment in which an agent (a computer program or a robot) must traverse a grid world filled with obstacles, hazards, and dangerous wumpus. Wumpus is a fictional character that kills the player in the game. The agent must travel the globe for a safe route to the treasure without falling into pits or being killed by the wumpus.

Properties of the Wumpus World

  • Partially observable: The Wumpus world in AI is partially observable because the agent can only sense the immediate surroundings, such as an adjacent room.
  • Deterministic: It is deterministic because the result and end of the world are already known.
  • Sequential: It is sequential because the order is essential.
  • Static: It is motionless because Wumpus and Pits are not moving.
  • Discrete: The surroundings are distinct.
  • One agent: The environment is a single agent because we only have one agent, and Wumpus is not regarded as an agent.

PEAS Description of Wumpus World

To build an intelligent agent for the Wumpus World, we must first define the problem’s Performance, Environment, Actuators, and Sensors (PEAS).

  1. Performance:
    • +1000 bonus points if the agent returns from the tunnel with the gold.
    • Being eaten by the wumpus or plummeting into the pit results in a -1000 point penalty.
    • Each move is worth -1, and using an arrow is worth -10.
    • The game is over if either agent dies or exits the tunnel.
  2. Environment:
    • A four-by-four grid of chambers.
    • The operative begins in room square [1, 1], facing the right.
    • Wumpus and gold locations are selected randomly except for the first square [1,1].
    • Except for the first square, each square in the tunnel has a 0.2 chance of being a pit.
  3. Actuators: They are the actions that the agent can take to interact with the world. The worker in Wumpus World in AI can carry out the following tasks:
    • Left turn
    • Right turn
    • Move forward
    • Grab
    • Release
    • Shoot
  4. Sensors: They are how the agent senses its surroundings. The agent’s instruments in the Wumpus World provide the following information:
    • If the agent is in the chamber next to the wumpus, he will notice the stench. (Not diagonally).
    • If the agent is in the room immediately adjacent to the pit, he will notice a breeze.
    • The agent will notice the glitter in the chamber with the gold.
    • The agent will notice the bump if he runs into a wall.
    • When the Wumpus is shot, it lets out a horrifying scream that can be heard throughout the tunnel.
    • These perceptions can be represented as a five-element list with distinct indicators for each sensor.
    • For example, if an agent detects stench and breeze but not glitter, bump, or scream, it can be depicted as [Stench, Breeze, None, None].

Applications of Wumpus World in AI

The Wumpus World in AI is a classic problem with multiple uses, including:

  • Developing intelligent agents: The Wumpus World in AI is an excellent platform for creating intelligent agents capable of navigating complicated environments, reasoning in uncertainty, and planning actions.
  • Testing AI algorithms: Wumpus World is a benchmark issue for testing and comparing various AI algorithms, such as search, planning, and reinforcement learning.
  • Education and training: Because it is simple to use and offers hands-on experience, the Wumpus World in AI is a popular tool for teaching AI concepts and algorithms to students.
  • Game Development: Wumpus World can motivate developers to create challenging and engaging games requiring strategic thinking and problem-solving.
  • Robotics: The Wumpus World can be used as a testing and development setting for robotics algorithms such as pathfinding and mapping.
Link to original

Solve given problem using Resolution

Module 5: Planning and Learning

What is planning in AI? Explain Partial-order planning with suitable example.

Planning in AI

Planning in Artificial Intelligence (AI) is the process of automatically generating a sequence of actions or steps that an intelligent agent needs to perform to achieve a specific goal from a given initial state.

  • It involves reasoning about the world, the effects of possible actions, and the desired outcomes.

  • The goal of planning is to find a plan — a set of actions arranged in a particular order — that leads from the current state to the goal state.

  • Planning is fundamental in AI applications such as robotics, autonomous systems, game playing, logistics, and decision-making.

Key Elements of Planning:

  • Initial State: The starting situation or condition.

  • Goal State: The desired condition or outcome.

  • Actions: Operations that change the state of the world.

  • Plan: A sequence (or partial order) of actions transforming the initial state to the goal.

Link to original

Partial Order Planning

Partial-Order Planning (POP) is a type of planning where the order of actions is only partially specified. This means that the planner allows some actions to remain unordered if there is no reason to enforce a specific order, offering flexibility and efficiency in planning.

Key Concepts:

  1. Actions: Basic steps with preconditions and effects.

  2. Ordering Constraints: Define which action must occur before another (e.g., A < B).

  3. Causal Links: Indicate that one action provides a condition required by another.

  4. Open Preconditions: Preconditions of actions that still need to be satisfied.

  5. Dummy Actions:

    • Start: Represents the initial state.

    • Finish: Represents the goal state.

Example of POP:

Goal: Wear both shoes.

  • Goal: RightShoeOn ∧ LeftShoeOn

Actions:

  • Action(RightSock, Effect: RightSockOn

  • Action(RightShoe, Precondition: RightSockOn, Effect: RightShoeOn)

  • Action(LeftSock, Effect: LeftSockOn)

  • Action(LeftShoe) → Precondition: LeftSockOnEffect: LeftShoeOn)

Plan Setup:

  • Initial Actions: {Start, Finish}

  • Initial Open Preconditions: {RightShoeOn, LeftShoeOn}

  • The planner must find a consistent way to fulfill these using available actions while adding ordering constraints and causal links as needed.

A possible linearization (totally ordered plan):

  1. Start

  2. RightSock

  3. RightShoe

  4. LeftSock

  5. LeftShoe

  6. Finish

But in partial-order, the socks can be worn in any order as long as each is worn before its respective shoe. This reduces constraints and increases flexibility.

A consistent POP plan:

  • No cycles in ordering

  • No conflicts in causal links

  • All preconditions are satisfied

Link to original

Design a planning problem using STRIP for Air cargo transport. It involves loading and unloading cargo onto and of planes and flying it from place. Initial state: At SFO airport, Cargo1, Plane1 and at JFK airport, Cargo2, Plane2 is present. Goal state: At SFO airport Cargo2 and at JFK airport Cargo1 is present.

Example 1

Design a planning problem using STRIP for Air cargo transport. It involves loading and unloading cargo onto and of planes and flying it from place. Initial state: At SFO airport, Cargo1, Plane1 and at JFK airport, Cargo2, Plane2 is present. Goal state: At SFO airport Cargo2 and at JFK airport Cargo1 is present.

1. Define Predicates

These describe the facts of the world:

  • At(x, y) – Object x is at location y

  • In(c, p) – Cargo c is inside Plane p

  • Cargo(x)x is a cargo

  • Plane(x)x is a plane

  • Airport(x)x is an airport


2. Initial State

At(Cargo1, SFO)
At(Plane1, SFO)
At(Cargo2, JFK)
At(Plane2, JFK)
Cargo(Cargo1)
Cargo(Cargo2)
Plane(Plane1)
Plane(Plane2)
Airport(SFO)
Airport(JFK)

3. Goal State

At(Cargo1, JFK)
At(Cargo2, SFO)

4. Actions

(a) Load(c, p, a)

Preconditions:
  At(c, a) ∧ At(p, a) ∧ Cargo(c) ∧ Plane(p) ∧ Airport(a)
 
Effects:
  In(c, p) ∧ ¬At(c, a)

(b) Unload(c, p, a)

Preconditions:
  In(c, p) ∧ At(p, a) ∧ Cargo(c) ∧ Plane(p) ∧ Airport(a)
 
Effects:
  At(c, a) ∧ ¬In(c, p)

(c) Fly(p, from, to)

Preconditions:
  At(p, from) ∧ Plane(p) ∧ Airport(from) ∧ Airport(to)
 
Effects:
  At(p, to) ∧ ¬At(p, from)

5. Plan Overview (One Possible Sequence)

To achieve the goal state:

  1. Load(Cargo1, Plane1, SFO)

  2. Fly(Plane1, SFO, JFK)

  3. Unload(Cargo1, Plane1, JFK)

  4. Load(Cargo2, Plane2, JFK)

  5. Fly(Plane2, JFK, SFO)

  6. Unload(Cargo2, Plane2, SFO)

Link to original

Consider problem of changing a flat tire. The goal is to have a good spare tire properly mounted on to the car’s axle, where the initial state has a flat tire on the axle and a good spare tire in the trunk. Give the ADL description for the problem and also discuss the solution.

Example 2

Consider problem of changing a flat tire. The goal is to have a good spare tire properly mounted on to the car’s axle, where the initial state has a flat tire on the axle and a good spare tire in the trunk. Give the ADL description for the problem and also discuss the solution.

Problem: Changing a Flat Tire

Initial State

  • On(FlatTire, Axle) – Flat tire is mounted on the axle

  • In(SpareTire, Trunk) – Spare tire is inside the trunk

  • Tire(FlatTire), Tire(SpareTire)

  • Spare(SpareTire)

  • WrenchAvailable, JackAvailable, Loose(FlatTire) is False initially

  • Removed(FlatTire) is False initially

  • Mounted(SpareTire) is False initially


Goal State

  • Mounted(SpareTire)

  • ¬On(FlatTire, Axle)

  • ¬In(SpareTire, Trunk)


ADL Description

1. Remove(FlatTire, Axle)

Preconditions:
  On(FlatTire, Axle) ∧ Loose(FlatTire)
 
Effects:
  ¬On(FlatTire, Axle)
  ∧ Removed(FlatTire)

2. Loosen(FlatTire)

Preconditions:
  On(FlatTire, Axle) ∧ WrenchAvailable
 
Effects:
  Loose(FlatTire)

3. GetSpare(SpareTire)

Preconditions:
  In(SpareTire, Trunk)
 
Effects:
  ¬In(SpareTire, Trunk)

4. Mount(SpareTire, Axle)

Preconditions:
  Removed(FlatTire) ∧ ¬On(FlatTire, Axle) ∧ ¬In(SpareTire, Trunk)
 
Effects:
  On(SpareTire, Axle)
  ∧ Mounted(SpareTire)

Solution Steps (Valid Plan)

  1. Loosen(FlatTire) – Loosen the flat tire bolts

  2. Remove(FlatTire, Axle) – Take off the flat tire

  3. GetSpare(SpareTire) – Take the spare tire out of the trunk

  4. Mount(SpareTire, Axle) – Mount the spare tire on the axle

Link to original

Explain the concept of PAC learning.

PAC Learning

Link to original

Explain Reinforcement learning in detail.

Reinforcement Learning

1. What is Reinforcement Learning?

Reinforcement Learning (RL) is a type of machine learning where an agent learns to make decisions by interacting with an environment to maximize cumulative reward.

In RL, an agent:

  • Perceives the environment’s state

  • Takes actions

  • Receives feedback (reward or penalty)

  • Learns a policy that maximizes long-term reward

It’s trial-and-error learning, where the agent explores and improves over time.


2. Key Components of RL

ComponentDescription
AgentLearner or decision maker
EnvironmentExternal system the agent interacts with
State (S)Current situation of the environment
Action (A)Choices the agent can make
Reward (R)Feedback signal (positive or negative)
Policy (π)Strategy mapping states to actions
Value Function (V)Expected long-term reward from a state
Q-Function (Q)Expected reward of taking action a in state s

3. The RL Cycle

  1. Agent observes the state

  2. It selects an action based on its policy

  3. The environment returns a new state and a reward

  4. Agent updates its policy based on experience


4. Types of Reinforcement Learning

(a) Model-Free RL

  • Learns directly from experience

  • No knowledge of environment dynamics

Examples:

  • Q-Learning

  • SARSA

(b) Model-Based RL

  • Learns a model of the environment (transition and reward functions)

  • Uses the model to plan


Q-Learning (Off-policy)

  • Learns Q-values:

  • Doesn’t follow the same policy it updates

SARSA (On-policy)

  • Learns Q-values while following current policy

Deep Q-Networks (DQN)

  • Combines Q-learning with neural networks

  • Handles high-dimensional state spaces (like games)


6. Exploration vs Exploitation

  • Exploration: Try new actions to discover better rewards

  • Exploitation: Use known actions that give high reward

A balance is needed (e.g., using ε-greedy policy).


7. Reward Signal

The reward is crucial in shaping agent behavior:

  • Immediate reward teaches short-term behavior

  • Discounted future rewards (via discount factor γ) encourage long-term planning


8. Applications of RL

  • Game Playing: AlphaGo, Dota bots

  • Robotics: Learning to walk, grip objects

  • Recommendation Systems

  • Autonomous Vehicles

  • Industrial Control Systems


9. Challenges in RL

  • Delayed rewards: Action effects seen after many steps

  • Exploration complexity: Large action/state spaces

  • Sample inefficiency: Requires lots of interaction data

  • Stability and convergence in training (especially deep RL)


Summary

FeatureReinforcement Learning
Learning StyleTrial-and-error
Feedback TypeScalar reward signal
GoalMaximize total reward
Best ForSequential decision-making
Core IdeaLearn from interaction with environment

Reinforcement learning is like teaching a dog tricks by giving it treats—it improves by trying, failing, and adjusting its behavior to get more rewards over time.

Link to original

Explain hierarchical planning in detail.

Hierarchical Planning

1. What is Hierarchical Planning?

In traditional planning (like STRIPS), a planner works directly with primitive actions.
In hierarchical planning, we start with high-level abstract tasks and decompose them step-by-step into simpler tasks.


2. Key Concepts

TermMeaning
TaskAny activity that needs to be accomplished
Primitive TaskA task that can be executed directly (like move(robot, A, B))
Compound TaskA higher-level task that needs to be broken into subtasks (like buildHouse)
Task NetworkA set of tasks with temporal or ordering constraints
DecompositionProcess of refining a compound task into subtasks
MethodsRules that specify how to decompose compound tasks

3. How It Works

  1. Start with a high-level goal

  2. Select a method to decompose that goal

  3. Decompose compound tasks into smaller subtasks (recursively)

  4. Repeat until only primitive tasks remain

  5. Execute the primitive actions in a valid order


4. Example: Building a House 🏠

High-Level Task:

BuildHouse

Method:

BuildHouse → [GetPermit, HireContractor, Construct, PayContractor]

Further Decomposition:

Construct → [LayFoundation, BuildWalls, InstallRoof]

Eventually:

InstallRoof → [OrderMaterials, HireRoofers, SuperviseInstallation]

These leaf-level tasks will eventually map to executable actions like:

Order(Materials, SupplierX), Pay(Contractor, Amount)

5. Benefits of Hierarchical Planning

Scalability: Reduces complexity by breaking large problems into manageable parts
Reusability: Methods can be reused for similar tasks
Abstraction: Focus on high-level strategy rather than low-level mechanics
Human-Like Reasoning: Mimics how humans naturally plan complex tasks


6. Applications

  • Robotics: e.g., plan to clean a house → clean rooms → sweep floor, etc.

  • Game AI: NPC behaviors like “attack base” → move to location → fire weapon

  • Logistics: Transporting goods → load → travel → unload

  • Workflow Management: Business processes → customer onboarding → send welcome email, etc.


7. Challenges

Choosing the Right Decomposition: Multiple methods may apply; selecting the optimal one is non-trivial
Execution Monitoring: Real-world tasks may fail; planner must adapt
Complex Constraints: Handling preconditions and interactions between subtasks is difficult


Summary Table

FeatureHierarchical Planning
Task TypeCompound and primitive
Core MechanismTask decomposition
Knowledge UsedDomain-specific methods
Planning GranularityHigh-level to low-level
AnalogyProject breakdown into subtasks
StrengthEfficient for complex domains

Hierarchical Planning offers a structured and efficient approach for solving real-world planning problems by “thinking big, and refining down.” It blends symbolic planning with abstraction and is key to many modern AI systems.

Link to original

Module 6: AI Applications

Explain different applications of AI in Robotics, Healthcare, Retail and Banking.

Applications of AI

1. AI in Robotics

AI enhances the capabilities of robots by allowing them to make decisions, adapt to environments, and perform complex tasks autonomously.

Applications:

  • Industrial Automation: Robots in manufacturing perform tasks like welding, assembling, and packaging with high precision and speed (e.g., automotive industry robots, industrial floor scrubbers).

  • Order Fulfillment: AI-powered robots in warehouses use path-finding algorithms to navigate and pick orders (e.g., Amazon warehouse robots).

  • Autonomous Vehicles: Drones and self-driving cars use AI to detect and avoid hazards, navigate autonomously, and make real-time decisions.

  • Human-like Robots: Robots are equipped with computer vision, NLP, and reinforcement learning to mimic human interactions (e.g., service robots).


2. AI in Healthcare

AI in healthcare improves diagnostics, treatment, and operational efficiency, contributing to better patient outcomes.

Applications:

  • Medical Imaging: AI analyzes X-rays, MRIs, and CT scans to detect diseases like tumors or fractures with high accuracy.

  • Disease Prediction & Prevention: By analyzing patient history and data, AI can detect early signs of diseases such as diabetes and heart problems.

  • Brain-Computer Interface (BCI): Helps patients with spinal cord injuries communicate by decoding neural signals.

  • Personalized Treatment Plans: AI recommends treatments based on a patient’s genetic makeup and medical history.

  • Hospital Management: AI predicts patient inflow, optimizes staff allocation, and manages resources effectively.


3. AI in Retail

AI transforms retail by enhancing customer experiences, streamlining operations, and increasing sales.

Applications:

  • Customer Behavior Analysis: AI analyzes shopping patterns to suggest personalized products and promotions.

  • Chatbots & Virtual Assistants: Used for 24/7 customer service, answering queries, and guiding users through purchases.

  • Inventory Management: Predicts demand and helps in efficient stock management.

  • In-store Automation: AI powers smart shelves, cashier-less checkouts, and real-time customer service kiosks.

  • Visual Search & Recommendation Engines: Helps users find products using images and recommends products based on browsing and buying history.


4. AI in Banking

AI in banking ensures security, improves customer service, and supports financial decision-making.

Applications:

  • Fraud Detection: AI detects unusual transaction patterns to prevent fraud in real time.

  • Credit Scoring: Assesses a customer’s creditworthiness using a variety of data, including behavioral analytics.

  • Automated Trading: Uses algorithms to analyze market trends and execute trades efficiently.

  • Customer Service: Virtual assistants answer FAQs and help customers manage accounts.

  • Risk Assessment: Evaluates risks in investments and loan disbursals by analyzing financial data and trends.

Link to original

Write detailed note on: Language models of Natural Language Processing.

Language Models in Natural Language Processing (NLP)

Introduction

A language model is a fundamental component in Natural Language Processing (NLP) that enables machines to understand, generate, and work with human language. It assigns probabilities to sequences of words, allowing it to predict the likelihood of a word or sequence occurring in a given context. Language models serve as the backbone for many NLP applications such as machine translation, text generation, speech recognition, sentiment analysis, and more.


What is a Language Model?

A language model estimates the probability distribution of a sequence of words . Formally, it calculates:

This can be broken down using the chain rule of probability:

This means the probability of the entire sequence is the product of the probability of each word given the preceding words.


Types of Language Models

1. Statistical Language Models

Statistical models were the traditional approach before deep learning gained popularity.

  • N-gram Models:

    • The most basic form.

    • Use fixed-length context (n-1 words) to predict the next word.

    • For example, a bigram model predicts .

    • Advantages: Simple and interpretable.

    • Limitations: Cannot capture long-range dependencies; suffers from data sparsity.

    • Techniques like smoothing (e.g., Laplace smoothing) are used to handle unseen word combinations.

  • Hidden Markov Models (HMMs):

    • Model sequences with hidden states representing grammatical or semantic tags.

    • Useful for tasks like part-of-speech tagging but less for pure language modeling.


2. Neural Language Models

With advances in deep learning, neural network-based language models have become dominant.

  • Feedforward Neural Networks:

    • Early neural models that predict the next word based on a fixed-size window of previous words.

    • Better at capturing distributed word representations (embeddings) than n-grams.

  • Recurrent Neural Networks (RNNs):

    • Designed to handle sequences of arbitrary length by maintaining a hidden state.

    • Can theoretically capture long-term dependencies.

    • However, they suffer from vanishing gradient problems when modeling long contexts.

  • Long Short-Term Memory (LSTM) and Gated Recurrent Units (GRUs):

    • Specialized RNN variants designed to better capture long-range dependencies by controlling information flow.

    • Widely used before transformers.


3. Transformer-Based Language Models

Transformers revolutionized NLP by introducing self-attention mechanisms that efficiently model long-range dependencies without recurrence.

  • Self-Attention:

    • Allows the model to weigh the importance of different words in the sequence for predicting the next word.
  • Examples of Transformer Language Models:

    • BERT (Bidirectional Encoder Representations from Transformers):

      • Focuses on understanding context by looking at words both before and after a target word.

      • Mainly used for understanding tasks rather than generation.

    • GPT (Generative Pre-trained Transformer):

      • Unidirectional model trained to predict the next word in a sequence.

      • Used extensively for text generation, conversation, summarization, etc.

    • T5, XLNet, RoBERTa, etc.:

      • Various architectures focusing on different tasks and improvements.

Training of Language Models

  • Language models are typically trained on large corpora of text data.

  • Objective is to maximize the likelihood of the training data, i.e., the model learns to assign high probabilities to actual word sequences.

  • Pretraining on vast general datasets is often followed by fine-tuning on specific tasks or domains.


Applications of Language Models

  • Text Generation: Generating coherent and contextually relevant text, e.g., chatbots, story generation.

  • Machine Translation: Translating text between languages.

  • Speech Recognition: Converting spoken language to text.

  • Sentiment Analysis: Understanding sentiment or opinion from text.

  • Text Summarization: Condensing large text into summaries.

  • Question Answering: Extracting answers from documents.

  • Spell Checking and Auto-completion: Predicting next words or correcting text input.


Challenges and Limitations

  • Context Understanding: Capturing long-range dependencies and subtle semantics can be difficult.

  • Bias and Fairness: Language models may learn and propagate biases present in training data.

  • Computational Resources: Large models require significant compute for training and inference.

  • Interpretability: Neural language models are often black boxes, making it hard to explain predictions.


Future Directions

  • Multimodal Models: Combining language with images, audio, and video.

  • More Efficient Models: Techniques like pruning, quantization, and distillation to reduce size and latency.

  • Better Understanding of Semantics and Pragmatics: Improving models’ ability to understand nuances, sarcasm, and context.

  • Ethical AI: Developing language models that are unbiased, fair, and respect privacy.


Summary

Language models are the core of NLP, enabling machines to process and generate human language by modeling the probability of word sequences. From simple statistical n-grams to advanced deep learning transformers, language models have evolved significantly, driving progress in many applications and continuing to shape the future of human-computer interaction.

Link to original

Give types of parsing and generate the parse tree for the sentence “The cat ate the fish.”

Types of Parsing in NLP

Parsing is the process of analyzing the grammatical structure of a sentence. It helps identify the syntactic relationships between words and phrases.

1. Top-Down Parsing

  • Starts from the highest-level rule (the start symbol, usually S for sentence) and tries to rewrite it to match the input sentence.

  • Works by expanding the grammar rules to generate the sentence.

  • Example techniques: Recursive descent parsing.

  • Pros: Intuitive and easy to implement.

  • Cons: Can be inefficient due to backtracking, and may not handle left-recursive grammars well.

2. Bottom-Up Parsing

  • Starts from the input words and tries to combine them into higher-level constructs until it reaches the start symbol.

  • Works by reducing the sentence to the start symbol using grammar rules.

  • Example techniques: Shift-reduce parsing, LR parsing.

  • Pros: Can handle a larger class of grammars efficiently.

  • Cons: More complex to implement than top-down parsing.

3. Chart Parsing

  • Uses dynamic programming to store intermediate parsing results to avoid redundant computations.

  • Combines features of both top-down and bottom-up parsing.

  • Useful for ambiguous or complex grammars.

4. Dependency Parsing

  • Focuses on relationships between “head” words and their dependents, rather than phrase structure.

  • Useful for understanding syntactic relations like subject, object, modifiers.

5. Constituency Parsing (Phrase Structure Parsing)

  • Breaks sentence into sub-phrases or constituents (like noun phrases, verb phrases).

  • Often represented as a parse tree.

  • The type of parsing needed for the parse tree example below.


Parse Tree for the Sentence:

“The cat ate the fish.”


Step 1: Identify parts of speech (POS) for each word:

  • The — Determiner (Det)

  • cat — Noun (N)

  • ate — Verb (V)

  • the — Determiner (Det)

  • fish — Noun (N)


Step 2: Phrase structure (simple example):

  • Sentence (S)

    • Noun Phrase (NP)

      • Det: The

      • Noun: cat

    • Verb Phrase (VP)

      • Verb: ate

      • Noun Phrase (NP)

        • Det: the

        • Noun: fish


Step 3: Visual parse tree (constituency):

            S
           / \
         NP   VP
        / \   /  \
      Det  N  V   NP
      |    |  |   /  \
     The  cat ate Det  N
                      |   |
                     the fish

Explanation:

  • The sentence (S) splits into a subject noun phrase (NP) and a predicate verb phrase (VP).

  • The subject NP is “The cat”.

  • The VP contains the verb “ate” and the object NP “the fish”.

  • Each NP breaks down into a determiner (Det) and a noun (N).

Link to original