8.0

### 2The Set State Representation

In the set state representation, the world is represented by a set. Actions and goals are represented by set actions and set conditions.

#### 2.1Set Actions

 (require planning/set/action) package: planning

A set action is an action in the set state representation.

 procedure v : any/c
A predicate for set actions.

procedure

 (set-action [ #:requirements requirements #:obstructions obstructions #:additions additions #:deletions deletions #:cost cost]) → set-action?
requirements : (sequence/c any/c) = empty-set
obstructions : (sequence/c any/c) = empty-set
additions : (sequence/c any/c) = empty-set
deletions : (sequence/c any/c) = empty-set
cost : (>=/c 0) = 1
Constructs a set action.

 procedure(set-act s action) → set? s : set? action : set-action?
Performs action on s. If action is not applicable in s, a contract error is raised.

Examples:
 > (set-act (set 1 2 3) (set-action #:additions (set 10) #:deletions (set 2 3)))

(set 1 10)

 > (set-act (set 1 2 3) (set-action #:requirements (set 5) #:additions (set 10)))

set-act: contract violation;

The action must be applicable to the set.

set: (set 1 2 3)

action: (set-action #:additions (set 10) #:cost 1

#:deletions (set) #:obstructions (set) #:requirements (set

5))

in: (->i

((set set?) (action set-action?))

#:pre/name

(set action)

"The action must be applicable to the set."

(set-action-applicable? action set)

(_ set?))

contract from:

<pkgs>/planning/set/action.rkt

blaming: top-level

(assuming the contract is correct)

at: <pkgs>/planning/set/action.rkt:7.3

 procedure(set-action-applicable? action s) → boolean? action : set-action? s : set?
Determines whether or not action is applicable in s: that is, whether or not s meets the action’s preconditions.

 procedure(set-action-requirements action) → set? action : set-action?
Returns the requirements of action.

 procedure(set-action-obstructions action) → set? action : set-action?
Returns the obstructions of action.

 procedure(set-action-additions action) → set? action : set-action?

 procedure(set-action-deletions action) → set? action : set-action?
Returns the deletions of action.

 procedure(set-action-cost action) → (>=/c 0) action : set-action?
Returns the cost of action.

 procedure action : set-action?
Returns a set condition describing the preconditions of action.

 procedure action : set-action?
Returns a set condition describing the postconditions of action.

Examples:
 (define action (set-action #:requirements (set 1 3 5) #:additions (set 2 4) #:deletions (set 5)))

> (set-action-preconditions action)

(set-condition #:obstructions (set) #:requirements (set 1 3 5))

> (set-action-postconditions action)

(set-condition #:obstructions (set 5) #:requirements (set 1 2 3 4))

 procedure(set-invariants s actions) → set-condition? s : set? actions : (sequence/c set-action?)
Determines the invariants of s that is, the conditions that will always be true no matter what sequence of actions from actions are performed.

Examples:
> (set-invariants (set liquid) (set melt freeze))

(set-condition #:obstructions (set) #:requirements (set))

> (set-invariants (set solid liquid) (set evaporate condense))
 (set-condition #:obstructions (set) #:requirements (set #))

#### 2.2Set Conditions

 (require planning/set/condition) package: planning

A set condition is a condition in the set state representation. A set condition is a set of requirements and a set of obstructions. To meet a set condition, a set must contain all of the condition’s requirements and none of its obstructions.

 procedure v : any/c
A predicate for set conditions.

procedure

 (set-condition [ #:requirements requirements #:obstructions obstructions]) → set-condition?
requirements : (sequence/c any/c) = empty-set
obstructions : (sequence/c any/c) = empty-set
Constructs a set condition.

 procedure(set-meets-condition? s condition) → boolean? s : set? condition : set-condition?
Determines whether or not s meets condition. To meet condition, s must contain all of the condition’s requirements and none of its obstructions.

Examples:
 > (define primes (set 2 3 5 7 11)) > (set-meets-condition? primes (set-condition #:requirements (set 7 11))) #t > (set-meets-condition? primes (set-condition #:obstructions (set 2 4 6 8))) #f > (set-meets-condition? primes (set-condition #:obstructions (set 4 6 8))) #t

 procedure(set-condition-requirements condition) → set? condition : set-condition?
Returns the requirements of condition.

 procedure(set-condition-obstructions condition) → set? condition : set-condition?
Returns the obstructions of condition.