• 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
      • Start-here
      • Real
      • Debugging
      • Miscellaneous
        • Term
        • Ld
          • Wormhole
          • Ld-skip-proofsp
          • Ld-redefinition-action
          • Lp
          • Ld-error-action
          • Ld-history
          • Guarantees-of-the-top-level-loop
          • Ld-post-eval-print
          • Ld-keyword-aliases
          • Current-package
          • Ld-query-control-alist
          • Ld-prompt
          • Keyword-commands
          • Redef+
          • Rebuild
          • Prompt
          • Ld-pre-eval-print
          • Calling-ld-in-bad-contexts
            • Ld-pre-eval-filter
            • P!
            • Ld-error-triples
            • Ld-verbose
            • Ld-evisc-tuple
            • A!
            • Default-print-prompt
            • Reset-ld-specials
            • Ld-always-skip-top-level-locals
            • Ld-missing-input-ok
            • Redef
            • Redef!
            • Redef-
            • I-am-here
            • Abort!
          • Hints
          • Type-set
          • Ordinals
          • ACL2-customization
          • With-prover-step-limit
          • With-prover-time-limit
          • Set-prover-step-limit
          • Local-incompatibility
          • Set-case-split-limitations
          • Subversive-recursions
          • Specious-simplification
          • Defsum
          • Oracle-timelimit
          • Thm
          • Defopener
          • Gcl
          • Case-split-limitations
          • Set-gc-strategy
          • Default-defun-mode
          • Top-level
          • Reader
          • Ttags-seen
          • Adviser
          • Ttree
          • Abort-soft
          • Defsums
          • Gc$
          • With-timeout
          • Coi-debug::fail
          • Expander
          • Gc-strategy
          • Coi-debug::assert
          • Sin-cos
          • Def::doc
          • Syntax
          • Subversive-inductions
        • Output-controls
        • Macros
        • Interfacing-tools
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Testing-utilities
      • Math
    • Ld

    Calling-ld-in-bad-contexts

    Errors caused by calling ld in inappropriate contexts

    The macro ld was designed to be called directly in the top-level ACL2 loop, although there may be a few occasions for calling it from functions. ACL2 cannot cope with invocations of ld during the process of loading a compiled file for a book, so that is an error.

    Specifically: ACL2 will cause an error in the following two circumstances:

    • when calling ld inside progn! unless state global ld-okp is first set to t, e.g., using (assign ld-okp t); also,
    • when calling ld while inside raw Lisp, e.g., when loading a compiled file during an invocation of include-book.

    Consider for example the following book, where file const.lsp contains the single form (defconst *foo* '(a b)) after its initial in-package form.

    (in-package "ACL2")
    (defttag t)
    (progn! (ld "const.lsp"))

    An attempt to certify this book as follows

    (certify-book "const-wrapper" 0 t :ttags :all)

    will cause an error:

    ACL2 Error in LD:  It is illegal to call LD in this context.  See :DOC
    calling-ld-in-bad-contexts.

    However, that error can be avoided by expanding the progn! call as follows.

    (progn! (assign ld-okp t)
            (ld "const.lsp"))

    Now certification succeeds; however, any subsequent call of include-book will fail to load the compiled file for the book. Again, that is necessary because of how ACL2 is designed; in this case, the ld call would interfere with tracking of constant definitions when loading the compiled file for the book. To avoid warnings about loading compiled files, either certify the book without creating a compiled file or else include the book without loading the compiled file; see certify-book and include-book.

    Note that it is legal to put a definition such as the following into a book, where ld is called in the body of a function; the two conditions above do not prohibit this.

    (defun foo (state)
      (declare (xargs :guard t :stobjs state :mode :program))
      (ld '((defun h (x) x)) :ld-user-stobjs-modified-warning t))

    One can then include the book, evaluate (foo state), and then evaluate calls of h.