• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • Macro-libraries
    • ACL2
    • 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-java-primitives
              • Atj-java-primitive-arrays
              • Atj-type-macros
              • Atj-java-syntax-operations
                • Jstatems+jblocks-count-ifs
                • Negate-boolean-jexpr
                • Unmake-right-assoc-condand
                • Jstatems+jblocks-methods
                • Mergesort-jmethods
                  • Mergesort-jfields
                  • Make-right-assoc-condand
                  • Merge-jmethods
                  • Merge-jfields
                  • Jexpr-vars
                  • Jexpr-methods
                • 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-java-syntax-operations

    Mergesort-jmethods

    Sort a list of methods according to their names.

    Signature
    (mergesort-jmethods methods) → sorted-methods
    Arguments
    methods — Guard (jmethod-listp methods).
    Returns
    sorted-methods — Type (jmethod-listp sorted-methods), given the guard.

    Definitions and Theorems

    Function: merge-jmethods

    (defun merge-jmethods (methods1 methods2)
      (declare (xargs :guard (and (jmethod-listp methods1)
                                  (jmethod-listp methods2))))
      (let ((__function__ 'merge-jmethods))
        (declare (ignorable __function__))
        (cond ((endp methods1) methods2)
              ((endp methods2) methods1)
              (t (if (string<= (jmethod->name (car methods1))
                               (jmethod->name (car methods2)))
                     (cons (car methods1)
                           (merge-jmethods (cdr methods1)
                                           methods2))
                   (cons (car methods2)
                         (merge-jmethods methods1 (cdr methods2))))))))

    Theorem: jmethod-listp-of-merge-jmethods

    (defthm jmethod-listp-of-merge-jmethods
      (implies (and (jmethod-listp methods1)
                    (jmethod-listp methods2))
               (b* ((merged-methods (merge-jmethods methods1 methods2)))
                 (jmethod-listp merged-methods)))
      :rule-classes :rewrite)

    Function: mergesort-jmethods

    (defun mergesort-jmethods (methods)
      (declare (xargs :guard (jmethod-listp methods)))
      (let ((__function__ 'mergesort-jmethods))
        (declare (ignorable __function__))
        (b* ((len-methods (len methods))
             ((when (<= len-methods 1)) methods)
             (len/2 (floor len-methods 2))
             (methods1 (mergesort-jmethods (take len/2 methods)))
             (methods2 (mergesort-jmethods (nthcdr len/2 methods))))
          (merge-jmethods methods1 methods2))))

    Theorem: jmethod-listp-of-mergesort-jmethods

    (defthm jmethod-listp-of-mergesort-jmethods
      (implies (and (jmethod-listp methods))
               (b* ((sorted-methods (mergesort-jmethods methods)))
                 (jmethod-listp sorted-methods)))
      :rule-classes :rewrite)