• 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-binary
              • Xeq-block-item-list-cons
              • Xeq-stmt-ifelse
              • Xeq-expr-cond
              • Xeq-expr-const
              • Gen-param-thms
              • Gen-expr-thm
              • Gen-from-params
              • Xeq-decl-decl
              • Xeq-expr-unary
              • Xeq-stmt-dowhile
              • Xeq-expr-cast
              • Lift-expr-pure-thm
                • Xeq-stmt-while
                • Gout
                • Gen-block-item-list-thm
                • Xeq-stmt-if
                • Gin
                • Xeq-expr-ident
                • Gen-expr-pure-thm
                • Gen-block-item-thm
                • Xeq-stmt-expr
                • Gen-initer-single-thm
                • Gen-init-scope-thm
                • Xeq-stmt-return
                • Gen-decl-thm
                • Gen-stmt-thm
                • Xeq-block-item-decl
                • Xeq-initer-single
                • Xeq-block-item-stmt
                • Xeq-stmt-compound
                • 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

    Lift-expr-pure-thm

    Lift a theorem for a pure expression from c::exec-expr-pure to c::exec-expr.

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

    As noted in gen-expr-pure-thm, we are transitioning from that function to gen-expr-thm. When the transition is completed, and that function is eliminated, this function will be eliminated as well.

    Definitions and Theorems

    Function: lift-expr-pure-thm

    (defun lift-expr-pure-thm (old new expr-pure-thm
                                   vartys const-new thm-index)
     (declare (xargs :guard (and (exprp old)
                                 (exprp new)
                                 (symbolp expr-pure-thm)
                                 (c::ident-type-mapp vartys)
                                 (symbolp const-new)
                                 (posp thm-index))))
     (declare (xargs :guard (and (expr-unambp old)
                                 (expr-annop old)
                                 (expr-unambp new)
                                 (expr-annop new))))
     (let ((__function__ 'lift-expr-pure-thm))
      (declare (ignorable __function__))
      (b*
       ((old (expr-fix old))
        (new (expr-fix new))
        ((unless (expr-pure-formalp old))
         (raise "Internal error: ~x0 is not in the formalized subset."
                old)
         (mv '(_) nil 1))
        ((unless (expr-pure-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))
        (vars-pre (gen-var-assertions vartys 'compst))
        ((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))
        (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-result old-compst)
                         (c::exec-expr old-expr compst old-fenv limit))
                        ((mv new-result new-compst)
                         (c::exec-expr new-expr compst new-fenv limit))
                        (old-value (c::expr-value->value old-result))
                        (new-value (c::expr-value->value new-result)))))
           (cons
            (cons
             'implies
             (cons
              (cons 'and
                    (append vars-pre
                            '((not (c::errorp old-result)))))
              (cons
               (cons
                'and
                (cons
                 '(not (c::errorp new-result))
                 (cons
                  '(iff old-result new-result)
                  (cons
                   '(equal old-value new-value)
                   (cons
                    '(equal old-compst new-compst)
                    (cons
                     'old-value
                     (cons
                       (cons 'equal
                             (cons '(c::type-of-value old-value)
                                   (cons (cons 'quote (cons ctype 'nil))
                                         'nil)))
                       'nil)))))))
               'nil)))
            'nil))))
        (hints
         (cons
          (cons
           '"Goal"
           (cons
            ':use
            (cons
             (cons
              expr-pure-thm
              (cons
               (cons
                ':instance
                (cons
                 'expr-pure-congruence
                 (cons
                    (cons 'old
                          (cons (cons 'quote (cons old-expr 'nil))
                                'nil))
                    (cons (cons 'new
                                (cons (cons 'quote (cons new-expr 'nil))
                                      'nil))
                          'nil))))
               (cons
                (cons
                 ':instance
                 (cons
                    'expr-pure-errors
                    (cons (cons 'expr
                                (cons (cons 'quote (cons old-expr 'nil))
                                      'nil))
                          '((fenv old-fenv)))))
                'nil)))
             '(:in-theory
                   '(c::exec-expr c::exec-expr-pure-when-const
                                  c::errorp-of-error (:e c::expr-purep)
                                  (:e c::expr-kind)
                                  (:e c::expr-binary->op)
                                  (:e c::binop-kind)
                                  (:e c::type-nonchar-integerp)
                                  (:e c::expr-pure-limit)
                                  (:t c::exec-expr-pure)
                                  (:t c::expr-value->value))))))
          '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-lift-expr-pure-thm.thm-event

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

    Theorem: symbolp-of-lift-expr-pure-thm.thm-name

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

    Theorem: posp-of-lift-expr-pure-thm.updated-thm-index

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

    Theorem: lift-expr-pure-thm-of-expr-fix-old

    (defthm lift-expr-pure-thm-of-expr-fix-old
      (equal (lift-expr-pure-thm (expr-fix old)
                                 new expr-pure-thm
                                 vartys const-new thm-index)
             (lift-expr-pure-thm old new expr-pure-thm
                                 vartys const-new thm-index)))

    Theorem: lift-expr-pure-thm-expr-equiv-congruence-on-old

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

    Theorem: lift-expr-pure-thm-of-expr-fix-new

    (defthm lift-expr-pure-thm-of-expr-fix-new
      (equal (lift-expr-pure-thm old (expr-fix new)
                                 expr-pure-thm
                                 vartys const-new thm-index)
             (lift-expr-pure-thm old new expr-pure-thm
                                 vartys const-new thm-index)))

    Theorem: lift-expr-pure-thm-expr-equiv-congruence-on-new

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