• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • ACL2
    • Macro-libraries
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • Soft
        • C
        • Bv
        • Imp-language
        • Event-macros
        • Java
          • Atj
            • Atj-implementation
              • Atj-types
              • Atj-java-primitive-array-model
              • Atj-java-abstract-syntax
              • Atj-input-processing
              • Atj-java-pretty-printer
              • Atj-code-generation
                • Atj-gen-test-method
                • Atj-shallow-code-generation
                • Atj-common-code-generation
                • Atj-shallow-quoted-constant-generation
                • Atj-pre-translation
                  • Atj-pre-translation-array-analysis
                  • Atj-pre-translation-type-annotation
                  • Atj-pre-translation-var-reuse
                  • Atj-pre-translate
                  • Atj-pre-translation-multiple-values
                  • Atj-pre-translation-no-aij-types-analysis
                  • Atj-pre-translation-var-renaming
                    • Atj-rename-formals
                    • Atj-rename-formal
                    • Atj-rename-term
                    • Atj-rename-formals+body
                      • *atj-init-indices*
                    • Atj-pre-translation-remove-return-last
                    • Atj-pre-translation-disjunctions
                    • Atj-pre-translation-trivial-vars
                    • Atj-pre-translation-conjunctions
                    • Atj-pre-translation-unused-vars
                    • Atj-pre-translation-remove-dead-if-branches
                  • Atj-gen-everything
                  • Atj-name-translation
                  • Atj-gen-test-cunit
                  • Atj-gen-test-class
                  • Atj-gen-main-file
                  • Atj-post-translation
                  • Atj-deep-code-generation
                  • Atj-gen-test-methods
                  • Atj-gen-test-file
                  • Atj-gen-env-file
                  • Atj-gen-output-subdir
                • Atj-java-primitives
                • Atj-java-primitive-arrays
                • Atj-type-macros
                • Atj-java-syntax-operations
                • Atj-fn
                • Atj-library-extensions
                • Atj-java-input-types
                • Atj-test-structures
                • Aij-notions
                • Atj-macro-definition
              • Atj-tutorial
            • Aij
            • Language
          • 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
    • Atj-pre-translation-var-renaming

    Atj-rename-formals+body

    Rename all the ACL2 variables to their Java names, in the formal parameters and body of an ACL2 function.

    Signature
    (atj-rename-formals+body formals body curr-pkg) 
      → 
    (mv new-formals new-body)
    Arguments
    formals — Guard (symbol-listp formals).
    body — Guard (pseudo-termp body).
    curr-pkg — Guard (stringp curr-pkg).
    Returns
    new-formals — Type (symbol-listp new-formals), given the guard.
    new-body — Type (pseudo-termp new-body), given the guard.

    We collect all the variables in the formals and body, remove their markings and annotations (recall that the type annotation and new/old marking pre-translation steps take place before this renaming step), and organize them by symbol name: the resulting alist is passed to the renaming functions.

    Starting with the empty alist of indices and the empty renaming alists, we introduce renamed variables for the formal parameters, and we use the resulting renaming alists to process the body.

    Definitions and Theorems

    Function: atj-rename-formals+body

    (defun atj-rename-formals+body (formals body curr-pkg)
      (declare (xargs :guard (and (symbol-listp formals)
                                  (pseudo-termp body)
                                  (stringp curr-pkg))))
      (declare (xargs :guard (not (equal curr-pkg ""))))
      (let ((__function__ 'atj-rename-formals+body))
        (declare (ignorable __function__))
        (b* ((vars (union-eq formals (all-free/bound-vars body)))
             ((mv vars &) (atj-unmark-vars vars))
             (vars (atj-type-unannotate-vars vars))
             (vars-by-name (organize-symbols-by-name vars))
             ((mv new-formals
                  renaming-new renaming-old indices)
              (atj-rename-formals formals nil nil *atj-init-indices*
                                  curr-pkg vars-by-name))
             ((mv new-body & &)
              (atj-rename-term body renaming-new renaming-old
                               indices curr-pkg vars-by-name)))
          (mv new-formals new-body))))

    Theorem: symbol-listp-of-atj-rename-formals+body.new-formals

    (defthm symbol-listp-of-atj-rename-formals+body.new-formals
      (implies (and (symbol-listp formals)
                    (pseudo-termp body)
                    (stringp curr-pkg)
                    (not (equal curr-pkg '"")))
               (b* (((mv ?new-formals ?new-body)
                     (atj-rename-formals+body formals body curr-pkg)))
                 (symbol-listp new-formals)))
      :rule-classes :rewrite)

    Theorem: pseudo-termp-of-atj-rename-formals+body.new-body

    (defthm pseudo-termp-of-atj-rename-formals+body.new-body
      (implies (and (symbol-listp formals)
                    (pseudo-termp body)
                    (stringp curr-pkg)
                    (not (equal curr-pkg '"")))
               (b* (((mv ?new-formals ?new-body)
                     (atj-rename-formals+body formals body curr-pkg)))
                 (pseudo-termp new-body)))
      :rule-classes :rewrite)

    Theorem: len-of-atj-rename-formals+body.new-formals

    (defthm len-of-atj-rename-formals+body.new-formals
      (b* (((mv ?new-formals ?new-body)
            (atj-rename-formals+body formals body curr-pkg)))
        (equal (len new-formals)
               (len formals))))