• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • Macro-libraries
      • B*
      • Defunc
      • Fty
      • Apt
      • Std/util
      • Defdata
      • Defrstobj
      • Seq
      • Match-tree
      • Defrstobj
      • With-supporters
      • Def-partial-measure
      • Template-subst
      • Soft
        • Soft-future-work
        • Soft-macros
          • Defun-inst
            • Defun-inst-implementation
              • Defun-inst-quant-events
              • Defun-inst-plain-events
              • Defun-inst-fn
              • Defun-inst-choice-events
                • Check-qrewrite-rule-funvars
                • Check-sofun-inst
                • Show-defun-inst
                • Defun-inst-macro-definition
            • Defequal
            • Defsoft
            • Defthm-inst
            • Defun2
            • Defunvar
            • Defun-sk2
            • Defchoose2
            • Defthm-2nd-order
            • Define-sk2
            • Defund-sk2
            • Define2
            • Defund2
          • Updates-to-workshop-material
          • Soft-implementation
          • Soft-notions
        • Defthm-domain
        • Event-macros
        • Def-universal-equiv
        • Def-saved-obligs
        • With-supporters-after
        • Definec
        • Sig
        • Outer-local
        • Data-structures
      • ACL2
        • Theories
        • Rule-classes
        • Proof-builder
        • Recursion-and-induction
        • Hons-and-memoization
        • Events
        • Parallelism
        • History
        • Programming
        • Operational-semantics
        • Real
        • Start-here
        • Miscellaneous
        • Output-controls
        • Bdd
        • Macros
          • Make-event
          • Defmacro
          • Untranslate-patterns
          • Tc
          • Trans*
          • Macro-aliases-table
          • Macro-args
          • Defabbrev
          • Trans
          • User-defined-functions-table
          • Untranslate-for-execution
          • Macro-libraries
            • B*
            • Defunc
            • Fty
            • Apt
            • Std/util
            • Defdata
            • Defrstobj
            • Seq
            • Match-tree
            • Defrstobj
            • With-supporters
            • Def-partial-measure
            • Template-subst
            • Soft
              • Soft-future-work
              • Soft-macros
                • Defun-inst
                  • Defun-inst-implementation
                    • Defun-inst-quant-events
                    • Defun-inst-plain-events
                    • Defun-inst-fn
                    • Defun-inst-choice-events
                      • Check-qrewrite-rule-funvars
                      • Check-sofun-inst
                      • Show-defun-inst
                      • Defun-inst-macro-definition
                  • Defequal
                  • Defsoft
                  • Defthm-inst
                  • Defun2
                  • Defunvar
                  • Defun-sk2
                  • Defchoose2
                  • Defthm-2nd-order
                  • Define-sk2
                  • Defund-sk2
                  • Define2
                  • Defund2
                • Updates-to-workshop-material
                • Soft-implementation
                • Soft-notions
              • Defthm-domain
              • Event-macros
              • Def-universal-equiv
              • Def-saved-obligs
              • With-supporters-after
              • Definec
              • Sig
              • Outer-local
              • Data-structures
            • Add-macro-fn
            • Check-vars-not-free
            • Safe-mode
            • Trans1
            • Defmacro-untouchable
            • Set-duplicate-keys-action
            • Add-macro-alias
            • Magic-macroexpand
            • Defmacroq
            • Trans!
            • Remove-macro-fn
            • Remove-macro-alias
            • Add-binop
            • Untrans-table
            • Trans*-
            • Remove-binop
            • Tcp
            • Tca
          • Installation
          • Mailing-lists
        • Interfacing-tools
        • Hardware-verification
        • Software-verification
        • Math
        • Testing-utilities
      • Defun-inst-implementation

      Defun-inst-choice-events

      Generate a list of events to submit, when instantiating a choice second-order function.

      Signature
      (defun-inst-choice-events fun sofun inst options ctx state) 
        → 
      (mv erp events+result+funvars state)
      Arguments
      fun — Guard (symbolp fun).
      sofun — Guard (choice-sofunp sofun (w state)).
      options — Guard (keyword-value-listp options).
      ctx — Context for errors.
      Returns
      erp — booleanp flag of the error triple.
      events+result+funvars — A tuple (events result funvars) where events is a pseudo-event-form-listp, result is a maybe-pseudo-event-formp, and funvars is a funvar-listp.

      Also return the defchoose2 or defchoose event form. This is printed when :print is :result.

      Also return the function variables that the new function depends on.

      Only the :print option may be present.

      We add fun to the table of second-order functions iff it is second-order.

      Definitions and Theorems

      Function: defun-inst-choice-events

      (defun defun-inst-choice-events (fun sofun inst options ctx state)
       (declare (xargs :stobjs (state)))
       (declare (xargs :guard (and (symbolp fun)
                                   (keyword-value-listp options)
                                   (choice-sofunp sofun (w state)))))
       (let ((__function__ 'defun-inst-choice-events))
        (declare (ignorable __function__))
        (b*
         ((wrld (w state))
          ((unless (subsetp (evens options) '(:print)))
           (er-soft+
            ctx t nil
            "Only the input keyword :PRINT is allowed, ~
                         because ~x0 is a choice second-order function."
            sofun))
          (bound-vars (defchoose-bound-vars sofun wrld))
          (sofun-body (defchoose-body sofun wrld))
          (fun-body (fun-subst-term inst sofun-body wrld))
          (funvars (funvars-of-term fun-body wrld))
          (fun-body (untranslate fun-body nil wrld))
          (formals (formals sofun wrld))
          (strengthen (defchoose-strengthen sofun wrld))
          (funvars (remove-duplicates funvars))
          (defchoose-event
           (cons
               'defchoose
               (cons fun
                     (cons bound-vars
                           (cons formals
                                 (cons fun-body
                                       (cons ':strengthen
                                             (cons strengthen 'nil))))))))
          (result
           (cons
               (if funvars 'defchoose2 'defchoose)
               (cons fun
                     (cons bound-vars
                           (cons formals
                                 (cons fun-body
                                       (cons ':strengthen
                                             (cons strengthen 'nil))))))))
          (table-event?
           (if funvars
            (cons
                 (cons 'table
                       (cons 'second-order-functions
                             (cons (cons 'quote (cons fun 'nil))
                                   (cons (cons 'quote (cons funvars 'nil))
                                         'nil))))
                 'nil)
            nil)))
         (value (list (cons defchoose-event table-event?)
                      result funvars)))))