Debian Codegraph @

doc/RefCard/interp-todo.tex

raw
1 % -*- Mode: LaTeX -*-
2 %!TEX TS-program = xelatex
3 %!TEX encoding = UTF-8 Unicode
4 \documentclass[a4paper,oneside,twocolumn]{memoir}
5 \usepackage[hscale=0.8,vscale=0.8]{geometry}
6 \geometry{landscape}
7 \usepackage{multicol}
8
9 % \<...> - surrounds a variable name in a code example
10 \def\<#1>{\textit{#1\/}}
11 % kbd - argument is characters typed literally. Like the Texinfo command.
12 \def\kbd#1{\texttt{#1}\null} %\null so not an abbrev even if period follows
13 \def\cafeobj{{CafeOBJ}\null}
14
15 \begin{document}
16 \midsloppy
17 %%%%%%
18 \mainmatter
19
20 %\title{\centerline{\bcafeobj\ Commands}}
21 %\title{\centerline{Quick Reference}}
22
23 %\centerline{(for interpreter version 1.4.8)}
24
25 \section{Notation}
26
27 Keywords apper in \kbd{type setter face},
28 when presented in the form like `x(yz)' it means the keyword `xyz'
29 can be abbreviated to `x'.
30 `[something]' means `something' is optional.
31 \kbd{|} is used for listing alternatives.
32 Slanted face, e.g., \<variety> is used when it varies (a
33 meta-variable) or is an expression of some language. For example,
34 \<modexp> is for module expressions and \<term> is for terms (you
35 should know what these are); others should easily be understood by
36 their \<name>s and/or from the context.
37 %%%%% starting cafeobj
38 \section{Starting \cafeobj\ interpreter}
39
40 To enter \cafeobj, just type its name: \kbd{cafeobj}
41
42 `\kbd{cafeobj -help}' will show you a summary of command options.
43
44 %%%%% leaving cafeobj
45 \section{Leaving \cafeobj}
46
47 \kbd{q(uit)} exits \cafeobj.
48
49 %%%%% getting little help
50 \section{Getting Little Help}
51
52 Typing \kbd{?} at the top-level prompt will print out a list of whole
53 top-level commands.
54
55 %%%%% escape
56 \section{Escape}
57
58 There would be a situation that you hit \kbd{return} expecting some feedback from the interpreter, but it does not respond.
59 This occurs when the interpreter expects some more inputs from you thinking
60 preceding input is not yet syntactically complete. If you encounter this situation,
61 and you don't know what the interpreter expects,
62 simply type in \kbd{esc}(escape key) and \kbd{return}, then it will
63 immediately be back to you discarding preceding input
64 and makes a fresh start. Alternatively, you can type in several \kbd{return} keys. This acts exactly the same as typing \kbd{esc} and \kbd{return}.
65
66 %%%%% rescue
67 \section{Rescue}
68
69 Occasionally you may meet a strange prompt \kbd{CHAOS>>} after some
70 error messages. This happens when the interpreter caused some internal
71 errors and could not recover from it. Try typing \kbd{:q}, this may
72 resume the session if you are lucky.
73
74 Sending interrupt signal (typing \kbd{C-c} from keyboard, or if you
75 are in Emacs, some key sequence specific to the \<mode> you are in)
76 forces the interpreter to break into underlying Lisp, and you will see
77 the same prompt as the above.
78 This might be useful when you feel the interpreter get confused.
79 \kbd{:q} also works for returning to \cafeobj\ interpreter from Lisp.
80
81 %%%%%% setting switches
82 \section{Setting Switches}
83
84 Switches are for controlling the interpreter's behaviour in several manner.
85 The general form of setting top-level switch is:
86
87 \ \ \kbd{set} {\textit{switch value\/} }
88
89 In the following, the default value of a switch is shown
90 underlined.
91
92 %% \paralign to \hsize{#\tabskip=8pt plus 1 fil&#\tabskip=0pt&#\cr
93 \begin{multicols}{3}
94 \textbf{switch}{\textbf{ value}}{\textbf{ what?}}
95 ***
96 {-- switches for rewriting}
97 \threecol{trace whole}{on|\ul{off}}{trace top-level rewrite step}
98 \threecol{trace}{on|\ul{off}}{trace every rewrite step}
99 \threecol{step}{on|\ul{off}}{stepwise rewriting process}
100 \threecol{memo}{\ul{on}|off}{enable term memoization}
101 \threecol{clean memo}{on|\ul{off}}{clean up term memo table}
102 \threecol{}{}{before normalization}
103 \threecol{stats}{\ul{on}|off}{show statistics data after reduction}
104 \threecol{rwt limit} {{\<number>}}{maximum number of rewriting}
105 \threecol{stop pattern}{[{\<term>}] .}{stop rewriting when meets}
106 \threecol{mel sort}{on|\ul{off}}{compute result sort with}
107 \threecol{}{}{sort membership predicates}
108 \threecol{reduce conditions}{on|\ul{off}}{reduce conditional part in}
109 \threecol{}{}{apply command}
110 \threecol{verbose}{on|\ul{off}}{set verbose mode}
111 \threecol{exec trace}{on|\ul{off}}{trace concurrent execution}
112 \threecol{exec limit}{{\<number>}}{limit maximum number of}
113 \threecol{}{}{concurrent execution}
114 \threecol{exec normalize}{\ul{on}|off}{reduce term before and after}
115 \threecol{}{}{each transition}
116 \threecol{exec all}{\ul{on}|off}{find all solutions of \kbd{=(*)=>}}
117 ***
118 \threecol{}{}{-- switches for system's behaviour}
119 \threecol{include BOOL}{\ul{on}|off}{import BOOL implicitly}
120 \threecol{incude RWL}{\ul{on}|off}{import RWL implicitly}
121 \threecol{include FOPL-CLAUSE}{\ul{on}|off}{import FOPL-CLAUSE
122 implicitly}
123 \threecol{auto context}{on|\ul{off}}{change current context in
124 automatic}
125 \threecol{auto reconstruct}{on|\ul{off}}{perform automatic reconstruction}
126 \threecol{}{}{of modules if it is inconsistent}
127 \threecol{reg signature}{on|\ul{off}}{regularize module signature}
128 \threecol{}{}{in automatic}
129 \threecol{check regularity}{on|\ul{off}}{perform regularity check of}
130 \threecol{}{}{signature in automatic}
131 \threecol{check compatibility}{on|\ul{off}}{perform compatibility check}
132 \threecol{}{}{of TRS in automatic}
133 \threecol{check builtin}{\ul{on}|off}{perform operator overloading}
134 \threecol{}{}{check with built-in sorts}
135 \threecol{select term}{on|\ul{off}}{system selects a term from}
136 \threecol{}{}{ambiguously parsed terms}
137 \threecol{quiet}{on|\ul{off}}{system mostly says nothing}
138 %%
139 \threecol{}{}{-- show/display options}
140 \threecol{all axioms}{on|\ul{off}}{print all axioms in}
141 \threecol{}{}{"\kbd{sh(ow) \<modexp>}" command}
142 \threecol{show mode}{\ul{:cafeobj}}{set syntax of printed
143 modules}
144 \threecol{}{|:chaos}{or views}
145 \threecol{show var sorts}{on|\ul{off}}{print variables with sorts}
146 \threecol{print mode}{\ul{:normal}}{set term priting form}
147 \threecol{}{|:fancy}{}
148 \threecol{}{|:tree} {}
149 \threecol{}{|:s-expr}{}
150 ***
151 \threecol{}{}{-- miscellaneous settings}
152 \threecol{libpath}{\<pathname>}{set file search path}
153 \threecol{print depth}{{\<number>}}{maximum depth of terms}
154 \threecol{}{}{ to be printed}
155 \threecol{accept \kbd{=*=} proof}{on|\ul{off}}{accept system's automatic}
156 \threecol{}{}{ proof of congruency of \kbd{=*=}}
157 %%%%%
158 }
159
160 The default value of \<pathname> of \kbd{set libpath} command is
161 `\$cafeobjhome/lib, \$cafeobjhome/exs',
162 where `\$cafeobjhome' varies depending on the installation options
163 of your interpreter. Normally, it is \kbd{/usr/local/lib/cafeobj1.4}.
164
165 The default value of \<number> in `set rwt limit' command is 0 meaning
166 no limit counter of rewriting is specified.
167
168 Omitting \<term> in \kbd{set stop pattern} sets the stop pattern to
169 empty, i.e., no term will match to the pattern.
170
171 %%%% getting values of switches
172 \section{Examining Values of Switches}
173
174 %% \paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr
175 \twocol{show switch}{{\rm print list of available switches}}
176 \twocol{}{{\rm with their values}}
177 \twocol{show switch \textit{switch}}{{\rm print out the value of the}}
178 \twocol{}{{\rm specified} \textit{switch}}
179 }
180 %%% setting context
181 \section{Setting Context}
182
183 \kbd{select} {\<modexp>}
184
185 This sets the context of the interpreter (\textbf{ current module})
186 to the module specified by \<modexp>.
187 It must be written in single line.
188 When you type in \<modexp>, the `\kbd{;}$<$newline$>$' treated as a
189 line continuation (that is, it is effectively ignored), so that you
190 can type in multiple lines for long module expressions. Note that one
191 or more blank characters are required before \kbd{;}.
192
193 %%%% inspecting modules
194 \section{Inspecting Module}
195
196 \kbd{sh(ow)} and \kbd{desc(ribe)} commands print information on a module.
197 In the sequel, we use a meta-variable \<show> which stands for
198 either \kbd{sh(ow)} or \kbd{desc(ribe)}. Most of the cases,
199 giving \kbd{desc(ribe)} for \<show> gives you more detailed
200 information.
201
202 %% \paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr
203 \twocol{\<show> \<modexp>}{prints a module \<modexp>. giving `\kbd{.}''}
204 \twocol{}{as \<modexp> shows the current module}
205 \twocol{\<show> sorts [\<modexp>]}{prints sorts of \<modexp>}
206 \twocol{\<show> ops [\<modexp>]}{prints operators of \<modexp>}
207 \twocol{\<show> vars [\<modexp>]}{prints variables of \<modexp>}
208 \twocol{\<show> params [\<modexp>]}{prints parameters of \<modexp>}
209 \twocol{\<show> subs [\<modexp>]}{prints direct submodules of \<modexp>}
210 \twocol{\<show> sign [\<modexp>]}{prints \kbd{sorts} and \kbd{ops} combined}
211 }
212
213 \<modexp> must be given in an one line.
214 The same convention for long module expressions is used as that of
215 \kbd{select} command (see \textbf{ Setting Context} above.)
216 If the optional [\<modexp>] is omitted, it defaults to the current
217 module.
218 Optionally supplying \kbd{all} before \kbd{sorts}, \kbd{ops},
219 \kbd{axioms}, and \kbd{sign}, i.e., \kbd{desc all ops} for an instance)
220 makes printed out information also include imported sorts, operators, etc.
221 otherwise it only prints own constructs of the \<modexp>.
222
223 The following \<show> commands assume the current
224 module is set to some module.
225 %%% \paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr
226 \twocol{\<show> sort \<sort>}{prints information on sort \<sort>}
227 \twocol{\<show> op \<operator>}{prints information on operator
228 \<operaotr>}
229 }
230
231 For inspecting submodules or parameters, the following \<show>
232 commands are useful:
233 %%% \paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr
234 \twocol{\<show> param \<argname>}{prints information on the parameter}
235 \twocol{\<show> sub \<n>}{prints information on the \<n>th direct}
236 \twocol{}{submodule}
237 }
238 \<argname> can be given by position, not by name.
239
240 You can see the hierarchy of a module or a sort by the follwing
241 \kbd{sh(ow)} commands:
242 %%% \paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr
243 \twocol{sh(ow) module tree \<modexp>}{prints pictorial hierarchy of
244 module.}
245 \twocol{}{specifying \kbd{.} as \<modexp> shows the}
246 \twocol{}{hierarcy of the current module}
247 \twocol{sh(ow) sort tree \<sort>}{prints hierarchy of sort pictorially}
248 }
249
250 %%% Evaluating terms
251 \section{Evaluating Terms}
252
253 \kbd{red(uce)} [\kbd{in} \<modexp> \kbd{:}] \<term> \kbd{.}
254
255 \kbd{exec(ute)} [\kbd{in} \<modexp> \kbd{:}] \<term> \kbd{.}
256
257 \kbd{reduce} reduces a given term \<term> in the term rewriting system
258 derived from \<modexp>.
259 \kbd{execute} is similar to \kbd{reduce}, but it also considers axioms
260 given by \textbf{ transition} declarations.
261 In both cases, omitted `\kbd{in} \<modexp> \kbd{:}' defaults to the current module.
262
263 The result term of \kbd{reduce} and \kbd{execute} is bould to
264 special variables \kbd{\$\$term} and \kbd{\$\$subterm} (see the next
265 section).
266
267 %%% Let variables and special variables
268 \section{Let Variables and Special Variables}
269
270 \kbd{let} \<let-variable> \kbd{=} \<term> \kbd{.}
271
272 \<let-variable> is an indentifier. Assuming the current module is set,
273 \kbd{let} binds \<let-variable> to the given term \<term>.
274 Once set, \<let-variable> can be used wherever \<term> can apper.
275
276 You can see the list of let bidings by:
277
278 \kbd{sh(ow) let}
279
280 There are two built-in special variables in the system:
281 %%% \paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr
282 \twocol{\$\$term}{bound to the result term of \kbd{reduce}, \kbd{execute},}
283 \twocol{}{\kbd{parse}, or \kbd{start} commands.}
284 \twocol{\$\$subterm}{bound to the result of \kbd{choose} command}
285 }
286
287 Let variales and special variables belongs to a context, i.e., each
288 context has its own let variables and special variables.
289
290 %%%% \newcolumn
291 %%%% Inspecting terms
292 \section{Inspecting Terms}
293 \kbd{parse} [\kbd{in} \<modexp> \kbd{:}] \<term> \kbd{.}
294
295 \kbd{parse} parses given term \<term> in the module \<modexp> (if
296 omitted, parses in the current module) and prints the result.
297 The result is bound to special variables \kbd{\$\$term} and
298 \kbd{\$\$subterm}.
299
300 The following \kbd{sh(ow)} command assumes the current module, and
301 prints the term.
302
303 \kbd{sh(ow) term} [\<let-variable>] [\kbd{tree}]
304
305 \<let-variable> can be a name of \<let-variable>, \kbd{\$\$term} or
306 \kbd{\$\$subterm}, if omitted the term bound to \kbd{\$\$term} is
307 printed. If optional \kbd{tree} is supplied, it prints the term tree
308 structure.
309
310 %%% open/closing module
311 \section{Opening/Closing Module}
312
313 %%% \paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr
314 \twocol{open \<modexp>}{opens module \<modexp>}
315 \twocol{close}{close the currently opening module}
316 }
317 Opening module can be modified, i.e., you can declare new sorts,
318 operators, axioms. You can open only one module at a time.
319
320 %%%% applying rewrite rules
321 \section{Applying Rewrite Rules}
322
323 \paragraph{Start}
324 The initial target (entire term) is set by \kbd{start} command.
325
326 \kbd{start} \<term> .
327
328 This binds two special variables \kbd{\$\$term} and
329 \kbd{\$\$subterm} to \<term>.
330
331 \paragraph{Apply}
332 \kbd{apply} command applies actions to (subterm of) \kbd{\$\$term}.
333
334 \kbd{apply} \<action> \<range> \<selection>
335
336 You specify an action by \<action>, and it will be applied to the
337 target (sub)term specified by \<selection>.
338
339 \<range> is either \kbd{within} or \kbd{at}: \kbd{within} means at or
340 inside the (sub)term specified by the \<selection>, and \kbd{at}
341 means exactly at the \<selection>.
342
343 \paragraph{Action}
344 \<action> can be the followings:
345 %%% \paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr
346 \twocol{red(uction)}{reduce the selected term}
347 \twocol{exec}{execute the selected term}
348 \twocol{print}{print the selected term}
349 \twocol{\<rule-spec>}{apply specified rule to the selected term}
350 }
351
352 \paragraph{Rule-Spec}
353 \<rule-spec> specifies the rule with possibly substitutions being
354 applied, and given by
355
356 [\kbd{+ | -}][\<modexp>].\<rule-name> [\<substitutions>]
357
358 The first optional `\kbd{+ | -}' specifies the direction of the rule;
359 left to right(if \kbd{+} or omitted) or right to left (if \kbd{-}).
360
361 A rule itself is specified by `[\<modexp>].\<rule-name>]'. This means
362 the rule with name \<rule-name> of the module \<modexp> (if omitted, the
363 current module). \<rule-name> is either a label of a rule or a number
364 which shown by \kbd{sh(ow) rules} command (see \textbf{ Showing Available
365 Rules below}.)
366
367 \<substitution> binds variables that apper in the selected rule before
368 applying it. This has the form
369
370 \kbd{with} \<variable> \kbd{=} \<term> \kbd{,} ...
371
372 \paragraph{Showing Available Rules}
373 To see the list of the rewrite rules, use
374
375 \kbd{sh(ow)} [\kbd{all}] \kbd{rules}
376
377 The list of the (all, i.e., includes imported rules if the optional
378 \kbd{all} is supplied) available rules are printed with each of which
379 being numbered. The number can be used for \<rule-name> (see above).
380
381 \paragraph{Selection}
382 \<selection> is a sequence of \<selector> separated by keyword
383 \kbd{of} specifying (sub)term of \kbd{\$\$term}:
384
385 \<selector> $\{$ \kbd{of} \<selector> $\}$ $\cdots$
386 %%% \paralign to \hsize{#\tabskip=4pt plus 1 fil&#\cr
387 \twocol{\textbf{ selector}}{\textbf{ description}}
388 \twocol{term}{the entire term (\kbd{\$\$term})}
389 \twocol{top}{ditto}
390 \twocol{subterm}{selects \kbd{\$\$subterm}}
391 \twocol{(\<number> $\cdots$ )}{selects by position}
392 \twocol{\kbd{[} \<number> \kbd{..} \<number> \kbd{]}}{by range
393 in flattened term structure}
394 \twocol{\kbd{\{} \<number> \kbd{,} $\cdots$ \kbd{\}}}{subset
395 in flattened term structure}
396 }
397
398 \paragraph{Step by Step Subterm Selection}
399 \kbd{choose} command selects a subterm of \kbd{\$\$subterm} and reset
400 the \kbd{\$\$subterm} to the selected one.
401
402 \kbd{choose} \<selector>
403
404 \paragraph{Matching Terms}
405
406 \kbd{match} \<term\_spec> \kbd{to} \<pattern>
407
408 \<term\_spec> specifies the term to be matched with \<pattern>:
409 %%% \paralign to \hsize{#\tabskip=4pt plus 1 fil&#\cr
410 \twocol{\textbf{ term\_spec}}{\textbf{ description}}
411 \twocol{\kbd{term}}{\kbd{\$\$term}}
412 \twocol{\kbd{top}}{ditto}
413 \twocol{\kbd{subterm}}{\kbd{\$\$term}}
414 \twocol{\kbd{it}}{ditto}
415 \twocol{\<term>}{ordinal term}
416 }
417
418 %%% \paralign to \hsize{#\tabskip=4pt plus 1 fil&#\cr
419 \twocol{\textbf{ pattern}}{\textbf{ description}}
420 \twocol{\kbd{[ all ][+ | -] rules}}{match with available rewrite
421 rules}
422 \twocol{\<term>}{match with specified term}
423 }
424 %%% stepper
425 \section{Stepper}
426 If the switch \kbd{step} is set to \kbd{on}, invoking \kbd{reduce} or
427 \kbd{execute} command runs into the term rewriting stepper.
428 The stepper has its own command interpreter loop, where the following
429 stepper commands are avilable:
430
431 %%% \paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr
432 \twocol{?}{print out available commands.}
433 \twocol{n(ext)}{go one step}
434 \twocol{g(o) \<number>}{go \<number> step}
435 \twocol{c(ontinue)}{continue rewriting without stepping}
436 \twocol{q(uit)}{leave stepper continuing rewrite}
437 \twocol{a(bort)}{abort rewriting}
438 \twocol{r(rule)}{prints current rewrite rule}
439 \twocol{s(ubst)}{prints substitution}
440 \twocol{l(imit)}{prints rewrite limit counter}
441 \twocol{p(attern)}{prints stop pattern}
442 \twocol{stop [\<term>]}{set (unset) stop pattern}
443 \twocol{rwt [\<number>]}{set (unset) rwrite limit counter}
444 }
445 You can also use families of \kbd{sh(ow)}(\kbd{desc(ribe)})
446 and \kbd{set} commands in stepper.
447
448 \section{Reading In Files}
449
450 %%% \paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr
451 \twocol{input \<file>}{read in \cafeobj\ program from \<file>}
452 \twocol{provide \<feature>}{provide the \<feature>}
453 \twocol{require \<feature> [\<file>]}{require \<feature>}
454 }
455 %%% save and restore
456 \section{Save and Restore}
457
458 %%% \paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr
459 \twocol{save \<file>}{save definitions of modules and views to \<file>}
460 \twocol{restore \<file>}{restore definitions of modules and views}
461 \twocol{reset}{recover definitions of built-in modules}
462 \twocol{full-reset}{reset system to initial status}
463 \twocol{save-system \<file>}{save image of the interpreter to \<file>}
464 }
465
466 %%% protecting your modules
467 \section{Protecting Your Modules}
468 %%% \paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr
469 \twocol{protect \<modexp>}{prevent the module from redefinition}
470 \twocol{unprotect \<modexp>}{allow moudle to be redefined}
471 }
472
473 %%% little semantic tools
474 \newcolumn
475 \section{Little Semantic Tools}
476 %%% \paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr
477 \twocol{check reg(ularity) [\<modexp>]}{reports the result of
478 regularity}
479 \twocol{}{check of module}
480 \twocol{check comat(ibility) [\<modexp>}{reports the result of
481 compatibility}
482 \twocol{}{check of the module}
483 }
484 For both commands, omitted \<modexp> will perform the
485 check in the current module.
486
487 The following \kbd{check} command assumes the current module:
488
489 \kbd{check laziness} [\<operator>]
490
491 This checks strictness of \<operator>. If \<operator> is omitted
492 all of the operators declared in the current modules are checked.
493
494 \section{TRAM Compiler Interface}
495 \kbd{tram compile} [\<modexp>]
496
497 This compiles module \<modexp> to Term Rewriting Abstract Machine.
498 If \<modexp> is omitted, it defaults to the current module.
499 \<modexp> must be given in an line. You can supply multiple lines
500 by using `\kbd{;}$<$new-line$>$'.
501
502 To evaluate term in compiled module, use the following:
503
504 \kbd{tram exec} [\kbd{in} \<modexp> :] \<term>
505
506 Omitting `\kbd{in} \<modexp> :' means the evaluation is performed in
507 the current module. If the module \<modexp> is not yet compiled,
508 this compiles it implicitly, then perform the evaluation.
509
510
511 \section{Miscellany}
512 %%% \paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr
513 \twocol{ls \<pathname>}{list contents of directories}
514 \twocol{cd \<pathname>}{change working directory of the interpreter}
515 \twocol{pwd}{prints working directory}
516 \twocol{! \<command>}{fork shell \<command>}
517 \twocol{ev \<lisp>}{evaluate lisp expression \<lisp> printing the
518 result}
519 \twocol{evq \<lisp>}{evaluate lisp expression \<lisp>}
520 }
521 \newcolumn
522
523 \end{document}
524
525 % Local variables:
526 % compile-command: "xetex interp"
527 % TeX-master: t
528 % End: