• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
          • Omaps
          • Directed-untranslate
          • Include-book-paths
          • Ubi
          • Numbered-names
          • Digits-any-base
          • Context-message-pair
          • With-auto-termination
          • Make-termination-theorem
          • Theorems-about-true-list-lists
          • Checkpoint-list
          • Sublis-expr+
          • Integers-from-to
          • Prove$
          • Defthm<w
          • System-utilities-non-built-in
          • Integer-range-fix
          • Minimize-ruler-extenders
          • Add-const-to-untranslate-preprocess
          • Unsigned-byte-fix
          • Signed-byte-fix
          • Defthmr
            • Paired-names
            • Unsigned-byte-list-fix
            • Signed-byte-list-fix
            • Show-books
            • Skip-in-book
            • Typed-tuplep
            • List-utilities
            • Checkpoint-list-pretty
            • Defunt
            • Keyword-value-list-to-alist
            • Magic-macroexpand
            • Top-command-number-fn
            • Bits-as-digits-in-base-2
            • Show-checkpoint-list
            • Ubyte11s-as-digits-in-base-2048
            • Named-formulas
            • Bytes-as-digits-in-base-256
            • String-utilities
            • Make-keyword-value-list-from-keys-and-value
            • Defmacroq
            • Integer-range-listp
            • Apply-fn-if-known
            • Trans-eval-error-triple
            • Checkpoint-info-list
            • Previous-subsumer-hints
            • Fms!-lst
            • Zp-listp
            • Trans-eval-state
            • Injections
            • Doublets-to-alist
            • Theorems-about-osets
            • Typed-list-utilities
            • Book-runes-alist
            • User-interface
            • Bits/ubyte11s-digit-grouping
            • Bits/bytes-digit-grouping
            • Message-utilities
            • Subsetp-eq-linear
            • Oset-utilities
            • Strict-merge-sort-<
            • Miscellaneous-enumerations
            • Maybe-unquote
            • Thm<w
            • Defthmd<w
            • Io-utilities
          • Set
          • Soft
          • C
          • Bv
          • Imp-language
          • Event-macros
          • Java
          • Bitcoin
          • Ethereum
          • Yul
          • Zcash
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Lists-light
          • Axe
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • 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.