Title: Sessions 1
1Sessions 1 2Introduction to AIPlanning
Search
- CSE 592
- Applications of Artificial Intelligence
- Henry Kautz
- Winter 2003
2What is Intelligence?What is Artificial
Intelligence?
3What is Artificial Intelligence?
- The study of the principles by which natural or
artificial machines manipulate knowledge - how knowledge is acquired
- how goals are generated and achieved
- how concepts are formed
- how collaboration is achieved
4. . . Exactly what the computer provides is the
ability not to be rigid and unthinking but,
rather, to behave conditionally. That is what it
means to apply knowledge to action It means to
let the action taken reflect knowledge of the
situation, to be sometimes this way, sometimes
that, as appropriate. . . . -Allen Newell
5- Classical AI
- Disembodied Intelligence
- Autonomous Systems
- Embodied Intelligence
6Classical AI
- The principles of intelligence are separate from
any hardware / software / wetware implementation - logical reasoning
- probabilistic reasoning
- strategic reasoning
- diagnostic reasoning
- Look for these principles by studying how to
perform tasks that require intelligence
7Success Story Medical Expert Systems
- Mycin (1980)
- Expert level performance in diagnosis of blood
infections - Today 1,000s of systems
- Everything from diagnosing cancer to designing
dentures - Often outperform doctors in clinical trials
- Major hurdle today non-expert part
doctor/machine interaction
8Success StoryChess
- I could feel I could smell a new kind of
intelligence across the table- Kasparov
- Examines 5 billion positions / second
- Intelligent behavior emerges from brute-force
search
9Autonomous Systems
- In the 1990s there was a growing concern that
work in classical AI ignored crucial scientific
questions - How do we integrate the components of
intelligence (e.g. learning planning)? - How does perception interact with reasoning?
- How does the demand for real-time performance in
a complex, changing environment affect the
architecture of intelligence?
10- Provide a standard problem where a wide range of
technologies can be integrated and examined - By 2050, develop a team of fully autonomous
humanoid robots that can win against the human
world champion team in soccer.
11Started January 1996 Launch October 15th,
1998 Experiment May 17-21
courtesy JPL
12Speed Capacity
13Not Speed Alone
- Speech Recognition
- Word spotting feasible today
- Continuous speech rapid progress
- Turns out that low level signal not as
ambiguous as we once thought - Translation / Interpretation / Question-answering
- Very limited progress
- The spirit is willing but the flesh is weak.
(English) - The vodka is good but the meat is rotten.
(Russian)
14Varieties of Knowledge
- What kinds of knowledge required to understand
- Time flies like an arrow.
- Fruit flies like a banana.
- Fruit flies like a rock.
15Historic Perspective
- 1940's - 1960's Artificial neural networks
- McCulloch Pitts 1943
- 1950's - 1960's Symbolic information processing
- General Problem Solver Simon Newell
- "Weak methods for search and learning
- 1969 - Minsky's Perceptrons
- 1940s 1970s Control theory for adaptive
(learning) systems - USSR Cybernetics Norbert Weiner
- Japan Fuzzy logic
- 1970's 1980s Expert systems
- Knowledge is power" Ed Feigenbaum
- Logical knowledge representation
- AI Boom
- 1985 2000 A million flowers bloom
- Resurgence of neural nets backpropagation
- Control theory OR Pavlovian conditioning
reinforcement learning - Probabilistic knowledge representation Bayesian
Nets Judea Pearl - Statistical machine learning
- 2000s Towards a grand unification
16 In sum, technology can be controlled
especially if it is saturated with intelligence
to watch over how it goes, to keep accounts, to
prevent errors, and to provide wisdom to each
decision. -Allen Newell
17Course Mechanics
- Topics
- What is AI?
- Search, Planning, and Satisfiability
- Bayesian Networks
- Statistical Natural Language Processing
- Decision Trees and Neural Networks
- Data Mining Pattern Discovery in Databases
- Planning under Uncertainty and Reinforcement
Learning - Autonomous Systems Case Studies
- Project Presentations
- Assignments
- 4 homeworks
- Significant project presentation
- Information
- http//www.cs.washington.edu/education/courses/592
/03wi/
18Planning Search
- Search the foundation for all work in AI
- Deduction
- Probabilistic reasoning
- Perception
- Learning
- Game playing
- Expert systems
- Planning
RN Ch 3, 4, 5, 11
19Planning
- Input
- Description of set of all possible states of the
world (in some knowledge representation language) - Description of initial state of world
- Description of goal
- Description of available actions
- May include costs for performing actions
- Output
- Sequence of actions that convert the initial
state into one that satisfies the goal - May wish to minimize length or cost of plan
20Classical Planning
- Simplifying assumptions
- Atomic time
- Actions have deterministic effects
- Agent knows complete initial state of the world
- Agent knows the effects of all actions
- States are either goal or non-goal states, rather
than numeric utilities or rewards - Agent is sole cause of change
- All these assumptions can be relaxed, as we will
see by the end of the course
21Example Route Planning
- Input
- State set
- Start state
- Goal state test
- Operators
- Output
22Example Robot Control (Blocks World)
- Input
- State set
- Start state
- Goal state test
- Operators (and costs)
- Output
23Implicitly Generated Graphs
- Planning can be viewed as finding paths in a
graph, where the graph is implicitly specified by
the set of actions - Blocks world
- vertex relative positions of all blocks
- edge robot arm stacks one block
How many states for K blocks?
stack(blue,table)
stack(green,blue)
stack(blue,red)
stack(green,red)
stack(green,blue)
24Missionaries and Cannibals
- 3 missionaries M1, M2, M3
- 3 cannibals C1, C2, C3
- Cross in a two person boat, so that missionaries
never outnumber cannibals on either shore - What is a state? How many states?
M1 M2 M3
C1 C2 C3
25STRIPS Representation
- Description of initial state of world
- Set of propositions that completely describes a
world - (block a) (block b) (block c) (on-table a)
(on-table b) (clear a) (clear b) (clear c)
(arm-empty) - Description of goal (i.e. set of desired worlds)
- Set of propositions that partially describes a
world - (on a b) (on b c)
- Description of available actions
26How Represent Actions?
- World set of propositions true in that world
- Actions
- Precondition conjunction of propositions
- Effects propositions made true propositions
made false (deleted from the state description)
operator stack_B_on_R precondition (on B Table)
(clear R) effect (on B R) (not (clear R))
27Action Schemata
- Compact representation of a large set of actions
(operator pickup parameters
((block ?ob1)) precondition (and (clear
?ob1) (on-table ?ob1)
(arm-empty)) effect
(and (not (on-table ?ob1)) (not
(clear ?ob1)) (not
(arm-empty)) (holding ?ob1)))
28Search Algorithms
- Backtrack Search
- DFS
- BFS / Dijkstras Algorithm
- Iterative Deepening
- Best-first search
- A
- Constraint Propagation
- Forward Checking
- k-Consistency
- DPLL Resolution
- Local Search
- Hillclimbing
- Simulated annealing
- Walksat
29Depth First Search
- Maintain stack of nodes to visit
- Evaluation
- Complete?
- Time Complexity?
- Space Complexity?
Not for infinite spaces
a
O(bd)
b
c
O(d)
g
h
d
e
f
30Breadth First Search
- Maintain queue of nodes to visit
- Evaluation
- Complete?
- Time Complexity?
- Space Complexity?
Yes
a
O(bd)
b
c
O(bd)
g
h
d
e
f
31Iterative Deepening Search
- DFS with limit incrementally grow limit
- Evaluation
- Complete?
- Time Complexity?
- Space Complexity?
Yes
a
a
O(bd)
b
b
c
c
O(d)
g
h
d
e
f
32Dijkstras Shortest Path Algorithm
- Like breadth-first search, but uses a priority
queue instead of a FIFO queue - Always select (expand) the vertex that has a
lowest-cost path from the initial state - Correctly handles the case where the lowest-cost
path to a vertex is not the one with fewest edges - Handles actions planning with costs, with same
advantages / disadvantages of BFS
33Pseudocode for Dijkstra
- Initialize the cost of each vertex to ?
- costs 0
- heap.insert(s)
- While (! heap.empty())
- n heap.deleteMin()
- For (each vertex a which is adjacent to n along
edge e) - if (costn edge_coste lt costa) then
- cost a costn edge_coste
- previous_on_path_toa n
- if (a is in the heap) then heap.decreaseKey(a)
- else heap.insert(a)
34Important Features
- Once a vertex is removed from the head, the cost
of the shortest path to that node is known - While a vertex is still in the heap, another
shorter path to it might still be found - The shortest path itself from s to any node a can
be found by following the pointers stored in
previous_on_path_toa
35Edsger Wybe Dijkstra (1930-2002)
- Invented concepts of structured programming,
synchronization, weakest precondition, and
semaphores - 1972 Turing Award
- In their capacity as a tool, computers will be
but a ripple on the surface of our culture. In
their capacity as intellectual challenge, they
are without precedent in the cultural history of
mankind.
36Heuristic Search
- A heuristic is
- Function from a state to a real number
- Low number means state is close to goal
- High number means state is far from the goal
Designing a good heuristic is very
important! (And often hard! Later we will see
how some heuristics can be created automatically)
37An Easier Case
- Suppose you live in Manhattan what do you do?
S
52nd St
G
51st St
50th St
10th Ave
9th Ave
8th Ave
7th Ave
6th Ave
5th Ave
4th Ave
3rd Ave
2nd Ave
38Best-First Search
- The Manhattan distance (? x ? y) is an estimate
of the distance to the goal - a heuristic value
- Best-First Search
- Order nodes in priority to minimize estimated
distance to the goal h(n) - Compare BFS / Dijkstra
- Order nodes in priority to minimize distance from
the start
39Best First in Action
- Suppose you live in Manhattan what do you do?
S
52nd St
G
51st St
50th St
10th Ave
9th Ave
8th Ave
7th Ave
6th Ave
5th Ave
4th Ave
3rd Ave
2nd Ave
40Problem 1 Led Astray
- Eventually will expand vertex to get back on the
right track
S
G
52nd St
51st St
50th St
10th Ave
9th Ave
8th Ave
7th Ave
6th Ave
5th Ave
4th Ave
3rd Ave
2nd Ave
41Problem 2 Optimality
- With Best-First Search, are you guaranteed a
shortest path is found when - goal is first seen?
- when goal is removed from priority queue (as with
Dijkstra?)
42Sub-Optimal Solution
- No! Goal is by definition at distance 0 will be
removed from priority queue immediately, even if
a shorter path exists!
(5 blocks)
S
52nd St
h2
h5
G
h4
51st St
h1
9th Ave
8th Ave
7th Ave
6th Ave
5th Ave
4th Ave
43Synergy?
- Dijkstra / Breadth First guaranteed to find
optimal solution - Best First often visits far fewer vertices, but
may not provide optimal solution - Can we get the best of both?
44A (A star)
- Order vertices in priority queue to minimize
- (distance from start) (estimated distance to
goal) - f(n) g(n) h(n)
- f(n) priority of a node
- g(n) true distance from start
- h(n) heuristic distance to goal
45Optimality
- Suppose the estimated distance (h) is always
less than or equal to the true distance to the
goal - heuristic is a lower bound on true distance
- heuristic is admissible
- Then when the goal is removed from the priority
queue, we are guaranteed to have found a shortest
path!
46Problem 2 Revisited
vertex g(n) h(n) f(n)
52nd 9th 0 5 5
S
(5 blocks)
52nd St
G
51st St
50th St
9th Ave
8th Ave
7th Ave
6th Ave
5th Ave
4th Ave
47Problem 2 Revisited
vertex g(n) h(n) f(n)
52nd 4th 5 2 7
51st 9th 1 4 5
S
(5 blocks)
52nd St
G
51st St
50th St
9th Ave
8th Ave
7th Ave
6th Ave
5th Ave
4th Ave
48Problem 2 Revisited
vertex g(n) h(n) f(n)
52nd 4th 5 2 7
51st 8th 2 3 5
50th 9th 2 5 7
S
(5 blocks)
52nd St
G
51st St
50th St
9th Ave
8th Ave
7th Ave
6th Ave
5th Ave
4th Ave
49Problem 2 Revisited
vertex g(n) h(n) f(n)
52nd 4th 5 2 7
51st 7th 3 2 5
50th 9th 2 5 7
50th 8th 3 4 7
S
(5 blocks)
52nd St
G
51st St
50th St
9th Ave
8th Ave
7th Ave
6th Ave
5th Ave
4th Ave
50Problem 2 Revisited
vertex g(n) h(n) f(n)
52nd 4th 5 2 7
51st 6th 4 1 5
50th 9th 2 5 7
50th 8th 3 4 7
50th 7th 4 3 7
S
(5 blocks)
52nd St
G
51st St
50th St
9th Ave
8th Ave
7th Ave
6th Ave
5th Ave
4th Ave
51Problem 2 Revisited
vertex g(n) h(n) f(n)
52nd 4th 5 2 7
51st 5th 5 0 5
50th 9th 2 5 7
50th 8th 3 4 7
50th 7th 4 3 7
S
(5 blocks)
52nd St
G
51st St
50th St
9th Ave
8th Ave
7th Ave
6th Ave
5th Ave
4th Ave
52Problem 2 Revisited
vertex g(n) h(n) f(n)
52nd 4th 5 2 7
50th 9th 2 5 7
50th 8th 3 4 7
50th 7th 4 3 7
S
(5 blocks)
52nd St
G
51st St
50th St
9th Ave
8th Ave
7th Ave
6th Ave
5th Ave
4th Ave
DONE!
53What Would Dijkstra Have Done?
S
(5 blocks)
52nd St
G
51st St
50th St
49th St
48th St
47th St
9th Ave
8th Ave
7th Ave
6th Ave
5th Ave
4th Ave
54Proof of A Optimality
- A terminates when G is popped from the heap.
- Suppose G is popped but the path found isnt
optimal - priority(G) gt optimal path length c
- Let P be an optimal path from S to G, and let N
be the last vertex on that path that has been
visited but not yet popped. - There must be such an N, otherwise the optimal
path would have been found. - priority(N) g(N) h(N) ? c
- So N should have popped before G can pop.
Contradiction.
non-optimal path to G
S
G
undiscovered portion of shortest path
portion of optimal path found so far
N
55What About Those Blocks?
- Distance to goal is not always physical
distance - Blocks world
- distance number of stacks to perform
- heuristic lower bound number of blocks out of
place
out of place 1, true distance to goal 3
563-Blocks State Space Graph
ABCh2
CABh3
BACh2
ABCh1
CBAh3
A CBh2
BCAh1
BC Ah3
CB Ah3
C A Bh3
AC Bh3
BA Ch2
AB Ch0
start
goal
573-Blocks Best First Solution
ABCh2
CABh3
BACh2
ABCh1
CBAh3
A CBh2
BCAh1
BC Ah3
CB Ah3
C A Bh3
AC Bh3
BA Ch2
AB Ch0
start
goal
583-Blocks BFS Solution
ABCh2
expanded, but not in solution
CABh3
BACh2
ABCh1
CBAh3
A CBh2
BCAh1
BC Ah3
CB Ah3
C A Bh3
AC Bh3
BA Ch2
AB Ch0
start
goal
593-Blocks A Solution
ABCh2
expanded, but not in solution
CABh3
BACh2
ABCh1
CBAh3
A CBh2
BCAh1
BC Ah3
CB Ah3
C A Bh3
AC Bh3
BA Ch2
AB Ch0
start
goal
60Maze Runner Demo
61Other Real-World Applications
- Routing finding computer networks, airline
route planning - VLSI layout cell layout and channel routing
- Production planning just in time optimization
- Protein sequence alignment
- Many other NP-Hard problems
- A class of problems for which no exact polynomial
time algorithms exist so heuristic search is
the best we can hope for
62Importance of Heuristics
- h1 number of tiles in the wrong place
- h2 sum of distances of tiles from correct
location
D IDS A(h1) A(h2) 2 10
6 6 4 112 13 12 6
680 20 18 8 6384 39 25 10
47127 93 39 12 364404 227
73 14 3473941 539 113 18
3056 363 24 39135 1641
63A STRIPS Planning
- Is there some general way to automatically create
a heuristic for a given set of STRIPS operators? - Count number of false goal propositions in
current state - Admissible?
- Delete all preconditions from actions, solve
easier relaxed problem (why easier?), use length - Admissible?
- Delete negative effects from actions, solve
easier relaxed problem, use length - Admissible?
64Planning as A Search
- HSP (Geffner Bonet 1999), introduced admissible
ignore negative effects heuristic - FF (Hoffman Nebel 2000), used a modified
non-admissible heuristic - Often dramatically faster, but usually
non-optimal solutions found - Best overall performance AIPS 2000 planning
competition
65Search Algorithms
- Backtrack Search
- DFS
- BFS / Dijkstras Algorithm
- Iterative Deepening
- Best-first search
- A
- Constraint Propagation
- Forward Checking
- k-Consistency
- DPLL Resolution
- Local Search
- Hillclimbing
- Simulated annealing
- Walksat
66Guessing versus Inference
- All the search algorithms weve seen so far are
variations of guessing and backtracking - But we can reduce the amount of guesswork by
doing more reasoning about the consequences of
past choices - Example planning a trip
- Idea
- Problem solving as constraint satisfaction
- As choices (guesses) are made, propagate
constraints
67Map Coloring
68CSP
- V is a set of variables v1, v2, , vn
- D is a set of finite domains D1, D2, , Dn
- C is a set of constraints C1, C2, , Cm
- Each constraint specifies a restriction over
joint values of a subset of the variables - E.g.
- v1 is Spain, v2 is France, v3 is Germany,
- Di Red, Blue, Green for all i
- For each adjacent vi, vj there is a constraint
Ck - (vi,vj) ? (R,G), (R,B), (G,R), (G,B), (B,R),
(B,G)
69Variations
- Find a solution that satisfies all constraints
- Find all solutions
- Find a tightest form for each constraint
- (v1,v2) ? (R,G), (R,B), (G,R), (G,B), (B,R),
(B,G) - ?
- (v1,v2) ? (R,G), (R,B), (B,G)
- Find a solution that minimizes some additional
objective function
70Chinese Dinner Constraint Network
Must be HotSour
Soup
No Peanuts
Chicken Dish
Appetizer
Total Cost lt 30
No Peanuts
Pork Dish
Vegetable
Rice
Seafood
Not Both Spicy
Not Chow Mein
71Exploiting CSP Structure
- Interleave inference and guessing
- At each internal node
- Select unassigned variable
- Select a value in domain
- Backtracking try another value
- Branching factor?
- At each node
- Propagate Constraints
72Running Example 4 Queens
Constraints
- Variables
- Q1 ? 1,2,3,4
- Q2 ? 1,2,3,4
- Q3 ? 1,2,3,4
- Q3 ? 1,2,3,4
Q1 Q2
1 3
1 4
2 4
3 1
4 1
4 2
Q
Q
Q
Q
73Constraint Checking
Q
Q
x
Q x
x
Q x
x x
Q x x
Q
x
x
Q x
Q
x
x Q
Q x x
Q x
x x
x Q x
Q x x x
Takes 5 guesses to determine first guess was wrong
74Forward Checking
x
x
x
Q x x x
x x
Q x x
x x x
Q x x x
When variable is set, immediately remove
inconsistent values from domains of other
variables
Q x x
x x
x x
Q x x x
Q x x
x x x
x Q x
Q x x x
Takes 3 guesses to determine first guess was wrong
75Arc Consistency
x
x
x
Q x x x
x
x
x
Q x x x
x
x
x x
Q x x
x x
x x
x x
Q x x
- Iterate forward checking
- Propagations
- Q33 inconsistent with Q4 ? 2,3,4
- Q21 and Q22 inconsistent with Q3 ? 1
Inference alone determines first guess was wrong!
76Huffman-ClowesLabeling
-
77Waltzs Filtering Arc-Consistency
- Lines variables
- Conjunctions constraints
- Initially Di ,-, ?, ? )
- Repeat until no changes
- Choose edge (variable)
- Delete labels on edge not consistent with both
endpoints
78No labeling!
79Path Consistency
- Path consistency (3-consistency)
- Check every triple of variables
- More expensive!
- k-consistency
- n-consistency backtrack-free search
80Variable and Value Selection
- Select variable with smallest domain
- Minimize branching factor
- Most likely to propagate most constrained
variable heuristic - Which values to try first?
- Most likely value for solution
- Least propagation! Least constrained value
- Why different?
- Every constraint must be eventually satisfied
- Not every value must be assigned to a variable!
- Tie breaking?
- In general randomized tie breaking best less
likely to get stuck on same bad pattern of choices
81CSPs in the real world
- Scheduling Space Shuttle Repair
- Transportation Planning
- Computer Configuration
- ATT CLASSIC Configurator
- 5ESS Switching System
- Configuring new orders 2 months ? 2 hours
82Quasigroup Completion Problem (QCP)
Given a partial assignment of colors (10 colors
in this case), can the partial quasigroup (latin
square) be completed so we obtain a full
quasigroup? Example
32 preassignment
(Gomes Selman 97)
83QCP Example Use Routers in Fiber Optic Networks
Dynamic wavelength routing in Fiber Optic
Networks can be directly mapped into the
Quasigroup Completion Problem.
(Barry and Humblet 93, Cheung et al. 90, Green
92, Kumar et al. 99)
84QCP as a CSP
- Variables -
-
- Constraints -
row
column
85Hill Climbing
- Idea
- Always choose best child,no backtracking
- Evaluation
- Complete?
- Space Complexity?
- Complexity of random restart hillclimbing, with
success probability P
86Simulated Annealing / Random Walk
- Objective avoid local minima
- Technique
- For the most part use hill climbing
- Occasionally take non-optimal step
- Annealing Reduce probability (non-optimal) over
time - Comparison to Hill Climbing
- Completeness?
- Speed?
- Space Complexity?
Temperature Objective
Time ?
87Backtracking with Randomized Restarts
- Idea
- If backtracking algorithm does not find solution
quickly, it is like to be stuck in the wrong part
of the search space - Early decisions were bad!
- So kill the run after T seconds, and restart
- Requires randomized heuristic, so choices not
always the same - Why does it often work?
- Many problems have a small set of backdoor
variables guess them on a restart, and your are
done! (Andrew, Selman, Gomes 2003) - Completeness?
88Demos!
- N-Queens
- Backtracking vs. Local Search
- Quasigroup Completion
- Randomized Restarts
- Travelling Salesman
- Simulated Annealing
89Exercise
- Peer interviews Real-world constraint
satisfaction problems - Break into pairs
- 7 minute interview example of needing to solve
a CSP type problem (work or life). Interviewer
takes notes - Describe problem
- What techniques actually used
- Any techniques from class that could have been
used? - Switch roles
- A few teams present now
- Hand in notes (MSR have someone collect and
mail to me at dept)
90Planning as CSP
- Phase 1 - Convert planning problem in a CSP
- Choose a fixed plan length
- Boolean variables
- Action executed at a specific time point
- Proposition holds at a specific time point
- Constraints
- Initial conditions true in first state, goals
true in final state - Actions do not interfere
- Relation between action, preconditions, effects
- Phase 2 - Solution Extraction
- Solve the CSP
91Planning Graph Representation of CSP
Precondition constraints
Effect constraints
Proposition Init State
Action Time 1
Proposition Time 1
Action Time 2
92Constructing the planning graph
- Initial proposition layer
- Just the initial conditions
- Action layer i
- If all of an actions preconditionss are in i-1
- Then add action to layer I
- Proposition layer i1
- For each action at layer i
- Add all its effects at layer i1
93Mutual Exclusion
- Actions A,B exclusive (at a level) if
- A deletes Bs precondition, or
- B deletes As precondition, or
- A B have inconsistent preconditions
- Propositions P,Q inconsistent (at a level) if
- All ways to achieve P exclude all ways to achieve
Q - Constraint propagation (arc consistency)
- Can force variables to become true or false
- Can create new mutexes
94Solution Extraction
- For each goal G at last time slice N
- Solve( G, N )
- Solve( G, t )
- CHOOSE action A making G true _at_t that is not
mutex with a previously chosen action - If no such action, backtrack to last choice point
- For each precondition P of A
- Solve(P, t-1)
95Graphplan
- Create level 0 in planning graph
- Loop
- If goal ? contents of highest level (nonmutex)
- Then search graph for solution
- If find a solution then return and terminate
- Else Extend graph one more level
A kind of double search forward direction checks
necessary (but insufficient) conditions for a
solution, ... Backward search verifies...
96Dinner Date
Initial Conditions (and (cleanHands)
(quiet)) Goal (and (noGarbage)
(dinner) (present)) Actions (operator carry
precondition effect (and (noGarbage)
(not (cleanHands))) (operator fire
precondition effect (and (noGarbage)
(not (paper))) (operator cook precondition
(cleanHands) effect (dinner)) (operator
wrap precondition (paper) effect
(present))
97Planning Graph
noGarb cleanH paper dinner
present
cleanH paper
carry fire cook wrap
98Are there any exclusions?
noGarb cleanH paper dinner
present
cleanH paper
carry noop fire noop cook wrap
99Do we have a solution?
noGarb cleanH paper dinner
present
cleanH paper
carry noop fire noop cook wrap
100Extend the Planning Graph
noGarb cleanH paper dinner
present
cleanH paper
noGarb cleanH paper dinner
present
noop carry noop fire noop cook noop wrap noop
carry noop fire noop cook wrap
101One (of 4) Solutions
noGarb cleanH paper dinner
present
cleanH paper
noGarb cleanH paper dinner
present
noop carry noop fire noop cook noop wrap noop
carry noop fire noop cook wrap
102Search Algorithms
- Backtrack Search
- DFS
- BFS / Dijkstras Algorithm
- Iterative Deepening
- Best-first search
- A
- Constraint Propagation
- Forward Checking
- k-Consistency
- DPLL Resolution
- Local Search
- Hillclimbing
- Simulated annealing
- Walksat
103Representing Knowledge in Propositional Logic
104Basic Idea of Logic
- By starting with true assumptions, you can deduce
true conclusions.
105Truth
- Francis Bacon (1561-1626)
- No pleasure is comparable to the standing upon
the vantage-ground of truth. - Thomas Henry Huxley (1825-1895)
- Irrationally held truths may be more harmful than
reasoned errors. - John Keats (1795-1821)
- Beauty is truth, truth beauty that is all
- Ye know on earth, and all ye need to know.
- Blaise Pascal (1623-1662)
- We know the truth, not only by the reason, but
also by the heart. - François Rabelais (c. 1490-1553)
- Speak the truth and shame the Devil.
- Daniel Webster (1782-1852)
- There is nothing so powerful as truth, and often
nothing so strange.
106Propositional Logic
- Ingredients of a sentence
- Propositions (variables)
- Logical Connectives ?, ?, ?, ?
- literal a variable or a negated variable
- A possible world assigns every proposition the
value true or false - A truth value for a sentence can be derived from
the truth value of its propositions by using the
truth tables of the connectives - The meaning of a sentence is the set of possible
worlds in which it is true
107Truth Tables for Connectives
?
?
0 0
0 1
1 0
1 1
0
1
?
?
0 0
0 1
1 0
1 1
0 0
0 1
1 0
1 1
108Special Syntactic Forms
- General PL
- ((q?? r) ? s)) ? ? (s ? t)
- Conjunction Normal Form (CNF)
- (? q ? r ? s ) ? (? s ? ? t)
- Set notation (? q, r, s ), (? s, ? t)
- empty clause () false
- Binary clauses 1 or 2 literals per clause
- (? q ? r) (? s ? ? t)
- Horn clauses 0 or 1 positive literal per clause
- (? q ? ? r ? s ) (? s ? ? t)
- (q?r) ? s (s?t) ? false
109Satisfiability, Validity, Entailment
- S is satisfiable if it is true in some world
- Example
- S is unsatisfiable if it is false all worlds
- S is valid if it is true in all worlds
- S1 entails S2 if wherever S1 is true S2 is true
110Reasoning Tasks
- Model finding
- KB background knowledge
- S description of problem
- Show (KB ? S) is satisfiable
- A kind of constraint satisfaction
- Deduction
- S question
- Prove that KB ? S
- Two approaches
- Rules to derive new formulas from old (inference)
- Show (KB ? ? S) is unsatisfiable
111Inference
- Mechanical process for computing new sentences
- Resolution
- (p ? ?), (? p ? ?) ?R (? ? ?)
- Correctness
- If S1 ?R S2 then S1 ? S2
- Refutation Completeness
- If S is unsatisfiable then S ?R ()
112Resolution
If the unicorn is mythical, then it is immortal,
but if it is not mythical, it is a mammal. If
the unicorn is either immortal or a mammal, then
it is horned. Prove the unicorn is horned. M
mythical I immortal A mammal H horned
113New Variable Trick
- Putting a formula in clausal form may increase
its size exponentially - But can avoid this by introducing dummy variables
- (a?b?c)?(d?e?f) ? (a?d),(a?e),(a?f),
- (b?d),(b?e),(b?f),
- (c?d),(c?e),(c?f)
- (a?b?c)?(d?e?f) ? (g?h),
- (?a??b??c?g),(?g?a),(?g?b),(?g?c),
- (?d??e??f?h),(?h?d),(?h?e),(?h?f)
- Dummy variables dont change satisfiability!
114DPLLDavis Putnam Loveland Logmann
- Model finding Backtrack search over space of
partial truth assignments
DPLL( wff ) Simplify wff for each unit
clause (Y) Remove clauses containing Y
if no clause left then return true
(satisfiable) Shorten clauses contain
? Y if empty clause then return false
Choose a variable Choose a value (0/1)
yields literal X if DPLL( wff, X ) return
true (satisfiable) else return DPLL(wff, ? X)
115DPLLDavis Putnam Loveland Logemann
- Backtrack search over space of partial truth
assignments
DPLL( wff ) Simplify wff for each unit
clause (Y) Remove clauses containing Y
if no clause left then return true
(satisfiable) Shorten clauses contain
? Y if empty clause then return false
Choose a variable Choose a value (0/1)
yields literal X if DPLL( wff, X ) return
true (satisfiable) else return DPLL(wff, ? X)
unit propagation arc consistency
116Horn Theories
- Recall the special case of Horn clauses
- (? q ? ? r ? s ), (? s ? ? t)
- ((q?r) ? s ), ((s?t) ? false)
- Many problems naturally take the form of such
if/then rules - If (fever) AND (vomiting) then FLU
- Unit propagation is refutation complete for Horn
theories - Good implementation linear time!
117DPLL
- Developed 1962 still the best complete
algorithm for propositional reasoning - State of the art solvers use
- Smart variable choice heuristics
- Clause learning at backtrack points,
determine minimum set of choices that caused
inconsistency, add new clause - Limited resolution (Agarwal, Kautz, Beame 2002)
- Randomized tie breaking restarts
- Chaff fastest complete SAT solver
- Created by 2 Princeton undergrads, for a summer
project! - Superscaler processor verification
- AI planning - Blackbox
118Exercise
- How could we represent the Quasigroup Completion
Problem as a Boolean formula in CNF form? - (take 10 minutes to sketch solution)
119WalkSat
- Local search over space of complete truth
assignments - With probability P flip any variable in any
unsat clause - With probability (1-P) flip best variable in any
unsat clause - Like fixed-temperature simulated annealing
- SAT encodings of QCP, N-Queens, scheduling
- Best algorithm for random K-SAT
- Best DPLL 700 variables
- Walksat 100,000 variables
120Random 3-SAT
- Random 3-SAT
- sample uniformly from space of all possible
3-clauses - n variables, l clauses
- Which are the hard instances?
- around l/n 4.3
121Random 3-SAT
- Varying problem size, n
- Complexity peak appears to be largely invariant
of algorithm - backtracking algorithms like Davis-Putnam
- local search procedures like GSAT
- Whats so special about 4.3?
122Random 3-SAT
- Complexity peak coincides with solubility
transition - l/n lt 4.3 problems under-constrained and SAT
- l/n gt 4.3 problems over-constrained and UNSAT
- l/n4.3, problems on knife-edge between SAT and
UNSAT
123Real-World Phase Transition Phenomena
- Many NP-hard problem distributions show phase
transitions - - job shop scheduling problems
- TSP instances from TSPLib
- exam timetables _at_ Edinburgh
- Boolean circuit synthesis
- Latin squares (alias sports scheduling)
- Hot research topic predicting hardness of a
given instance, using hardness to control
search strategy (Horvitz, Kautz, Ruan 2001-3)
124- Logical Reasoning about Time Change
- AKA
- Planning as Satisfiability
Salvidor Dali, Persistance of Memory
125Actions
- We want to relate changes in the world over time
to actions associated with those changes - How are actions represented?
- As functions from one state to another
- As predicates that are true in the state in which
they (begin to) occur
126Actions as Functions Situation Calculus
- On(cat, mat, S0)
- Happy(cat, S0)
- On(cat, mat, kick(S0))
- Happy(cat, kick(S0))
- Happy(cat, pet(kick(S0)))
- Branching time
kick
kick
pet
S0
kick
pet
pet
127Actions as PredicatesAction Calculus
- On(cat, mat, S0) ? Happy(S0)
- Kick(cat, S0)
- On(cat, mat, S1) ? ?Happy(CAT99, S1)
- Pet(CAT99, S1)
- On(CAT99, MAT37, S2) ? Happy(CAT99, S2)
- Linear time
S0
S1
S2
kick
pet
128Relating Actions to Preconditions Effects
- Strips notation
- Action Fly( plane, start, dest )
- Precondition Airplane(plane), City(start),
City(dest), At(plane, start) - Effect At(plane, dest), ? At(plane, start)
- Pure strips no negative preconditions!
- Need to represent logically
- An action requires its predications
- An action causes its effects
- Interfering actions do not co-occur
- Changes in the world are the result of actions.
129Preconditions Effects
- ? plane, start, dest, s . Fly(plane, start, dest,
s) ? At(plane, start, s) ?
Airplane(plane,s) ? City(start) ? City(dest) - Note state indexes on predicates that never
change not necessary. - ? plane, start, dest, s . Fly(plane, start, dest,
s) ? At(plane, dest, s1) - In action calculus, the logical representation of
requires and causes is the same! - Not a full blown theory of causation, but good
enough
130Interfering Actions
- Want to rule out
- Fly( PLANE32, NYC, DETROIT, S4) ? Fly( PLANE32,
NYC, DETROIT, S4) - Actions interfere if one changes a precondition
or effect of the other - They are mutually exclusive mutex
- ? p, c1, c2, c3, c4, s . Fly(p, c1, c2, s) ?
(c1 ? c3 ? c2 ? c4) ? ? Fly(p, c3, c4, s) - (Similar for any other actions Fly is mutex
with)
131Explanatory Axioms
- Dont want world to change by magic only
actions change things - If a proposition changes from true to false (or
vice-versa), then some action that can change it
must have occurred - plane, start, s . Airplane(plane) ? City(start)
At(plane,start,s) ? ?At(plane,city,s1) ?
? dest . City(dest) ? Fly(plane, start, dest,
s) - plane, dest, s . Airplane(plane) ? City(start)
?At(plane,dest,s) ? At(plane,dest,s1) ?
? start . City(start) ? Fly(plane, start, dest,
s)
132The Frame Problem
- General form of explanatory axioms
- p(s) ? ?p(s1) ? A1(s) ? A2(s) ? ? An(s)
- As a logical consequence, if none of these
actions occurs, the proposition does not change - ?A1(s) ? ?A2(s) ? ? ?An(s) ? p(s) ? p(s1)
- This solves the frame problem being able to
deduce what does not change when an action occurs
133Frame Problem in AI
- Frame problem identified by McCarthy in his first
paper on the situation calculus (1969) - 667 papers in researchindex !
- Lead to a (misguided?) 20 year effort to develop
non-standard logics where no frame axioms are
required (non-monotonic) - 7039 papers!
- 1990 - Haas and Schubert independently pointed
out that explanatory axioms are pretty easy to
write down
134Planning as Satisfiability
- Idea in action calculus assert that initial
state holds at time 0 and goal holds at some time
(in the future) - Axioms ? Initial ? ? s . Goal(s)
- Any model that satisfies these assertions and the
axioms for actions corresponds to a plan - Bounded model finding, i.e. satisfiability
testing - Assert goal holds at a particular time K
- Ground out (instantiate) the theory up to time K
- Try to find a model if so, done!
- Otherwise, increment K and repeat
135Reachability Analysis
- Problem many irrelevant propositions, large
formulas - Reachability analysis what propositions actually
connect to initial state or goal in K steps? - Graphplans plan graph computes reachable set!
- Blackbox (Kautz Selman 1999)
- Run graphplan to generate plan graph
- Translate plan graph to CNF formula
- Run any SAT solver
136Translation of Plan Graph
Act1
Pre1
Fact
Pre2
Act2
Fact ? Act1 ? Act2 Act1 ? Pre1 ? Pre2 Act1 ?
Act2
137Improved Encodings
- Translations of Logistics.a
- STRIPS ? Axiom Schemas ? SAT
- 3,510 variables, 16,168 clauses
- 24 hours to solve
- STRIPS ? Plan Graph ? SAT
- (Blackbox)
- 2,709 variables, 27,522 clauses
- 5 seconds to solve!
138Model-Based Diagnosis
- Idea
- Create a logical model of the correct functioning
of a device - When device is broken, observations model is
inconsistent - Create diagnosis by restoring consistency
139Simplified KB
- Knowledge Base
- SignalValueA ? ValveAok ? ValveAopen
- SignalValueB ? ValveBok ? ValveBopen
- SignalValueC ? ValveCok ? ValveCopen
- ValveAopen? ? EngineHasFuel
- ValveBopen? ? EngineHasFuel
- ValveCopen ? EngineHasOxy
- EngineHasFuel ? EngineHasOxy ? EngineFires
- Normal Assumptions
- ValveAok, ValveBok, ValveCok
- Direct Actions (cannot fail)
- SignalValveA, SignalValveB, SignalValveC
- Observed
- ? EngineFires
140Diagnosis 1
- Knowledge Base
- SignalValueA ? ValveAok ? ValveAopen
- SignalValueB ? ValveBok ? ValveBopen
- SignalValueC ? ValveCok ? ValveCopen
- ValveAopen? ? EngineHasFuel
- ValveBopen? ? EngineHasFuel
- ValveCopen ? EngineHasOxy
- EngineHasFuel ? EngineHasOxy ? EngineFires
- Normal Assumptions
- ValveAok, ValveBok, ValveCok
- Direct Actions (cannot fail)
- SignalValveA, SignalValveB, SignalValveC
- Observed
- ? EngineFires
Inconsistent by Unit Propagation
141Diagnosis 2
- Knowledge Base
- SignalValueA ? ValveAok ? ValveAopen
- SignalValueB ? ValveBok ? ValveBopen
- SignalValueC ? ValveCok ? ValveCopen
- ValveAopen? ? EngineHasFuel
- ValveBopen? ? EngineHasFuel
- ValveCopen ? EngineHasOxy
- EngineHasFuel ? EngineHasOxy ? EngineFires
- Normal Assumptions
- ValveAok, ValveBok, ValveCok
- Direct Actions (cannot fail)
- SignalValveA, SignalValveB, SignalValveC
- Observed
- ? EngineFires
Still Inconsistent
142Diagnosis 3
- Knowledge Base
- SignalValueA ? ValveAok ? ValveAopen
- SignalValueB ? ValveBok ? ValveBopen
- SignalValueC ? ValveCok ? ValveCopen
- ValveAopen? ? EngineHasFuel
- ValveBopen? ? EngineHasFuel
- ValveCopen ? EngineHasOxy
- EngineHasFuel ? EngineHasOxy ? EngineFires
- Normal Assumptions
- ValveAok, ValveBok, ValveCok
- Direct Actions (cannot fail)
- SignalValveA, SignalValveB, SignalValveC
- Observed
- ? EngineFires
Consistency Restored! Diagnosis Valve A and
Valve B broken (double fault)
143Diagnosis 4
- Knowledge Base
- SignalValueA ? ValveAok ? ValveAopen
- SignalValueB ? ValveBok ? ValveBopen
- SignalValueC ? ValveCok ? ValveCopen
- ValveAopen? ? EngineHasFuel
- ValveBopen? ? EngineHasFuel
- ValveCopen ? EngineHasOxy
- EngineHasFuel ? EngineHasOxy ? EngineFires
- Normal Assumptions
- ValveAok, ValveBok, ValveCok
- Direct Actions (cannot fail)
- SignalValveA, SignalValveB, SignalValveC
- Observed
- ? EngineFires
A different way to restore consistency Diagnosis
Valve C broken (single fault)
144- Diagnostic Engine for NASAs Deep Space One
- 2,000 variable CNF formula
- Real-time planning and diagnosis
145Beyond Logic
- Often you want most likely diagnosis rather than
all possible diagnoses - Can assign probabilities to sets of fault, and
search for most likely way to restore consistency - But suppose observations and model of the device
are also uncertain? - Next Probabilistic Reasoning in Bayesian Networks