Introduction
Open in the Padhaiko app1.1 Definition, foundation, history of AI
Artificial Intelligence
Artificial Intelligence (AI) is the branch of computer science that builds machines and programs able to perform tasks which, when done by people, are said to need intelligence: perceiving, reasoning, learning, planning, understanding language and acting to reach a goal.
There is no single definition, so exams usually expect the four classic views (Russell and Norvig). Each view is a combination of what is measured (thinking or acting) and against what standard (humans or an ideal):
| Human-like | Rational (ideal) | |
|---|---|---|
| Thinking | Thinking humanly: model the human mind (cognitive science) | Thinking rationally: "laws of thought", logic |
| Acting | Acting humanly: pass the Turing test | Acting rationally: a rational agent that does the best action |
- Turing test (1950): a human interrogator chats through a terminal with a hidden human and a hidden machine. If the interrogator cannot tell which is the machine, the machine passes. It needs natural language processing, knowledge representation, automated reasoning and machine learning (the total test adds computer vision and robotics).
- Rational agent view: the most used today. An agent is rational if it chooses the action that is expected to maximise its performance measure given what it has perceived. It is more general than the "laws of thought" view because correct inference is only one way of acting rationally.
Foundations of AI
AI borrows ideas from many older disciplines:
| Discipline | Contribution to AI |
|---|---|
| Philosophy | Logic, reasoning, the mind as a physical system, knowledge and its sources |
| Mathematics | Formal logic, computation and decidability, probability, optimisation |
| Economics | Decision theory and utility, game theory, handling uncertainty and rewards |
| Neuroscience | How neurons store and process information, inspiration for neural networks |
| Psychology | Models of perception, memory, learning and problem solving (cognitive science) |
| Computer engineering | Fast hardware and software (GPUs, memory) that make AI practical |
| Control theory | Feedback, adaptive control, optimising behaviour over time |
| Linguistics | Grammar, meaning and structure of language for natural language processing |
History of AI
| Period | Event |
|---|---|
| 1943 | McCulloch and Pitts propose a model of artificial neurons |
| 1950 | Turing publishes "Computing Machinery and Intelligence" and the Turing test |
| 1956 | Dartmouth workshop: John McCarthy coins the term "Artificial Intelligence" |
| 1950s–60s | Early optimism: Logic Theorist, General Problem Solver, LISP, ELIZA, perceptron |
| 1966–73 | First setbacks: combinatorial explosion, limits of single-layer perceptrons |
| 1969–86 | Knowledge-based expert systems (DENDRAL, MYCIN) |
| 1974–80 and late 1980s | AI winters: funding cuts after unmet promises |
| 1986 onwards | Backpropagation revives neural networks; probabilistic methods rise |
| 1997 | IBM Deep Blue beats world chess champion Kasparov |
| 2000s | Big data, machine learning and intelligent agents dominate |
| 2011–12 | Watson wins Jeopardy!; deep learning wins ImageNet (AlexNet) |
| 2016 | AlphaGo defeats Lee Sedol at Go |
| 2017 onwards | Transformers, large language models and generative AI |
1.2 Importance of knowledge and learning
Knowledge versus Data
Data are raw facts; information is data with meaning; knowledge is organised, validated information that can be used to reason and make decisions (facts, rules, relations and experience).
Why knowledge matters:
- Intelligence needs something to reason about. A chess program with no knowledge of the rules or of good positions can only try moves blindly.
- Knowledge narrows search. Heuristics and rules of thumb cut an exponentially large search space down to a manageable one.
- Knowledge is voluminous, hard to characterise and changes constantly, so it must be stored in a form that is easy to modify and reuse (rules, frames, logic).
- It lets a system explain decisions by pointing to the rules used.
Why learning matters:
- Designers cannot foresee every situation. A learning agent adapts to new environments.
- Writing all the knowledge by hand is slow (the knowledge acquisition bottleneck). Learning lets the program acquire knowledge from data.
- Performance improves with experience: after learning, the same agent does better on the same task.
1.3 Cognition and learning (Neuroscience)
Cognition is the mental process of acquiring, storing, transforming and using knowledge: perception, attention, memory, language, reasoning, problem solving and decision making. Cognitive science studies it and gives AI models to copy.
The brain is built from about neurons, each connected to thousands of others by synapses.
Dendrites ──► Cell body (soma) ──► Axon ──► Synapse ──► next neuron
(inputs) (sums the inputs, (output (connection
fires if above wire) strength)
a threshold)
x1 ─w1─┐
x2 ─w2─┼──► Σ wi·xi + b ──► activation f ──► y
x3 ─w3─┘| Biological | Artificial |
|---|---|
| Dendrites receive signals | Inputs |
| Synaptic strength | Weights |
| Soma sums signals and fires above a threshold | Weighted sum plus bias, then activation function |
| Axon carries output | Output |
| Learning = change of synaptic strength | Learning = change of weights |
How the brain learns, and the AI link:
- Hebbian learning: "neurons that fire together wire together". A connection is strengthened when the two neurons it joins are active together. This is the root of weight-update rules.
- Plasticity: the brain re-wires itself with experience, which is the biological counterpart of training.
- Parallel and distributed processing: many slow neurons (about milliseconds each) work simultaneously, which inspired parallel neural network computation.
1.4 Human intelligence and machine intelligence
| Aspect | Human Intelligence | Machine Intelligence |
|---|---|---|
| Speed of calculation | Slow and error-prone for large numbers | Extremely fast and exact |
| Learning | Learns from very few examples, in any domain | Usually needs large data and is narrow in one domain |
| Creativity and emotion | Has imagination, emotions, intuition and morals | Only imitates them from patterns, no real feeling |
| Common sense | Rich background knowledge of the world | Weak, often fails on simple everyday reasoning |
| Memory | Limited and forgetful, but associative | Huge, exact and permanent |
| Fatigue | Gets tired, needs rest | Works continuously without tiredness |
| Adaptability | Transfers skills to new problems easily | Poor transfer, must be retrained |
| Consciousness | Self-aware | None (as far as we know) |
1.5 AI tree: Branches and interdisciplinary nature
AI is a tree whose roots are the foundation disciplines of section 1.1 and whose branches are its sub-fields.
ARTIFICIAL INTELLIGENCE
┌──────────┬──────────┬──────────┬──────────┬──────────┬──────────┐
Search & Knowledge Machine Natural Computer Robotics Expert
problem represen- learning language vision systems
solving tation & (deep processing
reasoning learning)
Roots: philosophy, mathematics, statistics, neuroscience,
psychology, linguistics, computer engineering, control theory| Branch | What it does | Example |
|---|---|---|
| Search and planning | Finds a sequence of actions to a goal | Route finding, game playing |
| Knowledge representation and reasoning | Stores facts and derives new ones | Logic-based diagnosis |
| Machine learning | Learns patterns from data | Spam filtering, recommendations |
| Natural language processing | Understands and generates language | Translation, chatbots |
| Computer vision | Interprets images and video | Face recognition |
| Robotics | Senses and acts in the physical world | Warehouse robots |
| Expert systems | Encodes expert rules for advice | Medical diagnosis |
| Speech processing | Converts speech to text and back | Voice assistants |
Interdisciplinary nature: a medical-imaging AI needs medicine (domain), statistics (models), computer science (algorithms and hardware), ethics and law (privacy). Real AI projects therefore mix several fields and several branches at once.
1.6 Intelligent agents and types
Agent, Percept and Rational Agent
An agent is anything that perceives its environment through sensors and acts on it through actuators. The percept sequence is the complete history of what it has perceived. The agent function maps every percept sequence to an action; the agent program implements it.
A rational agent selects, for every percept sequence, the action expected to maximise its performance measure, using its built-in knowledge and the percepts so far.
percepts ┌───────────────┐
┌───────────────────────────────── │ ENVIRONMENT │
▼ └───────────────┘
SENSORS ─► [ AGENT PROGRAM: decide ] ─► ACTUATORS ─ actions ─► back to environmentPEAS description
To specify a task environment, give the PEAS: Performance measure, Environment, Actuators, Sensors.
| Agent | Performance | Environment | Actuators | Sensors |
|---|---|---|---|---|
| Automated taxi | Safe, fast, legal, comfortable trip, profit | Roads, traffic, pedestrians, weather | Steering, accelerator, brake, signal, horn | Cameras, GPS, speedometer, lidar |
| Medical diagnosis system | Healthy patient, low cost | Patient, hospital, staff | Display of tests and diagnosis | Keyboard entry of symptoms and results |
| Vacuum cleaner robot | Cleanliness, battery use, time | Rooms, dirt, furniture | Wheels, brushes, suction | Dirt sensor, bump sensor, camera |
| Spam filter | Few false positives and negatives | Incoming email stream | Mark as spam, move to folder | Email text and headers |
Properties of task environments
| Property | One end | Other end |
|---|---|---|
| Observability | Fully observable (sensors give the whole state) | Partially observable |
| Agents | Single agent | Multi-agent (competitive or cooperative) |
| Determinism | Deterministic (next state fixed by state and action) | Stochastic (random effects) |
| Episodes | Episodic (each step independent) | Sequential (past actions matter) |
| Change | Static (waits for the agent) | Dynamic (changes while agent thinks) |
| States | Discrete | Continuous |
| Knowledge | Known (rules are known) | Unknown (agent must learn the rules) |
Example: chess with a clock is fully observable, two-agent, deterministic, sequential, semi-dynamic and discrete. Taxi driving is partially observable, multi-agent, stochastic, sequential, dynamic and continuous.
Types of agents
Agents are classified by increasing generality:
- Simple reflex agent: acts only on the current percept using condition-action rules (
if dirty then suck). Fast and simple, but needs a fully observable environment and can loop forever. - Model-based reflex agent: keeps an internal state (a model of how the world works) to handle partial observability.
- Goal-based agent: uses a goal and does search or planning to choose actions that reach it, so it can adapt when the goal changes.
- Utility-based agent: uses a utility function to score how good a state is, so it can pick the best among several goal-reaching routes and handle trade-offs and uncertainty.
- Learning agent: improves with experience. It has four parts: the performance element (chooses actions), the critic (compares behaviour with the performance standard), the learning element (makes the improvements) and the problem generator (suggests exploratory actions).
Simple reflex: percept ─► [condition–action rules] ─► action
Model-based: percept ─► [state update using model] ─► [rules] ─► action
Goal-based: percept ─► [state] ─► [predict result of actions] ─► [goal?] ─► action
Utility-based: percept ─► [state] ─► [predict results] ─► [how happy (utility)?] ─► action
Learning: critic ─► learning element ─► (changes) performance element
problem generator ─► exploratory actions| Aspect | Goal-based Agent | Utility-based Agent |
|---|---|---|
| Decision rule | Does the action reach the goal: yes or no | How good is the resulting state: a number |
| Handles trade-offs | No | Yes (speed versus safety) |
| Handles uncertainty | Poorly | Maximises expected utility |
| Example | Reach city B | Reach city B quickly, safely and cheaply |
1.7 Agentic AI
Agentic AI
Agentic AI refers to AI systems, usually built around a large language model, that pursue a goal autonomously: they plan a multi-step task, call external tools (search, code, databases, APIs), observe the results, remember context and adjust their plan with little human supervision.
Core loop of an AI agent: perceive → reason and plan → act with a tool → observe the result → reflect and repeat until the goal is done. Its key components are:
- Reasoning and planning: breaks a goal into sub-tasks.
- Memory: short-term (the current conversation) and long-term (stored facts, vector database).
- Tools: the actuators of the software world (web search, calculator, code execution, email).
- Feedback and self-correction: checks results and retries.
- Guardrails and human oversight: limits on permissions and approval of risky actions.
| Aspect | Generative AI Chatbot | Agentic AI System |
|---|---|---|
| Behaviour | Reacts to one prompt with one reply | Pursues a goal over many steps |
| Tool use | Usually none | Calls tools and APIs |
| Autonomy | Low, the user drives | High, plans and acts on its own |
| Memory | Within the chat window | Persistent memory across tasks |
| Risk | Wrong text | Wrong actions with real effects |
Example: a travel agent that, given "plan a 3-day trip to Pokhara under Rs. 30,000", searches flights and hotels, compares prices, books after your approval and sends the itinerary.
Worked Out Examples
1.1
Describe an automated taxi driver as an intelligent agent using PEAS, and classify its task environment.
Performance measure: safe arrival, minimum travel time and fuel, obeying traffic law, passenger comfort, profit.
Environment, actuators and sensors: roads, other vehicles, pedestrians, weather and passengers form the environment. Steering, accelerator, brake, indicators and horn are the actuators. Cameras, lidar, GPS, speedometer and engine sensors are the sensors.
Classifying the environment with the seven properties: partially observable (cannot see round corners), multi-agent, stochastic (other drivers are unpredictable), sequential (a turn affects what follows), dynamic (traffic moves while the car decides), continuous (position and speed) and, for an ordinary driver, known rules.
PEAS: P = safe, fast, legal, comfortable, profitable trip; E = roads, traffic, pedestrians, weather; A = steering, accelerator, brake, signals, horn; S = cameras, lidar, GPS, speedometer. Environment: partially observable, multi-agent, stochastic, sequential, dynamic, continuous.
1.2
A rational agent can take action or . Action gives utility with probability and utility with probability . Action gives utility for certain. Which action should it take?
Expected utility of an action is the sum of probability times utility over its outcomes: .
For : .
For : .
A rational agent maximises expected utility, and , so it picks even though can sometimes give a negative result.
and , so the rational agent chooses .
1.3
A vacuum world has squares and , both dirty. The agent starts in and follows the rules: if the current square is dirty then Suck; else move to the other square. It scores per clean square after each time step. Trace four steps and give the total score.
Time 1: in , dirty, so Suck. is clean, dirty: score .
Time 2: in , clean, so move Right to . Still clean, dirty: score .
Time 3: in , dirty, so Suck. Both clean: score .
Time 4: in , clean, so move Left to . Both clean: score .
Total score .
Exercises
Exercise: Introduction to AI
Define Artificial Intelligence. Explain the four approaches to AI and the Turing test.
Definition: AI is the science of making machines do tasks that need human intelligence, such as reasoning, learning, perception and language.
Four approaches: thinking humanly (cognitive modelling), thinking rationally (laws of thought, logic), acting humanly (Turing test) and acting rationally (rational agent).
Turing test: an interrogator questions a hidden human and a hidden machine by text. If the interrogator cannot reliably tell them apart, the machine is said to be intelligent. It requires natural language processing, knowledge representation, reasoning and learning.
AI builds machines that perform tasks needing intelligence. The four views are thinking humanly, thinking rationally, acting humanly and acting rationally. The Turing test judges a machine by whether a human interrogator can distinguish it from a person in a text conversation.
Explain the foundations of AI and write briefly on its history up to the AI winters.
Foundations: philosophy (logic, mind), mathematics (logic, probability, computation), economics (utility, decisions), neuroscience (neurons), psychology (cognition), computer engineering (hardware), control theory (feedback) and linguistics (language).
History: 1943 McCulloch and Pitts neuron; 1950 Turing test; 1956 Dartmouth workshop coins "AI"; early programs such as Logic Theorist and ELIZA. Promises were not met because of combinatorial explosion and weak hardware, so funding fell in the AI winters (mid-1970s and late 1980s). Expert systems and, later, machine learning revived the field.
Foundations come from philosophy, mathematics, economics, neuroscience, psychology, computer engineering, control theory and linguistics. History: neuron model 1943, Turing test 1950, term AI 1956, expert systems 1970s–80s, AI winters after over-promising, then revival with learning and big data.
Action gives utility with probability and with probability . Action gives utility with probability and with probability . Which action will a rational (utility-based) agent choose?
.
.
A rational agent maximises expected utility, and , so it chooses , the safer action.
, . The agent chooses action .
Explain the five types of intelligent agents with a block diagram of each, and state where each is suitable.
Simple reflex: percept → condition-action rule → action. Suitable for fully observable, simple tasks (thermostat, simple vacuum).
Model-based reflex: adds an internal state updated from percepts and a model of the world. Suitable for partially observable tasks (driving with a blind spot).
Goal-based: adds a goal and uses search or planning to select actions that reach it. Suitable when the goal changes or paths differ (route planning).
Utility-based: adds a utility function that scores states and maximises expected utility. Suitable for trade-offs and uncertainty (a taxi balancing speed and safety).
Learning agent: has a performance element, critic, learning element and problem generator, and improves from experience. Suitable for unknown or changing environments (recommendation systems).
The five types are simple reflex, model-based reflex, goal-based, utility-based and learning agents; each adds one capability (state, goal, utility, learning) to the previous design, and the choice depends on observability and the complexity of the task.
Differentiate human intelligence from machine intelligence and give the PEAS description of a spam-filtering agent.
Comparison: machines are faster and exact in calculation, have permanent memory and never tire, but need large data, are narrow, lack common sense, emotion and consciousness. Humans learn from few examples, are creative and adaptable, but slower and forgetful.
PEAS of a spam filter: Performance = few false positives and false negatives; Environment = the stream of incoming email; Actuators = mark as spam, move to a folder; Sensors = email text, headers and sender information.
Machines excel in speed, memory and stamina; humans in creativity, common sense and flexible learning. Spam filter PEAS: P = accuracy, E = incoming mail, A = mark or move mail, S = message text and headers.