• 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
          • Xargs
            • Guard
              • Verify-guards
              • Mbe
              • Set-guard-checking
              • Ec-call
              • Print-gv
              • The
              • Guards-and-evaluation
              • Guard-debug
              • Set-check-invariant-risk
              • Guard-evaluation-table
              • Guard-evaluation-examples-log
              • Guard-example
              • Defthmg
              • Invariant-risk
              • With-guard-checking
              • Guard-miscellany
              • Guard-holders
                • Guard-formula-utilities
                • Set-verify-guards-eagerness
                • Guard-quick-reference
                • Set-register-invariant-risk
                • Guards-for-specification
                • Guard-evaluation-examples-script
                • Guard-introduction
                • Program-only
                • Non-exec
                • Set-guard-msg
                • Safe-mode
                • Set-print-gv-defaults
                • Guard-theorem-example
                • With-guard-checking-event
                • With-guard-checking-error-triple
                • Guard-checking-inhibited
                • Extra-info
              • Otf-flg
              • Normalize
            • Mutual-recursion
            • Defun-mode
            • Rulers
            • Defun-inline
            • Defun-nx
            • Defund
            • Set-ignore-ok
            • Set-well-founded-relation
            • Set-measure-function
            • Set-irrelevant-formals-ok
            • Defun-notinline
            • Set-bogus-defun-hints-ok
            • Defund-nx
            • Defun$
            • Defund-notinline
            • Defnd
            • Defn
            • Defund-inline
            • Set-bogus-measure-ok
          • 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
          • 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
    • Rule-classes
    • Term
    • Guard

    Guard-holders

    Remove trivial calls from a term

    For many rule-classes, the process of converting terms to rules includes the removal of certain trivial calls from the term. Such removal is performed in some other settings as well, including hints processing, generating proof obligations for guards and termination, and the storing of induction schemes and constraints.

    In all such cases, the resulting term is provably equivalent to the input term. A common example is to replace the term (prog2$ term1 term2) by the term term2. But (prog2$ term1 term2) is really an abbreviation for (i.e., macroexpands to) the term (return-last 'progn term1 term2); so a more accurate explanation, at the level of proper ACL2 terms, is that the call of function return-last is replaced by its last argument. ACL2 identifies certain such transformations, from a term to a trivial simplification of it, such that the input and output are provably equal. We historically have referred to the process of making such replacements as ``removing guard holders.'' (For a discussion of the connection to guards, see the ``Essay on the Removal of Guard Holders'' in the ACL2 sources.)

    The process of removing guard-holders includes the transformations below. That process is also applied to each argument of a function call and to the bodies of lambda expressions (see term), usually including quoted lambda expressions that appear in an argument position with ilk :FN (see apply$).

    (return-last term0 term1 term2)  ==>  term2
    
    (mv-list n term)                 ==>  term
    
    (cons-with-hint x y)             ==>  (cons x y)
    
    (the-check guard x y)            ==>  y
    
    (from-df x)                      ==>  x
    
    (to-df 'r)                       ==>  'r ; only when r satisfies dfp
    
    (df0)                            ==>  0
    
    (df1)                            ==>  1
    
    (do$ x1 x2 x3 x4 x5 'u1)         ==> (do$ x1 x2 x3 x4 x5 'nil)
                                         ; only when u1 is non-nil
    
    ; For replacing a term (the type term) by term:
    ((lambda (y) (the-check guard x y))
     val)                            ==>  val
    
    ; For replacing equality aliases; for example, this transforms
    ; the macroexpansion of (member x y) to (member-equal x y):
    (('LAMBDA (f1 ... fk) ('RETURN-LAST ''MBE1-RAW exec logic))
     a1 ... ak)                      ==>  logic
    
    ; For other than measure theorems and induction schemes, remove lambda
    ; applications that are ``trivial'' in either of the following two senses.
    
    ; For replacing a term (let ((v term)) v) by term:
    (('LAMBDA (v) v) term)           ==>  term
    
    ; When each formal is equal to the corresponding actual:
    (('LAMBDA (f1 ... fk) body)
     f1 ... fk)                      ==>  body

    Because of how mbe and ec-call are defined in terms of return-last, the expressions (mbe :logic l :exec e) and (ec-call (f t1 ... tk)) are effectively transformed by removing guard holders into l and (f t1 ... tk), respectively.

    The final two classes of simplification above (removal of ``trivial'' lambda applications) may be removed by executing the following form, which is local to an encapsulate form and to books.

    (defattach-system remove-guard-holders-lamp constant-nil-function-arity-0)

    Here is how to restore the default behavior.

    (defattach-system remove-guard-holders-lamp constant-t-function-arity-0)

    Note that by default, guard-holders are not removed inside calls of hide. You can however cause them to be removed inside such calls after all, as was the case through Version 8.2, as follows.

    (defattach-system ; generates (local (defattach ...))
      remove-guard-holders-blocked-by-hide-p
      constant-nil-function-arity-0)