The following sequence of steps will instruct CCalc to calculate the answer to Query 1.
1. cd to a directory where you want to keep CCalc input files and the temporary files that CCalc may create when it is run.
(The name of each of these temporary files is ccsat followed by an extension. CCalc may also create an external database of rules, which, if it exists, resides in the subdirectory rule_db.)
2. Copy the coins file into that directory.
3. Start SICStus Prolog or SWI-Prolog.
4. In response to the Prolog prompt (| ?-), load ccalc.pl with the full pathname:
| ?- ['.../ccalc/ccalc.pl'].(Steps 3 and 4 can be combined into one using the Prolog load option:
unix% sicstus -l .../ccalc/ccalc.pl for SICStus Prolog,
unix% pl -f .../ccalc/ccalc.pl      for SWI-Prolog.
This command will start Prolog and then load CCalc. You may find it convenient to introduce an alias for it. For instance, in case of SISCtus Prolog, put the line
alias ccalc 'sicstus -l .../ccalc/ccalc.pl'in file .cshrc under your home directory if you are using C shell (csh), or the line
alias ccalc='sicstus -l .../ccalc/ccalc.pl'in file .kshrc if you are using Korn shell (ksh).)
5. In response to the Prolog prompt, instruct CCalc to load the input file:
| ?- loadf coins.(Generally, the file name after loadf needs to be enclosed in single quotes, but for simple names this is not necessary.)
6. In response to the Prolog prompt, instruct CCalc to answer the query:
| ?- query 1.(The query command without a label tells CCalc that a query will be entered from the terminal. Accordingly, to instruct CCalc to answer the query that is specified in the input file but does not have a label, enter query 0.)
Now you are done. The lines
0: c=5 ACTIONS: a 1: c=6 ACTIONS: a 2: c=7in the output of CCalc describe the path satisfying the given conditions: v0 is labeled c=5, e0 is labeled a=t, and so forth.
To exit Prolog, type ctrl-d.
Exercise 1.1. Perform steps 1-6. Then repeat Step 6 with other labels to get answers to Queries 2 and 3.
Exercise 1.2. Use CCalc to determine whether this transition system has a path from c=4 to c=10 of length exactly 8.
Exercise 1.3. Use CCalc to verify that this transition system has no path of length <15 from c=10 to c=4.
Exercise 1.4. Consider the following alternative interpretation of the intuitive meaning of c and a. There is one coin and 11 people around the table, numbered clockwise 0,...,10. The value of c tells us which person has the coin. To execute action a, that person passes the coin to his neighbor in the clockwise direction. (a) Modify the action description in file coins in accordance with the new interpretation of c and a. (b) Use CCalc to find the shortest path from c=10 to c=4 in the modified transition system.
Forward to Section 1.4: How CCalc Does It Back to Section 1.2: CCalc Input: Queries Up to the Table of Contents