21
1 ture slides for Automated Planning r the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/ Chapter 7 Propositional Satisfiability Techniques Dana S. Nau CMSC 722, AI Planning University of Maryland, Fall 2004 Lecture slides for Automated Planning: Theory and Practice

Chapter 7 Propositional Satisfiability Techniques

  • Upload
    reegan

  • View
    36

  • Download
    2

Embed Size (px)

DESCRIPTION

Lecture slides for Automated Planning: Theory and Practice. Chapter 7 Propositional Satisfiability Techniques. Dana S. Nau CMSC 722, AI Planning University of Maryland, Fall 2004. Motivation. Propositional satisfiability: given a boolean formula - PowerPoint PPT Presentation

Citation preview

Page 1: Chapter 7 Propositional Satisfiability Techniques

1Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Chapter 7Propositional Satisfiability Techniques

Dana S. Nau

CMSC 722, AI PlanningUniversity of Maryland, Fall 2004

Lecture slides forAutomated Planning: Theory and Practice

Page 2: Chapter 7 Propositional Satisfiability Techniques

2Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

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

Page 3: Chapter 7 Propositional Satisfiability Techniques

3Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Outline Encoding planning problems as satisfiability problems Extracting plans from truth values Satisfiability algorithms

Davis-Putnam Local search GSAT

Combining satisfiability with planning graphs BlackBox

Page 4: Chapter 7 Propositional Satisfiability Techniques

4Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Overall Approach Bounded planning problem (P,n):

P is a planning problem; n is a positive integer Find a solution for P of length n

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

We’ll use propositional logic but we’ll write propositions that look like ground atoms e.g., at(r1,loc1) is the proposition that’s true iff r1 is at loc1

Page 5: Chapter 7 Propositional Satisfiability Techniques

5Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Fluents If π = a0, a1, …, an–1 is a solution for (P,n), then it generates the

following states:

s0, s1 = (s0,a0), s2 = (s1,a1), …, sn = (sn–1, an–1)

Fluents: propositions used to describe what’s true in each si

at(r1,loc1,i) is a fluent that’s true iff at(r1,loc1) is in si

We’ll use li to denote the fluent for literal l in state si

» e.g., if l = at(r1,loc1)

then li = at(r1,loc1,i)

ai is a fluent saying that a is the i’th step of π» e.g., if a = move(r1,loc2,loc1)

then ai = move(r1,loc2,loc1,i)

Page 6: Chapter 7 Propositional Satisfiability Techniques

6Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Encoding Planning Problems Encode (P,n) as a formula such that

π = a0, a1, …, an–1 is a solution for (P,n)

if and only if

can be satisfied in a way that makes the fluents a0, …, 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 …

Page 7: Chapter 7 Propositional Satisfiability Techniques

7Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Formulas in Formula describing the initial state:

/\{l0 | l s0} /\{l0 | l L – s0 }

Formula describing the goal:

/\{ln | l g+} /\{ln | l g–}

For every action a in A, formulas describing what changes a would make if it were the i’th step of the plan: ai /\{pi | p Precond(a)} /\ {ei+1 | e Effects(a)}

Complete exclusion axiom: For all actions a and b, formulas saying they can’t occur at the same time

ai bi

this guarantees there can be only one action at a time

Is this enough?

Page 8: Chapter 7 Propositional Satisfiability Techniques

8Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Frame Axioms Frame axioms:

Formulas describing what doesn’t changebetween steps i and i+1

Several ways to write these

One way: explanatory frame axioms One axiom for every literal l Says that if l changes between si and si+1,

then the action at step i must be responsible:

(li li+1 V{ai | l in effects+(a)})

(li li+1 V{ai | l in effects–(a)})

Page 9: Chapter 7 Propositional Satisfiability Techniques

9Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Example Planning domain:

one robot r1 two adjacent locations l1, l2 one operator (move the robot)

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

Page 10: Chapter 7 Propositional Satisfiability Techniques

10Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

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) …

How to avoid generating the last four actions? Assign data types to the constant symbols

like we did for state-variable representation

nonsensical

contradictions(easy to detect)

Page 11: Chapter 7 Propositional Satisfiability Techniques

11Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Example (continued) Locations: l1, l2 Robots: r1

Operator: move(r : robot, l : location, l’ : location)

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)

Page 12: Chapter 7 Propositional Satisfiability Techniques

12Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Example (continued) Complete-exclusion axiom:

move(r1,l1,l2,0) move(r1,l2,l1,0)

Explanatory frame axioms:

at(r1,l1,0) at(r1,l1,1) move(r1,l2,l1,0)

at(r1,l2,0) at(r1,l2,1) move(r1,l1,l2,0)

at(r1,l1,0) at(r1,l1,1) move(r1,l1,l2,0)

at(r1,l2,0) at(r1,l2,1) move(r1,l2,l1,0)

Page 13: Chapter 7 Propositional Satisfiability Techniques

13Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Extracting a Plan 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 ai = true

This is the i’th action of the plan.

Example (from the previous slides): can be satisfied with move(r1,l1,l2,0) = true Thus move(r1,l1,l2,0) is a solution for (P,0)

» It’s the only solution - no other way to satisfy

Page 14: Chapter 7 Propositional Satisfiability Techniques

14Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Planning How to find an assignment of truth values that satisfies ?

Use a satisfiability algorithm

Example: the Davis-Putnam algorithm

First need to put into conjunctive normal form

e.g., = D (D A B) (D A B) (D A B) A

Write as a set of clauses (disjuncts of literals)

= {D, (D A B), (D A B), (D A B), A}

Two special cases:

» = {} is a formula that’s always true

» = {…, (), …} is a formula that’s always false

Page 15: Chapter 7 Propositional Satisfiability Techniques

15Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

The Davis-Putnam ProcedureDepth-first backtracking through combinations of truth values

Select a variable P in Recursive call on P

Simplify: remove alloccurrences of P

If = {…, (), …}then backtrack

Else if = {} thenhave a solution

Recursive callon P

Simplify: remove alloccurrences of P

If = {…, (), …}then backtrack

Else if = {} then have a solution

Page 16: Chapter 7 Propositional Satisfiability Techniques

16Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

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 with the truth value of P 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

Page 17: Chapter 7 Propositional Satisfiability Techniques

17Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

GSAT Basic-GSAT:

Select a random assignment u while cost(u,) ≠ 0

» choose the P that minimizes cost(flip(P,u),) Not guaranteed to terminate

GSAT: restart after a max number of flips return failure after a max number of restarts

The book discusses several other stochastic procedures One is Walksat

» works better than both local search and GSAT I’ll skip the details

Page 18: Chapter 7 Propositional Satisfiability Techniques

18Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

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

How well does this work?

Page 19: Chapter 7 Propositional Satisfiability Techniques

19Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

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

How well does this work? By itself, not very practical (takes too much memory and time)

But it can be combined with other techniques e.g., planning graphs

Page 20: Chapter 7 Propositional Satisfiability Techniques

20Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

BlackBox The BlackBox procedure combines planning-graph expansion and

satisfiability checking It is roughly as follows:

for n = 0, 1, 2, … Graph expansion:

» create a “planning graph” that contains n “levels” Check whether the planning graph satisfies a necessary

(but insufficient) condition for plan existence If it does, then

» Encode (P,n) as a satisfiability problem but include only the actions in the planning graph

» If is satisfiable then return the solution

Page 21: Chapter 7 Propositional Satisfiability Techniques

21Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

More about BlackBox Memory requirement still is combinatorially large, but less than

satisfiability alone It was one of the two fastest planners in the 1998 planning

competition