SlideShare a Scribd company logo
ARTIFICIAL
INTELLIGENCE
By: Dessalew G.
BOOK : Artificial Intelligence A Modern Approach
Stuart J. Russell and Peter Norvig
CHAPTER ONE
Introduction to AI
01/16/2025 3
LIST OF CONTENTS
1. Objectives/Goals of AI
2. What is AI?
3. Approaches to AI – making computer:
 Think like a human ( Thinking humanly)
 Act like a human (Acting humanly)
 Think rationally (Thinking rationally)
 Act rationally (Acting rationally)
4. The Foundations of AI
5. History and the State of the Art
01/16/2025 4
1. OBJECTIVES/GOALS OF AI
 Humankind has given itself the scientific name homo sapiens: man the wise
 It is because, our mental capacities are so important to our everyday lives and our
sense of self.
 The field of artificial intelligence, or AI, attempts to understand intelligent entities.
 Thus, one reason to study it is to learn more about ourselves.
 But unlike philosophy and psychology, which are also concerned with intelligence,
AI strives to build intelligent entities as well as understand them
01/16/2025 5
CONT…
 One of the goals of AI is to be a problem-solving machine.
 There are already many computers that can solve problems, but only in a limited
scope.
 This said, a computer can only solve problems it is programed to solve or has the
necessary information to solve; AIs do not yet have analytical capabilities.
 Although AI does not have analytical abilities, some AI’s are much more efficient at
solving problems than people are.
01/16/2025 6
CONT…
 AI addresses one of the ultimate puzzles.
 How is it possible for a slow, tiny brain, whether biological or electronic, to perceive,
understand, predict, and manipulate a world far larger and more complicated than
itself?
 Alongside problem solving, another purpose of AI is learning.
 Certain intelligent robots are able to achieve a desired result or overcome an
obstacle in an unfamiliar situation by attempting different routes and memorizing the
route that worked best, so they can be successful in the future when they are in a
similar situation.
01/16/2025 7
CONT…
 There is a limit to learning.
 Some robots observe when humans interact socially and pick up visual and audio
cues, allowing them to learn how to respond appropriately.
 Other robots learn by mimicking human action.
 However, AIs have no where near the learning capabilities of humans.
 In a Stanford University article about AI, it is written that robots are not able to
learn like children do.
 we might see it in the near future
01/16/2025 8
CONT…
 Some of the goals of AI like creating problem solving and learning machines are shared by
many experts in the field, but there is still a plethora of varying objectives when it comes to AI.
 The reason why there are no clear definitions or clear goals set for AI is because AI is still in its
developmental stages.
 Everyday researchers are bringing in new ideas to the field, meaning that AI is a malleable
concept that has many open-ended avenues.
 One of the trickiest and most complicated classifications of AI is that AI aims at human level
intelligence.
 Only time will tell us what AI is and what will come from it.
01/16/2025 9
2.WHAT IS AI
 We have now explained why AI is exciting, but we have not said what it is.
 We could just say, "Well, it has to do with smart programs, so let's get on and write
some.
 Artificial intelligence (AI): is intelligence demonstrated by machines, as
opposed to natural intelligence displayed by animals including humans.
 Leading AI textbooks define the field as the study of "intelligent agents": any
system that perceives its environment and takes actions that maximize its chance
of achieving its goals.
01/16/2025 10
CONT…
 Some popular accounts use the term "artificial intelligence" to describe machines that
mimic "cognitive" functions that humans associate with the human mind, such as "learning"
and "problem solving", however, this definition is rejected by major AI researchers.
 AI applications include:
 advanced web search engines (i.e. Google),
 recommendation systems (used by YouTube, Amazon and Netflix)
 understanding human speech (such as Siri and Alexa),
01/16/2025 11
CONT…
 self-driving cars (e.g.Tesla)
 automated decision-making and competing at the highest level in strategic game
systems (such as chess and Go).
 As machines become increasingly capable, tasks considered to require "intelligence"
are often removed from the definition of AI, a phenomenon known as the AI effect.
 For instance, optical character recognition is frequently excluded from things
considered to be AI, having become a routine technology.
01/16/2025 12
3. APPROACHES TO AI – MAKING COMPUTER:
 Definitions of artificial intelligence according to eight recent textbooks:
01/16/2025 13
3.1 THINKING HUMANLY: THE COGNITIVE MODELLING
APPROACH
 Once we have a sufficiently precise theory of the mind, it becomes possible to express the
theory as a computer program.
 If the program's input/output and timing behavior matches human behavior, that is evidence
that some of the program's mechanisms may also be operating in humans.
 The interdisciplinary field of cognitive science brings together computer models from AI
and experimental techniques from psychology to try to construct precise and testable
theories of the workings of the human mind.
01/16/2025 14
CONT…
 Real cognitive science, however, is necessarily based on experimental
investigation of actual humans or animals, and authors assume that the reader only
has access to a computer for experimentation.
 We will note that AI and cognitive science continue to fertilize each other,
especially in the areas of vision, natural language, and learning.
 How to validate?
 Predicting and testing behavior of human subjects (top-down)
 Direct identification from neurological data (bottom-up)
01/16/2025 15
3.2 ACTING HUMANLY: THE TURING TEST APPROACH
 Turing test: proposed by Alan Turing (1950), was designed to provide a
satisfactory operational definition of intelligence.
 Turing defined intelligent behavior as the ability to achieve human-level
performance in all cognitive tasks, sufficient to fool an interrogator.
 Roughly speaking, the test he proposed is that the computer should be
interrogated by a human via a teletype, and passes the test if the interrogator
cannot tell if there is a computer or a human at the other end.
01/16/2025 16
CONT…
 The computer would need to possess the following capabilities:
 Natural language processing: to enable it to communicate successfully in English (or
some other human language); knowledge representation to store information provided
before or during the interrogation;
 Knowledge representation: to store information provided before or during the
interrogation;
 Automated reasoning: to use the stored information to answer questions and to draw
new conclusions;
 machine learning: to adapt to new circumstances and to detect and extrapolate patterns
01/16/2025 17
CONT…
 Turing's test deliberately avoided direct physical interaction between the interrogator
and the computer, because physical simulation of a person is unnecessary for
intelligence.
 Total Turing Test includes a video signal so that the interrogator can test the subject's
perceptual abilities, as well as the opportunity for the interrogator to pass physical
objects "through the hatch.“
 To pass the total Turing Test, the computer will need:
 Computer vision: to perceive objects, and
 Robotics: to move them about.
01/16/2025 18
3.3 THINKING RATIONALLY: THE LAWS OF THOUGHT
APPROACH
 The Greek philosopher Aristotle was one of the first to attempt to codify "right
thinking," that is, irrefutable reasoning processes.
 His famous syllogisms provided patterns for argument structures that always gave
correct conclusions given correct premises.
 For example, "Socrates is a man; all men are mortal; therefore Socrates is mortal.“
 These laws of thought were supposed to govern the operation of the mind, and
initiated the field of logic
01/16/2025 19
CONT…
 The development of formal logic in the late nineteenth and early twentieth
centuries provided a precise notation for statements about all kinds of things in the
world and the relations between them
 By 1965, programs existed that could, given enough time and memory, take a
description of a problem in logical notation and find the solution to the problem, if
one exists
 If there is no solution, the program might never stop looking for it
 The so-called logicist tradition within artificial intelligence hopes to build on such
programs to create intelligent systems
01/16/2025 20
3.4 ACTING RATIONALLY: THE RATIONAL AGENT
APPROACH
 Acting rationally means acting so as to achieve one's goals, given one's beliefs
 An agent is just something that perceives and acts
 In the "laws of thought" approach to AI, the whole emphasis was on correct inferences.
 Making correct inferences is sometimes part of being a rational agent, because one way
to act rationally is to reason logically to the conclusion that a given action will achieve
one's goals, and then to act on that conclusion
 On the other hand, correct inference is not all of rationality, because there are often
situations where there is no provably correct thing to do, yet something must still be
done
01/16/2025 21
CONT…
 There are also ways of acting rationally that cannot be reasonably said to involve
inference.
 For example, pulling one's hand off of a hot stove is a reflex action that is more
successful than a slower action taken after careful deliberation.
 All the "cognitive skills" needed for the Turing Test are there to allow rational actions.
 Thus, we need the ability to represent knowledge and reason with it because this
enables us to reach good decisions in a wide variety of situations.
01/16/2025 22
CONT…
 The study of AI as rational agent design therefore has two advantages.
 First, it is more general than the "laws of thought" approach, because correct inference is
only a useful mechanism for achieving rationality, and not a necessary one.
 Second, it is more amenable to scientific development than approaches based on human
behavior or human thought, because the standard of rationality is clearly defined and
completely general.
 Human behavior, on the other hand, is well-adapted for one specific environment and is the
product, in part, of a complicated and largely unknown evolutionary process that still may
be far from achieving perfection.
01/16/2025 23
4.THE FOUNDATIONS OF ARTIFICIAL INTELLIGENCE
 Although AI itself is a young field, it has inherited many ideas, viewpoints, and techniques from
other disciplines.
 From over 2000 years of tradition in philosophy, theories of reasoning and learning have
emerged.
 From over 400 years of mathematics, we have formal theories of logic, probability, decision
making, and computation.
 From psychology, we have the tools with which to investigate the human mind, and a scientific
language within which to express the resulting theories.
 From linguistics, we have theories of the structure and meaning of language.
 Finally, from computer science, we have the tools with which to make AI a reality.
01/16/2025 24
5. HISTORY AND THE STATE OF THE ART
 Gestation (1943-1952)
 Early learning theory, first neural network,Turing test
 McCulloch and Pitts artificial neuron, Hebbian learning
 Birth (1952 - 1956)
 Name coined by McCarthy
 Workshop at Dartmouth
01/16/2025 25
CONT…
 Early enthusiasm, great expectations (1956-1966)
 GPS, physical symbol system hypothesis
 Geometry Theorem Prover (Gelertner), Checkers (Samuels)
 Lisp (McCarthy),Theorem Proving (McCarthy), Microworlds (Minsky et. al.)
 “neat” (McCarthy @ Stanford) vs.“scruffy” (Minsky @ MIT)
 Dose of Reality (1966-1973)
 Combinatorial explosion
01/16/2025 26
CONT…
 Knowledge-based systems (1969-1979)
 AI Becomes an Industry (1980-present)
 Boom period 1980-88, then AI Winter
 Return of Neural Networks (1986-present)
 AI Becomes a Science (1987-present)
 Security Orchestration, Automation and Response (SOAR)
 Internet as a domain
 The emergence of intelligent agents(1995-present)
01/16/2025 27
CONT…
State of the art
 Deep Blue defeated the reigning world chess champion Garry Kasparov in 1997
 Proved a mathematical conjecture (Robbins conjecture) unsolved for decades
 No hands across America (driving autonomously 98% of the time from Pittsburgh
to San Diego)
 During the 1991 Gulf War, US forces deployed an AI logistics planning and
scheduling program that involved up to 50,000 vehicles, cargo, and people
01/16/2025 28
CONT…
 NASA's on-board autonomous planning program controlled the scheduling of
operations for a spacecraft
 Proverb solves crossword puzzles better than most humans
01/16/2025 29
THE END OF CHAPTER ONE
CHAPTER TWO
Intelligent Agents
01/16/2025 31
LIST OF CONTENTS
1. Introduction
2. Agents and Environments
3. Acting of Intelligent Agents
(Rationality)
4. Structure of Intelligent Agents
5. Agent Types
 Simple reflex agent
 Model-based reflex agent
 Goal-based agent
 Utility-based agent
 Learning agent
6. Important Concepts and Terms
01/16/2025 32
1. INTRODUCTION
 An agent is anything that can be viewed as perceiving its environment through
sensors and acting upon that environment through effectors
 A human agent has eyes, ears, and other organs for sensors, and hands, legs,
mouth, and other body parts for effectors.
 A robotic agent substitutes cameras and infrared range finders for the sensors and
various motors for the effectors
 A software agent has encoded bit strings as its percepts and actions
01/16/2025 33
CONT…
01/16/2025 34
2. AGENTS AND ENVIRONMENTS
 Actions are done by the agent on the environment, which in turn provides percepts to the agent
 Task environments are the problems While the rational agents are the solutions
 Specifying the task environment, apply PEAS description as fully as possible
 Performance
 Environment
 Actuators
 Sensors
 In designing an agent, the first step must always be to specify the task environment as fully as
possible
01/16/2025 35
CONT…
 Take taxi driver as an example, the following are the task environment
descriptions.
Agent type Performance
measure
Environment Actuator Sensor
Taxi driver Safe, fast, legal,
comfortable
trip, maximize
profits.
Roads, other
traffic,
pedestrians,
customers.
Steering,
accelerator,
break, signal,
horn, display.
Cameras, sonar,
speedometer,
GPS, odometer,
accelerometer,
engine sensor,
keyboard.
01/16/2025 36
CONT…
 Properties of environment
 Accessible vs. inaccessible.
If an agent's sensory apparatus gives it access to the complete state of the
environment, then we say that the environment is accessible to that agent
An environment is effectively accessible if the sensors detect all aspects that
are relevant to the choice of action
An accessible environment is convenient because the agent need not
maintain any internal state to keep track of the world
01/16/2025 37
CONT…
Deterministic vs. nondeterministic
If the next state of the environment is completely determined by the current
state and the actions selected by the agents, then we say the environment is
deterministic otherwise it is nondeterministic (stochastic).
In principle, an agent need not worry about uncertainty in an accessible,
deterministic environment.
If the environment is inaccessible, however, then it may appear to be
nondeterministic.
01/16/2025 38
CONT…
This is particularly true if the environment is complex, making it hard to keep
track of all the inaccessible aspects
Thus, it is often better to think of an environment as deterministic or
nondeterministic from the point of view of the agent
Strategic environment: is deterministic except for actions of other agents
Cleaner and taxi driver are:
 Stochastic because of some unobservable aspects -noise or unknown
01/16/2025 39
CONT…
Episodic vs. non-episodic
In an episodic environment, the agent's experience is divided into "episodes.“
 Each episode consists of the agent perceiving and then acting.
The quality of its action depends just on the episode itself
Because subsequent episodes do not depend on what actions occur in previous episodes.
Episodic environments are much simpler because the agent does not need to think ahead.
If Current action may affect all future decisions, then it is non-episodic or sequential
An example is taxi driver
01/16/2025 40
CONT…
Static vs. dynamic
If the environment can change while an agent is deliberating, then we say the environment is
dynamic for that agent, otherwise it is static
Static environments are easy to deal with because the agent need not keep looking at the world
while it is deciding on an action, nor need it worry about the passage of time
If the environment does not change with the passage of time but the agent's performance score
does, then we say the environment is semi-dynamic
• An example of dynamic environment: the number of people in the street (taxi)
• An example of static environment: the destination (taxi)
01/16/2025 41
CONT…
Discrete vs. continuous
If there are a limited number of distinct, clearly defined percepts and actions, we
say that the environment is discrete.
Chess is discrete: there are a fixed number of possible moves on each turn.
Taxi driving is continuous: the speed and location of the taxi and the other
vehicles sweep through a range of continuous values
01/16/2025 42
CONT…
Single agentVS. multi-agent
Playing a crossword puzzle: single agent
Chess playing: two agents
Competitive multi-agent environment
• Chess playing
Cooperative multi-agent environment
• Automated taxi driver: avoiding collision
01/16/2025 43
CONT…
 An examples of properties of an environment
01/16/2025 44
3. ACTING OF INTELLIGENT AGENTS
(RATIONALITY)
 Rational agent
 One that does the right thing
 Every entry in the table for the agent function is correct (rational)
 What is correct?
 The actions that cause the agent to be most successful
 The problem is deciding how and when to evaluate the agent's success
 We use the term performance measure for the how the criteria that determine
how successful an agent is
01/16/2025 45
CONT…
 Performance measure
 An objective function that determines how the agent does successfully
 E.g., 90% or 30% ?
 An agent, based on its percepts:
 If desirable, it is said to be performing well
 No universal performance measure for all agents
01/16/2025 46
CONT…
 Consider the case of an agent that is supposed to vacuum a dirty floor:
A plausible performance measure would be the amount of dirt cleaned up in a
single eight-hour shift.
A more sophisticated performance measure would factor in the amount of
electricity consumed and the amount of noise generated as well.
A third performance measure might give highest marks to an agent that not only
cleans the floor quietly and efficiently, but also finds time to go windsurfing at the
weekend
01/16/2025 47
CONT…
 Rationality
What is rational at any given time depends on four things:
 The performance measure defining the degree of success
 The agent's percept sequence up to now (perceptual history)
 The agent’s prior knowledge of the environment
 The actions that the agent can perform
01/16/2025 48
CONT…
 Ideal rational agent
For each possible percept sequence, an ideal rational agent should:
Do whatever action is expected
To maximize its performance measure, on the basis of the evidence provided
By the percept sequence and
Whatever built-in knowledge the agent has.
 E.g.Taxi driver have to look right and left while crossing
01/16/2025 49
CONT…
 An omniscient agent
 Knows the actual outcome of its actions in advance
 No other possible outcomes
 However, impossible in real world
An example:
crossing a street but died of the fallen cargo door from 33,000ft
o Rational but not omniscient
o Hence, all rational agents are not omniscient
01/16/2025 50
CONT…
 Autonomy
If an agent just relies on the prior knowledge of its designer rather than its own
percepts then the agent lacks autonomy.
 A rational agent should be autonomous: it should learn what it can to compensate for
partial or incorrect prior knowledge.
 E.g. a clock
 No input (percepts)
 Run only by its own algorithm (prior knowledge)
 No learning, no experience, etc.
01/16/2025 51
4.STRUCTURE OF INTELLIGENT AGENTS
 So far we have talked about agents by describing their behavior
Action that is performed after any given sequence of percepts
 Now, we will talk about how the insides work.
 The job of AI is to design the agent program: a function that implements the agent
mapping from percepts to actions
 Agent = architecture + program
 Architecture = some sort of computing device (sensors + actuators)
 (Agent) Program = some function that implements the agent mapping = “?”
01/16/2025 52
CONT…
 Before we design an agent program, we must have a pretty good idea of the
possible:
percepts and actions,
what goals or performance measure the agent is supposed to achieve,
what sort of environment it will operate in.
 These come in a wide variety
01/16/2025 53
CONT…
 Basic elements for a selection of agent types:
01/16/2025 54
CONT…
 Agent programs
All agent programs have the same skeleton, namely, accepting percepts from an
environment and generating actions
The early versions of agent programs will have a very simple form
This skeleton has two issues:
01/16/2025 55
CONT…
1. First, even though we defined the agent mapping as a function from percept
sequences to actions, the agent program receives only a single percept as its
input.
2. Second, the goal or performance measure is not part of the skeleton program.
Then what is the solution?
The simplest possible way we can think of to write the agent program is a lookup
table
It operates by keeping in memory its entire percept sequence, and using it to index
into table, which contains the appropriate action for all possible percept
01/16/2025 56
CONT…
 It keeps track of the percept sequence and just looks up the best
action.
o P = the set of possible percepts
o T= lifetime of the agent
o The total number of percepts it receives
o Size of the look up table  
T
t
t
P
1
o Consider playing chess
o P =10,T=150
o Will require a table of
at least 10150
entries
01/16/2025 57
5. AGENT TYPES
 Four types
 Simple reflex agents
 Model-based reflex agents
 Goal-based agents
 Utility-based agents
01/16/2025 58
CONT…
 Simple reflex agents
 It uses just condition-action rules
 The rules are like the form “if … then …”
 Efficient but have narrow range of applicability
 Because knowledge sometimes cannot be stated explicitly
 Work only if the environment is fully observable
01/16/2025 59
CONT…
 Schematic diagram of a simple reflex agent
01/16/2025 60
CONT…
 The agent program for simple reflex agent:
01/16/2025 61
CONT…
 Model-based Reflex Agents
For the world that is partially observable:
 The agent has to keep track of an internal state
 That depends on the percept history
 Reflecting some of the unobserved aspects
 E.g., driving a car and changing lane
 Requiring two types of knowledge
 How the world evolves independently of the agent
 How the agent’s actions affect the world
01/16/2025 62
CONT…
 Schematic diagram of model-based agent
01/16/2025 63
CONT…
 Agent program for model-based agent
01/16/2025 64
CONT…
 Goal-based agent
 Knowing about the current state of the environment is not always enough to
decide what to do
 As well as a current state description, the agent needs some sort of goal
information
 Goal-based agents are less efficient but, more flexible
 Agent  Different goals  different tasks
 Search and planning are two other sub-fields in AI to find out the action
sequences to achieve its goal
01/16/2025 65
CONT…
 Schematic diagram of goal-based agent

01/16/2025 66
CONT…
 Agent program for goal-based agent
01/16/2025 67
CONT…
 Utility-based agents
 Goals alone are not enough to generate high-quality behavior
 For example, there are many action sequences that will get the taxi to its destination
 Thereby achieving the goal, but some are quicker, safer, more reliable, or cheaper than
others.
 Goals just provide a crude distinction between "happy" and "unhappy" states
 whereas a more general performance measure should allow a comparison of different
world states (or sequences of states) according to exactly how happy they would make the
agent if they could be achieved
01/16/2025 68
CONT…
 Because "happy" does not sound very scientific, the customary terminology is to
say that if one world state is preferred to another, then it has higher utility for the
agent.
 Utility is therefore a function that maps a state onto a real number, which describes
the associated degree of happiness.
 It is said state A has higher utility If state A is more preferred than others
 Then utility means the degree of success
01/16/2025 69
CONT…
 Schematic diagram of utility-based agent
01/16/2025 70
CONT…
 Learning agent
After an agent is programmed, can it work immediately?
 No, it still need teaching
In AI,
 Once an agent is done
 We teach it by giving it a set of examples
 Test it by using another set of examples
We then say the agent learns
 A learning agent
01/16/2025 71
CONT…
Four conceptual components
 Learning element
 Making improvement
 Performance element
 Selecting external actions
01/16/2025 72
CONT…
 Critic
 Tells the Learning element how well the agent is doing with respect to fixed
performance standard.
 (Feedback from user or examples, good or not?)
 Problem generator
 Suggest actions that will lead to new and informative experiences.
01/16/2025 73
CONT…
 Schematic diagram of learning agent
01/16/2025 74
6. IMPORTANT CONCEPTS AND TERMS
 Percept
 Agent’s perceptual inputs at any given instant
 Percept sequence
 Complete history of everything that the agent has ever perceived.
 Agent function & program
Agent’s behavior is mathematically described by
 Agent function: it is a function mapping any given percept sequence to an
action
 Practically it is described by:
 An agent program (the real implementation)
01/16/2025 75
CONT…
 Vacuum-cleaner world
Perception: Clean or Dirty? where it is in?
Actions: Move left, Move right, suck, do nothing
01/16/2025 76
CONT…
 Partial tabulation of a simple agent function for Vacuum-cleaner world
01/16/2025 77
CONT…
 Program implementation Vacuum-cleaner world
Function Reflex-Vacuum-Agent([location, status]) return an
action
If status = Dirty then return Suck
else if location = A then return Right
else if location = B then return left
01/16/2025 78
THE END OF CHAPTER TWO
CHAPTER THREE
Solving Problems by Searching and
Constraint Satisfaction Problem
01/16/2025 80
LIST OF CONTENTS
1. Problem Solving by Searching
2. Problem Solving Agents
3. Problem Formulation
4. Search Strategies
5. Avoiding Repeated States
6. Constraint Satisfaction Search
7. Games as Search Problems
01/16/2025 81
1. PROBLEM SOLVING BY SEARCHING
 Simple reflex agents are limited in what they can do
 Because, their actions are determined only by the current percept
 Furthermore, they have no knowledge of what their actions do nor of what they are
trying to achieve
 They can’t work well in environments
which this mapping would be too large to store
and would take too long to learn
 Hence, goal-based agent is used
01/16/2025 82
CONT…
 Goal-based agents can succeed by considering future actions and the desirability
of their outcomes
 Goal-based agents that use more advanced factored or structured representations
are usually called planning agents
 Uninformed and informed search algorithms are used to create solution for
problems
01/16/2025 83
2. PROBLEM-SOLVING AGENTS
 Problem-solving agent is A kind of goal-based agent, It solves problem by finding
sequences of actions that lead to desirable states (goals)
 To solve a problem, the first step is the goal formulation, based on the current
situation
 The goal is formulated as a set of world states, in which the goal is satisfied
01/16/2025 84
CONT…
 To reaching from initial state to goal state
Actions are required
 Actions are the operators
causing transitions between world states
Actions should be abstract enough at a certain degree, instead of very detailed
E.g., turn left VS turn left 30 degree, etc.
01/16/2025 85
3. PROBLEM FORMULATION
 Problem formulation: is the process of deciding what actions and states to consider,
and follows goal formulation
 An agent with several immediate options of unknown value can decide what to do by
first examining ; different possible sequences of actions that lead to states of known
value, and then choosing the best one
 This process of looking for such a sequence is called search
 A search algorithm takes a problem as input and returns a solution in the form of an
action sequence
01/16/2025 86
CONT…
 Once a solution is found, the actions it recommends can be carried out.
 This is called the execution phase
 Thus, we have a simple "formulate, search, execute" design for the agent
 There are four essentially different types of problems:
Single state problems,
Multiple-state problems,
Contingency problems, and
Exploration problems
R
e
a
d
i
n
g
a
s
s
i
g
n
m
e
n
t
01/16/2025 87
CONT…
01/16/2025 88
CONT…
 Well-defined problems and solutions
A problem is really a collection of information that the agent will use to decide what to do
A problem is defined by 5 components:
Initial state
Actions
Transition model or (Successor functions)
 Goal Test
Path Cost
01/16/2025 89
CONT…
The initial state that the agent knows itself to be in.
The set of possible actions available to the agent.
The term operator is used to denote the description of an action in terms of
which state will be reached by carrying out the action in a particular state
(An alternate formulation uses a successor function S.
Together, these define the state space of the problem: the set of all states
reachable from the initial state by any sequence of actions.
01/16/2025 90
CONT…
A path in the state space is simply any sequence of actions leading from one state to another
The goal test applied to the current state to test if the agent is in its goal
Sometimes there is an explicit set of possible goal states
Sometimes the goal is described by the properties instead of stating explicitly the set of
states
Example: Chess
o The agent wins if it can capture the KING of the opponent on next move ( checkmate).
o No matter what the opponent does
01/16/2025 91
CONT…
A path cost function is a function that assigns a cost to a path.
The cost of a path is the sum of the costs of the individual actions along the path.
The path cost function is often denoted by g
The solution of a problem is then a path from the initial state to a state satisfying the
goal test
Optimal solution is the solution with lowest path cost among all solutions
01/16/2025 92
CONT…
 Measuring problem-solving performance
Completeness: is the strategy guaranteed to find a solution when there is
one?
Optimality: does the strategy find the highest-quality solution when there are
several different solutions?
Time complexity: how long does it take to find a solution?
Space complexity: how much memory is needed to perform the search?
01/16/2025 93
CONT…
In AI, complexity is expressed in
b, branching factor, maximum number of successors of any node
d, the depth of the shallowest goal node.
(depth of the least-cost solution)
m, the maximum length of any path in the state space
Time and Space is measured in
number of nodes generated during the search
maximum number of nodes stored in memory
01/16/2025 94
CONT…
For effectiveness of a search algorithm
we can just consider the total cost
The total cost = path cost (g) of the solution found + search cost
search cost = time necessary to find the solution
Tradeoff:
(long time, optimal solution with least g)
vs. (shorter time, solution with slightly larger path cost g)
01/16/2025 95
4. SEARCH STRATEGIES
 Because there are many ways to achieve the same goal
Those ways are together expressed as a tree
Multiple options of unknown value at a point,
the agent can examine different possible sequences of actions, and choose
the best
This process of looking for the best sequence is called search
The best sequence is then a list of actions, called solution
01/16/2025 96
CONT…
 It is helpful to think of the search process as building up a search tree
 The root of the search tree is a search node corresponding to the initial state
 The leaf nodes of the tree correspond to states that do not have successors in the
tree,
It is either because they have not been expanded yet, or
because they were expanded, but generated the empty set
 At each step, the search algorithm chooses one leaf node to expand
01/16/2025 97
CONT…
01/16/2025 98
CONT…
 The majority of work in the area of search has gone into finding the right search strategy
for a problem
 In our study of the field we will evaluate strategies in terms of four criteria:
1. Completeness: is the strategy guaranteed to find a solution when there is one?
2. Time complexity: how long does it take to find a solution?
3. Space complexity: how much memory does it need to perform the search?
4. Optimality: does the strategy find the highest-quality solution when there are
several different solutions
01/16/2025 99
CONT…
 Uninformed search (blind search)
no information about the number of steps
or the path cost from the current state to the goal
search the state space blindly
 Informed search, or heuristic search
a cleverer strategy that searches toward the goal,
based on the information from the current state so far
01/16/2025 100
CONT…
 The six Uninformed search strategies
Breadth-first search
Uniform cost search
Depth-first search
Depth-limited search
Iterative deepening search
Bidirectional search
01/16/2025 101
CONT…
 Breadth-first search
The root node is expanded first (FIFO)
All the nodes generated by the root node are then expanded
And then their successors and so on
In general, all the nodes at depth d in the search tree are expanded before the nodes at
depth d + 1
Can be implemented by GENERAL SEARCH algorithm
01/16/2025 102
CONT…
01/16/2025 103
CONT…
 Breadth first search analysis
Complete – find the solution eventually
Optimal, if step cost is 1
The disadvantage
if the branching factor of a node is large, for even small instances (e.g.,
chess)
the space complexity and the time complexity are enormous
01/16/2025 104
CONT…
 Properties of breadth-first search
Complete? Yes (if b is finite)
Time? 1+b+b2
+b3
+… +bd
= b(bd
-1) = O(bd+1
)
Space? O(bd+1
) (keeps every node in memory)
Optimal? Yes (if cost = 1 per step)
Space is the bigger problem (more than time)
01/16/2025 105
CONT…
 assuming 10,000 nodes can be processed per second, each with 1000 bytes of
storage:
01/16/2025 106
CONT…
 Uniform cost search
Breadth-first finds the shallowest goal state
but not necessarily be the least-cost solution
work only if all step costs are equal
Uniform cost search
modifies breadth-first strategy
by always expanding the lowest-cost node
The lowest-cost node is measured by the path cost g(n)
01/16/2025 107
CONT…
 It is easy to see that breadth-first search is just uniform cost search with g(n) =
DEPTH(n)
 When certain conditions are met:
the first solution that is found is guaranteed to be the cheapest solution,
because if there were a cheaper path that was a solution,
it would have been expanded earlier, and thus would have been found first
01/16/2025 108
CONT…
 Consider the following route finding problem
A route-finding problem:
(a) The state space, showing the cost for each
operator,
(b) Progression of the search.
Each node is labelled with g(n).
At the next step, the goal node with g = 10
will be selected
01/16/2025 109
CONT…
 The problem is to get from S to G and the cost of each operator is marked
 The strategy first expands the initial state, yielding paths to A, B, and C
 Because the path to A is cheapest, it is expanded next, generating the path SAG,
which is in fact a solution, though not the optimal one
 However, the algorithm does not yet recognize this as a solution, because it has cost
11, and thus is buried in the queue below the path SB, which has cost 5
 The next step is to expand SB, generating SBG, which is now the cheapest path
remaining in the queue, so it is goal-checked and returned as the solution
01/16/2025 110
CONT…
 Uniform cost search finds the cheapest solution provided a simple requirement is met:
 The cost of a path must never decrease as we go along the path.
 In other words, we insist that:
g(SUCCESSOR(n)) > g(n)
for every node n
 The cost of a path can never decrease as we go along the path, unless it is negative and
uniform-cost search can find the cheapest path without exploring the whole search tree
01/16/2025 111
CONT…
 Depth-first search
 Depth-first search always expands one of the nodes at the deepest level of the tree
 Only when the search hits a dead end (a non-goal node with no expansion) does
the search go back and expand nodes at shallower levels
 This strategy can be implemented by GENERAL-SEARCH
with a queuing function
that always puts the newly generated states at the front of the queue.
01/16/2025 112
CONT…
 Because the expanded node was the deepest, its successors will be even deeper and are
therefore now the deepest
 Depth-first search has very modest memory requirements.
 It needs to store only a single path from the root to a leaf node
 along with the remaining unexpanded sibling nodes for each node on the path
 branching factor b and max depth m, depth-first search requires storage of only bm nodes,
 in contrast to the bd
that would be required by breadth-first search in the case where the shallowest
goal is at depth d.
01/16/2025 113
CONT…
 E.g
S
A D
B D A E
C E E B B F
D F B F C E A C G
G C G F
14
19 19 17
17 15 15 13
G
25
11
01/16/2025 114
CONT…
 The drawback of depth-first search is that it can get stuck going down the wrong path
 Many problems have very deep or even infinite search trees, so depth-first search will
never be able to recover from an unlucky choice at one of the nodes near the top of
the tree
 That means depth-first search is neither complete nor optimal
 Because of this, depth-first search should be avoided for search trees with large or
infinite maximum depths
01/16/2025 115
CONT…
 Depth limited search
 Depth-limited search avoids the pitfalls of depth-first search by imposing a cutoff
on the maximum depth of a path
 This cutoff can be implemented with a special depth-limited search algorithm
 We are guaranteed to find the solution if it exists, but we are still not guaranteed to
find the shortest solution first
 depth-limited search is complete but not optimal
01/16/2025 116
CONT…
 If we choose a depth limit that is too small, then depth-limited search is not even
complete
 The time and space complexity of depth-limited search is similar to depth-first
search
 It takes O(bl
) time and O(bl
) space, where l is the depth limit
01/16/2025 117
CONT…
 Iterative deepening search
The hard part about depth-limited search is picking a good limit
For most problems, we will not know a good depth limit until we have solved the
problem
Iterative deepening search: is a strategy that sidesteps the issue of choosing the
best depth limit by trying all possible depth limits
Iterative deepening combines the benefits of depth-first and breadth-first
search
01/16/2025 118
CONT…
It is optimal and complete:
 like breadth-first search,
but has only the modest memory requirements of depth-first search
The order of expansion of states is similar to breadth-first, except that some states
are expanded multiple times
01/16/2025 119
CONT…
E.g Four iterations of
iterative deepening
search on a binary tree
01/16/2025 120
CONT…
 Properties of iterative deepening search
Complete? Yes
Time? (d+1)b0
+ d b1
+ (d-1)b2
+ … + bd
= O(bd
)
Space? O(bd)
Optimal? Yes, if step cost = 1
In general, iterative deepening is the preferred search method when there is a
large search space and the depth of the solution is not known.
01/16/2025 121
CONT…
 Bidirectional search
Run two simultaneous searches:
one forward from the initial state another backward from the goal
stop when the two searches meet
For problems where the branching factor is b in both directions:
 bidirectional search can make a big difference
01/16/2025 122
CONT…
If we assume as usual that there is a solution of depth d:
then the solution will be found in O(2bd/2
) = O(bd/2
) steps,
because the forward and backward searches each have to go only half way.
However, computing backward is difficult
The main question is, what does it mean to search backwards from the goal?
Searching backward means generating predecessors successively starting
from the goal node.
can the actions be reversible to compute its predecessors?
01/16/2025 123
CONT…
What can be done if there are many possible goal states?
We need to decide what kind of search is going to take place in each half
For example the following figure shows two breadth-first searches
01/16/2025 124
CONT…
 Comparing search strategies
01/16/2025 125
5. AVOIDING REPEATED STATES
 Up to this point,
we have all but ignored one of the most important complications to the search
process:
the possibility of wasting time by expanding states that have already been
encountered and expanded before on some other path
For example: rout finding problem
This may cause the path to be infinite  loop forever
Even if the tree is finite, avoiding repeated states can yield an exponential
reduction in search cost
01/16/2025 126
CONT…
 E.g.
A state space that generates an exponentially
larger search tree.
The left-hand side shows the state space,
in which there are two possible actions leading
from A to B, two from B to C, and so on.
The right-hand side shows the
corresponding search tree.
01/16/2025 127
CONT…
 There are three ways to deal with repeated states
1. Do not return to the state you just came from
2. Do not create paths with cycles in them
3. Do not generate any state that was ever generated before
01/16/2025 128
6. CONSTRAINT SATISFACTION SEARCH
 A constraint satisfaction problem (or CSP):
 is a special kind of problem
that satisfies some additional structural properties
beyond the basic requirements
 In a CSP, the states are defined by the values of a set of variables and the goal test
specifies a set of constraints that the values must obey
01/16/2025 129
CONT…
 For example, the 8-queens problem can be viewed as a CSP
 variables are the locations of each of the eight queens;
the possible values are squares on the board;
the constraints state that no two queens can be in the same row, column or
diagonal
 Each variable Vi in a CSP has a domain Di, which is the set of possible values that
the variable can take on
The domain can be discrete or continuous
01/16/2025 130
CONT…
 Let us first consider how we might apply a general-purpose search algorithm to a
CSP:
The initial state will be the state in which all the variables are unassigned
Operators will assign a value to a variable from the set of possible values
The goal test will check if all variables are assigned and all constraints satisfied
Notice that, the maximum depth of the search tree is fixed at n, the number of
variables,
and that all solutions are at depth n
01/16/2025 131
CONT…
We are therefore safe in using depth-first search,
as there is no danger of going too deep and no arbitrary depth limit is needed
Depth-first search on a CSP wastes time searching when constraints have
already been violated
Because of the way that the operators have been defined, an operator can never
redeem a constraint that has already been violated
01/16/2025 132
CONT…
For example, suppose that we put the first two queens in the top row
Depth-first search will examine all 86
possible positions for the remaining six queens
before discovering that no solution exists in that subtree
Our first improvement is therefore to insert a test before the successor generation step
to check whether any constraint has been violated by the variable assignments made
up to this point
The resulting algorithm, called backtracking search, then backtracks to try something
else.
01/16/2025 133
CONT…
Backtracking also has some obvious failings
Suppose that the squares chosen for the first six queens make it impossible to
place the eighth queen,
because they attack all eight squares in the last column.
Backtracking will try all possible placings for the seventh queen, even though the
problem is already rendered unsolvable, given the first six choices
Forward checking avoids this problem by looking ahead to detect un-solvability
01/16/2025 134
7. GAMES AS SEARCH PROBLEMS
 Games have engaged the intellectual faculties of humans sometimes to an alarming
degree for as long as civilization has existed
 Board games such as chess and Go are interesting in part because they offer pure,
abstract competition, without the fuss and bother of mustering up two armies and
going to war
 It is this abstraction that makes game playing an appealing target of AI research.
 The state of a game is easy to represent, and agents are usually restricted to a fairly
small number of well-defined actions
01/16/2025 135
CONT…
 That makes game playing an idealization of worlds in which hostile agents act so as
to diminish one's well-being
 Less abstract games, such as croquet or football, have not attracted much interest in
the AI community
 Early researchers chose chess for several reasons
 A chess-playing computer would be an existence proof of a machine doing
something thought to require intelligence
01/16/2025 136
CONT…
 Perfect decisions in two-person games
 We will consider game with two players, whom we will call MAX and M1N
 MAX moves first, and then they take turns moving until the game is over
 At the end of the game, points are awarded to the winning player (or sometimes
penalties are given to the loser)
 A game can be formally defined as a kind of search problem with the following
components:
01/16/2025 137
CONT…
 The initial state, which includes the board position and an indication of whose move it is
 A set of operators, which define the legal moves that a player can make
 A terminal test, which determines when the game is over
 A terminal states is states where the game has ended
 A utility function (also called a payoff function), which gives a numeric value for the
outcome of a game
01/16/2025 138
CONT…
 The minimax algorithm is designed to determine the optimal strategy for MAX,
and thus to decide what the best first move is
 The algorithm has five steps:
1. Generate the whole game tree, all the way down to the terminal states
2. Apply the utility function to each terminal state to get its value
3. Use the utility of the terminal states to determine the utility of the nodes one
level higher up in the search tree
01/16/2025 139
CONT…
4. Continue backing up the values from the leaf nodes toward the root, one layer at
a time
5. Eventually, the backed-up values reach the top of the tree; at that point, MAX
chooses the move that leads to the highest value
01/16/2025 140
CONT…
 Imperfect decisions
 The minimax algorithm assumes that the program has time to search all the way to
terminal states, which is usually not practical
 Shannon's original paper on chess proposed that instead of going all the way to
terminal states and using the utility function, the program should cut off the search
earlier and apply a heuristic evaluation function to the leaves of the tree
 An evaluation function returns an estimate of the expected utility of the game from a
given position
01/16/2025 141
CONT…
 Alpha-beta pruning
 It is possible to compute the correct minimax decision without looking at every
node in the search tree.
 The process of eliminating a branch of the search tree from consideration without
examining it is called pruning the search tree
01/16/2025 142
CONT…
 Games that include an element of chance
 In real life, unlike chess, there are many unpredictable external events that put us
into unforeseen situations
 Many games mirror this unpredictability by including a random element such as
throwing dice
 In this way, they take us a step nearer reality, and it is worthwhile to see how this
affects the decision-making process
01/16/2025 143
CONT…
 Backgammon is a typical game that combines luck and skill
 Dice are rolled at the beginning of a player's turn to determine the set of legal
moves that is available to the player
01/16/2025 144
CONT…
 State of the art
Chess
Checkers or Draughts
Othello
Backgammon
Go
01/16/2025 145
THE END OF CHAPTER THREE
CHAPTER FOUR
Knowledge and Reasoning
01/16/2025 147
LIST OF CONTENTS
1. Logical Agents
2. Propositional Logic
3. Predicate (First-Order)Logic
4. Inference in First-Order Logic
5. Knowledge-based Systems (prolog)
01/16/2025 148
1. LOGICAL AGENTS
 Knowledge-based agents are able to accept new tasks in the form of explicitly
described goals.
they can achieve competence quickly by being told or learning new knowledge
about the environment
they can adapt to changes in the environment by updating the relevant
knowledge
A knowledge-based agent needs to know many things:
01/16/2025 149
CONT…
the current state of the world
how to infer unseen properties of the world from percepts
how the world evolves over time
what it wants to achieve
what its own actions do in various circumstances
01/16/2025 150
CONT…
 The central component of a knowledge-based agent is, its knowledge base, or KB
 knowledge base is a set of representations of facts about the world
 Each individual representation is called a sentence
 The sentences are expressed in a language called a knowledge representation language
 There must be a way to add new sentences to the knowledge base, and a way to query
what is known
 The standard names for these tasks are TELL and ASK, respectively
01/16/2025 151
CONT…
 Determining what follows from what the KB has been TELLed is the job of the
inference mechanism
 At any point, we can describe a knowledge-based agent at three levels:
1. The knowledge level or epistemological level: is the most abstract; we can
describe the agent by saying what it knows
2. The logical level: is the level at which the knowledge is encoded into sentences
3. The implementation level: is the level that runs on the agent architecture
01/16/2025 152
1.1 THE WUMPUS WORLD ENVIRONMENT
 Wumpus world: provides plenty of motivation for logical reasoning
 Wumpus was an early computer game, based on an agent who explores a cave
consisting of rooms connected by passageways
Lurking somewhere in the cave is the wumpus, a beast that eats anyone who enters its
room
The only mitigating feature of living in this environment is the occasional heap of gold
 How wompus world environment works has been discussed next:
01/16/2025 153
CONT…
Specifying the environment
Like the vacuum world, the wumpus world
is a grid of squares surrounded by walls,
where each square can contain agents and objects.
The agent always starts in the lower left corner,
a square that we will label [1,1].
The agent's task is to find the gold, return to [1,1]
and climb out of the cave.
01/16/2025 154
CONT…
Figure one Figure two
01/16/2025 155
CONT…
 From the fact that there was no stench or breeze in [1,1],
 the agent can infer that [1,2] and [2,1] are free of dangers.
 They are marked with an OK to indicate this.
 From the fact that the agent is still alive, it can infer that [1,1 ] is also OK.
 A cautious agent will only move into a square that it knows is OK.
 Let us suppose the agent decides to move forward to [2,1], giving the scene in
Figure one(b).
01/16/2025 156
CONT…
 The agent detects a breeze in [2,1], so there must be a
pit in a neighboring square, either [2,2] or [3,1].
 The notation P? indicates a possible pit.
 The pit cannot be in [1,1], because the agent was already there and did not fall in.
 At this point, there is only one known square that is OK and has not been visited yet.
 So the prudent agent will turn around, go back to [1,1], and then proceed to [1,2],
giving the state of knowledge in Figure two(a).
01/16/2025 157
CONT…
 The agent detects a stench in [1,2], which means that there must be a wumpus nearby.
 But the wumpus cannot be in [1,1] (or it would have eaten the agent at the start), and it
cannot be in[2,2] (or the agent would have detected a stench when it was in [2,1]).
 Therefore, the agent can infer that the wumpus is in [1,3].
 The notation W! indicates this.
 More interesting is that the lack of a Breeze percept in [1,2] means that there must be
a pit in [3,1].
01/16/2025 158
CONT…
 The reasoning is that no breeze in [1,2] means there can be no pit in [2,2].
 But we already inferred that there must be a pit in either [2,2] or [3,1], so this means
it must be in [3,1].
 This is a fairly difficult inference, because it combines knowledge gained at different
times in different places, and relies on the lack of a percept to make one crucial step.
 The inference is beyond the abilities of most animals, but it is typical of the kind of
reasoning that a logical agent does
01/16/2025 159
CONT…
 After these impressive deductions, there is only one known unvisited OK square
left, [2,2], so the agent will move there.
 We will not show the agent's state of knowledge at [2,2]; we just assume the agent
turns and moves to [2,3], giving us Figure two(b).
 In [2,3], the agent detects a glitter, so it should grab the gold and head for home,
making sure its return trip only goes through squares that are known to be OK.
01/16/2025 160
1.2 REPRESENTATION, REASONING, AND LOGIC
 Together, representation and reasoning support the operation of a knowledge-
based agent
 The objective of knowledge representation is to express knowledge in computer-
tractable form, such that it can be used to help agents perform well.
 A knowledge representation language is defined by two aspects:
1. syntax: describes the possible configurations that can constitute sentences.
2. semantics: determines the facts in the world to which the sentences refer.
01/16/2025 161
CONT…
 For example, the syntax of the language of arithmetic expressions says that
if x and y are expressions denoting numbers, then x > y is a sentence about
numbers
The semantics of the language says that x > y is false when y is a bigger
number than x, and true otherwise
 Provided the syntax and semantics are defined precisely, we can call the language
a logic
01/16/2025 162
CONT…
 From the syntax and semantics, we can derive an inference mechanism for an
agent that uses the language
 Semantics of the language determine the fact to which a given sentence refers
 Facts are part of the world, whereas their representations must be encoded in some
way that can be physically stored within an agent
 We want to generate new sentences that are necessarily true, given that the old
sentences are true.
 This relation between sentences is called entailment
01/16/2025 163
CONT…
In mathematical notation, the relation of entailment between a knowledge
base KB and a sentence a is pronounced "KB entails a" and written as
KB |=a
01/16/2025 164
CONT…
 An inference procedure is complete if it can find a proof for any sentence that is
entailed
 Logics
To summarize, we can say that a logic consists of the following:
1. A formal system for describing states of affairs, consisting of
a) the syntax of the language, which describes how to make sentences
b) the semantics of the language, which states the systematic constraints on
how sentences relate to states of affairs
01/16/2025 165
CONT…
2. The proof theory: a set of rules for deducing the entailments of a set of
sentences
o We will concentrate on two kinds of logic: propositional or Boolean logic, and
first-order logic
o It is illuminating to consider logics in the light of their ontological and
epistemological commitments.
• Ontological commitments have to do with the nature of reality
• Epistemological commitments have to do with the possible states of
knowledge an agent can have using various types of logic
01/16/2025 166
CONT…
 Formal languages and their ontological and epistemological commitments
01/16/2025 167
2. PROPOSITIONAL LOGIC
 Despite its limited expressiveness, prepositional logic serves to illustrate many of
the concepts of logic just as well as first-order logic
 Its syntax, semantics, and associated inference procedures are discussed next
01/16/2025 168
2.1 SYNTAX
 The syntax of prepositional logic is simple
 The symbols of prepositional logic are the logical constants True and False,
proposition symbols such as P and Q, the logical connectives A,V, , =>, and ¬,
and parentheses, ().
 The logical constants True and False are sentences by themselves.
 A prepositional symbol such as P or Q is a sentence by itself.
 Wrapping parentheses around a sentence yields a sentence, for example, (P A Q).
01/16/2025 169
CONT…
 A sentence can be formed by combining simpler sentences with one of the five
logical connectives:
 A (and). A sentence whose main connective is A, such as P A (Q V R), is called a
conjunction (logic); its parts are the conjuncts. (The A looks like an "A" for "And.")
 V (or). A sentence using V, such as A V (P A Q), is a disjunction of the disjoints A
and (P A Q). (Historically, the V comes from the Latin "vel," which means "or." For
most people, it is easier to remember as an upside-down and.)
01/16/2025 170
CONT…
 =>(implies). A sentence such as (PA Q) =>R is called an implication (or
conditional). Its premise or antecedent is P A Q, and its conclusion or consequent is
R. Implications are also known as rules or if-then statements.
 (equivalent). The sentence (P A Q) & (Q A P) is an equivalence (also called a
biconditional).
 ¬ (not). A sentence such as ¬P is called negation of P. All the other connectives
combine two sentences into one. ¬is the only connective that operates on a single
sentence.
01/16/2025 171
CONT…
 The grammar introduces atomic sentences, which in propositional logic consist of a
single symbol (e.g., P), and complex sentences, which contain connectives or
parentheses (e.g., P A Q).
 A BNF (Backus-Naur Form) grammar of sentences in propositional logic:
01/16/2025 172
2.2 SEMANTICS
 The semantics of prepositional logic is also quite straightforward
 We define it by specifying the interpretation of the proposition symbols and constants,
and specifying the meanings of the logical connectives
 With logical constants, you have no choice;
the sentence True always has as its interpretation the way the world actually is the
true fact
The sentence False always has as its interpretation the way the world is not
 A complex sentence has a meaning derived from the meaning of its parts
01/16/2025 173
CONT…
 Truth table for five logical connectives

01/16/2025 174
CONT…
 Truth tables define the semantics of sentences such as True A True
 Complex sentences such as (PV Q) A ¬S are defined by a process of decomposition:
first, determine the meaning of (P A Q) and of ¬S, and then combine them using the
definition of the A function
 This is exactly analogous to the way a complex arithmetic expression such as (p x q)
+ s is evaluated
01/16/2025 175
2.3 VALIDITY AND INFERENCE
 Truth tables can be used not only to define the connectives, but also to test for valid sentences
 If the sentence is true in every row, then the sentence is valid
 For example, the sentence ((PV H) A ¬H) => P is valid
 If at some point we learn (PV H) and then we also learn ¬H, then we can use the valid
sentence above to conclude that P is true
 It can do this by building a truth table for the sentence Premises => Conclusion and
checking all the rows
01/16/2025 176
CONT…
 Truth table showing validity of a complex sentence
01/16/2025 177
2.4 MODELS
 Any world in which a sentence is true under a particular interpretation is called a
model of that sentence under that interpretation
 Models are very important in logic, because, to restate the definition of entailment,
a sentence a is entailed by a knowledge base KB if the models of KB are all
models of a.
 If this is the case, then whenever KB is true, a must also be true
01/16/2025 178
CONT…
 In fact, we could define the meaning of a sentence by means of set operations on
sets of models.
 For example, the set of models of P A Q is the intersection of the models of P and
the models of Q.
 The next diagrams shows the set relationships for the four binary connectives
01/16/2025 179
CONT…
◊ Models of complex sentences in
terms of the models of their
components.
◊ In each diagram, the shaded
parts correspond to the models
of the complex sentence
01/16/2025 180
2.5 RULES OF INFERENCE FOR PROPOSITIONAL LOGIC
 There are certain patterns of inferences that occur over and over again, and their
soundness can be shown once and for all
 Then the pattern can be captured in what is called an inference rule
 We have already seen the notation |-
α β to say that β can be derived from α by
inference
 There is an alternative notation which emphasizes that this is not a sentence, but
rather an inference rule
01/16/2025 181
CONT…
01/16/2025 182
CONT…
01/16/2025 183
READING ASSIGNMENT
 AN AGENT FOR THE WUMPUS WORLD(FOL)
01/16/2025 184
3. PREDICATE (FIRST-ORDER) LOGIC
 We used propositional logic as our representation language because it is one of
the simplest languages that demonstrates all the important points
 Unfortunately propositional logic has a very limited ontology, making only the
commitment that the world consists of facts
 This made it difficult to represent even something as simple as the wumpus world
 First-order logic: makes a stronger set of ontological commitments
01/16/2025 185
CONT…
 First-order logic (FOL) models the world in terms of:
Objects, which are things with individual identities
Properties of objects that distinguish them from other objects
Relations that hold among sets of objects
Functions, which are a subset of relations where there is only one “value” for
any given “input”
01/16/2025 186
CONT…
 Examples:
Objects: Students, lectures, companies, cars ...
Relations: Brother-of, bigger-than, outside, part-of, has-color, occurs-after, owns,
visits, precedes, ...
Properties: blue, oval, even, large, ...
Functions: father-of, best-friend, second-half, one-more-than ...
01/16/2025 187
CONT…
 Although FOL commits to the existence of objects and relations,
 it does not make an ontological commitment to such things as:
categories,
time,
events, which also seem to show up in most facts about the world
01/16/2025 188
3.1 SYNTAX AND SEMANTICS
 In propositional logic every expression is a sentence, which represents a fact
 FOL has sentences, but it also has terms, which represent objects
 Constant symbols, variables, and function symbols are used to build terms, and
quantifiers and predicate symbols are used to build sentences
 Constant symbols, which represent individuals in the world
e.g. Mary, 3, Green, A
 Predicate symbols: which map individuals to truth values
e.g. Round, Brother, greater, green
01/16/2025 189
CONT…
 Function symbols: which map individuals to individuals
 any given object is related to exactly one other object by the relation
e.g. Cosine, FatherOf, LeftLegOf, father-of ….
 FOL Provides:
 Variable symbols
e.g. x, y
01/16/2025 190
CONT…
Connectives
Same as in PL: not (), and (A), or (V), implies (), if and only if (bi-
conditional )
Quantifiers
Universal x or (Ax)
Existential x or (Ex)
01/16/2025 191
CONT…
 The syntax of FOL (with equality) in BNF (Backus-Naur Form)
01/16/2025 192
3.1.1 TERMS, ATOMIC, AND COMPLEX SENTENCES
 A term is a logical expression that refers to an object
 Terms denote a real-world individual is a constant symbol, a variable symbol, or an n-place
function of n terms
x and f(x1, ..., xn) are terms, where each xi is a term
A term with no variables is a ground term
 For example, in English we might use the expression "King John's left leg" rather than giving a
name to his leg
 This is what function symbols are for: instead of using a constant symbol, we use LeftLegOf (John).
01/16/2025 193
CONT…
 Atomic sentences
An atomic sentence is formed from a predicate symbol followed by a
parenthesized list of terms
has value true or false
e.g. Brother(Richard, John)
Atomic sentences can have arguments that are complex terms:
e.g. Married(FatherOf (Richard),MotherOf (John))
01/16/2025 194
CONT…
 Complex sentences
A complex sentence is formed from atomic sentences connected by the logical
connectives:
P, P V Q, P A Q, PQ, PQ where P and Q are sentences
 A quantified sentence adds quantifiers  and 
 A well-formed formula (wff) is a sentence containing no “free” variables.
That is, all variables are “bound” by universal or existential quantifiers.
01/16/2025 195
3.1.2 QUANTIFIERS
 FOL contains two standard quantifiers, called universal and existential
Universal quantification ()
(x)P(x) means that P holds for all values of x in the domain associated with that variable
E.g., (x) dolphin(x)  mammal(x)
Existential quantification ()
( x)P(x) means that P holds for some value of x in the domain associated with that variable
E.g., ( x) mammal(x)  lays-eggs(x)
Permits one to make a statement about some object without naming it
01/16/2025 196
CONT…
 Universal quantifiers are often used with “implies” to form “rules”:
(x) student(x)  smart(x) means “All students are smart”
 Universal quantification is rarely used to make blanket statements about every
individual in the world:
(x)student(x)smart(x) means “Everyone in the world is a student and is smart”
01/16/2025 197
CONT…
 Existential quantifiers are usually used with “and” to specify a list of properties
about an individual:
(x) student(x)  smart(x) means “There is a student who is smart”
 A common mistake is to represent this FOL sentence with English:
(x) student(x)  smart(x)
But what happens when there is a person who is not a student?
01/16/2025 198
CONT…
 Nested quantifiers:
 We will often want to express more complex sentences using multiple quantifiers
 For example, "For all x and all y, if x is the parent of y then y is the child of x"
becomes
x,y Parent(x,y) => Child(y,x)
 x,y is equivalent to  x y.
 Similarly, the fact that a person's brother has that person as a sibling is expressed
by:
x,y Brother(x,y) => Sibling(y,x)
01/16/2025 199
CONT…
 Quantifier Scope:
Switching the order of universal quantifiers does not change the meaning:
(x)(y)P(x,y) (
↔ y)(x) P(x,y)
Similarly, you can switch the order of existential quantifiers:
(x)(y)P(x,y) (
↔ y)(x) P(x,y)
Switching the order of universal and existential does change meaning:
Everyone likes someone: (x)(y) likes(x,y)
Someone likes everyone: (y)(x) likes(x,y)
01/16/2025 200
3.1.3 CONNECTIONS BETWEEN  AND 
 The two quantifiers are actually intimately connected with each other, through negation.
 when one says that everyone dislikes parsnips,
 one is also saying that there does not exist someone who likes them; and vice versa:
 We can relate sentences involving  and  using De Morgan’s laws:
01/16/2025 201
CONT…
 Equality
We can use the equality symbol to make statements to the effect that two terms
refer to the same object
For example:
Father(John) = Henry
says that the object referred by Father(John) and the object referred by Henry
are the same.
01/16/2025 202
3.2 HIGHER-ORDER LOGIC
 Higher-order logic allows us to quantify over relations and functions as well as over objects
 For example, in higher-order logic, we can say that two objects are equal if and only if all
properties applied to them are equivalent:
x,y (x = y) & (p p(x)  p(y))
 Or we could say that two functions are equal if and only if they have the same value for all
arguments:
f,g (f = g)  ( x f(x) = g(x))
 Higher-order logics have strictly more expressive power than first-order logic
 But undecidable: there isn’t an effective algorithm to decide whether all sentences are valid
01/16/2025 203
3.3 EXPRESSING UNIQUENESS
 Sometimes we want to say that there is a single, unique object that satisfies a
certain condition
 “There exists a unique x such that king(x) is true”
x king(x)  y (king(y)  x=y)
x king(x)  y (king(y)  xy)
! x king(x)
01/16/2025 204
CONT…
 “Every country has exactly one ruler”
c country(c)  ! r ruler(c,r)
 Iota operator:“ x P(x)” means “the unique x such that p(x) is true”
“The unique ruler of Freedonia is dead”
dead( x ruler(freedonia,x))
01/16/2025 205
3.4 LOGICAL AGENTS FOR THE WUMPUS WORLD
 Three (non-exclusive) agent architectures:
Reflex agents
Have rules that classify situations, specifying how to react to each possible
situation
Model-based agents
Construct an internal model of their world
Goal-based agents
Form goals and try to achieve them
01/16/2025 206
3.4.1 A SIMPLE REFLEX AGENT
 Rules to map percepts into observations:
b,g,u,c,t Percept([Stench, b, g, u, c], t)  Stench(t)
s,g,u,c,t Percept([s, Breeze, g, u, c], t)  Breeze(t)
s,b,u,c,t Percept([s, b, Glitter, u, c], t)  AtGold(t)
 Rules to select an action given observations:
t AtGold(t)  Action(Grab, t);
01/16/2025 207
CONT…
 Some difficulties:
Consider Climb:
 There is no percept that indicates the agent should climb out
position and holding gold are not part of the percept sequence
Loops:
 The percept will be repeated when you return to a square, which should cause
the same response (unless we maintain some internal model of the world)
01/16/2025 208
CONT…
 Representing change
 Representing change in the world in logic can be tricky.
One way is just to change the KB
Add and delete sentences from the KB to reflect changes
How do we remember the past, or reason about changes?
Situation calculus is another way
A situation is a snapshot of the world at some instant in time
When the agent performs an action A in situation S1, the result is a new situation S2.
01/16/2025 209
3.4.2 MODEL BASED AGENT
 Modeling the “right” conditions and the “right” effects at the “right” level of abstraction
is very difficult
 Knowledge engineering (creating and maintaining knowledge bases for intelligent
reasoning) is an entire field of investigation
 A problem with the Wumpus world knowledge base that we have built so far is that it is
difficult to decide which action is best among a number of possibilities
 We can solve this problem by separating facts about actions from facts about goals.
 This way our agent can be reprogrammed just by asking it to achieve different goals.
01/16/2025 210
3.4.2 GOAL BASED AGENT
 Once the gold is found, it is necessary to change strategies.
 So now we need a new set of action values.
 We could encode this as a rule:
 (s) Holding(Gold,s)  GoalLocation([1,1]),s)
 We must now decide how the agent will work out a sequence of actions to
accomplish the goal.
 Three possible approaches are:
 Inference: good versus wasteful solutions
 Search: make a problem with operators and set of states
 Planning: how, when, and what.
01/16/2025 211
4. INFERENCE IN FIRST-ORDER LOGIC
 propositional logic uses the inference rules like:
Modus Ponens, And-Elimination, And-Introduction, Or-Introduction, and
Resolution.
 These rules hold for first-order logic as well.
 But we will need additional inference rules to handle first-order logic sentences
with quantifiers.
 The three additional rules we introduce here are more complex than previous
01/16/2025 212
CONT…
 We will use the notation SUBST( , a)
θ to denote the result of applying the
substitution (or binding list) to the sentence a.
 For example:
SUBST({x/Sam, y/Pam], Likes(x,y)) = Likes(Sam,Pam)
01/16/2025 213
CONT…
 The three new inference rules are as follows:
 Universal Elimination: For any sentence , variable v, and ground term g:
For example, from Likes(x,IceCream), we can use the substitution {x/Ben} and
infer Likes(Ben, IceCream).
Existential Elimination: For any sentence , variable v, and constant symbol k
that does not appear elsewhere in the knowledge base:
01/16/2025 214
CONT…
For example, from x Kill(x,Victim), we can infer Kill(Murderer,Victim), as long
as Murderer does not appear elsewhere in the knowledge base
Existential Introduction: For any sentence , variable v that does not occur in ,
and ground term g that does occur in
For example, from Likes(Jerry, IceCream) we can infer x Likes(x, IceCream)
01/16/2025 215
4.1 AN EXAMPLE PROOF
 Application of inference rules is simply a question of matching their premise patterns
to the sentences in the KB and then adding their (suitably instantiated) conclusion
patterns
 We will begin with the situation as it might be described in English:
The law says that it is a crime for an American to sell weapons to hostile nations.
The country Nono, an enemy of America, has some missiles, and all of its missiles
were sold to it by Colonel West, who is an American.
 What we wish to prove is that West is a criminal.
01/16/2025 216
CONT…
 We first represent these facts in first-order logic, and then show the proof as a
sequence of applications of the inference rules.
1
2
3
01/16/2025 217
CONT…
4
5
6
7
01/16/2025 218
CONT…
8,9
 The proof consists of a series of applications of the inference rules:
10
11,12
01/16/2025 219
CONT…
13
14
15
16
01/16/2025 220
CONT…
17
18
19
20
01/16/2025 221
CONT…
21
 Initial state = KB (sentences 1-9)
 Operators = applicable inference rules
 Goal test = KB containing Criminal(West)
01/16/2025 222
4.2 GENERALIZED MODES PONENS (GMP)
 Apply modus ponens reasoning to generalized rules
 Combines And-Introduction, Universal-Elimination, and Modus Ponens
From P(c) and Q(c) and (x)(P(x)  Q(x))  R(x) derive R(c)
 General case: Given
atomic sentences P1, P2, ..., PN
implication sentence (Q1  Q2  ...  QN)  R
Q1, ..., QN and R are atomic sentences
substitution subst(θ, Pi) = subst(θ, Qi) for i=1,...,N
Derive new sentence: subst(θ, R)
01/16/2025 223
CONT…
 Substitutions
subst(θ, α) denotes the result of applying a set of substitutions defined by θ to
the sentence α
A substitution list θ = {v1/t1, v2/t2, ..., vn/tn} means to replace all occurrences of
variable symbol vi by term ti
Substitutions are made in left-to-right order in the list
subst({x/IceCream, y/Ziggy}, eats(y,x)) = eats(Ziggy, IceCream)
01/16/2025 224
HORN CLAUSES
 A Horn clause is a sentence of the form:
(x) P1(x)  P2(x)  ...  Pn(x)  Q(x)
where
 there are 0 or more Pis and 0 or 1 Q
 the Pis and Q are positive (i.e., non-negated) literals
 Equivalently: P1(x)  P2(x) …  Pn(x) where the Pi are all atomic and at most one of
them is positive
 Horn clauses represent a subset of the set of sentences representable in FOL
01/16/2025 225
CONT…
 Special cases
P1  P2  … Pn  Q
P1  P2  … Pn  false
true  Q
 These are not Horn clauses:
p(a)  q(a)
(P  Q)  (R  S)
01/16/2025 226
4.2.1 FORWARD CHAINING
 Proofs start with the given axioms/premises in KB, deriving new sentences using
GMP until the goal/query sentence is derived
 This defines a forward-chaining inference procedure because it moves “forward”
from the KB to the goal [eventually]
 Inference using GMP is complete for KBs containing only Horn clauses
01/16/2025 227
FORWARD CHAINING ALGORITHM
01/16/2025 228
4.2.2 BACKWARD CHAINING
 Backward-chaining deduction using GMP is also complete for KBs containing
only Horn clauses
 Proofs start with the goal query, find rules with that conclusion, and then prove
each of the antecedents in the implication
 Keep going until you reach premises
 Avoid loops: check if new subgoal is already on the goal stack
 Avoid repeated work: check if new subgoal
Has already been proved true
Has already failed
01/16/2025 229
BACKWARD CHAINING ALGORITHM
01/16/2025 230
FORWARD VS. BACKWARD CHAINING
 FC is data-driven
 Automatic, unconscious processing
 E.g., object recognition, routine decisions
 May do lots of work that is irrelevant to the goal
 BC is goal-driven, appropriate for problem-solving
 Where are my keys? How do I get to my next class?
 Complexity of BC can be much less than linear in the size of the KB
01/16/2025 231
4.2.3 COMPLETENESS OF GMP
 GMP (using forward or backward chaining) is complete for KBs that contain only Horn clauses
 It is not complete for simple KBs that contain non-Horn clauses
 The following entail that S(A) is true:
(x) P(x)  Q(x)
(x) P(x)  R(x)
(x) Q(x)  S(x)
(x) R(x)  S(x)
 If we want to conclude S(A), with GMP we cannot, since the second one is not a Horn clause
 It is equivalent to P(x)  R(x)
01/16/2025 232
4.3 RESOLUTION
 Resolution is a sound and complete inference procedure for FOL
 Reminder: Resolution rule for propositional logic:
 P1  P2  ...  Pn
 P1  Q2  ...  Qm
 Resolvent: P2  ...  Pn  Q2  ...  Qm
 Examples
 P and  P  Q : derive Q (Modus Ponens)
 ( P  Q) and ( Q  R) : derive  P  R
 P and  P : derive False [contradiction!]
 (P  Q) and ( P   Q) : derive True
01/16/2025 233
4.3.1 RESOLUTION IN FOL
 Given sentences
P1  ...  Pn
Q1  ...  Qm
 in conjunctive normal form:
 each Pi and Qi is a literal, i.e., a positive or negated predicate symbol with its
terms,
 if Pj and Qk unify with substitution list θ, then derive the resolvent sentence:
subst(θ, P1 ...  Pj-1  Pj+1 ... Pn  Q1  …Qk-1  Qk+1 ...  Qm)
01/16/2025 234
4.3.2 RESOLUTION REFUTATION
 Given a consistent set of axioms KB and goal sentence Q, show that KB |= Q
 Proof by contradiction: Add Q to KB and try to prove false.
i.e., (KB |- Q) (KB
↔  Q |- False)
 Resolution is refutation complete: it can establish that a given sentence Q is
entailed by KB, but can’t (in general) be used to generate all logical consequences
of a set of sentences
 Also, it cannot be used to prove that Q is not entailed by KB.
01/16/2025 235
CONT…
 Resolution won’t always give an answer since entailment is only semi-decidable
And you can’t just run two proofs in parallel, one trying to prove Q and the other
trying to prove Q, since KB might not entail either one
01/16/2025 236
236
REFUTATION RESOLUTION PROOF TREE
Implicative Normal Form (KB)
P(w) =>Q(w)
True => P(x)V R(x)
Q(y) => S(y)
R(z) => S(z)
A proof that S(A) follows from the KB in , using resolution.
Each "vertex" in the proof tree represents a resolution step:
the two sentences at the top are the premises, and the one at the
bottom is the conclusion or resolvent.
The substitution is shown for each resolution.
01/16/2025 237
CONT…
 Technically, the final resolvent should be True => S(A) V S(A), but we have taken
the liberty of removing the redundant disjunct.
 In some systems, there is a separate inference rule called factoring to do this, but it
is simpler to just make it be part of the resolution rule
 Chaining with resolution is more powerful than chaining with Modus Ponens, but it
is still not complete
 One complete inference procedure using resolution is refutation, also known as
proof by contradiction and reductio ad absurdum
01/16/2025 238
CONT…
 The idea is that to prove P, we assume P is false (i.e., add ->P to the knowledge
base) and prove a contradiction.
 If we can do this, then it must be that the knowledge base implies P.
 In other words:
(KB A P => False)  (KB => P)
 Proof by contradiction is a powerful tool throughout mathematics, and resolution
gives us a simple, sound, complete way to apply it
01/16/2025 239
CONT…
A proof that S(A) follows from the previous
KB using resolution with refutation.
01/16/2025 240
Reading assignment
 normalization and skolemization (conversion of FOL to CNF)
 Unification
01/16/2025 241
THE END OF CHAPTER FOUR
CHAPTER SIX
Machine Learning
01/16/2025 243
LIST OF CONTENTS
1. Learning from Examples/Observation
2. Knowledge in Learning
3. Learning Probabilistic Models
4. Neural Networks
01/16/2025 244
1. LEARNING FROM EXAMPLES/OBSERVATION
 Learning is any process by which a system improves performance from experience
 Learning takes place as a result of the interaction between
the agent and
the world,
And from observation by the agent of its own decision-making processes.
 What is the task?
Classification
Problem solving /planning /control
01/16/2025 245
CONT…
 The general model of learning agent
 The critic is designed to tell
the learning element how well
the agent is doing.
 Problem generator is responsible
for suggesting actions that will lead
to new and informative experiences
01/16/2025 246
CONT…
 The design of the learning element is affected by four major issues:
Which components of the performance element are to be improved.
What representation is used for those components.
What feedback is available.
What prior information is available.
01/16/2025 247
CONT…
 For some components,
such as the component for predicting the outcome of an action,
the available feedback generally tells the agent what the correct outcome is
 Any situation in which both the inputs and outputs of a component can be
perceived is called supervised learning.
Often, the outputs are provided by a friendly teacher
Learning when there is no hint at all about the correct outputs is called
unsupervised learning.
01/16/2025 248
1.1 BIAS AND HYPOTHESIS
 Bias of an algorithm is a set of assumptions that the learner uses to predict outputs.
 In machine learning, one aim to construct algorithms that are able to learn to predict a
certain target output
inductive bias = Y=a+bx (linear model)
 Hypothesis is a function that best describes the target in supervised machine learning
 The hypothesis that an algorithm would come up depends upon the data and also
depends on the restriction and bias that we have imposed on the data
01/16/2025 249
CONT…
In (a) we have some example (input, output) pairs.
In (b), (c), and (d) we have three hypotheses for functions from
which these examples could be drawn.
01/16/2025 250
1.2 LEARNING DECISION TREES
 Decision tree induction is one of the simplest and yet most successful forms of
learning algorithm.
 A decision tree takes as input an object or situation described by a set of
properties, and outputs a yes/no "decision.“
 Decision trees therefore represent Boolean functions.
 Functions with a larger range of outputs can also be represented, but for simplicity
we will usually stick to the Boolean case
01/16/2025 251
CONT…
 Each internal node in the tree corresponds to a test of the value of one of the
properties, and the branches from the node are labelled with the possible values of the
test.
 Each leaf node in the tree specifies the Boolean value to be returned if that leaf is
reached.
 Decision trees are implicitly limited to talking about a single object.
 We cannot use decision trees to represent tests that refer to two or more different
objects
01/16/2025 252
CONT…
A decision tree for deciding
whether to wait for a table
01/16/2025 253
CONT…
 An example is described by the values of the attributes and the value of the goal
predicate.
 We call the value of the goal predicate the classification of the example
 If the goal predicate is true for some example, we call it a positive example;
otherwise we call it a negative example.
 The complete set of examples is called the training set.
 A set of examples X1,... ,X12 for the restaurant domain is shown in next Figure
01/16/2025 254
CONT…
Examples for the restaurant domain.
01/16/2025 255
1.3 ASSESSING THE PERFORMANCE OF THE
LEARNING ALGORITHM
 A learning algorithm is good if it produces hypotheses that do a good job of predicting
the classifications of unseen examples.
 Obviously, a prediction is good if it turns out to be true, so we can assess the quality of
a hypothesis by checking its predictions against the correct classification once we
know it.
 We do this on a set of examples known as the test set
 Often it is more convenient to adopt the following methodology while training a
machine :
01/16/2025 256
CONT…
1. Collect a large set of examples.
2. Divide it into two disjoint sets: the training set and the test set.
3. Use the learning algorithm with the training set as examples to generate a hypothesis
H.
4. Measure the percentage of examples in the test set that are correctly classified by H.
5. Repeat steps 1 to 4 for different sizes of training sets and different randomly selected
training sets of each size.
01/16/2025 257
1.3.1 OVERFITTING
 Whenever there is a large set of possible hypotheses, one has to be careful not to
use the resulting freedom to find meaningless "regularity" in the data.
 This problem is called overfitting.
 simple technique to treat overfitting is called decision tree pruning.
 Pruning works by preventing recursive splitting on attributes that are not clearly
relevant, even when the data at that node in the tree is not uniformly classified.
 Cross-validation is another technique that eliminates the dangers of overfitting.
01/16/2025 258
CONT…
 The basic idea of cross-validation is to try to estimate how well the current
hypothesis will predict unseen data.
 This is done by setting aside some fraction of the known data, and using it to test
the prediction performance of a hypothesis induced from the rest of the known
data.
01/16/2025 259
2. KNOWLEDGE IN LEARNING
cumulative learning process uses, and adds to, its
stock of background knowledge over time.
01/16/2025 260
CONT…
 If we want to build an autonomous learning agent that uses background knowledge, the
agent must have some method for obtaining the background knowledge in the first place, in
order for it to be used in the new learning episodes.
 This method must itself be a learning process.
 The agent's life history will therefore be characterized by cumulative, or incremental,
development.
 Presumably, the agent could start out with nothing, performing inductions in vacuum like a
good little pure induction program
01/16/2025 261
2.1 EXPLANATION-BASED LEARN (EBL)
 Use of background knowledge allows much faster learning than one might expect from a pure
induction program
 Explanation-based learning is a method for extracting general rules from individual
observations
 The technique of memorization has long been used in computer science to speed up programs
by saving the results of computation.
 The basic idea of memo functions is to accumulate a database of input/output pairs; when the
function is called, it first checks the database to see if it can avoid solving the problem from
scratch.
01/16/2025 262
CONT…
 Explanation-based learning (EBL) takes this a good deal further, by creating
general rules that cover an entire class of cases.
 In the case of differentiation, memorization would remember that the derivative of
X2
with respect to X is 2X, but would leave the agent to calculate the derivative of Z2
with respect to Z from scratch
 We would like to be able to extract the general rule1 that for any arithmetic
unknown u, the derivative of u2
with respect to u is 2u
01/16/2025 263
2.2 INDUCTIVE LOGIC PROGRAMMING (ILP)
 Inductive logic programming (ILP) is one of the newest subfields in AI.
 It combines inductive methods with the power of first-order representations,
concentrating in particular on the representation of theories as logic programs
 ILP is a highly technical field, relying on some fairly advanced material from the
study of computational logic.
 One of the principal advantages of ILP algorithms is their applicability to a much
wider range of problems
01/16/2025 264
3. NEURAL NETWORKS
01/16/2025
Artificial_intelligenceI_GIS 265
# WHAT IS BIOLOGICAL NEURAL NETWORK
 In the Biological Neural network (BNN), neurons are working inside a human brain which
are connected by synapses activated for the specific function they ought to carry out
 There are two basic kinds of connections between neurons present in the biological brain
called synapses, both electrical and chemical
 Synapses help the connection of neurons in overlapping and interlinking the neural circuits
 Consider the Biological Neural Network to be a connective bridge in the difference
between a neural network and the human brain.
01/16/2025
Artificial_intelligenceI_GIS 266
# WHAT IS ARTIFICIAL NEURONS?
 Analogy to biological neural systems, the most robust learning systems we know.
 Attempt to understand natural biological systems through computational
modeling.
 Massive parallelism allows for computational efficiency.
 Artificial Neural Networks (ANN) is the main tool used in Machine learning.
 It has been gaining popularity at a very fast pace with Deep Learning, Data Science
and Machine Learning being around in the past few years.
01/16/2025
Artificial_intelligenceI_GIS 267
3.1 BIOLOGICAL VS ARTIFICIAL NEURONS
 The biological brain and Artificial Neural Networks (ANN) are two of the most
controversial aspects of analysis in the field of Neural Network research.
 But there have been some postulations regarding the working difference between
ANN and the human brain.
 SIZE: In the human brain, there are 86 billion neurons, and more than 100 trillion
synapses to pass on electrical signals throughout a biological body.
 But on the other hand, the number of neuron in the artificial neural network is way
more lesser in numbers.
01/16/2025
Artificial_intelligenceI_GIS 268
CONT…
 One layer perceptron network consists of several perceptrons that are not
connected to one another.
 TOPOLOGY:The artificial layers add up one by one, instead of being a part of a
network that has nodes that don’t add up synchronously.
 On the other hand, in biological networks, neurons paralelly fire asynchronously
with a small portion of highly connected neurons and a large amount of lesser
connected ones.
01/16/2025
Artificial_intelligenceI_GIS 269
CONT…
 POWER CONSUMPTION: The biological brain consumes about 20% of the overall human
body’s energy.
 An adult brain operates on about 20 watts, and in comparison to this, artificial builds can’t
even match the efficiency level of a biological brain.
 SPEED: In the biological neuron, electric signals travel at varied speeds depending on the
type of the nerve impulse.
 The speed usually ranges from 0.61 m/s to 119 m/s.
 On the other hand, an artificial neuron emits signal by the continuous, floating point
number values of synaptic weights.
01/16/2025
Artificial_intelligenceI_GIS 270
3.2 PERCEPTRON
 Assume supervised training examples giving the desired output for a unit given a
set of known input activations.
 Learn synaptic weights so that unit produces the correct output for each example.
 Perceptron uses iterative update algorithm to learn a correct set of weights.
 Update weights by:
Wij = Wji + η(tj - oj)oi
where η is learning rate,
tj is teacher specified output for unit j
01/16/2025
Artificial_intelligenceI_GIS 271
CONT…
 Equivalent to rules:
If output is correct do nothing.
If output is high, lower weights on active inputs
If output is low, increase weights on active inputs
 Also adjust threshold to compensate:
T = Tj – η(tj - oj)
01/16/2025
Artificial_intelligenceI_GIS 272
CONT…
 Perceptron learning algorithm
Iteratively update weights until convergence.
 Initialize weights to random values Until outputs of all training examples are
correct For each training pair, E, do:
Compute current output oj for E given its inputs
Compare current output to target value, tj , for E
Update synaptic weights and threshold using learning rule
Each execution of the outer loop is typically called an epoch.
01/16/2025
Artificial_intelligenceI_GIS 273
CONT…
 Perceptron as a linear separator
Since perceptron uses linear threshold function, it is searching for a linear
separator that discriminates the classes
01/16/2025
Artificial_intelligenceI_GIS 274
CONT…
 Perceptron limit
System obviously cannot learn concepts it cannot represent.
Minksy and Papert (1969) wrote a book analyzing the perceptron and
demonstrating many functions it could not learn.
These results discouraged further research on neural nets; and symbolic AI
became the dominate paradigm.
01/16/2025
Artificial_intelligenceI_GIS 275
CONT…
 Perceptron Convergence and Cycling Theorems
Perceptron convergence theorem: If the data is linearly separable and therefore a set
of weights exist that are consistent with the data, then the Perceptron algorithm will
eventually converge to a consistent set of weights.
Perceptron cycling theorem: If the data is not linearly separable, the Perceptron
algorithm will eventually repeat a set of weights and threshold at the end of some epoch
and therefore enter an infinite loop.
o By checking for repeated weights + threshold, one can guarantee termination with either
a positive or negative result.
01/16/2025
Artificial_intelligenceI_GIS 276
CONT…
 Perceptron as Hill Climbing
The hypothesis space being search is a set of weights and a threshold.
Objective is to minimize classification error on the training set.
Perceptron effectively does hill-climbing (gradient descent) in this space, changing the
weights a small amount at each point to decrease training set error.
For a single model neuron, the space is well behaved with a single minima.
01/16/2025 277
CONT…
 Perceptron performance
Linear threshold functions are restrictive (high bias) but still reasonably
expressive; more general than:
Pure conjunctive
Pure disjunctive
M-of-N (at least M of a specified set of N features must be present)
In practice, it converges fairly quickly for linearly separable data.
Can effectively use even incompletely converged results when only a few outliers
are misclassified.
Experimentally, Perceptron does quite well on many benchmark data sets.
Artificial_intelligenceI_GIS
01/16/2025 278
3.3 MULTI-LAYER NETWORKS
 Multi-layer networks can represent arbitrary functions, but an effective learning
algorithm for such networks was thought to be difficult.
 A typical multi-layer network consists of an input, hidden and output layer, each
fully connected to the next, with activation feeding forward.
Output layer
Input layer
hidden layer
• The weights determine the function computed.
• Given an arbitrary number of hidden units, any
Boolean function can be computed with a
single hidden layer.
01/16/2025 279
CONT…
 How many hidden units are needed?
 The problem of choosing the right number of hidden units in advance is still not
well-understood.
 The most popular method for learning in multilayer networks is called back-
propagation
01/16/2025 280
3.3.1 BACK-PROPAGATION
 The back-propagation algorithm is a sensible approach to dividing the
contribution of each weight.
 As in the perceptron learning algorithm, we try to minimize the error between
each target output and the output actually computed by the network.
 At the output layer, the weight update rule is very similar to the rule for the
perceptron.
 There are two differences:
1. the activation of the hidden unit ai is used instead of the input value; and
2. the rule contains a term for the gradient of the activation function.
01/16/2025 281
CONT…
 Backpropagation Learning Rule
∆wji = ηδjoi
δ = oj (1-oj) (tj - oj) if j is an output unit
δ = oj (1-oj)∑ δ kwkj if j is hidden unit
where is a constant called the learning rate
η
t j is the correct teacher output for unit j
δj is the error measure for unit j
01/16/2025 282
CONT…
 Error Backpropagation
 First calculate error of output units and use this to change the top layer of weights
Current output: oj = 0.2
Correct output: t j = 1.0
Error δj = oj (1–oj )(t j – oj )
0.2(1– 0.2)(1– 0.2)=0.128
# Update weights into j
∆wji = ηδ j oi
Input
hidden
output
01/16/2025 283
CONT…
 Next calculate error for hidden units based on errors on the output units it feeds into.
Input
hidden
output
δ = oj (1 - oj) ∑ δ k wjk
Input
hidden
01/16/2025 284
CONT…
 Finally update bottom layer of weights based on errors calculated for hidden units.
Input
hidden
output
01/16/2025 285
CONT…
 Backpropagation Training Algorithm
Create the 3-layer network with H hidden units with full connectivity between layers.
Set weights to small random real values.
Until all training examples produce the correct value (within ),
ε
or mean squared error ceases to decrease, or other termination criteria:
Begin epoch For each training example, d, do:
Calculate network output for d’s input values
Compute error between current output and correct output for d
Update weights by back-propagating error and using learning rule
End epoch
01/16/2025 286
CONT…
 Comments on Training Algorithm
Not guaranteed to converge to zero training error, may converge to local optima or
oscillate indefinitely.
However, in practice, does converge to low error for many large networks on real data.
Many epochs (thousands) may be required, hours or days of training for large networks.
To avoid local-minima problems, run several trials starting with different random
weights (random restarts).
Take results of trial with lowest training set error.
Build a committee of results from multiple trials
01/16/2025 287
CONT…
 Successful Applications
Text to Speech (NetTalk)
Fraud detection
Financial Applications
HNC (eventually bought by Fair Isaac)
Chemical Plant Control
Pavilion Technologies
Automated Vehicles
Game Playing
Neuro-gammon
Handwriting recognition
CHAPTER SEVEN
Communicating, Perceiving, and Acting
01/16/2025 289
LIST OF CONTENTS
1. Natural Language Processing and communication
2. Perception
3. Robotics
01/16/2025 290
1. NATURAL LANGUAGE PROCESSING
 NLP is the branch of computer science focused on developing systems that allow
computers to communicate with people using everyday language.
 Also called Computational Linguistics
Also concerns how computational methods can aid the understanding of human
language
 The goal in the production and comprehension of natural language is
communication.
01/16/2025 291
1.2 COMMUNICATION
 Communication for the speaker:
Intention: Decide when and what information should be transmitted (a.k.a.
strategic generation). May require planning and reasoning about agents’ goals
and beliefs.
Generation:Translate the information to be communicated (in internal logical
representation or “language of thought”) into string of words in desired natural
language (a.k.a. tactical generation).
Synthesis: Output the string in desired modality, text or speech.
01/16/2025 292
CONT…
 Communication for the listner:
Perception: Map input modality to a string of words, e.g. optical character recognition (OCR)
or speech recognition.
Analysis: Determine the information content of the string.
Syntactic interpretation (parsing): Find the correct parse tree showing the phrase
structure of the string.
Semantic Interpretation: Extract the (literal) meaning of the string (logical form).
Pragmatic Interpretation: Consider effect of the overall context on altering the literal
meaning of a sentence.
Incorporation: Decide whether or not to believe the content of the string and add it to the KB.
01/16/2025 293
CONT…
01/16/2025 294
CONT…
 Syntax concerns the proper ordering of words and its affect on
meaning.
 The dog bit the boy.
 The boy bit the dog.
 * Bit boy dog the the.
 Colorless green ideas sleep furiously.
 Semantics concerns the (literal) meaning of words, phrases, and
sentences.
 “plant” as a photosynthetic organism
 “plant” as a manufacturing facility
 “plant” as the act of sowing
 Pragmatics concerns the overall communicative and social context
and its effect on interpretation.
 The ham sandwich wants another beer. (co-reference, anaphora)
 John thinks vanilla. (ellipsis)
01/16/2025 295
1.2.1 AMBIGUITY
 Natural language is highly ambiguous and must be disambiguated.
I saw the man on the hill with a telescope.
I saw the Grand Canyon flying to LA.
Time flies like an arrow.
Horse flies like a sugar cube.
Time runners like a coach.
Time cars like a Porsche.
01/16/2025 296
CONT…
 Speech Recognition
“recognize speech” vs.“wreck a nice beach”
“youth in Asia” vs.“euthanasia”
 Syntactic Analysis
“I ate spaghetti with chopsticks” vs.“I ate spaghetti with meatballs.”
 Semantic Analysis
“The dog is in the pen.” vs.“The ink is in the pen.”
“I put the plant in the window” vs.“Ford put the plant in Mexico”
 Pragmatic Analysis
From “The Pink Panther Strikes Again”:
Clouseau: Does your dog bite?
Hotel Clerk: No.
Clouseau: [bowing down to pet the dog] Nice dog.
[Dog barks and bites Clouseau in the hand]
Clouseau: I thought you said your dog did not bite!
Hotel Clerk:That is not my dog.
01/16/2025 297
1.2.2 NATURAL LANGUAGES VS. COMPUTER LANGUAGES
 Ambiguity is the primary difference between natural and computer languages.
 Formal programming languages are designed to be unambiguous, i.e. they can be
defined by a grammar that produces a unique parse for each sentence in the
language.
 Programming languages are also designed for efficient (deterministic) parsing, i.e.
they are deterministic context-free languages (DCFLs).
A sentence in a DCFL can be parsed in O(n) time where n is the length of the
string.
01/16/2025 298
CONT…
 Syntactic Parsing
01/16/2025 299
1.2.3 CONTEXT FREE GRAMMARS (CFG)
 N a set of non-terminal symbols (or variables)
  a set of terminal symbols (disjoint from N)
 R a set of productions or rules of the form A→, where A is a non-terminal and 
is a string of symbols from ( N)*
 S, a designated non-terminal called the start symbol
01/16/2025 300
CONT…
 Simple CFG for English
Grammar
S NP VP
→
S Aux NP VP
→
S VP
→
NP Pronoun
→
NP Proper-Noun
→
NP Det Nominal
→
Nominal Noun
→
Nominal Nominal Noun
→
Nominal Nominal PP
→
VP Verb
→
VP Verb NP
→
VP VP PP
→
PP Prep NP
→
Lexicon
Det the | a | that | this
→
Noun book | flight | meal | money
→
Verb book | include | prefer
→
Pronoun I | he | she | me
→
Proper-Noun Houston | NWA
→
Aux does
→
Prep from | to | on | near | through
→
01/16/2025 301
CONT…
 Sentence Generation
Sentences are generated by recursively rewriting the start symbol using the productions
until only terminals symbols remain.
S
VP
Verb NP
Det Nominal
Nominal PP
book
Prep NP
through
Houston
Proper-Noun
the
flight
Noun
Derivation
or
Parse Tree
01/16/2025 302
1.2.4 WORD SENSE DISAMBIGUATION
 Words in natural language usually have a fair number of different possible
meanings.
Ellen has a strong interest in computational linguistics.
Ellen pays a large amount of interest on her credit card.
 For many tasks (question answering, translation), the proper sense of each
ambiguous word in a sentence must be determined.
01/16/2025 303
CONT…
 Syntactic and semantic ambiguities must be properly resolved for correct translation:
“John plays the guitar.” “John toca la guitarra.”
→
“John plays soccer.” “John juega el fútbol.”
→
 An apocryphal story is that an early MT system gave the following results when
translating from English to Russian and then back to English:
“The spirit is willing but the flesh is weak.”  “The liquor is good but the meat is
spoiled.”
“Out of sight, out of mind.”  “Invisible idiot.”
01/16/2025 304
CONT…
 WSD as a text categorization
Each sense of an ambiguous word is treated as a category.
“play” (verb)
play-game
play-instrument
play-role
“pen” (noun)
writing-instrument
enclosure
01/16/2025 305
CONT…
Treat current sentence (or preceding and current sentence) as a document to be
classified.
“play”:
play-game:“John played soccer in the stadium on Friday.”
play-instrument:“John played guitar in the band on Friday.”
play-role:“John played Hamlet in the theater on Friday.”
“pen”:
writing-instrument:“John wrote the letter with a pen in NewYork.”
enclosure:“John put the dog in the pen in NewYork.”
01/16/2025 306
CONT…
 Learning in WSD
Assume part-of-speech (POS), e.g. noun, verb, adjective, for the target word is
determined.
Treat as a classification problem with the appropriate potential senses for the target
word given its POS as the categories.
Encode context using a set of features to be used for disambiguation.
Train a classifier on labeled data encoded using these features.
Use the trained classifier to disambiguate future instances of the target word given their
contextual features.
01/16/2025 307
CONT…
WSD “line” Corpus
4,149 examples from newspaper articles containing the word “line.”
Each instance of “line” labeled with one of 6 senses from WordNet.
Each example includes a sentence containing “line” and the previous sentence for context.
 Senses of “line” are
01/16/2025 308
CONT…
01/16/2025 309
CONT…
 Experimental Data forWSD of “line”
Sample equal number of examples of each sense to construct a corpus of 2,094.
Represent as simple binary vectors of word occurrences in 2 sentence context.
Stop words eliminated
Stemmed to eliminate morphological variation
Final examples represented with 2,859 binary word features.
01/16/2025 310
CONT…
 Learning algorithms for DNS
 Naïve Bayes
 Binary features
 K Nearest Neighbor
 Simple instance-based algorithm with k=3 and Hamming distance
 Perceptron
 Simple neural-network algorithm.
 C4.5
 State of the art decision-tree induction algorithm
 PFOIL-DNF
 Simple logical rule learner for Disjunctive Normal Form
 PFOIL-CNF
 Simple logical rule learner for Conjunctive Normal Form
 PFOIL-DLIST
 Simple logical rule learner for decision-list of conjunctive rules
01/16/2025 311
1.2.5 OTHER SYNTACTIC TASKS
 Word Segmentation
Breaking a string of characters (graphemes) into a sequence of words.
In some written languages (e.g. Chinese) words are not separated by spaces.
Even in English, characters other than white-space can be used to separate
words [e.g. , ; . - : ( ) ]
Examples from English URLs:
jumptheshark.com  jump the shark .com
myspace.com/pluckerswingbar
 myspace .com pluckers wing bar
 myspace .com plucker swing bar
01/16/2025 312
CONT…
 Morphological Analysis
Morphology is the field of linguistics that studies the internal structure of words.
(Wikipedia)
A morpheme is the smallest linguistic unit that has semantic meaning
(Wikipedia)
 e.g.“carry”,“pre”,“ed”,“ly”,“s”
Morphological analysis is the task of segmenting a word into its morphemes:
carried  carry + ed (past tense)
independently  in + (depend + ent) + ly
Googlers  (Google + er) + s (plural)
01/16/2025 313
CONT…
 Part Of Speech (POS) Tagging
Annotate each word in a sentence with a part-of-speech.
Useful for subsequent syntactic parsing and word sense disambiguation
01/16/2025 314
1.2.6 OTHER SEMANTIC TASKS
 Semantic Role Labeling (SRL)
For each clause, determine the semantic role played by each noun phrase that is
an argument to the verb.
Also referred to a “case role analysis,”“thematic analysis,” and “shallow
semantic parsing”
01/16/2025 315
CONT…
 Semantic Parsing
A semantic parser maps a natural-language sentence to a complete, detailed
semantic representation (logical form).
For many applications, the desired output is immediately executable by another
program.
Example: Mapping an English database query to Prolog:
How many cities are there in the US?
answer(A, count(B, (city(B), loc(B, C),
const(C, countryid(USA))), A))
01/16/2025 316
CONT…
 Textual Entailment
Determine whether one natural language sentence entails (implies) another
under an ordinary interpretation.
01/16/2025 317
1.2.7 OTHER GENERAL TASKS
 Information Extraction (IE)
Identify phrases in language that refer to specific types of entities and relations in text.
Named entity recognition (NER) is task of identifying names of people, places,
organizations, etc. in text.
Relation extraction identifies specific relations between entities.
01/16/2025 318
CONT…
 Question Answering
Directly answer natural language questions based on information presented in a
corpora of textual documents (e.g. the web).
When was Barack Obama born? (factoid)
August 4, 1961
Who was president when Barack Obama was born?
John F. Kennedy
How many presidents have there been since Barack Obama was born?
9
01/16/2025 319
CONT…
 Text summarization
 Produce a short summary of a longer document or article.
Article: With a split decision in the final two primaries and a flurry of super
delegate endorsements, Sen. Barack Obama sealed the Democratic presidential
nomination last night after a grueling and history-making campaign against
Sen. Hillary Rodham Clinton that will make him the first African American to
head a major-party ticket. Before a chanting and cheering audience in St. Paul,
Minn., the first-term senator from Illinois savored what once seemed an unlikely
outcome to the Democratic race with a nod to the marathon that was ending and
to what will be another hard-fought battle, against Sen. John McCain, the
presumptive Republican nominee….
Summary: Senator Barack Obama was declared the presumptive Democratic
presidential nominee.
01/16/2025 320
CONT…
 Machine Translation (MT)
Translate a sentence from one natural language to another.
Hasta la vista, bebé 
Until we see each other again, baby.
01/16/2025 321
2. PERCEPTION
 Perception provides agents with information about the world they inhabit.
 Perception is initiated by sensors
 A sensor is anything that can change the computational state of the agent in response to
a change in the state of the world
 There are basically two approaches for perception
1. Feature Extraction
Detect some small number of features in sensory input and pass them to their
agent program
Agent program will combine features with other information
“bottom up”
01/16/2025 322
CONT…
2. Model Based
Sensory stimulus is used to reconstruct a model of the world
Start with a function that maps from a state of the world to a stimulus
“top down”
 In reality, both feature extraction and model-based approaches are needed
Not well understood how to combine these approaches
Knowledge representation of the model is the problem
01/16/2025 323
2.1 IMAGE FORMATION
 An image is a rectangular grid of data of light values
Commonly known as pixels
 Pixel values can be…
Binary
Gray scale
Color
Multimodal
01/16/2025 324
CONT…
 Image formation
01/16/2025 325
CONT…
01/16/2025 326
CONT…
 I(x,y,t) is the intensity at (x,y) at time t
 CCD camera has approximately 1,000,000 pixels
 Human eyes have approximately 240,000,000 “pixels”
i.e. 0.25 terabits / second
01/16/2025 327
2.2 IMAGE PROCESSING
 Image processing operations often apply a function to an image and the result is
another image
“Enhance the image” in some fashion
Smoothing
Histogram equalization
Edge detection
 Image processing operations can be done in either the spatial domain or the
frequency domain
01/16/2025 328
CONT…
• The first image is Arial image
• The rest of the images are after
performing some transformation
01/16/2025 329
CONT…
 Image data can be represented in a spatial domain or a frequency domain
 The transformation from the spatial domain to the frequency domain is
accomplished by the Fourier Transform
 By transforming image data to the frequency domain, it is often less
computationally demanding to perform image processing operations
01/16/2025 330
CONT…
Basic steps for filtering
In frequency domain
01/16/2025 331
CONT…
 Low Pass Filter
 Allows low frequencies to pass
 High Pass Filter
 Allows high frequencies to pass
 Band Pass Filter
 Allows frequencies in a given range to pass
 Notch Filter
 Suppresses frequencies in a range (attenuate)
01/16/2025 332
CONT…
 High frequencies are more noisy
Similar to the “salt and pepper” fleck on a TV
Use a low pass filter to remove the high frequencies from an image
Convert image back to spatial domain
Result is a “smoothed image”
 Image enhancement can be done with high pass filters and amplifying the filter
function
Sharper edges
01/16/2025 333
CONT…
 Transforming images to the frequency domain was (and is still) done to improve
computational efficiency
Filters were just like addition and subtraction
 Now computers are so fast that filter functions can be done in the spatial domain
Convolution
 Convolution is the spatial equivalent to filtering in the frequency domain
More computation involved
01/16/2025 334
CONT…
 After performing image enhancement, the next step is usually to detect edges in the
image
 Edge Detection
 Use the convolution algorithm with edge detection filters to find vertical and
horizontal edges
 Once edges are detected, we can use them to do stereoscopic processing,
detect motion, or recognize objects
 Segmentation is the process of breaking an image into groups, based on
similarities of the pixels
01/16/2025 335
2.3 COMPUTER VISION
 Contour Tracing
 Connected Component Analysis
When can we say that 2 pixels are neighbors?
In general, a connected component is a set of black pixels, P, such that for every
pair of pixels pi and pj in P, there exists a sequence of pixels pi, ..., pj such that:
all pixels in the sequence are in the set P i.e. are black, and
every 2 pixels that are adjacent in the sequence are "neighbors"
01/16/2025 336
CONT…
4-connected
regions
8-connected
region
not 8-connected
region
01/16/2025 337
3.3 OBJECT DETECTION
01/16/2025 338
CONT…
 L-Junction
A vertex defined by only two
lines…the endpoints touch
 Y-Junction
A three line vertex where the
angle between each of the lines
and the others is less than 180o
 W-Junction
A three line vertex where one of
the angles between adjacent
line pairs is greater than 180o
 T-Junction
A three line vertex where one of
the angles is exactly 180o
 An occluding edge is marked
with an arrow, 
hides part from view
 A convex edge is marked with
a plus, +
pointing towards viewer
 A concave edge is marked with
a minus, -
pointing away from the viewer
01/16/2025 339
CONT…
L W
W
L
W
Y
L
L
L
L
W
T
b
b
b
b
b
b
b
f
f
f
f
f
f







 -
+
+
+
+
+
b

01/16/2025 340
3. ROBOTICS
 The Robot Institute of America defines a robot as a programmable, multifunction
manipulator designed to move material, parts, tools, or specific devices through
variable programmed motions for the performance of a variety of tasks
 We will define robot simply as an active, artificial agent whose environment is the
physical world.
 We will be concerned primarily with autonomous robots, those that make
decisions on their own, guided by the feedback they get from their physical
sensors.
01/16/2025 341
3.1 TASKS: WHAT ARE ROBOTS GOOD FOR?
 Manufacturing and materials handling: Material handling is the storage, transport,
and delivery of material, which can range in size from silicon chips to diesel trucks.
 Hazardous environments: mobile robots are an important technology for reducing
risk to human life in hazardous environments.
 Telepresence and virtual reality: The idea of staying in one's home and being able
to sense exotic environments, either real (telepresence) or imaginary (virtual reality)
is indeed compelling, and is a driving force behind some major moves in the
computer and entertainment industries.
01/16/2025 342
3.2 PARTS: WHAT ARE ROBOTS MADE OF?
 Effectors: Tools for action.
An effector is any device that affects the environment, under the control of the
robot.
To have an impact on the physical world, an effector must be equipped with an
actuator that converts software commands into physical motion.
The actuators themselves are typically electric motors or hydraulic or pneumatic
cylinders.
For simplicity, we will assume that each actuator determines a single motion or
degree of freedom.
01/16/2025 343
CONT…
Effectors are used in two main ways: to change the position of the robot within its
environment (locomotion), and to move other objects in the environment
(manipulation).
 Sensors:Tools for perception.
Like humans, robots have a proprioceptive sense that tells them where their joints are.
Encoders fitted to the joints provide very accurate data about joint angle or extension.
Even though robots can sense and control the positions of their joints much more
accurately than humans, there are still many tasks that cannot be carried out using only
position sensing.
In addition to this robots can sense the surrounding environment
01/16/2025 344
CONT…
 There are different types of sensors to sense the surrounding environment
Light Sensor:
Photovoltaic Cells - Photovoltaic cells are energy conversion device used to convert
solar radiation into electrical electric energy.
Proximity Sensor:
Infrared (IR) Transceivers - In IR sensor LED transmit the beam of IR light and if it
find an obstacle then the light is reflected back which is captured by an IR receiver.
Sound Sensor
Temperature Sensor
Acceleration Sensor
01/16/2025 345
3.3 LAWS OF ROBOT
 Law 1: a robot may not injure human being or through inaction, allows a human
being to came to harm.
 Law 2: a robot must obey orders given to it by human beings, except which this
orders would conflict with the first law.
 Law 3: a robot must protect its own existence as long as such protection does not
conflict with the first law.
01/16/2025 346
3.4 ADVANTAGES AND DIS ADVANTAGES OF ROBOTS
 Advantages of robotes
No human intervention
Faster precis and accurate
They can work 24*7, so productivity increases
They can perform multitasking, so man power gets reduced
They can work in dangerous tasks, the risk of human health and safety is reduced
There is minimal risk if any failure occurs
01/16/2025 347
CONT…
 Disadvantages of robots
 Robots are replacing human beings in many places which leads to widespread
unemployment.
 They are costly to build
 There is lack of emotions and conscience
 They don’t have on spot decision making capability, they act only as they
programmed.
01/16/2025 348
THE END OF CHAPTER SEVEN
01/16/2025 349
Thank you
!

More Related Content

Similar to Artificial intelligence using prolog software (20)

PPTX
1.Introductiontrdrdtrresrrzrexrextrtrc.pptx
gkavitha5225
 
PDF
AI CHAPTER 1.pdf
VatsalAgola
 
PPT
cloud computing and distributedcomputing
logesswari
 
PPTX
M01_Overview of Artificial Intelligence.pptx
sadhana312471
 
PPTX
Chapter_1_Introductnvjygcgfxhgfxhfxhgfion.pptx
gkavitha5225
 
PPT
1 Introduction to Articial intelligence.ppt
gadisaAdamu
 
PPT
Materi Transformasi Digital semester satu
syifamega26
 
PDF
Introduction to Artificial Intelligence - Cybernetics Robo Academy
TutulAhmed3
 
PPTX
Artificial Intelligence BCS51 Intelligent
Anil Yadav
 
PPTX
Module 01 IS & MLA.pptx for 22 scheme notes in a ppt form
chandushivamurthy4
 
PDF
2022CSC4331_Lecture1 Artificial intelligence.pdf
ShaibuAbdullateef
 
PPT
EELU AI lecture 1- fall 2022-2023 - Chapter 01- Introduction.ppt
DaliaMagdy12
 
PPT
Artificial Intelligence by B. Ravikumar
Garry D. Lasaga
 
PPTX
Artificial intelligence introduction
RujalShrestha2
 
PDF
Presentation of Intro to AI unit -3.pdf
mittalakshat1074
 
PPT
01 introduction
Nour Zeineddine
 
PDF
Artificial Intelligence in Manufacturing
Ambo university
 
PPTX
artificial intelligence bcs515b notes vtu
ashwiniiseait
 
PDF
Introduction to Artificial Intelligence: Concepts and Applications
Rashmi Bhat
 
PDF
Lecture 1.pdf
AsmaPervaiz5
 
1.Introductiontrdrdtrresrrzrexrextrtrc.pptx
gkavitha5225
 
AI CHAPTER 1.pdf
VatsalAgola
 
cloud computing and distributedcomputing
logesswari
 
M01_Overview of Artificial Intelligence.pptx
sadhana312471
 
Chapter_1_Introductnvjygcgfxhgfxhfxhgfion.pptx
gkavitha5225
 
1 Introduction to Articial intelligence.ppt
gadisaAdamu
 
Materi Transformasi Digital semester satu
syifamega26
 
Introduction to Artificial Intelligence - Cybernetics Robo Academy
TutulAhmed3
 
Artificial Intelligence BCS51 Intelligent
Anil Yadav
 
Module 01 IS & MLA.pptx for 22 scheme notes in a ppt form
chandushivamurthy4
 
2022CSC4331_Lecture1 Artificial intelligence.pdf
ShaibuAbdullateef
 
EELU AI lecture 1- fall 2022-2023 - Chapter 01- Introduction.ppt
DaliaMagdy12
 
Artificial Intelligence by B. Ravikumar
Garry D. Lasaga
 
Artificial intelligence introduction
RujalShrestha2
 
Presentation of Intro to AI unit -3.pdf
mittalakshat1074
 
01 introduction
Nour Zeineddine
 
Artificial Intelligence in Manufacturing
Ambo university
 
artificial intelligence bcs515b notes vtu
ashwiniiseait
 
Introduction to Artificial Intelligence: Concepts and Applications
Rashmi Bhat
 
Lecture 1.pdf
AsmaPervaiz5
 

Recently uploaded (20)

PDF
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
PDF
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PPTX
MiniTool Power Data Recovery Full Crack Latest 2025
muhammadgurbazkhan
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PDF
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
PPTX
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
PPTX
Platform for Enterprise Solution - Java EE5
abhishekoza1981
 
PDF
Streamline Contractor Lifecycle- TECH EHS Solution
TECH EHS Solution
 
PPT
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PPTX
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
PPTX
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PPTX
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Tally software_Introduction_Presentation
AditiBansal54083
 
MiniTool Power Data Recovery Full Crack Latest 2025
muhammadgurbazkhan
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
Platform for Enterprise Solution - Java EE5
abhishekoza1981
 
Streamline Contractor Lifecycle- TECH EHS Solution
TECH EHS Solution
 
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
Ad

Artificial intelligence using prolog software

  • 1. ARTIFICIAL INTELLIGENCE By: Dessalew G. BOOK : Artificial Intelligence A Modern Approach Stuart J. Russell and Peter Norvig
  • 3. 01/16/2025 3 LIST OF CONTENTS 1. Objectives/Goals of AI 2. What is AI? 3. Approaches to AI – making computer:  Think like a human ( Thinking humanly)  Act like a human (Acting humanly)  Think rationally (Thinking rationally)  Act rationally (Acting rationally) 4. The Foundations of AI 5. History and the State of the Art
  • 4. 01/16/2025 4 1. OBJECTIVES/GOALS OF AI  Humankind has given itself the scientific name homo sapiens: man the wise  It is because, our mental capacities are so important to our everyday lives and our sense of self.  The field of artificial intelligence, or AI, attempts to understand intelligent entities.  Thus, one reason to study it is to learn more about ourselves.  But unlike philosophy and psychology, which are also concerned with intelligence, AI strives to build intelligent entities as well as understand them
  • 5. 01/16/2025 5 CONT…  One of the goals of AI is to be a problem-solving machine.  There are already many computers that can solve problems, but only in a limited scope.  This said, a computer can only solve problems it is programed to solve or has the necessary information to solve; AIs do not yet have analytical capabilities.  Although AI does not have analytical abilities, some AI’s are much more efficient at solving problems than people are.
  • 6. 01/16/2025 6 CONT…  AI addresses one of the ultimate puzzles.  How is it possible for a slow, tiny brain, whether biological or electronic, to perceive, understand, predict, and manipulate a world far larger and more complicated than itself?  Alongside problem solving, another purpose of AI is learning.  Certain intelligent robots are able to achieve a desired result or overcome an obstacle in an unfamiliar situation by attempting different routes and memorizing the route that worked best, so they can be successful in the future when they are in a similar situation.
  • 7. 01/16/2025 7 CONT…  There is a limit to learning.  Some robots observe when humans interact socially and pick up visual and audio cues, allowing them to learn how to respond appropriately.  Other robots learn by mimicking human action.  However, AIs have no where near the learning capabilities of humans.  In a Stanford University article about AI, it is written that robots are not able to learn like children do.  we might see it in the near future
  • 8. 01/16/2025 8 CONT…  Some of the goals of AI like creating problem solving and learning machines are shared by many experts in the field, but there is still a plethora of varying objectives when it comes to AI.  The reason why there are no clear definitions or clear goals set for AI is because AI is still in its developmental stages.  Everyday researchers are bringing in new ideas to the field, meaning that AI is a malleable concept that has many open-ended avenues.  One of the trickiest and most complicated classifications of AI is that AI aims at human level intelligence.  Only time will tell us what AI is and what will come from it.
  • 9. 01/16/2025 9 2.WHAT IS AI  We have now explained why AI is exciting, but we have not said what it is.  We could just say, "Well, it has to do with smart programs, so let's get on and write some.  Artificial intelligence (AI): is intelligence demonstrated by machines, as opposed to natural intelligence displayed by animals including humans.  Leading AI textbooks define the field as the study of "intelligent agents": any system that perceives its environment and takes actions that maximize its chance of achieving its goals.
  • 10. 01/16/2025 10 CONT…  Some popular accounts use the term "artificial intelligence" to describe machines that mimic "cognitive" functions that humans associate with the human mind, such as "learning" and "problem solving", however, this definition is rejected by major AI researchers.  AI applications include:  advanced web search engines (i.e. Google),  recommendation systems (used by YouTube, Amazon and Netflix)  understanding human speech (such as Siri and Alexa),
  • 11. 01/16/2025 11 CONT…  self-driving cars (e.g.Tesla)  automated decision-making and competing at the highest level in strategic game systems (such as chess and Go).  As machines become increasingly capable, tasks considered to require "intelligence" are often removed from the definition of AI, a phenomenon known as the AI effect.  For instance, optical character recognition is frequently excluded from things considered to be AI, having become a routine technology.
  • 12. 01/16/2025 12 3. APPROACHES TO AI – MAKING COMPUTER:  Definitions of artificial intelligence according to eight recent textbooks:
  • 13. 01/16/2025 13 3.1 THINKING HUMANLY: THE COGNITIVE MODELLING APPROACH  Once we have a sufficiently precise theory of the mind, it becomes possible to express the theory as a computer program.  If the program's input/output and timing behavior matches human behavior, that is evidence that some of the program's mechanisms may also be operating in humans.  The interdisciplinary field of cognitive science brings together computer models from AI and experimental techniques from psychology to try to construct precise and testable theories of the workings of the human mind.
  • 14. 01/16/2025 14 CONT…  Real cognitive science, however, is necessarily based on experimental investigation of actual humans or animals, and authors assume that the reader only has access to a computer for experimentation.  We will note that AI and cognitive science continue to fertilize each other, especially in the areas of vision, natural language, and learning.  How to validate?  Predicting and testing behavior of human subjects (top-down)  Direct identification from neurological data (bottom-up)
  • 15. 01/16/2025 15 3.2 ACTING HUMANLY: THE TURING TEST APPROACH  Turing test: proposed by Alan Turing (1950), was designed to provide a satisfactory operational definition of intelligence.  Turing defined intelligent behavior as the ability to achieve human-level performance in all cognitive tasks, sufficient to fool an interrogator.  Roughly speaking, the test he proposed is that the computer should be interrogated by a human via a teletype, and passes the test if the interrogator cannot tell if there is a computer or a human at the other end.
  • 16. 01/16/2025 16 CONT…  The computer would need to possess the following capabilities:  Natural language processing: to enable it to communicate successfully in English (or some other human language); knowledge representation to store information provided before or during the interrogation;  Knowledge representation: to store information provided before or during the interrogation;  Automated reasoning: to use the stored information to answer questions and to draw new conclusions;  machine learning: to adapt to new circumstances and to detect and extrapolate patterns
  • 17. 01/16/2025 17 CONT…  Turing's test deliberately avoided direct physical interaction between the interrogator and the computer, because physical simulation of a person is unnecessary for intelligence.  Total Turing Test includes a video signal so that the interrogator can test the subject's perceptual abilities, as well as the opportunity for the interrogator to pass physical objects "through the hatch.“  To pass the total Turing Test, the computer will need:  Computer vision: to perceive objects, and  Robotics: to move them about.
  • 18. 01/16/2025 18 3.3 THINKING RATIONALLY: THE LAWS OF THOUGHT APPROACH  The Greek philosopher Aristotle was one of the first to attempt to codify "right thinking," that is, irrefutable reasoning processes.  His famous syllogisms provided patterns for argument structures that always gave correct conclusions given correct premises.  For example, "Socrates is a man; all men are mortal; therefore Socrates is mortal.“  These laws of thought were supposed to govern the operation of the mind, and initiated the field of logic
  • 19. 01/16/2025 19 CONT…  The development of formal logic in the late nineteenth and early twentieth centuries provided a precise notation for statements about all kinds of things in the world and the relations between them  By 1965, programs existed that could, given enough time and memory, take a description of a problem in logical notation and find the solution to the problem, if one exists  If there is no solution, the program might never stop looking for it  The so-called logicist tradition within artificial intelligence hopes to build on such programs to create intelligent systems
  • 20. 01/16/2025 20 3.4 ACTING RATIONALLY: THE RATIONAL AGENT APPROACH  Acting rationally means acting so as to achieve one's goals, given one's beliefs  An agent is just something that perceives and acts  In the "laws of thought" approach to AI, the whole emphasis was on correct inferences.  Making correct inferences is sometimes part of being a rational agent, because one way to act rationally is to reason logically to the conclusion that a given action will achieve one's goals, and then to act on that conclusion  On the other hand, correct inference is not all of rationality, because there are often situations where there is no provably correct thing to do, yet something must still be done
  • 21. 01/16/2025 21 CONT…  There are also ways of acting rationally that cannot be reasonably said to involve inference.  For example, pulling one's hand off of a hot stove is a reflex action that is more successful than a slower action taken after careful deliberation.  All the "cognitive skills" needed for the Turing Test are there to allow rational actions.  Thus, we need the ability to represent knowledge and reason with it because this enables us to reach good decisions in a wide variety of situations.
  • 22. 01/16/2025 22 CONT…  The study of AI as rational agent design therefore has two advantages.  First, it is more general than the "laws of thought" approach, because correct inference is only a useful mechanism for achieving rationality, and not a necessary one.  Second, it is more amenable to scientific development than approaches based on human behavior or human thought, because the standard of rationality is clearly defined and completely general.  Human behavior, on the other hand, is well-adapted for one specific environment and is the product, in part, of a complicated and largely unknown evolutionary process that still may be far from achieving perfection.
  • 23. 01/16/2025 23 4.THE FOUNDATIONS OF ARTIFICIAL INTELLIGENCE  Although AI itself is a young field, it has inherited many ideas, viewpoints, and techniques from other disciplines.  From over 2000 years of tradition in philosophy, theories of reasoning and learning have emerged.  From over 400 years of mathematics, we have formal theories of logic, probability, decision making, and computation.  From psychology, we have the tools with which to investigate the human mind, and a scientific language within which to express the resulting theories.  From linguistics, we have theories of the structure and meaning of language.  Finally, from computer science, we have the tools with which to make AI a reality.
  • 24. 01/16/2025 24 5. HISTORY AND THE STATE OF THE ART  Gestation (1943-1952)  Early learning theory, first neural network,Turing test  McCulloch and Pitts artificial neuron, Hebbian learning  Birth (1952 - 1956)  Name coined by McCarthy  Workshop at Dartmouth
  • 25. 01/16/2025 25 CONT…  Early enthusiasm, great expectations (1956-1966)  GPS, physical symbol system hypothesis  Geometry Theorem Prover (Gelertner), Checkers (Samuels)  Lisp (McCarthy),Theorem Proving (McCarthy), Microworlds (Minsky et. al.)  “neat” (McCarthy @ Stanford) vs.“scruffy” (Minsky @ MIT)  Dose of Reality (1966-1973)  Combinatorial explosion
  • 26. 01/16/2025 26 CONT…  Knowledge-based systems (1969-1979)  AI Becomes an Industry (1980-present)  Boom period 1980-88, then AI Winter  Return of Neural Networks (1986-present)  AI Becomes a Science (1987-present)  Security Orchestration, Automation and Response (SOAR)  Internet as a domain  The emergence of intelligent agents(1995-present)
  • 27. 01/16/2025 27 CONT… State of the art  Deep Blue defeated the reigning world chess champion Garry Kasparov in 1997  Proved a mathematical conjecture (Robbins conjecture) unsolved for decades  No hands across America (driving autonomously 98% of the time from Pittsburgh to San Diego)  During the 1991 Gulf War, US forces deployed an AI logistics planning and scheduling program that involved up to 50,000 vehicles, cargo, and people
  • 28. 01/16/2025 28 CONT…  NASA's on-board autonomous planning program controlled the scheduling of operations for a spacecraft  Proverb solves crossword puzzles better than most humans
  • 29. 01/16/2025 29 THE END OF CHAPTER ONE
  • 31. 01/16/2025 31 LIST OF CONTENTS 1. Introduction 2. Agents and Environments 3. Acting of Intelligent Agents (Rationality) 4. Structure of Intelligent Agents 5. Agent Types  Simple reflex agent  Model-based reflex agent  Goal-based agent  Utility-based agent  Learning agent 6. Important Concepts and Terms
  • 32. 01/16/2025 32 1. INTRODUCTION  An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment through effectors  A human agent has eyes, ears, and other organs for sensors, and hands, legs, mouth, and other body parts for effectors.  A robotic agent substitutes cameras and infrared range finders for the sensors and various motors for the effectors  A software agent has encoded bit strings as its percepts and actions
  • 34. 01/16/2025 34 2. AGENTS AND ENVIRONMENTS  Actions are done by the agent on the environment, which in turn provides percepts to the agent  Task environments are the problems While the rational agents are the solutions  Specifying the task environment, apply PEAS description as fully as possible  Performance  Environment  Actuators  Sensors  In designing an agent, the first step must always be to specify the task environment as fully as possible
  • 35. 01/16/2025 35 CONT…  Take taxi driver as an example, the following are the task environment descriptions. Agent type Performance measure Environment Actuator Sensor Taxi driver Safe, fast, legal, comfortable trip, maximize profits. Roads, other traffic, pedestrians, customers. Steering, accelerator, break, signal, horn, display. Cameras, sonar, speedometer, GPS, odometer, accelerometer, engine sensor, keyboard.
  • 36. 01/16/2025 36 CONT…  Properties of environment  Accessible vs. inaccessible. If an agent's sensory apparatus gives it access to the complete state of the environment, then we say that the environment is accessible to that agent An environment is effectively accessible if the sensors detect all aspects that are relevant to the choice of action An accessible environment is convenient because the agent need not maintain any internal state to keep track of the world
  • 37. 01/16/2025 37 CONT… Deterministic vs. nondeterministic If the next state of the environment is completely determined by the current state and the actions selected by the agents, then we say the environment is deterministic otherwise it is nondeterministic (stochastic). In principle, an agent need not worry about uncertainty in an accessible, deterministic environment. If the environment is inaccessible, however, then it may appear to be nondeterministic.
  • 38. 01/16/2025 38 CONT… This is particularly true if the environment is complex, making it hard to keep track of all the inaccessible aspects Thus, it is often better to think of an environment as deterministic or nondeterministic from the point of view of the agent Strategic environment: is deterministic except for actions of other agents Cleaner and taxi driver are:  Stochastic because of some unobservable aspects -noise or unknown
  • 39. 01/16/2025 39 CONT… Episodic vs. non-episodic In an episodic environment, the agent's experience is divided into "episodes.“  Each episode consists of the agent perceiving and then acting. The quality of its action depends just on the episode itself Because subsequent episodes do not depend on what actions occur in previous episodes. Episodic environments are much simpler because the agent does not need to think ahead. If Current action may affect all future decisions, then it is non-episodic or sequential An example is taxi driver
  • 40. 01/16/2025 40 CONT… Static vs. dynamic If the environment can change while an agent is deliberating, then we say the environment is dynamic for that agent, otherwise it is static Static environments are easy to deal with because the agent need not keep looking at the world while it is deciding on an action, nor need it worry about the passage of time If the environment does not change with the passage of time but the agent's performance score does, then we say the environment is semi-dynamic • An example of dynamic environment: the number of people in the street (taxi) • An example of static environment: the destination (taxi)
  • 41. 01/16/2025 41 CONT… Discrete vs. continuous If there are a limited number of distinct, clearly defined percepts and actions, we say that the environment is discrete. Chess is discrete: there are a fixed number of possible moves on each turn. Taxi driving is continuous: the speed and location of the taxi and the other vehicles sweep through a range of continuous values
  • 42. 01/16/2025 42 CONT… Single agentVS. multi-agent Playing a crossword puzzle: single agent Chess playing: two agents Competitive multi-agent environment • Chess playing Cooperative multi-agent environment • Automated taxi driver: avoiding collision
  • 43. 01/16/2025 43 CONT…  An examples of properties of an environment
  • 44. 01/16/2025 44 3. ACTING OF INTELLIGENT AGENTS (RATIONALITY)  Rational agent  One that does the right thing  Every entry in the table for the agent function is correct (rational)  What is correct?  The actions that cause the agent to be most successful  The problem is deciding how and when to evaluate the agent's success  We use the term performance measure for the how the criteria that determine how successful an agent is
  • 45. 01/16/2025 45 CONT…  Performance measure  An objective function that determines how the agent does successfully  E.g., 90% or 30% ?  An agent, based on its percepts:  If desirable, it is said to be performing well  No universal performance measure for all agents
  • 46. 01/16/2025 46 CONT…  Consider the case of an agent that is supposed to vacuum a dirty floor: A plausible performance measure would be the amount of dirt cleaned up in a single eight-hour shift. A more sophisticated performance measure would factor in the amount of electricity consumed and the amount of noise generated as well. A third performance measure might give highest marks to an agent that not only cleans the floor quietly and efficiently, but also finds time to go windsurfing at the weekend
  • 47. 01/16/2025 47 CONT…  Rationality What is rational at any given time depends on four things:  The performance measure defining the degree of success  The agent's percept sequence up to now (perceptual history)  The agent’s prior knowledge of the environment  The actions that the agent can perform
  • 48. 01/16/2025 48 CONT…  Ideal rational agent For each possible percept sequence, an ideal rational agent should: Do whatever action is expected To maximize its performance measure, on the basis of the evidence provided By the percept sequence and Whatever built-in knowledge the agent has.  E.g.Taxi driver have to look right and left while crossing
  • 49. 01/16/2025 49 CONT…  An omniscient agent  Knows the actual outcome of its actions in advance  No other possible outcomes  However, impossible in real world An example: crossing a street but died of the fallen cargo door from 33,000ft o Rational but not omniscient o Hence, all rational agents are not omniscient
  • 50. 01/16/2025 50 CONT…  Autonomy If an agent just relies on the prior knowledge of its designer rather than its own percepts then the agent lacks autonomy.  A rational agent should be autonomous: it should learn what it can to compensate for partial or incorrect prior knowledge.  E.g. a clock  No input (percepts)  Run only by its own algorithm (prior knowledge)  No learning, no experience, etc.
  • 51. 01/16/2025 51 4.STRUCTURE OF INTELLIGENT AGENTS  So far we have talked about agents by describing their behavior Action that is performed after any given sequence of percepts  Now, we will talk about how the insides work.  The job of AI is to design the agent program: a function that implements the agent mapping from percepts to actions  Agent = architecture + program  Architecture = some sort of computing device (sensors + actuators)  (Agent) Program = some function that implements the agent mapping = “?”
  • 52. 01/16/2025 52 CONT…  Before we design an agent program, we must have a pretty good idea of the possible: percepts and actions, what goals or performance measure the agent is supposed to achieve, what sort of environment it will operate in.  These come in a wide variety
  • 53. 01/16/2025 53 CONT…  Basic elements for a selection of agent types:
  • 54. 01/16/2025 54 CONT…  Agent programs All agent programs have the same skeleton, namely, accepting percepts from an environment and generating actions The early versions of agent programs will have a very simple form This skeleton has two issues:
  • 55. 01/16/2025 55 CONT… 1. First, even though we defined the agent mapping as a function from percept sequences to actions, the agent program receives only a single percept as its input. 2. Second, the goal or performance measure is not part of the skeleton program. Then what is the solution? The simplest possible way we can think of to write the agent program is a lookup table It operates by keeping in memory its entire percept sequence, and using it to index into table, which contains the appropriate action for all possible percept
  • 56. 01/16/2025 56 CONT…  It keeps track of the percept sequence and just looks up the best action. o P = the set of possible percepts o T= lifetime of the agent o The total number of percepts it receives o Size of the look up table   T t t P 1 o Consider playing chess o P =10,T=150 o Will require a table of at least 10150 entries
  • 57. 01/16/2025 57 5. AGENT TYPES  Four types  Simple reflex agents  Model-based reflex agents  Goal-based agents  Utility-based agents
  • 58. 01/16/2025 58 CONT…  Simple reflex agents  It uses just condition-action rules  The rules are like the form “if … then …”  Efficient but have narrow range of applicability  Because knowledge sometimes cannot be stated explicitly  Work only if the environment is fully observable
  • 59. 01/16/2025 59 CONT…  Schematic diagram of a simple reflex agent
  • 60. 01/16/2025 60 CONT…  The agent program for simple reflex agent:
  • 61. 01/16/2025 61 CONT…  Model-based Reflex Agents For the world that is partially observable:  The agent has to keep track of an internal state  That depends on the percept history  Reflecting some of the unobserved aspects  E.g., driving a car and changing lane  Requiring two types of knowledge  How the world evolves independently of the agent  How the agent’s actions affect the world
  • 62. 01/16/2025 62 CONT…  Schematic diagram of model-based agent
  • 63. 01/16/2025 63 CONT…  Agent program for model-based agent
  • 64. 01/16/2025 64 CONT…  Goal-based agent  Knowing about the current state of the environment is not always enough to decide what to do  As well as a current state description, the agent needs some sort of goal information  Goal-based agents are less efficient but, more flexible  Agent  Different goals  different tasks  Search and planning are two other sub-fields in AI to find out the action sequences to achieve its goal
  • 65. 01/16/2025 65 CONT…  Schematic diagram of goal-based agent 
  • 66. 01/16/2025 66 CONT…  Agent program for goal-based agent
  • 67. 01/16/2025 67 CONT…  Utility-based agents  Goals alone are not enough to generate high-quality behavior  For example, there are many action sequences that will get the taxi to its destination  Thereby achieving the goal, but some are quicker, safer, more reliable, or cheaper than others.  Goals just provide a crude distinction between "happy" and "unhappy" states  whereas a more general performance measure should allow a comparison of different world states (or sequences of states) according to exactly how happy they would make the agent if they could be achieved
  • 68. 01/16/2025 68 CONT…  Because "happy" does not sound very scientific, the customary terminology is to say that if one world state is preferred to another, then it has higher utility for the agent.  Utility is therefore a function that maps a state onto a real number, which describes the associated degree of happiness.  It is said state A has higher utility If state A is more preferred than others  Then utility means the degree of success
  • 69. 01/16/2025 69 CONT…  Schematic diagram of utility-based agent
  • 70. 01/16/2025 70 CONT…  Learning agent After an agent is programmed, can it work immediately?  No, it still need teaching In AI,  Once an agent is done  We teach it by giving it a set of examples  Test it by using another set of examples We then say the agent learns  A learning agent
  • 71. 01/16/2025 71 CONT… Four conceptual components  Learning element  Making improvement  Performance element  Selecting external actions
  • 72. 01/16/2025 72 CONT…  Critic  Tells the Learning element how well the agent is doing with respect to fixed performance standard.  (Feedback from user or examples, good or not?)  Problem generator  Suggest actions that will lead to new and informative experiences.
  • 73. 01/16/2025 73 CONT…  Schematic diagram of learning agent
  • 74. 01/16/2025 74 6. IMPORTANT CONCEPTS AND TERMS  Percept  Agent’s perceptual inputs at any given instant  Percept sequence  Complete history of everything that the agent has ever perceived.  Agent function & program Agent’s behavior is mathematically described by  Agent function: it is a function mapping any given percept sequence to an action  Practically it is described by:  An agent program (the real implementation)
  • 75. 01/16/2025 75 CONT…  Vacuum-cleaner world Perception: Clean or Dirty? where it is in? Actions: Move left, Move right, suck, do nothing
  • 76. 01/16/2025 76 CONT…  Partial tabulation of a simple agent function for Vacuum-cleaner world
  • 77. 01/16/2025 77 CONT…  Program implementation Vacuum-cleaner world Function Reflex-Vacuum-Agent([location, status]) return an action If status = Dirty then return Suck else if location = A then return Right else if location = B then return left
  • 78. 01/16/2025 78 THE END OF CHAPTER TWO
  • 79. CHAPTER THREE Solving Problems by Searching and Constraint Satisfaction Problem
  • 80. 01/16/2025 80 LIST OF CONTENTS 1. Problem Solving by Searching 2. Problem Solving Agents 3. Problem Formulation 4. Search Strategies 5. Avoiding Repeated States 6. Constraint Satisfaction Search 7. Games as Search Problems
  • 81. 01/16/2025 81 1. PROBLEM SOLVING BY SEARCHING  Simple reflex agents are limited in what they can do  Because, their actions are determined only by the current percept  Furthermore, they have no knowledge of what their actions do nor of what they are trying to achieve  They can’t work well in environments which this mapping would be too large to store and would take too long to learn  Hence, goal-based agent is used
  • 82. 01/16/2025 82 CONT…  Goal-based agents can succeed by considering future actions and the desirability of their outcomes  Goal-based agents that use more advanced factored or structured representations are usually called planning agents  Uninformed and informed search algorithms are used to create solution for problems
  • 83. 01/16/2025 83 2. PROBLEM-SOLVING AGENTS  Problem-solving agent is A kind of goal-based agent, It solves problem by finding sequences of actions that lead to desirable states (goals)  To solve a problem, the first step is the goal formulation, based on the current situation  The goal is formulated as a set of world states, in which the goal is satisfied
  • 84. 01/16/2025 84 CONT…  To reaching from initial state to goal state Actions are required  Actions are the operators causing transitions between world states Actions should be abstract enough at a certain degree, instead of very detailed E.g., turn left VS turn left 30 degree, etc.
  • 85. 01/16/2025 85 3. PROBLEM FORMULATION  Problem formulation: is the process of deciding what actions and states to consider, and follows goal formulation  An agent with several immediate options of unknown value can decide what to do by first examining ; different possible sequences of actions that lead to states of known value, and then choosing the best one  This process of looking for such a sequence is called search  A search algorithm takes a problem as input and returns a solution in the form of an action sequence
  • 86. 01/16/2025 86 CONT…  Once a solution is found, the actions it recommends can be carried out.  This is called the execution phase  Thus, we have a simple "formulate, search, execute" design for the agent  There are four essentially different types of problems: Single state problems, Multiple-state problems, Contingency problems, and Exploration problems R e a d i n g a s s i g n m e n t
  • 88. 01/16/2025 88 CONT…  Well-defined problems and solutions A problem is really a collection of information that the agent will use to decide what to do A problem is defined by 5 components: Initial state Actions Transition model or (Successor functions)  Goal Test Path Cost
  • 89. 01/16/2025 89 CONT… The initial state that the agent knows itself to be in. The set of possible actions available to the agent. The term operator is used to denote the description of an action in terms of which state will be reached by carrying out the action in a particular state (An alternate formulation uses a successor function S. Together, these define the state space of the problem: the set of all states reachable from the initial state by any sequence of actions.
  • 90. 01/16/2025 90 CONT… A path in the state space is simply any sequence of actions leading from one state to another The goal test applied to the current state to test if the agent is in its goal Sometimes there is an explicit set of possible goal states Sometimes the goal is described by the properties instead of stating explicitly the set of states Example: Chess o The agent wins if it can capture the KING of the opponent on next move ( checkmate). o No matter what the opponent does
  • 91. 01/16/2025 91 CONT… A path cost function is a function that assigns a cost to a path. The cost of a path is the sum of the costs of the individual actions along the path. The path cost function is often denoted by g The solution of a problem is then a path from the initial state to a state satisfying the goal test Optimal solution is the solution with lowest path cost among all solutions
  • 92. 01/16/2025 92 CONT…  Measuring problem-solving performance Completeness: is the strategy guaranteed to find a solution when there is one? Optimality: does the strategy find the highest-quality solution when there are several different solutions? Time complexity: how long does it take to find a solution? Space complexity: how much memory is needed to perform the search?
  • 93. 01/16/2025 93 CONT… In AI, complexity is expressed in b, branching factor, maximum number of successors of any node d, the depth of the shallowest goal node. (depth of the least-cost solution) m, the maximum length of any path in the state space Time and Space is measured in number of nodes generated during the search maximum number of nodes stored in memory
  • 94. 01/16/2025 94 CONT… For effectiveness of a search algorithm we can just consider the total cost The total cost = path cost (g) of the solution found + search cost search cost = time necessary to find the solution Tradeoff: (long time, optimal solution with least g) vs. (shorter time, solution with slightly larger path cost g)
  • 95. 01/16/2025 95 4. SEARCH STRATEGIES  Because there are many ways to achieve the same goal Those ways are together expressed as a tree Multiple options of unknown value at a point, the agent can examine different possible sequences of actions, and choose the best This process of looking for the best sequence is called search The best sequence is then a list of actions, called solution
  • 96. 01/16/2025 96 CONT…  It is helpful to think of the search process as building up a search tree  The root of the search tree is a search node corresponding to the initial state  The leaf nodes of the tree correspond to states that do not have successors in the tree, It is either because they have not been expanded yet, or because they were expanded, but generated the empty set  At each step, the search algorithm chooses one leaf node to expand
  • 98. 01/16/2025 98 CONT…  The majority of work in the area of search has gone into finding the right search strategy for a problem  In our study of the field we will evaluate strategies in terms of four criteria: 1. Completeness: is the strategy guaranteed to find a solution when there is one? 2. Time complexity: how long does it take to find a solution? 3. Space complexity: how much memory does it need to perform the search? 4. Optimality: does the strategy find the highest-quality solution when there are several different solutions
  • 99. 01/16/2025 99 CONT…  Uninformed search (blind search) no information about the number of steps or the path cost from the current state to the goal search the state space blindly  Informed search, or heuristic search a cleverer strategy that searches toward the goal, based on the information from the current state so far
  • 100. 01/16/2025 100 CONT…  The six Uninformed search strategies Breadth-first search Uniform cost search Depth-first search Depth-limited search Iterative deepening search Bidirectional search
  • 101. 01/16/2025 101 CONT…  Breadth-first search The root node is expanded first (FIFO) All the nodes generated by the root node are then expanded And then their successors and so on In general, all the nodes at depth d in the search tree are expanded before the nodes at depth d + 1 Can be implemented by GENERAL SEARCH algorithm
  • 103. 01/16/2025 103 CONT…  Breadth first search analysis Complete – find the solution eventually Optimal, if step cost is 1 The disadvantage if the branching factor of a node is large, for even small instances (e.g., chess) the space complexity and the time complexity are enormous
  • 104. 01/16/2025 104 CONT…  Properties of breadth-first search Complete? Yes (if b is finite) Time? 1+b+b2 +b3 +… +bd = b(bd -1) = O(bd+1 ) Space? O(bd+1 ) (keeps every node in memory) Optimal? Yes (if cost = 1 per step) Space is the bigger problem (more than time)
  • 105. 01/16/2025 105 CONT…  assuming 10,000 nodes can be processed per second, each with 1000 bytes of storage:
  • 106. 01/16/2025 106 CONT…  Uniform cost search Breadth-first finds the shallowest goal state but not necessarily be the least-cost solution work only if all step costs are equal Uniform cost search modifies breadth-first strategy by always expanding the lowest-cost node The lowest-cost node is measured by the path cost g(n)
  • 107. 01/16/2025 107 CONT…  It is easy to see that breadth-first search is just uniform cost search with g(n) = DEPTH(n)  When certain conditions are met: the first solution that is found is guaranteed to be the cheapest solution, because if there were a cheaper path that was a solution, it would have been expanded earlier, and thus would have been found first
  • 108. 01/16/2025 108 CONT…  Consider the following route finding problem A route-finding problem: (a) The state space, showing the cost for each operator, (b) Progression of the search. Each node is labelled with g(n). At the next step, the goal node with g = 10 will be selected
  • 109. 01/16/2025 109 CONT…  The problem is to get from S to G and the cost of each operator is marked  The strategy first expands the initial state, yielding paths to A, B, and C  Because the path to A is cheapest, it is expanded next, generating the path SAG, which is in fact a solution, though not the optimal one  However, the algorithm does not yet recognize this as a solution, because it has cost 11, and thus is buried in the queue below the path SB, which has cost 5  The next step is to expand SB, generating SBG, which is now the cheapest path remaining in the queue, so it is goal-checked and returned as the solution
  • 110. 01/16/2025 110 CONT…  Uniform cost search finds the cheapest solution provided a simple requirement is met:  The cost of a path must never decrease as we go along the path.  In other words, we insist that: g(SUCCESSOR(n)) > g(n) for every node n  The cost of a path can never decrease as we go along the path, unless it is negative and uniform-cost search can find the cheapest path without exploring the whole search tree
  • 111. 01/16/2025 111 CONT…  Depth-first search  Depth-first search always expands one of the nodes at the deepest level of the tree  Only when the search hits a dead end (a non-goal node with no expansion) does the search go back and expand nodes at shallower levels  This strategy can be implemented by GENERAL-SEARCH with a queuing function that always puts the newly generated states at the front of the queue.
  • 112. 01/16/2025 112 CONT…  Because the expanded node was the deepest, its successors will be even deeper and are therefore now the deepest  Depth-first search has very modest memory requirements.  It needs to store only a single path from the root to a leaf node  along with the remaining unexpanded sibling nodes for each node on the path  branching factor b and max depth m, depth-first search requires storage of only bm nodes,  in contrast to the bd that would be required by breadth-first search in the case where the shallowest goal is at depth d.
  • 113. 01/16/2025 113 CONT…  E.g S A D B D A E C E E B B F D F B F C E A C G G C G F 14 19 19 17 17 15 15 13 G 25 11
  • 114. 01/16/2025 114 CONT…  The drawback of depth-first search is that it can get stuck going down the wrong path  Many problems have very deep or even infinite search trees, so depth-first search will never be able to recover from an unlucky choice at one of the nodes near the top of the tree  That means depth-first search is neither complete nor optimal  Because of this, depth-first search should be avoided for search trees with large or infinite maximum depths
  • 115. 01/16/2025 115 CONT…  Depth limited search  Depth-limited search avoids the pitfalls of depth-first search by imposing a cutoff on the maximum depth of a path  This cutoff can be implemented with a special depth-limited search algorithm  We are guaranteed to find the solution if it exists, but we are still not guaranteed to find the shortest solution first  depth-limited search is complete but not optimal
  • 116. 01/16/2025 116 CONT…  If we choose a depth limit that is too small, then depth-limited search is not even complete  The time and space complexity of depth-limited search is similar to depth-first search  It takes O(bl ) time and O(bl ) space, where l is the depth limit
  • 117. 01/16/2025 117 CONT…  Iterative deepening search The hard part about depth-limited search is picking a good limit For most problems, we will not know a good depth limit until we have solved the problem Iterative deepening search: is a strategy that sidesteps the issue of choosing the best depth limit by trying all possible depth limits Iterative deepening combines the benefits of depth-first and breadth-first search
  • 118. 01/16/2025 118 CONT… It is optimal and complete:  like breadth-first search, but has only the modest memory requirements of depth-first search The order of expansion of states is similar to breadth-first, except that some states are expanded multiple times
  • 119. 01/16/2025 119 CONT… E.g Four iterations of iterative deepening search on a binary tree
  • 120. 01/16/2025 120 CONT…  Properties of iterative deepening search Complete? Yes Time? (d+1)b0 + d b1 + (d-1)b2 + … + bd = O(bd ) Space? O(bd) Optimal? Yes, if step cost = 1 In general, iterative deepening is the preferred search method when there is a large search space and the depth of the solution is not known.
  • 121. 01/16/2025 121 CONT…  Bidirectional search Run two simultaneous searches: one forward from the initial state another backward from the goal stop when the two searches meet For problems where the branching factor is b in both directions:  bidirectional search can make a big difference
  • 122. 01/16/2025 122 CONT… If we assume as usual that there is a solution of depth d: then the solution will be found in O(2bd/2 ) = O(bd/2 ) steps, because the forward and backward searches each have to go only half way. However, computing backward is difficult The main question is, what does it mean to search backwards from the goal? Searching backward means generating predecessors successively starting from the goal node. can the actions be reversible to compute its predecessors?
  • 123. 01/16/2025 123 CONT… What can be done if there are many possible goal states? We need to decide what kind of search is going to take place in each half For example the following figure shows two breadth-first searches
  • 125. 01/16/2025 125 5. AVOIDING REPEATED STATES  Up to this point, we have all but ignored one of the most important complications to the search process: the possibility of wasting time by expanding states that have already been encountered and expanded before on some other path For example: rout finding problem This may cause the path to be infinite  loop forever Even if the tree is finite, avoiding repeated states can yield an exponential reduction in search cost
  • 126. 01/16/2025 126 CONT…  E.g. A state space that generates an exponentially larger search tree. The left-hand side shows the state space, in which there are two possible actions leading from A to B, two from B to C, and so on. The right-hand side shows the corresponding search tree.
  • 127. 01/16/2025 127 CONT…  There are three ways to deal with repeated states 1. Do not return to the state you just came from 2. Do not create paths with cycles in them 3. Do not generate any state that was ever generated before
  • 128. 01/16/2025 128 6. CONSTRAINT SATISFACTION SEARCH  A constraint satisfaction problem (or CSP):  is a special kind of problem that satisfies some additional structural properties beyond the basic requirements  In a CSP, the states are defined by the values of a set of variables and the goal test specifies a set of constraints that the values must obey
  • 129. 01/16/2025 129 CONT…  For example, the 8-queens problem can be viewed as a CSP  variables are the locations of each of the eight queens; the possible values are squares on the board; the constraints state that no two queens can be in the same row, column or diagonal  Each variable Vi in a CSP has a domain Di, which is the set of possible values that the variable can take on The domain can be discrete or continuous
  • 130. 01/16/2025 130 CONT…  Let us first consider how we might apply a general-purpose search algorithm to a CSP: The initial state will be the state in which all the variables are unassigned Operators will assign a value to a variable from the set of possible values The goal test will check if all variables are assigned and all constraints satisfied Notice that, the maximum depth of the search tree is fixed at n, the number of variables, and that all solutions are at depth n
  • 131. 01/16/2025 131 CONT… We are therefore safe in using depth-first search, as there is no danger of going too deep and no arbitrary depth limit is needed Depth-first search on a CSP wastes time searching when constraints have already been violated Because of the way that the operators have been defined, an operator can never redeem a constraint that has already been violated
  • 132. 01/16/2025 132 CONT… For example, suppose that we put the first two queens in the top row Depth-first search will examine all 86 possible positions for the remaining six queens before discovering that no solution exists in that subtree Our first improvement is therefore to insert a test before the successor generation step to check whether any constraint has been violated by the variable assignments made up to this point The resulting algorithm, called backtracking search, then backtracks to try something else.
  • 133. 01/16/2025 133 CONT… Backtracking also has some obvious failings Suppose that the squares chosen for the first six queens make it impossible to place the eighth queen, because they attack all eight squares in the last column. Backtracking will try all possible placings for the seventh queen, even though the problem is already rendered unsolvable, given the first six choices Forward checking avoids this problem by looking ahead to detect un-solvability
  • 134. 01/16/2025 134 7. GAMES AS SEARCH PROBLEMS  Games have engaged the intellectual faculties of humans sometimes to an alarming degree for as long as civilization has existed  Board games such as chess and Go are interesting in part because they offer pure, abstract competition, without the fuss and bother of mustering up two armies and going to war  It is this abstraction that makes game playing an appealing target of AI research.  The state of a game is easy to represent, and agents are usually restricted to a fairly small number of well-defined actions
  • 135. 01/16/2025 135 CONT…  That makes game playing an idealization of worlds in which hostile agents act so as to diminish one's well-being  Less abstract games, such as croquet or football, have not attracted much interest in the AI community  Early researchers chose chess for several reasons  A chess-playing computer would be an existence proof of a machine doing something thought to require intelligence
  • 136. 01/16/2025 136 CONT…  Perfect decisions in two-person games  We will consider game with two players, whom we will call MAX and M1N  MAX moves first, and then they take turns moving until the game is over  At the end of the game, points are awarded to the winning player (or sometimes penalties are given to the loser)  A game can be formally defined as a kind of search problem with the following components:
  • 137. 01/16/2025 137 CONT…  The initial state, which includes the board position and an indication of whose move it is  A set of operators, which define the legal moves that a player can make  A terminal test, which determines when the game is over  A terminal states is states where the game has ended  A utility function (also called a payoff function), which gives a numeric value for the outcome of a game
  • 138. 01/16/2025 138 CONT…  The minimax algorithm is designed to determine the optimal strategy for MAX, and thus to decide what the best first move is  The algorithm has five steps: 1. Generate the whole game tree, all the way down to the terminal states 2. Apply the utility function to each terminal state to get its value 3. Use the utility of the terminal states to determine the utility of the nodes one level higher up in the search tree
  • 139. 01/16/2025 139 CONT… 4. Continue backing up the values from the leaf nodes toward the root, one layer at a time 5. Eventually, the backed-up values reach the top of the tree; at that point, MAX chooses the move that leads to the highest value
  • 140. 01/16/2025 140 CONT…  Imperfect decisions  The minimax algorithm assumes that the program has time to search all the way to terminal states, which is usually not practical  Shannon's original paper on chess proposed that instead of going all the way to terminal states and using the utility function, the program should cut off the search earlier and apply a heuristic evaluation function to the leaves of the tree  An evaluation function returns an estimate of the expected utility of the game from a given position
  • 141. 01/16/2025 141 CONT…  Alpha-beta pruning  It is possible to compute the correct minimax decision without looking at every node in the search tree.  The process of eliminating a branch of the search tree from consideration without examining it is called pruning the search tree
  • 142. 01/16/2025 142 CONT…  Games that include an element of chance  In real life, unlike chess, there are many unpredictable external events that put us into unforeseen situations  Many games mirror this unpredictability by including a random element such as throwing dice  In this way, they take us a step nearer reality, and it is worthwhile to see how this affects the decision-making process
  • 143. 01/16/2025 143 CONT…  Backgammon is a typical game that combines luck and skill  Dice are rolled at the beginning of a player's turn to determine the set of legal moves that is available to the player
  • 144. 01/16/2025 144 CONT…  State of the art Chess Checkers or Draughts Othello Backgammon Go
  • 145. 01/16/2025 145 THE END OF CHAPTER THREE
  • 147. 01/16/2025 147 LIST OF CONTENTS 1. Logical Agents 2. Propositional Logic 3. Predicate (First-Order)Logic 4. Inference in First-Order Logic 5. Knowledge-based Systems (prolog)
  • 148. 01/16/2025 148 1. LOGICAL AGENTS  Knowledge-based agents are able to accept new tasks in the form of explicitly described goals. they can achieve competence quickly by being told or learning new knowledge about the environment they can adapt to changes in the environment by updating the relevant knowledge A knowledge-based agent needs to know many things:
  • 149. 01/16/2025 149 CONT… the current state of the world how to infer unseen properties of the world from percepts how the world evolves over time what it wants to achieve what its own actions do in various circumstances
  • 150. 01/16/2025 150 CONT…  The central component of a knowledge-based agent is, its knowledge base, or KB  knowledge base is a set of representations of facts about the world  Each individual representation is called a sentence  The sentences are expressed in a language called a knowledge representation language  There must be a way to add new sentences to the knowledge base, and a way to query what is known  The standard names for these tasks are TELL and ASK, respectively
  • 151. 01/16/2025 151 CONT…  Determining what follows from what the KB has been TELLed is the job of the inference mechanism  At any point, we can describe a knowledge-based agent at three levels: 1. The knowledge level or epistemological level: is the most abstract; we can describe the agent by saying what it knows 2. The logical level: is the level at which the knowledge is encoded into sentences 3. The implementation level: is the level that runs on the agent architecture
  • 152. 01/16/2025 152 1.1 THE WUMPUS WORLD ENVIRONMENT  Wumpus world: provides plenty of motivation for logical reasoning  Wumpus was an early computer game, based on an agent who explores a cave consisting of rooms connected by passageways Lurking somewhere in the cave is the wumpus, a beast that eats anyone who enters its room The only mitigating feature of living in this environment is the occasional heap of gold  How wompus world environment works has been discussed next:
  • 153. 01/16/2025 153 CONT… Specifying the environment Like the vacuum world, the wumpus world is a grid of squares surrounded by walls, where each square can contain agents and objects. The agent always starts in the lower left corner, a square that we will label [1,1]. The agent's task is to find the gold, return to [1,1] and climb out of the cave.
  • 155. 01/16/2025 155 CONT…  From the fact that there was no stench or breeze in [1,1],  the agent can infer that [1,2] and [2,1] are free of dangers.  They are marked with an OK to indicate this.  From the fact that the agent is still alive, it can infer that [1,1 ] is also OK.  A cautious agent will only move into a square that it knows is OK.  Let us suppose the agent decides to move forward to [2,1], giving the scene in Figure one(b).
  • 156. 01/16/2025 156 CONT…  The agent detects a breeze in [2,1], so there must be a pit in a neighboring square, either [2,2] or [3,1].  The notation P? indicates a possible pit.  The pit cannot be in [1,1], because the agent was already there and did not fall in.  At this point, there is only one known square that is OK and has not been visited yet.  So the prudent agent will turn around, go back to [1,1], and then proceed to [1,2], giving the state of knowledge in Figure two(a).
  • 157. 01/16/2025 157 CONT…  The agent detects a stench in [1,2], which means that there must be a wumpus nearby.  But the wumpus cannot be in [1,1] (or it would have eaten the agent at the start), and it cannot be in[2,2] (or the agent would have detected a stench when it was in [2,1]).  Therefore, the agent can infer that the wumpus is in [1,3].  The notation W! indicates this.  More interesting is that the lack of a Breeze percept in [1,2] means that there must be a pit in [3,1].
  • 158. 01/16/2025 158 CONT…  The reasoning is that no breeze in [1,2] means there can be no pit in [2,2].  But we already inferred that there must be a pit in either [2,2] or [3,1], so this means it must be in [3,1].  This is a fairly difficult inference, because it combines knowledge gained at different times in different places, and relies on the lack of a percept to make one crucial step.  The inference is beyond the abilities of most animals, but it is typical of the kind of reasoning that a logical agent does
  • 159. 01/16/2025 159 CONT…  After these impressive deductions, there is only one known unvisited OK square left, [2,2], so the agent will move there.  We will not show the agent's state of knowledge at [2,2]; we just assume the agent turns and moves to [2,3], giving us Figure two(b).  In [2,3], the agent detects a glitter, so it should grab the gold and head for home, making sure its return trip only goes through squares that are known to be OK.
  • 160. 01/16/2025 160 1.2 REPRESENTATION, REASONING, AND LOGIC  Together, representation and reasoning support the operation of a knowledge- based agent  The objective of knowledge representation is to express knowledge in computer- tractable form, such that it can be used to help agents perform well.  A knowledge representation language is defined by two aspects: 1. syntax: describes the possible configurations that can constitute sentences. 2. semantics: determines the facts in the world to which the sentences refer.
  • 161. 01/16/2025 161 CONT…  For example, the syntax of the language of arithmetic expressions says that if x and y are expressions denoting numbers, then x > y is a sentence about numbers The semantics of the language says that x > y is false when y is a bigger number than x, and true otherwise  Provided the syntax and semantics are defined precisely, we can call the language a logic
  • 162. 01/16/2025 162 CONT…  From the syntax and semantics, we can derive an inference mechanism for an agent that uses the language  Semantics of the language determine the fact to which a given sentence refers  Facts are part of the world, whereas their representations must be encoded in some way that can be physically stored within an agent  We want to generate new sentences that are necessarily true, given that the old sentences are true.  This relation between sentences is called entailment
  • 163. 01/16/2025 163 CONT… In mathematical notation, the relation of entailment between a knowledge base KB and a sentence a is pronounced "KB entails a" and written as KB |=a
  • 164. 01/16/2025 164 CONT…  An inference procedure is complete if it can find a proof for any sentence that is entailed  Logics To summarize, we can say that a logic consists of the following: 1. A formal system for describing states of affairs, consisting of a) the syntax of the language, which describes how to make sentences b) the semantics of the language, which states the systematic constraints on how sentences relate to states of affairs
  • 165. 01/16/2025 165 CONT… 2. The proof theory: a set of rules for deducing the entailments of a set of sentences o We will concentrate on two kinds of logic: propositional or Boolean logic, and first-order logic o It is illuminating to consider logics in the light of their ontological and epistemological commitments. • Ontological commitments have to do with the nature of reality • Epistemological commitments have to do with the possible states of knowledge an agent can have using various types of logic
  • 166. 01/16/2025 166 CONT…  Formal languages and their ontological and epistemological commitments
  • 167. 01/16/2025 167 2. PROPOSITIONAL LOGIC  Despite its limited expressiveness, prepositional logic serves to illustrate many of the concepts of logic just as well as first-order logic  Its syntax, semantics, and associated inference procedures are discussed next
  • 168. 01/16/2025 168 2.1 SYNTAX  The syntax of prepositional logic is simple  The symbols of prepositional logic are the logical constants True and False, proposition symbols such as P and Q, the logical connectives A,V, , =>, and ¬, and parentheses, ().  The logical constants True and False are sentences by themselves.  A prepositional symbol such as P or Q is a sentence by itself.  Wrapping parentheses around a sentence yields a sentence, for example, (P A Q).
  • 169. 01/16/2025 169 CONT…  A sentence can be formed by combining simpler sentences with one of the five logical connectives:  A (and). A sentence whose main connective is A, such as P A (Q V R), is called a conjunction (logic); its parts are the conjuncts. (The A looks like an "A" for "And.")  V (or). A sentence using V, such as A V (P A Q), is a disjunction of the disjoints A and (P A Q). (Historically, the V comes from the Latin "vel," which means "or." For most people, it is easier to remember as an upside-down and.)
  • 170. 01/16/2025 170 CONT…  =>(implies). A sentence such as (PA Q) =>R is called an implication (or conditional). Its premise or antecedent is P A Q, and its conclusion or consequent is R. Implications are also known as rules or if-then statements.  (equivalent). The sentence (P A Q) & (Q A P) is an equivalence (also called a biconditional).  ¬ (not). A sentence such as ¬P is called negation of P. All the other connectives combine two sentences into one. ¬is the only connective that operates on a single sentence.
  • 171. 01/16/2025 171 CONT…  The grammar introduces atomic sentences, which in propositional logic consist of a single symbol (e.g., P), and complex sentences, which contain connectives or parentheses (e.g., P A Q).  A BNF (Backus-Naur Form) grammar of sentences in propositional logic:
  • 172. 01/16/2025 172 2.2 SEMANTICS  The semantics of prepositional logic is also quite straightforward  We define it by specifying the interpretation of the proposition symbols and constants, and specifying the meanings of the logical connectives  With logical constants, you have no choice; the sentence True always has as its interpretation the way the world actually is the true fact The sentence False always has as its interpretation the way the world is not  A complex sentence has a meaning derived from the meaning of its parts
  • 173. 01/16/2025 173 CONT…  Truth table for five logical connectives 
  • 174. 01/16/2025 174 CONT…  Truth tables define the semantics of sentences such as True A True  Complex sentences such as (PV Q) A ¬S are defined by a process of decomposition: first, determine the meaning of (P A Q) and of ¬S, and then combine them using the definition of the A function  This is exactly analogous to the way a complex arithmetic expression such as (p x q) + s is evaluated
  • 175. 01/16/2025 175 2.3 VALIDITY AND INFERENCE  Truth tables can be used not only to define the connectives, but also to test for valid sentences  If the sentence is true in every row, then the sentence is valid  For example, the sentence ((PV H) A ¬H) => P is valid  If at some point we learn (PV H) and then we also learn ¬H, then we can use the valid sentence above to conclude that P is true  It can do this by building a truth table for the sentence Premises => Conclusion and checking all the rows
  • 176. 01/16/2025 176 CONT…  Truth table showing validity of a complex sentence
  • 177. 01/16/2025 177 2.4 MODELS  Any world in which a sentence is true under a particular interpretation is called a model of that sentence under that interpretation  Models are very important in logic, because, to restate the definition of entailment, a sentence a is entailed by a knowledge base KB if the models of KB are all models of a.  If this is the case, then whenever KB is true, a must also be true
  • 178. 01/16/2025 178 CONT…  In fact, we could define the meaning of a sentence by means of set operations on sets of models.  For example, the set of models of P A Q is the intersection of the models of P and the models of Q.  The next diagrams shows the set relationships for the four binary connectives
  • 179. 01/16/2025 179 CONT… ◊ Models of complex sentences in terms of the models of their components. ◊ In each diagram, the shaded parts correspond to the models of the complex sentence
  • 180. 01/16/2025 180 2.5 RULES OF INFERENCE FOR PROPOSITIONAL LOGIC  There are certain patterns of inferences that occur over and over again, and their soundness can be shown once and for all  Then the pattern can be captured in what is called an inference rule  We have already seen the notation |- α β to say that β can be derived from α by inference  There is an alternative notation which emphasizes that this is not a sentence, but rather an inference rule
  • 183. 01/16/2025 183 READING ASSIGNMENT  AN AGENT FOR THE WUMPUS WORLD(FOL)
  • 184. 01/16/2025 184 3. PREDICATE (FIRST-ORDER) LOGIC  We used propositional logic as our representation language because it is one of the simplest languages that demonstrates all the important points  Unfortunately propositional logic has a very limited ontology, making only the commitment that the world consists of facts  This made it difficult to represent even something as simple as the wumpus world  First-order logic: makes a stronger set of ontological commitments
  • 185. 01/16/2025 185 CONT…  First-order logic (FOL) models the world in terms of: Objects, which are things with individual identities Properties of objects that distinguish them from other objects Relations that hold among sets of objects Functions, which are a subset of relations where there is only one “value” for any given “input”
  • 186. 01/16/2025 186 CONT…  Examples: Objects: Students, lectures, companies, cars ... Relations: Brother-of, bigger-than, outside, part-of, has-color, occurs-after, owns, visits, precedes, ... Properties: blue, oval, even, large, ... Functions: father-of, best-friend, second-half, one-more-than ...
  • 187. 01/16/2025 187 CONT…  Although FOL commits to the existence of objects and relations,  it does not make an ontological commitment to such things as: categories, time, events, which also seem to show up in most facts about the world
  • 188. 01/16/2025 188 3.1 SYNTAX AND SEMANTICS  In propositional logic every expression is a sentence, which represents a fact  FOL has sentences, but it also has terms, which represent objects  Constant symbols, variables, and function symbols are used to build terms, and quantifiers and predicate symbols are used to build sentences  Constant symbols, which represent individuals in the world e.g. Mary, 3, Green, A  Predicate symbols: which map individuals to truth values e.g. Round, Brother, greater, green
  • 189. 01/16/2025 189 CONT…  Function symbols: which map individuals to individuals  any given object is related to exactly one other object by the relation e.g. Cosine, FatherOf, LeftLegOf, father-of ….  FOL Provides:  Variable symbols e.g. x, y
  • 190. 01/16/2025 190 CONT… Connectives Same as in PL: not (), and (A), or (V), implies (), if and only if (bi- conditional ) Quantifiers Universal x or (Ax) Existential x or (Ex)
  • 191. 01/16/2025 191 CONT…  The syntax of FOL (with equality) in BNF (Backus-Naur Form)
  • 192. 01/16/2025 192 3.1.1 TERMS, ATOMIC, AND COMPLEX SENTENCES  A term is a logical expression that refers to an object  Terms denote a real-world individual is a constant symbol, a variable symbol, or an n-place function of n terms x and f(x1, ..., xn) are terms, where each xi is a term A term with no variables is a ground term  For example, in English we might use the expression "King John's left leg" rather than giving a name to his leg  This is what function symbols are for: instead of using a constant symbol, we use LeftLegOf (John).
  • 193. 01/16/2025 193 CONT…  Atomic sentences An atomic sentence is formed from a predicate symbol followed by a parenthesized list of terms has value true or false e.g. Brother(Richard, John) Atomic sentences can have arguments that are complex terms: e.g. Married(FatherOf (Richard),MotherOf (John))
  • 194. 01/16/2025 194 CONT…  Complex sentences A complex sentence is formed from atomic sentences connected by the logical connectives: P, P V Q, P A Q, PQ, PQ where P and Q are sentences  A quantified sentence adds quantifiers  and   A well-formed formula (wff) is a sentence containing no “free” variables. That is, all variables are “bound” by universal or existential quantifiers.
  • 195. 01/16/2025 195 3.1.2 QUANTIFIERS  FOL contains two standard quantifiers, called universal and existential Universal quantification () (x)P(x) means that P holds for all values of x in the domain associated with that variable E.g., (x) dolphin(x)  mammal(x) Existential quantification () ( x)P(x) means that P holds for some value of x in the domain associated with that variable E.g., ( x) mammal(x)  lays-eggs(x) Permits one to make a statement about some object without naming it
  • 196. 01/16/2025 196 CONT…  Universal quantifiers are often used with “implies” to form “rules”: (x) student(x)  smart(x) means “All students are smart”  Universal quantification is rarely used to make blanket statements about every individual in the world: (x)student(x)smart(x) means “Everyone in the world is a student and is smart”
  • 197. 01/16/2025 197 CONT…  Existential quantifiers are usually used with “and” to specify a list of properties about an individual: (x) student(x)  smart(x) means “There is a student who is smart”  A common mistake is to represent this FOL sentence with English: (x) student(x)  smart(x) But what happens when there is a person who is not a student?
  • 198. 01/16/2025 198 CONT…  Nested quantifiers:  We will often want to express more complex sentences using multiple quantifiers  For example, "For all x and all y, if x is the parent of y then y is the child of x" becomes x,y Parent(x,y) => Child(y,x)  x,y is equivalent to  x y.  Similarly, the fact that a person's brother has that person as a sibling is expressed by: x,y Brother(x,y) => Sibling(y,x)
  • 199. 01/16/2025 199 CONT…  Quantifier Scope: Switching the order of universal quantifiers does not change the meaning: (x)(y)P(x,y) ( ↔ y)(x) P(x,y) Similarly, you can switch the order of existential quantifiers: (x)(y)P(x,y) ( ↔ y)(x) P(x,y) Switching the order of universal and existential does change meaning: Everyone likes someone: (x)(y) likes(x,y) Someone likes everyone: (y)(x) likes(x,y)
  • 200. 01/16/2025 200 3.1.3 CONNECTIONS BETWEEN  AND   The two quantifiers are actually intimately connected with each other, through negation.  when one says that everyone dislikes parsnips,  one is also saying that there does not exist someone who likes them; and vice versa:  We can relate sentences involving  and  using De Morgan’s laws:
  • 201. 01/16/2025 201 CONT…  Equality We can use the equality symbol to make statements to the effect that two terms refer to the same object For example: Father(John) = Henry says that the object referred by Father(John) and the object referred by Henry are the same.
  • 202. 01/16/2025 202 3.2 HIGHER-ORDER LOGIC  Higher-order logic allows us to quantify over relations and functions as well as over objects  For example, in higher-order logic, we can say that two objects are equal if and only if all properties applied to them are equivalent: x,y (x = y) & (p p(x)  p(y))  Or we could say that two functions are equal if and only if they have the same value for all arguments: f,g (f = g)  ( x f(x) = g(x))  Higher-order logics have strictly more expressive power than first-order logic  But undecidable: there isn’t an effective algorithm to decide whether all sentences are valid
  • 203. 01/16/2025 203 3.3 EXPRESSING UNIQUENESS  Sometimes we want to say that there is a single, unique object that satisfies a certain condition  “There exists a unique x such that king(x) is true” x king(x)  y (king(y)  x=y) x king(x)  y (king(y)  xy) ! x king(x)
  • 204. 01/16/2025 204 CONT…  “Every country has exactly one ruler” c country(c)  ! r ruler(c,r)  Iota operator:“ x P(x)” means “the unique x such that p(x) is true” “The unique ruler of Freedonia is dead” dead( x ruler(freedonia,x))
  • 205. 01/16/2025 205 3.4 LOGICAL AGENTS FOR THE WUMPUS WORLD  Three (non-exclusive) agent architectures: Reflex agents Have rules that classify situations, specifying how to react to each possible situation Model-based agents Construct an internal model of their world Goal-based agents Form goals and try to achieve them
  • 206. 01/16/2025 206 3.4.1 A SIMPLE REFLEX AGENT  Rules to map percepts into observations: b,g,u,c,t Percept([Stench, b, g, u, c], t)  Stench(t) s,g,u,c,t Percept([s, Breeze, g, u, c], t)  Breeze(t) s,b,u,c,t Percept([s, b, Glitter, u, c], t)  AtGold(t)  Rules to select an action given observations: t AtGold(t)  Action(Grab, t);
  • 207. 01/16/2025 207 CONT…  Some difficulties: Consider Climb:  There is no percept that indicates the agent should climb out position and holding gold are not part of the percept sequence Loops:  The percept will be repeated when you return to a square, which should cause the same response (unless we maintain some internal model of the world)
  • 208. 01/16/2025 208 CONT…  Representing change  Representing change in the world in logic can be tricky. One way is just to change the KB Add and delete sentences from the KB to reflect changes How do we remember the past, or reason about changes? Situation calculus is another way A situation is a snapshot of the world at some instant in time When the agent performs an action A in situation S1, the result is a new situation S2.
  • 209. 01/16/2025 209 3.4.2 MODEL BASED AGENT  Modeling the “right” conditions and the “right” effects at the “right” level of abstraction is very difficult  Knowledge engineering (creating and maintaining knowledge bases for intelligent reasoning) is an entire field of investigation  A problem with the Wumpus world knowledge base that we have built so far is that it is difficult to decide which action is best among a number of possibilities  We can solve this problem by separating facts about actions from facts about goals.  This way our agent can be reprogrammed just by asking it to achieve different goals.
  • 210. 01/16/2025 210 3.4.2 GOAL BASED AGENT  Once the gold is found, it is necessary to change strategies.  So now we need a new set of action values.  We could encode this as a rule:  (s) Holding(Gold,s)  GoalLocation([1,1]),s)  We must now decide how the agent will work out a sequence of actions to accomplish the goal.  Three possible approaches are:  Inference: good versus wasteful solutions  Search: make a problem with operators and set of states  Planning: how, when, and what.
  • 211. 01/16/2025 211 4. INFERENCE IN FIRST-ORDER LOGIC  propositional logic uses the inference rules like: Modus Ponens, And-Elimination, And-Introduction, Or-Introduction, and Resolution.  These rules hold for first-order logic as well.  But we will need additional inference rules to handle first-order logic sentences with quantifiers.  The three additional rules we introduce here are more complex than previous
  • 212. 01/16/2025 212 CONT…  We will use the notation SUBST( , a) θ to denote the result of applying the substitution (or binding list) to the sentence a.  For example: SUBST({x/Sam, y/Pam], Likes(x,y)) = Likes(Sam,Pam)
  • 213. 01/16/2025 213 CONT…  The three new inference rules are as follows:  Universal Elimination: For any sentence , variable v, and ground term g: For example, from Likes(x,IceCream), we can use the substitution {x/Ben} and infer Likes(Ben, IceCream). Existential Elimination: For any sentence , variable v, and constant symbol k that does not appear elsewhere in the knowledge base:
  • 214. 01/16/2025 214 CONT… For example, from x Kill(x,Victim), we can infer Kill(Murderer,Victim), as long as Murderer does not appear elsewhere in the knowledge base Existential Introduction: For any sentence , variable v that does not occur in , and ground term g that does occur in For example, from Likes(Jerry, IceCream) we can infer x Likes(x, IceCream)
  • 215. 01/16/2025 215 4.1 AN EXAMPLE PROOF  Application of inference rules is simply a question of matching their premise patterns to the sentences in the KB and then adding their (suitably instantiated) conclusion patterns  We will begin with the situation as it might be described in English: The law says that it is a crime for an American to sell weapons to hostile nations. The country Nono, an enemy of America, has some missiles, and all of its missiles were sold to it by Colonel West, who is an American.  What we wish to prove is that West is a criminal.
  • 216. 01/16/2025 216 CONT…  We first represent these facts in first-order logic, and then show the proof as a sequence of applications of the inference rules. 1 2 3
  • 218. 01/16/2025 218 CONT… 8,9  The proof consists of a series of applications of the inference rules: 10 11,12
  • 221. 01/16/2025 221 CONT… 21  Initial state = KB (sentences 1-9)  Operators = applicable inference rules  Goal test = KB containing Criminal(West)
  • 222. 01/16/2025 222 4.2 GENERALIZED MODES PONENS (GMP)  Apply modus ponens reasoning to generalized rules  Combines And-Introduction, Universal-Elimination, and Modus Ponens From P(c) and Q(c) and (x)(P(x)  Q(x))  R(x) derive R(c)  General case: Given atomic sentences P1, P2, ..., PN implication sentence (Q1  Q2  ...  QN)  R Q1, ..., QN and R are atomic sentences substitution subst(θ, Pi) = subst(θ, Qi) for i=1,...,N Derive new sentence: subst(θ, R)
  • 223. 01/16/2025 223 CONT…  Substitutions subst(θ, α) denotes the result of applying a set of substitutions defined by θ to the sentence α A substitution list θ = {v1/t1, v2/t2, ..., vn/tn} means to replace all occurrences of variable symbol vi by term ti Substitutions are made in left-to-right order in the list subst({x/IceCream, y/Ziggy}, eats(y,x)) = eats(Ziggy, IceCream)
  • 224. 01/16/2025 224 HORN CLAUSES  A Horn clause is a sentence of the form: (x) P1(x)  P2(x)  ...  Pn(x)  Q(x) where  there are 0 or more Pis and 0 or 1 Q  the Pis and Q are positive (i.e., non-negated) literals  Equivalently: P1(x)  P2(x) …  Pn(x) where the Pi are all atomic and at most one of them is positive  Horn clauses represent a subset of the set of sentences representable in FOL
  • 225. 01/16/2025 225 CONT…  Special cases P1  P2  … Pn  Q P1  P2  … Pn  false true  Q  These are not Horn clauses: p(a)  q(a) (P  Q)  (R  S)
  • 226. 01/16/2025 226 4.2.1 FORWARD CHAINING  Proofs start with the given axioms/premises in KB, deriving new sentences using GMP until the goal/query sentence is derived  This defines a forward-chaining inference procedure because it moves “forward” from the KB to the goal [eventually]  Inference using GMP is complete for KBs containing only Horn clauses
  • 228. 01/16/2025 228 4.2.2 BACKWARD CHAINING  Backward-chaining deduction using GMP is also complete for KBs containing only Horn clauses  Proofs start with the goal query, find rules with that conclusion, and then prove each of the antecedents in the implication  Keep going until you reach premises  Avoid loops: check if new subgoal is already on the goal stack  Avoid repeated work: check if new subgoal Has already been proved true Has already failed
  • 230. 01/16/2025 230 FORWARD VS. BACKWARD CHAINING  FC is data-driven  Automatic, unconscious processing  E.g., object recognition, routine decisions  May do lots of work that is irrelevant to the goal  BC is goal-driven, appropriate for problem-solving  Where are my keys? How do I get to my next class?  Complexity of BC can be much less than linear in the size of the KB
  • 231. 01/16/2025 231 4.2.3 COMPLETENESS OF GMP  GMP (using forward or backward chaining) is complete for KBs that contain only Horn clauses  It is not complete for simple KBs that contain non-Horn clauses  The following entail that S(A) is true: (x) P(x)  Q(x) (x) P(x)  R(x) (x) Q(x)  S(x) (x) R(x)  S(x)  If we want to conclude S(A), with GMP we cannot, since the second one is not a Horn clause  It is equivalent to P(x)  R(x)
  • 232. 01/16/2025 232 4.3 RESOLUTION  Resolution is a sound and complete inference procedure for FOL  Reminder: Resolution rule for propositional logic:  P1  P2  ...  Pn  P1  Q2  ...  Qm  Resolvent: P2  ...  Pn  Q2  ...  Qm  Examples  P and  P  Q : derive Q (Modus Ponens)  ( P  Q) and ( Q  R) : derive  P  R  P and  P : derive False [contradiction!]  (P  Q) and ( P   Q) : derive True
  • 233. 01/16/2025 233 4.3.1 RESOLUTION IN FOL  Given sentences P1  ...  Pn Q1  ...  Qm  in conjunctive normal form:  each Pi and Qi is a literal, i.e., a positive or negated predicate symbol with its terms,  if Pj and Qk unify with substitution list θ, then derive the resolvent sentence: subst(θ, P1 ...  Pj-1  Pj+1 ... Pn  Q1  …Qk-1  Qk+1 ...  Qm)
  • 234. 01/16/2025 234 4.3.2 RESOLUTION REFUTATION  Given a consistent set of axioms KB and goal sentence Q, show that KB |= Q  Proof by contradiction: Add Q to KB and try to prove false. i.e., (KB |- Q) (KB ↔  Q |- False)  Resolution is refutation complete: it can establish that a given sentence Q is entailed by KB, but can’t (in general) be used to generate all logical consequences of a set of sentences  Also, it cannot be used to prove that Q is not entailed by KB.
  • 235. 01/16/2025 235 CONT…  Resolution won’t always give an answer since entailment is only semi-decidable And you can’t just run two proofs in parallel, one trying to prove Q and the other trying to prove Q, since KB might not entail either one
  • 236. 01/16/2025 236 236 REFUTATION RESOLUTION PROOF TREE Implicative Normal Form (KB) P(w) =>Q(w) True => P(x)V R(x) Q(y) => S(y) R(z) => S(z) A proof that S(A) follows from the KB in , using resolution. Each "vertex" in the proof tree represents a resolution step: the two sentences at the top are the premises, and the one at the bottom is the conclusion or resolvent. The substitution is shown for each resolution.
  • 237. 01/16/2025 237 CONT…  Technically, the final resolvent should be True => S(A) V S(A), but we have taken the liberty of removing the redundant disjunct.  In some systems, there is a separate inference rule called factoring to do this, but it is simpler to just make it be part of the resolution rule  Chaining with resolution is more powerful than chaining with Modus Ponens, but it is still not complete  One complete inference procedure using resolution is refutation, also known as proof by contradiction and reductio ad absurdum
  • 238. 01/16/2025 238 CONT…  The idea is that to prove P, we assume P is false (i.e., add ->P to the knowledge base) and prove a contradiction.  If we can do this, then it must be that the knowledge base implies P.  In other words: (KB A P => False)  (KB => P)  Proof by contradiction is a powerful tool throughout mathematics, and resolution gives us a simple, sound, complete way to apply it
  • 239. 01/16/2025 239 CONT… A proof that S(A) follows from the previous KB using resolution with refutation.
  • 240. 01/16/2025 240 Reading assignment  normalization and skolemization (conversion of FOL to CNF)  Unification
  • 241. 01/16/2025 241 THE END OF CHAPTER FOUR
  • 243. 01/16/2025 243 LIST OF CONTENTS 1. Learning from Examples/Observation 2. Knowledge in Learning 3. Learning Probabilistic Models 4. Neural Networks
  • 244. 01/16/2025 244 1. LEARNING FROM EXAMPLES/OBSERVATION  Learning is any process by which a system improves performance from experience  Learning takes place as a result of the interaction between the agent and the world, And from observation by the agent of its own decision-making processes.  What is the task? Classification Problem solving /planning /control
  • 245. 01/16/2025 245 CONT…  The general model of learning agent  The critic is designed to tell the learning element how well the agent is doing.  Problem generator is responsible for suggesting actions that will lead to new and informative experiences
  • 246. 01/16/2025 246 CONT…  The design of the learning element is affected by four major issues: Which components of the performance element are to be improved. What representation is used for those components. What feedback is available. What prior information is available.
  • 247. 01/16/2025 247 CONT…  For some components, such as the component for predicting the outcome of an action, the available feedback generally tells the agent what the correct outcome is  Any situation in which both the inputs and outputs of a component can be perceived is called supervised learning. Often, the outputs are provided by a friendly teacher Learning when there is no hint at all about the correct outputs is called unsupervised learning.
  • 248. 01/16/2025 248 1.1 BIAS AND HYPOTHESIS  Bias of an algorithm is a set of assumptions that the learner uses to predict outputs.  In machine learning, one aim to construct algorithms that are able to learn to predict a certain target output inductive bias = Y=a+bx (linear model)  Hypothesis is a function that best describes the target in supervised machine learning  The hypothesis that an algorithm would come up depends upon the data and also depends on the restriction and bias that we have imposed on the data
  • 249. 01/16/2025 249 CONT… In (a) we have some example (input, output) pairs. In (b), (c), and (d) we have three hypotheses for functions from which these examples could be drawn.
  • 250. 01/16/2025 250 1.2 LEARNING DECISION TREES  Decision tree induction is one of the simplest and yet most successful forms of learning algorithm.  A decision tree takes as input an object or situation described by a set of properties, and outputs a yes/no "decision.“  Decision trees therefore represent Boolean functions.  Functions with a larger range of outputs can also be represented, but for simplicity we will usually stick to the Boolean case
  • 251. 01/16/2025 251 CONT…  Each internal node in the tree corresponds to a test of the value of one of the properties, and the branches from the node are labelled with the possible values of the test.  Each leaf node in the tree specifies the Boolean value to be returned if that leaf is reached.  Decision trees are implicitly limited to talking about a single object.  We cannot use decision trees to represent tests that refer to two or more different objects
  • 252. 01/16/2025 252 CONT… A decision tree for deciding whether to wait for a table
  • 253. 01/16/2025 253 CONT…  An example is described by the values of the attributes and the value of the goal predicate.  We call the value of the goal predicate the classification of the example  If the goal predicate is true for some example, we call it a positive example; otherwise we call it a negative example.  The complete set of examples is called the training set.  A set of examples X1,... ,X12 for the restaurant domain is shown in next Figure
  • 254. 01/16/2025 254 CONT… Examples for the restaurant domain.
  • 255. 01/16/2025 255 1.3 ASSESSING THE PERFORMANCE OF THE LEARNING ALGORITHM  A learning algorithm is good if it produces hypotheses that do a good job of predicting the classifications of unseen examples.  Obviously, a prediction is good if it turns out to be true, so we can assess the quality of a hypothesis by checking its predictions against the correct classification once we know it.  We do this on a set of examples known as the test set  Often it is more convenient to adopt the following methodology while training a machine :
  • 256. 01/16/2025 256 CONT… 1. Collect a large set of examples. 2. Divide it into two disjoint sets: the training set and the test set. 3. Use the learning algorithm with the training set as examples to generate a hypothesis H. 4. Measure the percentage of examples in the test set that are correctly classified by H. 5. Repeat steps 1 to 4 for different sizes of training sets and different randomly selected training sets of each size.
  • 257. 01/16/2025 257 1.3.1 OVERFITTING  Whenever there is a large set of possible hypotheses, one has to be careful not to use the resulting freedom to find meaningless "regularity" in the data.  This problem is called overfitting.  simple technique to treat overfitting is called decision tree pruning.  Pruning works by preventing recursive splitting on attributes that are not clearly relevant, even when the data at that node in the tree is not uniformly classified.  Cross-validation is another technique that eliminates the dangers of overfitting.
  • 258. 01/16/2025 258 CONT…  The basic idea of cross-validation is to try to estimate how well the current hypothesis will predict unseen data.  This is done by setting aside some fraction of the known data, and using it to test the prediction performance of a hypothesis induced from the rest of the known data.
  • 259. 01/16/2025 259 2. KNOWLEDGE IN LEARNING cumulative learning process uses, and adds to, its stock of background knowledge over time.
  • 260. 01/16/2025 260 CONT…  If we want to build an autonomous learning agent that uses background knowledge, the agent must have some method for obtaining the background knowledge in the first place, in order for it to be used in the new learning episodes.  This method must itself be a learning process.  The agent's life history will therefore be characterized by cumulative, or incremental, development.  Presumably, the agent could start out with nothing, performing inductions in vacuum like a good little pure induction program
  • 261. 01/16/2025 261 2.1 EXPLANATION-BASED LEARN (EBL)  Use of background knowledge allows much faster learning than one might expect from a pure induction program  Explanation-based learning is a method for extracting general rules from individual observations  The technique of memorization has long been used in computer science to speed up programs by saving the results of computation.  The basic idea of memo functions is to accumulate a database of input/output pairs; when the function is called, it first checks the database to see if it can avoid solving the problem from scratch.
  • 262. 01/16/2025 262 CONT…  Explanation-based learning (EBL) takes this a good deal further, by creating general rules that cover an entire class of cases.  In the case of differentiation, memorization would remember that the derivative of X2 with respect to X is 2X, but would leave the agent to calculate the derivative of Z2 with respect to Z from scratch  We would like to be able to extract the general rule1 that for any arithmetic unknown u, the derivative of u2 with respect to u is 2u
  • 263. 01/16/2025 263 2.2 INDUCTIVE LOGIC PROGRAMMING (ILP)  Inductive logic programming (ILP) is one of the newest subfields in AI.  It combines inductive methods with the power of first-order representations, concentrating in particular on the representation of theories as logic programs  ILP is a highly technical field, relying on some fairly advanced material from the study of computational logic.  One of the principal advantages of ILP algorithms is their applicability to a much wider range of problems
  • 265. 01/16/2025 Artificial_intelligenceI_GIS 265 # WHAT IS BIOLOGICAL NEURAL NETWORK  In the Biological Neural network (BNN), neurons are working inside a human brain which are connected by synapses activated for the specific function they ought to carry out  There are two basic kinds of connections between neurons present in the biological brain called synapses, both electrical and chemical  Synapses help the connection of neurons in overlapping and interlinking the neural circuits  Consider the Biological Neural Network to be a connective bridge in the difference between a neural network and the human brain.
  • 266. 01/16/2025 Artificial_intelligenceI_GIS 266 # WHAT IS ARTIFICIAL NEURONS?  Analogy to biological neural systems, the most robust learning systems we know.  Attempt to understand natural biological systems through computational modeling.  Massive parallelism allows for computational efficiency.  Artificial Neural Networks (ANN) is the main tool used in Machine learning.  It has been gaining popularity at a very fast pace with Deep Learning, Data Science and Machine Learning being around in the past few years.
  • 267. 01/16/2025 Artificial_intelligenceI_GIS 267 3.1 BIOLOGICAL VS ARTIFICIAL NEURONS  The biological brain and Artificial Neural Networks (ANN) are two of the most controversial aspects of analysis in the field of Neural Network research.  But there have been some postulations regarding the working difference between ANN and the human brain.  SIZE: In the human brain, there are 86 billion neurons, and more than 100 trillion synapses to pass on electrical signals throughout a biological body.  But on the other hand, the number of neuron in the artificial neural network is way more lesser in numbers.
  • 268. 01/16/2025 Artificial_intelligenceI_GIS 268 CONT…  One layer perceptron network consists of several perceptrons that are not connected to one another.  TOPOLOGY:The artificial layers add up one by one, instead of being a part of a network that has nodes that don’t add up synchronously.  On the other hand, in biological networks, neurons paralelly fire asynchronously with a small portion of highly connected neurons and a large amount of lesser connected ones.
  • 269. 01/16/2025 Artificial_intelligenceI_GIS 269 CONT…  POWER CONSUMPTION: The biological brain consumes about 20% of the overall human body’s energy.  An adult brain operates on about 20 watts, and in comparison to this, artificial builds can’t even match the efficiency level of a biological brain.  SPEED: In the biological neuron, electric signals travel at varied speeds depending on the type of the nerve impulse.  The speed usually ranges from 0.61 m/s to 119 m/s.  On the other hand, an artificial neuron emits signal by the continuous, floating point number values of synaptic weights.
  • 270. 01/16/2025 Artificial_intelligenceI_GIS 270 3.2 PERCEPTRON  Assume supervised training examples giving the desired output for a unit given a set of known input activations.  Learn synaptic weights so that unit produces the correct output for each example.  Perceptron uses iterative update algorithm to learn a correct set of weights.  Update weights by: Wij = Wji + η(tj - oj)oi where η is learning rate, tj is teacher specified output for unit j
  • 271. 01/16/2025 Artificial_intelligenceI_GIS 271 CONT…  Equivalent to rules: If output is correct do nothing. If output is high, lower weights on active inputs If output is low, increase weights on active inputs  Also adjust threshold to compensate: T = Tj – η(tj - oj)
  • 272. 01/16/2025 Artificial_intelligenceI_GIS 272 CONT…  Perceptron learning algorithm Iteratively update weights until convergence.  Initialize weights to random values Until outputs of all training examples are correct For each training pair, E, do: Compute current output oj for E given its inputs Compare current output to target value, tj , for E Update synaptic weights and threshold using learning rule Each execution of the outer loop is typically called an epoch.
  • 273. 01/16/2025 Artificial_intelligenceI_GIS 273 CONT…  Perceptron as a linear separator Since perceptron uses linear threshold function, it is searching for a linear separator that discriminates the classes
  • 274. 01/16/2025 Artificial_intelligenceI_GIS 274 CONT…  Perceptron limit System obviously cannot learn concepts it cannot represent. Minksy and Papert (1969) wrote a book analyzing the perceptron and demonstrating many functions it could not learn. These results discouraged further research on neural nets; and symbolic AI became the dominate paradigm.
  • 275. 01/16/2025 Artificial_intelligenceI_GIS 275 CONT…  Perceptron Convergence and Cycling Theorems Perceptron convergence theorem: If the data is linearly separable and therefore a set of weights exist that are consistent with the data, then the Perceptron algorithm will eventually converge to a consistent set of weights. Perceptron cycling theorem: If the data is not linearly separable, the Perceptron algorithm will eventually repeat a set of weights and threshold at the end of some epoch and therefore enter an infinite loop. o By checking for repeated weights + threshold, one can guarantee termination with either a positive or negative result.
  • 276. 01/16/2025 Artificial_intelligenceI_GIS 276 CONT…  Perceptron as Hill Climbing The hypothesis space being search is a set of weights and a threshold. Objective is to minimize classification error on the training set. Perceptron effectively does hill-climbing (gradient descent) in this space, changing the weights a small amount at each point to decrease training set error. For a single model neuron, the space is well behaved with a single minima.
  • 277. 01/16/2025 277 CONT…  Perceptron performance Linear threshold functions are restrictive (high bias) but still reasonably expressive; more general than: Pure conjunctive Pure disjunctive M-of-N (at least M of a specified set of N features must be present) In practice, it converges fairly quickly for linearly separable data. Can effectively use even incompletely converged results when only a few outliers are misclassified. Experimentally, Perceptron does quite well on many benchmark data sets. Artificial_intelligenceI_GIS
  • 278. 01/16/2025 278 3.3 MULTI-LAYER NETWORKS  Multi-layer networks can represent arbitrary functions, but an effective learning algorithm for such networks was thought to be difficult.  A typical multi-layer network consists of an input, hidden and output layer, each fully connected to the next, with activation feeding forward. Output layer Input layer hidden layer • The weights determine the function computed. • Given an arbitrary number of hidden units, any Boolean function can be computed with a single hidden layer.
  • 279. 01/16/2025 279 CONT…  How many hidden units are needed?  The problem of choosing the right number of hidden units in advance is still not well-understood.  The most popular method for learning in multilayer networks is called back- propagation
  • 280. 01/16/2025 280 3.3.1 BACK-PROPAGATION  The back-propagation algorithm is a sensible approach to dividing the contribution of each weight.  As in the perceptron learning algorithm, we try to minimize the error between each target output and the output actually computed by the network.  At the output layer, the weight update rule is very similar to the rule for the perceptron.  There are two differences: 1. the activation of the hidden unit ai is used instead of the input value; and 2. the rule contains a term for the gradient of the activation function.
  • 281. 01/16/2025 281 CONT…  Backpropagation Learning Rule ∆wji = ηδjoi δ = oj (1-oj) (tj - oj) if j is an output unit δ = oj (1-oj)∑ δ kwkj if j is hidden unit where is a constant called the learning rate η t j is the correct teacher output for unit j δj is the error measure for unit j
  • 282. 01/16/2025 282 CONT…  Error Backpropagation  First calculate error of output units and use this to change the top layer of weights Current output: oj = 0.2 Correct output: t j = 1.0 Error δj = oj (1–oj )(t j – oj ) 0.2(1– 0.2)(1– 0.2)=0.128 # Update weights into j ∆wji = ηδ j oi Input hidden output
  • 283. 01/16/2025 283 CONT…  Next calculate error for hidden units based on errors on the output units it feeds into. Input hidden output δ = oj (1 - oj) ∑ δ k wjk Input hidden
  • 284. 01/16/2025 284 CONT…  Finally update bottom layer of weights based on errors calculated for hidden units. Input hidden output
  • 285. 01/16/2025 285 CONT…  Backpropagation Training Algorithm Create the 3-layer network with H hidden units with full connectivity between layers. Set weights to small random real values. Until all training examples produce the correct value (within ), ε or mean squared error ceases to decrease, or other termination criteria: Begin epoch For each training example, d, do: Calculate network output for d’s input values Compute error between current output and correct output for d Update weights by back-propagating error and using learning rule End epoch
  • 286. 01/16/2025 286 CONT…  Comments on Training Algorithm Not guaranteed to converge to zero training error, may converge to local optima or oscillate indefinitely. However, in practice, does converge to low error for many large networks on real data. Many epochs (thousands) may be required, hours or days of training for large networks. To avoid local-minima problems, run several trials starting with different random weights (random restarts). Take results of trial with lowest training set error. Build a committee of results from multiple trials
  • 287. 01/16/2025 287 CONT…  Successful Applications Text to Speech (NetTalk) Fraud detection Financial Applications HNC (eventually bought by Fair Isaac) Chemical Plant Control Pavilion Technologies Automated Vehicles Game Playing Neuro-gammon Handwriting recognition
  • 289. 01/16/2025 289 LIST OF CONTENTS 1. Natural Language Processing and communication 2. Perception 3. Robotics
  • 290. 01/16/2025 290 1. NATURAL LANGUAGE PROCESSING  NLP is the branch of computer science focused on developing systems that allow computers to communicate with people using everyday language.  Also called Computational Linguistics Also concerns how computational methods can aid the understanding of human language  The goal in the production and comprehension of natural language is communication.
  • 291. 01/16/2025 291 1.2 COMMUNICATION  Communication for the speaker: Intention: Decide when and what information should be transmitted (a.k.a. strategic generation). May require planning and reasoning about agents’ goals and beliefs. Generation:Translate the information to be communicated (in internal logical representation or “language of thought”) into string of words in desired natural language (a.k.a. tactical generation). Synthesis: Output the string in desired modality, text or speech.
  • 292. 01/16/2025 292 CONT…  Communication for the listner: Perception: Map input modality to a string of words, e.g. optical character recognition (OCR) or speech recognition. Analysis: Determine the information content of the string. Syntactic interpretation (parsing): Find the correct parse tree showing the phrase structure of the string. Semantic Interpretation: Extract the (literal) meaning of the string (logical form). Pragmatic Interpretation: Consider effect of the overall context on altering the literal meaning of a sentence. Incorporation: Decide whether or not to believe the content of the string and add it to the KB.
  • 294. 01/16/2025 294 CONT…  Syntax concerns the proper ordering of words and its affect on meaning.  The dog bit the boy.  The boy bit the dog.  * Bit boy dog the the.  Colorless green ideas sleep furiously.  Semantics concerns the (literal) meaning of words, phrases, and sentences.  “plant” as a photosynthetic organism  “plant” as a manufacturing facility  “plant” as the act of sowing  Pragmatics concerns the overall communicative and social context and its effect on interpretation.  The ham sandwich wants another beer. (co-reference, anaphora)  John thinks vanilla. (ellipsis)
  • 295. 01/16/2025 295 1.2.1 AMBIGUITY  Natural language is highly ambiguous and must be disambiguated. I saw the man on the hill with a telescope. I saw the Grand Canyon flying to LA. Time flies like an arrow. Horse flies like a sugar cube. Time runners like a coach. Time cars like a Porsche.
  • 296. 01/16/2025 296 CONT…  Speech Recognition “recognize speech” vs.“wreck a nice beach” “youth in Asia” vs.“euthanasia”  Syntactic Analysis “I ate spaghetti with chopsticks” vs.“I ate spaghetti with meatballs.”  Semantic Analysis “The dog is in the pen.” vs.“The ink is in the pen.” “I put the plant in the window” vs.“Ford put the plant in Mexico”  Pragmatic Analysis From “The Pink Panther Strikes Again”: Clouseau: Does your dog bite? Hotel Clerk: No. Clouseau: [bowing down to pet the dog] Nice dog. [Dog barks and bites Clouseau in the hand] Clouseau: I thought you said your dog did not bite! Hotel Clerk:That is not my dog.
  • 297. 01/16/2025 297 1.2.2 NATURAL LANGUAGES VS. COMPUTER LANGUAGES  Ambiguity is the primary difference between natural and computer languages.  Formal programming languages are designed to be unambiguous, i.e. they can be defined by a grammar that produces a unique parse for each sentence in the language.  Programming languages are also designed for efficient (deterministic) parsing, i.e. they are deterministic context-free languages (DCFLs). A sentence in a DCFL can be parsed in O(n) time where n is the length of the string.
  • 299. 01/16/2025 299 1.2.3 CONTEXT FREE GRAMMARS (CFG)  N a set of non-terminal symbols (or variables)   a set of terminal symbols (disjoint from N)  R a set of productions or rules of the form A→, where A is a non-terminal and  is a string of symbols from ( N)*  S, a designated non-terminal called the start symbol
  • 300. 01/16/2025 300 CONT…  Simple CFG for English Grammar S NP VP → S Aux NP VP → S VP → NP Pronoun → NP Proper-Noun → NP Det Nominal → Nominal Noun → Nominal Nominal Noun → Nominal Nominal PP → VP Verb → VP Verb NP → VP VP PP → PP Prep NP → Lexicon Det the | a | that | this → Noun book | flight | meal | money → Verb book | include | prefer → Pronoun I | he | she | me → Proper-Noun Houston | NWA → Aux does → Prep from | to | on | near | through →
  • 301. 01/16/2025 301 CONT…  Sentence Generation Sentences are generated by recursively rewriting the start symbol using the productions until only terminals symbols remain. S VP Verb NP Det Nominal Nominal PP book Prep NP through Houston Proper-Noun the flight Noun Derivation or Parse Tree
  • 302. 01/16/2025 302 1.2.4 WORD SENSE DISAMBIGUATION  Words in natural language usually have a fair number of different possible meanings. Ellen has a strong interest in computational linguistics. Ellen pays a large amount of interest on her credit card.  For many tasks (question answering, translation), the proper sense of each ambiguous word in a sentence must be determined.
  • 303. 01/16/2025 303 CONT…  Syntactic and semantic ambiguities must be properly resolved for correct translation: “John plays the guitar.” “John toca la guitarra.” → “John plays soccer.” “John juega el fútbol.” →  An apocryphal story is that an early MT system gave the following results when translating from English to Russian and then back to English: “The spirit is willing but the flesh is weak.”  “The liquor is good but the meat is spoiled.” “Out of sight, out of mind.”  “Invisible idiot.”
  • 304. 01/16/2025 304 CONT…  WSD as a text categorization Each sense of an ambiguous word is treated as a category. “play” (verb) play-game play-instrument play-role “pen” (noun) writing-instrument enclosure
  • 305. 01/16/2025 305 CONT… Treat current sentence (or preceding and current sentence) as a document to be classified. “play”: play-game:“John played soccer in the stadium on Friday.” play-instrument:“John played guitar in the band on Friday.” play-role:“John played Hamlet in the theater on Friday.” “pen”: writing-instrument:“John wrote the letter with a pen in NewYork.” enclosure:“John put the dog in the pen in NewYork.”
  • 306. 01/16/2025 306 CONT…  Learning in WSD Assume part-of-speech (POS), e.g. noun, verb, adjective, for the target word is determined. Treat as a classification problem with the appropriate potential senses for the target word given its POS as the categories. Encode context using a set of features to be used for disambiguation. Train a classifier on labeled data encoded using these features. Use the trained classifier to disambiguate future instances of the target word given their contextual features.
  • 307. 01/16/2025 307 CONT… WSD “line” Corpus 4,149 examples from newspaper articles containing the word “line.” Each instance of “line” labeled with one of 6 senses from WordNet. Each example includes a sentence containing “line” and the previous sentence for context.  Senses of “line” are
  • 309. 01/16/2025 309 CONT…  Experimental Data forWSD of “line” Sample equal number of examples of each sense to construct a corpus of 2,094. Represent as simple binary vectors of word occurrences in 2 sentence context. Stop words eliminated Stemmed to eliminate morphological variation Final examples represented with 2,859 binary word features.
  • 310. 01/16/2025 310 CONT…  Learning algorithms for DNS  Naïve Bayes  Binary features  K Nearest Neighbor  Simple instance-based algorithm with k=3 and Hamming distance  Perceptron  Simple neural-network algorithm.  C4.5  State of the art decision-tree induction algorithm  PFOIL-DNF  Simple logical rule learner for Disjunctive Normal Form  PFOIL-CNF  Simple logical rule learner for Conjunctive Normal Form  PFOIL-DLIST  Simple logical rule learner for decision-list of conjunctive rules
  • 311. 01/16/2025 311 1.2.5 OTHER SYNTACTIC TASKS  Word Segmentation Breaking a string of characters (graphemes) into a sequence of words. In some written languages (e.g. Chinese) words are not separated by spaces. Even in English, characters other than white-space can be used to separate words [e.g. , ; . - : ( ) ] Examples from English URLs: jumptheshark.com  jump the shark .com myspace.com/pluckerswingbar  myspace .com pluckers wing bar  myspace .com plucker swing bar
  • 312. 01/16/2025 312 CONT…  Morphological Analysis Morphology is the field of linguistics that studies the internal structure of words. (Wikipedia) A morpheme is the smallest linguistic unit that has semantic meaning (Wikipedia)  e.g.“carry”,“pre”,“ed”,“ly”,“s” Morphological analysis is the task of segmenting a word into its morphemes: carried  carry + ed (past tense) independently  in + (depend + ent) + ly Googlers  (Google + er) + s (plural)
  • 313. 01/16/2025 313 CONT…  Part Of Speech (POS) Tagging Annotate each word in a sentence with a part-of-speech. Useful for subsequent syntactic parsing and word sense disambiguation
  • 314. 01/16/2025 314 1.2.6 OTHER SEMANTIC TASKS  Semantic Role Labeling (SRL) For each clause, determine the semantic role played by each noun phrase that is an argument to the verb. Also referred to a “case role analysis,”“thematic analysis,” and “shallow semantic parsing”
  • 315. 01/16/2025 315 CONT…  Semantic Parsing A semantic parser maps a natural-language sentence to a complete, detailed semantic representation (logical form). For many applications, the desired output is immediately executable by another program. Example: Mapping an English database query to Prolog: How many cities are there in the US? answer(A, count(B, (city(B), loc(B, C), const(C, countryid(USA))), A))
  • 316. 01/16/2025 316 CONT…  Textual Entailment Determine whether one natural language sentence entails (implies) another under an ordinary interpretation.
  • 317. 01/16/2025 317 1.2.7 OTHER GENERAL TASKS  Information Extraction (IE) Identify phrases in language that refer to specific types of entities and relations in text. Named entity recognition (NER) is task of identifying names of people, places, organizations, etc. in text. Relation extraction identifies specific relations between entities.
  • 318. 01/16/2025 318 CONT…  Question Answering Directly answer natural language questions based on information presented in a corpora of textual documents (e.g. the web). When was Barack Obama born? (factoid) August 4, 1961 Who was president when Barack Obama was born? John F. Kennedy How many presidents have there been since Barack Obama was born? 9
  • 319. 01/16/2025 319 CONT…  Text summarization  Produce a short summary of a longer document or article. Article: With a split decision in the final two primaries and a flurry of super delegate endorsements, Sen. Barack Obama sealed the Democratic presidential nomination last night after a grueling and history-making campaign against Sen. Hillary Rodham Clinton that will make him the first African American to head a major-party ticket. Before a chanting and cheering audience in St. Paul, Minn., the first-term senator from Illinois savored what once seemed an unlikely outcome to the Democratic race with a nod to the marathon that was ending and to what will be another hard-fought battle, against Sen. John McCain, the presumptive Republican nominee…. Summary: Senator Barack Obama was declared the presumptive Democratic presidential nominee.
  • 320. 01/16/2025 320 CONT…  Machine Translation (MT) Translate a sentence from one natural language to another. Hasta la vista, bebé  Until we see each other again, baby.
  • 321. 01/16/2025 321 2. PERCEPTION  Perception provides agents with information about the world they inhabit.  Perception is initiated by sensors  A sensor is anything that can change the computational state of the agent in response to a change in the state of the world  There are basically two approaches for perception 1. Feature Extraction Detect some small number of features in sensory input and pass them to their agent program Agent program will combine features with other information “bottom up”
  • 322. 01/16/2025 322 CONT… 2. Model Based Sensory stimulus is used to reconstruct a model of the world Start with a function that maps from a state of the world to a stimulus “top down”  In reality, both feature extraction and model-based approaches are needed Not well understood how to combine these approaches Knowledge representation of the model is the problem
  • 323. 01/16/2025 323 2.1 IMAGE FORMATION  An image is a rectangular grid of data of light values Commonly known as pixels  Pixel values can be… Binary Gray scale Color Multimodal
  • 326. 01/16/2025 326 CONT…  I(x,y,t) is the intensity at (x,y) at time t  CCD camera has approximately 1,000,000 pixels  Human eyes have approximately 240,000,000 “pixels” i.e. 0.25 terabits / second
  • 327. 01/16/2025 327 2.2 IMAGE PROCESSING  Image processing operations often apply a function to an image and the result is another image “Enhance the image” in some fashion Smoothing Histogram equalization Edge detection  Image processing operations can be done in either the spatial domain or the frequency domain
  • 328. 01/16/2025 328 CONT… • The first image is Arial image • The rest of the images are after performing some transformation
  • 329. 01/16/2025 329 CONT…  Image data can be represented in a spatial domain or a frequency domain  The transformation from the spatial domain to the frequency domain is accomplished by the Fourier Transform  By transforming image data to the frequency domain, it is often less computationally demanding to perform image processing operations
  • 330. 01/16/2025 330 CONT… Basic steps for filtering In frequency domain
  • 331. 01/16/2025 331 CONT…  Low Pass Filter  Allows low frequencies to pass  High Pass Filter  Allows high frequencies to pass  Band Pass Filter  Allows frequencies in a given range to pass  Notch Filter  Suppresses frequencies in a range (attenuate)
  • 332. 01/16/2025 332 CONT…  High frequencies are more noisy Similar to the “salt and pepper” fleck on a TV Use a low pass filter to remove the high frequencies from an image Convert image back to spatial domain Result is a “smoothed image”  Image enhancement can be done with high pass filters and amplifying the filter function Sharper edges
  • 333. 01/16/2025 333 CONT…  Transforming images to the frequency domain was (and is still) done to improve computational efficiency Filters were just like addition and subtraction  Now computers are so fast that filter functions can be done in the spatial domain Convolution  Convolution is the spatial equivalent to filtering in the frequency domain More computation involved
  • 334. 01/16/2025 334 CONT…  After performing image enhancement, the next step is usually to detect edges in the image  Edge Detection  Use the convolution algorithm with edge detection filters to find vertical and horizontal edges  Once edges are detected, we can use them to do stereoscopic processing, detect motion, or recognize objects  Segmentation is the process of breaking an image into groups, based on similarities of the pixels
  • 335. 01/16/2025 335 2.3 COMPUTER VISION  Contour Tracing  Connected Component Analysis When can we say that 2 pixels are neighbors? In general, a connected component is a set of black pixels, P, such that for every pair of pixels pi and pj in P, there exists a sequence of pixels pi, ..., pj such that: all pixels in the sequence are in the set P i.e. are black, and every 2 pixels that are adjacent in the sequence are "neighbors"
  • 338. 01/16/2025 338 CONT…  L-Junction A vertex defined by only two lines…the endpoints touch  Y-Junction A three line vertex where the angle between each of the lines and the others is less than 180o  W-Junction A three line vertex where one of the angles between adjacent line pairs is greater than 180o  T-Junction A three line vertex where one of the angles is exactly 180o  An occluding edge is marked with an arrow,  hides part from view  A convex edge is marked with a plus, + pointing towards viewer  A concave edge is marked with a minus, - pointing away from the viewer
  • 340. 01/16/2025 340 3. ROBOTICS  The Robot Institute of America defines a robot as a programmable, multifunction manipulator designed to move material, parts, tools, or specific devices through variable programmed motions for the performance of a variety of tasks  We will define robot simply as an active, artificial agent whose environment is the physical world.  We will be concerned primarily with autonomous robots, those that make decisions on their own, guided by the feedback they get from their physical sensors.
  • 341. 01/16/2025 341 3.1 TASKS: WHAT ARE ROBOTS GOOD FOR?  Manufacturing and materials handling: Material handling is the storage, transport, and delivery of material, which can range in size from silicon chips to diesel trucks.  Hazardous environments: mobile robots are an important technology for reducing risk to human life in hazardous environments.  Telepresence and virtual reality: The idea of staying in one's home and being able to sense exotic environments, either real (telepresence) or imaginary (virtual reality) is indeed compelling, and is a driving force behind some major moves in the computer and entertainment industries.
  • 342. 01/16/2025 342 3.2 PARTS: WHAT ARE ROBOTS MADE OF?  Effectors: Tools for action. An effector is any device that affects the environment, under the control of the robot. To have an impact on the physical world, an effector must be equipped with an actuator that converts software commands into physical motion. The actuators themselves are typically electric motors or hydraulic or pneumatic cylinders. For simplicity, we will assume that each actuator determines a single motion or degree of freedom.
  • 343. 01/16/2025 343 CONT… Effectors are used in two main ways: to change the position of the robot within its environment (locomotion), and to move other objects in the environment (manipulation).  Sensors:Tools for perception. Like humans, robots have a proprioceptive sense that tells them where their joints are. Encoders fitted to the joints provide very accurate data about joint angle or extension. Even though robots can sense and control the positions of their joints much more accurately than humans, there are still many tasks that cannot be carried out using only position sensing. In addition to this robots can sense the surrounding environment
  • 344. 01/16/2025 344 CONT…  There are different types of sensors to sense the surrounding environment Light Sensor: Photovoltaic Cells - Photovoltaic cells are energy conversion device used to convert solar radiation into electrical electric energy. Proximity Sensor: Infrared (IR) Transceivers - In IR sensor LED transmit the beam of IR light and if it find an obstacle then the light is reflected back which is captured by an IR receiver. Sound Sensor Temperature Sensor Acceleration Sensor
  • 345. 01/16/2025 345 3.3 LAWS OF ROBOT  Law 1: a robot may not injure human being or through inaction, allows a human being to came to harm.  Law 2: a robot must obey orders given to it by human beings, except which this orders would conflict with the first law.  Law 3: a robot must protect its own existence as long as such protection does not conflict with the first law.
  • 346. 01/16/2025 346 3.4 ADVANTAGES AND DIS ADVANTAGES OF ROBOTS  Advantages of robotes No human intervention Faster precis and accurate They can work 24*7, so productivity increases They can perform multitasking, so man power gets reduced They can work in dangerous tasks, the risk of human health and safety is reduced There is minimal risk if any failure occurs
  • 347. 01/16/2025 347 CONT…  Disadvantages of robots  Robots are replacing human beings in many places which leads to widespread unemployment.  They are costly to build  There is lack of emotions and conscience  They don’t have on spot decision making capability, they act only as they programmed.
  • 348. 01/16/2025 348 THE END OF CHAPTER SEVEN