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