Professional Documents
Culture Documents
Lecture 1
Introduction
13-10-2022
Course Information
Course Code: Comp 401
Course Title: Artificial Intelligence
Number of Credit Hours: 3 (3 hours lecture + 0 lab.)
Prerequisite : -
Final Exam (duration): 3 hours
Total Marks: 150
◼ 105 Final Exam.
◼ 37 Quarterly Exam. (Midterm 27 Mark + Small Project 10 Marks)
◼ 8 Oral Exam.
Textbook
Stuart Russell and Peter Norvig (2020). Artificial
Intelligence: A Modern Approach (4th Edition),
Prentice Hall.
Course Objectives
Give a solid understanding of the definitions,
abstractions, reasoning techniques, and topics
related to the field of artificial intelligence (AI).
The focus is on:
Search strategies for solving problems in AI.
Knowledge representation and reasoning using first-
order logic.
Course Outline
Introduction.
Intelligent agent.
Problem-solving by searching.
Knowledge representation; types of reasoning;
logic languages; inferences in first-order logic.
Dealing with uncertainty.
Agenda of Lecture 1
What is AI?
Intelligent Agents.
Problem Solving by Searching
Problem formalization
State-space graph vs search tree
Thought 2
Think Humanly Think Rationally 1
time?
Intelligent Agents
An agent is an entity that can be viewed as perceiving its
environment through sensors and acting upon that
environment through actuators.
Examples
1. Human agent:
Sensors: eyes, ears, and other organs
Actuators: hands, legs, mouth, and other body parts
2. Robotic agent:
Sensors: cameras and infrared range finders
Actuators: various motors for actuators
Intelligent Agents (Cont.)
Examples
3. Software agent:
receives keystrokes, file contents, and network
packets as sensory inputs,
acts on the environment by displaying on the
screen, writing files, and sending network packets.
Agents and environments
Result ( 1 2 3 , left ) = 1 2 3
8 5 8 5
4 7 6 4 7 6
State Space
Transition model indicates how states and actions
are related to each other.
The initial state, actions, and transition model
define the state space of the problem—the set of
all states reachable from the initial state by any
sequence GRAPH of actions.
The state space forms is a graph G = (V, E):
V is a set of states (vertices)
E is a set of edges connecting the vertices through
actions.
Goal Test and Path Cost
Goal Test: A method to detect whether a given state
is a goal state or not.
Path Cost: numerical cost associated with a given
path.
It is desired to minimize the path cost as mush as
possible.
Search Problem
A search problem consists of
1. Initial state
2. State space
3. Goal test
4. Actions
5. Transition model
6. Action cost
A solution is a sequence of actions that leads from
the initial state to a goal state.
Example 1: Romania
On holiday in Romania; currently in Arad.
Flight leaves tomorrow from Airport in Bucharest
Formulate goal:
be in Bucharest
Formulate problem:
states: various cities
actions: drive between cities
Start state: Arad
Goal test: Is state = = Bucharest
Find solution:
sequence of cities from Arad to Bucharest, e.g., Arad, Sibiu,
Fagaras, Bucharest
Example 1: Romania
Example 2: The 8-puzzle
states?
actions?
goal test?
Example 2: The 8-puzzle
actions? move blank left, move blank right, move blank up, move
blank down
attacked.
State Space Graphs
State space graph: A mathematical
representation of a search problem
Nodes are (abstracted) world configurations a G
(states of the problem)
b c
Arcs represent successors (action results)
The goal test is a set of goal nodes (may be e
d f
only one)
S h
p r
In a search graph, each state occurs q
only once!
Tiny search graph for a tiny
We can rarely build this full graph in search problem
memory (it’s too big), but it’s a
useful idea.
Search Trees
A search tree:
The start state is the root node
Children correspond to successors
Nodes show states, but correspond to Actions that achieve those states
For most problems, we can never actually build the whole tree
State Space Graphs vs. Search Trees
Each NODE in
State Space Graph in the search Search Tree
tree is an entire S
PATH in the
a G d e p
b c
state space
graph. b c e h r q
e
d f a a h r p q f
S h We construct
p q f q c G
p q r both on demand
q c a
– and we G
construct as little a
as possible.
State Space Graphs vs. Search Trees
Consider this 4-state graph: How big is its search tree (from S)?
S G
Search:
Expand out potential plans (tree nodes)
Maintain a fringe of partial plans under consideration
Try to expand as few tree nodes as possible
General Tree Search
function Tree_Search (problem, strategy) returns a solution, or failure
initialize the search tree using the initial state of problem
loop do
if there are no candidates for expansion then return failure
choose a leaf node for expansion according to strategy
if the node contains a goal state then return the corresponding solution
else expand the node and add the resulting nodes to the search tree
end
Important ideas:
Fringe : set of leaf nodes that are waiting to be expanded
Expansion: pick one node out of the fringe and check if it is a goal or
not, if it not a goal expand it.
Exploration strategy: which node in the fringe you choose for expansion
Main question: which fringe nodes to explore?
Example: Tree Search
a G
b c
S : Initial state d
e
f
G: Goal state S h
p r
q
Depth-First Search
Depth-First Search
Strategy: expand a a G
b c
deepest node first
e
d f
Implementation: Fringe S h
is a LIFO stack p q r
d e p
b c e h r q
a a h r p q f
p q f q c G
q c G a
a
Search Algorithm Properties
Search Algorithm Properties
Is it complete?
m could be infinite; it is complete only
if we prevent cycles.
Is it optimal?
No, it finds the “leftmost” solution,
regardless of depth or cost
Breadth-First Search
Breadth-First Search
Strategy: expand a a G
b c
shallowest node first
e
d f
Implementation: Fringe is S h
a FIFO queue
p q r
d e p
Search
b c e h r q
Tiers
a a h r p q f
p q f q c G
q c G a
a
Breadth-First Search (BFS) Properties
What nodes does BFS expand?
Processes all nodes above shallowest
solution
1 node
Let depth of shallowest solution be s b
… b nodes
Search takes time O(bs) s tiers
b2 nodes
bs nodes
How much space does the fringe take?
Has roughly the last tier, so O(bs)
bm nodes
Is it complete?
s must be finite if a solution exists,
so yes!
Is it optimal?
Only if costs are all 1 (more on costs
later)