1.2. CCalc Input: Queries

A query in CCalc input begins with the expression :- query and ends with a period. A query is a question about paths in the transition system under consideration (see Section 0.3). The length of the paths is denoted by the expression maxstep, so that the paths have the form

<v0, e0, v1, e1, ..., vmaxstep>

where vi are vertices and ei are edges.

For instance, the query

:- query
 maxstep :: 1.
calls for finding paths of length 1, that is to say, edges of the transition system.

Here is how the language of CCalc can express the examples from Section 0.3. The prediction problem -- a question about the path in TS2 of length 2 that starts at the vertex c=5 and has both edges labeled a=t -- can be encoded as

:- query
 maxstep :: 2;
 0: c=5;
 0: a;
 1: a.
Prefixing a constant or a condition with i: indicates that it is evaluated at the vertex vi or the edge ei. For instance, the expression 0: c=5 in this query means that the condition c=5 holds at the starting vertex v0 of the path. Similarly, 0: a and 1: a mean that the labels of e0 and e1 assign to a the value t. Note that the colon in each of these expressions is separated from the formula that follows by a space; without such a space, CCalc may parse the expression incorrectly. The part
 0: c=5;
 0: a;
can be also written as
 0: c=5, a
or as
 0: c=5 & a

To express the postdiction problem from Section 0.3 -- a question about the path of length 2 that ends at c=5 and has both edges labeled a=t -- we only need to replace the part 0: c=5 in the query above with

2: c=5
Alternatively, we can write this line as
maxstep: c=5
because CCalc treats every occurrence of maxstep in a query after its first occurrence as a macro for the corresponding number, like n in the example at the end of Section 1.1.

Finally, the planning problem from Section 0.3 calls for finding the shortest path from c=4 to c=10. We can describe this problem in the language of CCalc as follows:

:- query
 maxstep :: 0..infinity;
 0: c=4;
 maxstep: c=10.
This query asks for the shortest path satisfying the conditions in the last two lines. By replacing here the interval 0..infinity with 5..10 we would instruct CCalc to limit its search for the shortest solution to paths not shorter than 5 and not longer than 10.

Forward to Section 1.3: Running CCalc
Back to Section 1.1: CCalc Input: Transition Systems
Up to the Table of Contents