• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Debugging
    • Projects
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Hons-and-memoization
      • Events
        • Defun
        • Verify-guards
        • Table
        • Memoize
        • Make-event
        • Include-book
        • Encapsulate
        • Defun-sk
        • Defttag
        • Defpkg
        • Mutual-recursion
        • Defattach
        • Defstobj
        • Defchoose
        • Progn
        • Defabsstobj
        • Verify-termination
        • Redundant-events
        • Defmacro
        • In-theory
        • Embedded-event-form
        • Defconst
        • Skip-proofs
        • Value-triple
        • Comp
        • Local
        • Defthm
          • Otf-flg
          • Defthm<w
          • Defthmr
            • Defthmd
            • Previous-subsumer-hints
            • Dft
            • Thm<w
            • Defthmd<w
          • Progn!
          • Defevaluator
          • Theory-invariant
          • Assert-event
          • Defun-inline
          • Project-dir-alist
          • Define-trusted-clause-processor
          • Partial-encapsulate
          • Defproxy
          • Defexec
          • Defun-nx
          • Defthmg
          • Defpun
          • Defabbrev
          • Defrec
          • Add-custom-keyword-hint
          • Name
          • Regenerate-tau-database
          • Deftheory
          • Deftheory-static
          • Defcong
          • Defaxiom
          • Defund
          • Evisc-table
          • Verify-guards+
          • Logical-name
          • Profile
          • Defequiv
          • Defmacro-untouchable
          • Defthmr
            • Defstub
            • Deflabel
            • Defrefinement
            • In-arithmetic-theory
            • Defabsstobj-missing-events
            • Defthmd
            • Set-body
            • Unmemoize
            • Defun-notinline
            • Dump-events
            • Defund-nx
            • Defun$
            • Remove-custom-keyword-hint
            • Dft
            • Defthy
            • Defund-notinline
            • Defnd
            • Defn
            • Defund-inline
            • Defmacro-last
          • History
          • Parallelism
          • Programming
          • Start-here
          • Real
          • Debugging
          • Miscellaneous
          • Output-controls
          • Macros
          • Interfacing-tools
        • Interfacing-tools
        • Hardware-verification
        • Software-verification
        • Testing-utilities
        • Math
      • Defthm
      • Events
      • Kestrel-utilities

      Defthmr

      Submit a theorem, as a rewrite rule only if possible.

      Defthmr stands for ``defthm rule''. It is a macro that is intended to be equivalent to defthm — in particular, it takes the same arguments as defthm — but when necessary it avoids the default of :rule-classes :rewrite. Here we also document defthmdr, which is similar to defthmr but when a rewrite rule is created, it is immediately disabled; thus defthmdr is to defthmd as defthmr is to defthm.

      Examples:
      
      (defthmr symbol-name-abc
        (equal (symbol-name 'abc) "ABC"))
      
      (defthmdr symbol-name-intern$-acl2
        (equal (symbol-name (intern$ name "ACL2")) name))
      
      General Forms:
      
      (defthmr  name term ...) ; same keyword arguments accepted as for defthm
      (defthmdr name term ...) ; same keyword arguments accepted as for defthm

      In the first example above, the use of defthm would cause an error:

      ACL2 !>(defthm symbol-name-abc
               (equal (symbol-name 'abc) "ABC"))
      
      
      ACL2 Error in ( DEFTHM SYMBOL-NAME-ABC ...):  A :REWRITE rule generated
      from SYMBOL-NAME-ABC is illegal because it rewrites the term 'T to
      itself! ....

      The problem is that the internal form for the term (equal (symbol-name 'abc) "ABC") is, perhaps surprisingly, 'T. The reason is that ACL2 evaluates calls of undefined primitives, such as symbol-name and equal, when translating to internal form.

      Defthmr and defthmdr avoid this problem by adding :rule-classes nil in such cases. The two examples above thus generate the following events. In the first example, the addition of :rule-classes nil avoids the error discussed above, by instructing ACL2 to avoid the default behavior of attempting to store the theorem as a rewrite rule. The second example has no such problem (because of the variable, name), so ACL2 treats that defthmdr simply as defthmd.

      (defthm symbol-name-abc
        (equal (symbol-name 'abc) "ABC")
        :rule-classes nil)
      
      (defthmd symbol-name-intern$-acl2
        (equal (symbol-name (intern$ name "ACL2")) name))

      Note that if a :rule-classes keyword argument is supplied, then the given call of defthmr or defthmdr simply expands directly to the corresponding call of defthm or defthmd, respectively.