Control whether abbreviated output can be read back in
The following log may be sufficient for you to see how to use
ACL2 !>(thm (p y)) (1 Breaking (:REWRITE AX) on (P Y): 1 ACL2 >:eval 1x (:REWRITE AX) failed because :HYP 1 rewrote to (EQUAL Y '(NIL NIL NIL NIL ...)). 1 ACL2 >:a! Abort to ACL2 top-level Here is the current pstack [see :DOC pstack]: (REWRITE-ATM SIMPLIFY-CLAUSE WATERFALL) *** Note: No checkpoints to print. *** ACL2 Version 6.4. Level 1. Cbd "u/smith/". System books directory "/u/smith/acl2/v6-4/books/". Type :help for help. Type (good-bye) to quit completely out of ACL2. ACL2 !>(set-iprint t) ACL2 Observation in SET-IPRINT: Iprinting has been enabled. ACL2 !>(thm (p y)) (1 Breaking (:REWRITE AX) on (P Y): 1 ACL2 >:eval 1x (:REWRITE AX) failed because :HYP 1 rewrote to (EQUAL Y '(NIL NIL NIL NIL . #@2#)). 1 ACL2 >(without-evisc '(EQUAL Y '(NIL NIL NIL NIL . #@2#))) (EQUAL Y '(NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)) 1 ACL2 >
This concludes the introductory example.
When ACL2 pretty-prints large expressions using formatted printing
(see fmt), it may save time and space by printing tokens `
(set-iprint t)
to enable a mode called ``iprinting''. Then, instead of printing `
The following example should suffice to illustrate how to recover elided
subexpressions. (Below this example we provide details that may be of
interest only to advanced users.) Here we cause an error by defining a macro
of one argument and then calling it with two arguments. By default, error
messages abbreviate subexpressions deeper than level 5 with `
ACL2 !>(defmacro foo (x) x) Summary Form: ( DEFMACRO FOO ...) Rules: NIL Warnings: None Time: 0.02 seconds (prove: 0.00, print: 0.00, other: 0.02) FOO ACL2 !>(foo arg1 (a (b (c (d (e (f (g)))))) h i j k l m n)) ACL2 Error in macro expansion: Wrong number of args in macro expansion of (FOO ARG1 (A (B (C (D #))) H I J K L ...)). (See :DOC set-iprint to be able to see elided values in this message.) ACL2 !>(set-iprint t) ACL2 Observation in SET-IPRINT: Iprinting has been enabled. ACL2 !>(foo arg1 (a (b (c (d (e (f (g)))))) h i j k l m n)) ACL2 Error in macro expansion: Wrong number of args in macro expansion of (FOO ARG1 (A (B (C (D #@1#))) H I J K L . #@2#)). ACL2 !>(acl2-count '(FOO ARG1 (A (B (C (D #@1#))) H I J K L . #@2#))) 23 ACL2 !>
Sometimes you may want to supply the abbreviated form not to compute with it, as in the ACL2-count example just above, but so that you can see it. The macro without-evisc eliminates elision during printing. Below we show two ways to use this utility: first, we use it to print the elided form, and then, we use it instead on the original input form to print the entire error message.
ACL2 !>(without-evisc '(FOO ARG1 (A (B (C (D #@1#))) H I J K L . #@2#))) (FOO ARG1 (A (B (C (D (E (F (G)))))) H I J K L M N)) ACL2 !>(without-evisc (foo arg1 (a (b (c (d (e (f (g)))))) h i j k l m n))) ACL2 Error in macro expansion: Wrong number of args in macro expansion of (FOO ARG1 (A (B (C (D (E (F (G)))))) H I J K L M N)). ACL2 !>
If you wish to know which elided expressions are equal, you may call
ACL2 !>'((a b c d e f) (a b c d e f) (a b c d e f)) ((A B . #@2#) (A B . #@2#) . #@3#) ACL2 !>
We use the log displayed below to explain iprint sharing a bit more. The
Warning below is pointing out that previous iprint indices are no longer
valid; we are starting over. The first Observation points out that iprint
sharing is on, and gives the name
ACL2 !>(set-iprint t :share t) ACL2 Warning [Iprint] in SET-IPRINT: Converting SET-IPRINT action from T to :RESET-ENABLE, as required by use of keyword :SHARE or :HARD- BOUND. See :DOC set-iprint. ACL2 Observation in SET-IPRINT: Iprinting is enabled with sharing, with a fast-alist whose name is :IPRINT-FAL. ACL2 Observation in SET-IPRINT: Iprinting has been reset and enabled. ACL2 !>(set-evisc-tuple (evisc-tuple 2 2 nil nil) :sites :all) (:TERM :LD . #@1#) ACL2 !>'((a b c d e f) (a b c d e f) (a b c d e f)) ((A B . #@2#) (A B . #@2#) . #@3#) ACL2 !>'(b c d e f) (B C . #@4#) ACL2 !>
One might have expected the last form printed above to take advantage of
the fact that the tail
(set-iprint t :share :eager)
If we use that call of
ACL2 !>'((a b c d e f) (a b c d e f) (a b c d e f)) ((A B . #@2#) (A B . #@2#) . #@3#) ACL2 !>'(b c d e f) (B . #@2#) ACL2 !>
The documentation above probably suffices for most users. For those who
want more details, below we detail all the ways to use the
Example Forms: (set-iprint t) ; enable iprinting (elision with #@i@) (set-iprint nil) ; disable iprinting General Form: (set-iprint action ; t, nil, :reset, :reset-enable, or :same :share sym ; initially nil :soft-bound s ; initially 1000 :hard-bound h ; initially 10000)
where all arguments are optional, but ACL2 queries for
t — Enable iprinting. If either keyword:share or:hard-bound is supplied, thent is converted to:reset-enable .
nil — Disable iprinting. If either keyword:share or:hard-bound is supplied, thennil is converted to:reset . Otherwise, if the next call ofset-iprint is with a first argument oft , then iprint indices will start at the next available value rather than going back to 1.
:reset — Reset iprinting to its initial disabled state, so that when enabled, the first indexi for which `#@i# is printed will be 1. Note that all stored information for existing iprint indices will be erased.
:reset-enable — Reset iprinting as with:reset , and then enable iprinting.
:same — If either keyword:share or:hard-bound is supplied, then:same is converted to:reset or:reset-enable according to whether iprinting is currently disabled or enabled, respectively. Otherwise, make no change to the iprinting state other than setting thesoft-bound if specified, as explained below.
The value of
Immediately after a top-level form is read, hence before it is evaluated, a
check is made for whether the latest iprint index exceeds a certain bound,
The above ``soft bound'' is applied once for each top-level form, but you
may want finer control by applying a bound after the pretty-printing of each
individual form (since many forms may be pretty-printed between successive
evaluations of top-level forms). That bound is
A ``rollover'' is the detection that the soft or hard bound has been
exceeded, along with a state update setting
ACL2 !>(set-iprint t :soft-bound 3) ACL2 Observation in SET-IPRINT: The soft-bound for iprinting has been set to 3. ACL2 Observation in SET-IPRINT: Iprinting has been enabled. ACL2 !>(set-evisc-tuple (evisc-tuple 2 3 nil nil) :sites :ld) (:LD) ACL2 !>'((a b c d e f g) (a b c d e f g) (a b c d e f g)) ((A B C . #@1#) (A B C . #@2#) (A B C . #@3#)) ACL2 !>'((a b c d e f g) (a b c d e f g) (a b c d e f g)) ((A B C . #@4#) (A B C . #@5#) (A B C . #@6#)) ACL2 !>(without-evisc '((A B C . #@4#) (A B C . #@5#) (A B C . #@6#))) ((A B C D E F G) (A B C D E F G) (A B C D E F G)) ACL2 !>'(1 2 3 4 5) (1 2 3 . #@1#) ACL2 !>'((a b c d e f g) (a b c d e f g) (a b c d e f g)) ((A B C . #@2#) (A B C . #@3#) (A B C . #@4#)) ACL2 !>(without-evisc '((A B C . #@4#) (A B C . #@5#) (A B C . #@6#))) ((A B C D E F G) (A B C D E F G) (A B C D E F G)) ACL2 !>(without-evisc '((A B C . #@4#) (A B C . #@5#) (A B C . #@6#))) *********************************************** ************ ABORTING from raw Lisp *********** ********** (see :DOC raw-lisp-error) ********** Error: Out-of-bounds index in #@5#. See :DOC set-iprint. *********************************************** The message above might explain the error. If not, and if you didn't cause an explicit interrupt (Control-C), then it may help to see :DOC raw-lisp-error. To enable breaks into the debugger (also see :DOC acl2-customization): (SET-DEBUGGER-ENABLE T) ACL2 !>
Rollover has the following additional effect when iprint sharing is on: it is illegal to read a form that has both an index from before the rollover and an index from after the rollover. The following log illustrates this requirement. Note that if the last input form below were read without error, the result would likely be highly confusing, since iprint index 1 no longer refers to the value it was originally given at the time the other iprint indices in the input (2, 3, and 4) were given their values.
ACL2 !>(set-iprint t :soft-bound 3 :share t) ACL2 Warning [Iprint] in SET-IPRINT: Converting SET-IPRINT action from T to :RESET-ENABLE, as required by use of keyword :SHARE or :HARD- BOUND. See :DOC set-iprint. ACL2 Observation in SET-IPRINT: The soft-bound for iprinting has been set to 3. ACL2 Observation in SET-IPRINT: Iprinting is enabled with sharing, with a fast-alist whose name is :IPRINT-FAL. ACL2 Observation in SET-IPRINT: Iprinting has been reset and enabled. ACL2 !>(set-evisc-tuple (evisc-tuple 2 3 nil nil) :sites :ld) (:LD) ACL2 !>'((a b c d) (x y z w)) ((A B C . #@1#) (X Y Z . #@2#)) ACL2 !>'((e f g h) (k l m n)) ((E F G . #@3#) (K L M . #@4#)) ACL2 !>'(#@1# #@2# #@3# #@4#) ; OK, since rollover occurs after the read ((D) (W) (H) . #@1#) ACL2 !>'(#@1# #@2# #@3# #@4#) *********************************************** ************ ABORTING from raw Lisp *********** ********** (see :DOC raw-lisp-error) ********** Error: Attempt to read a form containing both an index created before the most recent rollover (#@2#) and an index created after that rollover (#@1#). See :DOC set-iprint. *********************************************** The message above might explain the error. If not, and if you didn't cause an explicit interrupt (Control-C), then it may help to see :DOC raw-lisp-error. To enable breaks into the debugger (also see :DOC acl2-customization): (SET-DEBUGGER-ENABLE T) ACL2 !>
We conclude by mentioning two cases where iprinting and evisc-tuples are ignored. (1) This is typically the case when printing results in raw Lisp outside the ACL2 loop. To use iprinting and evisc-tuples in raw Lisp, use raw-mode; see set-raw-mode. In raw-mode, results that are ACL2 objects will be printed in the same way that ACL2 would print those results if not in raw-mode. (2) Iprinting and evisc-tuples are ignored by print-object$, which however is sensitive to many settings that do not affect formatted (fmt etc.) printing; see print-control.
The reader interested in design and implementation issues considered during the addition of iprinting to ACL2 is invited to read the paper ``Abbreviated Output for Input in ACL2: An Implementation Case Study''; see the proceedings of ACL2 Workshop 2009.