AI Course Notes
Below is a more in‐depth, “from scratch” explanation of the topics. These notes expand on
every section with additional details, examples, and reasoning behind each concept.
1. Introduction to Artificial Intelligence
(AI)
What is AI?
Artificial Intelligence is a branch of computer science dedicated to building systems that can
perform tasks normally requiring human intelligence. These tasks include reasoning,
learning, problem-solving, perception, and language understanding. Instead of simply
following preprogrammed rules, an AI system is designed to adapt its behavior based on its
experiences.
Perspectives on Defining AI
AI is understood from four different perspectives, and each emphasizes a different aspect of
intelligence:
1. Acting Humanly (Turing Test Approach):
Concept:
The idea here is to create machines that behave like humans. Alan Turing proposed
that if a machine could converse with a human without the human realizing it was a
machine, then the machine could be considered intelligent.
What It Involves:
Natural Language Processing (NLP): The machine must be able to understand
and generate human language.
Knowledge Representation: It needs a way to store, recall, and use knowledge
to answer questions.
Automated Reasoning: The system should draw conclusions and answer
questions logically.
1/19
Machine Learning: To adapt to new situations and improve performance over
time.
Example:
Chatbots that can hold a conversation or virtual assistants like Siri or Alexa use these
ideas to simulate human-like interaction.
2. Thinking Humanly (Cognitive Modeling Approach):
Concept:
This approach focuses on creating computer models that mimic the way humans
think. To design such models, researchers study how people process information—
using introspection, psychological experiments, and brain imaging.
What It Involves:
Cognitive Psychology: Understanding how humans solve problems, learn, and
remember.
Cognitive Science: Interdisciplinary research combining psychology,
neuroscience, and computer science to model human thinking.
Example:
The General Problem Solver (GPS), an early AI program, attempted to simulate the
human problem-solving process by following the same steps a human might take
when thinking through a puzzle.
3. Thinking Rationally (Laws of Thought Approach):
Concept:
In this view, intelligence is measured by the ability to reason logically. Early
philosophers like Aristotle developed systems of logic (e.g., syllogisms) that show
how conclusions can be drawn from premises.
What It Involves:
Formal Logic: Representing knowledge using symbols and rules to derive
conclusions.
Inference: Applying logical rules to known facts to generate new information.
Challenges:
Formalizing human thought is difficult because real-life knowledge is often
uncertain and ambiguous, and simple logical systems can become computationally
expensive.
2/19
4. Acting Rationally (Rational Agent Approach):
Concept:
Instead of trying to mimic human behavior exactly or mimic human thought
processes, this approach focuses on designing agents that make the best decisions
based on the information available.
What It Involves:
Rational Decision-Making: The agent chooses actions that maximize its
expected performance or “utility” based on a defined performance measure.
Adaptability: It must take into account the uncertainty of real-world
environments.
Example:
An autonomous car that continuously evaluates road conditions, other vehicles, and
traffic laws to choose the safest and most efficient route is acting as a rational
agent.
2. Historical and Disciplinary
Foundations of AI
AI did not emerge in isolation—it evolved from many disciplines. Understanding these roots
helps explain both the capabilities and limitations of AI today.
Philosophy
Formal Reasoning and Logic:
Aristotle’s Syllogisms: Early methods of deductive reasoning that form the basis for
modern logical systems.
Development of Formal Logic: In the 19th century, mathematicians developed
formal systems to represent logical arguments; these systems later influenced AI
research.
Mind-Body and Epistemological Debates:
3/19
Dualism vs. Materialism: Philosophers like Descartes debated whether the mind
was separate from the body or a product of physical processes—this debate informs
how AI researchers model thinking and consciousness.
Inductive vs. Deductive Reasoning:
Empiricism (Locke, Hume): Suggests knowledge is primarily derived from
experience, leading to data-driven AI methods like machine learning.
Rationalism (Descartes, Leibniz): Emphasizes reasoning, influencing rule-based AI
systems.
Economics
Utility Theory and Decision Making:
Adam Smith and Beyond: Economics models view agents as individuals maximizing
their utility.
Decision Theory: Combines probability with utility to help design systems that can
choose the best course of action under uncertainty.
Game Theory:
Studies strategic interactions where the outcome for each participant depends on
the actions of others. This is central to multi-agent systems and competitive AI
scenarios.
Neuroscience
Mapping the Brain:
Early Discoveries: Broca’s area (speech production), Golgi’s neuron staining, and
Cajal’s mapping of neural structures provided the basis for understanding how
biological intelligence works.
Neuroplasticity: The brain’s ability to change and adapt, inspiring machine learning
algorithms that adjust based on new data.
Differences Between Brains and Computers:
Brains operate with massive parallelism and interconnected networks, while
computers have high speed but typically process sequentially. Understanding these
differences drives research into parallel computing and neural networks.
Psychology
4/19
Behaviorism and Cognitive Psychology:
Behaviorism (Watson): Focused solely on observable behavior, influencing early AI
that relied on stimulus-response rules.
Cognitive Psychology (James, Craik): Sees the brain as an information-processing
device, leading to models that simulate human memory, attention, and problem-
solving.
Cognitive Science:
Combines insights from psychology, neuroscience, linguistics, and computer science
to create models that both explain human thought and inspire intelligent
algorithms.
Computer Engineering
Evolution of Computers:
Early Machines: Devices like the Heath Robinson, Colossus, and ENIAC laid the
groundwork for modern computing.
Impact on AI: The rapid increase in computing power, storage, and speed has
enabled more complex AI models and algorithms.
Programming Paradigms:
Innovations in software design (object-oriented, functional programming) have also
been influenced by the needs of AI research.
Control Theory and Cybernetics
Self-Regulating Systems:
Early Mechanisms: Devices such as water clocks and steam engine governors are
examples of early feedback control systems.
Cybernetics (Wiener): Introduced the concept of feedback loops and error
minimization, which are crucial in designing systems that can adapt and regulate
their behavior.
Difference from AI:
While control theory focuses on continuous systems using mathematical tools like
calculus, AI often deals with discrete symbols and logical inference.
Linguistics
5/19
Language and Learning:
Behaviorist Approach (Skinner): Early theories considered language as a series of
learned responses.
Chomsky’s Critique: Demonstrated that language involves inherent creativity and
structure that cannot be explained solely by behaviorism.
Impact on AI:
Chomsky’s work led to computational linguistics, where formal grammar rules are
used to process and understand human language, laying the foundation for NLP
systems.
3. Agents and Environments
Understanding Agents
An agent in AI is any entity that perceives its environment through sensors and acts upon
that environment using actuators. The concept of an agent is central because it provides a
way to abstract and model intelligent behavior.
Types of Agents
Human Agents:
Use natural sensory organs (eyes, ears) and limbs to interact.
Robotic Agents:
Equipped with cameras, microphones, and motors, they can perform tasks in the
physical world (e.g., assembly line robots).
Software Agents:
Operate in digital environments (e.g., web crawlers, virtual assistants) using inputs
like keystrokes or network data.
Percepts and Agent Functions
Percept:
The raw input data that the agent receives at any moment—for example, a camera
6/19
image or a sensor reading.
Percept Sequence:
The history of all percepts that the agent has received over time. This history can be
used to build context or update an internal model.
Agent Function:
An abstract mapping that takes the percept sequence as input and returns an action.
Think of it as a “lookup table” that tells the agent what to do in every possible situation.
Agent Program:
The actual software (or hardware) implementation of the agent function. It must run on
the agent’s architecture (e.g., a computer or robot).
Rationality and Evaluating Agents
Rational Agent:
An agent that makes decisions to maximize its performance based on a predefined
performance measure. It chooses the best action according to what it has learned and
perceived.
Performance Measure:
A function or set of criteria that evaluates how well the agent is doing. For example, for a
vacuum-cleaner agent, performance might be measured by the amount of clean floor
over time.
Key Considerations:
Prior Knowledge: What does the agent already know about the environment?
Available Actions: What can the agent do at any given moment?
Percept History: How does the agent use past information to make better
decisions?
The PEAS Framework
PEAS is an acronym that helps in specifying the task environment of an agent:
Performance: The goals the agent should achieve (e.g., efficiency, safety).
Environment: The world or domain in which the agent operates (e.g., roads for an
autonomous taxi, the Internet for a web crawler).
Actuators: The tools or devices the agent uses to act on the environment (e.g., motors,
display screens).
7/19
Sensors: The means by which the agent perceives its environment (e.g., cameras,
microphones, GPS).
Examples
Automated Taxi:
Performance: Get passengers to their destination safely and quickly, minimize fuel
consumption, and ensure comfort.
Environment: Urban roads, highways, varying weather conditions.
Actuators: Steering wheel, accelerator, brakes, communication system.
Sensors: Cameras, GPS, speedometer, radar.
Web News Aggregator (Software Agent):
Performance: Deliver relevant news and maximize ad revenue.
Environment: Dynamic Internet data sources.
Actuators: Display interface, recommendation engine.
Sensors: Web crawlers, user feedback.
Dimensions of Task Environments
Task environments can be characterized along several dimensions, each influencing how an
agent is designed:
Observability:
Fully Observable: The agent has complete information (e.g., a chessboard in chess).
Partially Observable: Some information is hidden or noisy (e.g., a self-driving car
might have blind spots).
Number of Agents:
Single-Agent: The agent operates alone.
Multi-Agent: The environment contains other agents, leading to competitive or
cooperative interactions.
Determinism:
Deterministic: The result of each action is predictable.
Stochastic: The outcome involves uncertainty.
Temporal Nature:
8/19
Episodic: Each action is independent (e.g., image classification).
Sequential: Decisions affect future states (e.g., driving, chess).
Dynamics:
Static: The environment does not change while the agent is deciding.
Dynamic: The environment changes continuously.
Granularity:
Discrete: Finite and countable states (e.g., board games).
Continuous: Smooth changes (e.g., real-world driving).
4. The Structure of Agents
Components of an Agent
Every agent has two main components:
Agent Program:
This is the algorithm that tells the agent how to behave. It processes current percepts (or
percept sequences) and determines an appropriate action.
Agent Architecture:
The underlying hardware or software system that supports the program. It includes the
sensors (for input) and actuators (for output).
Types of Agent Programs
1. Simple Reflex Agents:
Mechanism:
These agents make decisions based solely on the current percept using condition–
action rules (if-then rules). They do not consider past percepts.
Advantages:
Simplicity and speed.
Effective in fully observable and simple environments.
Limitations:
9/19
They fail when the environment is partially observable or when context is
necessary to make an informed decision.
Example:
A basic vacuum agent that cleans if it detects dirt in its immediate square, and
otherwise moves to a neighboring square.
2. Model-Based Reflex Agents:
Mechanism:
In addition to current percepts, these agents maintain an internal state (or model)
that reflects parts of the world not directly observable at the moment.
Advantages:
Better handling of environments where not all information is available at each
moment.
Can “remember” past events to infer the current state.
Example:
An automated taxi that remembers the locations of previously encountered
obstacles, even if they are currently out of view.
3. Goal-Based Agents:
Mechanism:
These agents are designed to achieve specific goals. They use planning and search
methods to evaluate sequences of actions that lead from the current state to a
desired goal state.
Advantages:
Flexibility and adaptability since goals can be updated, and the agent can plan
several steps ahead.
Example:
A navigation system that plans a route from your current location to your
destination by considering various possible paths.
4. Utility-Based Agents:
Mechanism:
Instead of just aiming to reach a goal, these agents assess the “quality” or
“desirability” of different states using a utility function. The utility function quantifies
10/19
how good a state is, allowing the agent to weigh trade-offs (like speed versus
safety).
Advantages:
They can handle multiple, sometimes conflicting, objectives.
They allow for more nuanced decision-making in uncertain or complex
environments.
Example:
An autonomous vehicle that chooses a route not only based on distance but also
based on factors such as traffic conditions and safety, maximizing overall “utility.”
5. Learning Agents:
Mechanism:
These agents have the ability to improve their performance over time by learning
from experience. They often incorporate components such as:
Performance Element: Executes actions based on current knowledge.
Learning Element: Updates the agent’s knowledge or strategy using feedback.
Critic: Evaluates how well the agent performed relative to a benchmark.
Problem Generator: Suggests exploratory actions to discover new strategies.
Advantages:
They adapt to changes in the environment, improving decision-making as they
encounter new scenarios.
Example:
A self-driving car that learns from each trip, adjusting its responses to different road
conditions and unexpected obstacles.
Levels of Representation
How an agent “perceives” and “understands” the world can vary in complexity:
Atomic Representation:
The state is treated as a single, indivisible unit. Useful for simple problems but does not
capture internal structure.
Factored Representation:
The state is broken down into several attributes or variables (e.g., the state of a car
might include location, speed, and fuel level). This allows for more detailed reasoning.
11/19
Structured Representation:
Provides an explicit description of objects, relationships, and hierarchies (e.g., an object-
oriented model of a room with furniture, people, and spatial relationships). This is used
in advanced AI applications such as natural language processing and relational
databases.
5. Problem-Solving by Searching
What Are Problem-Solving Agents?
These agents focus on achieving specific goals by planning a sequence of actions. They
simplify decision-making by breaking down the problem into clearly defined components.
Key Steps in Problem Solving:
1. Goal Formulation:
The agent begins by defining what it wants to achieve. For instance, in route-finding,
the goal might be “arrive at Bucharest.”
2. Problem Formulation:
The problem is described by specifying:
Initial State: Where the agent starts (e.g., Arad for a route-finding problem).
Actions: What moves are possible (e.g., “go to Sibiu,” “go to Zerind”).
Transition Model: A function that tells you what new state results from taking a
particular action in a given state.
Goal Test: A method for checking if the current state meets the goal conditions.
Path Cost: A numerical measure (like distance or time) that represents the “cost”
of a particular path.
3. Search for a Solution:
The agent uses search algorithms to explore the state space, trying to find a
sequence of actions that leads from the initial state to the goal state.
4. Execution:
12/19
Once a solution is found, the agent executes the sequence of actions. In some cases,
this execution might not involve continuous monitoring (open-loop), while in other
cases, the agent may re-assess after every action.
Abstraction in Problem Solving
Purpose:
Abstraction helps simplify a complex real-world problem by ignoring irrelevant details.
For example, while driving, you don’t need to model every minor movement of your foot
on the pedal; you only need to decide when to accelerate, decelerate, or turn.
Abstraction of Actions:
Higher-level actions (like “drive from City A to City B”) encapsulate many low-level
operations. This allows the agent to plan at a more manageable level while leaving the
details for lower-level controllers.
Example Problems
Toy Problems:
Vacuum World:
States: Defined by the agent’s location and the status (clean or dirty) of each
square.
Actions: Simple commands such as “move left,” “move right,” or “suck” (clean).
Goal: Clean all squares, with the performance measured by the number of steps
taken.
8-Puzzle:
States: Different configurations of eight tiles and one blank space.
Actions: Sliding the blank space up, down, left, or right.
Goal: Arrange the tiles in a specified order.
Real-World Problems:
Route-Finding:
States represent different geographic locations; the agent chooses paths based
on distance, traffic, and other factors.
Traveling Salesperson Problem (TSP):
The goal is to find the shortest possible route that visits each city exactly once
and returns to the start, which involves complex optimization and planning.
13/19
6. Search Algorithms
Search algorithms are methods that allow agents to explore the state space defined in a
problem formulation and find the best sequence of actions to achieve a goal.
Search Tree Structure
Concept:
The search process can be visualized as a tree:
Root Node: Represents the initial state.
Child Nodes: Generated by applying actions to the current state.
Branches: Each branch represents a sequence of actions.
Frontier:
The collection of nodes that have been generated but not yet expanded.
Exploration:
Nodes are expanded (i.e., their successors are generated) until a goal state is found or all
nodes have been explored.
Tree-Search vs. Graph-Search
Tree-Search:
Explores states without keeping track of which states have already been visited.
This can lead to revisiting states, causing inefficiency or even infinite loops.
Graph-Search:
Maintains an “explored set” to track nodes that have been expanded, avoiding
redundant work and cycles.
It requires more memory but is generally more efficient in large or cyclic state
spaces.
Data Structures for Search
Queues:
14/19
FIFO (First-In, First-Out): Used in Breadth-First Search (BFS) to ensure that the
shallowest nodes are expanded first.
Stacks:
LIFO (Last-In, First-Out): Used in Depth-First Search (DFS) to explore as deeply as
possible before backtracking.
Priority Queues:
Used in algorithms like Uniform-Cost Search and A*, where nodes are ordered by a
cost function (e.g., the cumulative cost so far plus an estimate of the cost to the
goal).
Uninformed (Blind) Search Strategies
These strategies do not use additional domain-specific information. They rely solely on the
problem’s definition.
1. Breadth-First Search (BFS):
Mechanism:
Expands nodes level by level. It uses a FIFO queue to guarantee that nodes closer to
the root are expanded first.
Properties:
Completeness: It will find a solution if one exists.
Optimality: It finds the shortest solution if every action has the same cost.
Drawbacks:
The time and memory usage grows exponentially with the depth of the solution.
2. Uniform-Cost Search:
Mechanism:
Instead of exploring by depth, it expands the node with the lowest path cost from
the start, using a priority queue.
Properties:
Optimality: It guarantees an optimal solution if the cost function is correctly
defined.
Completeness: It finds a solution as long as the cost of every action is positive.
Drawbacks:
Can be slow if there are many low-cost actions that lead to many nodes.
15/19
3. Depth-First Search (DFS):
Mechanism:
Explores as far as possible down one branch before backtracking, using a stack
(LIFO).
Properties:
Memory Efficient: Only needs to store one path at a time.
Completeness: Not guaranteed, especially if the search tree is infinite.
Drawbacks:
May find a solution that is not optimal and can get stuck in deep or infinite
branches.
4. Depth-Limited Search (DLS):
Mechanism:
A variation of DFS that imposes a limit on how deep the search can go.
Properties:
Helps avoid infinite loops by stopping the search at a predefined depth.
May miss solutions if they lie beyond the depth limit.
5. Iterative Deepening Search (IDS):
Mechanism:
Repeatedly applies depth-limited search with increasing depth limits until a solution
is found.
Properties:
Completeness and Optimality: Combines the benefits of BFS (completeness)
and DFS (space efficiency).
Drawbacks:
Some work is repeated at shallower levels, but the overhead is often acceptable
given the memory savings.
6. Bidirectional Search:
Mechanism:
Simultaneously starts from the initial state and the goal state, working until the two
searches meet.
Properties:
16/19
Time Efficiency: The effective search depth is roughly halved, making it
significantly faster in many cases.
Challenges:
Managing two search frontiers and finding the meeting point can be complex,
especially when the goal state is not well defined.
Informed (Heuristic) Search Strategies
Heuristic search algorithms use additional information—typically an estimate of the cost to
reach the goal—to guide the search more efficiently.
1. Greedy Best-First Search:
Mechanism:
Uses a heuristic function, h(n), to estimate the cost from the current node to the
goal and expands the node that seems closest to the goal.
Properties:
Speed: Can quickly find a solution if the heuristic is effective.
Limitations:
Not guaranteed to find the optimal solution and might even get stuck in local
minima.
2. A Search:*
Mechanism:
Combines the actual cost to reach a node, g(n), with a heuristic estimate, h(n), to
form a total cost function: f(n) = g(n) + h(n).
Properties:
Optimality and Completeness: Guaranteed if the heuristic is both admissible
(never overestimates the true cost) and consistent.
Drawbacks:
Can be memory intensive because it stores all generated nodes.
3. Memory-Bounded Heuristic Searches:
When standard A* is too memory-intensive, several variants can be used:
IDA (Iterative-Deepening A):**
Uses a threshold on f(n) and iteratively deepens the search without storing all
nodes.
17/19
Recursive Best-First Search (RBFS):
Uses recursion to mimic best-first search while keeping memory usage low by
remembering only a limited set of nodes.
SMA (Simplified Memory-Bounded A):**
Maintains a fixed amount of memory by discarding the least promising nodes when
memory is full.
4. Heuristic Functions for Puzzle Problems (e.g., 8-Puzzle):
h₁ (Misplaced Tiles):
Counts the number of tiles that are not in their target position. Simple and fast but
less informative.
h₂ (Manhattan Distance):
Calculates the sum of the horizontal and vertical distances each tile is away from its
correct position. It generally leads to fewer node expansions because it provides a
more precise estimate.
Generating Better Heuristics:
Advanced techniques include:
Relaxed Problems: Removing constraints to get a lower-bound estimate on the
true cost.
Pattern Databases: Precomputing the exact cost for subproblems and storing
these in a database.
Learning-Based Approaches: Using machine learning to infer heuristic values
from data.
Evaluating Search Algorithms
When choosing or designing a search algorithm, consider:
Completeness: Will the algorithm find a solution if one exists?
Optimality: Does the algorithm guarantee the best (lowest cost) solution?
Time Complexity: How many nodes will be generated and expanded before a solution is
found?
Space Complexity: How much memory is required to store nodes during the search?
Effective Branching Factor: A measure of how effectively the heuristic or algorithm
reduces the number of nodes expanded.
18/19
Summary and Study Tips
These detailed notes cover the evolution and fundamental ideas behind AI, starting from its
philosophical and historical roots, through the design of agents and environments, to the
intricate methods of problem-solving via search. To study effectively:
Understand the Concepts: Don’t just memorize definitions—try to relate each idea to
real-world examples (e.g., compare a simple reflex agent to a modern self-driving car).
Visualize the Processes: Draw diagrams of search trees, the PEAS framework, and agent
architectures. Visual aids help solidify understanding.
Work Through Examples: Apply the ideas to simple problems like the 8-puzzle or
vacuum world. Step through how each algorithm would explore the problem space.
Connect the Disciplines: Notice how insights from philosophy, economics, neuroscience,
and computer engineering all influence AI. This inter-disciplinary approach is key to
understanding both the potential and limitations of AI systems.
These explanations should give you a robust foundation for studying AI from scratch. Each
section builds on previous ideas, so ensure you understand one topic before moving on to
the next. Happy studying!
19/19