• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • C
        • Soft
        • Bv
        • Imp-language
        • Ethereum
        • Event-macros
          • Evmac-input-hints-p
          • Evmac-input-print-p
          • Event-macro-input-processing
          • Function-definedness
          • Event-macro-screen-printing
          • Make-event-terse
          • Event-macro-applicability-conditions
          • Event-macro-results
          • Template-generators
          • Event-macro-event-generators
            • Evmac-generate-defun
              • Evmac-generate-soft-defun-sk2
              • Evmac-generate-soft-defun2
              • Evmac-generate-defthm
              • Evmac-generate-soft-defunvar
            • Event-macro-proof-preparation
            • Try-event
            • Restore-output?
            • Restore-output
            • Fail-event
            • Cw-event
            • Event-macro-xdoc-constructors
            • Event-macro-intro-macros
          • Java
          • Riscv
          • Bitcoin
          • Zcash
          • Yul
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Axe
          • Lists-light
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Event-macro-event-generators

    Evmac-generate-defun

    Generate a defun or defund function definition with the specified attributes.

    Signature
    (evmac-generate-defun name &key (formals ':absent) 
                          (guard 't) 
                          (body ':absent) 
                          (verify-guards ':absent) 
                          (enable ':absent) 
                          (guard-hints 'nil) 
                          (guard-simplify 't) 
                          (measure 'nil) 
                          (well-founded-relation 'nil) 
                          (hints 'nil)) 
     
      → 
    (mv local-event exported-event)
    Arguments
    name — Guard (symbolp name).
    formals — Guard (symbol-listp formals).
    guard — A term.
    body — A term.
    verify-guards — Guard (booleanp verify-guards).
    enable — Guard (booleanp enable).
    guard-hints — Guard (true-listp guard-hints).
    guard-simplify — Guard (member-eq guard-simplify '(t :limited)).
    measure — A term.
    well-founded-relation — Guard (symbolp well-founded-relation).
    hints — Guard (true-listp hints).
    Returns
    local-event — Type (pseudo-event-formp local-event).
    exported-event — Type (pseudo-event-formp exported-event).

    Definitions and Theorems

    Function: evmac-generate-defun-fn

    (defun evmac-generate-defun-fn
           (name formals guard body verify-guards
                 enable guard-hints guard-simplify
                 measure well-founded-relation hints)
     (declare
          (xargs :guard (and (symbolp name)
                             (symbol-listp formals)
                             (booleanp verify-guards)
                             (booleanp enable)
                             (true-listp guard-hints)
                             (member-eq guard-simplify '(t :limited))
                             (symbolp well-founded-relation)
                             (true-listp hints))))
     (let ((__function__ 'evmac-generate-defun))
      (declare (ignorable __function__))
      (b*
       (((when (eq formals :absent))
         (raise "Internal error: :FORMALS must be always supplied.")
         (mv '(irrelevant) '(irrelevant)))
        ((when (eq body :absent))
         (raise "Internal error: :BODY must be always supplied.")
         (mv '(irrelevant) '(irrelevant)))
        ((when (eq verify-guards :absent))
         (raise
              "Internal error: :VERIFY-GUARDS must be always supplied.")
         (mv '(irrelevant) '(irrelevant)))
        ((when (eq enable :absent))
         (raise "Internal error: :ENABLE must be always supplied.")
         (mv '(irrelevant) '(irrelevant)))
        (macro (if enable 'defun 'defund))
        (measure (and measure (list :measure measure)))
        (well-founded-relation
             (and well-founded-relation
                  (list :well-founded-relation well-founded-relation)))
        (hints (and measure hints (list :hints hints)))
        (guard (list :guard guard))
        (guard-hints (and guard-hints verify-guards
                          (list :guard-hints guard-hints)))
        (guard-simplify (and (not (eq guard-simplify t))
                             (list :guard-simplify guard-simplify)))
        (verify-guards (list :verify-guards verify-guards))
        (local-event
         (cons
          'local
          (cons
           (cons
            macro
            (cons
             name
             (cons
              formals
              (cons
               (cons
                'declare
                (cons
                 (cons
                  'xargs
                  (append
                   measure
                   (append
                    well-founded-relation
                    (append
                     hints
                     (append
                       guard
                       (append verify-guards
                               (append guard-hints guard-simplify)))))))
                 'nil))
               (cons body 'nil)))))
           'nil)))
        (exported-event
         (cons
          macro
          (cons
           name
           (cons
            formals
            (cons
             (cons
              'declare
              (cons
                   (cons 'xargs
                         (append measure
                                 (append well-founded-relation
                                         (append guard verify-guards))))
                   'nil))
             (cons body 'nil)))))))
       (mv local-event exported-event))))

    Theorem: pseudo-event-formp-of-evmac-generate-defun.local-event

    (defthm pseudo-event-formp-of-evmac-generate-defun.local-event
      (b*
       (((mv ?local-event ?exported-event)
         (evmac-generate-defun-fn name formals guard body verify-guards
                                  enable guard-hints guard-simplify
                                  measure well-founded-relation hints)))
       (pseudo-event-formp local-event))
      :rule-classes :rewrite)

    Theorem: pseudo-event-formp-of-evmac-generate-defun.exported-event

    (defthm pseudo-event-formp-of-evmac-generate-defun.exported-event
      (b*
       (((mv ?local-event ?exported-event)
         (evmac-generate-defun-fn name formals guard body verify-guards
                                  enable guard-hints guard-simplify
                                  measure well-founded-relation hints)))
       (pseudo-event-formp exported-event))
      :rule-classes :rewrite)