• 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
          • Defequal
          • Defsoft
            • Defsoft-implementation
              • Defsoft-fn
              • Ensure-defun-sk-rule-same-funvars
                • Ensure-wfrel-o<
                • Defsoft-macro-definition
            • 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
                • Defequal
                • Defsoft
                  • Defsoft-implementation
                    • Defsoft-fn
                    • Ensure-defun-sk-rule-same-funvars
                      • Ensure-wfrel-o<
                      • Defsoft-macro-definition
                  • 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
      • Defsoft-implementation

      Ensure-defun-sk-rule-same-funvars

      Ensure that a function, if introduced by defun-sk, has an associated rewrite rule (the one generated by defun-sk that depends on exactly the same function variables that the function's matrix depends on.

      Signature
      (ensure-defun-sk-rule-same-funvars fn ctx state) 
        → 
      (mv erp nothing state)
      Arguments
      fn — Guard (symbolp fn).
      Returns
      nothing — Always nil.

      We collect the function variables that the defun-sk matrix depends on and the ones that the defun-sk rewrite rule depends on; we ensure that they are the same function variables. It seems unlikely that this check will ever fail in practice, but defun-sk allows custom rules (for universal quantifiers) that might somehow change the dependencies on function variables; for now we do not support this situation, but we might recosider this if some compelling example comes up. Unless the rewrite rule is a custom one, this check is always expected to pass.

      Definitions and Theorems

      Function: ensure-defun-sk-rule-same-funvars

      (defun ensure-defun-sk-rule-same-funvars (fn ctx state)
       (declare (xargs :stobjs (state)))
       (declare (xargs :guard (symbolp fn)))
       (let ((__function__ 'ensure-defun-sk-rule-same-funvars))
        (declare (ignorable __function__))
        (b*
         ((wrld (w state))
          ((unless (defun-sk-p fn wrld))
           (value nil))
          (rule-name (defun-sk-rewrite-name fn wrld))
          (rule-body (formula rule-name nil wrld))
          (fn-matrix (defun-sk-matrix fn wrld))
          (rule-funvars (funvars-of-term rule-body wrld))
          (matrix-funvars (funvars-of-term fn-matrix wrld))
          ((when (set-equiv rule-funvars matrix-funvars))
           (value nil))
          ((unless (eq (defun-sk-rewrite-kind fn wrld)
                       :custom))
           (value
            (raise
             "Internal error: ~
                             the DEFUN-SK function ~x0 has a matrix ~x1
                             that depends on the function variables ~&2 ~
                             but a non-custom rewrite rule ~x3
                             that depends on the function variables ~&4.
                             This was not expected to happen."
             fn fn-matrix matrix-funvars
             rule-body rule-funvars))))
         (er-soft+
          ctx t nil
          "The DEFUN-SK function ~x0 has a matrix ~x1
                     that depends on the function variables ~&2 ~
                     but a custom rewrite rule ~x3
                     that depends on the function variables ~&4."
          fn fn-matrix matrix-funvars
          rule-body rule-funvars))))