Debugging Computed Hints

We have found that it is sometimes helpful to define hints so that they print out messages to the terminal when they fire, so you can see what hint was generated and which of your computed hints did it.

To that end we have defined a macro we sometimes use. Suppose you have a :hints specification such as:

:hints (computed-hint-fn (hint-expr id))
If you defmacro the macro below you could then write instead:
:hints ((show-hint computed-hint-fn 1)
        (show-hint (hint-expr id) 2))
with the effect that whenever either hint is fired (i.e., returns non-nil), a message identifying the hint by the marker (1 or 2, above) and the non-nil value is printed.

(defmacro show-hint (hint &optional marker)
   ((and (consp hint)
         (stringp (car hint)))
    `(let ((marker ,marker)
           (ans ,(if (symbolp hint)
                     `(,hint id clause world stable-under-simplificationp)
       (if ans
            (cw "~%***** Computed Hint~#0~[~/ (from hint ~x1)~]~%~x2~%~%"
                (if (null marker) 0 1)
                (cons (string-for-tilde-@-clause-id-phrase id)
Note that when show-hint is applied to a hint that is a symbol, e.g., computed-hint-fn, it applies the symbol to the four computed-hint arguments: id, clause, world, and stable-under-simplificationp. If computed-hint-fn is of arity 3 the code above would cause an error. One way to avoid it is to write
:hints ((show-hints (computed-hint-fn id clause world) 1)
        (show-hint (hint-expr id) 2)).
If you only use computed hints of arity 3, you might eliminate the occurrence of stable-under-simplificationp in the definition of show-hint above.

Putting a show-hint around a common hint has no effect. If you find yourself using this utility let us know and we'll consider putting it into the system itself. But it does illustrate that you can use computed hints to do unusual things.