Red beetle car vehicle transportation side view powerpoint ppt slides.
Red Slides Dec06
-
Upload
bishesh-tiwaree -
Category
Documents
-
view
65 -
download
0
description
Transcript of Red Slides Dec06
-
Artificial IntelligenceCourse No. 320331, Fall 2011
Dr. Kaustubh PathakAssistant Professor, Computer [email protected]
Jacobs University Bremen
December 6, 2011
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 1 / 396
-
Introduction
Goal-based Problem-solving Agents using Searching
Non-classical Search Algorithms
Logical Agents
Probability Calculus
Bayesian Networks
Learning
Conclusion
Home-assignments
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 2 / 396
-
Introduction
Contents
IntroductionCourse LogisticsWhat is Artificial Intelligence (AI)?Foundations of AIHistory of AIState of the ArtPython IntroductionAgents and their Task-environments
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 3 / 396
-
Introduction Course Logistics
Basics
I Textbook: Artificial Intelligence, a Modern Approach by StuartRussell and Peter Norvig, III Edition, Pearson, 2010.
I I/II editions are also usable. Reserve copies in the library.
I Additional material from other sources will supplement the textbookmaterial.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 4 / 396
-
Introduction Course Logistics
Grading
I Break-down: Home-assignments (60%), Mid-term exam (15%), Finalexam (25%). Exams compulsory.
I In all, 10 home-assignments: 8 (5%) and 2 (10%).
I Mid-term exam date 25 Oct. 2011 (Tue.) after the reading days.
I Coding in Python (preferred) or C++.
I Teaching Assistant: Mr. Mohammad [email protected]
I Home-assignments email to both the instructor and the TA with [AI]in the subject-line.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 5 / 396
-
Introduction Course Logistics
Syllabus
I Introduction to AI; Intelligent agents: Chapters 1,2.I A brief introduction to Python.
I Solving problems by searching: Chapters 3,4.I BF, DF, A? search; GA, Simulated Annealing.
I Uncertain knowledge & reasoning: Chapters 13, 14, 15.I Bayesian Networks.
I Learning: Chapters 18, 20.I By examples; probabilistic models.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 6 / 396
-
Introduction What is Artificial Intelligence (AI)?
Defining AIHuman-centered vs. Rationalist Approaches
Thinking Humanly [Theautomation of] activities that
we associate with human think-
ing, activities such as decision-
making, problem-solving, learn-
ing... (Bellman, 1978)
Thinking Rationally Thestudy of computations that make
it possible to perceive, reason, and
act. (Winston, 1992)
Acting Humanly The artof creating machines that per-
form functions that require intelli-
gence when performed by people.
(Kurzweil, 1990)
Acting Rationally Computa-tional Intelligence is the study of
the design of intelligent agents.
(Poole et al., 1998)
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 7 / 396
-
Introduction What is Artificial Intelligence (AI)?
Acting Humanly
The Turing Test (1950)
The test is passed if a human interrogator,after posing some written questions,cannot determine whether the responsescome from a human or from a computer.
Total Turing Test
There is a video signal for the interrogatorto test the subjects perceptual abilities, aswell as a hatch to pass physical objectsthrough.
Figure 1: Alan Turing(1912-1954)
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 8 / 396
-
Introduction What is Artificial Intelligence (AI)?
Capabilities required for passing the Turing test
The Turing Test
I Natural language processing
I Knowledge representation
I Automated reasoning
I Machine learning
The Total Turing Test
I Computer vision
I Robotics
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 9 / 396
-
Introduction What is Artificial Intelligence (AI)?
Thinking HumanlyCognitive Science
Trying to discover how human mindswork.
I Introspection
I Psychological experiments onhumans
I Brain imaging: FunctionalMagnetic Resonance Imaging(fMRI), Positron EmissionTomography (PET), EEG, etc.
Figure 2: fMRI image (source: V.Tsytsarev http://www.umsl.edu/~tsytsarev)
Youtube video (1:00-4:20)
Reading mind by fMRI
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 10 / 396
-
Introduction What is Artificial Intelligence (AI)?
Thinking Rationally
I Aristotles Syllogisms.
I The logicist tradition in AI. Logical programming.I Problems:
I Cannot handle uncertaintyI Does not scale-up due to high computational requirements.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 11 / 396
-
Introduction What is Artificial Intelligence (AI)?
Acting RationallyThe Rational Agent Approach
Definition 1 (Agent)
An agent is something that acts. A rational agent is one that acts so as toachieve the best outcome, or when there is uncertainty, the best expectedoutcome.
I This approach is more amenable to scientific development than theones based on human behavior or thought.
I Rationality is well defined mathematically in a way, it is justoptimization under constraints. When, due to computationaldemands in a complicated environment, the agent cannot maintainperfect rationality, it resorts to limited rationality.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 12 / 396
-
Introduction Foundations of AI
Disciplines Contributing to AI. I
Philosophy
I Rationalism: Using power of reasoning to understand the world.I How does the mind arise from the physical brain?
I Dualism: Part of mind is separate from matter/nature. ProponentRene Descartes, among others.
I Materialism: Brains operation constitutes the mind. Claims that freewill is just the way perception of available choices appears to thechoosing entity.
MathematicsLogic, computational tractability, probability theory.
EconomicsUtility theory, decision theory (probability theory + utility theory), gametheory.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 13 / 396
-
Introduction Foundations of AI
NeuroscienceThe exact way the brain enables thought is still a scientific mystery.However, the mapping between areas of the brain and parts of body theycontrol or receive sensory input from.
Parietal LobeFrontal Lobe
Occipital Lobe
Temporal Lobe
Motor Cortex
Visual Cortex
Dorsal Stream
Ventral Stream
Cerebellum
Spinal Cord
Figure 3: The human cortex with the various lobes shown in different colors. Theinformation from the visual cortex gets channeled into the dorsal (where/how)and the ventral (what) streams.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 14 / 396
-
Introduction Foundations of AI
Psychology
Behaviorism (stimulus/response), Cognitive psychology.
Computer Engineering
Hardware and Software. Computer vision.
Linguistics
Natural language processing.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 15 / 396
-
Introduction Foundations of AI
Control Theory and Cybernetics
I The basic idea of control theory is to use sensory feedback to altersystem inputs so as to minimize the error between desired andobserved output. Basic example: controlling the movement of anindustrial robotic arm.
I Norbert Wiener (18941964)
I Modern control theory and AI have a considerable overlap. Controltheory focuses more on calculus of continuous variables, Matrixalgebra, whereas AI also uses tools of logical inference and planning.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 16 / 396
-
Introduction History of AI
History of AI I
Gestation Period (1943-1955)
McCulloch and Pitts (1943) proposed a model for the neuron. Hebbianlearning (1949) for updating inter-neuron connection strengths developed.Alan Turing published Computing Machinery and Intelligence (1950),proposing the Turing test, machine learning, genetic algorithms, andreinforcement learning.
Birth of AI (1956)
The Dartmouth workshop organized by John McCarthy of Stanford.
Early Enthusiasm (1952-1969)
LISP developed. Several small successes including theorem proving etc.Perceptrons (Rosenblatt, 1962) developed.
Reality hits (1966-1973)
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 17 / 396
-
Introduction History of AI
History of AI II
After the Sputnik launch (1957), automatic Russian to English translationattempted. Failed miserably.
1. The spirit is willing, but the flesh is weak. Translated to:
2. The wodka is good but the meat is rotten.
Computational complexity scaling-up could not be handled. Perceptronswere found to have very limited representational power. Most ofgovernment funding stopped.
Knowledge-based Systems (1969-1979)
Use of expert domain specific knowledge for inference. Examples:DENDRAL (1969) for inferring molecular structure from massspectrometer results; MYCIN (Blood infection diagnosis).
AI in Industry (1980-present)
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 18 / 396
-
Introduction History of AI
History of AI III
Companies like DEC, DuPont etc. developed expert systems. Governmentfunding restored.
Return of Neural Networks (1986-present)
Back-propagation learning algorithm developed.
AI embraces Control Theory and Statistics (1987-present)
Rigorous mathematical methods began to be resused instead of ad hocmethods. Example: Hidden Markov Models (HMM), Bayesian Networks,etc.
Intelligent agents (1995-present)
Growth of the Internet. AI in web-based applications (-bots).
Huge data-sets (2001-present)
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 19 / 396
-
Introduction History of AI
History of AI IV
Learning based on very large data-sets. Example: Filling in holes in aphotograph; Hayes and Efros (2007). Performance went from poor for10,000 samples to excellent for 2 million samples.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 20 / 396
-
Introduction State of the Art
Successful Applications
Intelligent Software Wizards
Figure 4: Microsoft Office Assistant Clippit
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 21 / 396
-
Introduction State of the Art
Logistics Planning
Dynamic Analysis and Replanning Tool (DART). Used during Gulf war(1990s) for scheduling of transportation. DARPA stated that this singleapplication paid back DARPAs 30 years investment in AI.DART won DARPAs outstanding Performance by a Contractor award, formodification and transportation feasibility analysis for Time-Phased Forceand Deployment Data that was used during Desert Storm.http://www.bbn.com
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 22 / 396
-
Introduction State of the Art
DARPA Urban Challenge 2007
Figure 5: Video (6:05)
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 23 / 396
-
Introduction State of the Art
Simultaneous Localization and Mapping (SLAM)
Figure 6: Video (4:17)
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 24 / 396
-
Introduction State of the Art
Big Dog: A Control Engineering Marvel
Figure 7: Video (3:28)
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 25 / 396
-
Introduction State of the Art
Digression
New Sensing Technologies: Example Kinect
(a) The Microsoft Kinect 3D camera(from Wikipedia)
(b) A point-cloud obtained from it (fromWillow Garage).
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 26 / 396
-
Introduction State of the Art
Probabilistic Grasp Planning
Figure 8: Video (1:45)
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 27 / 396
-
Introduction State of the Art
Object Recognition & Pose Estimation
Figure 9: Video (2:39)
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 28 / 396
-
Introduction State of the Art
DARPA Grand Challenge 2005 I
Figure 10: Autonomous driving in the Mojave Desert region of the United Statesalong a 150-mile route. The winning car Stanley from Stanford.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 29 / 396
-
Introduction State of the Art
DARPA Grand Challenge 2005 II
Touareg interface
Laser mapper
Wireless E-Stop
Top level control
Laser 2 interface
Laser 3 interface
Laser 4 interface
Laser 1 interface
Laser 5 interface
Camera interface
Radar interface Radar mapper
Vision mapper
UKF Pose estimation
Wheel velocity
GPS position
GPS compass
IMU interface Surface assessment
Health monitor
Road finder
Touch screen UI
Throttle/brake control
Steering control
Path planner
laser map
vehicle state (pose, velocity)
velocity limit
map
vision map
vehicle state
obstacle list
trajectory
road center
RDDF database
driving mode
pause/disable command
Power server interface
clocks
emergency stop
power on/off
Linux processes start/stop heart beats
corridor
SENSOR INTERFACE PERCEPTION PLANNING&CONTROL USER INTERFACE
VEHICLE
INTERFACE
RDDF corridor (smoothed and original)
Process controller
GLOBAL
SERVICES
health status
data
Data logger File system
Communication requests
vehicle state (pose, velocity)
Brake/steering
Communication channels
Inter-process communication (IPC) server Time server
Figure 11: Stanleys architecture. Watch http://youtu.be/TDqzyd7fDRc.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 30 / 396
-
Introduction Python Introduction
Built-in Data-types
Type Example ImmutableNumbers 12, 3.4, 7788990L, 6.1+4j, Decimal XStrings "abcd", abc, "abcs" XBoolean True, False XLists [True, 1.2, "vcf"]Dictionaries {"A" : 25, "V" : 70}Tuples ("ABC", 1, Z) XSets/FrozenSets {90,a}, frozenset({a, 2}) X/XFiles f= open(spam.txt, r)}Single Instances None, NotImplemented. . .
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 31 / 396
-
Introduction Python Introduction
Sequences Istr, list, tuple
Creation and Indexing
a= "1234567"
a[0]
b= [z, x, a, k]
b[-1] == b[len(b)-1], b[-1] is b[len(b)-1]
x= """This is a
multiline string"""
print x
y= me
too
print y
len(y)
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 32 / 396
-
Introduction Python Introduction
Sequences IIstr, list, tuple
Immutability
a[1]= q # Fails
b[1]= s
c= a;
c is a, c==a
a= "xyz"; c is a
Help
dir(b)
help(b.sort)
b.sort()
b # In-place sorting
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 33 / 396
-
Introduction Python Introduction
Sequences IIIstr, list, tuple
Slicing
a[1:2]
a[0:-1]
a[:-1], a[3:]
a[:]
a[0:len(a):2]
a[-1::-1]
Repetition & Concatenation
c=a*2
b*3
a= a + 5mn
d= b + [abs, 1, False]
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 34 / 396
-
Introduction Python Introduction
Sequences IVstr, list, tuple
Nesting
A=[[1,2,3],[4,5,6],[7,8,9]]
A[0]
A[0][2]
A[0:-1][-1]
A[3] # Error
List Comprehension
q= [x.isdigit() for x in a]
print q
p=[(r[1]**2) for r in A if r[1]< 8] # Power
print p
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 35 / 396
-
Introduction Python Introduction
Sequences Vstr, list, tuple
Dictionaries
D= {0:Rhine, 1:"Indus", 3:"Hudson"}
D[0]
D[6] # Error
D[6]="Volga"
dir(D)
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 36 / 396
-
Introduction Python Introduction
Numbers I
I Math Operations
1 a= 10; b= 3; c= 10.5; d=1.2345
2 a/b
3 a//b, c//b # Floor division: b*(a//b) + (a%b) == a
4 d**c # Power
5 type(10**40) # Unlimited integers
6 import math
7 import random
8 dir(math)
9 math.pi # repr(x)
10 print math.pi # str(x)
11 s= "e is %08.3f and list is %s" % (math.e, [a,1,1.5])
12 random.random() # [0,1)
13 random.choice([apple,orange,banana,kiwi])
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 37 / 396
-
Introduction Python Introduction
Numbers II
I Booleans
1 s1= True
2 s2= 3 < 5
-
Introduction Python Introduction
Dynamic Typing I
I Variables are names and have no types. They can refer to objects ofany type. Type is associated with objects.
1 a= "abcf"
2 b= "abcf"
3 a==b, a is b
4 a= 2.5
I Objects are garbage-collected automatically.
I Shared references
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 39 / 396
-
Introduction Python Introduction
Dynamic Typing II1 a= [4,1,5,10]
2 b=a
3 b is a
4 a.sort()
5 b is a
6 a.append(w)
7 a
8 b is a
9 a= a + [w]
10 a
11 b is a
12 b
13 x= 42
14 y= 42
15 x is y, x==y
16 x= [1,2,3]; y=[1,2,3]
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 40 / 396
-
Introduction Python Introduction
Dynamic Typing III
17 x is y, x==y
18 x=123; y= 123
19 x is y, x==y # Wassup?
20 # Assignments create references
21 L= [1,2,3]
22 M= [x, L, c]
23 M
24 L[1]= 0
25 M
26 # To copy
27 L= [1,2,3]
28 M= [x, L[:], c]
29 M
30 L[1]= 0
31 M
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 41 / 396
-
Introduction Python Introduction
Control Statements I
I Mind the indentation! One extra carriage return to finish ininteractive mode.
1 import sys
2 tmp= sys.stdout
3 sys.stdout = open(log.txt, a)
4 x= random.random();
5 if x < 0.25:
6 [y, z]= [-1, 4]
7 elif 0.25
-
Introduction Python Introduction
Loops I
I While
1 i= 0;
2 while i< 5:
3 s= raw_input("Enter an int: ")
4 try:
5 j= int(s)
6 except:
7 print invalid input
8 break;
9 else:
10 print "Its square is %d" % j**2
11 i += 1
12 else:
13 print "exited normally without break"
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 43 / 396
-
Introduction Python Introduction
Loops II
I For
1 X= range(2,10,2) # [2, 4, 6, 8]
2 N= 7
3 for x in X:
4 if x> N:
5 print x, "is >", N
6 break;
7 else:
8 print no number > , N, found
9
10 for line in open(test.txt).xreadlines():
11 print line.upper()
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 44 / 396
-
Introduction Python Introduction
Functions I
I Arguments are passed by assignment
1 def change_q(p, q):
2 for i in p:
3 if i not in q: q.append(i)
4 p= abc
5
6 x= [a,b,c]; # Mutable
7 y= bdg # Immutable
8 print x, y
9 change_q(q=x,p=y)
10 print x, y
I Output
[a, b, c] bdg
[a, b, c, d, g] bdg
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 45 / 396
-
Introduction Python Introduction
Functions II
I Scoping rule: LEGB= Local-function, Enclosing-function(s), Global(module), Built-ins.
1 v= 99
2 def local():
3 def locallocal():
4 v= u
5 print "inside locallocal ", v
6 u= 7; v= 2
7 locallocal()
8 print "outside locallocal ", v
9
10
11 def glob1():
12 global v
13 v += 1
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 46 / 396
-
Introduction Python Introduction
Functions III
14
15 local()
16 print v
17 glob1()
18 print v
I Output
inside locallocal 7
outside locallocal 2
99
100
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 47 / 396
-
Introduction Python Introduction
Packages, Modules IPython Standard Library http://docs.python.org/library/
I Folder structure
root/
pack1/
__init__.py
mod1.py
pack2/
__init__.py
mod2.py
I root should be in one of the following: 1) program home folder, 2)PYTHONPATH 3) standard lib folder, or, 4) in a .pth file on path. Thefull search-path is in sys.path.
I Importing
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 48 / 396
-
Introduction Python Introduction
Packages, Modules IIPython Standard Library http://docs.python.org/library/
import pack1.mod1
import pack1.mod3 as m3
from pack1.pack2.mod2 import A,B,C
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 49 / 396
-
Introduction Python Introduction
Classes I
I Example
class Animal(object): # new style classes
count= 0
def __init__(self, _name):
Animal.count += 1
self.name= _name
def __str__(self):
return I am + self.name
def make_noise(self):
print (self.speak()+" ")*3
class Dog(Animal):
def __init__(self, _name):
Animal.__init__(self, _name)
self.count= 1
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 50 / 396
-
Introduction Python Introduction
Classes II
def speak(self):
return "woof"
I Full examples in python examples.tgz
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 51 / 396
-
Introduction Python Introduction
Useful External Libraries
I The SciPy library is a vast Python library for scientific computations.I http://www.scipy.org/I In Ubuntu install python-scitools in the package-manager.I Library for doing linear-algebra, statistics, FFT, integration,
optimization, plotting, etc.
I Boost is a very mature and professional C++ library. It has Pythonbindings. Refer to:http://www.boost.org/doc/libs/1_47_0/libs/python/doc/
I For creation of Python graph data-structures (leveraging boost) lookat: http://projects.skewed.de/graph-tool/
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 52 / 396
-
Introduction Agents and their Task-environments
A general agent
Agent Sensors
Actuators
Enviro
nment
Percepts
Actions
?
Definition 2 (A Rational Agent)
For each possible percept sequence, a rational agent should select anaction that is expected to maximize its performance measure, given theevidence provided by the percept sequence, and whatever built-in (prior)knowledge the agent has.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 53 / 396
-
Introduction Agents and their Task-environments
The PEAS Description of the Task EnvironmentPerformance, Environment, Actuators, Sensors
Agent-Type Performance-measure
Environment Actuators Sensors
Part-pickingrobot
Percentage ofparts in thecorrect bin
Conveyor beltwith parts; bins
Motors tomove the var-ious joints ofthe arm
Camera, motorangle-encoders
Medical diag-nosis system
Healthy pa-tient, reducedcosts
Patient, hospi-tal
Tests, treat-ments, refer-rals
Symptoms,Test-findings
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 54 / 396
-
Introduction Agents and their Task-environments
Properties of the Task EnvironmentFully observable: relevant environmentstate fully exposed by the sensors.
Partially observable: e.g. a limitedfield-of-view sensor. Unobservable
Single Agent Multi-agentDeterministic: If the next state is com-pletely determined by the current stateand the action of the agent
Stochastic: Uncertainties quantified byprobabilities.
Episodic: Agents experience is dividedinto atomic episodes, each independentof the last, e.g. assembly-line robot.
Sequential: current action affects futureactions, e.g. chess-playing agent.
Static: Environment unchanging.Semi-dynamic: agents performancemeasure changes with time, env. static.
Dynamic: The environment changeswhile the agent is deliberating.
Discrete: state of the environment isdiscrete, e.g. chess-playing, traffic con-trol.
Continuous: The state smoothlychanges in time, e.g. a mobile robot.
Known: rules of the game/laws ofphysics of the env. are known to theagent.
Unknown: The agent must learn therules of the game.
I Hardest case: Partially observable, multiagent, stochastic, sequential,dynamic, continuous, and unknown.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 55 / 396
-
Introduction Agents and their Task-environments
Example of a Partially Observable Environment
Figure 12: A mobile robot operating GUI.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 56 / 396
-
Introduction Agents and their Task-environments
Agent Types
Four basic types in order of increasing generality:
I Simple reflex agents
I Reflex agents with state
I Goal-based agents
I Utility-based agents
All these can be turned into learning agents
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 57 / 396
-
Introduction Agents and their Task-environments
Simple reflex agents
Agent
Environment
Sensors
What the worldis like now
What action Ishould do nowConditionaction rules
Actuators
Algorithm 1: Simple-Reflex-Agent
input : perceptoutput : actionpersistent: rules, a set of
condition-action rules
state Interpret-Input(percept) ;rule Rule-Match(state, rules) ;action rule.action;return action
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 58 / 396
-
Introduction Agents and their Task-environments
Model-based reflex agents I
Agent
Environment
Sensors
What action Ishould do now
State
How the world evolves
What my actions do
Conditionaction rules
Actuators
What the worldis like now
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 59 / 396
-
Introduction Agents and their Task-environments
Model-based reflex agents II
Algorithm 2: Model-Based-Reflex-Agent
input : perceptoutput : actionpersistent: state, agents current conception of worlds state
model , how next state depends on the current state and actionrules, a set of condition-action rulesaction, the most recent action, initially none
state Update-State(state, action, percept, model) ;rule Rule-Match(state, rules) ;action rule.action;return action
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 60 / 396
-
Introduction Agents and their Task-environments
Goal-based agents
Agent
Environment
Sensors
What it will be like if I do action A
What action Ishould do now
State
How the world evolves
What my actions do
Goals
Actuators
What the worldis like now
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 61 / 396
-
Introduction Agents and their Task-environments
Utility-based agents
Agent
Environment
Sensors
What it will be like if I do action A
How happy I will be in such a state
What action Ishould do now
State
How the world evolves
What my actions do
Utility
Actuators
What the worldis like now
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 62 / 396
-
Introduction Agents and their Task-environments
Learning agents
Performance standard
Agent
Environment
Sensors
Performance element
changes
knowledgelearning goals
Problem generator
feedback
Learning element
Critic
Actuators
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 63 / 396
-
Goal-based Problem-solving Agents using Searching
Contents
Goal-based Problem-solving Agents using SearchingThe Graph-Search AlgorithmUninformed (Blind) SearchInformed (Heuristic) Search
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 64 / 396
-
Goal-based Problem-solving Agents using Searching
Problem Solving Agents
Algorithm 3: Simple-Problem-Solving-Agentinput : perceptoutput : actionpersistent: seq, an action sequence, initially empty
state, agents current conception of worlds stategoal , a goal, initially nullproblem, a problem formulation
state Update-State(state, percept) ;if seq is empty then
goal Formulate-Goal(state) ;problem Formulate-Problem(state, goal) ;seq Search(problem) ;if seq = failure then return a null action
action First(seq) ;seq Rest(seq) ;return action
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 65 / 396
-
Goal-based Problem-solving Agents using Searching
Searching for Solutions
I State: The system-state of x Xparameterizes all properties of interest. Theinitial-state of the state is x0 and the set ofgoal-states is Xg . The set X of valid statesis called the state-space.
I Actions or Inputs: At each state x, thereare a set of valid actions u(x) U(x) thatcan be taken by the search agent to alter thestate.
I State Transition Function: How a newstate x is created by applying an action u tothe current state x.
x = f(x,u) (2.1)
The transition may have a cost k(x,u) > 0.
u1u2
Initial State x0
Goal State xg
Valid Actions
Figure 13: Nodes arestates, and edges arestate-transitions causedby actions.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 66 / 396
-
Goal-based Problem-solving Agents using Searching
Searching for Solutions
I State: The system-state of x Xparameterizes all properties of interest. Theinitial-state of the state is x0 and the set ofgoal-states is Xg . The set X of valid statesis called the state-space.
I Actions or Inputs: At each state x, thereare a set of valid actions u(x) U(x) thatcan be taken by the search agent to alter thestate.
I State Transition Function: How a newstate x is created by applying an action u tothe current state x.
x = f(x,u) (2.1)
The transition may have a cost k(x,u) > 0.
u1u2
Initial State x0
Goal State xg
Valid Actions
Figure 13: Nodes arestates, and edges arestate-transitions causedby actions.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 66 / 396
-
Goal-based Problem-solving Agents using Searching
Searching for Solutions
I State: The system-state of x Xparameterizes all properties of interest. Theinitial-state of the state is x0 and the set ofgoal-states is Xg . The set X of valid statesis called the state-space.
I Actions or Inputs: At each state x, thereare a set of valid actions u(x) U(x) thatcan be taken by the search agent to alter thestate.
I State Transition Function: How a newstate x is created by applying an action u tothe current state x.
x = f(x,u) (2.1)
The transition may have a cost k(x,u) > 0.
u1u2
Initial State x0
Goal State xg
Valid Actions
Figure 13: Nodes arestates, and edges arestate-transitions causedby actions.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 66 / 396
-
Goal-based Problem-solving Agents using Searching
Examples I
2
Start State Goal State
51 3
4 6
7 8
5
1
2
3
4
6
7
8
5
(a) An instance
1
23
45
6
7
81
23
45
6
7
8
State Node depth = 6g = 6
state
parent, action
(b) A node of the search-graph. Arrowspoint to parent-nodes.
Figure 14: The 8-puzzle problem
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 67 / 396
-
Goal-based Problem-solving Agents using Searching
Examples II
Figure 15: An instance of the 8-Queens problem
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 68 / 396
-
Goal-based Problem-solving Agents using Searching
Examples III
Giurgiu
UrziceniHirsova
Eforie
NeamtOradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
DobretaCraiova
Sibiu Fagaras
Pitesti
Vaslui
Iasi
Rimnicu Vilcea
Bucharest
71
75
118
111
70
75120
151
140
99
80
97
101
211
138
146 85
90
98
142
92
87
86
Figure 16: The map of Romania. An instance of the route planning problemgiven a map.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 69 / 396
-
Goal-based Problem-solving Agents using Searching
Examples IV
Figure 17: A 2D occupancy grid map created using Laser-Range-Finder (LRF).
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 70 / 396
-
Goal-based Problem-solving Agents using Searching
Examples V
Figure 18: Result of A path-planning algorithm on a multi-resolution quad-tree.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 71 / 396
-
Goal-based Problem-solving Agents using Searching The Graph-Search Algorithm
Graph-SearchCompare with Textbook Fig. 3.7
Algorithm 4: Graph-Search
input : x0,XgD = , The explored-set/dead-set/passive-set;F .Insert(x0, g(x0) = 0) The frontier/active-set;while F not empty dox, g(x) F .Choose() Remove x from the frontier;if x Xg then return SUCCESS;D D {x};for u U(x) do
1 x f(x,u), g(x) g(x) + k(x,u) ;if (x / D) and (x / F) thenF .Insert(x, g(x) + h(x));
else if (x F) then2 F .Resolve-Duplicate(x);
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 72 / 396
-
Goal-based Problem-solving Agents using Searching The Graph-Search Algorithm
Measuring Problem-Solving Performance
I Completeness: Is the algorithm guaranteed to find a solution if thereis one?
I Optimality: Does the strategy find optimal solutions?I Time & Space Complexity: How long does the algorithm take and
how much memory is needed?I Branching factor b: The maximum number of successors (children) of
any node.I Depth d : The shallowest goal-node level.I Max-length m: Maximum length of any path in state-space.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 73 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
Breadth-First Search (BFS)
I The frontier F is implemented as a FIFO queue. The oldest elementis chosen by Choose().
I For a finite graph, it is complete, and optimum if all edges have samecost. It finds the shallowest goal node.
I The Graph-Search can return as soon as a goal-state is generatedin line 1.
I Number of nodes generated b + b2 + . . .+ bd = O(bd). This is thespace and time complexity.
I The explored set will have O(bd1) nodes and the frontier will haveO(bd) nodes.
I Mememory becomes more critical than computation time, e.g. forb = 10, d = 12, 1 KB/node, search-time is 13 days, andmemory-requirements 1 petabyte.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 74 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
BFS Example
A
B C
D E F G
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 75 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
BFS Example
A
B C
D E F G
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 75 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
BFS Example
A
B C
D E F G
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 75 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
BFS Example
A
B C
D E F G
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 75 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
Dijkstra Algorithm or Uniform-Cost Search
I The frontier F is implemented as a priority-queue. Choose() selectsthe element with the highest priority, i.e. the minimum path-lengthg(x).
I F .Resolve-Duplicate(x) function on line 2 updates the path-costg(x) of x in the frontier F , if the new value is lower than the storedvalue. If the cost is decreased, the old parent is replaced by the newone. The priority queue is reordered to reflect the change.
I It is complete and optimum.
I When a node x is chosen from the priority-queue, the minimum lengthpath from x0 to it has been found. Its length is denoted as g(x).
I In other words, the optimum path-lengths of all the explored nodes inthe set D have already been found.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 76 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
Correctness of Dijkstra Algorithm I
D
F
x
xg
x0
Figure 19: The graph separation by the frontier. The node x in the frontier ischosen for further expansion. The set D is a tree.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 77 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
Correctness of Dijkstra Algorithm II
Observations
I Unexplored nodes can only be reached through the frontier nodes.
I An existing frontier node xf s cost can only be reduced thorough anode xc which currently has been chosen from the priority-queue as ithas the smallest cost in the frontier. The reduced cost g(xf ) > g(xc),and now parent(x)= xc .
I Note that D remains a tree.
I The frontier expands only through the unexplored children of thechosen frontier node, all of the children will have costs worse thantheir parent.
I The costs of the successively chosen frontier nodes arenon-decreasing.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 78 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
Correctness of Dijkstra Algorithm IIIRemark 3 (When a frontier node xc is chosen for exansion, itsoptimum path has been found: Proof by induction.)
I Initially, x0 is added to D and expanded. Its child with the minimumpath-cost is then chosen from the frontier to be added to D. Itsfound path-cost is optimum.
I Assume that the paths of all nodes in D from x0 are optimum. Nowwe choose a new node xc to expand from the frontier. Then, we needto show that the path from x0 to xc through parent(xc) D is theoptimum.If this were not the case, then the optimum path to xc will passthrough some other node in the frontier, but their optimumpath-costs cannot be less than g(xc).
Thus sub-paths of an optimum path are also optimum: this is arestatement of the Bellmans Principle of Optimality.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 79 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
Depth-first Search (DFS)
I The frontier F is implemented as a LIFO stack. The newest elementis chosen by Choose().
I For a finite graph, it is complete, and but not optimum.
I Explored nodes with no descendants in the frontier can be removedfrom the memory! This gives a space-complexity adavantage: O(bm)nodes. This happens automatically if the algorithm is writtenrecursively.
I Assuming that nodes at the same depth as the goal-node have nosuccessors, b = 10, d = 16, 1 KB/node, DFS will require 7 trillion(1012) times less space than BFS! That is why, it is popular in AIresearch.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 80 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
Algorithm 5: Depth-limited-Search
input : current-state x, depth dif x Xg then
return SUCCESS ;else if d = 0 then
return CUTOFFelse
for u U(x) dox f(x,u);result Depth-limited-Search(x, d 1);if result =SUCCESS then
return SUCCESSelse if result =CUTOFF then
cutoff-occurred trueif cutoff-occurred then return CUTOFF ;else return NOT-FOUND ;
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 81 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
DFS ExampleGoal node M
A
B C
D E F G
H I J K L M N O
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 82 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
DFS ExampleGoal node M
A
B C
D E F G
H I J K L M N O
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 82 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
DFS ExampleGoal node M
A
B C
D E F G
H I J K L M N O
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 82 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
DFS ExampleGoal node M
A
B C
D E F G
H I J K L M N O
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 82 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
DFS ExampleGoal node M
A
B C
D E F G
H I J K L M N O
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 82 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
DFS ExampleGoal node M
A
B C
D E F G
H I J K L M N O
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 82 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
DFS ExampleGoal node M
A
B C
D E F G
H I J K L M N O
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 82 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
DFS ExampleGoal node M
A
B C
D E F G
H I J K L M N O
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 82 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
DFS ExampleGoal node M
A
B C
D E F G
H I J K L M N O
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 82 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
DFS ExampleGoal node M
A
B C
D E F G
H I J K L M N O
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 82 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
DFS ExampleGoal node M
A
B C
D E F G
H I J K L M N O
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 82 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
DFS ExampleGoal node M
A
B C
D E F G
H I J K L M N O
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 82 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
Iterative Deepening Search (IDS)
I As O(bd) O(bd1), one can combine the benefits of BFSand DFS.
I All the work from previous iteration is redone, but this isacceptable, as the frontier-size is dominant.
Algorithm 6: Iterative-Deepening-Search
for d= 0 to doresult Depth-limited-Search(x0, d);if result 6= CUTOFF then
return result
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 83 / 396
-
Goal-based Problem-solving Agents using Searching Uninformed (Blind) Search
Limit = 3
Limit = 2
Limit = 1
Limit = 0 A A
A
B C
A
B C
A
B C
A
B C
A
B C
D E F G
A
B C
D E F G
A
B C
D E F G
A
B C
D E F G
A
B C
D E F G
A
B C
D E F G
A
B C
D E F G
A
B C
D E F G
A
B C
D E F G
H I J K L M N O
A
B C
D E F G
H I J K L M N O
A
B C
D E F G
H I J K L M N O
A
B C
D E F G
H I J K L M N O
A
B C
D E F G
H I J K L M N O
A
B C
D E F G
H I J K L M N O
A
B C
D E F G
H I J K L M N O
A
B C
D E F G
H I J K L M N O
A
B C
D E F G
H I J K L M N O
A
B C
D E F G
H I J K L M N O
A
B C
D E F G
H J K L M N OI
A
B C
D E F G
H I J K L M N O
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 84 / 396
-
Goal-based Problem-solving Agents using Searching Informed (Heuristic) Search
A Search I
est. path-cost from x0 to xg `(x)
= g(x) + est. path-cost from x to xg h(x)
(2.2)
`(x) , g(x) + h(x) (2.3)`(xg ) g(xg ), as h(xg ) = 0. (2.4)
I h(x) is a heuristically estimated cost, e.g., for the map route-findingproblem, h(x) = xg x.
I `(x) is the estimated cost of the cheapest solution through node x.
I A is a Graph-Search where, the frontier F is a priority-queue withhigher priority given to lower values of the evaluation function `(x).
I If no heuristics are taken, i.e. h(x) 0, A reduces to Dijkstrasalgorithm.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 85 / 396
-
Goal-based Problem-solving Agents using Searching Informed (Heuristic) Search
A Search II
I Similar to Dijkstras Algorithm, F .Resolve-Duplicate(x) online 2 of Algo. 4 updates the cost `(x) in the frontier F , if the newvalue is lower than the stored value. If this occurs, the old parent ofx is replaced by the new one. The priority queue is reordered toreflect the change.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 86 / 396
-
Goal-based Problem-solving Agents using Searching Informed (Heuristic) Search
Example heuristic function
Urziceni
NeamtOradea
Zerind
Timisoara
Mehadia
Sibiu
PitestiRimnicu Vilcea
Vaslui
Bucharest
GiurgiuHirsova
Eforie
Arad
Lugoj
DrobetaCraiova
Fagaras
Iasi
0160242161
77151
366
244226
176
241
25332980
199
380234
374
100193
Figure 20: Values of hSLD straight-line distances to Bucharest.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 87 / 396
-
Goal-based Problem-solving Agents using Searching Informed (Heuristic) Search
Conditions for Optimality of A IA will find the optimal path, if the heuristic cost h(x) is admissible andconsistent.
Definition 4 (Admissibility)
h(x) is admissible, if it never over-estimates the cost to reach the goal h(x) is always optimistic.Definition 5 (Consistency)
h(x) is consistent, if for every child (generated by action ui ) xi of a node x
the triangle-inequality holds:
h(xg ) = 0, (2.5)
h(x) k(x,ui , xi ) + h(xi ), i (2.6)
This is a stronger condition than admissibility, i.e. consistency admissibility.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 88 / 396
-
Goal-based Problem-solving Agents using Searching Informed (Heuristic) Search
A proof I
Lemma 6 (`(x) is non-decreasing along any optimal path)
x0 xm
xnxp
Figure 21: A dashed line between two nodes denotes that the nodes areconnected by a path, but are not necessarily directly connected.
To prove: Let xp be a node for which the optimum-path with cost g(xp)has been found (see figure): Nodes xm and xn lie on this optimum pathsuch that xm precedes xn, then
`(xm) `(xn) (2.7)
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 89 / 396
-
Goal-based Problem-solving Agents using Searching Informed (Heuristic) Search
A proof IIProof.
I First note that since xm and xn lie on the optimum path to xp, theirpaths are also optimum and have lengths g(xn) and g(xm)respectively.
I Let us first assume that xm is the parent of xn, then
`(xn) = h(xn) + g(xn) (2.8)= h(xn) + g
(xm) + k(xm, xn) (2.9)(2.6)
h(xm) + g(xm) = `(xm) (2.10)I Now if xm is not the parent of xn but a predecessor, the inequality
can be chained for every child-parent node on the path between them,and we reach the same conclusion.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 90 / 396
-
Goal-based Problem-solving Agents using Searching Informed (Heuristic) Search
A proof III
Lemma 7 (At selection for expansion, a nodes optimum path hasbeen found)
To prove: In every iteration of A, the node x selected for expansion bythe frontier F having the minimum value of `(x) is such that, at selection:
g(x) = g(x). (2.11)
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 91 / 396
-
Goal-based Problem-solving Agents using Searching Informed (Heuristic) Search
Proof of Lemma 7 I
x0
xn
Fk+1
D xs
xp
xm
(x0 : xm)
(x0 : xm)
(xp : xn)
Figure 22: The path shown in blue is the assumed optimal path. (x0 : xm) isthe optimum path found for a node xm. Since xm D at iteration k + 1, by theinduction hypothesis it must have been selected by Fi , i < k + 1, and hence itspath is optimum.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 92 / 396
-
Goal-based Problem-solving Agents using Searching Informed (Heuristic) Search
Proof of Lemma 7 II
I Proof is by induction. At N = 1, the frontier F selects its only nodex0 with cost g(x0) = g(x0) = 0.
I Assume that the induction hypothesis holds for N = 1 . . . k , Now weneed to show that it holds for iteration k + 1.
I Assume that Fk+1 selects xn at this iteration. All frontier nodes havetheir parents in D. At the time of selection, parent(xn)= xs . Supposethat the path through xs is not the optimal path for xn, but theoptimal path is , as shown in the figure in blue. The path consistsof edges existing in the search-graph which consists of all possibleparent-child edges of all nodes. This path exists in the graph atiteration k + 1 whether or not it will ever be discovered in futureiterations is irrelevant.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 93 / 396
-
Goal-based Problem-solving Agents using Searching Informed (Heuristic) Search
Proof of Lemma 7 IIII Note that the assumed optimal-path has to pass through a node
which is in Fk+1 because the frontier separates the dead-nodes Dand unknown nodes and all expansion occurs through the frontiernodes.
I Let xp be the first of all the nodes in the frontier Fk+1 (ref. figure).Since it is the first, its parent xm D. The entire assumed optimalpath consists of the following sub-paths ( stands forpath-concatenation):
(x0 : xn) = (x0 : xm) (xm : xp) (xp : xn) (2.12)
The sub-path (x0 : xm) of the assumed optimal path might bedifferent from (x0 : xm) already found at a previous iteration due tothe induction hypothesis (ref. figure). However, since all sub-paths ofan optimal path are also optimal, we conclude:
(x0 : xm) (x0 : xm). (2.13)Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 94 / 396
-
Goal-based Problem-solving Agents using Searching Informed (Heuristic) Search
Proof of Lemma 7 IVI Note that the path may wander around the frontier Fk+1 and the
unexplored space before it reaches xn, but it cannot re-enter D, onceit leaves it at xm. Why?
I Node xp was added to the frontier Fk+1 with path-cost
gk+1(xp) = g(xm) + k(xm, xp) (2.14)
As xp is part of the assumed optimal path , its path-cost is alsooptimal. Combining this with (2.13),
g(xp) = gk+1(xp) (2.15)`k+1(xp) = `
(xp) = h(xp) + g(xp). (2.16)
I As xp lies on the optimum-path to xn, from Lemma 6,
`(xp) `(xn) (2.17a) `k+1(xn), the cost of xn at k+1. (2.17b)
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 95 / 396
-
Goal-based Problem-solving Agents using Searching Informed (Heuristic) Search
Proof of Lemma 7 VI However, xn was selected by Fk+1 for expansion. Therefore, at
iteration k + 1, it must be true that,
`k+1(xn) `k+1(xp) (2.16)= `(xp). (2.18)
Combining (2.16), (2.17), and (2.18), we get:
`(xp) `(xn) `k+1(xn) `(xp), (2.19) `(xn) = `k+1(xn), (2.20)
g(xn) + h(xn) = gk+1(xn) + h(xn), (2.21)
g(xn) = gk+1(xn), (2.22)
or, the path-cost of g(xn) at k + 1 is indeed optimum. This is incontradiction to what we assumed, with our alternate optimal-path assumption. Therefore, we conclude that the optimal path g(xn) isfound at N = k + 1 when xn is selected by Fk+1.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 96 / 396
-
Goal-based Problem-solving Agents using Searching Informed (Heuristic) Search
Proof of Lemma 7 VI
I By extension, when the goal point is selected by the frontier, itsoptimum path with cost g(xg ) has been found.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 97 / 396
-
Goal-based Problem-solving Agents using Searching Informed (Heuristic) Search
Figure 23: Region searched before finding a solution: Dijkstra path search
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 98 / 396
-
Goal-based Problem-solving Agents using Searching Informed (Heuristic) Search
Figure 24: Region searched before finding a solution: A path search. Thenumber of nodes expanded is the minimum possible.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 99 / 396
-
Goal-based Problem-solving Agents using Searching Informed (Heuristic) Search
Lemma 8 (Monotonicity of Expansion)
Let the selected node by Fj be xj , and that selected by Fj+1 be xj+1.Then it must be true that
`(xj) `(xj+1). (2.23)
Why? This shows that at iteration N = j , if Fj selects xj then:I All nodes x with `(x) < `(xj) have already been expanded, and
some nodes with `(x) = `(xj) have also been expanded.I In particular, when the first goal is found, then, All nodes x with`(x) < g(xg ) have already been expanded, and some nodes with`(x) = g(xg ) have also been expanded.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 100 / 396
-
Goal-based Problem-solving Agents using Searching Informed (Heuristic) Search
Properties of A
I The paths are optimal w.r.t. the cost function, but do you notice anyundesirable properties of the planned paths?
I Why are there less colors in Fig. 7 than in Fig. 6?
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 101 / 396
-
Goal-based Problem-solving Agents using Searching Informed (Heuristic) Search
Selection of the Heuristic Cost
I The heuristic cost-to-go functions h can be generated from relaxedproblems where no search is required. E.g. straight-line distance formap route planning.
I Possibilities for the 8-puzzle problem (Fig. 14): 1) h is the number ofmisplaced tiles, 2) h is the Manhattan distance of tiles from their goalpositions. Which is better?
I From Lemma 8, at the iteration when the goal is found, themaximum possible number of nodes expanded uptil then form a set
Sh = {x | h(x) g(xg ) g(x)} (2.24)
Thus, if we have two heuristics h1, h2 s.t. x
h2(x) h1(x) |Sh2 | |Sh1 | h2 is more efficient. (2.25)I Can always take h(x) = max{h1(x), . . . , hm(x)}
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 102 / 396
-
Non-classical Search Algorithms
Contents
Non-classical Search AlgorithmsHill-ClimbingSampling from a PMFSimulated AnnealingGenetic Algorithms
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 103 / 396
-
Non-classical Search Algorithms
Local Search
currentstate
objective function
state space
global maximum
local maximumflat local maximum
shoulder
Figure 25: A 1-D state-space landscape. The aim is to find the global maximum.
Local search algorithms are used whenI The search-path itself is not important, but only the final optimal
state, e.g. 8-Queen problem, job-shop scheduling, IC design, TSP, etc.I Memory efficiency is needed. Typically only one node is retained.I The aim is to find the best state according to an objective function to
be optimized. We may be seeking the global maximum or theminimum. How can we reformulate the former to the latter?
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 104 / 396
-
Non-classical Search Algorithms Hill-Climbing
Algorithm 7: Hill-Climbing
input : x0, objective (value) function v(x)to maximize
output: x, the state where a localmaximum is achieved
x x0 ;while True do
y the highest-valued child of x ;if v(y) v(x) then return x ;x y
To avoid getting stuck in plateaux:
I Allow side-ways movements (upto alimit)
I Random-restart: perform search frommany randomly chosen x0 till anoptimal solution is found.
Figure 26: A ridge. The localmaxima are not directlyconnected to each other.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 105 / 396
-
Non-classical Search Algorithms Sampling from a PMF
Sampling from a Probability Mass Function (pmf)
Definition 9 (PMF)
Given a discrete random-variable A with an exhaustive and ordered (canbe user-defined, if no natural order exists) list of its possible values[a1, a2, . . . , an], its pmf P(A) is a table, with probabilitiesP(A = ai ), i = 1 . . . n. Obviously,
ni=1 P(A = ai ) = 1.
Problem 10Sampling a PMF A uniform random number generator in the unit-intervalhas the probability distribution function pu[0,1](x) as shown below in thefigure. Python random.random() returns a sample x [0.0, 1.0). Howcan you use it to sample a given discrete distribution (PMF)?
1
0 1
pu[0,1](x)
xa b
P (x [a, b] ; 0 a b < 1) = b a
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 106 / 396
-
Non-classical Search Algorithms Sampling from a PMF
Definition 11 (Cumulative PMF FA for a PMF P(A))
FA(aj) , P(A aj) =n
i=1
P(A = ai )u(aj ai ), where, (3.1)
u(x) ,{
0 x < 0
1 x 0 (3.2)
FA(aj) ij
P(A = ai ) (3.3)
u(x) is called the discrete unit-step function or the Heaviside stepfunction. What is FA(an)?
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 107 / 396
-
Non-classical Search Algorithms Sampling from a PMF
I Form a vector of half-closed intervals
s ,
[0,FA(a1))
[FA(a1),FA(a2))...
[FA(an2),FA(an1))[FA(an1), 1)
, Define a0 s.t. FA(a0) , 0. (3.4)
I Let ru be a sample from a uniform random-number generator in theunit-interval [0, 1). Then,
P(ru s[i ]) = P(FA(ai1) ru < FA(ai ))= P(FA(ai1) ru FA(ai ))= FA(ai ) FA(ai1)(3.3)= P(ai ) (3.5)
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 108 / 396
-
Non-classical Search Algorithms Simulated Annealing
Algorithm 8: Simulated-Annealing
input : x0, objective (cost) function c(x)to minimize
output: x, a locally optimum statex x0 ;for k k0 to do
T Schedule(k) ;if 0 < T < then return x ;y a randomly selected child of x ;E c(y) c(x) ;if E < 0 then
x yelse
x y with probability P(E ,T ) ;P(E ,T ) = 1
1+eE/T eE/T ;
(Boltzmann distribution)
An example of aschedule is
Tk = T0ln(k0)
ln(k)(3.6)
Applications:
VLSI layouts,Factory-scheduling.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 109 / 396
-
Non-classical Search Algorithms Simulated Annealing
Another Schedule
We first generate some random rearrangements, and use themto determine the range of values of E that will be encounteredfrom move to move. Choosing a starting value of T which isconsiderably larger than the largest E normally encountered,we proceed downward in multiplicative steps each amounting toa 10 % decrease in T . We hold each new value of T constantfor, say, 100N reconfigurations, or for 10N successfulreconfigurations, whichever comes first. When efforts to reduceE further become sufficiently discouraging, we stop.
Numerical Recipes in C: The Art of Scientific Computing.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 110 / 396
-
Non-classical Search Algorithms Genetic Algorithms
Algorithm 9: Genetic Algorithm
input : P = {x}, a population of individuals,a Fitness() function to maximize
output: x, an individualrepeatPn ;for i 1 to Size(P) do
x Random-Selection(P, Fitness()) ;y Random-Selection(P, Fitness()) ;c Reproduce(x, y) ;if small probability then Mutate(c) ;Add c to Pn
P Pnuntil x P, Fitness(x) > Threshold, or enough timeelapsed ;return best individual in P
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 111 / 396
-
Non-classical Search Algorithms Genetic Algorithms
Algorithm 10: Reproduce(x, y)
N Length(x) ;R random-number from 1 to N (cross-over point);c Substring(x, 1, R) + Substring(y, R + 1, N) ;return c
(a)Initial Population
(b)Fitness Function
(c)Selection
(d)Crossover
(e)Mutation
24
23
20
11
29%
31%
26%
14%
32752411
24748552
32752411
24415124
32748552
24752411
32752124
24415411
32252124
24752411
32748152
24415417
24748552
32752411
24415124
32543213
Figure 27: The 8-Queens problem. The ith number in the string is the position ofthe queen in the ith column. The fitness function is the number of non-attackingpairs (maximum fitness 28).
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 112 / 396
-
Non-classical Search Algorithms Genetic Algorithms
Properties of Genetic Algorithms (GA)
I Crucial issue: encoding.
I Schema e.g. 236 , an instance of this schema is 23689745. Ifaverage fitness of instances of schema are above the mean, then thenumber of instances of the schema in the population will grow overtime. It is important that the schema makes some sense within thesemantics/physics of the problem.
I GAs have been used in job-shop scheduling, circuit-layout, etc.
I The identification of the exact conditions under which GAs performwell requires further research.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 113 / 396
-
Logical Agents
Contents
Logical AgentsPropositional LogicEntailment and InferenceInference by Model-CheckingInference by Theorem ProvingInference by ResolutionInference with Horn ClausesAgents based on Propositional LogicTime out from Logic
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 114 / 396
-
Logical Agents
Knowledge-Base
A Knowledge-Base is a set of sentences expressed in a knowledgerepresentation language. New sentences can be added to the KB and itcan be queried about whether a given sentence can be inferred from whatis known.A KB-Agent is an example of a Reflex-Agent explained previously.
Algorithm 11: Knowledge-Base (KB) Agent
input : KB, a knowledge-base,t, time, initially 0.
Tell(KB, Make-Percept-Sentence(percept, t)) ;action Ask(KB, Make-Action-Query(t)) ;Tell(KB, Make-Action-Sentence(action, t)) ;t t + 1 ;return action
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 115 / 396
-
Logical Agents Propositional Logic
Propositional LogicA simple knowledge representation language
Syntax, BNF Grammar
Sentence AtomicSentence | ComplexSentenceAtomicSentence True | False | P | Q | R | . . .
ComplexSentence (Sentence ) | [Sentence ]| Sentence| Sentence Sentence| Sentence Sentence| Sentence Sentence| Sentence Sentence
Operator-Precedence : ,,,, (4.1)
Axioms are sentences which are given and cannot be derived from othersentences.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 116 / 396
-
Logical Agents Propositional Logic
Propositional Logic Semantics ITruth-Value
The truth-tables of (negation), (and/conjunction), (or/disjunction)are well-known.
P Q P Q P QT T T TT F F FF T T FF F T T
P Q P Q Premise implies Conclusion (4.2a)P Q Q P Contraposition (4.2b)P Q (P Q ) (Q P ) Biconditional (4.2c)
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 117 / 396
-
Logical Agents Propositional Logic
Propositional Logic Semantics IITruth-Value
R (P Q ) (R P ) Q Associativity (4.2d)R (P Q ) (R P ) Q Associativity (4.2e)(P Q ) P Q De Morgan (4.2f)(P Q ) P Q De Morgan (4.2g)
R (P Q ) (R P ) (R Q ) Distributivity (4.2h)R (P Q ) (R P ) (R Q ) Distributivity (4.2i)
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 118 / 396
-
Logical Agents Propositional Logic
Wumpus World
PIT
1 2 3 4
1
2
3
4
START
Stench
Stench
Breeze
Gold
PIT
PIT
Breeze
Breeze
Breeze
Breeze
Breeze
Stench
Figure 28: Actions=[Move-Forward, Turn-Left, Turn-Right, Grab, Shoot, Climb],Percept=[Stench, Breeze, Glitter, Bump, Scream]
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 119 / 396
-
Logical Agents Propositional Logic
Wumpus World KB
Px ,y is true if there is a pit in [x , y ]Wx ,y is true if there is a Wumpus in [x , y ]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 ]
R1 : P1,1 (4.3)R2 : B1,1 (P1,2 P2,1), R3 : B2,1 (P1,1 P2,2 P3,1) (4.4)
(4.5)
We also have percepts.
R4 : B1,1, R5 : B2,1 (4.6)
Query to the KB: = P1,2 or = P2,2.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 120 / 396
-
Logical Agents Propositional Logic
Model and Sentences
Definition 12 (Model)
I A model is a possible-world, where we fix the truth-value of everyrelevant sentence.
I If a sentence is true in model m, we say that m satisfies , or m isa model of . For example, m = {P = F ,Q = F} is a model of = (P Q ).
I The notation M() means the set of all models of the sentence ,that is all possible assignments of the relevant truth-values, for which evaluates to true.
I A sentence is valid (is a tautology) is it is true for all models, e.g.P P .
I A sentence is satisfiable if it is true in some model.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 121 / 396
-
Logical Agents Entailment and Inference
Entailment
Definition 13 (Entailment)
The sentence entails the sentence , i.e.
, if and only if (iff) M() M() (4.7)
Theorem 14 (Deduction Theorem)
For any sentences and , iff the sentence ( ) is valid, i.e.true in all models.
Theorem 15 (Proof by Contradiction)
For any sentences and , iff the sentence ( ) isunsatisfiable. Assume to be false, and show that it leads tocontradictions with known axioms of .
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 122 / 396
-
Logical Agents Entailment and Inference
Logical Inference
I Inference is the use of entailment to draw conclusions. For example,KB , shows that the sentence can be concluded from what theagent knows.
I KB `i denotes that the inference algorithm i derives from KB .An algorithm which derives only entailed sentences is called sound.An algorithm is complete if it can derive any sentence that is entailed.
I Simplest inference is by model-checking: list all models in which KBis true, and show that for all those models, is true.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 123 / 396
-
Logical Agents Inference by Model-Checking
Model-Checking Based InferenceAlgorithm 12: TT-Entails(KB, )
input: KB, a knowledge-base; , a query sentencesymbols list of proposition symbols in KB and ;return TT-Check(KB, , symbols, model={})Algorithm 13: TT-Check(KB, , symbols, model)
input: KB, a knowledge-base; , a sentence; symbols; modelif Empty(symbols) then
if Pl-true(KB, model) thenreturn Pl-true(, model)
elsereturn true // KB is false
elseP First(symbols); tail Rest(symbols) ;return TT-Check(KB, , tail, model {P = T}) andTT-Check(KB, , tail, model {P = F})
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 124 / 396
-
Logical Agents Inference by Model-Checking
Conjunctive Normal Form (CNF)
Definition 16 (Clause)
A clause is a disjunction of literals. Example: (P Q R)Definition 17 (CNF)
Every sentence of propositional logic is equivalent to a conjunction ofclauses: This form is called the Conjunctive Normal Form (CNF). TheCNF can be arrived at by making use of the equivalence-relationships likeDe Morgan laws, distributivity, etc. Example:
A B (A B) (B A)
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 125 / 396
-
Logical Agents Inference by Model-Checking
Davis-Putnam-Logemann-Loveland (DPLL) AlgorithmA complete backtracking algorithm
TT-Entails can be made more efficient. First entailment is now to beinferred by solving the SAT problem: iff the sentence ( ) isunsatisfiable. DPLL has 3 improvements over TT-Entails:I Early Termination: A clause is true, if any literal is true. A sentence
(in CNF) is false if any clause is false, which occurs when all itsliterals are false. Sometimes a partial model suffices. Example:(A B) (C A) is true if A = True .
I Pure Symbol: A symbol which occurs with the same sign in allclauses. Example: (A B), (C B), (C A). If a sentence has amodel, then it has a model with pure symbols assigned to make theirliteral true: this never makes the clause false.
I Unit Clause is a single literal clause or a clause where all literals butone have already been assigned false by the model. To make aunit-clause true, an appropriate truth-value for the sole literal can befound. Example: (C B) with B already assigned true. Assigninga unit-clause may create another: unit propagation.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 126 / 396
-
Logical Agents Inference by Model-Checking
Davis-Putnam-Logemann-Loveland (DPLL) AlgorithmA complete backtracking algorithm
TT-Entails can be made more efficient. First entailment is now to beinferred by solving the SAT problem: iff the sentence ( ) isunsatisfiable. DPLL has 3 improvements over TT-Entails:I Early Termination: A clause is true, if any literal is true. A sentence
(in CNF) is false if any clause is false, which occurs when all itsliterals are false. Sometimes a partial model suffices. Example:(A B) (C A) is true if A = True .
I Pure Symbol: A symbol which occurs with the same sign in allclauses. Example: (A B), (C B), (C A). If a sentence has amodel, then it has a model with pure symbols assigned to make theirliteral true: this never makes the clause false.
I Unit Clause is a single literal clause or a clause where all literals butone have already been assigned false by the model. To make aunit-clause true, an appropriate truth-value for the sole literal can befound. Example: (C B) with B already assigned true. Assigninga unit-clause may create another: unit propagation.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 126 / 396
-
Logical Agents Inference by Model-Checking
Davis-Putnam-Logemann-Loveland (DPLL) AlgorithmA complete backtracking algorithm
TT-Entails can be made more efficient. First entailment is now to beinferred by solving the SAT problem: iff the sentence ( ) isunsatisfiable. DPLL has 3 improvements over TT-Entails:I Early Termination: A clause is true, if any literal is true. A sentence
(in CNF) is false if any clause is false, which occurs when all itsliterals are false. Sometimes a partial model suffices. Example:(A B) (C A) is true if A = True .
I Pure Symbol: A symbol which occurs with the same sign in allclauses. Example: (A B), (C B), (C A). If a sentence has amodel, then it has a model with pure symbols assigned to make theirliteral true: this never makes the clause false.
I Unit Clause is a single literal clause or a clause where all literals butone have already been assigned false by the model. To make aunit-clause true, an appropriate truth-value for the sole literal can befound. Example: (C B) with B already assigned true. Assigninga unit-clause may create another: unit propagation.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 126 / 396
-
Logical Agents Inference by Model-Checking
Algorithm 14: DPLL-Satisfiable(s)
input: s, a sentence in propositional logicclauses the set of clauses in the CNF of s ;symbols a list of propositional symbols in s ;return DPLL(clauses, symbols, { })Algorithm 15: DPLL(clauses, symbols, model)
if every clause in clauses is true in model then return true ;if some clause in clauses is false in model then return false ;P, v Find-Pure-Symbol(symbols, clauses, model) ;if P 6= then return DPLL(clauses, symbols P, model { P=v }) ;P, v Find-Unit-Clause(clauses, model) ;if P 6= then return DPLL(clauses, symbols P, model { P=v }) ;P First(symbols); rest Rest(symbols) ;return DPLL(clauses, rest, model { P= true }) or DPLL(clauses,rest, model { P= false })
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 127 / 396
-
Logical Agents Inference by Model-Checking
WalkSATA local search algorithm for satisfiability
Algorithm 16: WalkSAT
input : C , a set of propositional clauses; p, probability of random-walk,typically 0.5; N maximum flips allowed
output: A satisfying model or failuremodel a random assignment of T/F to symbols in C . ;for i = 1 to N do
if model satisfies C then return model ;clause a randomly clause in C that is false in model ;if sample true with probability p then
flip the value in model of a randomly selected symbol from clause ;else
flip whichever symbol in clause maximizes the number of satisfiedclauses
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 128 / 396
-
Logical Agents Inference by Theorem Proving
Propositional Theorem Proving I
Use inference rules and equivalence-relationships to produce a chain ofconclusions which leads to the desired goal sentence.
Inference Rules
,
Modus Ponens (( ) ) (4.8)
And-Elimination ( ) (4.9)
Monotonicity of Logical Systems
The set of entailed sentences can only increase as information is added tothe KB. If KB then KB Search for Proving
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 129 / 396
-
Logical Agents Inference by Theorem Proving
Propositional Theorem Proving II
I Initial State: The initial KB.
I Action: All inference rules applied to all the sentences that match thetop half of the inference rule.
I Result: The application of an action results in adding the sentence inthe bottom half of the inference rule to the KB.
I Goal: The sentence were trying to prove.
The search can be performed by e.g. IDS. This search is sound, but is itcomplete?
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 130 / 396
-
Logical Agents Inference by Resolution
Resolution
Applies to clauses: disjunctions of literals. The inference-rule calledresolution leads to a complete inference algorithm when combined with acomplete search algorithm.
s1 . . . sk , sis1 . . . si1 si+1 . . . sk unit resolution rule (4.10)
(4.11)
If si and mj are complementary literals, the full resolution rule states:
s1 . . . sk , m1 . . . mns1 . . . si1 si+1 . . . sk m1 . . . mj1 mj+1 . . . mn
(4.12)
To show soundness, consider the two possible truth values of si . Theresulting clause after resolution should contain only one copy of eachliteral: removal of multiple copies is called factoring.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 131 / 396
-
Logical Agents Inference by Resolution
Completeness of the Resolution Algorithm I
Remark 18 (Caution)
When resolving (A B C ) and (A B), the resolvent is eitherB B C or A A C , both of which are equivalent to True . Theresolvent is not C . You can validate
(A B C ) (A B) 2 C
by a truth-table.
Definition 19 (Resolution Closure RC (S))
The set of all clauses derivable by repeated application of resolution to aset of clauses S .
Definition 20 (Resolution Applied to Contradicting Clauses)
An empty-clause results from applying resolution to contradicting clauses,e.g. to A and A.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 132 / 396
-
Logical Agents Inference by Resolution
Completeness of the Resolution Algorithm II
Theorem 21 (Ground Resolution Theorem)
If a set of clauses is unsatisfiable, then the resolution closure of thoseclauses contains the empty clause.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 133 / 396
-
Logical Agents Inference by Resolution
Explicit Model Construction when Empty-Clause / RC (S)Algorithm 17: SatisfyingModelConstruction
input : S , a set of propositional clauses;RC (S), the set of clauses which is the resolution-closure of S and
does not contain the null-clauseoutput: A satisfying model[P1, . . . ,Pn] The list of all symbols in S ;for i = 1 to n do
Find a clause RC (S) s.t. = (Pi False . . . False ) aftersubstituting P1 . . .Pi1 assigned in previous iterations ;if such a clause found then
Pi False ;else
Pi True ;return The constructed model [P1, . . . ,Pn].
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 134 / 396
-
Logical Agents Inference by Resolution
A Worked-out Example
I Let the sentence S consist of the following clausesC1 : X Y Z , C2 : Z R S , C3 : S T .
I Its closure RC (S) contains, in addition to S , (using G to denoteresolution) C4 = C1 G C2 : X Y R S ,C5 = C2 G C3 : Z R T , andC6 = C1 G C5 : X Y R T .
I We now trace the Algo. 17 for [P1, . . . ,Pn] = [X ,Y ,R,T ,S ,Z ]. Inthe for-loop over i , the following selections will be made:
I i=1: X = True .I i=2: Y = True .I i=3: R = True .I i=4: T = False , due to C6 under previous assignments.I i=5: S = True .I i=6: Z = False , due to C1 under previous assignments.
It can be verified, that under this model, all clauses of RC (S) areTrue .
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 135 / 396
-
Logical Agents Inference by Resolution
Proof of the Ground Resolution Theorem I
I Proof by contraposition: we prove that if the closure RC (S) does notcontain the empty-clause, then S is satisfiable. One such modelsatisfying S , which is in CNF, can be recursively constructed byassigning truth-values to all symbols [P1, . . . ,Pn] in S using theAlgo. 17 SatisfyingModelConstruction.
I Algo. SatisfyingModelConstruction produces a valid modelfor S , i.e. all of its clauses are true in this model. To prove this,assume the opposite: at some iteration i = k of the for-loop inAlgo. 17, the assignment to Pk causes a clause C of RC (S) tobecome false for the first time. For this to occur,C = (false . . . false Pk) or C = (false . . . false Pk). Ifonly one of these two is present in RC (S), then the assignment rulechooses the appropriate value for Pk to make C true.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 136 / 396
-
Logical Agents Inference by Resolution
Proof of the Ground Resolution Theorem II
I The problem occurs if both are in RC (S). But in this case, theirresolvent (false . . . false ) also has to be in RC (S), which meansthat the resolvent is already false by the assignment P1, . . . ,Pk1.This contradicts our assumption that the first falsified clause appearsat stage k. Thus, the construction never falsifies a clause in RC (S)-it thus produces a valid model for RC (S) and in particular, for S .
I Therefore, this proves that if the closure RC (S) does not contain theempty-clause, then S is satisfiable. It also proves its contraposition,namely, the Ground Resolution Theorem.
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 137 / 396
-
Logical Agents Inference by Resolution
A Resolution Algorithm for Inferring Entailment
Algorithm 18: PL-Resolution(KB, )
input: KB, a knowledge-base; , a sentence; symbols; modelclauses the set of clauses in the CNF of (KB ) ;N {} ;while true do
for clause-pair Ci ,Cj clauses doresolvents Resolve(Ci ,Cj) ;if resolvents contains the empty-clause then return true ;N N resolvents
if N clauses then return false ;clauses clauses N
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 138 / 396
-
Logical Agents Inference by Resolution
Wumpus World
P2,1 B1,1 B1,1 P1,2 P2,1 P1,2 B1,1 B1,1 P1,2
P2,1 P1,2P1,2 P2,1 P2,1 B1,1 P2,1 B1,1 P1,2 P2,1 P1,2B1,1 P1,2 B1,1
^
^
^
^^ ^ ^
^ ^ ^
^
^
Figure 29: CNF of B1,1 (P1,2 P2,1) along with the observation B1,1. Itentails P1,2
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 139 / 396
-
Logical Agents Inference with Horn Clauses
Definition 22 (Definite Clause)
A clause with only one positive literal. Every definite clause can be writtenas an implication. Example: (A B C ) (B C A).Definition 23 (Horn Clause)
I A clause with at most one positive literal. Includes definite clauses.
I Horn clauses are closed under resolution. Why?
I Horn clauses with no positive literals are called goal clauses.
I Inference with Horn clauses can be done with forward or backwardchaining. Deciding entailment with Horn clauses can be done in timethat is linear in size of the KB!
Kaustubh Pathak (Jacobs University Bremen) Artificial Intelligence December 6, 2011 140 / 396
-
Logical Agents Inference with Horn Clauses
Definition 22 (Definite Clause)
A clause with only one positive literal. Every definite clause can be writtenas