• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • C
          • Syntax-for-tools
          • Atc
          • Transformation-tools
            • Simpadd0
            • Proof-generation
              • Xeq-fundef
              • Xeq-expr-cond
              • Xeq-expr-binary
              • Xeq-block-item-list-cons
              • Xeq-stmt-ifelse
              • Xeq-expr-const
              • Gen-param-thms
              • Gen-from-params
              • Xeq-decl-decl
              • Gout
              • Gen-block-item-list-thm
              • Xeq-stmt-while
              • Xeq-stmt-dowhile
              • Gin
              • Xeq-expr-ident
              • Gen-block-item-thm
              • Xeq-stmt-if
              • Xeq-expr-cast
              • Gen-initer-single-thm
              • Gen-init-scope-thm
              • Gen-expr-thm
                • Xeq-expr-unary
                • Gen-decl-thm
                • Gen-stmt-thm
                • Xeq-stmt-return
                • Xeq-stmt-expr
                • Xeq-block-item-decl
                • Xeq-block-item-stmt
                • Xeq-stmt-compound
                • Xeq-initer-single
                • Gen-thm-name
                • Gin-update
                • Gen-var-assertions
                • Tyspecseq-to-type
                • Xeq-block-item-list-empty
                • Gout-no-thm
                • Irr-gout
              • Split-gso
              • Wrap-fn
              • Constant-propagation
              • Specialize
              • Split-fn
              • Split-fn-when
              • Split-all-gso
              • Copy-fn
              • Variables-in-computation-states
              • Rename
              • Utilities
              • Proof-generation-theorems
              • Input-processing
            • Language
            • Representation
            • Insertion-sort
            • Pack
          • Soft
          • Bv
          • Imp-language
          • Ethereum
          • Event-macros
          • Java
          • Riscv
          • Bitcoin
          • Zcash
          • Yul
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Axe
          • Lists-light
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Proof-generation

    Gen-expr-thm

    Generate a theorem for the transformation of an expression.

    Signature
    (gen-expr-thm old new vartys const-new thm-index hints) 
      → 
    (mv thm-event thm-name updated-thm-index)
    Arguments
    old — Guard (exprp old).
    new — Guard (exprp new).
    vartys — Guard (c::ident-type-mapp vartys).
    const-new — Guard (symbolp const-new).
    thm-index — Guard (posp thm-index).
    hints — Guard (true-listp hints).
    Returns
    thm-event — Type (pseudo-event-formp thm-event).
    thm-name — Type (symbolp thm-name).
    updated-thm-index — Type (posp updated-thm-index).

    Definitions and Theorems

    Function: gen-expr-thm

    (defun gen-expr-thm (old new vartys const-new thm-index hints)
     (declare (xargs :guard (and (exprp old)
                                 (exprp new)
                                 (c::ident-type-mapp vartys)
                                 (symbolp const-new)
                                 (posp thm-index)
                                 (true-listp hints))))
     (declare (xargs :guard (and (expr-unambp old)
                                 (expr-annop old)
                                 (expr-unambp new)
                                 (expr-annop new))))
     (let ((__function__ 'gen-expr-thm))
      (declare (ignorable __function__))
      (b*
       ((old (expr-fix old))
        (new (expr-fix new))
        ((unless (expr-formalp old))
         (raise "Internal error: ~x0 is not in the formalized subset."
                old)
         (mv '(_) nil 1))
        ((unless (expr-formalp new))
         (raise "Internal error: ~x0 is not in the formalized subset."
                new)
         (mv '(_) nil 1))
        (type (expr-type old))
        ((unless (equal (expr-type new) type))
         (raise
          "Internal error: ~
                    the type ~x0 of the new expression ~x1 differs from ~
                    the type ~x2 of the old expression ~x3."
          (expr-type new)
          new type old)
         (mv '(_) nil 1))
        ((unless (type-formalp type))
         (raise "Internal error: expression ~x0 has type ~x1."
                old type)
         (mv '(_) nil 1))
        ((mv & old-expr) (ldm-expr old))
        ((mv & new-expr) (ldm-expr new))
        ((mv & ctype) (ldm-type type))
        (vars-pre (gen-var-assertions vartys 'compst))
        (vars-post (gen-var-assertions vartys 'old-compst))
        (formula
         (cons
          'b*
          (cons
           (cons (cons 'old-expr
                       (cons (cons 'quote (cons old-expr 'nil))
                             'nil))
                 (cons (cons 'new-expr
                             (cons (cons 'quote (cons new-expr 'nil))
                                   'nil))
                       '(((mv old-eval old-compst)
                          (c::exec-expr old-expr compst old-fenv limit))
                         ((mv new-eval new-compst)
                          (c::exec-expr new-expr compst new-fenv limit))
                         (old-val (c::expr-value->value old-eval))
                         (new-val (c::expr-value->value new-eval)))))
           (cons
            (cons
             'implies
             (cons
              (cons 'and
                    (append vars-pre '((not (c::errorp old-eval)))))
              (cons
               (cons
                'and
                (cons
                 '(not (c::errorp new-eval))
                 (cons
                  '(iff old-eval new-eval)
                  (cons
                   '(equal old-val new-val)
                   (cons
                    '(equal old-compst new-compst)
                    (append
                     (if (c::type-case ctype :void)
                         '((not old-eval))
                      (cons
                       'old-eval
                       (cons
                        (cons
                             'equal
                             (cons '(c::type-of-value old-val)
                                   (cons (cons 'quote (cons ctype 'nil))
                                         'nil)))
                        'nil)))
                     vars-post))))))
               'nil)))
            'nil))))
        ((mv thm-name thm-index)
         (gen-thm-name const-new thm-index))
        (thm-event
         (cons
          'defrule
          (cons
               thm-name
               (cons formula
                     (cons ':rule-classes
                           (cons 'nil
                                 (cons ':hints (cons hints 'nil)))))))))
       (mv thm-event thm-name thm-index))))

    Theorem: pseudo-event-formp-of-gen-expr-thm.thm-event

    (defthm pseudo-event-formp-of-gen-expr-thm.thm-event
      (b* (((mv ?thm-event ?thm-name ?updated-thm-index)
            (gen-expr-thm old
                          new vartys const-new thm-index hints)))
        (pseudo-event-formp thm-event))
      :rule-classes :rewrite)

    Theorem: symbolp-of-gen-expr-thm.thm-name

    (defthm symbolp-of-gen-expr-thm.thm-name
      (b* (((mv ?thm-event ?thm-name ?updated-thm-index)
            (gen-expr-thm old
                          new vartys const-new thm-index hints)))
        (symbolp thm-name))
      :rule-classes :rewrite)

    Theorem: posp-of-gen-expr-thm.updated-thm-index

    (defthm posp-of-gen-expr-thm.updated-thm-index
      (b* (((mv ?thm-event ?thm-name ?updated-thm-index)
            (gen-expr-thm old
                          new vartys const-new thm-index hints)))
        (posp updated-thm-index))
      :rule-classes :rewrite)

    Theorem: gen-expr-thm-of-expr-fix-old

    (defthm gen-expr-thm-of-expr-fix-old
      (equal (gen-expr-thm (expr-fix old)
                           new vartys const-new thm-index hints)
             (gen-expr-thm old
                           new vartys const-new thm-index hints)))

    Theorem: gen-expr-thm-expr-equiv-congruence-on-old

    (defthm gen-expr-thm-expr-equiv-congruence-on-old
      (implies
           (c$::expr-equiv old old-equiv)
           (equal (gen-expr-thm old
                                new vartys const-new thm-index hints)
                  (gen-expr-thm old-equiv
                                new vartys const-new thm-index hints)))
      :rule-classes :congruence)

    Theorem: gen-expr-thm-of-expr-fix-new

    (defthm gen-expr-thm-of-expr-fix-new
      (equal (gen-expr-thm old (expr-fix new)
                           vartys const-new thm-index hints)
             (gen-expr-thm old
                           new vartys const-new thm-index hints)))

    Theorem: gen-expr-thm-expr-equiv-congruence-on-new

    (defthm gen-expr-thm-expr-equiv-congruence-on-new
     (implies (c$::expr-equiv new new-equiv)
              (equal (gen-expr-thm old
                                   new vartys const-new thm-index hints)
                     (gen-expr-thm old new-equiv
                                   vartys const-new thm-index hints)))
     :rule-classes :congruence)