• 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
      • Parallelism
      • History
      • Programming
        • Defun
        • Declare
          • 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
            • Type-spec
            • Declare-stobjs
            • Set-ignore-ok
            • Set-irrelevant-formals-ok
          • System-utilities
          • Stobj
          • State
          • Mutual-recursion
          • Memoize
          • Mbe
          • Io
          • Defpkg
          • Apply$
          • Loop$
          • Programming-with-state
          • Arrays
          • Characters
          • Time$
          • Defmacro
          • Loop$-primer
          • Fast-alists
          • Defconst
          • Evaluation
          • 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
            • Equality-variants
            • Compilation
            • Hons
            • ACL2-built-ins
              • Let
              • Declare
                • 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
                  • Type-spec
                  • Declare-stobjs
                  • Set-ignore-ok
                  • Set-irrelevant-formals-ok
                • Mbe
                • Apply$
                • Fmt
                • Loop$
                • Return-last
                • Mv-let
                • Df
                • Pseudo-termp
                • Defwarrant
                • Time$
                • Mbt
                • Ec-call
                • Mv-nth
                • Sys-call
                • Msg
                • Er
                • Value-triple
                • O-p
                • Comp
                • Member
                • O<
                • Cw
                • Flet
                • Or
                • Hons
                • Cbd
                • Mv
                • Defbadge
                • Append
                • *ACL2-exports*
                • Comment
                • Eql
                • List
                • Unsigned-byte-p
                • Posp
                • Natp
                • The
                • Nth
                • And
                • Len
                • Time-tracker
                • Term-order
                • True-listp
                • Msgp
                • Booleanp
                • <
                • If
                • Pseudo-term-listp
                • +
                • Not
                • With-global-stobj
                • Bitp
                • Equal
                • Cdr
                • Car
                • String-listp
                • Nat-listp
                • Implies
                • Iff
                • Character-listp
                • Alistp
                • Cons
                • Symbol-listp
                • Macrolet
                • Quote
                • Integerp
                • Consp
                • True-list-listp
                • State-global-let*
                • Compress1
                • Symbolp
                • Stringp
                • *common-lisp-symbols-from-main-lisp-package*
                • Characterp
                • Prog2$
                • *
                • Last-prover-steps
                • Hons-acons
                • Let*
                • Eq
                • With-guard-checking
                • @
                • Length
                • With-local-stobj
                • Hard-error
                • -
                • Zp
                • Search
                • Intersection$
                • Assign
                • Aset1
                • Symbol-name
                • Union$
                • Set-gc-strategy
                • In-tau-intervalp
                • Cons-with-hint
                • Break-on-error
                • Pand
                • Case-match
                • Fast-alist-fork
                • Sys-call+
                • Signed-byte-p
                • ACL2-count
                • Remove-duplicates
                • With-serialize-character
                • Observation
                • Hons-resize
                • Make-tau-interval
                • Logbitp
                • Termp
                • Position
                • Assoc
                • *standard-co*
                • Hons-acons!
                • Update-nth
                • Take
                • Aref1
                • Read-run-time
                • Keywordp
                • Symbol-package-name
                • Symbol-alistp
                • Hons-wash
                • Expt
                • Coerce
                • Get-internal-time
                • Intern
                • Non-exec
                • Case
                • Standard-oi
                • Standard-co
                • Formula
                • Nthcdr
                • Atom
                • Without-evisc
                • Good-bye
                • With-local-state
                • Spec-mv-let
                • Intern-in-package-of-symbol
                • Binary-+
                • <=
                • Ash
                • With-fast-alist
                • Set-difference$
                • Hons-clear
                • Flush-compress
                • Rationalp
                • Por
                • Rassoc
                • Remove-assoc
                • =
                • Pargs
                • Nfix
                • Hons-copy
                • Alphorder
                • Subsetp
                • Logand
                • Remove1-assoc
                • No-duplicatesp
                • Mv-list
                • Canonical-pathname
                • Aset2
                • Floor
                • Serialize-read
                • Random$
                • Fmt-to-comment-window
                • F-put-global
                • Compress2
                • Concatenate
                • Fast-alist-clean
                • Assert$
                • Remove
                • Remove1
                • Intersectp
                • Endp
                • Put-assoc
                • Princ$
                • Primitive
                • Keyword-value-listp
                • True-list-fix
                • Swap-stobjs
                • Integer-listp
                • Illegal
                • Hons-get
                • With-output-lock
                • Setenv$
                • Open-output-channel!
                • Fast-alist-free
                • Er-progn
                • Cw-print-base-radix
                • Reverse
                • Cond
                • Complex
                • Add-to-set
                • Truncate
                • Digit-char-p
                • Code-char
                • Char-code
                • Set-print-case
                • Set-print-base
                • Read-ACL2-oracle
                • Error1
                • Print-object$
                • Plet
                • Integer-length
                • Zip
                • With-live-state
                • Hons-assoc-equal
                • Extend-pathname
                • Logior
                • With-guard-checking-event
                • Term-listp
                • Print-object$+
                • Fmx-cw
                • String
                • Mod
                • In-package
                • Unary--
                • Set-print-radix
                • Resize-list
                • Pkg-witness
                • Revappend
                • Null
                • Term-list-listp
                • Make-fast-alist
                • Header
                • Boole$
                • Subseq
                • With-guard-checking-error-triple
                • /
                • Make-list
                • Logxor
                • Char-upcase
                • Char-downcase
                • Strip-cars
                • Set-fmt-hard-right-margin
                • Make-ord
                • Ifix
                • Fast-alist-free-on-exit
                • F-get-global
                • Aref2
                • Standard-char-p
                • Lognot
                • Last
                • Must-be-equal
                • Integer-range-p
                • Getenv$
                • Binary-append
                • Er-hard
                • Eqlablep
                • Cpu-core-count
                • Boolean-listp
                • Allocate-fixnum-range
                • ACL2-numberp
                • Butlast
                • Pairlis$
                • Mod-expt
                • Hons-equal
                • Gc$
                • Substitute
                • Ceiling
                • With-stolen-alist
                • Mv?-let
                • String-upcase
                • String-downcase
                • Round
                • Count
                • Char
                • Sys-call-status
                • Progn$
                • Pprogn
                • Lexorder
                • Hons-summary
                • Break$
                • Assert*
                • Alpha-char-p
                • Strip-cdrs
                • Serialize-write
                • Keyword-listp
                • Upper-case-p
                • Lower-case-p
                • Logeqv
                • List*
                • Proofs-co
                • Maximum-length
                • Fix
                • Explode-nonnegative-integer
                • Eqlable-listp
                • Dimensions
                • Default
                • Arity
                • Sublis
                • Max
                • Evenp
                • Explode-atom
                • Change
                • Zerop
                • String<
                • String-equal
                • Abs
                • Set-print-base-radix
                • Print-base-p
                • Nonnegative-integer-quotient
                • Intern$
                • Getprop
                • Binary-*
                • Aset1-trusted
                • Symbol<
                • String-append
                • Rfix
                • Mv?
                • Logic-fns-list-listp
                • Fast-alist-fork!
                • Er-hard?
                • Char-equal
                • 1+
                • *standard-oi*
                • Sys-call*
                • Pos-listp
                • Mbt*
                • Hons-wash!
                • Hons-clear!
                • Signum
                • Rem
                • Real/rationalp
                • Rational-listp
                • O-first-coeff
                • Logic-fnsp
                • Logic-fns-listp
                • Hons-copy-persistent
                • Gc-strategy
                • Fast-alist-summary
                • String>=
                • String<=
                • Acons
                • O-first-expt
                • Fast-alist-clean!
                • >=
                • >
                • Subst
                • Logcount
                • Getpropc
                • Evens
                • Er-soft
                • Digit-to-char
                • Comp-gcl
                • Atom-listp
                • Arities-okp
                • ACL2-number-listp
                • /=
                • Cadr
                • *standard-ci*
                • Unary-/
                • The-true-list
                • Realfix
                • O-rst
                • Fast-alist-len
                • Complex/complex-rationalp
                • Array2p
                • Array1p
                • Logtest
                • Logandc1
                • Char<
                • Trace-co
                • Putprop
                • Get-real-time
                • Eqlable-alistp
                • Count-keys
                • Assoc-string-equal
                • Logorc1
                • Logandc2
                • Denominator
                • 1-
                • Packn
                • Logic-termp
                • Logic-term-list-listp
                • Fmt!
                • Fms
                • Cw!
                • Assoc-keyword
                • String>
                • Numerator
                • Logorc2
                • Char>=
                • Update-nth-array
                • The-number
                • Odds
                • Makunbound-global
                • Make-character-list
                • Make
                • List$
                • Int=
                • Get-cpu-time
                • Fmt-to-comment-window!
                • Fms!
                • F-boundp-global
                • Complex-rationalp
                • Alist-to-doublets
                • Access
                • Min
                • Lognor
                • Listp
                • Identity
                • Char>
                • Char<=
                • Zpf
                • Standard-char-listp
                • O-finp
                • Number-subtrees
                • Logic-term-listp
                • Last-cdr
                • Fmt1!
                • Fmt-to-comment-window!+
                • Character-alistp
                • Oddp
                • Minusp
                • Lognand
                • Imagpart
                • Conjugate
                • Xor
                • Unquote
                • String-alistp
                • Packn-pos
                • Maybe-flush-and-compress1
                • Kwote
                • Fmt1
                • Fmt-to-comment-window+
                • Cw-print-base-radix!
                • Alist-keys-subsetp
                • Realpart
                • Plusp
                • First
                • Symbol-name-lst
                • R-symbol-alistp
                • R-eqlable-alistp
                • Fmx
                • Cw!+
                • Cons-subtrees
                • Cons-count-bounded
                • Cddr
                • Caar
                • Proper-consp
                • Kwote-lst
                • Improper-consp
                • Cw+
                • Rest
                • Standard-char-p+
                • Mbe1
                • Caddr
                • Pairlis-x2
                • Pairlis-x1
                • O>=
                • O<=
                • O-infp
                • Merge-sort-lexorder
                • Fix-true-list
                • Cdddr
                • Set-fmt-soft-right-margin
                • Real-listp
                • O>
                • Cddar
                • Cdar
                • Cdadr
                • Cdaar
                • Cadar
                • Caadr
                • Caaar
                • Cadddr
                • Caddar
                • Third
                • Tenth
                • Sixth
                • Seventh
                • Second
                • Ninth
                • Fourth
                • Fifth
                • Eighth
                • Cddddr
                • Cdddar
                • Cddadr
                • Cddaar
                • Cdaddr
                • Cdadar
                • Cdaadr
                • Cdaaar
                • Cadadr
                • Cadaar
                • Caaddr
                • Caadar
                • Caaadr
                • Caaaar
                • Hons-shrink-alist!
                • Hons-shrink-alist
                • Flush-hons-get-hash-table-link
                • Delete-assoc
              • Developers-guide
              • System-attachments
              • Advanced-features
              • Set-check-invariant-risk
              • Numbers
              • Efficiency
              • Irrelevant-formals
              • 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
              • Oracle-eval
              • Defmacro-untouchable
              • <<
              • Primitive
              • Revert-world
              • Unmemoize
              • Set-duplicate-keys-action
              • Symbols
              • Def-list-constructor
              • Easy-simplify-term
              • Defiteration
              • Fake-oracle-eval
              • Defopen
              • Sleep
            • 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)