Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Cognitive Modeling Language

This is a description of the Cognitive Modeling Language used to describe HTNs and other planning models.

Cognitive model source files consist of a package and a set of domains. Follow the links in the diagram to see details about each element.

References to deferred planning and the use of the defer keyword are forward looking descriptions. Explicit deferred planning is not yet supported by the planning engine.

package namespace domain

Example:

package com.ursafrontier.tutorials

domain games.rings-and-poles

...

Achievement

achieves name

Action

action cap_name , { property_definition } costs

Example:

action PlaceRing {
    integer ring
    string pole
}
costs {
  time = 1
  effort = 1 / ring
}

Action Invocation

namespace . cap_name ( kwarg , ) event_expectations

And Expression

unary_rel_expression and

And Predicates

and predicate_union ,

The comma (,) separating predicate unions can be spelled and if desired. You may have to use paranethesis to avoid ambiguity since the comma binds looser than the or keyword but the and keyword binds tigher than the or keyword.

Array Type

[ type ]

Behavior

behavior cap_name { trigger }

Example:

behavior PlayRingsAndPoles {
    when PlayGame() {
        play(rings)
    }
}

Binding Variables

? name

Binding variables are used to pull information from the agent state during planning. They may only be used in the preconditions or guards of methods or macros. A collection of guards fails if the binding variables can’t be assigned values that satisfy all the guards.

The planner must be able to assert a set of potential values for each binding variable based on inspecting the predicates in the guard clauses. That is, each binding variable must appear by itself as a predicate argument or as the variable being tested for inclusion in a set. Function calls or other expressions are only used to filter the set of potential values.

Example:

take(block) when clear(block), pos(block, ?pos), ?pos != "table", not holding("hand", _) {
  ...
}

Calculation

CapName

[A-Z] - \_ [A-Za-z] [0-9]

Choice

Cost

name = statement

Costs

costs { cost }

Costs may be associated with actions, methods, and tasks. Costs for methods and tasks are only used when task expansion is deferred.

You can associate as many costs as needed with an action, method, or task. The planning engine will only calculate those costs necessary to satisfy the cost criteria when planning.

Cost Bound

with relational_expression ,

Cost Limit

minimizing maximizing expression

Domain

domain namespace action behavior event function method perception task

Event

event cap_name , { property_definition }

Event Expectation

namespace . cap_name ( kwarg , ) as name is success failure

Event Expectations

{ event_expectation }

Expression

name = statement and_expression or

Function

function function_name ( function_arg , ) preconditions { statement }

Function Arg

type name

Function Name

name ?

Horizon

defer when relational_expression ,

Implication

not predicate name = expression

Inclusion

Map Type

[ type , type ]

Method

name ( function_arg , ) achievement preconditions { method_step }

A method that isn’t tied to a task is considered a macro in automated planning. The planner treats it as if it were a method attached to a task with the same name.

Method Step

action_invocation implies implication , choice calculation task_invocation ( method_step )

Name

[a-z] - \_ [A-Za-z] [0-9]

Namespace

name .

Perception

perception name ( function_arg , ) => type

Perceptions are not yet used by any system. They are included for future use.

Perceptions define a function that the cognitive model can use to query the environment. The implementation depends on the environment in which the cognitive model runs, similar to how action adjudication is handled.

Postconditions

implies implication ,

Preconditions

when predicates

Preconditions may not have binding variables when associated with a function definition.

Predicate

function_name ( predicate_arg , )

Predicates

predicate_union ,

The comma (,) separating predicate unions can be spelled and if desired. You may have to use paranethesis to avoid ambiguity since the comma binds looser than the or keyword but the and keyword binds tigher than the or keyword.

Predicate Arg

unused_name expression

Predicate arguments in guard clauses may contain binding variables when guarding a method rather than a function. These won’t appear in the syntax diagrams, but they may be used where any variable would be present in the guard expression.

An “unused name” is a placeholdeer variable in a predicate that indicates that the value in that position is not used. That is, when evaluating the predicate, the value in that position is free to be anything. This only works with predicates. For example, the predicate foo(_, 1, _) matches any value in the first and third positions and only matches the value 1 in the second position. Obviously, this doesn’t work with functions since the function operates on the values in the arguments.

Predicate Union

not predicate inclusion relational_expression or

Property Definition

type name = constant

Relational Expression

sum_expression == != < <= > >= sum_expression

Statement

expression ( statement )

A parenthesized list of statements has its own scope, so any variables set will be unset when leaving the parenthesis. The value of a list of statements is the value of the last statement in the list.

Example:

x = 3
y = (
  x = 4
  x * 2
)

At the end of this code, x will be 3 and y will be 8.

Sum Expression

product_expression + - product_expression

Task

name ( function_arg , ) preconditions postconditions

When using an HTN planner, task preconditions and postconditions are not evaluated unless the task expansion is explicitely deferred.

Task Invocation

defer namespace . name ( expression , )

A task, method, or macro invocation looks identical to a function call except that functions may only be called as parts of expressions and tasks, macros, and methods are never part of expressions. The defer keyword marks the task, macro, or method so that the planner does not expand it during the planning phase. If a task is deferred, then the planner will use the preconditions and implications of the task to test and update the hypothetical state of the planner.

If a macro or method is deferred, then the planner will not update any hypothetical state. This may cause the planner to mark the plan as incomplete but successful, with the remaining planning implicitely deferred until execution reaches the deferral point.

Trigger

when cap_name ( kwargs ) and_predicates { method_steps } cost_limit cost_bound horizon

Type

signed unsigned integer real boolean char string array_type map_type

Unary Relational Expression

not expression rel_expression

Unused Name

\_ name