Note that p is declared here as an inertialFluent, rather
than simply a fluent, and a is declared as an
exogenousAction, rather than simply an action. See
Section 0.2 above for a brief, informal
discussion of these ideas.
Transition system TS2
is actually a family of transition systems, one for each value of N.
The following piece of code defines the system corresponding to N=3:
The causes propositions in this example follow a simple pattern, and
the input language of CCalc allows us to use this fact to make the action
description more compact:
The last piece of code can be further improved by treating the value of
N as a macro:
:- constants
p :: inertialFluent;
a :: exogenousAction.
a causes p.
This description consists of the declarations of the constants p
and a (the first 3 lines) and a proposition (the last line).
The declaration part begins with the heading :- constants and
ends with a period. The proposition is followed by a period also. A semicolon
separates the two declarations from each other. Within each declaration, the
symbol :: separates the constant that is being declared from the
symbol that indicates what kind of constant it is.
:- constants
c :: inertialFluent(0..3);
a :: exogenousAction.
a causes c=1 if c=0.
a causes c=2 if c=1.
a causes c=3 if c=2.
nonexecutable a if c=3.
In the declaration of c, the symbol inertialFluent is
followed by (0..3) to indicate that the possible values of this
fluent are integers between 0 and 3, rather than f and t.
Each of the causes propositions is conditional -- it includes
if. For instance, the
first of them describes the effect of action a when it is executed
in a state satisfying c=0.
The nonexecutable proposition in the last line tells us that the
transition system does not have an edge that begins at the vertex
c=3 and is labeled a=t. (Without this proposition,
such an edge would be included in the transition system, according to the
semantics of
C+. Since the causes propositions in this action description do not
postulate any effect of a on c when c=3, this edge, by
inertia, would be a loop.)
:- constants
c :: inertialFluent(0..3);
a :: exogenousAction.
:- variables
I :: 0..2.
a causes c=I+1 if c=I.
nonexecutable a if c=3.
The letter I is declared here to be a variable ranging over
0,1,2, and we use it in a "schematic proposition" that represents
a set of 3 instances. In CCalc code, capital letters and identifiers
beginning with a capital letter are customarily used as variables, but not
as constants (or as anything else, for that matter). This convention is
related to the fact that CCalc is written in Prolog. Violating this
convention is considered, in some cases, a syntax error.
:- macros
n -> 3.
:- constants
c :: inertialFluent(0..n);
a :: exogenousAction.
:- variables
I :: 0..n-1.
a causes c=I+1 if c=I.
nonexecutable a if c=n.
The macro definition instructs CCalc to replace every
occurrence of n in the rest of the file by 3, as a
preprocessing step.