Guide to AI and Data Courses · Lecture Notes

Chapter 2: Artificial Intelligence

When we tell a warehouse robot to go from shelf A to shelf B, it has a map, a goal and hundreds of possible routes. We do not draw the route; the robot chooses it. Artificial intelligence is the course about that choosing: designing an agent that perceives its environment and finds the action that best serves its goal. Sometimes the choice is made by searching through paths, sometimes by logical inference, and sometimes by computing probabilities from incomplete information. These notes introduce the course and work through its three core ideas with small examples you can compute by hand.

Learning outcomes

Agent and environment
Describe a problem by its sensors, actuators, environment and performance measure; classify an environment by properties such as observability and determinism.
Rationality
Compute the performance of a simple agent under a measure and compare two agents by it.
Search
Trace breadth-first search and A* by hand on a small graph; check whether a heuristic function is admissible.
Uncertainty
Update a belief with a new observation using Bayes' rule and choose the action with the highest expected utility.
Place of the course
State what separates artificial intelligence from machine learning, expert systems, optimization and multi-agent systems.

2.1What question does the course ask?

How does a machine act intelligently by searching, reasoning and planning?

Artificial intelligence studies how to design intelligent agents that perceive their environment and choose the action that best serves their goal. The course brings search, logical inference, probabilistic reasoning, planning and learning into one framework. Machine learning is part of that framework, not all of it.

An AI course does not teach a single algorithm; it teaches a point of view: seeing intelligent behavior as a loop between an agent and its environment. The agent perceives, chooses an action based on what it knows, carries it out, and the environment changes. The rest of the course lists what can stand behind the word "chooses": searching states systematically, deriving conclusions from rules, reasoning with probability, or building a sequence of actions.

Two consequences of this view matter. First, "intelligent" is tied to a measure: an agent is rational if it tries to maximize the performance measure it was given. Whether it thinks like a human stays in the background. Second, the same agent framework describes very different problems in one language: a chess engine, a route planner and a diagnosis system are all agents that choose actions from what they perceive; only their environments and measures differ.

2.1.1Every problem starts with an environment

Before choosing an algorithm for a problem, we question its environment. Can the agent see all of it? Is the outcome of an action certain, or does it depend on chance? Does the environment change while the agent is thinking? The answers decide which technique will work: in a fully observable, deterministic environment search is enough; in a partially observable or random one we need probability. The three core sections below follow this order: agent and measure first, then search, then uncertainty.

2.1.2At a glance

CriterionArtificial Intelligence
Approachsearch, logic, probability and learning combined
Inputproblem definition: states, actions, goal
Outputaction sequence, plan or decision
Success measurereaching the goal, cost, rationality
Math loadmedium: logic, probability, graphs
Data needslittle; often a model and knowledge suffice

2.2A short history

YearMilestone
1950Turing proposes the imitation game (the Turing test) in "Computing Machinery and Intelligence".
1956Dartmouth summer workshop: the name "artificial intelligence" is coined and the field is born.
1980sExpert systems (MYCIN, XCON) go commercial; unmet expectations bring an "AI winter".
1997Deep Blue beats Kasparov at chess: powerful search and a hand-written evaluation.
2016AlphaGo beats Lee Sedol at Go: tree search, deep networks and reinforcement learning together.
2022Large language models reach a mass audience through chat interfaces.

2.3Core concepts

The rest of the course is built on the concepts below. The following sections work through the most important ones with examples.

ConceptMeaning
Intelligent agentPerceives the environment through sensors, acts on it through actuators.
RationalityChoosing the action expected to maximize the performance measure.
State-space searchBFS, DFS, A*; heuristic functions.
Adversarial searchMinimax and alpha-beta pruning in games.
Constraint satisfactionVariables, domains, constraints: Sudoku, timetabling.
Logic and knowledgePropositional and first-order logic, inference rules.
UncertaintyBayes' rule, Bayesian networks, decision theory.
PlanningBuilding a sequence of actions from start to goal.

2.4Intelligent agents and rationality

An agent is anything that perceives its environment through sensors and acts on it through actuators. Its behavior is an agent function: a mapping from the sequence of percepts so far to an action. A common template for describing an agent is known as PEAS: performance measure, environment, actuators, sensors.

Definition 2.1 (Rational agent)

For each percept sequence, a rational agent selects the action that is expected to maximize the expected value of its performance measure, given what it has perceived so far. Rationality does not mean knowing everything or never making mistakes; it means doing the best with the information at hand.

ElementRobot vacuum example
Performance measurenumber of clean squares at each time step
Environmenta two-square room (A and B), each square dirty or clean
Actuatorssuck, move to the other square
Sensorswhich square it is in and whether that square is dirty
Example 2.1: Comparing two agents by a measure

The room has two squares. The robot starts in A and both squares are dirty. There are four time steps; at the end of each step the number of clean squares is scored. We try three agents:

  1. Reflex agent: if its square is dirty it sucks, otherwise it moves to the other square. Step 1: sucks A, clean squares 1. Step 2: moves to B, clean 1. Step 3: sucks B, clean 2. Step 4: moves to A, clean 2. Total 1 + 1 + 2 + 2 = 6.
  2. Always-suck agent: never moves, sucks A. Clean squares 1 at every step. Total 4 × 1 = 4.
  3. Always-move agent: never sucks. Clean squares always 0. Total 0.

By this measure the ranking is reflex (6), always-suck (4), always-move (0). A simple rule is rational when it serves the measure well; but the same rule may not score the same in another environment, for example a room where dirt reappears. An agent is judged together with its environment.

The properties of an environment tell us how complex the agent must be. Let us compare four commonly asked questions for two environments.

PropertyChessDriving a taxi
Is the environment fully observable?yes, the board is in viewno, other drivers' intentions are hidden
Is the outcome of an action certain?yesno, traffic and road conditions are random
Does the environment change while the agent thinks?no (without a clock)yes, traffic keeps moving
Are the states discrete?yesno, position and speed are continuous

This is why chess suits search, while driving a taxi needs perception, prediction and probability. The order of the course follows it: fully observable, deterministic environments first, then uncertainty.

Common mistake

Choosing a performance measure that rewards what is easy to measure rather than what we want. If we score the robot above by "amount of dirt sucked", a robot that dumps dirt and sucks it up again gets the highest score and the room is never cleaned. The measure should reward the desired state of the environment (clean squares), not how the agent behaves.

2.5State-space search and A*

When the environment is fully observable and actions are certain, the agent can try out the outcome in its head. The problem is set up as a state space: an initial state, the actions available in each state with their costs, and a goal test. A solution is a sequence of actions from the start to the goal; search expands states systematically to find it. Uninformed searches look only at cost: breadth-first search (BFS) finds the path with the fewest actions, uniform-cost search the cheapest path. A* also uses a heuristic function that estimates how far the goal still is.

Definition 2.2 (A* search)

For each node we compute f(n) = g(n) + h(n), where g(n) is the cost so far from the start to n and h(n) is an estimate of the remaining cost from n to the goal. At every step the node with the smallest f is expanded. If h never overestimates the true cost (it is admissible), A* finds the cheapest path.

Example 2.2: A* on a four-node graph

Edge costs: S–A 1, S–B 4, A–B 2, A–G 12, B–G 5. Start S, goal G. Heuristic values h(S) = 7, h(A) = 6, h(B) = 5, h(G) = 0. The true remaining costs are 8 from S, 7 from A and 5 from B, so no h value exceeds them: h is admissible.

  1. Expand S (f = 0 + 7 = 7). Neighbors: A, g = 1, f = 1 + 6 = 7; B, g = 4, f = 4 + 5 = 9.
  2. Expand A (smallest f = 7). Reaching B through A is cheaper: g = 1 + 2 = 3, f = 3 + 5 = 8. G gets g = 1 + 12 = 13, f = 13.
  3. Expand B (f = 8). G through B: g = 3 + 5 = 8, f = 8, better than the earlier 13.
  4. Expand G (f = 8) and the goal is found. The path is S → A → B → G with cost 8.

Comparison: BFS looks for the fewest actions; S → A → G (cost 13) and S → B → G (cost 9) have two actions each, while the cheapest path (8) has three and looks worse to it. Greedy search, which looks only at h, picks B after S because its h is smaller and reaches G at cost 9. A* adds g and h and finds the cheapest path, 8.

2.5.1How is a heuristic chosen?

A good h is close to the truth but never above it. For a robot moving on a grid, Manhattan distance is an admissible estimate, because obstacles can only lengthen the path. The same holds for the 8-puzzle: sum each tile's distance to its goal square (row difference + column difference). The closer h is to the truth, the fewer nodes A* expands. If h is always 0, A* becomes uniform-cost search.

Common mistake

Choosing a generous heuristic "to be a good estimate". In the graph above, if h(B) is taken as 12 instead of 5, B's f becomes 15. After A is expanded, G with f = 13 is expanded before B (f = 3 + 12 = 15) and A* returns the path of cost 13, although the cheapest is 8. An h that exceeds the true cost can make search miss the cheapest path.

2.6Decisions under uncertainty

In real environments sensors are noisy and the full state is hidden. The agent keeps only a belief: a probability distribution over possible states. When a new observation arrives, the belief is updated with Bayes' rule; then the agent picks an action by looking at the utility of its outcomes.

Definition 2.3 (Bayes' rule and expected utility)

P(H | O) = P(O | H) · P(H) / P(O); here H is a hypothesis (for example "there is an obstacle ahead") and O is the observation. The expected utility of an action is the utility of each outcome times its probability, summed: EU(a) = Σ P(s) · U(s, a). A rational agent picks the action with the largest EU.

Example 2.3: A robot sensing an obstacle

The probability that there is an obstacle ahead of a robot is P(O) = 0.2. The front sensor raises an alarm 90% of the time when there is an obstacle and 10% of the time when there is none. The alarm sounds. (The values are illustrative.)

  1. Probability of an alarm. P(alarm) = 0.9 · 0.2 + 0.1 · 0.8 = 0.18 + 0.08 = 0.26.
  2. Update. P(O | alarm) = 0.18 / 0.26 ≈ 0.69. The belief rose from 0.20 to 0.69.
  3. Utilities. Braking costs 1 unit if there is no obstacle (an unnecessary stop) and 0 if there is one. Continuing costs 100 units if there is an obstacle (a crash) and 0 if there is none.
  4. Expected utilities. EU(brake) = −1 · 0.31 ≈ −0.31; EU(continue) = −100 · 0.69 ≈ −69.2. The robot brakes.
  5. A second alarm. If the sensor errors are independent, the second alarm multiplies the odds by the likelihood ratio (90/10 = 9): odds 2.25 × 9 = 20.25, so P(O) ≈ 0.95.

Braking is the right decision even at a small belief: continuing is better only when P(O) < 1/101 ≈ 0.01. Because a crash is so costly, the robot slows down even when it is not sure about the obstacle.

Three things connect here: an observation changes the belief, utility judges the outcomes, and a rational agent weighs both together. This framework extends to Bayesian networks, Markov decision processes and reinforcement learning.

Common mistake

Treating the obstacle as certain once the alarm sounds, or reasoning "the alarm is 90% accurate, so the obstacle is 90% likely". The 90% is P(alarm | obstacle), not P(obstacle | alarm); the difference between them is the prior. Here the prior was 0.2, so the result is 0.69; if obstacles were very rare, the same alarm would give much less confidence.

2.7How is the course taught?

2.7.1A typical workflow

PerceivesensorsRepresentstate,knowledge baseSearch orinfersearch, logic,probabilityChooseperformancemeasureActactuators
Figure 2.1: A typical workflow in Artificial Intelligence

A navigation app senses its location, represents the road network as a graph, searches routes with A*, picks the fastest one and guides the driver by voice. Nothing in this loop is "learned"; the system is still AI.

2.7.2Topics over the semester

  1. Intelligent agents and types of environments
  2. Uninformed search: BFS, DFS, uniform-cost search
  3. Heuristic search: greedy best-first and A*
  4. Local search: hill climbing, simulated annealing
  5. Adversarial search: minimax and alpha-beta pruning
  6. Constraint satisfaction problems and backtracking
  7. Propositional logic and inference by resolution
  8. First-order logic and knowledge representation
  9. Classical planning: STRIPS and PDDL
  10. Probability, Bayes' rule and Bayesian networks
  11. Decision theory and Markov decision processes
  12. Learning from examples and reinforcement learning

This is a typical semester; the order and coverage vary between universities.

2.7.3Skills you will gain

  • formulating problems as state spaces
  • implementing A* with heuristics
  • logic programming in Prolog
  • writing planning problems in PDDL
  • building Bayesian networks with pgmpy
  • comparing algorithms by complexity

2.7.4Try it yourself

The Try It: A Warehouse Robot Finds Its Way slide in the presentation lets you solve a typical problem of this course yourself: A warehouse robot must travel from cell R between the shelves to the item in cell H. Click a cell to add or remove a shelf; compare how many cells the two search methods examine.

2.8Are you ready for this course?

2.8.1Prerequisites

CourseWhy it is needed
Probability and Statisticsreasoning under uncertainty, Bayes' rule
Data Structuresstacks, queues, priority queues and graphs: the building blocks of search
Algorithmsgraph search, shortest paths and complexity analysis
Discrete Mathematicspropositional logic, sets and proof techniques

2.8.2Ask yourself

For every "no", the right-hand column shows where to start. If you can say "yes" to most of them, you are ready.

QuestionIf not, start with
Can you trace BFS and DFS on a graph step by step on paper?Graphs and queues from a data structures course
Can you explain a priority queue and big-O notation?Complexity analysis from an algorithms course
Can you build a truth table with "and", "or" and "implies"?Propositional logic from discrete mathematics
Can you explain conditional probability and Bayes' rule?Probability and Statistics

2.9Neighboring courses

Machine LearningProbability & StatisticsOptimizationNLPFuzzy LogicEvolutionary OptimizationExpert SystemsMulti-Agent SystemsArtificial Intelligence
subfieldbuilds onshares methodsapplication
Figure 2.2: Neighbors of Artificial Intelligence and the kind of relation

2.9.1Where it overlaps

RelationCourseShared ground
subfieldMachine Learning is a subfield of this coursean agent that learns from data; statistical generalization instead of search
subfieldNatural Language Processing and Text Mining is a subfield of this courselanguage understanding and generation
subfieldFuzzy Logic and Fuzzy Systems is a subfield of this courseapproximate reasoning
subfieldEvolutionary and Metaheuristic Optimization is a subfield of this courseheuristic search
subfieldExpert Systems and Knowledge Representation is a subfield of this coursesymbolic AI, logic and rules
subfieldMulti-Agent Systems is a subfield of this coursethe agent concept, collective decisions
builds onThis course builds on Probability and Statisticsreasoning under uncertainty, Bayes' rule
shares methodsShares methods with Optimizationstate-space search, constraint satisfaction

2.9.2Where it differs

  • Machine Learning: AI can find how to reach a goal by search or inference; ML learns the same behavior by generalizing from data.
  • Expert Systems and Knowledge Representation: Expert systems are one approach within AI (rules and logic); AI also covers search, probability and learning.
  • Optimization: Optimization solves a problem already stated mathematically; AI starts by modeling it as agent, environment and goal.
  • Multi-Agent Systems: AI focuses on the decisions of a single agent; multi-agent systems study agents that affect one another.

2.10In practice

2.10.1Applications

AreaWhat is done
GamesChess and Go engines, computer opponents in games.
Route planningNavigation, logistics, paths of warehouse robots.
SchedulingClass timetables, flight crews and shift plans.
Virtual assistantsSystems that understand speech and turn it into tasks.
Autonomous vehiclesWhere perception, prediction and planning meet.
Decision supportDiagnosis suggestions in medicine, fault diagnosis in engineering.

2.10.2Risks and ethics

RiskExplanation
The wrong performance measureAn agent maximizes its measure literally: a route planner that only minimizes travel time can push traffic onto side streets past schools.
Search that does not scaleState spaces grow exponentially; a search that takes seconds on a toy problem runs out of memory and time at real size.
An incomplete knowledge baseA system that treats whatever is missing from its rules as false draws confident but wrong conclusions from one forgotten rule.
Responsibility for autonomyWhen an autonomous car or weapon system decides on its own, it becomes unclear who answers for its mistakes.

These issues are discussed in depth in Explainable AI and AI Ethics.

2.10.3Tools and datasets

Tools: Python, Prolog, PDDL planners, Google OR-Tools, Gymnasium, pgmpy (Bayesian networks).

Classic example problems: 8-puzzle, n-queens, Sudoku, Wumpus world, Traveling salesman, Chess and Go.

An AI course usually gives a problem definition instead of a dataset: once states, actions and the goal are known, the solution is found by search.

2.11Common misconceptions

Common mistake

AI and machine learning are the same thing.

ML is a subfield of AI. Search, planning and logic are AI even without learning.

Common mistake

AI aims to think like humans.

The course mostly aims at acting rationally; imitating humans is only one approach.

Common mistake

Chess engines learn by playing.

Classic engines like Deep Blue use search and a hand-written evaluation; learning is not required.

Common mistake

Chatbots are all of AI.

Large language models come from NLP and generative models; AI is a much broader field.

2.12Summary

  • Artificial intelligence studies agents that perceive an environment and choose actions; an agent is described by PEAS: performance measure, environment, actuators, sensors.
  • A rational agent chooses the action that maximizes the expected value of its performance measure given what it knows; if the measure is chosen wrongly, the agent does the wrong thing well.
  • In fully observable, deterministic environments a problem is set up as a state space; BFS finds the path with the fewest actions, uniform-cost search the cheapest, and A* narrows the search with a heuristic function.
  • If the heuristic never exceeds the true cost (admissible), A* returns the cheapest path; if it does, the returned path may not be the cheapest.
  • Under uncertainty an agent updates its belief with Bayes' rule and picks the action with the highest expected utility; the prior and the cost of actions matter as much as the observation.

2.13Test Yourself

  1. Write the PEAS description of a garden-watering robot and describe its environment on four properties (observable, deterministic, discrete, changing while the agent thinks).

    Answer

    Performance measure: time the soil moisture stays in the desired range, water used. Actuators: valve, wheels. Sensors: moisture and rain sensors, position. Environment: because it depends on rain and sun it is partially observable, random, continuous and changes while the agent thinks.

  2. A reflex agent ("if dirty, suck; otherwise move to the other square") starts in B of a two-square room; B is clean and A is dirty. Score the number of clean squares at each of four steps. What is the total?

    Answer

    Step 1: B is clean, moves to A; clean squares 1 (B). Step 2: A is dirty, sucks; clean 2. Step 3: A is clean, moves to B; clean 2. Step 4: moves to A; clean 2. Total 1 + 2 + 2 + 2 = 7.

  3. In a tree where every state has 3 actions, the goal is at depth 4. How many nodes does BFS generate in the worst case?

    Answer

    The number of nodes at depths 0 to 4 is 1, 3, 9, 27, 81. Total 1 + 3 + 9 + 27 + 81 = 121. This grows exponentially with depth: at depth 8 it is 9841, which is why heuristic search is needed.

  4. In the 8-puzzle the start state is "2 8 3 / 1 6 4 / 7 _ 5" and the goal is "1 2 3 / 8 _ 4 / 7 6 5". Find the number of misplaced tiles and the Manhattan sum.

    Answer

    The misplaced tiles are 2, 8, 1 and 6: count 4. Manhattan: 2 is one column away (1), 8 is two squares away (2), 1 is one square away (1), 6 is one square away (1); 3, 4, 5 and 7 are in place. Total 1 + 2 + 1 + 1 = 5. The Manhattan sum is larger than the misplaced count (5 > 4) and does not exceed the true cost; both are admissible, but Manhattan is more informative.

  5. For a burglar alarm, P(burglar) = 0.01; the alarm sounds with probability 0.95 if there is a burglar and 0.05 if there is none. What is the probability of a burglary when the alarm sounds? Compare with your intuition.

    Answer

    P(alarm) = 0.95 · 0.01 + 0.05 · 0.99 = 0.0095 + 0.0495 = 0.059. P(burglar | alarm) = 0.0095 / 0.059 ≈ 0.16. Although the alarm is 95% sensitive, the event is so rare that there is a burglar only about one time in six.

  6. The probability of rain is 0.3. Taking an umbrella has utility 0 in rain and −1 without rain (the nuisance of carrying it). Not taking it has utility −10 in rain and 0 without. Which is chosen? Above which probability of rain is taking the umbrella worthwhile?

    Answer

    EU(take) = −1 · 0.7 = −0.7; EU(leave) = −10 · 0.3 = −3. The umbrella is taken. They are equal when 10p = 1 − p, that is p = 1/11 ≈ 0.09; above that probability, taking it is better.

2.14After this course

AI is the roof of this guide: machine learning, natural language processing, fuzzy logic, evolutionary optimization, expert systems and multi-agent systems are its branches. To decide which branch interests you, a good start is to see this course's search, logic and uncertainty topics first.

Courses that build on or extend this one: Machine Learning, Natural Language Processing and Text Mining, Fuzzy Logic and Fuzzy Systems, Evolutionary and Metaheuristic Optimization, Expert Systems and Knowledge Representation, Multi-Agent Systems.

Related careers: AI engineer, Researcher, Game AI developer, Robotics software engineer, Decision support specialist.

2.15Further reading

  • S. Russell and P. Norvig, Artificial Intelligence: A Modern Approach (4th ed., 2020): presents the agent framework, search and probabilistic reasoning at the level closest to a course; the agent and PEAS vocabulary of these notes comes from it.
  • D. Poole and A. Mackworth, Artificial Intelligence: Foundations of Computational Agents (3rd ed., 2023): covers the same topics from an agent point of view with many worked examples.
  • N. Nilsson, The Quest for Artificial Intelligence (2010): a readable account of the history of the field and where its ideas came from.

2.16References

  1. Russell and Norvig, Artificial Intelligence: A Modern Approach, 4th ed., Pearson, 2020.
  2. Poole and Mackworth, Artificial Intelligence: Foundations of Computational Agents, 3rd ed., Cambridge University Press, 2023.
  3. Nilsson, The Quest for Artificial Intelligence, Cambridge University Press, 2010 (history of the field).
  4. Turing, "Computing Machinery and Intelligence", Mind 59(236), 1950.

Related pages: Slides · Slides (PDF) · Course page