• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
          • Defbyte
          • Defresult
            • Reserr
            • Reserr-option
            • Patbind-ok
            • Reserrf-push
            • Defresult-macro-definition
              • Reserrf
              • Patbind-okf
            • Fold
            • Defsubtype
            • Defset
            • Specific-types
            • Defflatsum
            • Deflist-of-len
            • Pos-list
            • Defbytelist
            • Defomap
            • Defbyte-standard-instances
            • Deffixtype-alias
            • Defbytelist-standard-instances
            • Defunit
            • Byte-list
            • Byte
            • Database
            • Pos-option
            • Nibble
            • Nat-option
            • String-option
            • Byte-list20
            • Byte-list32
            • Byte-list64
            • Pseudo-event-form
            • Natoption/natoptionlist
            • Nati
            • Character-list
            • Nat/natlist
            • Maybe-string
            • Nibble-list
            • Natoption/natoptionlist-result
            • Nat/natlist-result
            • Nat-option-list-result
            • Set
            • String-result
            • String-list-result
            • Nat-result
            • Nat-option-result
            • Nat-list-result
            • Maybe-string-result
            • Integer-result
            • Character-result
            • Character-list-result
            • Boolean-result
            • Map
            • Bag
            • Pos-set
            • Hex-digit-char-list
            • Dec-digit-char-list
            • Pseudo-event-form-list
            • Nat-option-list
            • Symbol-set
            • String-set
            • Nat-set
            • Oct-digit-char-list
            • Bin-digit-char-list
            • Bit-list
          • Isar
          • Kestrel-utilities
          • Set
          • Soft
          • C
          • Bv
          • Imp-language
          • Event-macros
          • Java
          • Bitcoin
          • Ethereum
          • Yul
          • Zcash
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Lists-light
          • Axe
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Defresult

    Defresult-macro-definition

    Definition of defresult.

    Macro: defresult

    (defmacro defresult (type &key ok
                              pred fix equiv (parents 'nil parents?)
                              short long prepwork)
     (cons
      'make-event
      (cons
       (cons
        'defresult-fn
        (cons
         (cons 'quote (cons type 'nil))
         (cons
          (cons 'quote (cons ok 'nil))
          (cons
           (cons 'quote (cons pred 'nil))
           (cons
            (cons 'quote (cons fix 'nil))
            (cons
             (cons 'quote (cons equiv 'nil))
             (cons
              (cons 'quote (cons parents 'nil))
              (cons (cons 'quote (cons parents? 'nil))
                    (cons (cons 'quote (cons short 'nil))
                          (cons (cons 'quote (cons long 'nil))
                                (cons (cons 'quote (cons prepwork 'nil))
                                      '((w state)))))))))))))
       'nil)))

    Definitions and Theorems

    Function: defresult-fn

    (defun defresult-fn (type ok pred fix equiv parents
                              parents? short long prepwork wrld)
     (declare (xargs :guard (plist-worldp wrld)))
     (let ((__function__ 'defresult-fn))
      (declare (ignorable __function__))
      (b* ((fty-table (get-fixtypes-alist wrld))
           (fty-info (find-fixtype ok fty-table))
           (ok-pred (fixtype->pred fty-info))
           (type-pred (or pred (add-suffix type "-P")))
           (type-fix (or fix (add-suffix type "-FIX")))
           (type-equiv (or equiv (add-suffix type "-EQUIV")))
           (not-reserrp-when-ok-pred
                (acl2::packn-pos (list 'not-reserrp-when- ok-pred)
                                 type))
           (ok-pred-when-type-pred-and-not-reserrp
                (acl2::packn-pos (list ok-pred '-when-
                                       type-pred '-and-not-reserrp)
                                 type)))
       (cons
        'encapsulate
        (cons
         'nil
         (append
          prepwork
          (cons
           (cons
            'defflatsum
            (cons
             type
             (append
              (and parents? (list :parents parents))
              (append
               (and short (list :short short))
               (append
                (and long (list :long long))
                (cons
                 (cons ':ok (cons ok 'nil))
                 (cons
                  '(:err reserr)
                  (cons
                   ':pred
                   (cons
                    type-pred
                    (cons ':fix
                          (cons type-fix
                                (cons ':equiv
                                      (cons type-equiv 'nil)))))))))))))
           (cons
            (cons 'defruled
                  (cons not-reserrp-when-ok-pred
                        (cons (cons 'implies
                                    (cons (cons ok-pred '(x))
                                          '((not (reserrp x)))))
                              (cons ':enable
                                    (cons (cons ok-pred '(reserrp))
                                          'nil)))))
            (cons
             (cons
              'defruled
              (cons ok-pred-when-type-pred-and-not-reserrp
                    (cons (cons 'implies
                                (cons (cons 'and
                                            (cons (cons type-pred '(x))
                                                  '((not (reserrp x)))))
                                      (cons (cons ok-pred '(x)) 'nil)))
                          (cons ':enable (cons type-pred 'nil)))))
             'nil)))))))))