These elements can appear in any order. Every element except for comments ends with a period.
The syntax of these elements is defined below, mostly using EBNF notation. The following symbols belong to EBNF notation:
::=, |, [ ], { }.The vertical bar expresses disjunction, the square brackets mean that what they enclose is optional, and the braces are used for grouping. Nonterminals begin with a capital letter. Many of the parentheses in this grammar can be dropped due to operator precedences.
An integer is a whole number in the usual decimal notation, such as 5 or -20. Extended integers are expressions that are evaluated to integers in the process of operation of CCalc. They have the following syntax:
ExtendedInteger ::= Integer | maxstep | - ExtendedInteger | ( ExtendedInteger { + | - | * | // | mod } ExtendedInteger )The second operand of // (which stands for integer division) and the second operand of mod must have nonzero values.
If a symbol is declared more than once then all its declarations must put it in the same group. The first declaration of an identifier must occur before its first use. Certain reserved words and predeclared identifiers cannot be declared.
Every declaration begins with :- followed by the name of the group and by a tuple of one of more elements separated by semicolons. If the tuple consists of several elements then the declaration has the same meaning as several declarations, each containing one element. For instance, the declaration
:- variables B,B1 :: block; L :: location.has the same meaning as two declarations
:- variables B,B1 :: block. :- variables L :: location.
:- sorts index; location >> block >> ( smallBlock ; largeBlock ).expresses that there are five sets of objects -- indices, locations, etc. -- and also that every block is a location, every smallBlock is a block, and every largeBlock is a block.
Sorts are denoted by identifiers, and their declarations have the following syntax:
SortDeclaration ::= :- sorts SortSpecTuple . SortSpecTuple ::= SortSpec | ( SortSpecTuple ; SortSpecTuple ) SortSpec ::= SortIdentifier | ( SortIdentifier >> SortSpecTuple ) SortIdentifier ::= IdentifierTwo sorts are standard in CCalc:
boolean | The objects of this sort are false and true. | |||
step | The objects of this sort are the nonnegative integers that are less than or equal to maxstep. |
:- objects table :: location; 1..10 :: index; box(index) :: block.expresses that table is an object of sort location, that numbers 1,...,10 are objects of sort index, and that the identifier box followed by an object of sort index enclosed in parentheses is an object of sort block.
ObjectDeclaration ::= :- objects ObjectSpecTuple . ObjectSpecTuple ::= ObjectSpec | ( ObjectSpecTuple ; ObjectSpecTuple ) ObjectSpec ::= ( ObjectSchemaList :: SortIdentifier ) ObjectSchemaList ::= ObjectSchema | ( ObjectSchemaList , ObjectSchemaList ) ObjectSchema ::= ExtendedInteger | ( ExtendedInteger .. ExtendedInteger ) | ObjectIdentifier [ ( SortIdentifierList ) ] SortIdentifierList ::= SortIdentifier | ( SortIdentifierList , SortIdentifierList ) SortIdentifier ::= IdentifierA set of object declarations and a set of sort declarations characterize the set of objects represented by each of the sorts. For instance, given the object declarations and the sort declarations in the examples above, the set of locations is
box(1), ..., box(10), table.The set of object declarations in a CCalc input file must be acyclic. For instance,
next(index) :: indexis not allowed. The acyclicity condition guarantees that the set of objects of each sort is finite.
VariableDeclaration ::= :- variables VariableSpecTuple . VariableSpecTuple ::= VariableSpec | ( VariableSpecTuple ; VariableSpecTuple ) VariableSpec ::= ( VariableList :: SortIdentifier ) VariableList ::= VariableIdentifier | ( VariableList , VariableList ) VariableIdentifier ::= Identifier
:- constants unlimitedResources :: boolean; loc(block) :: fluent(location).expresses that the identifier unlimitedResources is a boolean constant, and that the identifier loc followed by an object of sort block enclosed in parentheses is a simple fluent constant whose domain is the set of locations.
Syntactically, one of the differences between an object declaration and a constant declaration is that the symbol :: in a constant declaration can be followed not only by a sort, such as boolean, but also by a composite sort, such as fluent(location). As another example of the use of composite sorts, we can declare a boolean statically determined fluent constant using the composite sort sdFluent(boolean), or simply sdFluent, because of the convention that the part (boolean) in a composite sort can be dropped. It is convenient to allow such composite sorts as rigid(location); this expression has the same meaning as sort identifier location.
A composite sort can be also used to declare an attribute of an action, for instance:
:- constants destination(block) :: attribute(location) of move(block).This declaration tells us that identifier destination followed by an object of sort block enclosed in parentheses is an action constant whose domain consists of the locations and the predeclared object na ("not applicable"). Furthermore, it tells us that this action constant is an attribute of the action of moving that block.
ConstantDeclaration ::= :- constants ConstantSpecTuple . ConstantSpecTuple ::= ConstantSpec | ( ConstantSpecTuple ; ConstantSpecTuple ) ConstantSpec ::= ( ConstantSchemaList :: { SortIdentifier | CompositeSort } ) ConstantSchemaList ::= ConstantSchema | ( ConstantSchemaList , ConstantSchemaList ) ConstantSchema ::= ConstantIdentifier [ ( SortIdentifierList ) ] CompositeSort ::= rigid [ ( sortIdentifier ) ] | fluent [ ( sortIdentifier ) ] | sdFluent [ ( sortIdentifier ) ] | inertialFluent [ ( sortIdentifier ) ] | action [ ( sortIdentifier ) ] | attribute [ ( sortIdentifier ) ] of ConstantSchemaIn an attribute declaration, the ConstantSchema must satisfy two conditions. First, its ConstantIdentifier must be a boolean action constant. Second, its SortIdentifierList, if any, should be a prefix of the SortIdentifierList in each ConstantSchema that is being declared.
:- tests even/1 :: 'tests.pl'.expresses that even is a unary predicate defined in file tests.pl.
TestDeclaration ::= :- tests TestSpecTuple . TestSpecTuple ::= TestSpec | ( TestSpecTuple ; TestSpecTuple ) TestSpec ::= TestList :: ' Filename ' TestList ::= TestIdentifier / Arity | ( TestList , TestList ) TestIdentifier ::= Identifier Arity ::= Integer
5.1. Include
The include directive is used to include files during loading. The syntax
is as follows.
IncludeDirective ::= :- include PathnameTuple . PathnameTuple ::= ' Pathname ' | ( PathnameTuple ; PathnameTuple ) Pathname is the name of a file.
5.2. Show
6. Comments
A comment is the text appearing on a line following a % or
appearing on one or more lines between /* and */.
7. Reserved Words and Predeclared Identifiers
The following identifiers are reserved words in the language of CCalc:
action after anyAction anyFluentValues anyInitialState attribute cause caused causes constants constraint cwaActions default exogenous fluent inertial inertialFluent if include |
label macros may maxstep mod never nonexecutable objects of possibly query rigid sdFluent show sort sorts tests variables where |
boolean | sort | |||
false | object of sort boolean | |||
maxstep | object of sort step | |||
na | object | |||
step | sort | |||
true | object of sort boolean |