Top Banner
For Friday No new reading Logic and Resolution Homework
67

For Friday No new reading Logic and Resolution Homework.

Jan 04, 2016

Download

Documents

David George
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: For Friday No new reading Logic and Resolution Homework.

For Friday

• No new reading• Logic and Resolution Homework

Page 2: For Friday No new reading Logic and Resolution Homework.

Program 2

• Any questions?

Page 3: For Friday No new reading Logic and Resolution Homework.

Resolution

• Propositional version.

{a Ú b, ¬b Ú c} |- a Ú c OR {¬aÞ b, b Þ c} |- ¬a Þ c

Reasoning by cases OR transitivity of implication • First order form

– For two literals pj and qk in two clauses • p1 Ú ... pj ... Ú pm

• q1 Ú ... qk ... Ú qn

such that q=UNIFY(pj , ¬qk), derive

SUBST(q, p1Ú...pj 1Úpj+1...ÚpmÚq1Ú...qk 1 qk+1...Úqn)

Page 4: For Friday No new reading Logic and Resolution Homework.

Implication form

• Can also be viewed in implicational form where all negated literals are in a conjunctive antecedent and all positive literals in a disjunctive conclusion.

¬p1Ú...Ú¬pmÚq1Ú...Úqn Û

p1Ù... Ù pm Þ q1Ú ...Ú qn

Page 5: For Friday No new reading Logic and Resolution Homework.

Conjunctive Normal Form (CNF)

• For resolution to apply, all sentences must be in conjunctive normal form, a conjunction of disjunctions of literals

(a1 Ú ...Ú am) Ù

(b1 Ú ... Ú bn) Ù

..... Ù

(x1 Ú ... Ú xv)

• Representable by a set of clauses (disjunctions of literals)

• Also representable as a set of implications (INF).

Page 6: For Friday No new reading Logic and Resolution Homework.

Example

Initial CNF INF

P(x) Þ Q(x) ¬P(x) Ú Q(x) P(x) Þ Q(x)

¬P(x) Þ R(x) P(x) Ú R(x) True Þ P(x) Ú R(x)

Q(x) Þ S(x) ¬Q(x) Ú S(x) Q(x) Þ S(x)

R(x) Þ S(x) ¬R(x) Ú S(x) R(x) Þ S(x)

Page 7: For Friday No new reading Logic and Resolution Homework.

Resolution Proofs

• INF (CNF) is more expressive than Horn clauses.

• Resolution is simply a generalization of modus ponens.

• As with modus ponens, chains of resolution steps can be used to construct proofs.

• Factoring removes redundant literals from clauses – S(A) Ú S(A) -> S(A)

Page 8: For Friday No new reading Logic and Resolution Homework.

Sample Proof

P(w) Q(w) Q(y) S(y)

{y/w}

P(w) S(w) True P(x) R(x)

{w/x}

True S(x) R(x) R(z) S(z) {x/A, z/A}

True S(A)

Page 9: For Friday No new reading Logic and Resolution Homework.

Refutation Proofs• Unfortunately, resolution proofs in this form

are still incomplete. • For example, it cannot prove any tautology

(e.g. PÚ¬P) from the empty KB since there are no clauses to resolve.

• Therefore, use proof by contradiction (refutation, reductio ad absurdum). Assume the negation of the theorem P and try to derive a contradiction (False, the empty clause). – (KB Ù ¬P Þ False) Û KB Þ P

Page 10: For Friday No new reading Logic and Resolution Homework.

Sample Proof

P(w) Q(w) Q(y) S(y)

{y/w}

P(w) S(w) True P(x) R(x)

{w/x}

True S(x) R(x) R(z) S(z) {z/x}

S(A) False True S(x)

{x/A}

False

Page 11: For Friday No new reading Logic and Resolution Homework.

Resolution Theorem Proving

• Convert sentences in the KB to CNF (clausal form)

• Take the negation of the proposed theorem (query), convert it to CNF, and add it to the KB.

• Repeatedly apply the resolution rule to derive new clauses.

• If the empty clause (False) is eventually derived, stop and conclude that the proposed theorem is true.

Page 12: For Friday No new reading Logic and Resolution Homework.

Conversion to Clausal Form• Eliminate implications and biconditionals by

rewriting them. p Þ q -> ¬p Ú q

p Û q > (¬p Ú q) Ù (p Ú ¬q) • Move ¬ inward to only be a part of literals by

using deMorgan's laws and quantifier rules. ¬(p Ú q) -> ¬p Ù ¬q

¬(p Ù q) -> ¬p Ú¬q

¬"x p -> $x ¬p

¬$x p -> "x ¬p

¬¬p -> p

Page 13: For Friday No new reading Logic and Resolution Homework.

Conversion continued

• Standardize variables to avoid use of the same variable name by two different quantifiers.

"x P(x) Ú $x P(x) -> "x1 P(x1) Ú $x2 P(x2) • Move quantifiers left while maintaining

order. Renaming above guarantees this is a truth preserving transformation.

"x1 P(x1) Ú $x2 P(x2) -> "x1 $x2 (P(x1) Ú P(x2))

Page 14: For Friday No new reading Logic and Resolution Homework.

Conversion continued• Skolemize: Remove existential quantifiers by replacing

each existentially quantified variable with a Skolem constant or Skolem function as appropriate. – If an existential variable is not within the scope of any universally

quantified variable, then replace every instance of the variable with the same unique constant that does not appear anywhere else.

$x (P(x) Ù Q(x)) -> P(C1) Ù Q(C1)

– If it is within the scope of n universally quantified variables, then replace it with a unique n ary function over these universally quantified variables.

"x1$x2(P(x1) Ú P(x2)) -> "x1 (P(x1) Ú P(f1(x1)))

"x(Person(x) Þ $y(Heart(y) Ù Has(x,y))) ->

"x(Person(x) Þ Heart(HeartOf(x)) Ù Has(x,HeartOf(x))) – Afterwards, all variables can be assumed to be universally

quantified, so remove all quantifiers.

Page 15: For Friday No new reading Logic and Resolution Homework.

Conversion continued• Distribute Ù over Ú to convert to conjunctions of

clauses (aÙb) Ú c -> (aÚc) Ù (bÚc)

(aÙb) Ú (cÙd) -> (aÚc) Ù (bÚc) Ù (aÚd) Ù (bÚd) – Can exponentially expand size of sentence.

• Flatten nested conjunctions and disjunctions to get final CNF (a Ú b) Ú c -> (a Ú b Ú c)

(a Ù b) Ù c -> (a Ù b Ù c)

• Convert clauses to implications if desired for readability

(¬a Ú ¬b Ú c Ú d) -> a Ù b Þ c Ú d

Page 16: For Friday No new reading Logic and Resolution Homework.

Sample Clause Conversion"x((Prof(x) Ú Student(x)) Þ ($y(Class(y) Ù Has(x,y)) Ù

$y(Book(y) Ù Has(x,y))))

"x(¬(Prof(x) Ú Student(x)) Ú ($y(Class(y) Ù Has(x,y)) Ù $y(Book(y) Ù Has(x,y))))

"x((¬Prof(x) Ù ¬Student(x)) Ú ($y(Class(y) Ù Has(x,y)) Ù $y(Book(y) Ù Has(x,y))))

"x((¬Prof(x) Ù ¬Student(x)) Ú ($y(Class(y) Ù Has(x,y)) Ù $z(Book(z) Ù Has(x,z))))

"x$y$z((¬Prof(x)Ù¬Student(x))Ú ((Class(y) Ù Has(x,y)) Ù (Book(z) Ù Has(x,z))))

(¬Prof(x)Ù¬Student(x))Ú (Class(f(x)) Ù Has(x,f(x)) Ù Book(g(x)) Ù Has(x,g(x))))

Page 17: For Friday No new reading Logic and Resolution Homework.

Clause Conversion(¬Prof(x)Ù¬Student(x))Ú (Class(f(x)) Ù Has(x,f(x)) Ù

Book(g(x)) Ù Has(x,g(x))))

(¬Prof(x) Ú Class(f(x))) Ù

(¬Prof(x) Ú Has(x,f(x))) Ù

(¬Prof(x) Ú Book(g(x))) Ù

(¬Prof(x) Ú Has(x,g(x))) Ù

(¬Student(x) Ú Class(f(x))) Ù

(¬Student(x) Ú Has(x,f(x))) Ù

(¬Student(x) Ú Book(g(x))) Ù

(¬Student(x) Ú Has(x,g(x))))

Page 18: For Friday No new reading Logic and Resolution Homework.

Sample Resolution Problem

• Jack owns a dog. • Every dog owner is an animal lover. • No animal lover kills an animal. • Either Jack or Curiosity killed Tuna the cat. • Did Curiosity kill the cat?

Page 19: For Friday No new reading Logic and Resolution Homework.

In Logic Form

A) $x Dog(x) Ù Owns(Jack,x)

B) "x ($y Dog(y) Ù Owns(x,y)) Þ AnimalLover(x))

C) "x AnimalLover(x) Þ ("y Animal(y) Þ ¬Kills(x,y))

D) Kills(Jack,Tuna) Ú Kills(Cursiosity,Tuna)

E) Cat(Tuna)

F) "x(Cat(x) Þ Animal(x))

Query: Kills(Curiosity,Tuna)

Page 20: For Friday No new reading Logic and Resolution Homework.

In Normal Form

A1) Dog(D)

A2) Owns(Jack,D)

B) Dog(y) Ù Owns(x,y) Þ AnimalLover(x)

C) AnimalLover(x) Ù Animal(y) Ù Kills(x,y) Þ False

D) Kills(Jack,Tuna) Ú Kills(Curiosity,Tuna)

E) Cat(Tuna)

F) Cat(x) Þ Animal(x)

Query: Kills(Curiosity,Tuna) Þ False

Page 21: For Friday No new reading Logic and Resolution Homework.

Resolution Proof

Page 22: For Friday No new reading Logic and Resolution Homework.

Search

• What are characteristics of good problems for search?

• What does the search know about the goal state?

• Consider the package problem on the exam:– How well would search REALLY work on that

problem?

Page 23: For Friday No new reading Logic and Resolution Homework.

Search vs. Planning

• Planning systems:– Open up action and goal representation to allow

selection– Divide and conquer by subgoaling– Relax the requirement for sequential

construction of solutions

Page 24: For Friday No new reading Logic and Resolution Homework.

Planning in Situation CalculusPlanResult(p,s) is the situation resulting from executing

p in sPlanResult([],s) = s

PlanResult([a|p],s) = PlanResult(p,Result(a,s))

Initial state At(Home,S_0) Have(Milk,S_0) …

Actions as Successor State axiomsHave(Milk,Result(a,s)) [(a=Buy(Milk) At(Supermarket,s)) Have(Milk,s)

a ...)]

Query s=PlanResult(p,S_0) At(Home,s) Have(Milk,s) …

Solution p = Go(Supermarket),Buy(Milk),Buy(Bananas),Go(HWS),…]

• Principal difficulty: unconstrained branching, hard to apply heuristics

Page 25: For Friday No new reading Logic and Resolution Homework.

The Blocks World

• We have three blocks A, B, and C• We can know things like whether a block is

clear (nothing on top of it) and whether one block is on another (or on the table)

• Initial State:

• Goal State:

A

B CA

B

C

Page 26: For Friday No new reading Logic and Resolution Homework.

Situation Calculus in Prologholds(on(A,B),result(puton(A,B),S)) :

holds(clear(A),S), holds(clear(B),S),

neq(A,B).

holds(clear(C),result(puton(A,B),S)) :

holds(clear(A),S), holds(clear(B),S),

holds(on(A,C),S),

neq(A,B).

holds(on(X,Y),result(puton(A,B),S)) :

holds(on(X,Y),S),

neq(X,A), neq(Y,A), neq(A,B).

holds(clear(X),result(puton(A,B),S)) :

holds(clear(X),S), neq(X,B).

holds(clear(table),S).

Page 27: For Friday No new reading Logic and Resolution Homework.

neq(a,table).

neq(table,a).

neq(b,table).

neq(table,b).

neq(c,table).

neq(table,c).

neq(a,b).

neq(b,a).

neq(a,c).

neq(c,a).

neq(b,c).

neq(c,b).

Page 28: For Friday No new reading Logic and Resolution Homework.

Situation Calculus Planner

plan([],_,_).

plan([G1|Gs], S0, S) :

holds(G1,S),

plan(Gs, S0, S),

reachable(S,S0).

reachable(S,S).

reachable(result(_,S1),S) :

reachable(S1,S). • However, what will happen if we try to make

plans using normal Prolog depth first search?

Page 29: For Friday No new reading Logic and Resolution Homework.

Stack of 3 Blocks

holds(on(a,b), s0).

holds(on(b,table), s0).

holds(on(c,table),s0).

holds(clear(a), s0).

holds(clear(c), s0).

| ? cpu_time(db_prove(6,plan([on(a,b),on(b,c)],s0,S)), T).

S = result(puton(a,b),result(puton(b,c),result(puton(a,table),s0)))

T = 1.3433E+01

Page 30: For Friday No new reading Logic and Resolution Homework.

Invert stack

holds(on(a,table), s0).

holds(on(b,a), s0).

holds(on(c,b),s0).

holds(clear(c), s0).

? cpu_time(db_prove(6,plan([on(b,c),on(a,b)],s0,S)),T).

S = result(puton(a,b),result(puton(b,c),result(puton(c,table),s0))),

T = 7.034E+00

Page 31: For Friday No new reading Logic and Resolution Homework.

Simple Four Block Stackholds(on(a,table), s0).

holds(on(b,table), s0).

holds(on(c,table),s0).

holds(on(d,table),s0).

holds(clear(c), s0).

holds(clear(b), s0).

holds(clear(a), s0).

holds(clear(d), s0).

| ? cpu_time(db_prove(7,plan([on(b,c),on(a,b),on(c,d)],s0,S)),T).

S = result(puton(a,b),result(puton(b,c),result(puton(c,d),s0))),

T = 2.765935E+04

7.5 hours!

Page 32: For Friday No new reading Logic and Resolution Homework.

STRIPS• Developed at SRI (formerly Stanford Research

Institute) in early 1970's. • Just using theorem proving with situation

calculus was found to be too inefficient. • Introduced STRIPS action representation. • Combines ideas from problem solving and

theorem proving. • Basic backward chaining in state space but

solves subgoals independently and then tries to reachieve any clobbered subgoals at the end.

Page 33: For Friday No new reading Logic and Resolution Homework.

STRIPS Representation

• Attempt to address the frame problem by defining actions by a precondition, and add list, and a delete list. (Fikes & Nilsson, 1971). – Precondition: logical formula that must be true

in order to execute the action. – Add list: List of formulae that become true as a

result of the action. – Delete list: List of formulae that become false

as result of the action.

Page 34: For Friday No new reading Logic and Resolution Homework.

Sample Action

• Puton(x,y) – Precondition: Clear(x) Ù Clear(y) Ù On(x,z) – Add List: {On(x,y), Clear(z)} – Delete List: {Clear(y), On(x,z)}

Page 35: For Friday No new reading Logic and Resolution Homework.

STRIPS Assumption

• Every formula that is satisfied before an action is performed and does not belong to the delete list is satisfied in the resulting state.

• Although Clear(z) implies that On(x,z) must be false, it must still be listed in the delete list explicitly.

• For action Kill(x,y) must put Alive(y), Breathing(y), Heart Beating(y), etc. must all be included in the delete list although these deletions are implied by the fact of adding Dead(y)

Page 36: For Friday No new reading Logic and Resolution Homework.

Subgoal Independence

• If the goal state is a conjunction of subgoals, search is simplified if goals are assumed independent and solved separately (divide and conquer)

• Consider a goal of A on B and C on D from 4 blocks all on the table

Page 37: For Friday No new reading Logic and Resolution Homework.

Subgoal Interaction

• Achieving different subgoals may interact, the order in which subgoals are solved in this case is important.

• Consider 3 blocks on the table, goal of A on B and B on C

• If do puton(A,B) first, cannot do puton(B,C) without undoing (clobbering) subgoal: on(A,B)

Page 38: For Friday No new reading Logic and Resolution Homework.

Sussman Anomaly

• Goal of A on B and B on C• Starting state of C on A and B on table• Either way of ordering subgoals causes

clobbering

Page 39: For Friday No new reading Logic and Resolution Homework.

STRIPS Approach

• Use resolution theorem prover to try and prove that goal or subgoal is satisfied in the current state.

• If it is not, use the incomplete proof to find a set of differences between the current and goal state (a set of subgoals).

• Pick a subgoal to solve and an operator that will achieve that subgoal.

• Add the precondition of this operator as a new goal and recursively solve it.

Page 40: For Friday No new reading Logic and Resolution Homework.

STRIPS AlgorithmSTRIPS(init state, goals, ops)

Let current state be init state;

For each goal in goals do

If goal cannot be proven in current state

Pick an operator instance, op, s.t. goal Î adds(op);

/* Solve preconditions */

STRIPS(current state, preconds(op), ops);

/* Apply operator */

current state := current state + adds(op) dels(ops);

/* Patch any clobbered goals */

Let rgoals be any goals which are not provable in current state;

STRIPS(current state, rgoals, ops).

Page 41: For Friday No new reading Logic and Resolution Homework.

Algorithm Notes

• The “pick operator instance” step involves a nondeterministic choice that is backtracked to if a dead end is ever encountered.

• Employs chronological backtracking (depth first search), when it reaches a dead end, backtrack to last decision point and pursue the next option.

Page 42: For Friday No new reading Logic and Resolution Homework.

Norvig’s Implementation

• Simple propositional (no variables) Lisp implementation of STRIPS. #S(OP ACTION (MOVE C FROM TABLE TO B)

PRECONDS ((SPACE ON C) (SPACE ON B) (C ON TABLE))

ADD LIST ((EXECUTING (MOVE C FROM TABLE TO B)) (C ON B))

DEL LIST ((C ON TABLE) (SPACE ON B)))

• Commits to first sequence of actions that achieves a subgoal (incomplete search).

• Prefers actions with the most preconditions satisfied in the current state.

• Modified to to try and re-achieve any clobbered subgoals (only once).

Page 43: For Friday No new reading Logic and Resolution Homework.

STRIPS Results; Invert stack (good goal ordering)

> (gps '((a on b)(b on c) (c on table) (space on a) (space on table))

'((b on a) (c on b)))

Goal: (B ON A)

Consider: (MOVE B FROM C TO A)

Goal: (SPACE ON B)

Consider: (MOVE A FROM B TO TABLE)

Goal: (SPACE ON A)

Goal: (SPACE ON TABLE)

Goal: (A ON B)

Action: (MOVE A FROM B TO TABLE)

Page 44: For Friday No new reading Logic and Resolution Homework.

Goal: (SPACE ON A)

Goal: (B ON C)

Action: (MOVE B FROM C TO A)

Goal: (C ON B)

Consider: (MOVE C FROM TABLE TO B)

Goal: (SPACE ON C)

Goal: (SPACE ON B)

Goal: (C ON TABLE)

Action: (MOVE C FROM TABLE TO B)

((START)

(EXECUTING (MOVE A FROM B TO TABLE))

(EXECUTING (MOVE B FROM C TO A))

(EXECUTING (MOVE C FROM TABLE TO B)))

Page 45: For Friday No new reading Logic and Resolution Homework.

; Invert stack (bad goal ordering)

> (gps '((a on b)(b on c) (c on table) (space on a) (space on table))

'((c on b)(b on a)))

Goal: (C ON B)

Consider: (MOVE C FROM TABLE TO B)

Goal: (SPACE ON C)

Consider: (MOVE B FROM C TO TABLE)

Goal: (SPACE ON B)

Consider: (MOVE A FROM B TO TABLE)

Goal: (SPACE ON A)

Goal: (SPACE ON TABLE)

Goal: (A ON B)

Action: (MOVE A FROM B TO TABLE)

Goal: (SPACE ON TABLE)

Goal: (B ON C)

Action: (MOVE B FROM C TO TABLE)

Page 46: For Friday No new reading Logic and Resolution Homework.

Goal: (SPACE ON B)

Goal: (C ON TABLE)

Action: (MOVE C FROM TABLE TO B)

Goal: (B ON A)

Consider: (MOVE B FROM TABLE TO A)

Goal: (SPACE ON B)

Consider: (MOVE C FROM B TO TABLE)

Goal: (SPACE ON C)

Goal: (SPACE ON TABLE)

Goal: (C ON B)

Action: (MOVE C FROM B TO TABLE)

Goal: (SPACE ON A)

Goal: (B ON TABLE)

Action: (MOVE B FROM TABLE TO A)

Page 47: For Friday No new reading Logic and Resolution Homework.

Must reachieve clobbered goals: ((C ON B))

Goal: (C ON B)

Consider: (MOVE C FROM TABLE TO B)

Goal: (SPACE ON C)

Goal: (SPACE ON B)

Goal: (C ON TABLE)

Action: (MOVE C FROM TABLE TO B)

((START)

(EXECUTING (MOVE A FROM B TO TABLE))

(EXECUTING (MOVE B FROM C TO TABLE))

(EXECUTING (MOVE C FROM TABLE TO B))

(EXECUTING (MOVE C FROM B TO TABLE))

(EXECUTING (MOVE B FROM TABLE TO A))

(EXECUTING (MOVE C FROM TABLE TO B)))

Page 48: For Friday No new reading Logic and Resolution Homework.

STRIPS on Sussman Anomaly> (gps '((c on a)(a on table)( b on table) (space on c) (space on b)

(space on table)) '((a on b)(b on c)))

Goal: (A ON B)

Consider: (MOVE A FROM TABLE TO B)

Goal: (SPACE ON A)

Consider: (MOVE C FROM A TO TABLE)

Goal: (SPACE ON C)

Goal: (SPACE ON TABLE)

Goal: (C ON A)

Action: (MOVE C FROM A TO TABLE)

Goal: (SPACE ON B)

Goal: (A ON TABLE)

Action: (MOVE A FROM TABLE TO B)

Goal: (B ON C)

Page 49: For Friday No new reading Logic and Resolution Homework.

Consider: (MOVE B FROM TABLE TO C)

Goal: (SPACE ON B)

Consider: (MOVE A FROM B TO TABLE)

Goal: (SPACE ON A)

Goal: (SPACE ON TABLE)

Goal: (A ON B)

Action: (MOVE A FROM B TO TABLE)

Goal: (SPACE ON C)

Goal: (B ON TABLE)

Action: (MOVE B FROM TABLE TO C)

Must reachieve clobbered goals: ((A ON B))

Goal: (A ON B)

Consider: (MOVE A FROM TABLE TO B)

Page 50: For Friday No new reading Logic and Resolution Homework.

Goal: (SPACE ON A)

Goal: (SPACE ON B)

Goal: (A ON TABLE)

Action: (MOVE A FROM TABLE TO B)

((START) (EXECUTING (MOVE C FROM A TO TABLE))

(EXECUTING (MOVE A FROM TABLE TO B))

(EXECUTING (MOVE A FROM B TO TABLE))

(EXECUTING (MOVE B FROM TABLE TO C))

(EXECUTING (MOVE A FROM TABLE TO B)))

Page 51: For Friday No new reading Logic and Resolution Homework.

How Long Do 4 Blocks Take?

;; Stack four clear blocks (good goal ordering)

> (time (gps '((a on table)(b on table) (c on table) (d on table)(space on a)

(space on b) (space on c) (space on d)(space on table))

'((c on d)(b on c)(a on b))))

User Run Time = 0.00 seconds

((START)

(EXECUTING (MOVE C FROM TABLE TO D))

(EXECUTING (MOVE B FROM TABLE TO C))

(EXECUTING (MOVE A FROM TABLE TO B)))

Page 52: For Friday No new reading Logic and Resolution Homework.

;; Stack four clear blocks (bad goal ordering)

> (time (gps '((a on table)(b on table) (c on table) (d on table)(space on a)

(space on b) (space on c) (space on d)(space on table))

'((a on b)(b on c) (c on d))))

User Run Time = 0.06 seconds

((START)

(EXECUTING (MOVE A FROM TABLE TO B))

(EXECUTING (MOVE A FROM B TO TABLE))

(EXECUTING (MOVE B FROM TABLE TO C))

(EXECUTING (MOVE B FROM C TO TABLE))

(EXECUTING (MOVE C FROM TABLE TO D))

(EXECUTING (MOVE A FROM TABLE TO B))

(EXECUTING (MOVE A FROM B TO TABLE))

(EXECUTING (MOVE B FROM TABLE TO C))

(EXECUTING (MOVE A FROM TABLE TO B)))

Page 53: For Friday No new reading Logic and Resolution Homework.

State-Space Planners• State space (situation space) planning algorithms

search through the space of possible states of the world searching for a path that solves the problem.

• They can be based on progression: a forward search from the initial state looking for the goal state.

• Or they can be based on regression: a backward search from the goals towards the initial state

• STRIPS is an incomplete regression based algorithm.

Page 54: For Friday No new reading Logic and Resolution Homework.

Plan-Space Planners

• Plan space planners search through the space of partial plans, which are sets of actions that may not be totally ordered.

• Partial order planners are plan based and only introduce ordering constraints as necessary (least commitment) in order to avoid unnecessarily searching through the space of possible orderings

Page 55: For Friday No new reading Logic and Resolution Homework.

Partial Order Plan

• Plan which does not specify unnecessary ordering.

• Consider the problem of putting on your socks and shoes.

Page 56: For Friday No new reading Logic and Resolution Homework.

Plans

• A plan is a three tuple <A, O, L> – A: A set of actions in the plan, {A1 ,A2 ,...An}

– O: A set of ordering constraints on actions {Ai <Aj , Ak <Al ,...Am <An}. These must be consistent, i.e. there must be at least one total ordering of actions in A that satisfy all the constraints.

– L: a set of causal links showing how actions support each other

Page 57: For Friday No new reading Logic and Resolution Homework.

Causal Links and Threats

• A causal link, Ap ® QAc, indicates that action Ap has an effect Q that achieves precondition Q for action Ac.

• A threat, is an action A t that can render a causal link Ap ® QAc ineffective because: – O È {AP < At < Ac} is consistent

– At has ¬Q as an effect

Page 58: For Friday No new reading Logic and Resolution Homework.

Threat Removal

• Threats must be removed to prevent a plan from failing

• Demotion adds the constraint At < Ap to prevent clobbering, i.e. push the clobberer before the producer

• Promotion adds the constraint Ac < At to prevent clobbering, i.e. push the clobberer after the consumer

Page 59: For Friday No new reading Logic and Resolution Homework.

Initial (Null) Plan

• Initial plan has – A={ A0, A¥}

– O={A0 < A¥}

– L ={}

• A0 (Start) has no preconditions but all facts in the initial state as effects.

• A¥ (Finish) has the goal conditions as preconditions and no effects.

Page 60: For Friday No new reading Logic and Resolution Homework.

Example

Op( Action: Go(there); Precond: At(here);

Effects: At(there), ¬At(here) )

Op( Action: Buy(x), Precond: At(store), Sells(store,x);

Effects: Have(x) )

• A0:– At(Home) Sells(SM,Banana) Sells(SM,Milk)

Sells(HWS,Drill)

• A¥ – Have(Drill) Have(Milk) Have(Banana)

At(Home)

Page 61: For Friday No new reading Logic and Resolution Homework.

POP Algorithm• Stated as a nondeterministic algorithm where

choices must be made. Various search methods can be used to explore the space of possible choices.

• Maintains an agenda of goals that need to be supported by links, where an agenda element is a pair <Q,Ai> where Q is a precondition of Ai that needs supporting.

• Initialize plan to null plan and agenda to conjunction of goals (preconditions of Finish).

• Done when all preconditions of every action in plan are supported by causal links which are not threatened.

Page 62: For Friday No new reading Logic and Resolution Homework.

POP(<A,O,L>, agenda) 1) Termination: If agenda is empty, return <A,O,L>.

Use topological sort to determine a totally ordered plan.

2) Goal Selection: Let <Q,Aneed> be a pair on the agenda

3) Action Selection: Let A add be a nondeterministically chosen action that adds Q. It can be an existing action in A or a new action. If there is no such action return failure. L’ = L È {Aadd ® QAneed} O’ = O È {Aadd < Aneed} if Aadd is new then

A’ = A È {Aadd} and O’=O’ È {A0 < Aadd <A¥} else A’ = A

Page 63: For Friday No new reading Logic and Resolution Homework.

4) Update goal set: Let agenda’= agenda - {<Q,Aneed>}

If Aadd is new then for each conjunct Qi of its precondition,

add <Qi , Aadd> to agenda’

5) Causal link protection: For every action At that threatens a causal link Ap ® QAc add an ordering constraint by choosing nondeterministically either (a) Demotion: Add At < Ap to O’

(b) Promotion: Add Ac < At to O’

If neither constraint is consistent then return failure.

6) Recurse: POP(<A’,O’,L’>, agenda’)

Page 64: For Friday No new reading Logic and Resolution Homework.

Example

Op( Action: Go(there); Precond: At(here);

Effects: At(there), ¬At(here) )

Op( Action: Buy(x), Precond: At(store), Sells(store,x);

Effects: Have(x) )

• A0:– At(Home) Sells(SM,Banana) Sells(SM,Milk)

Sells(HWS,Drill)

• A¥ – Have(Drill) Have(Milk) Have(Banana)

At(Home)

Page 65: For Friday No new reading Logic and Resolution Homework.

Example Steps

• Add three buy actions to achieve the goals• Use initial state to achieve the Sells

preconditions• Then add Go actions to achieve new pre-

conditions

Page 66: For Friday No new reading Logic and Resolution Homework.

Handling Threat

• Cannot resolve threat to At(Home) preconditions of both Go(HWS) and Go(SM).

• Must backtrack to supporting At(x) precondition of Go(SM) from initial state At(Home) and support it instead from the At(HWS) effect of Go(HWS).

• Since Go(SM) still threatens At(HWS) of Buy(Drill) must promote Go(SM) to come after Buy(Drill). Demotion is not possible due to causal link supporting At(HWS) precondition of Go(SM)

Page 67: For Friday No new reading Logic and Resolution Homework.

Example Continued

• Add Go(Home) action to achieve At(Home) • Use At(SM) to achieve its precondition• Order it after Buy(Milk) and Buy(Banana)

to resolve threats to At(SM)