Download Propositional Satisfiability Techniques - Automated Planning - Lecture Slides and more Slides Computer Science in PDF only on Docsity!
Chapter 7
Propositional Satisfiability Techniques
Lecture slides for
Automated Planning: Theory and Practice
Motivation
- Propositional satisfiability: given a boolean formula
- e.g., (P ∨ Q) ∧ (¬Q ∨ R ∨ S) ∧ (¬R ∨ ¬P),
does there exist a model
- i.e., an assignment of truth values to the propositions
that makes the formula true?
- This was the very first problem shown to be NP-complete
- Lots of research on algorithms for solving it
- Algorithms are known for solving all but a small subset in
average-case polynomial time
- Therefore,
- Try translating classical planning problems into satisfiability
problems, and solving them that way
Overall Approach
• A bounded planning problem is a pair ( P,n ):
- P is a planning problem; n is a positive integer
- Any solution for P of length n is a solution for ( P,n )
• Planning algorithm:
• Do iterative deepening like we did with Graphplan:
- for n = 0, 1, 2, …,
- encode ( P,n ) as a satisfiability problem Φ
- if Φ is satisfiable, then
- From the set of truth values that satisfies Φ, a solution plan can be constructed, so return it and exit
Notation
• For satisfiability problems we need to use propositional
logic
• Need to encode ground atoms into propositions
- For set-theoretic planning we encoded atoms into
propositions by rewriting them as shown here:
- Atom: at(r1,loc1)
- Proposition: at-r1-loc
• For planning as satisfiability we’ll do the same thing
- But we won’t bother to do a syntactic rewrite
- Just use at(r1,loc1) itself as the proposition
• Also, we’ll write plans starting at a 0 rather than a 1
- π = 〈 a 0 , a 1 , …, a (^) n –1〉
Encoding Planning Problems
- Encode ( P,n ) as a formula Φ such that
- π = 〈 a 0 , a 1 , …, an –1〉 is a solution for ( P,n ) if and only if Φ can be satisfied in a way that makes the fluents a 0 , …, an –1 true
- Let
- A = {all actions in the planning domain}
- S = {all states in the planning domain}
- L = {all literals in the language}
- Φ is the conjunct of many other formulas …
Formulas in Φ
- Formula describing the initial state:
- */* { l 0 | l ∈ s 0 } ∧ */* {¬ l 0 | l ∈ L – s 0 }
- Formula describing the goal:
- */* { l (^) n | l ∈ g + } ∧ */* {¬ l (^) n | l ∈ g – }
- For every action a in A and for i = 1, …, n , a formula describing what changes a would make if it were the i ’th step of the plan:
- a (^) i ⇒ */* { p (^) i | p ∈ Precond( a )} ∧ */* { ei +1 | e ∈ Effects( a )}
- Complete exclusion axiom:
- For every pair of actions a and b , and for i = 0, …, n– 1, a formula saying they can’t both be the i ’th step of the plan ¬ a (^) i ∨ ¬ bi
- this guarantees there can be only one action at a time
Example
Planning domain:
one robot r two adjacent locations l1, l one planning operator (to move the robot from one location to another)
Encode ( P,n ) where n = 1
- Initial state: {at(r1,l1)} Encoding: at(r1,l1,0) ∧ ¬at(r1,l2,0)
- Goal: {at(r1,l2)} Encoding: at(r1,l2,1) ∧ ¬at(r1,l1,1)
- Operator: see next slide
Example (continued)
- Operator: move( r , l , l' )
precond: at( r , l ) effects: at( r , l' ), ¬at( r , l ) Encoding: move(r1,l1,l2,0) ⇒ at(r1,l1,0) ∧ at(r1,l2,1) ∧ ¬at(r1,l1,1) move(r1,l2,l1,0) ⇒ at(r1,l2,0) ∧ at(r1,l1,1) ∧ ¬at(r1,l2,1) move(r1,l1,l1,0) ⇒ at(r1,l1,0) ∧ at(r1,l1,1) ∧ ¬at(r1,l1,1) move(r1,l2,l2,0) ⇒ at(r1,l2,0) ∧ at(r1,l2,1) ∧ ¬at(r1,l2,1) move(l1,r1,l2,0) ⇒ … move(l2,l1,r1,0) ⇒ … move(l1,l2,r1,0) ⇒ … move(l2,l1,r1,0) ⇒ …
- Operator: move( r : robot, l : location, l' : location)
precond: at( r , l ) effects: at( r , l' ), ¬at( r , l )
nonsensical, and we can avoid generating them if we use data types like we did for state-variable representation
contradictions (easy to detect)
Summary of the Example
- P is a planning problem with one robot and two locations
- initial state {at(r1,l1)}
- goal {at(r1,l2)}
- Encoding of ( P, 1)
- Φ = [at(r1,l1,0) ∧ ¬at(r1,l2,0)] (initial state) ∧ [at(r1,l2,1) ∧ ¬at(r1,l1,1)] (goal) ∧ [move(r1,l1,l2,0) ⇒ at(r1,l1,0) ∧ at(r1,l2,1) ∧ ¬at(r1,l1,1)] (action) ∧ [move(r1,l2,l1,0) ⇒ at(r1,l2,0) ∧ at(r1,l1,1) ∧ ¬at(r1,l2,1)] (action) ∧ [¬move(r1,l1,l2,0) ∨ ¬move(r1,l2,l1,0)] (complete exclusion) ∧ [¬at(r1,l1,0) ∧ at(r1,l1,1) ⇒ move(r1,l2,l1,0)] (frame axiom) ∧ [¬at(r1,l2,0) ∧ at(r1,l2,1) ⇒ move(r1,l1,l2,0)] (frame axiom) ∧ [at(r1,l1,0) ∧ ¬at(r1,l1,1) ⇒ move(r1,l1,l2,0)] (frame axiom) ∧ [at(r1,l2,0) ∧ ¬at(r1,l2,1) ⇒ move(r1,l2,l1,0)] (frame axiom)
Extracting a Plan
- Let Φ be an encoding of ( P,n )
- Suppose we find an assignment of truth values that satisfies Φ.
- This means P has a solution of length n
- For i =1,…, n , there will be exactly one action a such that a (^) i = true
- This is the i ’th action of the plan.
- Example
- The formula on the previous slide
- Φ can be satisfied with move(r1,l1,l2,0) = true
- Thus 〈move(r1,l1,l2,0)〉 is a solution for ( P ,1)
- It’s the only solution - no other way to satisfy Φ
The Davis-Putnam Procedure
Backtracking search through alternative assignments of truth values to literals
- μ = {literals to which we have assigned the value TRUE}
- For every unit clause l
- add l to μ
- remove clauses that contain l
- modify clauses that contain ¬ l
- If Φ contains ∅, μ fails
- If Φ = ∅, μ is a solution
- Select a Boolean variable P in Φ
- do two recursive calls
Unit-propagate(Φ, μ)
if ∅ ∈ Φ then return error in the book here
if Φ = ∅ then exit with μ
Local Search
- Let u be an assignment of truth values to all of the variables
- cost( u ,Φ) = number of clauses in Φ that aren’t satisfied by u
- flip( P,u ) = u except that P ’s truth value is reversed
- Local search:
- Select a random assignment u
- while cost( u ,Φ) ≠ 0
- if there is a P such that cost(flip( P,u ),Φ) < cost( u ,Φ) then
- randomly choose any such P
- u ← flip( P,u )
- else return failure
- Local search is sound
- If it finds a solution it will find it very quickly
- Local search is not complete: can get trapped in local minima
Boolean variable
Discussion
- Recall the overall approach:
- for n = 0, 1, 2, …,
- encode ( P,n ) as a satisfiability problem Φ
- if Φ is satisfiable, then
- From the set of truth values that satisfies Φ, extract a solution plan and return it
- By itself, not very practical (takes too much memory and time)
- But it can work well if combined with other techniques
SatPlan
- SatPlan combines planning-graph expansion and satisfiability checking
- Works roughly as follows:
- for k = 0, 1, 2, …
- Create a planning graph that contains k levels
- Encode the planning graph as a satisfiability problem
- Try to solve it using a SAT solver
- If the SAT solver finds a solution within some time limit, » Remove some unnecessary actions » Return the solution
- Memory requirement still is combinatorially large
- but less than what’s needed by a direct translation into satisfiability
- BlackBox (predecessor to SatPlan) was one of the best planners in the 1998 planning competition
- SatPlan was one of the best planners in the 2004 and 2006 planning competitions