• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Error-checking
        • Apt
        • Abnf
        • Fty-extensions
        • Isar
        • Kestrel-utilities
          • Omaps
          • Directed-untranslate
          • Include-book-paths
          • Ubi
            • Checkpoint-list
            • Digits-any-base
            • Context-message-pair
            • Numbered-names
            • With-auto-termination
            • Theorems-about-true-list-lists
            • Make-termination-theorem
            • Sublis-expr+
            • Prove$
            • Defthm<w
            • System-utilities-non-built-in
            • Integer-range-fix
            • Add-const-to-untranslate-preprocess
            • Integers-from-to
            • Minimize-ruler-extenders
            • Unsigned-byte-fix
            • Signed-byte-fix
            • Defthmr
            • Paired-names
            • Unsigned-byte-list-fix
            • Signed-byte-list-fix
            • Show-books
            • Checkpoint-list-pretty
            • List-utilities
            • Skip-in-book
            • Typed-tuplep
            • Defunt
            • Keyword-value-list-to-alist
            • Magic-macroexpand
            • Top-command-number-fn
            • Bits-as-digits-in-base-2
            • Show-checkpoint-list
            • Ubyte11s-as-digits-in-base-2048
            • Named-formulas
            • Bytes-as-digits-in-base-256
            • String-utilities
            • Make-keyword-value-list-from-keys-and-value
            • Integer-range-listp
            • Defmacroq
            • Apply-fn-if-known
            • Trans-eval-error-triple
            • Checkpoint-info-list
            • Previous-subsumer-hints
            • Fms!-lst
            • Zp-listp
            • Doublets-to-alist
            • Trans-eval-state
            • Injections
            • Theorems-about-osets
            • Typed-list-utilities
            • Book-runes-alist
            • User-interface
            • Bits/ubyte11s-digit-grouping
            • Bits/bytes-digit-grouping
            • Message-utilities
            • Subsetp-eq-linear
            • Strict-merge-sort-<
            • Miscellaneous-enumerations
            • Maybe-unquote
            • Oset-utilities
            • Thm<w
            • Defthmd<w
          • Prime-field-constraint-systems
          • Soft
          • Bv
          • Imp-language
          • Event-macros
          • Bitcoin
          • Ethereum
          • Yul
          • Zcash
          • ACL2-programming-language
          • Prime-fields
          • Java
          • C
          • Syntheto
          • Number-theory
          • Cryptography
          • Lists-light
          • File-io-light
          • Json
          • Built-ins
          • Solidity
          • Axe
          • Std-extensions
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Execloader
        • Axe
      • Testing-utilities
      • Math
    • Kestrel-utilities
    • History

    Ubi

    Undo back up to longest initial segment containing only calls of certain symbols, including defpkg and include-book.

    The following example explains how :ubi works. We start up ACL2 and submit the following commands.

    (include-book "kestrel/utilities/ubi" :dir :system)
    (local (include-book "kestrel/utilities/system/world-queries" :dir :system))
    (defpkg "FOO" nil)
    (include-book "kestrel/std/system/defun-sk-queries" :dir :system))
    (defun f (x) x)
    (include-book "arithmetic/top" :dir :system)
    (defun g (x) x)

    We can use :pbt to see where we are:

    ACL2 !>:pbt 0
               0  (EXIT-BOOT-STRAP-MODE)
       d       1  (INCLUDE-BOOK "kestrel/utilities/ubi"
                                :DIR ...)
       d       2  (LOCAL (INCLUDE-BOOK "kestrel/utilities/system/world-queries"
                                       :DIR ...))
               3  (DEFPKG "FOO" NIL)
       d       4  (INCLUDE-BOOK "kestrel/std/system/defun-sk-queries"
                                :DIR ...)
     L         5  (DEFUN F (X) ...)
       d       6  (INCLUDE-BOOK "arithmetic/top" :DIR ...)
     L         7:x(DEFUN G (X) ...)
    ACL2 !>

    The :ubi command, which could be viewed as abbreviating ``Undo Back to Includes'' or``Undo Back to Initial commands that we want to keep,'' undoes commands to keep the longest initial segment of commands in the list *keeper-cmds*, including include-book, defpkg, add-include-book-dir, and others; commands to be kept may be wrapped in calls of local or with-output. These initial commands typically set things up for the rest of the events in a given book. They often include the commands from any ACL2-customization files, followed by the include-book events at the start of the book. The :ubi command can thus be used to quickly clear out anything introduced in the book, while keeping the initial include-books, which may be slow to replay.

    So to continue the example above:

    ACL2 !>:ubi
       d       4:x(INCLUDE-BOOK "kestrel/std/system/defun-sk-queries"
                                :DIR ...)
    ACL2 !>:pbt 0
               0  (EXIT-BOOT-STRAP-MODE)
       d       1  (INCLUDE-BOOK "kestrel/utilities/ubi"
                                :DIR ...)
       d       2  (LOCAL (INCLUDE-BOOK "kestrel/utilities/system/world-queries"
                                       :DIR ...))
               3  (DEFPKG "FOO" NIL)
       d       4:x(INCLUDE-BOOK "kestrel/std/system/defun-sk-queries"
                                :DIR ...)
    ACL2 !>

    Note that when successful, :ubi generates a call of ubu, which in turn prints out the most recent remaining command (in this case, command number 4). But :ubi can fail if there is no undoing to do: we can extend the log above by trying to run :ubi again.

    ACL2 !>:ubi
    
    There is nothing to undo, since all commands after the boot-strap are
    DEFUN, DEFPKG, INCLUDE-BOOK, XDOC, ADD-INCLUDE-BOOK-DIR or
    ADD-INCLUDE-BOOK-DIR! commands.
    ACL2 !>

    Note that :ubi only looks at commands after the latest command that is a call of reset-prehistory, if any. Continuing the example above, where the final command is number 4 as shown above, let us execute these commands.

    (defun f (x) x)
    (reset-prehistory)
    (include-book "arithmetic/top" :dir :system)
    (defun g (x) x)

    Here is a subsequent log. Notice that :ubi only considers what is after the call of reset-prehistory. Thus, the initial segment that we keep concludes with the include-book that is command number 1, because defun of f preceding that command is irrelevant (since that defun precedes the reset-prehistory call).

    ACL2 !>:pbt 0
               0  (RESET-PREHISTORY)
       d       1  (INCLUDE-BOOK "arithmetic/top" :DIR ...)
     L         2:x(DEFUN G (X) ...)
    ACL2 !>:ubi
       d       1:x(INCLUDE-BOOK "arithmetic/top" :DIR ...)
    ACL2 !>

    Finally, note that ubi can be given any number of symbol arguments. These are added to *keeper-commands* as those whose calls may appear in the initial segment of post-boot-strap commands that remain after undoing. Consider for example this world:

    ACL2 !>:pbt 0
               0  (EXIT-BOOT-STRAP-MODE)
       d       1  (INCLUDE-BOOK "kestrel/utilities/ubi"
                                :DIR ...)
       d       2  (LOCAL (INCLUDE-BOOK "kestrel/utilities/system/world-queries"
                                       :DIR ...))
               3  (DEFPKG "FOO" NIL)
       d       4  (INCLUDE-BOOK "kestrel/std/system/defun-sk-queries"
                                :DIR ...)
     L         5  (DEFUN F (X) ...)
       d       6  (INCLUDE-BOOK "arithmetic/top" :DIR ...)
     L         7:x(DEFUN G (X) ...)
    ACL2 !>

    Our first example above showed that submitting :ubi leaves us with four commands after the boot-strap world. Note that submitting :ubi is equivalent to submitting (ubi); see keyword-commands. Suppose that instead, we submit the command (ubt defun). Then commands that are defun calls are allowed to remain in the resulting world. In this example, every command is either a call of defun or a call of one of the default commands in *keeper-commands*, so (ubi defun) has no effect. If we then execute some other sort of command, say a call of defmacro, then (ubi defun) will undo it, leaving us with the seven commands displayed above. Of course, (ubi defun defmacro) would not undo the defmacro call.