• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Recursion-and-induction
      • Hons-and-memoization
      • Events
        • Defun
        • Verify-guards
        • Table
        • Mutual-recursion
        • Memoize
        • Make-event
        • Include-book
        • Encapsulate
        • Defun-sk
        • Defttag
        • Defstobj
        • Defpkg
        • Defattach
        • Defabsstobj
        • Defchoose
        • Progn
        • Verify-termination
        • Redundant-events
        • Defmacro
        • Defconst
          • Prohibition-of-loop$-and-lambda$
          • Defval
          • Ignored-attachment
          • Defconsts
            • Sharp-dot-reader
          • Skip-proofs
          • In-theory
          • Embedded-event-form
          • Value-triple
          • Comp
          • Local
          • Defthm
          • Progn!
          • Defevaluator
          • Theory-invariant
          • Assert-event
          • Defun-inline
          • Project-dir-alist
          • Partial-encapsulate
          • Define-trusted-clause-processor
          • Defproxy
          • Defexec
          • Defun-nx
          • Defthmg
          • Defpun
          • Defabbrev
          • Set-table-guard
          • Name
          • Defrec
          • Add-custom-keyword-hint
          • Regenerate-tau-database
          • Defcong
          • Deftheory
          • Defaxiom
          • Deftheory-static
          • Defund
          • Evisc-table
          • Verify-guards+
          • Logical-name
          • Profile
          • Defequiv
          • Defmacro-untouchable
          • Add-global-stobj
          • Defthmr
          • Defstub
          • Defrefinement
          • Deflabel
          • In-arithmetic-theory
          • Unmemoize
          • Defabsstobj-missing-events
          • Defthmd
          • Fake-event
          • Set-body
          • Defun-notinline
          • Functions-after
          • Macros-after
          • Dump-events
          • Defund-nx
          • Defun$
          • Remove-global-stobj
          • Remove-custom-keyword-hint
          • Dft
          • Defthy
          • Defund-notinline
          • Defnd
          • Defn
          • Defund-inline
          • Defmacro-last
        • Parallelism
        • History
        • Programming
        • Operational-semantics
        • Real
        • Start-here
        • Debugging
        • Miscellaneous
        • Output-controls
        • Macros
        • Interfacing-tools
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Std/util
    • Defconst

    Defconsts

    An enhanced variant of defconst that lets you use state and other ACL2::stobjs, and directly supports calling mv-returning functions to define multiple constants.

    Examples:

    (include-book "std/util/defconsts" :dir :system)
    
    (defconsts *foo* 1)
    (defconsts (*foo*) 1)
    (defconsts (*foo* *bar*) (mv 1 2))
    (defconsts (*foo* *bar* &) (mv 1 2 3))
    
    (defconsts (& *shell* state) (getenv$ "SHELL" state))
    
    (defconsts (*hundred* state)
      (mv-let (col state)
              (fmt "Hello, world!" nil *standard-co* state nil)
              (declare (ignore col))
              (mv 100 state)))

    General form:

    (defconsts names body)

    where names may be a single symbol or a list of n symbols, and body is a form that returns n values.

    Each symbol in names should either be:

    • A "starred" name like *foo*,
    • The name of a stobj (e.g., state), or
    • The symbol &, which means "ignore this return value."

    We introduce a defconst form that binds each starred name to the corresponding value returned by body.

    Defconst versus Defconsts

    NOTE: defconsts differs from defconst in an important way. When you use these forms in a book:

    • Results from defconsts are stored in the ACL2::certificate, while
    • Results from defconst are recomputed at include-book time.

    This has some performance implications:

    • Computations that take a long time but produce "small" results (e.g., checking the primality of a large number) might best be done as defconsts to avoid repeating the computation.
    • Computations that are fast but produce "large" results (e.g., (make-list 10000)), might best be done as defconst, to avoid storing this large list in the certificate.