Uploaded by Obert Gwamure

Stuvia-1705658-cos3751-notes-summary

COS3751 - Notes (Summary)
written by
StuddyScene
www.stuvia.com
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
COS3751
Study Notes
Revision PACK
Exam Notes & Memo
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Fundamentals of
Artificial Intelligence
Introduction to Artificial Intelligence
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
What is Artificial Intelligence?
• The art of creating machines that perform functions that require intelligence wh
performed by people.
• The branch of computer science that is concerned with the automation of intelli
behavior.
• Views of AI fall into four categories:
• Systems that act like humans
• Systems that think like humans
• Systems that think rationally
• Systems that act rationally
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Acting humanly: The Turing Test
• Turing Test, proposed by Alan Turing (1950), was designed to provide a satisfa
operational definition of intelligence
• Can machines think?  Can machines behave intelligently?
• Operational test for intelligent behavior: the Imitation Game
• Suggested major components of AI system: knowledge representation, automat
reasoning, natural language understanding, machine learning.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Thinking humanly: Cognitive Science
• The field of cognitive science brings together computer models from AI and
experimental techniques from psychology to construct precise and testable theo
of the human mind.
• Requires scientific theories of internal activities of the brain
• What level of abstraction? Knowledge or Circuits?
• How to validate? Requires:
1) Predicting and testing behavior of human subjects (top-down), or
2) Direct identification from neurological data (bottom-up)
• Both approaches (Cognitive Science and Cognitive Neuroscience) are now dis
from AI.
• Both share with AI the following characteristic: the available theories do not ex
anything resembling human-level general intelligence
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Thinking rationally: Laws of Thought
• Aristotle: what are correct arguments/thought processes?
• Development of various forms of logic:
• notation and rules of derivation for thoughts.
• may or may not have proceeded to the idea of mechanization
• Direct line through mathematics and philosophy to modern AI
• Main obstacles to this approach.
• First, it is not easy to take informal knowledge and state it in the formal terms required by
logical notation, particularly when the knowledge is less than 100% certain.
• Second, there is a big difference between solving a problem “in principle” and solving it in
practice.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Acting rationally: The rational agent approach
• An agent is just something that acts.
• A rational agent is one that acts so as to achieve the best outcome or, when the
uncertainty, the best expected outcome.
• In the “laws of thought” approach to AI, the emphasis was on correct inferences
• Making correct inferences is sometimes part of being a rational agent, and
• There are also ways of acting rationally that cannot involve inference.
• Rational behavior: doing the right thing
• The right thing: that which is expected to maximize goal achievement, given the available
information
• Doing the right thing doesn't necessarily always involve thinking but thinking should be in
service of rational action
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Acting rationally: Rational agents
• An agent is an entity that perceives and acts
• This AI course concentrates on general principles of rational agents and on
components for constructing them.
• Abstractly, an agent is a function from percept histories to actions:
f : P* → A
• For any given class of environments and tasks, we seek the agent (or class of
agents) with the best performance.
• Computational limitations can make perfect rationality unachievable
 Design best program for given machine resources
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Foundations of AI
• Many disciplines contribute to a foundation for artificial intelligence.
• Philosophy: logic, methods of reasoning, mind as physical system
• Mathematics: formal representation and proof, algorithms, computation,
decidability, probability
• Psychology: phenomena of perception and motor control
• Economics: formal theory of rational decisions
• Linguistics: knowledge representation, grammar
• Neuroscience: how the brain works
• Computer engineers provided powerful machines that make AI application
possible.
• Control theory: designing devices that act optimally on the basis of feedba
from the environment
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
History of Artificial Intelligence
1943
McCulloch & Pitts: Boolean circuit model of brain
• The first work that is now generally recognized as AI.
1950 Turing's “Computing Machinery and Intelligence"
• Turing introduced the Turing Test, machine learning, and reinforcement learning.
1950s Early AI programs:
• Samuel's checkers program, Newell & Simon's Logic Theorist
1956 Dartmouth meeting: Birth of “Artificial Intelligence"
• McCarthy, Minsky and others come together to study artificial intelligence.
1958
McCarthy defined the high-level language Lisp,
• Lisp was to become the dominant AI programming language
1965 Robinson’s discovery of the resolution method
• a complete theorem-proving algorithm for first-order logic
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
History of Artificial Intelligence
1966-74 AI discovers computational complexity
• Neural network research almost disappears
1969-79 Early development of knowledge-based systems
1980-88 Expert systems industry booms
1985-95 Neural networks return to popularity
1987- AI adopts the scientific method
• Hidden Markov Models (HMMs), Bayesian network formalism for uncertainty, data mining
2001- Availability of very large data sets
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
The State of The Art
• What can AI do today?
• Robotic vehicles: driverless robotic cars
• Speech recognition
• Autonomous planning and scheduling: NASA’s Remote Agent program
became the first on-board autonomous planning program to control the
scheduling of operations for a spacecraft
• Game playing: IBM’s DEEP BLUE became the first computer program to
defeat the world champion in a chess match
• Spam fighting
• Robotics
• Machine Translation
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Fundamentals of
Artificial Intelligence
Intelligent Agents
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Agents and Environments
• An agent is anything that can be viewed as perceiving its environment throug
sensors and acting upon that environment through actuators.
• The term percept to refer to the agent’s perceptual inputs at any given instant.
• An agent’s percept sequence is the complete history of everything the agent ha
ever perceived.
• An agent’s behavior is described by the agent function that maps any given per
sequence to an action.
• The agent function for an artificial agent will be implemented by an agent program.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Agents and Environments
• Agents include humans, robots, softbots (software agents), thermostats, etc.
• The agent function f maps from percept histories to actions:
f : P* → A
• The agent program runs on the physical architecture to produce f
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Vacuum-cleaner world with two locations
• Percepts: location and contents, e.g., [A;Dirty]
• Actions: Left, Right, Suck, NoOp
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
A vacuum-cleaner agent
• Partial tabulation of a simple agent function for the vacuum-cleaner world
• Various vacuum-world agents can be defined by filling in the right-hand column in var
ways.
• What is the right way to fill out the table?
• In other words, what makes an agent good or bad, intelligent or stupid?
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Good Behavior: Rationality
• A rational agent is one that does the right thing.  What is the right thing?
• A sequence of actions causes the environment to go through a sequence of states.
• If the sequence is desirable, then the agent has performed well.
• The notion of desirability is captured by a performance measure that evaluates
given sequence of environment states.
• A rational agent chooses whichever action maximizes the expected value of th
performance measure given the percept sequence.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Rationality: omniscience, learning, and autonomy
• An omniscient (perfect) agent knows the actual outcome of its actions and can
accordingly; but perfection is impossible in reality.
• Rationality is NOT the same as perfection.
• Rationality maximizes expected performance, while perfection maximizes actual perform
• A rational agent not only to gather information (exploration) but also to learn
much as possible from what it perceives.
• An agent relies on the prior knowledge of its designer rather than on its own
percepts, we say that the agent lacks autonomy. A rational agent should be
autonomous.
• Rational  exploration, learning, autonomy
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Task Environment: PEAS
• To design a rational agent, we must specify the task environment.
• The performance measure, the environment, and the agent’s actuators and senso
are grouped as the task environment, and called as PEAS (Performance meas
Environment, Actuators, Sensors).
PEAS description of the task environment for an automated taxi
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Environment types
• The environment type largely determines the agent design.
• Fully observable vs. partially observable:
• If an agent’s sensors give it access to the complete state of the environment at each point in
then task environment is called as fully observable.
• Fully observable environments are convenient because the agent need not maintain any internal
to keep track of the world.
• An environment might be partially observable because of noisy and inaccurate sensors.
• Single agent vs. multi agent:
• One or more agents. Solving a crossword puzzle is a single agent environment.
• Chess is a competitive multi agent environment because an agent tries to maximize its
performance while minimizing the performance of other agent.
• Taxi-driving partially cooperative multi agent environment because avoiding collisions
maximizes all agents’ performances.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Environment types
• Deterministic vs. stochastic:
• If the next state of the environment is completely determined by the current state and the ac
executed by the agent, then the environment is deterministic; otherwise, it is stochastic.
• Episodic vs. sequential:
• In an episodic task environment, the agent’s experience is divided into atomic episodes. I
episode the agent receives a percept and then performs a single action. The next episode do
depend on the actions taken in previous episodes.
• In sequential environments, on the other hand, the current decision could affect all future
decisions. Chess and taxi driving are sequential: in both cases, short-term actions can have
term consequences.
• Static vs. dynamic:
• If the environment can change while an agent is deliberating, then we say the environment
dynamic for that agent; otherwise, it is static.
• Discrete vs. continuous:
• The discrete/continuous distinction applies to the state of the environment.
• Chess is discrete; Taxi-driving continuous
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Environment types:
examples of task environments and their characteristic
• The real world is (of course) partially observable, stochastic, sequential, dynam
continuous, multi-agent
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Agent types
• Four basic types in order of increasing generality:
• simple reflex agents
• reflex agents with state
• goal-based agents
• utility-based agents
• All these can be turned into learning agents
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Simple reflex agents
• Simple reflex agents select actions on the basis of the current percept, ignoring
rest of the percept history.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Simple reflex agent in the two-state vacuum environmen
• This program implements the agent function in the following table.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Model-based reflex agents
• A model-based reflex agent keeps track of the current state of the world, using
internal model. It then chooses an action in the same way as the reflex agent.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Goal-based agents
• A goal-based agent keeps track of the world state as well as a set of goals it is
trying to achieve, and chooses an action that will (eventually) lead to the
achievement of its goals.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Utility-based agents
• A utility-based agent uses a model of the world, along with a utility function th
measures its preferences among states of the world.
• Then it chooses the action that leads to the best expected utility, where expected
utility is computed by averaging over all possible outcome states, weighted by t
probability of the outcome.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Learning agents
• learning element is responsible for making improvements,
• performance element is responsible for selecting external actions.
• The learning element uses feedback from critic on how agent is doing and
determines how performance element should be modified to do better in future.
• problem generator is responsible for suggesting actions that will lead to new a
informative experiences.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Intelligent Agents: Summary
•
•
•
•
•
•
•
Agents interact with environments through actuators and sensors
The agent function describes what the agent does in all circumstances
The performance measure evaluates the environment sequence
A rational agent maximizes expected performance
Agent programs implement (some) agent functions
PEAS descriptions define task environments
Environments are categorized along several dimensions:
• observable? deterministic? episodic? static? discrete? single-agent?
• Several basic agent architectures exist:
• reflex, reflex with state, goal-based, utility-based
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Fundamentals of
Artificial Intelligence
Solving Problems by Searching
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Problem-Solving Agent
• A problem-solving agent is a goal-based agent and use atomic representations.
• In atomic representations, states of the world are considered as wholes, with no internal structure visi
the problem solving algorithms.
• Intelligent agents are supposed to maximize their performance measure. Achieving this is some
simplified if the agent can adopt a goal and aim at satisfying it.
• Problem formulation is the process of deciding what actions and states to consider, given a go
• The process of looking for a sequence of actions that reaches the goal is called search.
• A search algorithm takes a problem as input and returns a solution in the form of an action
sequence.
• Once a solution is found, the carrying actions it recommends is called the execution phase.
• A problem-solving agent has three phases:
• problem formulation, searching solution and executing actions in the solution.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Problem-Solving Agent
Well-defined problems
A problem can be defined by five components:
• initial state, actions, transition model, goal test, path cost.
INITIAL STATE: The initial state that the agent starts in.
ACTIONS: A description of the possible actions available to the agent.
• Given a particular state s, ACTIONS(s) returns the set of actions that can be executed in s.
• Each of these actions is applicable in s.
TRANSITION MODEL: A description of what each action does is known as the transition mod
• A function RESULT(s,a) that returns the state that results from doing action a in state s.
• The term successor to refer to any state reachable from a given state by a single
• The state space of the problem is the set of all states reachable from the initial state by any seq
of actions.
• The state space forms a graph in which the nodes are states and the links between nodes are ac
• A path in the state space is a sequence of states connected by a sequence of actions.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Problem-Solving Agent
Well-defined problems
GOAL TEST: The goal test determines whether a given state is a goal state.
PATH COST: A path cost function that assigns a numeric cost to each path.
• The problem-solving agent chooses a cost function that reflects its own performance measure.
• The cost of a path can be described as the sum of the costs of the individual actions along the p
• The step cost of taking action a in state s to reach state s′ is denoted by c(s, a, s′).
• A SOLUTION to a problem is an action sequence that leads from the initial state to a goal stat
• Solution quality is measured by the path cost function, and an OPTIMAL SOLUTION has the
lowest path cost among all solutions.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Problem Example
Travelling in Romania
• On holiday in Romania; currently in Arad.
• Flight leaves tomorrow from Bucharest
Formulate goal:
• be in Bucharest
Formulate problem:
• states: various cities
• actions: drive between cities
Find solution:
• sequence of cities, e.g., Arad, Sibiu, Fagaras, Bucharest
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Problem Example
Travelling in Romania: A simplified road map
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Problem Example
Travelling in Romania
• Travelling in Romania problem can be defıned by:
initial state: in Arad
actions: transition model: is the graph
successor function S(x) = set of action{state pairs
e.g., S(Arad) = { <Arad → Zerind,Zerind>, <Arad → Sibiu,Sibiu>,
< Arad → Timisoara,Timisoara> }
goal test: in Bucharest
path cost: sum of distances, number of actions executed, etc.
c(x; a; y) is the step cost, assumed to be ≥ 0
• A solution is a sequence of actions leading from the initial state to a goal state
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Problem Example
vacuum world
States:
• The state is determined by both the agent location and the dirt locations.
• The agent is in one of two locations, each of which might or might not contain dirt.
• Thus, there are 2 × 22 = 8 possible world states.
Initial state: Any state can be designated as the initial state.
Actions: Each state has just three actions: Left, Right, and Suck.
Transition model:
• The actions have their expected effects, except that moving Left in the leftmost square, moving
in the rightmost square, and Sucking in a clean square have no effect.
• The transition model defines a state space.
Goal test: This checks whether all the squares are clean.
Path cost: Each step costs 1, so the path cost is the number of steps in the path.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Problem Example
vacuum world: state space for the vacuum world
• Links denote actions: L = Left, R =Right, S = Suck.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Problem Example
8-puzzle
• The 8-puzzle consists of a 3×3 board with eight numbered tiles and a blank space.
• A tile adjacent to the blank space can slide into the space.
• The object is to reach a specified goal state.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Problem Example
8-puzzle
States: A state specifies the location of each of the eight tiles and the blank in one of the nine squ
Initial state: Any state can be designated as the initial state.
• Note that goal can be reached from exactly half of the possible initial states.
Actions: Movements of the blank space Left, Right, Up, or Down.
• Different subsets of these are possible depending on where the blank is.
Transition model: Given a state and action, this returns the resulting state;
Goal test: This checks whether the state matches the goal configuration
Path Cost: Each step costs 1, so the path cost is the number of steps in the path.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Problem Example
8-puzzle
• The 8-puzzle belongs to the family of sliding-block puzzles,
• This family is known to be NP-complete.
• Optimal solution of n-Puzzle family is NP-hard. ie NO polynomial solution for the problem
• The 8-puzzle has 9!/2=181, 440 reachable states.
• The 15-puzzle (on a 4×4 board) has around 1.3 trillion states,
• The 24-puzzle (on a 5 × 5 board) has around 1025 states
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Real-World Problems
• Route-finding problem is defined in terms of specified locations and transitions along links be
them.
• Route-finding algorithms are used in a variety of applications such as Web sites and in-car syste
that provide driving directions.
• VLSI layout problem requires positioning millions of components and connections on a chip t
minimize area, minimize circuit delays, minimize stray capacitances, and maximize manufactur
yield.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Searching for Solutions
• A solution is an action sequence and search algorithms considers various possible action seque
• The possible action sequences starting at the initial state form a search tree with the initial state
the root;
• The branches are actions and the nodes correspond to states in the state space of the problem.
• Expanding the current state is application of each legal action to the current state and generatio
new set of states.
• The current state is the parent node, newly generated states are child nodes
• Leaf node is a node with no children in the tree.
• The set of all leaf nodes available for expansion at any given point is called the frontier.
• Search algorithms all share this basic structure; they vary primarily according to how they cho
which state to expand next: search strategy.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Partial Search Trees for Travelling in Romania
initial state
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Partial Search Trees for Travelling in Romania
After expanding Arad
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Partial Search Trees for Travelling in Romania
After expanding Sibiu
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Infrastructure for Search Algorithms
• Search algorithms require a data structure to keep track of the search tree that is being construct
• Each node n of the tree contains four components:
n.STATE: the state in the state space to which the node corresponds;
n.PARENT: the node in the search tree that generated this node;
n.ACTION: the action that was applied to the parent to generate the node;
n.PATH-COST: the cost of the path from the initial state to the node,
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Informal Description of
Graph Search Algorithms
function GRAPH-SEARCH(problem) returns a solution, or failure
• initialize frontier using initial state of problem
• initialize explored set to be empty
• loop do
• if frontier is empty then return failure
• choose a leaf node from frontier and remove it from there
• if node contains a goal state then return corresponding solution
• add node to explored set
• expand node, adding resulting nodes to frontier only if not in frontier or explored set
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Informal Description of
Graph Search Algorithms
• To avoid exploring redundant paths is to remember them.
• Explored set (also known as closed list) remembers every expanded node.
• The frontier needs to be stored in such a way that search algorithm can easily choose next nod
expand according to its preferred strategy.
• The appropriate data structure for this is a queue.
• Queues are characterized by the order in which they store the inserted nodes.
• First-in, first-out or FIFO queue, which pops the oldest element of the queue; (QUEUE)
• Last-in, first-out or LIFO queue (also known as STACK), which pops the newest element
• PRIORITY QUEUE, which pops the element of the queue with the highest priority according to som
ordering function.
• The explored set can be implemented with a hash table to allow efficient checking for repeated
states.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Measuring Problem-Solving Performance
• We can evaluate a search algorithm’s performance in four ways:
Completeness: Is the algorithm guaranteed to find a solution when there is one?
Optimality: Does the strategy find the optimal solution?
Time complexity: How long does it take to find a solution?
Space complexity: How much memory is needed to perform the search?
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Measuring Problem-Solving Performance
• The typical measure for time and space complexity is the size of the state space graph, |V | + |E
where V is the set of vertices (nodes) of the graph and E is the set of edges (links).
• This is appropriate when the graph is an explicit data structure.
• In AI, graph is often represented implicitly by the initial state, actions, and transition model and
frequently infinite. For these reasons, complexity is expressed in terms of three quantities:
• b - maximum branching factor of the search tree
• d - depth of the least-cost solution
• m - maximum depth of the state space (may be ∞)
• Time is often measured in terms of the number of nodes generated during the search, and space
terms of the maximum number of nodes stored in memory.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Uninformed Search Strategies
• Uninformed strategies use only the information available in the problem definition.
• All they can do is generate successors and distinguish a goal state from a non-goal state.
• All search strategies are distinguished by the order in which nodes are expanded.
• Uninformed (blind) Search Strategies are:
• Breadth-first Search
• Uniform-cost Search
• Depth-first Search
• Depth-limited Search
• Iterative Deepening Search
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Breadth-First Search
• Breadth-first search is a simple strategy in which the root node is expanded first, then all the
successors of the root node are expanded next, then their successors, and so on.
• All nodes are expanded at a given depth in search tree before any nodes at next level are
expanded.
• Breadth-first search uses a FIFO queue for the frontier
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Breadth-First Search
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Breadth-First Search: Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Frontier
Explor
A
empty
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Breadth-First Search: Example
Frontier
Explor
B
A
C
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Breadth-First Search: Example
Frontier
Explor
C
A, B
D
E
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Breadth-First Search: Example
Frontier
Explor
D
A, B, C
E
F
G
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Properties of Breadth-First Search
Complete?
Yes
if branching factor b is finite
Time?
1 + b + b2 + b3 + : : : + bd = O(bd+1), i.e., exponential in depth d
Space?
O(bd+1) (keeps every node in memory)
Optimal?
Yes
(if cost = 1 per step); not optimal in general
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Breadth-First Search
• Time and memory requirements for breadth-first search assuming branching factor b = 10; 1 million
nodes/second; 1000 bytes/node.
• The memory requirements are a bigger problem for breadth-first search than is the execution time.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Uniform-Cost Search
• When all step costs are equal, breadth-first search is optimal because it always expands the
shallowest unexpanded node.
• In general, it is not optimal when step costs are different.
• By a simple extension, we can find an algorithm that is optimal with any step-cost functio
• Uniform-cost search expands node n with the lowest path cost g(n).
• This is done by storing the frontier as a priority queue ordered by g.
• Uniform-cost search is equivalent to breadth-first if step costs are all equal
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Uniform-Cost Search
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Properties of Uniform-Cost Search
if step cost ≥ 𝜖 where cost of every step exceeds positive constant 𝜖.
Complete?
Yes
Time?
O(bC/e) where C is the cost of the optimal solution and e is 𝜖
The cost of generating all nodes whose costs ≤ cost of optimal solution
Space?
O(bC/e) where C is the cost of the optimal solution and e is 𝜖
Keeping all nodes whose costs ≤ cost of optimal solution
Optimal?
Yes
nodes expanded in increasing order of path cost
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Depth-First Search
• Depth-first search always expands deepest unexpanded node in frontier of search tree.
• As nodes are expanded, they are dropped from frontier, so then search “backs up” to next
deepest node that still has unexplored successors.
• Depth-first search uses a LIFO queue (STACK).
• A LIFO queue means that the most recently generated node is chosen for expansion.
• This must be the deepest unexpanded node because it is one deeper than its parent.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Depth-First Search
• Depth-first search on a binary tree.
• Explored nodes with no descendants in the frontier are removed from memory.
• Nodes at depth 3 have no successors and M is the only goal node.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Depth-First Search
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Depth-First Search
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Depth-First Search
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Depth-First Search
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Depth-First Search
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Depth-First Search
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Depth-First Search
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Depth-First Search
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Depth-First Search
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Depth-First Search
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Depth-First Search
•
Goal (M) is found
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Properties of depth-first search
Complete?
No:
fails in infinite-depth spaces, spaces with loops
Modify to avoid repeated states along path  complete finite spaces
Time?
O(bm) where m is the maximum depth of search tree
terrible if m is much larger than d (depth of shallowest solution)
but if solutions are dense, may be much faster than breadth-first
Space?
O(bm) linear space
Optimal?
No
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Depth-Limited Search
• The failure of depth-first search in infinite state spaces can be alleviated by supplying depth-firs
search with a predetermined depth limit ℓ.
• Nodes at depth ℓ are treated as if they have no successors.
• This approach is called depth-limited search.
• The depth limit solves the infinite-path problem.
• Unfortunately, it also introduces an additional source of incompleteness if we choose ℓ < d, that
the shallowest goal is beyond the depth limit.
• Depth-limited search will also be non-optimal if we choose ℓ > d.
• Its time complexity is O(bℓ) and its space complexity is O(bℓ).
• Depth-first search can be viewed as a special case of depth-limited search with ℓ=∞.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Depth-Limited Search
Recursive implementation
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Iterative Deepening Depth-First Search
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Iterative deepening search l = 0
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Iterative deepening search l = 1
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Iterative deepening search l = 2
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Iterative deepening search l = 3
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Properties of iterative deepening search
Complete?
Yes
Time?
O(bd)
Space?
O(bd)
linear space
Optimal?
Yes
if step cost = 1
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Comparing uninformed search strategies
• b is the branching factor; d is the depth of the shallowest solution;
• m is the maximum depth of the search tree; l is the depth limit.
• Superscripts:
• a complete if b is finite;
• b complete if step costs ≥ 𝜖 for positive 𝜖;
• c optimal if step costs are all identical;
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Fundamentals of
Artificial Intelligence
Informed Searches
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Informed (Heuristic) Search Strategies
• An informed search strategy uses problem specific knowledge beyond the definition of the pr
itself and it can find solutions more efficiently than can an uninformed strategy.
• Best-first search is an algorithm in which a node is selected for expansion based on an evaluat
function, f(n).
• The evaluation function is construed as a cost estimate, so the node with the lowest evaluation i
expanded first.
• The implementation of best-first graph search is identical to that for uniform-cost search excep
the use of evaluation function f instead of lowest path cost g to order the priority queue.
• The choice of evaluation function determines the search strategy.
• Most best-first algorithms include a heuristic function, h(n) as a component of evaluation
function.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Uniform-Cost Search: Review
We have use evalu
function f(n) inste
PATH-COST for Be
search.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Heuristic Function
• A heuristic function h(n) is the estimated cost of the cheapest path from the state at node n to
state.
• Heuristic functions are the most common form of additional knowledge of the problem for
informed (heuristic) search algorithms.
• Heuristic functions are nonnegative, problem-specific functions, with one constraint: if n is a g
node, then h(n)=0.
• When we use a heuristic function to guide our search, we perform informed (heuristic”) sear
• Some informed (heuristic) searches:
• Greedy best-first search
• A*
• Recursive best-first search (a memory-bounded heuristic search)
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Heuristic Function Example
straight line distance heuristic
• For route-finding problems in Romania, we can use the straight line distance heuristic hSLD.
• If the goal is Bucharest, we need to know the straight-line distances to Bucharest
• The values of hSLD cannot be computed from the problem description itself.
• Since hSLD is correlated with actual road distances and it is a useful heuristic.
hSLD(n) = straight-line distance from node n to Bucharest
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Heuristic Function Example
straight line distance heuristic
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Greedy best-first search
• Greedy best-first search expands the node that is closest to the goal, on the grounds that this i
likely to lead to a solution quickly.
• Greedy search expands the node that appears to be closest to goal
• Greedy best-first search evaluates nodes by using just the heuristic function.
• This means that it uses heuristic function h(n) as the evaluation function f(n) ( that is f(n) = h(n
• For Romania problem, the heuristic function
hSLD(n) = straight-line distance from n to Bucharest
as evaluation function
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Greedy search example
Node labels are hSLD values
Arad is the initial state.
Frontier
Arad
Explored
366
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Greedy search example
Node labels are hSLD values
After expanding Arad.
Frontier
Sibiu
Timisoara
Zerind
253
329
374
Explored
Arad
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Greedy search example
Node labels are hSLD values
After expanding Sibiu.
Frontier
Fagaras
RimnicuVil
Timisoara
Zerind
Oradea
176
193
329
374
380
Explored
Arad
Sibiu
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Greedy search example
Node labels are hSLD values
After expanding Fagaras.
Frontier
Bucharest
RimnicuVil
Timisoara
Zerind
Oradea
0
193
329
374
380
Explored
Arad
Sibiu
Fagaras
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Properties of greedy search
Complete?
NO
It can get stuck in loops without repeated-state checking
Complete in finite space with repeated-state checking
Time?
O(bm) where m is the maximum depth of the search tree.
but a good heuristic can give dramatic improvement
Space?
O(bm)
keeps all nodes in memory
Optimal?
NO
nodes expanded in increasing order of path cost
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Properties of greedy search
Optimal? NO
the path via Sibiu and Fagaras to Bucharest is 32 kilometers longer than
the path through Rimnicu Vilcea and Pitesti.
path found by greedy sear
optimum path
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
A* Search
Minimizing the total estimated solution cost
Idea: Avoid expanding paths that are already expensive
Evaluation function f(n) = g(n) + h(n)
g(n) = cost so far to reach node n
h(n) = estimated cost to goal from node n
f(n) = estimated total cost of path through node n to goal
• Since g(n) gives the path cost from the start node to node n, and h(n) is the estimated cost of th
cheapest path from n to the goal,
f(n) = estimated cost of the cheapest solution through n
• If heuristic function h(n) satisfies certain conditions, A∗ search is both complete and optim
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
A* Search Example
Node labels are f(n) = g(n) + hSLD(n)
Arad is the initial state.
Frontier
Arad
Explored
366
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
A* Search Example
Node labels are f(n) = g(n) + hSLD(n)
After expanding Arad.
Frontier
Sibiu
Timisoara
Zerind
393
447
449
Explored
Arad
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
A* Search Example
Node labels are f(n) = g(n) + hSLD(n)
After expanding Sibiu.
Frontier
RimnicuVil
Fagaras
Timisoara
Zerind
Oradea
413
415
447
449
671
Explored
Arad
Sibiu
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
A* Search Example
Node labels are f(n) = g(n) + hSLD(n)
After expanding Rimnicu Vilcea.
Frontier
Fagaras
Pitesti
Timisoara
Zerind
Craiova
Oradea
415
417
447
449
526
671
Explored
Arad
Sibiu
RimnicuVil
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
A* Search Example
Node labels are f(n) = g(n) + hSLD(n)
After expanding Fagaras.
Frontier
Pitesti
Timisoara
Zerind
Bucharest
Craiova
Oradea
417
447
449
450
526
671
Explored
Arad
Sibiu
RimnicuVil
Fagaras
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
A* Search Example
Node labels are f(n) = g(n) + hSLD(n)
After expanding Pitesti.
Frontier
Bucharest
Timisoara
Zerind
Craiova
Oradea
450 418
447
449
526
671
Explored
Arad
Sibiu
RimnicuVil
Fagaras
Pitesti
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
A* Search Example
Node labels are f(n) = g(n) + hSLD(n)
Path found by A*: Arad, Sibiu, Rimnicu Vilcea, Pitesti, Bucharest
A* Path Cost: 140+80+97+101 = 418
Optimum Path Cost: 418
A* finds an optimum path.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Conditions for Optimality:
Admissibility and Consistency
• The first condition for optimality is that heuristic function h(n) must be an admissible heuristic
• An admissible heuristic is one that never overestimates the cost to reach the goal (optimist
• A heuristic h(n) is admissible if for every node n, h(n)≤ C(n) where C(n) is the true cost to
the goal state from the state of node n.
• Straight-line distance heuristic hSLD(n) is admissible because the shortest path between any two po
a straight line. hSLD(n) never overestimates actual distance.
• If h(n) is admissible, f(n) never overestimates the cost to reach the goal because f(n)=g(n)+h(n) and g
the actual cost to reach node n.
• A heuristic h(n) is consistent if, for every node n and every successor n′ of n generated by any
action a, the estimated cost of reaching the goal from n is no greater than the step cost of getting
plus the estimated cost of reaching the goal from n′:
h(n) ≤ c(n, a, n′) + h(n′)
• hSLD(n) is consistent.
• If h(n) is admissible and consistent, then A* is complete and optimal.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Optimality of A* (proof)
• If h(n) is consistent (h(n) ≤ c(n, a, n′) + h(n′)),
then the values of f(n) along any path are non-decreasing.
• The proof follows directly from the definition of consistency.
• Suppose n′ is a successor of n; then g(n′)=g(n) + c(n, a, n′) for some action a, and we have
f(n′) = g(n′) + h(n′) = g(n) + c(n, a, n′) + h(n′) ≥ g(n) + h(n) = f(n) .
• Whenever A∗ selects a node n for expansion, the optimal path to that node has been found
• If this is not the case, there would have to be another frontier node n′ on the optimal path from the sta
node to n, because f is non-decreasing along any path, n′ would have lower f-cost than n and would h
been selected first.
• From these two preceding observations, it follows that the sequence of nodes expanded by
in non-decreasing order of f(n).
• Hence, the first goal node selected for expansion must be an optimal solution because f is t
true cost for goal nodes (h(Goal)=0) and all later goal nodes will be at least as expensive.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Optimality of A*
• A* expands nodes in order of increasing f value. Gradually adds f-contours of nodes. Contour i
all nodes with f = fi, where fi < fi+1
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Properties of A*
unless there are infinitely many nodes with f ≤f(Goal)
Complete?
YES
Time?
Exponential (depends on h(n))
Space?
O(bm)
keeps all nodes in memory
Optimal?
YES
A* cannot expand fi+1 until fi is finished.
• A* expands all nodes with f(n) < C* where C* is the optimal cost
• A* expands some nodes with f(n) = C*
• A* expands no nodes with f(n) > C*
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Recursive best-first search
Memory-bounded heuristic search
• Recursive best-first search (RBFS) is a simple recursive algorithm that attempts to mimic the
operation of standard best-first search, but using only linear space.
• Its structure is similar to that of a recursive depth-first search, but rather than continuing indefi
down the current path, it uses the f-limit variable to keep track of the f-value of the best alternat
path available from any ancestor of the current node.
• If the current node exceeds this limit, the recursion unwinds back to the alternative path.
• As the recursion unwinds, RBFS replaces the f-value of each node along the path with a backed
value (the best f-value of its children).
• In this way, RBFS remembers the f-value of the best leaf in the forgotten subtree and can theref
decide whether it’s worth
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Recursive best-first search
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Stages in an RBFS search
for the shortest route to Bucharest.
Arad will be expanded.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Stages in an RBFS search
for the shortest route to Bucharest.
Sibiu will be expanded
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Stages in an RBFS search
for the shortest route to Bucharest.
Rimnicu Vilcea will be expanded
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Stages in an RBFS search
for the shortest route to Bucharest.
Unwind to Sibiu.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Stages in an RBFS search
for the shortest route to Bucharest.
After unwinding to Sibiu. Fagaras will be expanded
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Stages in an RBFS search
for the shortest route to Bucharest.
Unwind to Sibiu again.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Stages in an RBFS search
for the shortest route to Bucharest.
After Unwinding to Sibiu again. Rimnicu Vilcea will be re-expanded.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Stages in an RBFS search
for the shortest route to Bucharest.
Pitesti will be expanded.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Stages in an RBFS search
for the shortest route to Bucharest.
After expanding Pitesti, the best successor is Bucharest. RBFS will be called with Bucharest and Goal is reac
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Heuristic Functions
• The 8-puzzle was one of the earliest heuristic search problems.
• The average solution cost for a randomly generated 8-puzzle instance is about 22 steps.
• The branching factor is about 3.
• in the middle four moves
• in a corner  two moves
• along an edge  three moves
• A search algorithm may look at 170,000 states to solve a random 8-puzzle instance, because
9!/2=181,400 distinct states are reachable.
• A search algorithm may look at 1013 s.tates to solve a random 15-puzzle instance
 We need a good heuristic function.
 If we want to find the shortest solutions by using A∗,
we need a heuristic function that never overestimates the number of steps to the goal.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Heuristic Functions
• A typical instance of the 8-puzzle. The solution is 26 steps long.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Heuristic Functions
Two admissible heuristics for 8-puzzle.
h1(n) = number of misplaced tiles
• h1 is an admissible heuristic because any tile that is out of place must be moved at least once.
h2(n) = total Manhattan distance (the sum of the distances of the tiles from their goal positio
• Because tiles cannot move along diagonals, the distance is the sum of the horizontal and vertical dist
• h2 is also admissible because all any move can do is move one tile one step closer to the goal.
h1(start) = 8
h2(start) = 3+1+2+2+2+3+3+2 = 18
summation Manhattan Distances of tiles 1 to 8
Neither of these overestimates the true solution cost, which
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
The effect of heuristic accuracy on performance
• The quality of a heuristic can be measured by its effective branching factor b∗.
• If the total number of nodes generated by A∗ for a particular problem is N and the solution dept
then b∗ is the branching factor that a uniform tree of depth d would have to have in order to con
N + 1 nodes.
• If A∗ finds a solution at depth 5 using 52 nodes, then the effective branching factor is 1.92.
• Experimental measurements of b∗ on a small set of problems can provide a good guide to the
heuristic’s overall usefulness.
• A well-designed heuristic would have a value of b∗ close to 1.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
The effect of heuristic accuracy on performance
• To test the heuristic functions h1 and h2, 1200 random problems are generated with solution len
from 2 to 24 (100 for each even number) and solved with iterative deepening search and with A
search using both h1 and h2.
• The results suggest that h2 is better than h1, and it is far better than using iterative deepening se
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Dominance
• If h2(n) ≥ h1(n) for all n (both h1 and h2 are admissible) then h2 dominates h1 and h2 is bette
h1 for search.
• Domination translates directly into efficiency.
• A∗ using h2 will never expand more nodes than A∗ using h1.
• It is generally better to use a heuristic function with higher values, provided it is consistent.
Given any admissible heuristics ha, hb,
h(n) = max(ha(n), hb(n))
is also admissible and h(n) dominates both ha and hb
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Generating Admissible Heuristics from Relaxed Problem
• h1 (misplaced tiles) and h2 (Manhattan distance) are fairly good heuristics for the 8-puzzle and
h2 is better.
• A problem with fewer restrictions on the actions is called a relaxed problem.
• Admissible heuristics can be derived from the exact solution cost of a relaxed version of th
problem.
• If the rules of the 8-puzzle are relaxed so that a tile can move anywhere, then h1(n) gives the sh
solution.
• If the rules are relaxed so that a tile can move to any adjacent square, then h2(n) gives the short
solution.
• Key point: the optimal solution cost of a relaxed problem is no greater than the optimal solution
of the real problem
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Summary
• Heuristic functions estimate costs of shortest paths
• Good heuristics can dramatically reduce search cost
• Greedy best-first search expands lowest h
• incomplete and not always optimal
• A* search expands lowest g + h
• complete and optimal
• also optimally efficient
• Admissible heuristics can be derived from exact solution of relaxed problems
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Fundamentals of
Artificial Intelligence
Local Search Algorithms
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Local Search
• The uninformed and informed search algorithms that we have seen are designed to explore sear
spaces systematically.
• They keep one or more paths in memory and by record which alternatives have been explored at each
along the path.
• When a goal is found, the path to that goal also constitutes a solution to the problem.
• In many problems, however, the path to the goal is irrelevant.
• If the path to the goal does not matter, we might consider a different class of algorithms that do
worry about paths at all.
 local search algorithms
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Local Search
• Local search algorithms operate using a single current node and generally move only to neigh
of that node.
• Local search algorithms ease up on completeness and optimality in the interest of improving
and space complexity?
• Although local search algorithms are not systematic, they have two key advantages:
1. They use very little memory (usually a constant amount), and
2. They can often find reasonable solutions in large or infinite (continuous) state spaces.
• In addition to finding goals, local search algorithms are useful for solving pure optimization
problems, in which the aim is to find the best state according to an objective function.
• In optimization problems, the path to goal is irrelevant and the goal state itself is the solu
• In some optimization problems, the goal is not known and the aim is to find the best state
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Hill Climbing Search
(Steepest Ascent/Descent)
• At each iteration, the hill-climbing search algorithm moves to the best successor of the curren
node according to an objective function.
•
•
•
•
Best successor is the successor with best value (highest or lowest) according to an objective function
If no successors have better value than the current value, it returns.
It moves in direction of uphill (hill climbing).
It terminates when it reaches a “peak” where no neighbor has a higher value.
• The algorithm does not maintain a search tree, so the data structure for the current node need on
record the state and the value of the objective function.
• Hill climbing does not look ahead beyond the immediate neighbors of the current state.
• Hill climbing is sometimes called greedy local search because it grabs a good neighbor state w
thinking ahead about where to go next.
• Greedy algorithms often perform quite well and
• Hill climbing often makes rapid progress toward a solution.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Hill Climbing Search
(Steepest Ascent/Descent)
best successor
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Hill Climbing Search
• To understand local search, it is useful to consider the state-space landscape.
• The aim is to find the highest peak - a global maximum.
• Hill-climbing search modifies the current state to try to improve it.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Hill Climbing Search
• A local maximum is a peak that is higher than each of its neighboring states but lower than the
global maximum.
• Hill-climbing algorithms that reach the vicinity of a local maximum will be drawn upward toward th
but will then be stuck with nowhere else to go.
• A plateau is a flat area of the state-space landscape. It can be a flat local maximum, from whi
uphill exit exists, or a shoulder, from which progress is possible.
• A hill-climbing search might get lost on the plateau.
• Random sideways moves can escape from shoulders but they loop forever on flat maxima.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Hill Climbing Example
n-queens
• Put n queens on an n × n board with no two queens on the same row, column, or diagonal
• Move a queen to reduce number of conflicts.
 Objective function: number of conflicts (no conflicts is global minimum)
• The successors of a state are all possible states generated by moving a single queen to another square
the same column (so each state has n*(n-1) successors).
• The heuristic cost function h is the number of pairs of queens that are attacking each other, either dir
or indirectly.
• The global minimum of this function is zero, which occurs only at perfect solutions.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Hill Climbing Example
n-queens
• Hill Climbing may NOT reach to a goal state for n-queens problem.
 five steps to reach this state
• An 8-queens state with heuristic cost estimate h=17
• The value of h for each possible successor obtained
by moving a queen within its column.
• The best moves are marked with value 12.
• A local minimum in the 8-queens state sp
the state has h=1
• but every successor has a higher cost.
• Hill Climbing will stuck here
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Hill Climbing Example
n-queens
• Starting from a randomly generated 8-queens state, steepest-ascent hill climbing gets stuck 86
the time, solving only 14% of problem instances.
• The Hill Climbing algorithm halts if it reaches a plateau.
• One possible solution is to allow sideways move in the hope that the plateau is really a shoulder.
• If we always allow sideways moves when there are no uphill moves, an infinite loop will occur when
the algorithm reaches a flat local maximum that is not a shoulder.
• One common solution is to put a limit on the number of consecutive sideways moves allowed.
• For example, we could allow up to 100 consecutive sideways moves in the 8-queens problem. This r
the percentage of problem instances solved by hill climbing from 14% to 94%.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Hill Climbing Example
8-puzzle
Heuristic function is
Manhattan Distance
1
6
4
2
3
5
7
8
h=3
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Hill Climbing Example
8-puzzle
1
6
1
6
4
2
3
5
7 8
h=4
4
2
1
3
5
3
5
7
8
6
7 8
h=2
h=3
Heuristic function is
Manhattan Distance
4
2
1
4
2
6
3
5
7
8
h=4
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Hill Climbing Example
8-puzzle
1
6
4
2
3
5
7 8
h=4
1
6
4
2
3
5
7
h=3
1
1
6
3
3
5
6
6
7 8
h=2
1
4
3
5
2
1
3
5
7
8
h=3
4
1
4
2
6
3
5
7
8
h=4
6
8
2
2
4
4
5
7 8
h=1
7
h=3
2
8
1
4
2
3
7
5
h=3 6
Heuristic function is
Manhattan Distance
8
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Hill Climbing Example
8-puzzle: a solution case
1
6
4
2
3
5
7 8
h=4
1
6
4
2
3
5
7
h=3
1
1
6
1
5
3
7 8
h=1
6
3
3
5
6
6
7 8
h=2
1
4
3
5
2
1
3
5
7
8
h=3
4
1
4
2
6
3
5
7
8
h=4
6
8
2
2
4
4
7
h=3
2
4
5
7 8
h=0
2
8
1
4
2
3
7
5
h=3 6
Heuristic function is
Manhattan Distance
8
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Hill Climbing Example
8-puzzle: stuck at local maximum
2
1
7
2
3
1
8
4
7
6
5
h = 12
1
7
8
3
1
2
3
4
7
8
4
6 5
h = 13
Heuristic function is
Manhattan Distance
6 5
h = 12
2
3
8
4
1
6 5
h = 11
7
1
2
3
8
4
We are stuck with a local maximum.
6 5
h = 12
2
3
8
4
7
6 5
h = 12
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Hill Climbing
• Hill Climbing is NOT complete.
• Hill Climbing is NOT optimal.
• Why use local search?
• Low memory requirements – usually constant
• Effective – Can often find good solutions in extremely large state spaces
• Randomized variants of hill climbing can solve many of the drawbacks in practice.
• Many variants of hill climbing have been invented.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Stochastic Hill Climbing
• Stochastic hill climbing chooses at random from among the uphill moves;
• The probability of selection can vary with the steepness of the uphill move.
• Stochastic hill climbing usually converges more slowly than steepest ascent, but in some state
landscapes, it finds better solutions.
• Stochastic hill climbing is NOT complete, but it may be less likely to get stuck.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
First-Choice Hill Climbing
• First-choice hill climbing implements stochastic hill climbing by generating successors rando
until one is generated that is better than the current state.
• This is a good strategy when a state has many of successors.
• First-choice hill climbing is also NOT complete,
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Random-Restart Hill Climbing
• Random-Restart Hill Climbing conducts a series of hill-climbing searches from randomly
generated initial states, until a goal is found.
• Random-Restart Hill Climbing is complete if infinite (or sufficiently many tries) are allowed.
• If each hill-climbing search has a probability p of success, then the expected number of restart
required is 1/p.
• For 8-queens instances with no sideways moves allowed, p ≈ 0.14, so we need roughly 7 iterati
find a goal (6 failures and 1 success).
• For 8-queens, then, random-restart hill climbing is very effective indeed.
• Even for three million queens, the approach can find solutions in under a minute.
• The success of hill climbing depends very much on the shape of the state-space landscape:
• If there are few local maxima and plateau, random-restart hill climbing will find a good solution ver
quickly.
• On the other hand, many real problems have many local maxima to get stuck on.
• NP-hard problems typically have an exponential number of local maxima to get stuck on.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Simulated Annealing
• A hill-climbing algorithm that never makes “downhill” moves toward states with lower value
higher cost) is guaranteed to be incomplete, because it can get stuck on a local maximum.
• In contrast, a purely random walk—that is, moving to a successor chosen uniformly at random from
set of successors—is complete but extremely inefficient.
• Therefore, it seems reasonable to combine hill climbing with a random walk in some way that yield
efficiency and completeness.
• Idea: escape local maxima by allowing some “bad” moves but gradually decrease their size a
frequency.
• The simulated annealing algorithm, a version of stochastic hill climbing where some downhi
moves are allowed.
• Annealing: the process of gradually cooling metal to allow it to form stronger crystalline struct
• Simulated annealing algorithm: gradually “cool” search algorithm from Random Walk to Firs
Choice Hill Climbing
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Simulated Annealing
• Downhill moves are accepted readily ear
in the annealing schedule and then less o
as time goes on.
• The schedule input determines the value
temperature T as a function of time.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Simulated Annealing
• Instead of picking the best move, Simulated Annealing picks a random move.
• If the move improves the situation, it is always accepted.
• Otherwise, the algorithm accepts the move with some probability less than 1.
• The probability decreases exponentially with the “badness” of the move—the amount ΔE by wh
the evaluation is worsened.
• The probability also decreases as the “temperature” T goes down: “bad” moves are more likely
allowed at the start when T is high, and they become more unlikely as T decreases.
• If the schedule lowers T slowly enough, the algorithm will find a best state with probabilit
approaching 1.
• Simulated Annealing is widely used in VLSI layout and airline scheduling.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Local Beam Search
• The local beam search algorithm keeps track of k states rather than just one.
• It begins with k randomly generated states.
• At each step, all the successors of all k states are generated.
• If any one is a goal, the algorithm halts.
• Otherwise, it selects the k best successors from the complete list and repeats.
• The local beam search algorithm is not the same as k searches run in parallel!
• In a local beam search, searches that find good states recruit other searches to join them.
• In a random-restart search, each search process runs independently of the others.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Stochastic Beam Search
• Problem: quite often, all k states end up on same local hill in local beam search algorithm
• Idea: choose k successors randomly, biased towards good ones
 Stochastic Beam Search
• Instead of choosing the best k from the pool of candidate successors, stochastic beam search
chooses k successors at random, with the probability of choosing a given successor being an
increasing function of its value.
• Stochastic beam search bears some resemblance to the process of natural selection, whereby th
“successors” (offspring) of a “state” (organism) populate the next generation according to its “v
(fitness).
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Genetic Algorithms
• A genetic algorithm (GA) is a variant of stochastic beam search in which successor states are
generated by combining two parent states rather than by modifying a single state.
• Like beam searches, GAs begin with a set of k randomly generated states, called the populatio
• Each state, or individual, is represented as a string over a finite alphabet—most commonly, a st
of 0s and 1s.
• An 8-queens state must specify the positions of 8 queens, each in a column of 8 squares, and so it req
8× log2 8=24 bits.
• Alternatively, the state could be represented as 8 digits, each in the range from 1 to 8.
• Each state is rated by an objective function, or (in GA terminology) the fitness function.
• Pairs of individuals are randomly selected for reproduction.
• From each pair new offsprings (children) are generated using crossover operation.
• A crossover point is chosen randomly from the positions in the string.
• The offsprings are created by crossing over the parent strings at the crossover point.
• Each child is subject to random mutation with a small independent probability.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Genetic Algorithms
• A state can be represented using a 8 digit string.
• Each digit in the range from 1 to 8 to indicate the position of the queen in that column.

16257483
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Genetic Algorithms
• The initial population has 4 states.
• A fitness function should return higher values for better states, so, for the 8-queens problem we
the number of non-attacking pairs of queens, which has a value of 28 for a solution.
• The values of the four states are 24, 23, 20, and 11.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Genetic Algorithms
• The probability of being chosen for reproducing is directly proportional to the fitness score.
• Two pairs are selected at random for reproduction, in accordance with the probabilities.
• Notice that one individual is selected twice and one not at all.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Genetic Algorithms
• The crossover points are after third digit in first pair and after fifth digit in second pair.
• The first child of the first pair gets the first three digits from the first parent and the remaining d
from the second parent, whereas the second child gets the first three digits from the second pare
and the rest from the first parent.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Genetic Algorithms
• Crossover helps iff substrings are meaningful components.
• The shaded columns are lost in the crossover step and the unshaded columns are retained.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Genetic Algorithms
• One digit was mutated in the first, third, and fourth offspring.
• In the 8-queens problem, this corresponds to choosing a queen at random and moving it to a ran
square in its column.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Genetic Algorithms
A genetic algorithm: each mating of two parents produces only one offspring, not tw
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Fundamentals of
Artificial Intelligence
Adversarial Search
Game Playing
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Games
• In multiagent environments, each agent needs to consider the actions of other agents and how
affect its own welfare.
• The agents can be cooperative or competitive.
• In competitive environments, the agents’ goals are in conflict, giving rise to Adversarial Sear
problems — often known as GAMES.
• In mathematical game theory, a multiagent environment is treated as a game, the impact of eac
agent (economy) on the others is significant, regardless of whether the agents are cooperative o
competitive.
• In AI, the most common games are deterministic, turn-taking, two-player, zero-sum games of
perfect information (such as chess).
• In deterministic and fully observable environments in two agents act alternately and in which the util
values at the end of the game are always equal and opposite.
• If one player wins a game of chess, the other player necessarily loses.
• It is this opposition between the agents’ utility functions that makes the situation adversarial.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Games
• Games are too hard to solve.
• Chess has an average branching factor of about 35, and games often go to 50 moves by each player, s
search tree has about 35100 nodes.
• Games require the ability to make decision even when calculating optimal decision is infeasib
• Pruning allows us to ignore portions of the search tree.
• Heuristic evaluation functions allow us to approximate true utility of a state without doing a
complete search.
• Games such as backgammon includes elements of imperfect information because not all cards
visible to each player.
• Types of games
deterministic
chance
perfect
information
chess, checkers,
go, othello
backgammon
monopoly
imperfect
information
battleships,
bridge, poker,
scrabble
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Games as Search Problem
• S0: The initial state, which specifies how the game is set up at the start.
• PLAYER(s): Defines which player has the move in a state.
• ACTIONS(s): Returns the set of legal moves in a state.
• RESULT(s, a): The transition model, which defines the result of a move.
• TERMINAL-TEST(s): A terminal test, which is true when the game is over and false otherwis
States where the game has ended are called terminal states.
• UTILITY(s, p): A utility function (also called objective function or payoff function), defines
final numeric value for a game that ends in terminal state s for a player p.
• In chess, the outcome is a win, loss, or draw, with values +1, 0, or 1/2 .
• A zero-sum game is (constant-sum is a better term) defined as one where the total payoff to all playe
the same for every instance of the game.
• Chess is zero-sum because every game has payoff of either 0+1, 1+0 or 1/2+1/2.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Games as Search Problem
• The initial state, ACTIONS function, and RESULT function define the game tree for the game—
tree where the nodes are game states and the edges are moves.
• For tic-tac-toe the game tree is relatively small—fewer than 9! = 362, 880 terminal nodes.
• But for chess there are over 1040 nodes, so the game tree is best thought of as a theoretical construct t
cannot realize in the physical world.
• We have two players: MAX and MIN.
• MAX (our player) moves first in the game.
• Regardless of size of game tree, MAX’s (our player’s) job to search for a good move in search
• A search algorithm does not explore the full game tree, and examines enough nodes to allow a player
determine what move to make.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Game Tree
• A game tree for the game of tic-tac
• The top node is the initial state, an
MAX moves first, placing an X in
empty square.
• Game tree gives alternating moves
MIN (O) and MAX (X), until
eventually reaching terminal states
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Optimal Decisions in Games
• Optimal Solution in a search problem is a sequence of actions leading to a goal state (a termin
state that is a win).
• MAX must find a contingent strategy, which specifies MAX’s move in the initial state, then M
moves in the states resulting from every possible response by MIN.
• Given a game tree, optimal strategy can be determined from minimax value of each node n, a
is called as MINIMAX(n).
• The minimax value of a node is the utility (for MAX) of being in the corresponding state,
assuming that both players play optimally from there to the end of the game.
• The minimax value of a terminal state is just its utility.
• MAX prefers to move to a state of maximum value, whereas MIN prefers a state of minimum v
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
MINIMAX
• ∆ nodes are “MAX nodes,” in which it is MAX’s turn to move, and ∇ nodes are “MIN nodes.”
• Terminal nodes show the utility values for MAX; other nodes are labeled with their minimax va
• MAX’s best move at the root is a1, because it leads to the state with the highest minimax value,
MIN’s best reply is b1, because it leads to the state with the lowest minimax value.
Maximum of
its (MIN) children
Minimum of
its (MAX) children
utility values
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Minimax Algorithm
• Minimax Algorithm retur
action corresponding to th
possible move, that is, the
that leads to the outcome w
best utility, under the assu
that the opponent pla
minimize utility.
• The functions MAX-VALU
MIN-VALUE go through the
game tree, all the way
leaves, to determine the bac
value of a state.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Properties of Minimax Algorithm
• The minimax algorithm performs a complete depth-first exploration of the game tree.
Complete:
YES, if tree is finite
Optimal:
YES, against an optimal opponent.
Time complexity: O(bm)
Space complexity: O(bm) (depth-first exploration) Algorithm generates all actions at once
• For real games, the time cost is totally impractical, but minimax algorithm serves as the basis fo
mathematical analysis of games and for more practical algorithms.
• For chess, b≈35, m≈100 for reasonable games  exact solution completely infeasible
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Alpha–Beta Pruning
• The problem with minimax search is that the number of game states it has to examine is expone
in the depth of the tree.
• Unfortunately, we can’t eliminate the exponent, but we can effectively cut it in half.
• It is possible to compute correct minimax decision without looking at every node in game tree
• Alpha–Beta pruning prunes away branches of the minimax tree that cannot possibly influence
final decision and it returns the same move as minimax algorithm would.
• α = the value of the best (i.e., highest-value) choice we have found so far at any choice point
the path for MAX.
• β = the value of the best (i.e., lowest-value) choice we have found so far at any choice point a
the path for MIN.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Alpha–Beta Pruning Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Alpha–Beta Pruning Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Alpha–Beta Pruning Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Alpha–Beta Pruning Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Alpha–Beta Pruning Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Alpha–Beta Pruning Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
The general case for alpha–beta pruning
• If m is better than n for Player, we will never get to n in play.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Alpha–Beta Search Algorithm
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Alpha–Beta Search Algorithm
3
-∞,+∞
/
3
/
-∞,+∞
-∞,+∞
-∞,3
3
3,+∞
/ 3
+∞
12
-∞,3
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
+∞
/ 2
3,+∞
3,+∞
8
-∞
/ 3
2
5
14
/
3,+∞
/
+∞
/
3,14
3
14
Want to earn
R13,625 per year?
5
Stuvia.com - The study-notes marketplace
Properties of Alpha–Beta Search Algorithm
• Pruning does not affect final result
• Good move ordering improves effectiveness of pruning
• With perfect ordering, time complexity = O(bm/2)  doubles solvable depth
• Unfortunately, 3550 is still impossible! (for chess)
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Imperfect Real-Time Decisions
• In order to make a move in a reasonable amount of time, programs should cut off the search
and apply a heuristic evaluation function to states in the search, effectively turning nontermin
nodes into terminal leaves.
• Replace the utility function by a heuristic evaluation function EVAL, which estimates the
position’s utility, and
• Replace the terminal test by a cutoff test that decides when to apply EVAL.
• Depth-limit can be used in cutoff test.
• Heuristic minimax for state s and maximum depth d:
Example: Suppose we have 100 seconds, explore 104 nodes/second for chess
106 nodes per move ≈ 358/2
 Alpha–Beta Search Algorithm reaches depth 8  pretty good chess program
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Evaluation Functions
• An evaluation function returns an estimate of the expected utility of the game from a given
position.
• The performance of a program depends strongly on the quality of its evaluation function.
• An inaccurate evaluation function guides an agent toward losing positions.
How exactly do we design good evaluation functions?
1.
Evaluation function should order the terminal states same as the true utility function: win stat
must be better than draw states, draw states must be better than loss states.
2.
The computation must not take too long! (The whole point is to search faster.)
3.
For nonterminal states, evaluation function should be correlated with actual chances of winni
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Evaluation Functions
• Most evaluation functions work by calculating features of the state.
• Evaluation function can be a weighted linear function of features expressed as
where wi is weight and fi is featur
• For chess, fi could be numbers of each kind of piece on the board, and wi could be values of pieces (1
pawn, 3 for bishop, 3 for knight, 5 for rook, 9 for queen). This may NOT be a good evaluation functi
white to move
Black has advantage
white to move
White has advantage
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Stochastic (Nondeterministic) Games
• Many games mirror unpredictability by including a random element, such as the throwing of d
 They are called as Stochastic (Nondeterministic) Games
• Backgammon is a typical game that combines luck and skill.
White has rolled a 6–5 and has four possible moves.
(5–10,5–11), (5–11,19–24), (5–10,10–16), and (5–11,11–16)
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Stochastic (Nondeterministic) Games
• In backgammon, although White knows what his own legal moves are, but White does not know
what Black is going to roll and thus does not know what Black’s legal moves will be.
• That means White cannot construct a standard game tree of the sort we saw in chess and tic-tac
• A game tree in backgammon must include chance nodes in addition to MAX and MIN nodes.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Game Tree for a Backgammon Position
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
How to Make Correct Decisions?
• We still want to pick the move that leads to the best position.
• However, positions do not have definite minimax values.
• Instead, we can only calculate the expected value of a position: the average over all possible
outcomes of the chance nodes.
• We can generalize the minimax value for deterministic games to an expecti-minimax value for
games with chance nodes.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Evaluation functions for games of chance
• Evaluation functions for backgammon should be just like evaluation functions for chess.
• Behavior is preserved only by positive linear transformation of EVAL
• Hence EVAL should be proportional to the expected payoff.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Games of Imperfect Information
• Card games, where opponent's initial cards are unknown
• Typically we can calculate a probability for each possible deal
• Seems just like having one big dice roll at the beginning of the game.
• Idea: compute the minimax value of each action in each deal, then choose the action with highe
expected value over all deals
• Special case: if an action is optimal for all deals, it's optimal.
GIB, current best bridge program, approximates this idea by
1) generating 100 deals consistent with bidding information
2) picking the action that wins most tricks on average
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
State-of-the-Art Game Programs
Chess:
• IBM’s DEEP BLUE chess program defeated world champion Garry Kasparov
• Deep Blue ran on a parallel computer with 30 IBM RS/6000 processors
• used alpha–beta search
• searched up to 30 billion positions per move, reaching depth 14
• evaluation function had over 8000 features
• used a large endgame database of solved positions containing all positions with five pieces
many with six pieces
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
State-of-the-Art Game Programs
Checkers:
• CHINOOK, which runs on regular PCs and uses alpha–beta search.
• Chinook defeated the long-running human champion in a match in 1990.
• Used database of all 444 billion endgame positions with 8 pieces
Othello:
• In 1997, the LOGISTELLO program defeated the human world champion.
• Humans are no match for computers at Othello
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Summary
• A game can be defined by
• the initial state (how the board is set up),
• the legal actions in each state,
• the result of each action,
• a terminal test (which says when the game is over), and
• a utility function that applies to terminal states.
• In two-player zero-sum games with perfect information, the minimax algorithm can select op
moves by a depth-first enumeration of the game tree.
• The alpha–beta search algorithm computes the same optimal move as minimax, but achieves
much greater efficiency by eliminating subtrees that are provably irrelevant.
• Usually, it is not feasible to consider the whole game tree so we need to cut the search off at som
point and apply a heuristic evaluation function that estimates the utility of a state.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Summary
• Many game programs precompute tables of best moves in the opening and endgame so that th
can look up a move rather than search.
• Games of chance can be handled by an extension to the minimax algorithm that evaluates a cha
node by taking the average utility of all its children, weighted by the probability of each child.
• Optimal play in games of imperfect information, such as bridge, requires reasoning about the
current and future belief states of each player. A simple approximation can be obtained by
averaging the value of an action over each possible configuration of missing information.
• Programs have bested even champion human players at games such as chess, checkers, and Oth
Humans retain the edge in several games of imperfect information, such as poker, bridge
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Fundamentals of
Artificial Intelligence
Constraint Satisfaction Problems
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Constraint Satisfaction Problems
• A constraint satisfaction problem consists of three components, X, D, and C:
X is a set of variables, {X1, . . . ,Xn}.
D is a set of domains, {D1, . . . ,Dn}, one for each variable.
C is a set of constraints that specify allowable combinations of values.
• Each domain Di consists of a set of allowable values, {v1, . . . , vk} for variable Xi.
• Each constraint Ci consists of a pair {scope, rel }, where scope is a tuple of variables that partic
in the constraint and rel is a relation that defines the values that those variables can take on.
• A relation can be represented as an explicit list of all tuples of values that satisfy the constraint, or as
abstract relation that supports two operations.
• If X1 and X2 both have the domain {A,B}, then the constraint saying the two variables must have dif
values can be written as <(X1,X2), [(A,B), (B,A)]> or as <(X1,X2),X1≠X2>
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Constraint Satisfaction Problems
• In standard search problem:
• a state is a black box with no internal structure.
• it that supports goal test, eval, successor.
• In CSP:
• A state is defined by variables Xi with values from domain Di
• A goal test is a set of constraints specifying allowable combinations of values for subsets
variables
• CSP allows useful general-purpose algorithms with more power than standard search algorithm
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Constraint Satisfaction Problems
• Each state in a CSP is defined by an assignment of values to some or all of the variables,
{Xi=vi,Xj= vj , . . .}.
• An assignment that does not violate any constraints is called a consistent (or legal) assignmen
• A complete assignment is an assignment in which every variable is assigned.
• A solution to a CSP is a consistent, complete assignment.
• A partial assignment is one that assigns values to only some of the variables.
• In order to solve a CSP, a consistent complete assignment must be found (be searched).
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Example: Map-Coloring
• We are given the task of coloring each region of Australia either red, green, or blue in such a wa
no neighboring regions have the same color.
• To formulation as a CSP,
Variables: Each region is a variable:
X = {WA,NT,Q,NSW, V,SA, T} .
Domains: The domain of each variable is the set Di = {red , green, blue}.
Constraints require neighboring regions to have distinct colors.
• Since there are nine places where regions border, there are nine constraints:
C = {SA ≠ WA, SA ≠ NT, SA ≠ Q, SA ≠ NSW, SA ≠ V,
WA ≠ NT, NT ≠ Q,Q ≠ NSW, NSW ≠ V } .
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Example: Map-Coloring
Variables WA, NT, Q, NSW, V , SA, T
Domains Di = {red, green, blue}
Constraints:
• adjacent regions must have different colors
• e.g., WA≠NT (if the language allows this), or
(WA,NT) ∊ {(red,green), (red,blue),(green,red),…}
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Example: Map-Coloring
• Solutions are assignments satisfying all constraints,
e.g., {WA=red, NT=green, Q=red, NSW=green, V=red, SA=blue, T=green}
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Constraint Graph
• It can be helpful to visualize a CSP as a constraint graph.
• The nodes of the constraint graph correspond to variables of the problem,
• A link of the constraint graph connects two variables in a constraint. (Binary CSP)
• General-purpose CSP algorithms use the graph structure to speed up search.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Why formulate a problem as a CSP?
• CSPs yield a natural representation for a wide variety of problems.
• If we already have a CSP-solving system, it is often easier to solve a problem using it than to d
a custom solution using another search technique.
• CSP solvers can be faster than state-space searchers because the CSP solver can quickly elimina
large portions of the search space.
• For example, once we have chosen {SA=blue} in the Australia problem, we can conclude that none o
five neighboring variables can take on the value blue.
• Without taking advantage of constraint propagation, a search procedure would have to consider 35 =2
assignments for the five neighboring variables;
• With constraint propagation we never have to consider blue as a value, so we have only 25 =32 assign
to look at, a reduction of 87%.
• With CSPs, once we find out that a partial assignment is not a solution, we can immediately dis
further refinements of the partial assignment.
• Many problems that are intractable for regular state-space search can be solved quickly when
formulated as a CSP.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Variations on the CSP formalism
types of variables
• The simplest kind of CSP involves variables that have discrete, finite domains.
• Map-coloring problems, scheduling with time limits and 8-queens problem are finite-domain CSP.
• A discrete domain can be infinite: the set of integers or the set of strings
• With infinite domains, constraints cannot be enumerated by all allowed combinations of value
• With infinite domains, a constraint language must be used to describe constraints such as T1+d
directly, without enumerating the set of pairs of allowable values for (T1, T2).
• Linear constraints on integer variables are solvable.
• No algorithm exists for solving general nonlinear constraints on integer variables.
• Continuous-domain CSPs with linear constraints are solvable in polynomial time by linear
programming methods.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Variations on the CSP formalism
types of constraints
• Unary Constraint restricts the value of a single variable.
• Ex: <(SA),SA=green>
• Binary Constraint relates two variables.
• For example, SA≠NSW is a binary constraint.
• A binary CSP can be represented as a constraint graph.
• Higher-order constraints (global constraints) involve 3 or more variables.
• A CSP can be transformed into a CSP with only binary constraints
• Violation of absolute constraints rules out a potential solution.
• Many real-world CSPs include preference constraints indicating which solutions are preferred.
• For example, in a university class-scheduling problem there are absolute constraints that no professor can
two classes at the same time.
• But we also may allow preference constraints: Prof. X might prefer teaching in the morning, whereas Prof
prefers teaching in the afternoon.
• CSPs with preferences can be solved with optimization search methods, and they are called as constraint
optimization problems.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Example: Cryptarithmetic
• In a Cryptarithmetic puzzle, each letter stands for a distinct digit; the aim is to find a substitut
digits for letters such that the resulting sum is arithmetically correct.
• The global constraint Alldiff (F, T,U,W,R,O) represents distinction of each letter.
• The constraints on the four columns of the puzzle can be written as n-ary constraints.
where C10, C100, and C1000 are auxiliary variables representing the digit carried over into the tens,
hundreds, or thousands column.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Example: Cryptarithmetic
• Constraints can be represented in a constraint hypergraph,
• A hypergraph consists of ordinary nodes and hypernodes which represent n-ary constraints.
Alldiff (F, T,U,W,R,O)
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Real-world CSPs
• Assignment problems
• e.g., who teaches what class
• Timetabling problems
• e.g., which class is offered when and where?
• Hardware configuration
• Transportation scheduling
• Factory scheduling
• Many real-world problems involve real-valued variables
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Search Formulation for CSPs
States are defined by the values assigned so far (partial assignments).
Initial State: the empty assignment, {}
Successor Function: assign a value to an unassigned variable that does not conflict with current
assignment.
• If there is no legal assignments, cause failure
Goal Test: the current assignment is complete and satisfies all constraints.
• ie. a goal state is a complete and consistent assignment
Naïve Formulation:
• This search formulation is the same for all CSPs!
• Every solution appears at depth n with n variables  use depth-first search
• There are dn complete assignments for a CSP with n variables of domain size d,.
• Branching factor: nd at the first level and (n-d)h at depth h, hence n!dn leaves!
• It is not so practical.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Commutativity
• A problem is commutative if the order of application of any given set of actions has no effect o
outcome.
• CSPs are commutative because when assigning values to variables, we reach the same partial
assignment regardless of order.
• We need only consider a single variable at each node in the search tree.
• For example, at the root node of a search tree for coloring the map of Australia, we might make a cho
between SA=red, SA=green, and SA=blue, but we would never choose between SA=red and WA=bl
• With this restriction (commutative property of CSPs), the number of leaves is dn.
• All CSP search algorithms consider a single variable assignment at a time, thus there are dn le
• The backtracking search for CSPs is a depth-first search that chooses values for one variabl
time and backtracks when a variable has no legal values left to assign.
• Backtracking search is the basic uninformed algorithm for CSPs.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Backtracking Search
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Backtracking Search: Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Improving Backtracking Efficiency
• General-purpose methods can give huge gains in speed:
1. Which variable should be assigned next?
2. In what order should its values be tried?
3. Can we detect inevitable failure early?
4. Can we take advantage of problem structure?
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Minimum Remaining Values
a heuristic for variable selection
• The simplest strategy for variable selection is to choose the next unassigned variable in order,
{X1,X2, . . .}.
• This static variable ordering may NOT produce an efficient search.
Minimum Remaining Values (MRV) Heuristic:
Choose the variable with the fewest legal values.
all of them selectable here
Select NT or SA here
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Degree Heuristic
a heuristic for variable selection
• A tie-breaker among MRV variables
Degree Heuristic:
• choose the variable with the most constraints on remaining variables
• The minimum-remaining values heuristic is usually a more powerful guide, but the degree heur
can be useful as a tie-breaker.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Least-Constraining-Value
a heuristic for value selection
• Once a variable has been selected, the algorithm must decide on the order in which to examine
values.
• Given a variable, least constraining value heuristic prefers the value that rules out the fewest
choices for the neighboring variables in the constraint graph.
LCV heuristic prefers this one
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Variable and Value Ordering
• Minimum Remaining Values (MRV) heuristic picks a variable that is most likely to cause a fa
soon, thereby pruning the search tree.
• MRV also has been called the most constrained variable or fail-first heuristic.
• If some variable X has no legal values left, the MRV heuristic will select X and failure will be detect
immediately—avoiding pointless searches through other variables.
• Least-Constraining-Value heuristic picks a value that is most likely to cause a failure last.
• We only need one solution; therefore it makes sense to look for the most likely values first.
• If we wanted to enumerate all solutions rather than just find one, then value ordering would be irrelev
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Interleaving Search and Inference
• Some inference algorithms can infer reductions in the domain of variables before we begin th
search
• Inference algorithms can infer new domain reductions on the neighboring variables every time
make a choice of a value for a variable.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Inference: Forward Checking
• Whenever a variable X is assigned, the forward-checking process establishes arc consistency
• For each unassigned variable Y that is connected to X by a constraint, delete from Y ’s domain any v
that is inconsistent with the value chosen for X.
• Because forward checking only does arc consistency inferences, there is no reason to do forward che
if we have already done arc consistency as a preprocessing step.
• For many problems the search will be more effective if we combine the MRV heuristic with for
checking.
• Forward Checking Idea: Keep track of remaining legal values for unassigned variables and
terminate search when any variable has no legal values.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Forward Checking
Initial doma
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Forward Checking
Initial domain
After WA=re
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Forward Checking
Initial domain
After WA=re
After Q=gree
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Forward Checking
Initial domains
After WA=red
After Q=green
After V=blue
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Constraint Propagation
• Forward checking propagates information from assigned to unassigned variables, but doesn't
provide early detection for all failures:
• NT and SA cannot both be blue!
• Constraint propagation repeatedly enforces constraints locally
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Arc Consistency
• Simplest form of constraint propagation makes each arc consistent.
• A variable in a CSP is arc-consistent if every value in its domain satisfies the variable’s binary
constraints.
• Xi is arc-consistent with respect to another variable Xj if for every value in the current domain
there is some value in the domain Dj that satisfies the binary constraint on the arc(Xi,Xj).
• X → Y is consistent iff
for every value x of X there is some allowed y for Y
• A network is arc-consistent if every variable is arc consistent with every other variable.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Arc Consistency
X → Y is consistent iff
for every value x of X there is some allowed y for Y
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Arc Consistency
X → Y is consistent iff
for every value x of X there is some allowed y for Y
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Arc Consistency
X → Y is consistent iff
for every value x of X there is some allowed y for Y
If X loses a value, neighbors of X need to be rechecked
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Arc Consistency
X → Y is consistent iff
for every value x of X there is some allowed y for Y
If X loses a value, neighbors of X need to be rechecked
Arc consistency detects failure earlier than forward checking
Can be run as a preprocessor or after each assignment
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Arc Consistency Algorithm
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Problem Structure
• The structure of the problem can be used to find solutions
quickly.
• Coloring Tasmania and coloring the mainland are
independent subproblems
• Independence can be ascertained simply by finding
connected components of the constraint graph.
• Each component corresponds to a subproblem CSPi.
• If assignment Si is a solution of CSPi, then
of 𝑖 CSPi .
𝑖 Si
is a solution
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Problem Structure
• Why independent subproblems are important?
• Suppose each CSPi has c variables from the total of n variables, where c is a constant.
• Then there are n/c subproblems, each of which takes at most dc work to solve, where d is the siz
the domain.
• Hence, the total work is O(dc n/c), which is linear in n.
• Without the decomposition, the total work is O(dn), which is exponential in n.
E.g., n=80, d=2, c=20
• 280 = 4 billion years at 10 million nodes/sec
• 4 * 220 = 0.4 seconds at 10 million nodes/sec
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Tree-structured CSPs
• A constraint graph is a tree when any two variables are connected by only one path (no loops)
• Theorem: If the constraint graph has no loops, the CSP can be solved in O(n d2) time (linear in
• Compare to general CSPs, where worst-case time is O(dn)
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Algorithm for tree-structured CSPs
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Nearly tree-structured CSPs
• We have an efficient algorithm for trees, we can consider whether more general constraint graph
be reduced to trees somehow.
• Delete South Australia, the graph would become a tree.
•
•
•
•
Instantiate SA to a value, and
From domains of other variables, delete any values that are inconsistent with the value chosen for SA
Any solution for CSP after SA and its constraints are removed will be consistent with value chosen fo
The value chosen for SA could be the wrong one, so we would need to try each possible value.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Nearly tree-structured CSPs
General Algorithm:
1.
Choose a subset S of the CSP’s variables such that the constraint graph becomes a tree after
removal of S. S is called a cycle cutset.
2.
For each possible assignment to the variables in S that satisfies all constraints on S,
(a) remove from the domains of the remaining variables any values that are inconsistent with
assignment for S, and
(b) If the remaining CSP has a solution, return it together with the assignment for S.
Cutset size c  runtime O(dc (.n - c) d2), very fast for small c
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Local Search For CSPs
• Local search algorithms can be effective in solving many CSPs.
• complete-state formulation is used: the initial state assigns a value to every variable, and the s
changes the value of one variable at a time.
• In choosing a new value for a variable, the most obvious heuristic is to select the valuethat resu
the minimum number of conflicts with other variables—the min-conflicts heuristic.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Min-conflicts
• Min-conflicts is surprisingly effective for many CSPs.
• On the n-queens problem, the run time of min-conflicts is roughly independent of problem size
• It solves even the million-queens problem in an average of 50 steps
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Min-conflicts on 8-queens problem
• A two-step solution using min-conflicts for an 8-queens problem. At each stage, a queen is chos
reassignment in its column.
• The number of conflicts (number of attacking queens) is shown in each square.
• The algorithm moves the queen to the min-conflicts square, breaking ties randomly.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Summary
• CSPs are a special kind of problem:
• states defined by values of a fixed set of variables
• goal test defined by constraints on variable values
• Backtracking = depth-first search with one variable assigned per node
• Variable ordering and value selection heuristics help significantly
• Forward checking prevents assignments that guarantee later failure
• Constraint propagation (e.g., arc consistency) does additional work to constrain values and dete
inconsistencies
• The CSP representation allows analysis of problem structure
• Tree-structured CSPs can be solved in linear time
• Iterative min-conflicts is usually effective in practice
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Fundamentals of
Artificial Intelligence
Logical Agents and
Propositional Logic
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Knowledge Based Agents
• The intelligence of humans is achieved not by purely reflex mechanisms but by processes of
reasoning that operate on internal representations of knowledge.
• In AI, this approach to intelligence is embodied in knowledge-based agents.
• Logical agents (knowledge-based agents) can
• form representations of a complex world,
• use a process of inference to derive new representations about the world, and
• use these new representations to deduce what to do.
• Knowledge-based agents is supported by logic such as propositional logic or first-order pred
logic.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Knowledge Base
• A knowledge base (KB) is a set of sentences in a formal language.
• Inference: Deriving new sentences from old sentences in KB.
• Each time a knowledge-based agent does three things.
1.
TELLs the knowledge base what it perceives. TELL operations add new sentences (agen
perceptions) to the knowledge base.
2.
ASKs the knowledge base what action it should perform.
• Extensive reasoning (inference) may be done about the current state of the world, abou
outcomes of possible action sequences.
3.
The agent TELLs the knowledge base which action was chosen, and the agent executes t
action.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
A Simple Knowledge-Based Agent
•
MAKE-PERCEPT-SENTENCE constructs a sentence asserting that the agent perceived the given per
at the given time.
•
MAKE-ACTION-QUERY constructs a sentence that asks what action should be done at the current ti
•
MAKE-ACTION-SENTENCE constructs a sentence asserting that the chosen action was executed.
•
The details of the inference mechanisms are hidden inside TELL and ASK.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Wumpus World
• The wumpus world is a simple comput
game, but it illustrates some important
about intelligence.
• Wumpus eats anyone who enters its roo
• The wumpus can be shot by an agent
(wumpus dies if it is shot), but the agen
only one arrow.
• The agent can safely enter a death
wumpus’s room.
• Some rooms contain bottomless pits tha
trap anyone who wanders into these roo
• A room contains gold.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Wumpus World Description
Performance measure: gold +1000, death -1000, -1 per step, -10 for using the arrow
Environment: A 4×4 grid of rooms. The agent always starts in the square [1,1], facing to the righ
locations of the gold and the wumpus are chosen randomly, with a uniform distribution, from the
squares other than the start square. Each square other than the start can be a pit, with probability 0
•
•
•
•
•
•
•
Squares adjacent to wumpus are smelly
Squares adjacent to pit are breezy
Glitter iff gold is in the same square
Shooting kills wumpus if you are facing it
Shooting uses up the only arrow
Grabbing picks up gold if in same square
Releasing drops the gold in same square
Actuators: Left turn, Right turn, Forward, Grab, Release, Shoot
Sensors: Breeze, Glitter, Smell, (Bump, Scream)
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Exploring A Wumpus World
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Exploring A Wumpus World
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Exploring A Wumpus World
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Exploring A Wumpus World
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Exploring A Wumpus World
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Exploring A Wumpus World
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Exploring A Wumpus World
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Exploring A Wumpus World
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Some Tight Spots in Wumpus World
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Logic
LOGICS are formal languages for representing information such that conclusions can be drawn.
SYNTAX: The Syntax of a logic defines the sentences (well-formed formulas) in that logic.
SEMANTICS: The Semantics of a logic defines the meaning of sentences.
• The semantics defines the truth of each sentence with respect to each possible world.
• The term model is also used in place of possible world.
SATISFACTION:
• If a sentence α is TRUE in model m, we say that m SATISFIES α (or sometimes we sim
say that m is a model of α).
• The notation M(α) to mean the set of all models of α
(i.e. M(α) is the set of all models that satisfy α) .
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Logical Entailment
(other names: Logical Consequence or Logical Implication)
• Logical Entailment between sentences means that a sentence follows logically from another
sentence. In mathematical notation, 𝜶 ⊨ 𝜷
The formal definition of entailment :
𝜶 logically entails 𝜷 𝜶 ⊨ 𝜷
if and only if,
𝜷 is true in all worlds where 𝜶 is true
• 𝜶 ⊨ 𝜷 if and only if M(𝜶) ⊆ M(𝜷) .
• if 𝜶 ⊨ 𝜷 , then 𝜶 is a stronger assertion than 𝜷 : it rules out more possible worlds.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Logical Entailment: Models
• Logicians typically think in terms of models, which are formally structured worlds with respect
which truth can be evaluated
• We say m is a model of a sentence α if α is true in m
• M(α) is the set of all models of α (all models satisfy α)
• Then KB ⊨ α if and only if M(KB) ⊆ M(α)
M(α)
• E.g. KB = Giants won and Reds won
α = Giants won
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Entailment in Wumpus World
Situation after detecting nothing in [1,1],
moving right, breeze in [2,1]
Consider possible models for ?s
assuming only pits
3 Boolean choices  8 possible models
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Entailment in Wumpus World: Wumpus Models
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Wumpus Models: is [1,2] safe?
KB = wumpus-world rules + observations
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Wumpus Models: is [1,2] safe?
KB = wumpus-world rules + observations
α 1 = “[1,2] is safe”, KB ⊨ α 1,
proved by model checking
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Wumpus Models: is [2,2] safe?
KB = wumpus-world rules + observations
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Wumpus Models: is [2,2] safe?
KB = wumpus-world rules + observations
α 2 = “[2,2] is NOT safe”, KB ⊭ α 2,
proved by model checking
•
the agent cannot conclude that there is
no pit in [2,2]. (Nor can it conclude that
there is a pit in [2,2].
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Model Checking
• In Wumpus world, the entailment is applied to derive conclusions from KB; i.e. a logical infere
is carried out by checking the models.
• The algorithm used in this process is called as model checking.
• Model Checking is an inference algorithm that enumerates all possible models (of KB) to chec
α is true in all models in which KB is true, that is, that M(KB) ⊆ M(α). Thus KB ⊨ α
• Model checking algorithm can be expensive (or impractical) because KB can have too many m
(or it can have infinite models in some logics).
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Inference (Proofs)
• If an inference algorithm i can derive α from KB (generally by syntactic operations), we write
KB ⊢i α
which is pronounced “α is derived from KB by inference procedure i”.
(or α is proved/deducted from KB)
• In a derivation, we start from premises (sentences (in KB) assumed to be true) and axioms
(sentences that are true in every world).
• Then, we apply an inference rule to sentences that are already derived (proved) to derive a new
sentence at each step of the derivation.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Inference: Soundness and Completeness
Soundness:
An inference algorithm i is sound (or truth-preserving) if
whenever KB ⊢i α, it is also true that KB ⊨ α
• If an inference algorithm is sound, all derivable sentences from KB are also logical consequen
of KB.
Completeness:
An inference algorithm i is complete if
whenever KB ⊨ α, it is also true that KB ⊢i α
• If an inference algorithm is complete, all entailed sentences from KB are also derivable from
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Propositional Logic
• Propositional Logic is a simple but powerful logic.
• The syntax of propositional logic defines the allowable sentences.
• The semantics of propositional logic defines the rules for determining the truth of a sentence
respect to a particular model.
• Propositional Logic contains proposition symbols and logical connectives (logical operators).
• The meaning of a propositional symbol can be true or false.
• The meaning of a logical connective is given by its truth table.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Propositional Logic: Syntax
NEGATION
CONJUNCTION
DISJUNCTION
IMPLICATION
BICONDITIONAL
• The atomic sentences consist of a single proposition symbol.
• Each proposition symbol stands for a proposition that can be true or false.
• There are two proposition symbols with fixed meanings (constants): True is the always-true
proposition and False is the always-false proposition.
• Complex sentences are constructed from other sentences, using parentheses and logical connectives.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Propositional Logic: Syntax
• A literal is either an atomic sentence (a positive literal) or a negated atomic sentence (a negat
literal).
• A sentence whose main connective is ∧, such as P ∧ Q, is called a conjunction; its parts are the
conjuncts.
• A sentence whose main connective is ∨, such as P ∨ Q, is called a disjunction; its parts are the
disjuncts.
• A sentence such as P ⇒ Q is called an implication (or conditional). Its premise or antecedent i
and its conclusion or consequent is Q.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Propositional Logic: Semantics
• The semantics defines the rules for determining the truth of a sentence with respect to a partic
model.
• In propositional logic, a model simply fixes the truth value—true or false—for every propositi
symbol.
P
Q
R
Ex. Model:
true
true
true
• If the sentences in the knowledge base make use of the
true
true
false
true
false
true
true
false
false
false
true
true
false
true
false
false
false
true
false
false
false
proposition symbols P, Q, and R, then one possible model is
m1 = {P=false, Q=false, R=true} .
• With three proposition symbols, there are
23=8
possible models
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Propositional Logic: Semantics
• The semantics for propositional logic must specify how to compute the truth value of any
sentence, for a given a model m.
• Since all sentences are constructed from atomic sentences and the five connectives; we need to
specify
• how to compute the truth of atomic sentences and
• how to compute the truth of sentences formed with each of the five connectives.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Propositional Logic: Semantics
Rules for evaluating truth with respect to a model m
Atomic Sentences:
• True is true in every model and False is false in every model.
• The truth value of every other proposition symbol must be specified directly in the model
Complex Sentences: five rules which hold for any sub-sentences P and Q in any model m
• ¬P is true iff P is false in m.
• P ∧ Q is true iff both P and Q are true in m.
• P ∨ Q is true iff either P or Q is true in m.
• P ⇒ Q is true unless P is true and Q is false in m.
• P ⇔ Q is true iff P and Q are both true or both false in m.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Propositional Logic: Semantics
Truth Tables
• The semantic rules can also be expressed with truth tables that specify the truth value of a com
sentence for each possible assignment of truth values to its components.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Propositional Logic
Wumpus world sentences
•
•
•
•
Px,y is true if there is a pit in [x, y].
Wx,y is true if there is a wumpus in [x, y], dead or alive.
Bx,y is true if the agent perceives a breeze in [x, y].
Sx,y is true if the agent perceives a stench in [x, y].
• There is no pit in [1,1]:
• A square is breezy if and only if there is a pit in a neighboring square.
• The breeze percepts for the first two squares visited in the specific world the agent is in.
• From these sentences, we can derive
(there is no pit in [1,2]).
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Propositional Logic
Inference by Enumeration of Models
• Our goal now is to decide whether KB ⊨ α for some sentence α.
• For example, is ¬P1,2 entailed by our KB?
• Inference by Enumeration of Models is a direct implementation of the definition of entailment
• Enumerate the models, and check that α is true in every model in which KB is true.
• Models are assignments of true or false to every proposition symbol.
• Inference by Enumeration of Models algorithm is sound and complete.
• If KB and α contain n symbols in all, then there are 2n models.
• Thus, the time complexity of the algorithm is O(2n).
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Propositional Logic
Inference by Enumeration of Models
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Propositional Logic
Inference by Enumeration of Models
•
•
•
Enumerate rows (different assignments to
symbols),
if KB is true in row, check that α is too
Since there are 7 propositional symbols, there are
128 rows.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
• In all 3 rows, P1,2 is false, so there is no p
• On the other hand, there might (or migh
pit in [2,2].
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Logical Equivalence
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Validity and Satisfiability
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Inference and Proofs
• A proof is a sequence of sentences that leads to the desired goal.
• A proof starts with given premises and each new sentence in the sequence is obtained as a resul
the application of an inference rule to previous sentences in the sequence.
Some Inference Rules:
Modus Ponens:
And-Elimination:
• All logical equivalences can be used as inference rules.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Inference and Proofs
• Inference rules are sound. i.e. when their premises are true their conclusions are also true.
Wumpus World Proof Example:
1.
2.
3.
(WumpusAhead ∧WumpusAlive) ⇒ Shoot
(WumpusAhead ∧ WumpusAlive)
Shoot
Premise
Premise
Modus Ponens 1 and 2
Another Example:
1.
2.
(WumpusAhead ∧ WumpusAlive)
WumpusAlive
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Premise
And-Elimination 1
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Inference and Proofs
Derivation (proof) of ¬P1,2 from given premises
1.
¬P1,1
Premise
2.
B1,1 ⇔ (P1,2 ∨ P2,1)
Premise
3.
B2,1 ⇔ (P1,1 ∨ P2,2 ∨ P3,1)
Premise
4.
¬B1,1
Premise
5.
B2,1
Premise
6.
(B1,1 ⇒ (P1,2 ∨ P2,1)) ∧ ((P1,2 ∨ P2,1) ⇒ B1,1)
Biconditional elimination to 2
7.
((P1,2 ∨ P2,1) ⇒ B1,1)
And-Elimination to 6
8.
(¬B1,1 ⇒ ¬(P1,2 ∨ P2,1))
Logical equivalence for contrapositives to 7
9.
¬(P1,2 ∨ P2,1)
Modus Ponens to 8 and 4
10. ¬P1,2 ∧ ¬P2,1
De Morgan’s rule to 9
11. ¬P1,2
And-Elimination to 10
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Searching for Proofs
• Searching for proofs is an alternative to enumerating models (exponential) and it is more efficie
• We can apply any of the search algorithms to find a sequence of steps that constitutes a proof. W
just need to define a proof problem as follows:
INITIAL STATE: The initial knowledge base.
ACTIONS: The set of actions consists of all the inference rules applied to all the sentences that m
the top half of the inference rule.
RESULT: The result of an action is to add the sentence in the bottom half of the inference rule.
GOAL: The goal is a state that contains the sentence we are trying to prove.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Proof by Resolution
• The inference rules that we look at are sound, but we have not discussed the question of
completeness for the inference algorithms that use them.
• Search algorithms such as iterative deepening search are complete in the sense that they will fi
any reachable goal.
• But if the available inference rules are inadequate, then the goal is not reachable—no proof exists th
only those inference rules.
• For example, if we removed the biconditional elimination rule, the Wumpus World proof would not g
through.
• So, our proof system will not be complete.
• A single inference rule, RESOLUTION, that yields a complete inference algorithm when cou
with any complete search algorithm.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Clause
• Resolution inference rule works on clauses.
• A clause is a disjunction of literals.
• A literal is either an atomic sentence (a positive literal) or a negated atomic sentence (a negative li
• Clause Example:
P ∨ R ∨ Q ∨ S
• A single literal can be viewed as a disjunction of one literal, also known as a unit clause.
• Resolution is sound and complete for propositional logic
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Resolution
Resolution Inference Rule
• where li and mj are complementary literals. The resolution takes two clauses and produces a ne
clause containing all the literals of the two original clauses except the two complementary litera
• Conclusion of the rule is called as resolvent.
P ∨ R ∨ Q ∨ S
T ∨ Q ∨ M
-----------------------------------------------P ∨ R ∨ S ∨ T ∨ M
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Conjunctive Normal Form
• The resolution rule applies only to clauses.
• knowledge bases and queries should consist of clauses.
• Every sentence of propositional logic is logically equivalent to a conjunction of clauses.
• A sentence expressed as a conjunction of clauses is said to be in conjunctive normal form (CN
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Converting to CNF
1.
Eliminate ⇔, replacing α ⇔ β with (α ⇒ β) ∧ (β ⇒ α)
2.
Eliminate ⇒, replacing α ⇒ β with α ∨ β
3.
CNF requires  to appear only in literals, so we “move  inwards” by repeated application o
following equivalences
4.
Now we have a sentence containing nested ∧ and ∨ operators applied to literals. We apply the
distributivity law, distributing ∨ over ∧ wherever possible.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Converting to CNF
• Example:
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
A Simple Resolution Algorithm
for Propositional Logic
• PL-RESOLVE returns the set of all possible clauses obtained by resolving its two inputs.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
PL-RESOLUTION Example
• Partial application of PL-RESOLUTION to a simple inference in the Wumpus world. ¬P1,2 is sh
to follow from the first four clauses in the top row.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Horn Clauses and Definite Clauses
• The definite clause, which is a disjunction of literals of which exactly one is positive.
• Horn clause is a disjunction of literals of which at most one is positive.
• So all definite clauses are Horn clauses,
• Clauses with no positive literals; these are called goal clauses.
• Knowledge bases containing only definite clauses are interesting for three reasons:
1. Every definite clause can be written as an implication whose premise is a conjunction of
positive literals and whose conclusion is a single positive literal.
• In Horn form, the premise is called the body and the conclusion is called the head.
• A sentence consisting of a single positive literal is called a fact.
2. Inference with Horn clauses can be done through the forward chaining and backward
chaining algorithms. This type of inference is the basis for logic programming.
3. Deciding entailment with Horn clauses can be done in time that is linear in the size of the
knowledge base
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Horn Clauses and Definite Clauses
Definite Clause Examples:
P ∨ R ∨ S
R∧S⇒P
P
P
Goal Clause Example:
R ∨ S
R ∧ S ⇒ False
or R ∧ S ⇒
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Forward-Chaining Algorithm
for Propositional Logic
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Forward-Chaining Algorithm Example
FC Algorithm: Fire any rule whose premises are satisfied in the KB, add its conclusion to the KB
until query is found.
A set of Horn clauses.
The corresponding AND–OR graph.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Forward-Chaining Algorithm Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Forward-Chaining Algorithm Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Forward-Chaining Algorithm Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Forward-Chaining Algorithm Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Forward-Chaining Algorithm Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Forward-Chaining Algorithm Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Forward-Chaining Algorithm Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Forward-Chaining Algorithm Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Proof of Completeness of FC
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Backward Chaining
• Backward chaining is a form of goal-directed reasoning.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Backward Chaining Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Backward Chaining Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Backward Chaining Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Backward Chaining Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Backward Chaining Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Backward Chaining Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Backward Chaining Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Backward Chaining Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Backward Chaining Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Backward Chaining Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Backward Chaining Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Resolution Proof Example
P ∨ Q
Proof of Q
L ∨ M ∨ P
B ∨ L ∨ M
Clause1
Clause2
Resolvent
A ∨ P ∨ L
A
A ∨ B ∨ L
B ∨ L
A ∨ B ∨ L
B
B ∨ L
L
A
B
B ∨ L ∨ M
L ∨ M
B
L
L ∨ M
M
L
L ∨ M ∨ P
M ∨ P
M
M ∨ P
P
P
P ∨ Q
Q
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Forward vs. Backward Chaining
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Summary
• Logical agents apply inference to a knowledge base to derive new information and make decisi
• Basic concepts of logic:
•
•
•
•
•
•
syntax: formal structure of sentences
semantics: truth of sentences wrt models
entailment: necessary truth of one sentence given another
inference: deriving sentences from other sentences
soundness: derivations produce only entailed sentences
completeness: derivations can produce all entailed sentences
• Wumpus world requires the ability to represent partial and negated information, reason by cases
• Forward, backward chaining are linear-time, complete for Horn clauses
• Resolution is complete for propositional logic
• Propositional logic lacks expressive power
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Fundamentals of
Artificial Intelligence
First Order Logic
(Predicate Logic)
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Pros and Cons of Propositional Logic
• Propositional logic is declarative: pieces of syntax correspond to facts
• Propositional logic allows partial/disjunctive/negated information (unlike most data structures a
databases)
• Propositional logic is compositional: meaning of P  Qis derived from meaning of P and of Q
• Meaning in propositional logic is context-independent (unlike natural language, where meaning
depends on context)
• Propositional logic has very limited expressive power (unlike natural language)
• E.g., cannot say ‘pits cause breezes in adjacent squares’ except by writing one sentence for each squa
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Limitations of Propositional Logic
• In propositional logic, we are not able represent the following sentences accurately.
• “All men are mortal.”
• “Socrates is a man.”
• And, we are not able deduct that “Socrates is mortal” from their representations.
• We need more expressive power, and the answer is the first order predicate logic.
• In predicate logic, we represent those sentences as:
• ∀x(Man(x)→Mortal(x)
• Man(Socrates)
• Mortal(Socrates)
• And, we are able to deduct the third one from first two.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Extending Propositional Logic
into Predicate Logic
• Instead of propositions, Predicate Logic has predicates that take a predefined number (≥0) of
arguments (parameters).
• The arguments are terms intended to denote objects in some universe (not true/false statements)
• Terms may contains symbols denoting variables, constants, and functions.
• Formulas may include quantification over variables: “for all” x, “there exists” x.
• Logical connectives of propositional logic are still available in predicate logic.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Predicate Logic (First Order Logic)
• Whereas propositional logic assumes world contains facts, first-order logic (like natural langua
assumes the world contains
• Objects: people, houses, numbers, theories, Ronald McDonald, colors, baseball games, wars,
centuries, …
• Relations: red, round, bogus, prime, multistoried, brother of, bigger than, inside, part of, has co
occurred after, owns, comes between, …
• Functions: father of, best friend, third inning of, one more than, end of, …
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Predicate Logic Syntax: Terms
• Terms are intended to denote objects, and terms are defined in BNF as follows:
t ::= x | c | f(t, . . . , t)
where x is a variable symbol, c is a constant (a function symbol with arity=0) and f is a function symbo
arity n > 0.
Definition: Term
• A variable symbol is a term.
• A constant symbol (a nullary function symbol) is a term.
• If t1,t2,…,tn are terms and f is a function symbol with arity n > 0, then f(t1,t2,…,tn ) is a term.
• Nothing else is a term.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Predicate Logic Syntax
Terms - Examples
• If x,y,z are variable symbols, a, b, c are constant symbols and f(with arity 1), g(with arity 2) are
function symbols, then followings are tems.
• x
y
z
• a
b
c
• f(a)
f(x)
f(f(x))
f(f(a))
• g(a,b)
g(x,y)
g(a,z)
g(f(a),g(b,y))
f(f(f(a)))
• But if P (with arity 1) is predicate symbol, the followings are NOT terms.
• P(x)
P(a)
f(P(a))
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Predicate Logic Syntax
Sentences (Formulas)
• A wff of predicate logic can be defined using following BNF rules.
φ ::= P(t1, … , tn) | t1= t2 |
Atomic Sentences
(¬φ) | (φ ∧ φ) | (φ ∨ φ) | (φ ⇒ φ) | (φ ⇔ φ) |
(∀xφ) | (∃xφ)
where P is a predicate symbol of arity n ≥ 0, ti are terms and x is a variable symbol.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Predicate Logic Syntax
Sentences (Formulas): Examples
• If P is a predicate symbol with arity 1, and Q is a predicate symbol with arity 2.
– P(x)
P(a)
P(f(a))
– Q(x,a)
Q(x,y)
Q(f(x),f(a))
– ∀xP(x)
∃xP(x)
– ∀xQ(x,a)
∃xQ(b,x)
∀xQ(x,y)
– ∀x∀yQ(x,y)
∃x∃yQ(x,y)
∀x∃yQ(x,y)
P(f(x))
∃xQ(y,x)
– ∀x(P(x) ⇒ ∃yQ(x,y))
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Free and Bound Variables
• Quantifiers bind variable occurrences within a sub-formula.
• Occurrences of a variable are bound by the most recent quantifier of that variable within that su
formula.
• If the occurrence of a variable is not bound, it is said to be free.
• The same variable symbol may be bound by different quantifiers, when it occurs in different su
formulas
• renaming them improves clarity.
• A sentence (a closed formula) is a formula with no free variables.
Examples
• ∃xP(x,y)
• ∃x(P(x,y) ˄ ∀yQ(x,y))
• ∃x(P(x,y) ˄ ∀xQ(x,y))
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Semantics of Predicate Logic Models
• The meanings of constant, function and predicate symbols come from models.
A model M consists of:
• Each model identifies a universe U, a non-empty set of objects to which terms are intended to b
mapped.
• Each constant symbol c is mapped to an object cM in U.
• Each function symbol f is mapped to a function fM from Un to U,
where n is the arity of f. fM: Un → U
• Each predicate symbol P is mapped to a n-ary relation PM ( a subset of n-tuples Un )
where n is the arity of P.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Model - Examples
• Let c be a constant symbol, f be a function symbol (with arity 1), P be a predicate symbol
(with arity 2).
• And, let M be a model as follows
• The universe of M = {1,2,3}
• cM = 1
• fM is the function {(1,2),(2,3),(3,1)}
• PM is the relation{(1,1),(1,2)}
• Term Meanings:
• f(c) maps to fM(cM) = fM(1) = 2
• f(f(c)) maps to fM(fM(cM)) = fM(fM(1)) = fM(2) = 3
• Atomic Formula Meanings:
• P(a,f(c)) maps to True since (1,2) ∈ PM
• P(f(c),f(c)) maps to False since (2,2) ∉ PM
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Semantics of Predicate Logic
Environments
• Meanings of free variables come from environments (state or look-up table).
• An environment is a function maps variables to objects of the universe of a model.
• Examples:
• {(x,1),(y,2),(z,1)} is an environment l.
• a function from variables {x,y,z} to the universe of our model M (={1,2,3})
• l(x) is 1 since l maps x to 1
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Semantics of Predicate Logic
Satisfaction Relation
• Truth values of formulas of predicate logic are evaluated wrt a model M and an environmen
• Truth values of closed formulas of predicate logic are evaluated wrt a model M.
• Given a model M with the universe U and given an environment l, we define the satisfaction rel
M⊨l φ for each logical formula φ by structural induction on φ.
Satisfaction Relation:
• If φ is of the form P(t1,… tn), then we map the terms t1,…,tn to the objects a1,…,an in set U by u
the model M and the environment l.
Now M ⊨l P(t1,… tn) holds iff (a1,…, an) is in the relation PM.
• M ⊨l ∀xψ holds iff M ⊨l [x→a] ψ holds for all a ∈ U.
• M ⊨l ∃xψ holds iff M ⊨l [x→a] ψ holds for some a ∈ U.
• M ⊨l ¬ψ holds iff it is not the case that M ⊨l ψ holds.
• M ⊨l ψ1 ∨ ψ2 holds iff M ⊨l ψ1 or M ⊨l ψ2 holds.
• M ⊨l ψ1 ∧ ψ2 holds iff M ⊨l ψ1 and M ⊨l ψ2 hold.
• M ⊨l ψ1 → ψ2 holds iff M ⊨l ψ2 holds whenever M ⊨l ψ1 holds.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Satisfaction Relation - Example
• Let M be a model as follows
• The universe of M = {1,2}
cM = 1
PM is the relation{(1,1),(1,2)}
• Let e be an environment {x→1, y→2}
• The following satisfaction relations hold or not?
• M ⊨e P(x,y)
• M ⊨e P(y,x)
• M ⊨e P(x,c)
• M ⊨e P(y,c)
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Satisfaction Relation - Example
• Let M be a model as follows
• The universe of M = {1,2}
cM = 1
PM is the relation{(1,1),(1,2)}
• Let e be an environment {x→1, y→2}
• The following satisfaction relations hold or not?
• M ⊨e P(x,y)
YES
(1,2)∈PM
• M ⊨e P(y,x)
NO
(2,1)∉PM
• M ⊨e P(x,c)
YES
(1,1)∈PM
• M ⊨e P(y,c)
NO
(2,1)∉PM
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Satisfaction Relation - Example
• Let M be a model as follows
• The universe of M = {1,2}
cM = 1
PM is the relation{(1,1),(1,2)}
• Let e be an environment {x→1, y→2}
• The following satisfaction relations hold or not?
• M ⊨e ∀yP(x,y)
• M ⊨e ∀xP(x,y)
• M ⊨ ∀x∀yP(x,y)
• M ⊨ ∀xyP(x,y)
• M ⊨ x∀yP(x,y)
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Satisfaction Relation - Example
• Let M be a model as follows
• The universe of M = {1,2}
cM = 1
PM is the relation{(1,1),(1,2)}
• Let e be an environment {x→1, y→2}
• The following satisfaction relations hold or not?
• M ⊨e ∀yP(x,y)
YES
(1,1) and (1,2) ∈ PM
• M ⊨e ∀xP(x,y)
NO
(2,2)∉PM
• M ⊨ ∀x∀yP(x,y)
NO
(2,1) and (2,2) ∉ PM
• M ⊨ ∀xyP(x,y)
NO
(2,1) or (2,2) ∉ PM
• M ⊨ x∀yP(x,y)
YES
(1,1) and (1,2) ∈ PM
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Reasoning Over All Models
• Validity:
φ is valid if M ⊨l φ for all M, l.
• Unsatisfiable:
φ is unsatisfiable if M ⊭l φ for all M, l.
• Satisfiability:
φ is satisfiable if there exists M, l such that M ⊨l φ.
• Entailment:
ψ ⊨ φ if M ⊨l φ whenever M ⊨l ψ holds for every M, l.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Reasoning Over All Models - Examples
• Decide the following formulas are valid, satisfiable (but not valid) or unsatisfiable.
• ∀x(P(x)→P(x))
• ∀x(P(x)∨Q(x))
• ∀x(P(x)) ∧ y(!P(y))
• Decide whether following logical consequence relations hold or not.
• ∀x(P(x))∧∀y(Q(y)) ⊨ ∀x(P(x)∧Q(x))
• ∀x(P(x)∨Q(x)) ⊨ ∀x(P(x))∨∀y(Q(y))
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Reasoning Over All Models - Examples
• Decide the following formulas are valid, satisfiable (but not valid) or unsatisfiable.
• ∀x(P(x)→P(x))
Valid
• ∀x(P(x)∨Q(x))
Satisfiable
• ∀x(P(x)) ∧ y(!P(y))
Unsatisfiable
• Decide whether following logical consequence relations hold or not.
• ∀x(P(x))∧∀y(Q(y)) ⊨ ∀x(P(x)∧Q(x))
Holds
• ∀x(P(x)∨Q(x)) ⊨ ∀x(P(x))∨∀y(Q(y))
Does NOT hold
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Fun with Sentences: Quantifiers
• Everybody loves somebody
∀x ∃y Loves(x, y)
• There is someone who is loved by everyone
∃y ∀x Loves(x, y)
• Quantifier duality: each can be expressed using the other
∀x Likes(x, IceCream)
is equivalent to ¬∃x ¬Likes(x, IceCream)
∃x Likes(x, Broccoli)
is equivalent to ¬∀x ¬Likes(x, Broccoli)
¬∀x Likes(x, IceCream) is equivalent to ∃x ¬Likes(x, IceCream)
¬∃x Likes(x, Broccoli)
is equivalent to ∀x ¬Likes(x, Broccoli)
• One's mother is one's female parent
∀m∀c Mother(m,c) ⇔ Female(m) ∧ Parent
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Interacting with FOL KBs
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Inference in Predicate Logic
Proofs
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Proofs
• How can we produce a proof for query Evil(x) from the following KB?
∀x King(x) ∧ Greedy(x) ⇒ Evil(x)
King(John)
Greedy(John)
• Substitution {x/John} solves the query Evil(x)
• To use the rule that greedy kings are evil, find some x such that x is a king and x is greedy,
then infer that this x is evil.
• More generally, if there is some substitution θ that makes each of the conjuncts of the prem
the implication identical to sentences already in the knowledge base, then we can assert the
conclusion of the implication, after applying θ.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Proofs
• We will assume that our KB
• contains only definite clauses (exactly one positive literal) and
• all variables are universally quantified.
• We will use a single inference rule called as Generalized Modus Ponens (A Variation of Resol
Rule for Horn Clauses) in our proofs.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Generalized Modus Ponens
• Generalized Modus Ponens (GMP) Inference Rule:
• There are n+1 premises to this GMP rule: the n atomic sentences pi’ and the one implication.
• The conclusion is the result of applying the substitution θ to the consequent q.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Generalized Modus Ponens
• A proof for query Evil(x) from the following KB using GMP?
∀x King(x) ∧ Greedy(x) ⇒ Evil(x)
King(John)
Greedy(John)
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Unification
• Finding substitutions that make different logical expressions look identical is called unification
• The UNIFY algorithm takes two sentences and returns a unifier for them if one exists:
UNIFY(p, q)=θ where SUBST(θ, p)=SUBST(θ, q)
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Unification
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Unification Algorithm
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Forward Chaining Algorithm
• On each iteration, it adds all the atomic sentences that can be inferred in one step from the implication sen
and the atomic sentences already in KB.
• STANDARDIZE-VARIABLES replaces all variables with new ones that have not been used before.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Generalized Modus Ponens: Example
Knowledge Base:
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 Co
West, who is American.
Prove that Col. West is a criminal.
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Generalized Modus Ponens: Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Forward Chaining Proof
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Forward Chaining Proof
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Forward Chaining Proof
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Backward Chaining Algorithm
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Backward Chaining Algorithm: Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Backward Chaining Algorithm: Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Backward Chaining Algorithm: Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Backward Chaining Algorithm: Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Backward Chaining Algorithm: Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Backward Chaining Algorithm: Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Backward Chaining Algorithm: Example
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
FOL Resolution: Brief Summary
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Conversion to CNF
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Conversion to CNF
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Want to earn
R13,625 per year?
Stuvia.com - The study-notes marketplace
Resolution Proof: Definite Clauses
Downloaded by: stuvia7feva | stuvia.7feva@simplelogin.com
Distribution of this document is illegal
Powered by TCPDF (www.tcpdf.org)
Want to earn
R13,625 per year?