| 1 |
% !TEX TS-program = pdftex |
| 2 |
% -*- Mode: TeX -*- |
| 3 |
% Quick Reference of CafeOBJ 1.5.6 Interpreter Commands |
| 4 |
% ----------- **start of header |
| 5 |
\newcount\columnsperpage |
| 6 |
\columnsperpage=2 |
| 7 |
|
| 8 |
\def\versionnumber{1.5.6} |
| 9 |
\def\year{2016} |
| 10 |
\def\version{February \year\ v\versionnumber} |
| 11 |
|
| 12 |
% make \bye not \outer so that the \def\bye in the \else clause below |
| 13 |
% can be scanned without complaint. |
| 14 |
\def\bye{\par\vfill\supereject\end} |
| 15 |
|
| 16 |
\newdimen\intercolumnskip %horizontal space between columns |
| 17 |
\newbox\columna %boxes to hold columns already built |
| 18 |
\newbox\columnb |
| 19 |
|
| 20 |
\def\ncolumns{\the\columnsperpage} |
| 21 |
|
| 22 |
\def\scaledmag#1{ scaled \magstep #1} |
| 23 |
\hsize 3.5in |
| 24 |
\vsize 7.95in |
| 25 |
\hoffset -.6in |
| 26 |
%\voffset -.745in |
| 27 |
%\voffset -.74in |
| 28 |
\font\titlefont=cmbx10 \scaledmag2 |
| 29 |
\font\headingfont=cmbx10 \scaledmag1 |
| 30 |
\font\smallfont=cmr6 |
| 31 |
\font\smallsy=cmsy6 |
| 32 |
\font\eightrm=cmr8 |
| 33 |
\font\eightbf=cmbx8 |
| 34 |
\font\eightit=cmti8 |
| 35 |
\font\eighttt=cmtt8 |
| 36 |
\font\eightmi=cmmi8 |
| 37 |
\font\eightsy=cmsy8 |
| 38 |
\font\eightsf=cmss8 |
| 39 |
\font\bigsf=cmss10 \scaledmag2 |
| 40 |
\font\tensf=cmss10 \scaledmag1 |
| 41 |
\textfont0=\eightrm |
| 42 |
\textfont1=\eightmi |
| 43 |
\textfont2=\eightsy |
| 44 |
\def\rm{\eightrm} |
| 45 |
\def\bf{\eightbf} |
| 46 |
\def\it{\eightit} |
| 47 |
\def\tt{\eighttt} |
| 48 |
\def\sf{\eightsf} |
| 49 |
\normalbaselineskip=.8\normalbaselineskip |
| 50 |
\normallineskip=.8\normallineskip |
| 51 |
\normallineskiplimit=.8\normallineskiplimit |
| 52 |
\normalbaselines\rm %make definitions take effect |
| 53 |
|
| 54 |
\let\maxcolumn=b |
| 55 |
\footline{\hss\rm\folio\hss} |
| 56 |
\def\makefootline{\vskip 2in \hsize=6.86in\line{\the\footline}} |
| 57 |
\intercolumnskip=.46in |
| 58 |
\def\abc{a} |
| 59 |
\output={% %see The TeXbook page 257 |
| 60 |
% This next line is useful when designing the layout. |
| 61 |
%\immediate\write16{Column \folio\abc\space starts with \firstmark} |
| 62 |
\if \maxcolumn\abc \multicolumnformat \global\def\abc{a} |
| 63 |
\else\if a\abc |
| 64 |
\global\setbox\columna\columnbox \global\def\abc{b} |
| 65 |
%% in case we never use \columnb (two-column mode) |
| 66 |
\global\setbox\columnb\hbox to -\intercolumnskip{} |
| 67 |
\else |
| 68 |
\global\setbox\columnb\columnbox \global\def\abc{c}\fi\fi} |
| 69 |
\def\multicolumnformat{\shipout\vbox{\makeheadline |
| 70 |
\hbox{\box\columna\hskip\intercolumnskip |
| 71 |
\box\columnb\hskip\intercolumnskip\columnbox} |
| 72 |
\makefootline}\advancepageno} |
| 73 |
\def\columnbox{\leftline{\pagebody}} |
| 74 |
|
| 75 |
\def\bye{\par\vfill\supereject |
| 76 |
\if a\abc \else\null\vfill\eject\fi |
| 77 |
\if a\abc \else\null\vfill\eject\fi |
| 78 |
\end} |
| 79 |
% we won't be using math mode much, so redefine some of the characters |
| 80 |
% we might want to talk about |
| 81 |
\catcode`\^=12 |
| 82 |
\catcode`\_=12 |
| 83 |
|
| 84 |
\chardef\\=`\\ |
| 85 |
\chardef\{=`\{ |
| 86 |
\chardef\}=`\} |
| 87 |
%\newdimen\z@ \z@=0pt |
| 88 |
\def\m@th{\mathsurround0pt} |
| 89 |
\def\ul#1{% |
| 90 |
\relax |
| 91 |
\ifmmode\underline{#1}% |
| 92 |
\else $\underline{\hbox{#1}}\m@th$\relax\fi} |
| 93 |
\parindent 0pt |
| 94 |
\parskip 1ex plus .5ex minus .5ex |
| 95 |
|
| 96 |
\def\small{\smallfont\textfont2=\smallsy\baselineskip=.8\baselineskip} |
| 97 |
|
| 98 |
% newcolumn - force a new column. Use sparingly, probably only for |
| 99 |
% the first column of a page, which should have a title anyway. |
| 100 |
\outer\def\newcolumn{\vfill\eject} |
| 101 |
|
| 102 |
% title - page title. Argument is title text. |
| 103 |
\outer\def\title#1{{\titlefont\centerline{#1}}\vskip 1ex plus .5ex} |
| 104 |
|
| 105 |
% section - new major section. Argument is section name. |
| 106 |
\outer\def\section#1{\par%\filbreak |
| 107 |
\vskip 3ex plus 2ex minus 2ex {\headingfont #1}{\mark{#1}}% |
| 108 |
\vskip 0.8ex\hrule \vskip 1.0ex} |
| 109 |
|
| 110 |
% paragraph |
| 111 |
\outer\def\paragraph#1{\par%\filbreak |
| 112 |
\vskip 3ex plus 2ex minus 2ex {\bf #1}{\mark{#1}}% |
| 113 |
} |
| 114 |
|
| 115 |
\newdimen\keyindent |
| 116 |
|
| 117 |
% beginindentedkeys...endindentedkeys - key definitions will be |
| 118 |
% indented, but running text, typically used as headings to group |
| 119 |
% definitions, will not. |
| 120 |
\def\beginindentedkeys{\keyindent=1em} |
| 121 |
\def\endindentedkeys{\keyindent=0em} |
| 122 |
\endindentedkeys |
| 123 |
|
| 124 |
% paralign - begin paragraph containing an alignment. |
| 125 |
% If an \halign is entered while in vertical mode, a parskip is never |
| 126 |
% inserted. Using \paralign instead of \halign solves this problem. |
| 127 |
\def\paralign{\vskip\parskip\halign} |
| 128 |
|
| 129 |
% \<...> - surrounds a variable name in a code example |
| 130 |
\def\<#1>{{\it #1\/}} |
| 131 |
|
| 132 |
% kbd - argument is characters typed literally. Like the Texinfo command. |
| 133 |
\def\kbd#1{{\tt#1}\null} %\null so not an abbrev even if period follows |
| 134 |
|
| 135 |
% beginexample...endexample - surrounds literal text, such a code example. |
| 136 |
% typeset in a typewriter font with line breaks preserved |
| 137 |
\def\beginexample{\par\leavevmode\begingroup |
| 138 |
\obeylines\obeyspaces\parskip0pt\tt} |
| 139 |
{\obeyspaces\global\let =\ } |
| 140 |
\def\endexample{\endgroup} |
| 141 |
|
| 142 |
% key - definition of a key. |
| 143 |
% \key{description of key}{key-name} |
| 144 |
% prints the description left-justified, and the key-name in a \kbd |
| 145 |
% form near the right margin. |
| 146 |
\def\key#1#2{\leavevmode\hbox to \hsize{\vtop |
| 147 |
{\hsize=.75\hsize\rightskip=1em |
| 148 |
\hskip\keyindent\relax#1}\kbd{#2}\hfil}} |
| 149 |
|
| 150 |
% twocol |
| 151 |
\def\twocol#1#2{\hskip\keyindent\relax\kbd{#1}\hfil&{#2}\hfil\quad\cr} |
| 152 |
|
| 153 |
% threecol |
| 154 |
\def\threecol#1#2#3{\hskip\keyindent\relax\kbd{#1}\hfil&\kbd{#2}\hfil\quad |
| 155 |
&{#3}\hfil\quad\cr} |
| 156 |
|
| 157 |
\def\cafeobj{{\sf CafeOBJ}\null} |
| 158 |
\def\bcafeobj{{\bigsf CafeOBJ}\null} |
| 159 |
\def\hcafeobj{{\tensf CafeOBJ}\null} |
| 160 |
|
| 161 |
% -------------------- end of header |
| 162 |
|
| 163 |
|
| 164 |
\title{\centerline{\bcafeobj\ Commands}} |
| 165 |
\title{\centerline{Quick Reference}} |
| 166 |
|
| 167 |
\centerline{(for interpreter version \version)} |
| 168 |
|
| 169 |
\section{Notation} |
| 170 |
|
| 171 |
Keywords apper in \kbd{type setter face}, |
| 172 |
when presented in the form like `x(yz)' it means the keyword `xyz' |
| 173 |
can be abbreviated to `x'. |
| 174 |
`[something]' means `something' is optional. |
| 175 |
\kbd{|} is used for listing alternatives. |
| 176 |
Slanted face, e.g., \<variety> is used when it varies (a |
| 177 |
meta-variable) or is an expression of some language. For example, |
| 178 |
\<modexp> is for module expressions and \<term> is for terms (you |
| 179 |
should know what these are); others should easily be understood by |
| 180 |
their \<name>s and/or from the context. |
| 181 |
%%%%% starting cafeobj |
| 182 |
\section{Starting \hcafeobj\ interpreter} |
| 183 |
|
| 184 |
To enter \cafeobj, just type its name: \kbd{cafeobj} |
| 185 |
|
| 186 |
`\kbd{cafeobj -help}' will show you a summary of command options. |
| 187 |
|
| 188 |
%%%%% leaving cafeobj |
| 189 |
\section{Leaving \hcafeobj} |
| 190 |
|
| 191 |
\kbd{q(uit)} exits \cafeobj. |
| 192 |
|
| 193 |
%%%%% getting little help |
| 194 |
\section{Getting Help} |
| 195 |
|
| 196 |
Typing \kbd{?} at the top-level prompt will print out a online help |
| 197 |
guidance. This is a good startng point for navigating the system. |
| 198 |
Also try typing \kbd{com}, this shows the list of major toplevel commands. |
| 199 |
|
| 200 |
%%%%% escape |
| 201 |
\section{Escape} |
| 202 |
|
| 203 |
There would be a situation that you hit \kbd{return} expecting some feedback from the interpreter, |
| 204 |
but it does not respond. |
| 205 |
This occurs when the interpreter expects some more inputs from you thinking |
| 206 |
preceding input is not yet syntactically complete. |
| 207 |
If you encounter this situation, |
| 208 |
first, try type in '\kbd{.}' and \kbd{return}. |
| 209 |
When this does not help, |
| 210 |
then type in \kbd{esc}(escape key) and \kbd{return}, |
| 211 |
it will immediately be back to you discarding preceding input |
| 212 |
and makes a fresh start. |
| 213 |
|
| 214 |
%%%%% rescue |
| 215 |
\section{Rescue} |
| 216 |
|
| 217 |
Occasionally you may meet a strange prompt \kbd{CHAOS>>} |
| 218 |
(on platform Allegro CommonLisp) or \kbd{0]} (on platform |
| 219 |
SteelBank Common Lisp) after someerror messages. |
| 220 |
This happens when the interpreter caused some internal |
| 221 |
errors and could not recover from it. |
| 222 |
There should be some guides printed describing how you can recover |
| 223 |
from it, please follow them. |
| 224 |
|
| 225 |
Sending interrupt signal (typing \kbd{C-c} from keyboard, or if you |
| 226 |
are in Emacs, some key sequence specific to the \<mode> you are in) |
| 227 |
forces the interpreter to break into underlying Lisp, and you will see |
| 228 |
the same prompt as the above. |
| 229 |
This might be useful when you feel the interpreter get confused. |
| 230 |
\kbd{:q} also works for returning to \cafeobj\ interpreter from Lisp. |
| 231 |
|
| 232 |
%%%%%% setting switches |
| 233 |
\section{Setting Switches} |
| 234 |
|
| 235 |
Switches are for controlling the interpreter's behaviour in several manner. |
| 236 |
The general form of setting top-level switch is: |
| 237 |
|
| 238 |
\ \ \kbd{set} {\it switch value\/} |
| 239 |
|
| 240 |
In the following, the default value of a switch is shown |
| 241 |
underlined. |
| 242 |
|
| 243 |
\paralign to \hsize{#\tabskip=8pt plus 1 fil&#\tabskip=0pt&#\cr |
| 244 |
\threecol{{\bf switch}}{{\bf value}}{{\bf what?}} |
| 245 |
*** |
| 246 |
\threecol{}{}{-- switches for rewriting} |
| 247 |
\threecol{trace whole}{on|\ul{off}}{trace top-level rewrite step} |
| 248 |
\threecol{trace}{on|\ul{off}}{trace every rewrite step} |
| 249 |
\threecol{step}{on|\ul{off}}{stepwise rewriting process} |
| 250 |
\threecol{memo}{\ul{on}|off}{enable term memoization} |
| 251 |
\threecol{always memo}{on|\ul{off}}{implicitly set 'memo' attributes} |
| 252 |
\threecol{}{}{to all user defined operators} |
| 253 |
\threecol{clean memo}{on|\ul{off}}{clean up term memo table} |
| 254 |
\threecol{}{}{before normalization} |
| 255 |
\threecol{stats}{\ul{on}|off}{show statistics data after reduction} |
| 256 |
\threecol{rwt limit} {{\<number>}}{maximum number of rewriting} |
| 257 |
\threecol{stop pattern}{[{\<term>}] .}{stop rewriting when meets} |
| 258 |
\threecol{reduce conditions}{on|\ul{off}}{reduce conditional part in} |
| 259 |
\threecol{}{}{apply command} |
| 260 |
\threecol{verbose}{on|\ul{off}}{set verbose mode} |
| 261 |
\threecol{exec trace}{on|\ul{off}}{trace concurrent execution} |
| 262 |
\threecol{exec limit}{{\<number>}}{limit maximum number of} |
| 263 |
\threecol{}{}{concurrent execution} |
| 264 |
*** |
| 265 |
\threecol{}{}{-- switches for system's behaviour} |
| 266 |
\threecol{include BOOL}{\ul{on}|off}{import BOOL implicitly} |
| 267 |
\threecol{incude RWL}{\ul{on}|off}{import RWL implicitly} |
| 268 |
\threecol{include FOPL-CLAUSE}{\ul{on}|off}{import FOPL-CLAUSE |
| 269 |
implicitly} |
| 270 |
\threecol{auto context}{on|\ul{off}}{change current context in |
| 271 |
automatic} |
| 272 |
\threecol{reg signature}{on|\ul{off}}{regularize module signature} |
| 273 |
\threecol{}{}{in automatic} |
| 274 |
\threecol{check regularity}{on|\ul{off}}{perform regularity check of} |
| 275 |
\threecol{}{}{signature in automatic} |
| 276 |
\threecol{check compatibility}{on|\ul{off}}{perform compatibility check} |
| 277 |
\threecol{}{}{of TRS in automatic} |
| 278 |
\threecol{quiet}{on|\ul{off}}{system mostly says nothing} |
| 279 |
%% |
| 280 |
\threecol{}{}{-- show/display options} |
| 281 |
\threecol{all axioms}{on|\ul{off}}{print all axioms in} |
| 282 |
\threecol{}{}{"\kbd{sh(ow) \<modexp>}" command} |
| 283 |
\threecol{show mode}{\ul{:cafeobj}}{set syntax of printed |
| 284 |
modules} |
| 285 |
\threecol{}{|:chaos}{or views} |
| 286 |
\threecol{show var sorts}{on|\ul{off}}{print variables with sorts} |
| 287 |
\threecol{print mode}{\ul{:normal}}{set term priting form} |
| 288 |
\threecol{}{|:fancy}{} |
| 289 |
\threecol{}{|:tree} {} |
| 290 |
\threecol{}{|:s-expr}{} |
| 291 |
*** |
| 292 |
\threecol{}{}{-- miscellaneous settings} |
| 293 |
\threecol{libpath}{\<pathname>}{set file search path} |
| 294 |
\threecol{print depth}{{\<number>}}{maximum depth of terms} |
| 295 |
\threecol{}{}{ to be printed} |
| 296 |
%% \threecol{accept \kbd{=*=} proof}{on|\ul{off}}{accept system's automatic} |
| 297 |
%% \threecol{}{}{ proof of congruency of \kbd{=*=}} |
| 298 |
%%%%% |
| 299 |
} |
| 300 |
|
| 301 |
The default value of \<pathname> of \kbd{set libpath} command is |
| 302 |
`\$cafeobjhome/share/cafeobj\<version>/lib/', |
| 303 |
where \kbd{\<version>} is a version number of the release, |
| 304 |
as of this writing, it is \kbd{1.5.5}, |
| 305 |
and `\$cafeobjhome' varies depending on the installation options |
| 306 |
of your interpreter. |
| 307 |
By default it is \kbd{/usr/local/}, so |
| 308 |
it will be \kbd{/usr/local/share/cafeobj1.5/lib/}. |
| 309 |
|
| 310 |
The default value of \<number> in `set rwt limit' command is 0 meaning |
| 311 |
no limit counter of rewriting is specified. |
| 312 |
|
| 313 |
Omitting \<term> in \kbd{set stop pattern} sets the stop pattern to |
| 314 |
empty, i.e., no term will match to the pattern. |
| 315 |
|
| 316 |
%%%% getting values of switches |
| 317 |
\section{Examining Values of Switches} |
| 318 |
|
| 319 |
\paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr |
| 320 |
\twocol{show switch}{{\rm print list of available switches}} |
| 321 |
\twocol{}{{\rm with their values}} |
| 322 |
\twocol{show switch {\it switch}}{{\rm print out the value of the}} |
| 323 |
\twocol{}{{\rm specified} {\it switch}} |
| 324 |
} |
| 325 |
%%% setting context |
| 326 |
\section{Setting Context} |
| 327 |
|
| 328 |
\kbd{select} {\<modexp>} |
| 329 |
|
| 330 |
This sets the context of the interpreter ({\bf current module}) |
| 331 |
to the module specified by \<modexp>. |
| 332 |
It must be written in single line. |
| 333 |
When you type in \<modexp>, the `\kbd{;}$<$newline$>$' treated as a |
| 334 |
line continuation (that is, it is effectively ignored), so that you |
| 335 |
can type in multiple lines for long module expressions. Note that one |
| 336 |
or more blank characters are required before \kbd{;}. |
| 337 |
|
| 338 |
%%%% inspecting modules |
| 339 |
\section{Inspecting Module} |
| 340 |
|
| 341 |
\kbd{sh(ow)} and \kbd{desc(ribe)} commands print information on a module. |
| 342 |
In the sequel, we use a meta-variable \<show> which stands for |
| 343 |
either \kbd{sh(ow)} or \kbd{desc(ribe)}. Most of the cases, |
| 344 |
giving \kbd{desc(ribe)} for \<show> gives you more detailed |
| 345 |
information. |
| 346 |
|
| 347 |
\paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr |
| 348 |
\twocol{\<show> \<modexp>}{prints a module \<modexp>. giving `\kbd{.}''} |
| 349 |
\twocol{}{as \<modexp> shows the current module} |
| 350 |
\twocol{\<show> sorts [\<modexp>]}{prints sorts of \<modexp>} |
| 351 |
\twocol{\<show> ops [\<modexp>]}{prints operators of \<modexp>} |
| 352 |
\twocol{\<show> vars [\<modexp>]}{prints variables of \<modexp>} |
| 353 |
\twocol{\<show> params [\<modexp>]}{prints parameters of \<modexp>} |
| 354 |
\twocol{\<show> subs [\<modexp>]}{prints direct submodules of \<modexp>} |
| 355 |
\twocol{\<show> sign [\<modexp>]}{prints \kbd{sorts} and \kbd{ops} combined} |
| 356 |
} |
| 357 |
|
| 358 |
\<modexp> must be given in an one line. |
| 359 |
The same convention for long module expressions is used as that of |
| 360 |
\kbd{select} command (see {\bf Setting Context} above.) |
| 361 |
If the optional [\<modexp>] is omitted, it defaults to the current |
| 362 |
module. |
| 363 |
Optionally supplying \kbd{all} before \kbd{sorts}, \kbd{ops}, |
| 364 |
\kbd{axioms}, and \kbd{sign}, i.e., \kbd{desc all ops} for an instance) |
| 365 |
makes printed out information also include imported sorts, operators, etc. |
| 366 |
otherwise it only prints own constructs of the \<modexp>. |
| 367 |
|
| 368 |
The following \<show> commands assume the current |
| 369 |
module is set to some module. |
| 370 |
\paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr |
| 371 |
\twocol{\<show> sort \<sort>}{prints information on sort \<sort>} |
| 372 |
\twocol{\<show> op \<operator>}{prints information on operator |
| 373 |
\<operaotr>} |
| 374 |
\twocol{\<show> [all] axioms}{prints (all) axioms in the current module} |
| 375 |
\twocol{\<show> [all] rules}{prints (all) rewrite rules in the current module} |
| 376 |
} |
| 377 |
|
| 378 |
For inspecting submodules or parameters, the following \<show> |
| 379 |
commands are useful: |
| 380 |
\paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr |
| 381 |
\twocol{\<show> param \<argname>}{prints information on the parameter} |
| 382 |
\twocol{\<show> sub \<n>}{prints information on the \<n>th direct} |
| 383 |
\twocol{}{submodule} |
| 384 |
} |
| 385 |
\<argname> can be given by position, not by name. |
| 386 |
|
| 387 |
You can see the hierarchy of a module or a sort by the follwing |
| 388 |
\kbd{sh(ow)} commands: |
| 389 |
\paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr |
| 390 |
\twocol{sh(ow) module tree \<modexp>}{prints pictorial hierarchy of |
| 391 |
module.} |
| 392 |
\twocol{}{specifying \kbd{.} as \<modexp> shows the} |
| 393 |
\twocol{}{hierarcy of the current module} |
| 394 |
\twocol{sh(ow) sort tree \<sort>}{prints hierarchy of sort pictorially} |
| 395 |
} |
| 396 |
|
| 397 |
%%% Evaluating terms |
| 398 |
\section{Evaluating Terms} |
| 399 |
|
| 400 |
\kbd{red(uce)} [\kbd{in} \<modexp> \kbd{:}] \<term> \kbd{.} |
| 401 |
|
| 402 |
\kbd{exec(ute)} [\kbd{in} \<modexp> \kbd{:}] \<term> \kbd{.} |
| 403 |
|
| 404 |
\kbd{reduce} reduces a given term \<term> in the term rewriting system |
| 405 |
derived from \<modexp>. |
| 406 |
\kbd{execute} is similar to \kbd{reduce}, but it also considers axioms |
| 407 |
given by {\bf transition} declarations. |
| 408 |
In both cases, omitted `\kbd{in} \<modexp> \kbd{:}' defaults to the current module. |
| 409 |
|
| 410 |
The result term of \kbd{reduce} and \kbd{execute} is bould to |
| 411 |
special variables \kbd{\$\$term} and \kbd{\$\$subterm} (see the next |
| 412 |
section). |
| 413 |
|
| 414 |
%%% Let variables and special variables |
| 415 |
\section{Let Variables and Special Variables} |
| 416 |
|
| 417 |
\kbd{let} \<let-variable> \kbd{=} \<term> \kbd{.} |
| 418 |
|
| 419 |
\<let-variable> is an indentifier. Assuming the current module is set, |
| 420 |
\kbd{let} binds \<let-variable> to the given term \<term>. |
| 421 |
Once set, \<let-variable> can be used wherever \<term> can apper. |
| 422 |
|
| 423 |
You can see the list of let bidings by: |
| 424 |
|
| 425 |
\kbd{sh(ow) let} |
| 426 |
|
| 427 |
There are two built-in special variables in the system: |
| 428 |
\paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr |
| 429 |
\twocol{\$\$term}{bound to the result term of \kbd{reduce}, \kbd{execute},} |
| 430 |
\twocol{}{\kbd{parse}, or \kbd{start} commands.} |
| 431 |
\twocol{\$\$subterm}{bound to the result of \kbd{choose} command} |
| 432 |
} |
| 433 |
|
| 434 |
Let variales and special variables belongs to a context, i.e., each |
| 435 |
context has its own let variables and special variables. |
| 436 |
|
| 437 |
%%%% \newcolumn |
| 438 |
%%%% Inspecting terms |
| 439 |
\section{Inspecting Terms} |
| 440 |
\kbd{parse} [\kbd{in} \<modexp> \kbd{:}] \<term> \kbd{.} |
| 441 |
|
| 442 |
\kbd{parse} parses given term \<term> in the module \<modexp> (if |
| 443 |
omitted, parses in the current module) and prints the result. |
| 444 |
The result is bound to special variables \kbd{\$\$term} and |
| 445 |
\kbd{\$\$subterm}. |
| 446 |
|
| 447 |
The following \kbd{sh(ow)} command assumes the current module, and |
| 448 |
prints the term. |
| 449 |
|
| 450 |
\kbd{sh(ow) term} [\<let-variable>] [\kbd{tree}] |
| 451 |
|
| 452 |
\<let-variable> can be a name of \<let-variable>, \kbd{\$\$term} or |
| 453 |
\kbd{\$\$subterm}, if omitted the term bound to \kbd{\$\$term} is |
| 454 |
printed. If optional \kbd{tree} is supplied, it prints the term tree |
| 455 |
structure. By setting a switch \kbd{tree horizontal} to |
| 456 |
\kbd{true}, the term tree will be shown horizontally. |
| 457 |
|
| 458 |
%%% open/closing module |
| 459 |
\section{Opening/Closing Module} |
| 460 |
|
| 461 |
\paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr |
| 462 |
\twocol{open \<modexp>}{opens module \<modexp>} |
| 463 |
\twocol{close}{close the currently opening module} |
| 464 |
} |
| 465 |
Opening module can be modified, i.e., you can declare new sorts, |
| 466 |
operators, axioms. You can open only one module at a time. |
| 467 |
|
| 468 |
%%%% applying rewrite rules |
| 469 |
\section{Applying Rewrite Rules} |
| 470 |
|
| 471 |
\paragraph{Start} |
| 472 |
The initial target (entire term) is set by \kbd{start} command. |
| 473 |
|
| 474 |
\kbd{start} \<term> . |
| 475 |
|
| 476 |
This binds two special variables \kbd{\$\$term} and |
| 477 |
\kbd{\$\$subterm} to \<term>. |
| 478 |
|
| 479 |
\paragraph{Apply} |
| 480 |
\kbd{apply} command applies actions to (subterm of) \kbd{\$\$term}. |
| 481 |
|
| 482 |
\kbd{apply} \<action> \<range> \<selection> |
| 483 |
|
| 484 |
You specify an action by \<action>, and it will be applied to the |
| 485 |
target (sub)term specified by \<selection>. |
| 486 |
|
| 487 |
\<range> is either \kbd{within} or \kbd{at}: \kbd{within} means at or |
| 488 |
inside the (sub)term specified by the \<selection>, and \kbd{at} |
| 489 |
means exactly at the \<selection>. |
| 490 |
|
| 491 |
\paragraph{Action} |
| 492 |
\<action> can be the followings: |
| 493 |
\paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr |
| 494 |
\twocol{red(uction)}{reduce the selected term} |
| 495 |
\twocol{exec}{execute the selected term} |
| 496 |
\twocol{print}{print the selected term} |
| 497 |
\twocol{\<rule-spec>}{apply specified rule to the selected term} |
| 498 |
} |
| 499 |
|
| 500 |
\paragraph{Rule-Spec} |
| 501 |
\<rule-spec> specifies the rule with possibly substitutions being |
| 502 |
applied, and given by |
| 503 |
|
| 504 |
[\kbd{+ | -}][\<modexp>].\<rule-name> [\<substitutions>] |
| 505 |
|
| 506 |
The first optional `\kbd{+ | -}' specifies the direction of the rule; |
| 507 |
left to right(if \kbd{+} or omitted) or right to left (if \kbd{-}). |
| 508 |
|
| 509 |
A rule itself is specified by `[\<modexp>].\<rule-name>]'. This means |
| 510 |
the rule with name \<rule-name> of the module \<modexp> (if omitted, the |
| 511 |
current module). \<rule-name> is either a label of a rule or a number |
| 512 |
which shown by \kbd{sh(ow) rules} command (see {\bf Showing Available |
| 513 |
Rules below}.) |
| 514 |
|
| 515 |
\<substitution> binds variables that apper in the selected rule before |
| 516 |
applying it. This has the form |
| 517 |
|
| 518 |
\kbd{with} \<variable> \kbd{=} \<term> \kbd{,} ... |
| 519 |
|
| 520 |
\paragraph{Showing Available Rules} |
| 521 |
To see the list of the rewrite rules, use |
| 522 |
|
| 523 |
\kbd{sh(ow)} [\kbd{all}] \kbd{rules} |
| 524 |
|
| 525 |
The list of the (all, i.e., includes imported rules if the optional |
| 526 |
\kbd{all} is supplied) available rules are printed with each of which |
| 527 |
being numbered. The number can be used for \<rule-name> (see above). |
| 528 |
|
| 529 |
\paragraph{Selection} |
| 530 |
\<selection> is a sequence of \<selector> separated by keyword |
| 531 |
\kbd{of} specifying (sub)term of \kbd{\$\$term}: |
| 532 |
|
| 533 |
\<selector> $\{$ \kbd{of} \<selector> $\}$ $\cdots$ |
| 534 |
\paralign to \hsize{#\tabskip=4pt plus 1 fil&#\cr |
| 535 |
\twocol{{\bf selector}}{{\bf description}} |
| 536 |
\twocol{term}{the entire term (\kbd{\$\$term})} |
| 537 |
\twocol{top}{ditto} |
| 538 |
\twocol{subterm}{selects \kbd{\$\$subterm}} |
| 539 |
\twocol{(\<number> $\cdots$ )}{selects by position} |
| 540 |
\twocol{\kbd{[} \<number> \kbd{..} \<number> \kbd{]}}{by range |
| 541 |
in flattened term structure} |
| 542 |
\twocol{\kbd{\{} \<number> \kbd{,} $\cdots$ \kbd{\}}}{subset |
| 543 |
in flattened term structure} |
| 544 |
} |
| 545 |
|
| 546 |
\paragraph{Step by Step Subterm Selection} |
| 547 |
\kbd{choose} command selects a subterm of \kbd{\$\$subterm} and reset |
| 548 |
the \kbd{\$\$subterm} to the selected one. |
| 549 |
|
| 550 |
\kbd{choose} \<selector> |
| 551 |
|
| 552 |
\paragraph{Matching Terms} |
| 553 |
|
| 554 |
\kbd{match} \<term\_spec> \kbd{to} \<pattern> |
| 555 |
|
| 556 |
\<term\_spec> specifies the term to be matched with \<pattern>: |
| 557 |
\paralign to \hsize{#\tabskip=4pt plus 1 fil&#\cr |
| 558 |
\twocol{{\bf term\_spec}}{{\bf description}} |
| 559 |
\twocol{\kbd{term}}{\kbd{\$\$term}} |
| 560 |
\twocol{\kbd{top}}{ditto} |
| 561 |
\twocol{\kbd{subterm}}{\kbd{\$\$term}} |
| 562 |
\twocol{\kbd{it}}{ditto} |
| 563 |
\twocol{\<term>}{ordinal term} |
| 564 |
} |
| 565 |
|
| 566 |
\paralign to \hsize{#\tabskip=4pt plus 1 fil&#\cr |
| 567 |
\twocol{{\bf pattern}}{{\bf description}} |
| 568 |
\twocol{\kbd{[ all ][+ | -] rules}}{match with available rewrite |
| 569 |
rules} |
| 570 |
\twocol{\<term>}{match with specified term} |
| 571 |
} |
| 572 |
%%% stepper |
| 573 |
\section{Stepper} |
| 574 |
If the switch \kbd{step} is set to \kbd{on}, invoking \kbd{reduce} or |
| 575 |
\kbd{execute} command runs into the term rewriting stepper. |
| 576 |
The stepper has its own command interpreter loop, where the following |
| 577 |
stepper commands are avilable: |
| 578 |
|
| 579 |
\paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr |
| 580 |
\twocol{?}{print out available commands.} |
| 581 |
\twocol{n(ext)}{go one step} |
| 582 |
\twocol{g(o) \<number>}{go \<number> step} |
| 583 |
\twocol{c(ontinue)}{continue rewriting without stepping} |
| 584 |
\twocol{q(uit)}{leave stepper continuing rewrite} |
| 585 |
\twocol{a(bort)}{abort rewriting} |
| 586 |
\twocol{r(rule)}{prints current rewrite rule} |
| 587 |
\twocol{s(ubst)}{prints substitution} |
| 588 |
\twocol{l(imit)}{prints rewrite limit counter} |
| 589 |
\twocol{p(attern)}{prints stop pattern} |
| 590 |
\twocol{stop [\<term>]}{set (unset) stop pattern} |
| 591 |
\twocol{rwt [\<number>]}{set (unset) rwrite limit counter} |
| 592 |
} |
| 593 |
You can also use families of \kbd{sh(ow)}(\kbd{desc(ribe)}) |
| 594 |
and \kbd{set} commands in stepper. |
| 595 |
|
| 596 |
\section{Reading In Files} |
| 597 |
|
| 598 |
\paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr |
| 599 |
\twocol{input \<file>}{read in \cafeobj\ program from \<file>} |
| 600 |
\twocol{provide \<feature>}{provide the \<feature>} |
| 601 |
\twocol{require \<feature> [\<pathname>]}{require \<feature>} |
| 602 |
} |
| 603 |
\kbd{requre} requires a feature, which usually |
| 604 |
denotes a set of module definitions. Given this command, the |
| 605 |
system searches for a file named the feature, and read the file |
| 606 |
if found. If the \<feature> contains `::', they are treated as |
| 607 |
path separators. |
| 608 |
|
| 609 |
If a \<pathname> is given, the system searches for a file |
| 610 |
named the pathname instead. |
| 611 |
For example, \kbd{require foo::bar} |
| 612 |
would search for `foo/bar.cafe' in the pathes from `libpath'. |
| 613 |
%%% full reset |
| 614 |
\section{Resetting System} |
| 615 |
|
| 616 |
\paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr |
| 617 |
\twocol{reset}{recover definitions of built-in modules} |
| 618 |
\twocol{full reset}{reset system to initial status} |
| 619 |
} |
| 620 |
|
| 621 |
%%% protecting your modules |
| 622 |
\section{Protecting Your Modules} |
| 623 |
\paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr |
| 624 |
\twocol{protect \<modexp>}{prevent the module from redefinition} |
| 625 |
\twocol{unprotect \<modexp>}{allow moudle to be redefined} |
| 626 |
} |
| 627 |
|
| 628 |
%%% little semantic tools |
| 629 |
\newcolumn |
| 630 |
\section{Little Semantic Tools} |
| 631 |
\paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr |
| 632 |
\twocol{check reg(ularity) [\<modexp>]}{reports the result of |
| 633 |
regularity} |
| 634 |
\twocol{}{check of module} |
| 635 |
\twocol{check comat(ibility) [\<modexp>}{reports the result of |
| 636 |
compatibility} |
| 637 |
\twocol{}{check of the module} |
| 638 |
} |
| 639 |
For both commands, omitted \<modexp> will perform the |
| 640 |
check in the current module. |
| 641 |
|
| 642 |
The following \kbd{check} command assumes the current module: |
| 643 |
|
| 644 |
\kbd{check laziness} [\<operator>] |
| 645 |
|
| 646 |
This checks strictness of \<operator>. If \<operator> is omitted |
| 647 |
all of the operators declared in the current modules are checked. |
| 648 |
|
| 649 |
\section{Miscellany} |
| 650 |
\paralign to \hsize{#\tabskip=10pt plus 1 fil&#\cr |
| 651 |
\twocol{ls \<pathname>}{list contents of directories} |
| 652 |
\twocol{cd \<pathname>}{change working directory of the interpreter} |
| 653 |
\twocol{pwd}{prints working directory} |
| 654 |
\twocol{! \<command>}{fork shell \<command>} |
| 655 |
\twocol{ev \<lisp>}{evaluate lisp expression \<lisp> printing the |
| 656 |
result} |
| 657 |
\twocol{evq \<lisp>}{evaluate lisp expression \<lisp>} |
| 658 |
} |
| 659 |
\newcolumn |
| 660 |
|
| 661 |
\bye |
| 662 |
|
| 663 |
% Local variables: |
| 664 |
% compile-command: "pdftex interp" |
| 665 |
% TeX-master: t |
| 666 |
% End: |