TLPlan

Disclaimers

Copyright (c) 1998, 2003, Fahiem Bacchus and Michael Ady. All rights reserved. Use of this software is permitted for non-commercial research purposes, and it may be copied only for that use. All copies must include this copyright message. This software and any documentation and/or information supplied with it is distributed on an as is basis. Fahiem Bacchus, Michael Ady and the University of Toronto make no warranties, express or implied, including but not limited to implied warranties of merchantability and fitness for a particular purpose, regarding the documentation, functions or performance of such software, documentation and/or information.

Acknowledgments

Microsoft, Windows 95, Windows 98, Windows NT, Windows 2000, Windows XP and MS-DOS are trademarks or trade names of Microsoft Corporation.

UNIX is a trademark of X/Open Company Ltd.

Intel and Pentium are trademarks or trade names of Intel Corporation.

Sun, Sun Microsystems, SunOS and Solaris are trademarks or trade names of Sun Microsystems Inc.

This software was developed with support from the Canadian Government through their NSERC and IRIS programs.

Installation.

The system is distributed as a tar file named tlplan.tar Follow the following sequence of steps.

  1. Place tlplan.tar in the directory you want to store tlplan. Then move to that directory (i.e., make it your current directory).
  2. tar -xvf tlplan.tar (note that the tar file will not create a new top level directory---it will create a subdirectory called Blocks).
  3. Either move libtl.so to a directory accessible to the loader, or change the environment variable LD_LIBRARY_PATH so that the loader can find libtl.so. (Remember that LD_LIBRARY_PATH must be accessible to all subproceses, so, e.g., cshrc it must be a setenv variable).

The README file gives a bit more detail, and there is also a “runtlplan” file that can be edited and used to invoke tlplan. To test, move to the sub-directory and invoke

tlplan runblockstest.tlp

This should result the creation of a file “tlplan.log” containing a plan for a random 1000 blocksworld problem (a random problem generated by the Slaney-Thiébaux generator, John Slaney and Sylvie Thiébaux Blocks World revisited Artificial Intelligence 125 (2001): 119-153). On a 2Gz this will take about 1/3 of a sec. The script file will also terminate tlplan with an (exit) command. Comment out (with a “;”) this command if you want to enter an interactive session after the plan has been completed.

Overview

The best place to start is to browse the paper Using Temporal Logics to Express Search Control Knowledge for Planning. In particular, look at the section that describes the design of Tlplan. The basic steps are

  1. Defining the planning domain. First one tells the planner about the predicate and function symbols to be used in the domain. You must have some described symbols (these are the basic predicates and function that get updated by actions), and you can have defined symbols (defined by first-order formulas) and external symbols (used to invoke external C routines). Once all of the symbols have been defined, you can talk about the domain using the first-order language generated by these predicate and function symbols. The symbols declared to be defined must subsequently be given definitions. Then one can define the domain's actions. These can be defined using standard STRIPS operators or using ADL operators. To fully understand ADL actions you must understand how formulas are evaluated (see the paper cited above). Both STRIPS and ADL operators generate first-order formulas that are evaluated in thee current world to generate the successor worlds. In particular, the adds and deletes of the ADL operators are activated if and only if the evaluator evaluates the add/del clause in the operator (this in turn is controlled by the evaluator's rules for early termination). Note that functions can be used and updated by including a function specification inside of an add clause, and ADL operators can specify a recursive set of updates by invoking recursive defined predicates in their set of clauses.
  2. Defining the search control for the domain. Unless you are dealing with a very simple domain you will need to specify domain specific search control. The main mechanism for doing so is to specify a temporal logic formula using set-tl-control. See the paper cited above to understand how temporal formulas allows one to control search. Also see the various domains that come with the planner for an extensive set of examples. In addition to temporal formulas the user may specify the planner's search strategy (depth-first, best-first, etc.) and may also specify a heuristic function for best-first search. See the file "tlplan/domains/Eight/EightWorld.tlp" for an example of searching Lloyd's sliding tile puzzle using the standard Manhattan distance heuristic.
  3. Specify the initial world and the goal. The initial world and goal are specified using a list of predicate and function specifications. If one sets the goal type to be "extended" then the goal can be an arbitrary temporal formula. If every initial world in this domain has some special features, or one wants to initially set up some additional described predicates and functions, the special commands set-initialization-sequence and set-initial-facts can be used.
  4. Running the Planner. To run the planner one loads the domain definition file sets the initial world and goal, and then invokes the planner with the command plan.

Notes:

  • The planner's top level evaluates first order formulas. All (almost all) of the planner's commands are pseudo-predicates that return true or false (usually false on error). So for example the command (implies (plan) (print 0 "Found Plan!")) will invoke the planner (by evaluating the pseudo-predicate (plan)), and if the plan succeeds (if the pseudo-predicate evaluates to true) will then evaluate the pseudo-predicate (print ...). This facility can be used to effect complex control over the search for a plan.
  • One can use local variables in defined predicates and functions and can define global variables with various lifetimes. Such variables are useful for optimizing various computations, for storing information gathered during search, etc.
  • There are a number of built in arithmetic functions and generators than are quite useful.
  • There are many options for printing out information. For example, one can define a domain specific print function by defining a predicate whose formula involves evaluating the pseudo-predicate print. In addition, one can open and redirect various file streams to which output can be directed.
  • One can either load a domain file by using the loadfile command or by informing the planner of the collection of files that make up the domain (using the def-domain command) and then loading them all with the load-domain command. The file "tlplan/domains/domains.tlp" contains a domain definition for the standard domains.
  • There are commands for interrogating the worlds in a plan, and for printing out various statistics gathered during planning.
  • Different random number generators are built into the planner.

Contents

Commands for Defining a Domain

Initializations and Declarations

Definitions

Syntax of Formulas

Commands for Defining Operators

Defining STRIPS Operators

Defining ADL Operators

Commands for Controlling the Planner

Search Cost and Priority Routines

Controlling information generated during planning

Commands for Running the Planner

Commands for Specifying and Manipulating Worlds

Specifying Initial Worlds

Commands for Handling Files and I/O

File Operations

Printing

Commands for Installing a Domain

Utility Routines

Routines for Interrogating the Current World

Routines for Retrieving Planning Statistics

Arithmetic Functions and Predicates

Random Number Generators

Generators

World Context Selectors

Miscellaneous Routines

 

User Libraries

CDF – Cumulative Distribution Functions

 

Commands for Defining a Domain

Initializations and Declarations

(clear-world-symbols)

Type: Pseudo-predicate returning true.

Description: Clear the previous domain's language definition. This command must be called first in a new domain definition file. This command also calls the reset-print-world-fn command and reset-tl-control. These commands reset the temporal control formula and the print world command to their defaults.

(declare-defined-symbols (function|predicate|generator name arity) ...)

Type: Pseudo-predicate returning false on error.

Description: Declare the defined predicate, function and generator symbols of the domain. The defined symbols must be declared after the described symbols.  name is the name of the defined symbol (i.e. function, predicate or generator).  arity specifies the number of parameters accepted by the defined symbol.

(declare-described-symbols (function|predicate name arity [no-cycle-check|rewritable]) ...)

Type: Pseudo-predicate returning false on error.

Description: Declare the described predicate and function symbols of the domain. The described symbols must be declared prior to any other symbols.  name is the name of the described symbol (i.e. function or predicate).  arity specifies the number of parameters accepted by the described symbol. 

Optionally, either qualifier, no-cycle-check and/or rewritable may be specified.  If no-cycle-check is specified, then the associated described symbol will be excluded from cycle-checking.  The planner can spend a significant amount of time doing cycle-checking, and in some circumstances performance can be greatly improved by excluding certain described symbols from cycle checking.  This option can be specified if a particular function/predicate value never changes, or if it does not affect any of the decisions made by the planner.  

By default, TLPlan, complains whenever a described predicate is add’ed whenever it is already asserted or true. If rewritable is specified for a described predicate, then this warning is suppressed.  The use of this option is not recommended unless you are trying to get someone else’s domain to work under TLPlan (i.e. the domain semantics are defined for some other planner).  If TLPlan complains with “Rewriting predicate symbol…” for domains you have written yourself, then it is most likely that you have a logical error in you domain definition.   Rather than specifying rewritable for a particular described predicate, first consider if you have failed to add or delete the symbol in some operator, and you will almost certainly discover a logical error.

(declare-external-symbols library
(function|predicate|generator|macro name libref arity) ...)

Type: Pseudo-predicate returning false on error.

Description: Declare the externally defined predicate, function, generator and macro symbols of the domain. External symbols must be declared before they are used. library, is the location and name of the user library. A separate call to assign a value to the function's name. Note that formula may include a reference to the current function (thus recursive function definitions are allowed). To use this feature be sure you understand the evaluator's early termination rules. With early termination formula can be written so as to ensure any recursion terminates.

While parameters and local variables are "local" to the defined function, they are "global" to all formulas evaluated as a consequence of evaluating formula.

(def-defined-generator (name parameters) (local-vars declarations) formula)

Type: Pseudo-predicate returning false on error.

Description: Include a new generator, defined in the domain language. name is a symbol which names the new generator. parameters is a list of variables that are the arguments of the new generator. declarations is an optional list of local variables and arrays.

formula is evaluated to calculate the value(s) of the generator (as a side-effect). To return generated values, the generator must assign each value to the appropriate parameter in the parameters list.

In addition to its parameters, each generator is passed a value that indicates whether it is being called for the first time or not. This value is passed in a variable with the same name as the generator, but with a leading '?'. This variable has a value of 0 the first time the generator is called, and a value of 1 each time thereafter.

The first time a generator is called, it must initialize its context and save important information in its declared local-vars. Each time the generator successfully generates a new value or set of values, formula must evaluate to true. When the generator has generated all possible values and wishes to terminate, formula must evaluate to false.

While parameters and local variables are "local" to the defined generator, they are "global" to all formulas evaluated as a consequence of evaluating formula.

(def-defined-predicate (name parameters) (local-vars declarations) formula)

Type: Pseudo-predicate returning false on error.

Description: Include a new predicate, defined in terms of a first-order formula involving other predicates, in the domain language. name is a symbol naming the new predicate. parameters is a sequence of variables that are the arguments of the new predicate. declarations is a list of local variables and arrays. formula is a first-order formula that defines the new predicate. Note that formula may include a reference to the current predicate (thus recursive predicate definitions are allowed). To use this feature be sure you understand the evaluator's early termination rules. With early termination formula can be written so as to ensure any recursion terminates.

While parameters and local variables are "local" to the defined predicate, they are "global" to all formulas evaluated as a consequence of evaluating formula.

(define name list)

Type: Pseudo-predicate returning false on error.

Description: Define name as an abbreviation for list. This allows macro substitution in domain definition files.

(:= ?variable value)

Type: Pseudo-predicate returning false on error.

Description: := is a pseudo-predicate that assigns value to ?variable. Note that := is only used to assign values to variables. = is used to assign values to described functions (among other things).

Syntax of Formulas

Terms

constant

Type: Term.

Description: Any symbol, number, or string is a term.

?variable

Type: Term.

Description: Any symbol that starts with ? is a variable, and is also a term.

(?array index ...)

Type: Term.

Description: An array reference is a special type of variable, and is also a term. The declared dimension of the array must agree with the number of indices given.

(function term ...)

Type: Term.

Description: A list consisting of a function name followed by a sequence of terms is a term. function is a symbol that has been declared to be a domain function by one of the initial declarations. (See Initializations and Declarations.) The arity of function must agree with the number of terms given. Note that any of the built-in arithmetic functions can be used as functions (they do not need to be declared).

Atomic Formulas

(predicate term ...)

Type: Predicate.

Description: A list consisting of a predicate followed by a sequence of terms is an atomic formula. predicate is a symbol that has been defined to be a domain predicate one of the initial declarations. (See Initializations and Declarations.) The arity of predicate must agree with the number of terms given.

(= term1 term2)

Type: Predicate.

Description: Equality is a predefined binary predicate.

(TRUE)

Type: Predicate.

Description: The constant atomic formula that always evaluates to true.

(FALSE)

Type: Predicate.

Description: The constant atomic formula that always evaluates to false.

First-Order Formulas

atomic-formula

Type: Predicate.

Description: Any atomic formula is a first-order formula.

(and formula ...)

Type: Predicate.

Description: The logical and of a sequence of formulas.

(or formula ...)

Type: Predicate.

Description: The logical or of a sequence of formulas.

(xor formula ...)

Type: Predicate.

Description: The logical exclusive or of a sequence of formulas.

(not formula)

Type: Predicate.

Description: The logical negation of formula.

(implies formula1 formula2)

Type: Predicate.

Description: Logical implication, the result is true iff formula1 and formula2 are both true or formula1 is false.

(if-then-else formula1 formula2 formula3)

Type: Predicate.

Description: The result is true iff formula1 and formula2 are both true, or formula1 is false and formula3 is true.

(forall var-gen ... [formula])

Type: Predicate.

Description: Universal quantification, the formula is true iff formula is true for all bindings of the variables in var-gen that are generated by the generator in var-gen. This formula is trivially TRUE if the final formula is missing.

Multiple var-gens may appear in a quantified formula. This is shorthand for a nested invocation of the quantifier. For example, the formula:

(forall (?x) (at ROBOT ?x) (?y) (in ?x ?y) ...)

is equivalent to:

(forall (?x) (at ROBOT ?x) (forall (?y) (in ?x ?y) ...))

(exists var-gen ... [formula])

Type: Predicate.

Description: Existential quantification, the formula is true iff formula is true for some binding of the variables in var-gen that are generated by the generator in var-gen. The last item, formula, is optional. If it is absent then the formula is true iff the generator in var-gen generates some binding for the variables in var-gen.

Once again, multiple var-gens may appear in a quantified formula as shorthand for a nested invocation of the quantifier. For example, the formula:

(exists (?x) (at ROBOT ?x) (?y) (in ?x ?y) ...)

is equivalent to:

(exists (?x) (at ROBOT ?x) (exists (?y) (in ?x ?y) ...))

(exists! var-gen ... [formula])

Type: Predicate.

Description: Unique existential quantification, the formula is true iff formula is true for exactly one binding of the variables in var-gen that are generated by the generator in var-gen. If formula is absent then the formula is true iff generator generates only a single binding for the variables in var-gen.

When multiple var-gens appear in a quantified formula, it is shorthand for a nested invocation of the quantifier. For example, the formula:

(exists! (?x) (at ROBOT ?x) (?y) (in ?x ?y) ...)

is equivalent to:

(exists! (?x) (at ROBOT ?x) (exists! (?y) (in ?x ?y) ...))

Generators

(predicate-generator term ...)

Type: Generator.

Description: Any described predicate can serve as a generator. Every one of the immediately enclosing quantifier's variables must appear as a term of this formula. Additional variables appearing in term ... must have been bound by earlier quantifiers.

(= (function term ...) value)

Type: Generator.

Description: Any described function can be a generator. Every one of the immediately enclosing quantifier's variables must appear as a term of the function. Additional variables appearing in value and term ... must have been bound by earlier quantifiers.

Note that described functions generate at most one binding of the quantified variables.

(computed-generator term ...)

Type: Generator.

Description: An internal or user defined computed generator can be used as generator. Every one of the immediately enclosing quantifier's variables must appear as a term of the generator. Additional variables appearing in term ... must have been bound by earlier quantifiers. Look here for a list of the available internal generators, external or user defined generators are described here.

Syntax of Temporal Logic Formulas

first-order-formula

Type: Temporal formula.

Description: Any first-order formula is a temporal formula, as is any first-order formula that contains temporal formulas.

(next tf)

Type: Temporal formula.

Description: This formula is true of a sequence of states iff the temporal formula tf is true in the next state.

(eventually tf)

Type: Temporal formula.

Description: This formula is true of a sequence of states iff the temporal formula tf is true of some future state.

(t-eventually ispec tf)

Type: Temporal formula.

Description: This formula is true of a sequence of states iff the temporal formula tf is true of some future state in the interval ispec.

(always tf)

Type: Temporal formula.

Description: This formula is true of a sequence of states iff the temporal formula tf is true for all future states.

(t-always ispec tf)

Type: Temporal formula.

Description: This formula is true of a sequence of states iff the >Description: This formula is true of a sequence of states iff the temporal formula tf1 is true in all states until a state is reached where tf2 is true. Note that if tf2 is true in the current state, then so is the until formula.

(t-until ispec tf1 tf2)

Type: Temporal formula.

Description: This formula is true of a sequence of states iff the temporal formula tf1 is true in all states until a state is reached in the interval ispec where tf2 is true.

(delta tf)*

Type: Temporal formula.

Description: The user should not use this temporal formula constructor. It is used internally by the planner while progressing formulas. This formula is true iff tf

(binding (variables) (values) tf)

Type: Temporal formula.

Description: The user should not use this temporal formula constructor. It is used internally by the planner while progressing formulas. This formula is true iff tf is true when the variables (that appear in tf) are bound (sequentially) to values.

Modalities

Modalities cause their arguments to be evaluated in the context of another world. Modalities can be applied to any first-order formula, temporal formula or generator, and the result, respectively, is a first-order formula, a temporal formula or a generator.

(goal formula|tf|generator)

Type: Modality.

Description: The specified first-order formula, temporal formula or generator is evaluated in the goal world. The goal modality can only be used when dealing with classical goals.

(previous formula|tf|generator)

Type: Modality.

Description: The specified first-order formula, temporal formula or generator is evaluated in the previous state. (previous tf) is always false in the initial world.

(current formula|tf|generator)

Type: Modality.

Description: The specified first-order formula, temporal formula or generator is evaluated in the current state. This modality is used with select-initial-world, select-final-world, select-previous-world and select-next-world to interrogate the results of a planning session.

 

Commands for Defining Operators

Defining STRIPS Operators

(def-strips-operator name pre del add cost duration priority)

Type: Pseudo-predicate returning false on error.

Description: This command defines a new STRIPS operator. It accepts seven sub-clauses, described below:

(name v ...)

The name clause declares the name of the operator and its parameters. The operator is given the name symbol, and the variables, v ..., are declared to be arguments of the operator.

When the variables are instantiated, the name and instantiated variables should provide a unique name for the action. This helps to make clear, just which operator generated each world. However, there is no requirement that the name clauses of distinct operators be distinct themselves. Sometimes this feature can be put to good use, allowing a single logical operation to be split up and then handled by two or perhaps more operators.

(pre formula ...)

The pre clause declares the precondition list. This is a list of conditions that must be satisfied before applying the operator. It is a list of atomic formulas, including negations of atomic formulas, i.e., expressions of the form (not atomic-formula). Arbitrary terms can appear in the atomic formulas. However, every variable in the list of preconditions must first appear as a term of a non-negated described predicate. Furthermore, every variable in the name clause must appear as a term in at least one formula of the pre clause.

(add p ...)

The add clause declares the additions list. The additions list specifies the described predicates that are added to the new world by the action. The additions list can also specify updates to described functions which have their values modified in the new world by the action.

The additions list is a list of atomic formulas formed from described predicates and described functions. Arbitrary terms are allowed in these predicates, but every variable that appears in these terms must have previously appeared in the pre clause.

(del p ...)

The del clause declares the delete list. The delete list specifies the described predicates (and described functions) which are removed from the world by the action. This clause has the same format as the add clause.

When modifying the value of a described function, it is not necessary to first delete the previous value of the function, before adding the new value. This action is implied by the add. The only time that the value of a described function might possibly need to be deleted would be to make the value of the function in question undefined.

(cost n)

The cost clause specifies the cost of the action, n. n may be a number or a term which evaluates to a number. The default cost is 1.

(duration n)

The duration clause specifies the duration of the action, n. n may be an number or a term which evaluates to a number. The default duration is 1.

(priority n)

The priority clause specifies the priority of the action, n, an integer. The priority is used during search to order the successors of a world (dependent on the search strategy). It defaults to 0. Operations with higher priorities are selected before those with lower priorities by priority-based search strategies.

Defining ADL Operators

(def-adl-operator name pre modifier-clauses cost duration priority)

Type: Pseudo-predicate returning false on error.

Description: This command defines a new ADL operator. It accepts six sub-clauses, described below.

(name v ...)

The name clause declares the name of the operator and its parameters. The operator is given the name symbol, and the variables, v ..., are declared as the arguments of the operator.

(pre var-gen ... [formula])

The pre clause declares the precondition list. It contains a sequence of one or more variable-generator pairs and a single, optional, first-order formula. It can be viewed like a quantifier, and has the same syntax as, for example, the forall quantifier. Each binding of the variables contained in var-gen that for make formula true generates a single instance of the ADL action that can be applied to the current world.

modifier-clauses

Each ADL operator must contain one or more modifier clauses. The modifier clauses describe what changes to make in the current world to create the new world generated by each of its instances. Each modifier clause is an arbitrary first-order formula with the addition of one or more add or del meta-predicate clauses.

The add and del clauses have the same syntax as the corresponding STRIPS clauses. However, within ADL operators, add and del act as meta-predicates that always evaluate to true. Thus in general, they may appear in modifier clauses anywhere an atomic formula may appear (except not as generator literals). add and del are meta-predicates since they take atomic formulas as arguments.

Modifier clauses are preprocessed internally by the planner so that all deletions act before all additions. When a modifier clause contains both add and del predicates, the planner acts as if it duplicates the clause, and removes all of the add meta-predicates from the first copy, and all of the del meta-predicates from the second.

(cost n)

The cost clause specifies the cost of the action, n. n may be a number or a term which evaluates to a number. The default cost is 1.

(duration n)

The duration clause specifies the duration of the action, n. n may be an number or a term which evaluates to a number. The default duration is 1.

(priority n)

The priority clause specifies the priority of the action, n, an integer. The priority is used during search to order the successors of a world (see search strategy). It defaults to 0.

 

Commands for Controlling the Planner