PadhaikoAll subjects

Introduction

Artificial Intelligence (ENCT 351)

Open in the Padhaiko app

1.1 Definition, foundation, history of AI

Definition

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):

Four Approaches to Defining AI
Human-likeRational (ideal)
ThinkingThinking humanly: model the human mind (cognitive science)Thinking rationally: "laws of thought", logic
ActingActing humanly: pass the Turing testActing rationally: a rational agent that does the best action

Foundations of AI

AI borrows ideas from many older disciplines:

Foundation Disciplines and Their Contribution
DisciplineContribution to AI
PhilosophyLogic, reasoning, the mind as a physical system, knowledge and its sources
MathematicsFormal logic, computation and decidability, probability, optimisation
EconomicsDecision theory and utility, game theory, handling uncertainty and rewards
NeuroscienceHow neurons store and process information, inspiration for neural networks
PsychologyModels of perception, memory, learning and problem solving (cognitive science)
Computer engineeringFast hardware and software (GPUs, memory) that make AI practical
Control theoryFeedback, adaptive control, optimising behaviour over time
LinguisticsGrammar, meaning and structure of language for natural language processing

History of AI

Milestones in the History of AI
PeriodEvent
1943McCulloch and Pitts propose a model of artificial neurons
1950Turing publishes "Computing Machinery and Intelligence" and the Turing test
1956Dartmouth workshop: John McCarthy coins the term "Artificial Intelligence"
1950s–60sEarly optimism: Logic Theorist, General Problem Solver, LISP, ELIZA, perceptron
1966–73First setbacks: combinatorial explosion, limits of single-layer perceptrons
1969–86Knowledge-based expert systems (DENDRAL, MYCIN)
1974–80 and late 1980sAI winters: funding cuts after unmet promises
1986 onwardsBackpropagation revives neural networks; probabilistic methods rise
1997IBM Deep Blue beats world chess champion Kasparov
2000sBig data, machine learning and intelligent agents dominate
2011–12Watson wins Jeopardy!; deep learning wins ImageNet (AlexNet)
2016AlphaGo defeats Lee Sedol at Go
2017 onwardsTransformers, large language models and generative AI

1.2 Importance of knowledge and learning

Definition

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:

  1. Intelligence needs something to reason about. A chess program with no knowledge of the rules or of good positions can only try moves blindly.
  2. Knowledge narrows search. Heuristics and rules of thumb cut an exponentially large search space down to a manageable one.
  3. 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).
  4. It lets a system explain decisions by pointing to the rules used.

Why learning matters:

  1. Designers cannot foresee every situation. A learning agent adapts to new environments.
  2. Writing all the knowledge by hand is slow (the knowledge acquisition bottleneck). Learning lets the program acquire knowledge from data.
  3. 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.

A biological neuron and its artificial counterpartText
 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 versus Artificial Neuron
BiologicalArtificial
Dendrites receive signalsInputs
Synaptic strengthWeights
Soma sums signals and fires above a thresholdWeighted sum plus bias, then activation function
Axon carries outputOutput
Learning = change of synaptic strengthLearning = change of weights

How the brain learns, and the AI link:

1.4 Human intelligence and machine intelligence

AspectHuman IntelligenceMachine Intelligence
Speed of calculationSlow and error-prone for large numbersExtremely fast and exact
LearningLearns from very few examples, in any domainUsually needs large data and is narrow in one domain
Creativity and emotionHas imagination, emotions, intuition and moralsOnly imitates them from patterns, no real feeling
Common senseRich background knowledge of the worldWeak, often fails on simple everyday reasoning
MemoryLimited and forgetful, but associativeHuge, exact and permanent
FatigueGets tired, needs restWorks continuously without tiredness
AdaptabilityTransfers skills to new problems easilyPoor transfer, must be retrained
ConsciousnessSelf-awareNone (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.

The AI tree: main branchesText
                      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
Branches of AI
BranchWhat it doesExample
Search and planningFinds a sequence of actions to a goalRoute finding, game playing
Knowledge representation and reasoningStores facts and derives new onesLogic-based diagnosis
Machine learningLearns patterns from dataSpam filtering, recommendations
Natural language processingUnderstands and generates languageTranslation, chatbots
Computer visionInterprets images and videoFace recognition
RoboticsSenses and acts in the physical worldWarehouse robots
Expert systemsEncodes expert rules for adviceMedical diagnosis
Speech processingConverts speech to text and backVoice 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

Definition

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.

Agent and environmentText
          percepts                    ┌───────────────┐
  ┌─────────────────────────────────  │  ENVIRONMENT  │
  ▼                                   └───────────────┘
 SENSORS ─► [ AGENT PROGRAM: decide ] ─► ACTUATORS ─ actions ─► back to environment

PEAS description

To specify a task environment, give the PEAS: Performance measure, Environment, Actuators, Sensors.

PEAS of Some Agents
AgentPerformanceEnvironmentActuatorsSensors
Automated taxiSafe, fast, legal, comfortable trip, profitRoads, traffic, pedestrians, weatherSteering, accelerator, brake, signal, hornCameras, GPS, speedometer, lidar
Medical diagnosis systemHealthy patient, low costPatient, hospital, staffDisplay of tests and diagnosisKeyboard entry of symptoms and results
Vacuum cleaner robotCleanliness, battery use, timeRooms, dirt, furnitureWheels, brushes, suctionDirt sensor, bump sensor, camera
Spam filterFew false positives and negativesIncoming email streamMark as spam, move to folderEmail text and headers

Properties of task environments

Environment Properties
PropertyOne endOther end
ObservabilityFully observable (sensors give the whole state)Partially observable
AgentsSingle agentMulti-agent (competitive or cooperative)
DeterminismDeterministic (next state fixed by state and action)Stochastic (random effects)
EpisodesEpisodic (each step independent)Sequential (past actions matter)
ChangeStatic (waits for the agent)Dynamic (changes while agent thinks)
StatesDiscreteContinuous
KnowledgeKnown (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:

  1. 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.
  2. Model-based reflex agent: keeps an internal state (a model of how the world works) to handle partial observability.
  3. 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.
  4. 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.
  5. 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).
Structure of the five agent typesText
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
AspectGoal-based AgentUtility-based Agent
Decision ruleDoes the action reach the goal: yes or noHow good is the resulting state: a number
Handles trade-offsNoYes (speed versus safety)
Handles uncertaintyPoorlyMaximises expected utility
ExampleReach city BReach city B quickly, safely and cheaply

1.7 Agentic AI

Definition

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:

AspectGenerative AI ChatbotAgentic AI System
BehaviourReacts to one prompt with one replyPursues a goal over many steps
Tool useUsually noneCalls tools and APIs
AutonomyLow, the user drivesHigh, plans and acts on its own
MemoryWithin the chat windowPersistent memory across tasks
RiskWrong textWrong 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

Example 1.1

1.1 (6 marks)

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.

Answer:

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.

Example 1.2

1.2 (6 marks)

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.

Answer:

and , so the rational agent chooses .

Example 1.3

1.3 (6 marks)

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 .

Answer:

Total score .

Exercises

Exercise: Introduction to AI

Question 1

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.

Answer:

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.

Question 2

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.

Answer:

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.

Question 3

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.

Answer:

, . The agent chooses action .

Question 4

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).

Answer:

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.

Question 5

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.

Answer:

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.

Problem Solving and Search (part 1: 2.1–2.4) →