• 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
          • Defstobj
          • Defabsstobj
          • Stobj-table
          • Preservation-thms
          • Nested-stobjs
          • Defrstobj
          • User-stobjs-modified-warnings
          • With-global-stobj
          • Stobj-example-1
          • Defrstobj
          • Stobj-example-3
          • Stobj-example-1-proofs
          • With-local-stobj
          • Stobj-example-1-defuns
          • Declare-stobjs
          • Trans-eval-and-stobjs
            • With-local-state
            • Stobj-example-2
            • Stobj-example-1-implementation
            • Swap-stobjs
            • Resize-list
            • Nth-aliases-table
            • Trans-eval-and-locally-bound-stobjs
            • Std/stobjs
            • Count-keys
            • Update-nth-array
          • State
          • Memoize
          • Mbe
          • Io
          • Defpkg
          • Apply$
          • Mutual-recursion
          • Loop$
          • Programming-with-state
          • Arrays
          • Characters
          • Time$
          • Loop$-primer
          • Fast-alists
          • Defmacro
          • Defconst
          • Evaluation
          • Guard
          • 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
    • Trans-eval
    • Stobj

    Trans-eval-and-stobjs

    How user-defined stobjs are handled by trans-eval

    See trans-eval for basic background on the relatively advanced system utility, trans-eval. In this topic we discuss how trans-eval handles user-defined stobjs.

    A field of the ACL2 state, the user-stobj-alist, is an association list (alist) that maps each user-defined stobj name to its current value. Trans-eval evaluates with respect to this alist, so that any time a variable (which must be a stobj name) is to be evaluated, its value is looked up in that alist.

    For example, suppose that you evaluate the following forms in the top-level ACL2 loop.

    (defstobj st fld)
    (fld st)

    To evaluate the expression, (fld st), ACL2 calls trans-eval — or more accurately its variant, trans-eval-default-warning — on that expression. (We generally consider all such variants to be the same as trans-eval for purposes of this documentation topic.) Although st has the syntax of a global variable, it is bound in the user-stobj-alist. Here we see trans-eval in action.

    ACL2 !>(trace$ trans-eval-default-warning)
     ((TRANS-EVAL-DEFAULT-WARNING))
    ACL2 !>(fld st)
    1> (TRANS-EVAL-DEFAULT-WARNING (FLD ST)
                                   TOP-LEVEL |*the-live-state*| T)
    <1 (TRANS-EVAL-DEFAULT-WARNING NIL ((NIL))
                                   |*the-live-state*|)
    NIL
    ACL2 !>

    This call of trans-eval (or more accurately, trans-eval-default-warning) invokes an ACL2 evaluator (ev form alist state ...), by calling it on the form (fld st) and an alist that binds the variable st to its value in the user-stobj-alist component of the ACL2 state. We may refer to this value as the ``global value of'' st.

    We can of course update this stobj.

    ACL2 !>(update-fld 3 st)
    1> (TRANS-EVAL-DEFAULT-WARNING (UPDATE-FLD 3 ST)
                                   TOP-LEVEL |*the-live-state*| T)
    <1 (TRANS-EVAL-DEFAULT-WARNING NIL ((ST) . REPLACED-ST)
                                   |*the-live-state*|)
    <st>
    ACL2 !>(fld st) ; check that the update occurred
    1> (TRANS-EVAL-DEFAULT-WARNING (FLD ST)
                                   TOP-LEVEL |*the-live-state*| T)
    <1 (TRANS-EVAL-DEFAULT-WARNING NIL ((NIL) . 3)
                                   |*the-live-state*|)
    3
    ACL2 !>

    We see above that the global value of st was indeed updated by evaluating the update-fld call. That is: the value of st in the user-stobj-alist of the ACL2 state was updated by calling trans-eval on the expression, (update-fld 3 st). More generally: as trans-eval returns, it updates the user-stobj-alist of the ACL2 state according to all stobj values that have been returned.