• 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
        • State
        • Memoize
        • Mbe
        • Io
        • Defpkg
        • Apply$
          • Lambda
          • Warrant
          • Defwarrant
            • Fn-equal
          • Badge
          • Lambda$
          • Tame
          • Defbadge
          • Print-cl-cache
          • Introduction-to-apply$
          • Well-formed-lambda-objectp
          • Rewriting-calls-of-apply$-ev$-and-loop$-scions
          • Mixed-mode-functions
          • Explain-giant-lambda-object
          • Gratuitous-lambda-object-restrictions
          • Scion
          • Ilk
          • Ev$
          • Translam
          • Fn-equal
          • Apply$-guard
          • L<
          • Apply$-lambda-guard
          • Apply$-userfn
          • Badge-userfn
          • Defun$
          • Apply$-lambda
        • Mutual-recursion
        • Loop$
        • Programming-with-state
        • Arrays
        • Characters
        • Time$
        • Loop$-primer
        • Fast-alists
        • Defmacro
        • Defconst
        • Evaluation
        • Guard
        • Equality-variants
        • Compilation
        • Hons
        • ACL2-built-ins
          • Let
          • Declare
          • Mbe
          • Apply$
            • Lambda
            • Warrant
            • Defwarrant
              • Fn-equal
            • Badge
            • Lambda$
            • Tame
            • Defbadge
            • Print-cl-cache
            • Introduction-to-apply$
            • Well-formed-lambda-objectp
            • Rewriting-calls-of-apply$-ev$-and-loop$-scions
            • Mixed-mode-functions
            • Explain-giant-lambda-object
            • Gratuitous-lambda-object-restrictions
            • Scion
            • Ilk
            • Ev$
            • Translam
            • Fn-equal
            • Apply$-guard
            • L<
            • Apply$-lambda-guard
            • Apply$-userfn
            • Badge-userfn
            • Defun$
            • Apply$-lambda
          • Fmt
          • Loop$
          • Return-last
          • Mv-let
          • Pseudo-termp
          • Defwarrant
            • Fn-equal
          • Time$
          • Ec-call
          • Sys-call
          • Msg
          • Mbt
          • Mv-nth
          • Value-triple
          • Comp
          • O-p
          • Member
          • O<
          • Cw
          • Er
          • Or
          • Hons
          • Flet
          • Mv
          • Append
          • Defbadge
          • Cbd
          • *ACL2-exports*
          • Eql
          • Natp
          • Comment
          • Unsigned-byte-p
          • Posp
          • Nth
          • And
          • List
          • Len
          • Time-tracker
          • Term-order
          • True-listp
          • Msgp
          • Booleanp
          • If
          • Pseudo-term-listp
          • +
          • Not
          • Bitp
          • Equal
          • Cdr
          • Car
          • With-global-stobj
          • Symbol-listp
          • String-listp
          • Nat-listp
          • Implies
          • Iff
          • Character-listp
          • Alistp
          • The
          • Cons
          • Quote
          • Integerp
          • Consp
          • True-list-listp
          • Compress1
          • Symbolp
          • Stringp
          • *common-lisp-symbols-from-main-lisp-package*
          • Prog2$
          • <
          • *
          • Macrolet
          • Characterp
          • Last-prover-steps
          • Hons-acons
          • Eq
          • With-guard-checking
          • Let*
          • With-local-stobj
          • Length
          • Hard-error
          • Search
          • @
          • Zp
          • State-global-let*
          • Aset1
          • Intersection$
          • -
          • Assign
          • Union$
          • Set-gc-strategy
          • In-tau-intervalp
          • Pand
          • Cons-with-hint
          • Case-match
          • Symbol-name
          • Fast-alist-fork
          • Sys-call+
          • Signed-byte-p
          • Remove-duplicates
          • With-serialize-character
          • Hons-resize
          • Observation
          • Make-tau-interval
          • ACL2-count
          • Logbitp
          • Position
          • Termp
          • *standard-co*
          • Hons-acons!
          • Aref1
          • Assoc
          • Read-run-time
          • Hons-wash
          • Break-on-error
          • Expt
          • Take
          • Symbol-package-name
          • Coerce
          • Intern
          • Atom
          • Standard-oi
          • Non-exec
          • Update-nth
          • Get-internal-time
          • Formula
          • Keywordp
          • Without-evisc
          • Standard-co
          • Good-bye
          • Case
          • With-local-state
          • Spec-mv-let
          • Intern-in-package-of-symbol
          • Hons-clear
          • Binary-+
          • Ash
          • With-fast-alist
          • Set-difference$
          • Flush-compress
          • Rationalp
          • Symbol-alistp
          • Por
          • Rassoc
          • Remove-assoc
          • Logand
          • Pargs
          • Hons-copy
          • Alphorder
          • =
          • <=
          • Subsetp
          • Remove1-assoc
          • No-duplicatesp
          • Mv-list
          • Aset2
          • Floor
          • Concatenate
          • Serialize-read
          • Random$
          • Fmt-to-comment-window
          • F-put-global
          • Compress2
          • Canonical-pathname
          • Primitive
          • Nfix
          • Fast-alist-clean
          • Remove
          • Nthcdr
          • Remove1
          • Intersectp
          • Assert$
          • Endp
          • Put-assoc
          • Standard-char-p
          • True-list-fix
          • Keyword-value-listp
          • Illegal
          • Digit-char-p
          • Cond
          • With-output-lock
          • Princ$
          • Open-output-channel!
          • Fast-alist-free
          • Er-progn
          • Cw-print-base-radix
          • Truncate
          • Reverse
          • Complex
          • Add-to-set
          • Swap-stobjs
          • Set-print-case
          • Set-print-base
          • Code-char
          • Setenv$
          • Print-object$
          • Plet
          • Hons-get
          • Fmx-cw
          • Error1
          • Integer-length
          • Zip
          • With-live-state
          • Logior
          • With-guard-checking-event
          • Term-listp
          • Print-object$+
          • Hons-assoc-equal
          • String
          • Char-code
          • Unary--
          • Set-print-radix
          • Resize-list
          • Pkg-witness
          • Integer-listp
          • Boole$
          • /
          • Revappend
          • Mod
          • In-package
          • Term-list-listp
          • Read-ACL2-oracle
          • Make-fast-alist
          • Header
          • Extend-pathname
          • Subseq
          • Null
          • With-guard-checking-error-triple
          • Make-list
          • Logxor
          • Strip-cars
          • Make-ord
          • Fast-alist-free-on-exit
          • Aref2
          • Lognot
          • Must-be-equal
          • Integer-range-p
          • Getenv$
          • F-get-global
          • Ifix
          • Er-hard
          • Eqlablep
          • Cpu-core-count
          • ACL2-numberp
          • Ceiling
          • Butlast
          • Pairlis$
          • Mod-expt
          • Hons-equal
          • Gc$
          • Substitute
          • Round
          • With-stolen-alist
          • Mv?-let
          • Count
          • Char-downcase
          • Char
          • Sys-call-status
          • Set-fmt-hard-right-margin
          • Pprogn
          • Lexorder
          • Hons-summary
          • Boolean-listp
          • Assert*
          • List*
          • Char-upcase
          • Strip-cdrs
          • Serialize-write
          • Proofs-co
          • Progn$
          • Keyword-listp
          • Sublis
          • String-downcase
          • Logeqv
          • Maximum-length
          • Explode-nonnegative-integer
          • Eqlable-listp
          • Dimensions
          • Default
          • Arity
          • String-upcase
          • Max
          • Last
          • Evenp
          • Nonnegative-integer-quotient
          • Change
          • Binary-append
          • Zerop
          • String<
          • Abs
          • Set-print-base-radix
          • Intern$
          • Getprop
          • Explode-atom
          • Binary-*
          • Aset1-trusted
          • String-equal
          • Symbol<
          • String-append
          • Print-base-p
          • Mv?
          • Logic-fns-list-listp
          • Fix
          • Fast-alist-fork!
          • Er-hard?
          • Allocate-fixnum-range
          • Rem
          • Alpha-char-p
          • 1+
          • *standard-oi*
          • Sys-call*
          • Pos-listp
          • Mbt*
          • Hons-wash!
          • Hons-clear!
          • Break$
          • Upper-case-p
          • String>=
          • String<=
          • Signum
          • Lower-case-p
          • Char-equal
          • Real/rationalp
          • Rational-listp
          • O-first-coeff
          • Logic-fnsp
          • Logic-fns-listp
          • Hons-copy-persistent
          • Gc-strategy
          • Fast-alist-summary
          • Acons
          • Rfix
          • O-first-expt
          • Getpropc
          • Fast-alist-clean!
          • Digit-to-char
          • >=
          • >
          • Subst
          • Logcount
          • Evens
          • Comp-gcl
          • Atom-listp
          • Arities-okp
          • ACL2-number-listp
          • /=
          • Cadr
          • *standard-ci*
          • Unary-/
          • The-true-list
          • O-rst
          • Fast-alist-len
          • Er-soft
          • Complex/complex-rationalp
          • Array2p
          • Array1p
          • Logtest
          • Logandc1
          • Char<
          • Putprop
          • Good-atom-listp
          • Get-real-time
          • Eqlable-alistp
          • Count-keys
          • Assoc-string-equal
          • Logorc1
          • Logandc2
          • 1-
          • Standard-string-alistp
          • Packn
          • Logic-termp
          • Logic-term-list-listp
          • Get-cpu-time
          • Fmt!
          • Fms
          • Cw!
          • Assoc-keyword
          • String>
          • Numerator
          • Logorc2
          • Listp
          • Denominator
          • Char>=
          • The-number
          • Realfix
          • Odds
          • Makunbound-global
          • Make-character-list
          • Make
          • Fmt-to-comment-window!
          • Fms!
          • F-boundp-global
          • Complex-rationalp
          • Alist-to-doublets
          • Access
          • Min
          • Lognor
          • Identity
          • Char>
          • Char<=
          • Zpf
          • Update-nth-array
          • 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
          • Packn-pos
          • Maybe-flush-and-compress1
          • Kwote
          • Int=
          • Fmt1
          • Fmt-to-comment-window+
          • Cw-print-base-radix!
          • Alist-keys-subsetp
          • Realpart
          • Plusp
          • First
          • Symbol-name-lst
          • R-symbol-alistp
          • R-eqlable-alistp
          • Cw!+
          • Cons-subtrees
          • Cons-count-bounded
          • Cddr
          • Caar
          • Standard-char-p+
          • Proper-consp
          • Kwote-lst
          • Improper-consp
          • Fmx
          • Cw+
          • Mbe1
          • Caddr
          • Pairlis-x2
          • Pairlis-x1
          • O>=
          • O<=
          • O-infp
          • Merge-sort-lexorder
          • Fix-true-list
          • Rest
          • 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
        • 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
  • Apply$
  • ACL2-built-ins

Defwarrant

Issue a warrant for a function so apply$ can use it in proofs

It is best to be somewhat familiar with the documentation of apply$ before reading this topic.

Before using defwarrant or a utility like defun$ that relies on it:

(include-book "projects/apply/top" :dir :system)

Several lemmas in that book are necessary for defwarrant to prove the theorems it must prove.

Badges versus Warrants

It is easy to confuse badges, which are issued by defbadge, with warrants, which are issued by defwarrant. See the first section of defbadge for an extended discussion.

Requirements of Defwarrant

General Form:
(defwarrant fn)

where fn is a defined function name. This command analyzes the body of fn to determine whether it satisfies certain stringent syntactic and semantic conditions that allow the ACL2 proof theory to be extended so that the prover can simplify forms like (apply$ 'fn ...). The syntactic conditions include those of defbadge, which defwarrant essentially invokes if fn is a :logic mode function that is not already badged. But below we describe all the conditions checked by defwarrant since many users use defwarrant to issue both a badge and a warrant.

Basic conditions include that fn is in :logic-mode and that its justification (i.e., the measure, well-founded relation, and domain predicate used to admit fn) be expressible without any reference to apply$, ev$, or apply$-userfn.

Defwarrant imposes some additional conditions on fn, but exactly what those conditions are depends on a certain ``reachability'' test detailed in the section titled The ``Reachability'' Test in defbadge. Roughly speaking the test is whether apply$ is ancestral in fn, meaning apply$ is somehow involved in the definition of fn or the functions it calls.

If the reachability test succeeds — colloquially, if fn depends on apply$ — then defwarrant imposes the following additional conditions in order to issue a warrant.

(a) If fn is recursive it must not be part of a mutually recursive clique and its measure must be of type natp or be a lexicographic combination of natural numbers as defined by the llist function in the Community Books at books/ordinals/.

(b) Every function called in the body of fn, except fn itself, must already have a badge and a warrant. If some subfunction doesn't already have a badge, defwarrant will call defbadge and signal an error if that fails. If some subfunction doesn't already have a warrant, defwarrant will signal an error and suggest that you call defwarrant on the offending subfunction first. Defwarrant will continue to fail until all subfunctions have badges and warrants.

(c) It must be possible for each formal of fn to be assigned one of three ilks, :FN, :EXPR, or NIL, as described below. The basic idea is that a formal can be assigned ilk :FN (or ilk :EXPR) iff it is sometimes passed into a :FN (or :EXPR) slot in the body of fn and is never passed into any other kind of slot. A formal can be be assigned ilk NIL iff it is never passed into a slot of ilk :FN or :EXPR, i.e., if it is used as an ``ordinary'' object. We are more precise below.

(d) Every :FN and :EXPR slot of every function called in the body of fn is occupied either by a formal of fn of the same ilk or, in the case of calls of functions other than fn, a quoted tame function symbol or quoted tame (preferably well-formed) LAMBDA object.

This completes the list of additional restrictions imposed by defwarrant on fn, when apply$ is reachable from fn.

If the reachability test fails — colloquially, if fn does not depend on apply$ — then defwarrant just checks that fn does not call any of a few functions that apply$ is prohibited from running. Among those blacklisted functions are sys-call and other functions requiring a trust tag. For a list of the blacklisted functions see the value of *blacklisted-apply$-fns*.

Note that the restrictions imposed on functions from which apply$ cannot be reached are comparatively generous. If fn does not depend on apply$ then fn can be warranted despite (a) being defined mutually recursively or with an arbitrary ordinal measure, or (b) calling unbadged or unbadgeable functions. Defwarrant can be relaxed in this case because the warrant constrains (apply$ 'fn ...) to be (fn ...) and fn is a well-defined :logic mode function that is independent of apply$. Thus, in the model of apply$ that justifies the whole apply$ story, the handling of fn is just a base case. The situation would be more restrictive if the warrant constrained (apply$ 'fn ...) to evaluate the body of fn with ev$ which would possibly raise termination issues.

Regardless of whether apply$ is reachable, if the requisite conditions are not met, defwarrant causes an error.

If the requisite conditions are met, defwarrant obtains or constructs the badge for fn, setting the arity and out arity appropriately and setting the ilks field to the list of computed ilks (or to T if every formal has ilk NIL). The generated badge is stored for the future use of defwarrant. See defbadge for a brief discussion of how ilks are computed.

Furthermore, defwarrant generates the warrant for fn. The name of that 0-ary function will be APPLY$-WARRANT-fn. Calls of apply$ on 'fn in proof attempts can only be simplified if the warrant hypothesis, (APPLY$-WARRANT-fn), aka ``the warrant,'' is among the hypotheses of the conjecture being proved. The warrant specifies the values of both (badge 'fn) and (apply$ 'fn ...), including the tameness requirements imposed on apply$. (The warrant explicitly specifies the values of badge-userfn and apply$-userfn and then defwarrant proves rewrite rules to make calls of badge and apply$ simplify accordingly.)

If a warrant is issued for fn, then defwarrant also extends ACL2's evaluation theory (but not its proof theory) so that the warrant hypothesis is assumed true in that theory, allowing calls of badge and apply$ to be evaluated in the evaluation theory (but not in the proof theory). See warrant for details.

You might worry that theorems burdened by warrants are vacuously valid because it might be impossible to satisfy all the warrant hypotheses. You needn't worry about this. There is a model of apply$ and all of its scions that makes every warrant issued by defwarrant valid. The proof of this is sketched in ``Limited Second-Order Functionality in a First-Order Setting'' by Matt Kaufmann and J Strother Moore and fully fleshed out in the comment titled Essay on Admitting a Model for Apply$ and the Functions that Use It in the ACL2 source file apply-raw.lisp.

Defwarrant also proves that fn-equal is a congruence relation for each :FN position of fn.

Subtopics

Fn-equal
Equivalence relation on tame functions