• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Hons-and-memoization
      • Events
      • History
      • Parallelism
      • Programming
        • Defun
        • Declare
        • System-utilities
        • Stobj
        • State
        • Memoize
        • Mbe
        • Io
        • Defpkg
        • Apply$
        • Mutual-recursion
        • Loop$
        • Programming-with-state
        • Arrays
        • Characters
        • Time$
        • Loop$-primer
        • Fast-alists
        • Defmacro
        • Defconst
        • Evaluation
        • Guard
          • Verify-guards
          • Mbe
          • Set-guard-checking
          • Ec-call
          • Print-gv
          • Guards-and-evaluation
          • Guard-debug
          • Set-check-invariant-risk
          • Guard-evaluation-table
          • The
          • Guard-evaluation-examples-log
          • Guard-miscellany
          • Defthmg
          • Invariant-risk
          • With-guard-checking
          • Guard-holders
          • Guard-formula-utilities
          • Guard-example
          • Set-verify-guards-eagerness
          • Guard-quick-reference
          • Set-register-invariant-risk
          • Guards-for-specification
          • Guard-evaluation-examples-script
          • Guard-introduction
          • Non-exec
          • Set-guard-msg
          • Safe-mode
            • Safe-mode-cheat-sheet
            • Set-print-gv-defaults
            • Guard-theorem-example
            • With-guard-checking-event
            • With-guard-checking-error-triple
            • Program-only
            • Guard-checking-inhibited
            • Extra-info
          • Equality-variants
          • Compilation
          • Hons
          • ACL2-built-ins
          • Developers-guide
          • System-attachments
          • Advanced-features
          • Set-check-invariant-risk
          • Numbers
          • Irrelevant-formals
          • Efficiency
          • Introduction-to-programming-in-ACL2-for-those-who-know-lisp
          • Redefining-programs
          • Lists
          • Invariant-risk
          • Errors
          • Defabbrev
          • Conses
          • Alists
          • Set-register-invariant-risk
          • Strings
          • Program-wrapper
          • Get-internal-time
          • Basics
          • Packages
          • Defmacro-untouchable
          • Primitive
          • <<
          • Revert-world
          • Set-duplicate-keys-action
          • Unmemoize
          • Symbols
          • Def-list-constructor
          • Easy-simplify-term
          • Defiteration
          • Defopen
          • Sleep
        • Start-here
        • Real
        • Debugging
        • Miscellaneous
        • Output-controls
        • Macros
        • Interfacing-tools
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Testing-utilities
      • Math
    • Safe-mode

    Safe-mode-cheat-sheet

    Working around ``program-only'' issues

    This cheat sheet gives workarounds for errors caused by attempts to evaluate executable-counterparts (see evaluation) of so-called program-only functions. This most often occurs when safe-mode is active. Recall that safe-mode can be set by (assign safe-mode t), and also is used during macroexpansion and other logical acts that might involve :program mode functions.

    The problems manifest with a hard error like this:

    HARD ACL2 ERROR in PROGRAM-ONLY:  The call
    <term>
    is an illegal call of a function that has been marked as ``program-
    only,'' presumably because it has special raw Lisp code and safe-mode
    is active.  See :DOC program-only for further explanation and a link
    to possible workarounds.
    (See :DOC set-iprint to be able to see elided values in this message.)

    When the term is a call of ev-w, an unsafe hack allowing such calls is as follows. Warning: This may result in unsoundness!

    (value :q)
    (setf (symbol-function (*1*-symbol 'ev-w))
          (symbol-function 'ev-w))
    (lp)

    Typically that just leads to other similar errors and so you discover the call tree, each of whose functions can be handled similarly (also in raw Lisp):

    (setf (symbol-function (*1*-symbol 'ev-rec))
          (symbol-function 'ev-rec))
    (setf (symbol-function (*1*-symbol 'ev-fncall-rec))
          (symbol-function 'ev-fncall-rec))
    (setf (symbol-function (*1*-symbol 'push-warning))
          (symbol-function 'push-warning))

    Other times you may avoid the problem by defining your own utilities. For example, in safe-mode you can't use the utility without-evisc (which is useful when iprinting is active). But the following works, provided form evaluates to an error-triple.

    (defmacro without-evisc-error-triple (form)
      `(state-global-let*
        ((abbrev-evisc-tuple nil set-abbrev-evisc-tuple-state)
         (gag-mode-evisc-tuple nil set-gag-mode-evisc-tuple-state)
         (term-evisc-tuple nil set-term-evisc-tuple-state)
         (ld-evisc-tuple nil set-ld-evisc-tuple-state))
        ,form))

    The following log illustrates how to use this utility to avoid an error caused by without-evisc in safe-mode.

    ACL2 !>(set-iprint t)
    
    ACL2 Observation in SET-IPRINT:  Iprinting has been enabled.
    ACL2 !>(assign safe-mode t)
     T
    ACL2 !>(cw "Something printed with evisceration: ~X01~|"
               '((((DEEP))))
               (evisc-tuple 3 4 nil nil))
    Something printed with evisceration: (((#@1#)))
    NIL
    ACL2 !>(without-evisc-error-triple (value '(((#@1#)))))
     ((((DEEP))))
    ACL2 !>