• 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
        • Soft
        • Bv
        • Imp-language
        • Ethereum
        • Event-macros
        • Java
        • Riscv
        • Bitcoin
        • Zcash
        • Yul
        • ACL2-programming-language
        • Prime-fields
        • Json
        • Syntheto
          • Process-syntheto-toplevel-fn
          • Translation
          • Language
            • Static-semantics
              • Check-expression-fns
              • Subtypep
              • Match-type
              • Check-product-update-expression
              • Get-builtin-function-in/out/pre-post
                • Check-sum-update-expression
                • Check-sum-field-expression
                • Check-strict-binary-expression
                • Check-lt/le/gt/ge-expression
                • Check-eq/ne-expression
                • Check-div/rem-expression
                • Check-add/sub/mul-expression
                • Align-let-vars-values
                • Check-iff-expression
                • Check-function-definition-top/nontop
                • Check-sum-construct-expression
                • Check-rem-expression
                • Check-mul-expression
                • Check-sub-expression
                • Check-div-expression
                • Check-add-expression
                • Check-ne-expression
                • Check-lt-expression
                • Check-le-expression
                • Check-gt-expression
                • Check-ge-expression
                • Check-eq-expression
                • Check-function-specifier
                • Type-result
                • Check-product-construct-expression
                • Supremum-type
                • Check-call-expression
                • Check-product-field-expression
                • Check-function-definer
                • Make-subproof-obligations
                • Get-function-in/out/pre/post
                • Check-sum-test-expression
                • Match-field
                • Decompose-expression
                • Match-to-target
                • Check-unary-expression
                • Max-supertype
                • Match-type-list
                • Check-minus-expression
                • Check-type-definition
                • Check-not-expression
                • Check-type-product
                • Match-field-list
                • Check-type-subset
                • Check-type-definition-in-recursion
                • Align-let-vars-values-aux
                • Non-trivial-proof-obligation
                • Check-type-recursion
                • Check-function-specification
                • Check-toplevel
                • Supremum-type-list
                • Check-component-expression
                • Check-branch-list
                • Check-function-recursion
                • Check-function-definition
                • Binding
                • Check-function-header
                • Check-function-definition-list
                • Check-type-definition-list-in-recursion
                • Check-theorem
                • Check-nonstrict-binary-expression
                • Context-add-variables
                • Decompose-expression-aux
                • Check-alternative
                • Check-multi-expression
                • Check-type-sum
                • Check-type
                • Check-alternative-list
                • Context-add-condition
                • Check-type-definer
                • Check-transform
                • Check-variable
                • Check-transform-args
                • Check-toplevel-list
                • Context-add-condition-list
                • Check-if/when/unless-expression
                • Initializers-to-variable-substitution
                • Context-add-binding
                • Check-function-header-list
                • Context-add-toplevel
                • Ensure-single-type
                • Max-supertypes
                • Check-bind-expression
                • Check-type-list
                • Check-literal
                • Literal-type
                • Check-expression-list
                • Variable-context
                • Check-cond-expression
                • Check-branch
                • Args-without-defaults
                • Check-expression
                • *builtin-function-names*
                • Function-called-in
              • Abstract-syntax
              • Outcome
              • Abstract-syntax-operations
              • Outcome-list
              • Outcomes
            • Process-syntheto-toplevel
            • Shallow-embedding
          • File-io-light
          • Cryptography
          • Number-theory
          • Axe
          • Lists-light
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Static-semantics

    Get-builtin-function-in/out/pre-post

    Retrieve the inputs, outputs, precondition, and postcondition of a built-in function.

    Signature
    (get-builtin-function-in/out/pre-post name types) 
      → 
    (mv err? foundp inputs outputs precondition? postcondition?)
    Arguments
    name — Guard (identifierp name).
    types — Guard (type-listp types).
    Returns
    foundp — Type (booleanp foundp).
    inputs — Type (typed-variable-listp inputs).
    outputs — Type (typed-variable-listp outputs).
    precondition? — Type (maybe-expressionp precondition?).
    postcondition? — Type (maybe-expressionp postcondition?).

    This ACL2 function implicitly defines the inputs, outputs, preconditions, and postoconditions of the built-in functions. At this time, there is no other explicit representation of them in the Syntheto abstract syntax of top-level constructs.

    The current built-in functions are polymorphic. The types argument of this ACL2 function specifies which monomorphic instance is being referenced.

    The names of the currently supported built-in functions are in *builtin-function-names*.

    Definitions and Theorems

    Function: get-builtin-function-in/out/pre-post

    (defun get-builtin-function-in/out/pre-post (name types)
     (declare (xargs :guard (and (identifierp name)
                                 (type-listp types))))
     (let ((__function__ 'get-builtin-function-in/out/pre-post))
      (declare (ignorable __function__))
      (cond
       ((identifier-equiv name (identifier "empty"))
        (b* (((unless (= (len types) 1))
              (mv (list :builtin-wrong-types
                        (identifier-fix name)
                        (type-list-fix types))
                  nil nil nil nil nil))
             (type (car types)))
          (cond ((type-case type :sequence)
                 (mv nil t nil
                     (list (make-typed-variable :name (identifier "x")
                                                :type type))
                     nil nil))
                ((type-case type :set)
                 (mv nil t nil
                     (list (make-typed-variable :name (identifier "x")
                                                :type type))
                     nil nil))
                (t (mv (list :builtin-wrong-type
                             (identifier-fix name)
                             (type-fix type))
                       nil nil nil nil nil)))))
       ((identifier-equiv name (identifier "add"))
        (b* (((unless (= (len types) 1))
              (mv (list :builtin-wrong-types
                        (identifier-fix name)
                        (type-list-fix types))
                  nil nil nil nil nil))
             (type (car types)))
         (cond
          ((type-case type :sequence)
           (mv
            nil t
            (list
               (make-typed-variable :name (identifier "x")
                                    :type (type-sequence->element type))
               (make-typed-variable :name (identifier "y")
                                    :type type))
            (list (make-typed-variable :name (identifier "xy")
                                       :type type))
            nil nil))
          ((type-case type :set)
           (mv
              nil t
              (list (make-typed-variable :name (identifier "x")
                                         :type (type-set->element type))
                    (make-typed-variable :name (identifier "y")
                                         :type type))
              (list (make-typed-variable :name (identifier "xy")
                                         :type type))
              nil nil))
          (t (mv (list :builtin-wrong-type
                       (identifier-fix name)
                       (type-fix type))
                 nil nil nil nil nil)))))
       ((identifier-equiv name (identifier "append"))
        (b* (((unless (= (len types) 1))
              (mv (list :builtin-wrong-types
                        (identifier-fix name)
                        (type-list-fix types))
                  nil nil nil nil nil))
             (type (car types)))
          (cond ((type-case type :sequence)
                 (mv nil t
                     (list (make-typed-variable :name (identifier "x")
                                                :type type)
                           (make-typed-variable :name (identifier "y")
                                                :type type))
                     (list (make-typed-variable :name (identifier "xy")
                                                :type type))
                     nil nil))
                (t (mv (list :builtin-wrong-type
                             (identifier-fix name)
                             (type-fix type))
                       nil nil nil nil nil)))))
       ((identifier-equiv name (identifier "length"))
        (b* (((unless (= (len types) 1))
              (mv (list :builtin-wrong-types
                        (identifier-fix name)
                        (type-list-fix types))
                  nil nil nil nil nil))
             (type (car types)))
          (cond ((type-case type :sequence)
                 (mv nil t
                     (list (make-typed-variable :name (identifier "x")
                                                :type type))
                     (list (make-typed-variable :name (identifier "b")
                                                :type (type-integer)))
                     nil nil))
                ((type-case type :set)
                 (mv nil t
                     (list (make-typed-variable :name (identifier "x")
                                                :type type))
                     (list (make-typed-variable :name (identifier "b")
                                                :type (type-integer)))
                     nil nil))
                (t (mv (list :builtin-wrong-type
                             (identifier-fix name)
                             (type-fix type))
                       nil nil nil nil nil)))))
       ((identifier-equiv name (identifier "is_empty"))
        (b* (((unless (= (len types) 1))
              (mv (list :builtin-wrong-types
                        (identifier-fix name)
                        (type-list-fix types))
                  nil nil nil nil nil))
             (type (car types)))
          (cond ((type-case type :sequence)
                 (mv nil t
                     (list (make-typed-variable :name (identifier "x")
                                                :type type))
                     (list (make-typed-variable :name (identifier "b")
                                                :type (type-boolean)))
                     nil nil))
                ((type-case type :set)
                 (mv nil t
                     (list (make-typed-variable :name (identifier "x")
                                                :type type))
                     (list (make-typed-variable :name (identifier "b")
                                                :type (type-boolean)))
                     nil nil))
                (t (mv (list :builtin-wrong-type
                             (identifier-fix name)
                             (type-fix type))
                       nil nil nil nil nil)))))
       ((identifier-equiv name (identifier "first"))
        (b* (((unless (= (len types) 1))
              (mv (list :builtin-wrong-types
                        (identifier-fix name)
                        (type-list-fix types))
                  nil nil nil nil nil))
             (type (car types)))
         (cond
          ((type-case type :sequence)
           (mv
            nil t
            (list (make-typed-variable :name (identifier "x")
                                       :type type))
            (list
              (make-typed-variable :name (identifier "y")
                                   :type (type-sequence->element type)))
            (make-expression-unary
             :operator (unary-op-not)
             :operand
             (make-expression-call
              :function (identifier "is_empty")
              :types (list type)
              :arguments
              (list (make-expression-variable :name (identifier "x")))))
            nil))
          ((type-case type :set)
           (mv
            nil t
            (list (make-typed-variable :name (identifier "x")
                                       :type type))
            (list (make-typed-variable :name (identifier "y")
                                       :type (type-set->element type)))
            (make-expression-unary
             :operator (unary-op-not)
             :operand
             (make-expression-call
              :function (identifier "is_empty")
              :types (list type)
              :arguments
              (list (make-expression-variable :name (identifier "x")))))
            nil))
          (t (mv (list :builtin-wrong-type
                       (identifier-fix name)
                       (type-fix type))
                 nil nil nil nil nil)))))
       ((identifier-equiv name (identifier "last"))
        (b* (((unless (= (len types) 1))
              (mv (list :builtin-wrong-types
                        (identifier-fix name)
                        (type-list-fix types))
                  nil nil nil nil nil))
             (type (car types)))
         (cond
          ((type-case type :sequence)
           (mv
            nil t
            (list (make-typed-variable :name (identifier "x")
                                       :type type))
            (list
              (make-typed-variable :name (identifier "y")
                                   :type (type-sequence->element type)))
            (make-expression-unary
             :operator (unary-op-not)
             :operand
             (make-expression-call
              :function (identifier "is_empty")
              :types (list type)
              :arguments
              (list (make-expression-variable :name (identifier "x")))))
            nil))
          (t (mv (list :builtin-wrong-type
                       (identifier-fix name)
                       (type-fix type))
                 nil nil nil nil nil)))))
       ((identifier-equiv name (identifier "rest"))
        (b* (((unless (= (len types) 1))
              (mv (list :builtin-wrong-types
                        (identifier-fix name)
                        (type-list-fix types))
                  nil nil nil nil nil))
             (type (car types)))
         (cond
          ((type-case type :sequence)
           (mv
            nil t
            (list (make-typed-variable :name (identifier "x")
                                       :type type))
            (list (make-typed-variable :name (identifier "y")
                                       :type type))
            (make-expression-unary
             :operator (unary-op-not)
             :operand
             (make-expression-call
              :function (identifier "is_empty")
              :types (list type)
              :arguments
              (list (make-expression-variable :name (identifier "x")))))
            nil))
          ((type-case type :set)
           (mv
            nil t
            (list (make-typed-variable :name (identifier "x")
                                       :type type))
            (list (make-typed-variable :name (identifier "y")
                                       :type type))
            (make-expression-unary
             :operator (unary-op-not)
             :operand
             (make-expression-call
              :function (identifier "is_empty")
              :types (list type)
              :arguments
              (list (make-expression-variable :name (identifier "x")))))
            nil))
          (t (mv (list :builtin-wrong-type
                       (identifier-fix name)
                       (type-fix type))
                 nil nil nil nil nil)))))
       ((identifier-equiv name (identifier "member"))
        (b* (((unless (= (len types) 1))
              (mv (list :builtin-wrong-types
                        (identifier-fix name)
                        (type-list-fix types))
                  nil nil nil nil nil))
             (type (car types)))
         (cond
          ((type-case type :sequence)
           (mv
            nil t
            (list
               (make-typed-variable :name (identifier "x")
                                    :type (type-sequence->element type))
               (make-typed-variable :name (identifier "y")
                                    :type type))
            (list (make-typed-variable :name (identifier "b")
                                       :type (type-boolean)))
            nil nil))
          ((type-case type :set)
           (mv
              nil t
              (list (make-typed-variable :name (identifier "x")
                                         :type (type-set->element type))
                    (make-typed-variable :name (identifier "y")
                                         :type type))
              (list (make-typed-variable :name (identifier "b")
                                         :type (type-boolean)))
              nil nil))
          (t (mv (list :builtin-wrong-type
                       (identifier-fix name)
                       (type-fix type))
                 nil nil nil nil nil)))))
       ((identifier-equiv name (identifier "remove_first"))
        (b* (((unless (= (len types) 1))
              (mv (list :builtin-wrong-types
                        (identifier-fix name)
                        (type-list-fix types))
                  nil nil nil nil nil))
             (type (car types)))
         (cond
          ((type-case type :sequence)
           (mv
            nil t
            (list
               (make-typed-variable :name (identifier "x")
                                    :type (type-sequence->element type))
               (make-typed-variable :name (identifier "y")
                                    :type type))
            (list (make-typed-variable :name (identifier "z")
                                       :type type))
            nil nil))
          ((type-case type :set)
           (mv
              nil t
              (list (make-typed-variable :name (identifier "x")
                                         :type (type-set->element type))
                    (make-typed-variable :name (identifier "y")
                                         :type type))
              (list (make-typed-variable :name (identifier "z")
                                         :type type))
              nil nil))
          (t (mv (list :builtin-wrong-type
                       (identifier-fix name)
                       (type-fix type))
                 nil nil nil nil nil)))))
       (t (mv nil nil nil nil nil nil)))))

    Theorem: booleanp-of-get-builtin-function-in/out/pre-post.foundp

    (defthm booleanp-of-get-builtin-function-in/out/pre-post.foundp
      (b* (((mv ?err? ?foundp ?inputs
                ?outputs ?precondition? ?postcondition?)
            (get-builtin-function-in/out/pre-post name types)))
        (booleanp foundp))
      :rule-classes :rewrite)

    Theorem: typed-variable-listp-of-get-builtin-function-in/out/pre-post.inputs

    (defthm
     typed-variable-listp-of-get-builtin-function-in/out/pre-post.inputs
     (b* (((mv ?err? ?foundp ?inputs
               ?outputs ?precondition? ?postcondition?)
           (get-builtin-function-in/out/pre-post name types)))
       (typed-variable-listp inputs))
     :rule-classes :rewrite)

    Theorem: typed-variable-listp-of-get-builtin-function-in/out/pre-post.outputs

    (defthm
     typed-variable-listp-of-get-builtin-function-in/out/pre-post.outputs
     (b* (((mv ?err? ?foundp ?inputs
               ?outputs ?precondition? ?postcondition?)
           (get-builtin-function-in/out/pre-post name types)))
       (typed-variable-listp outputs))
     :rule-classes :rewrite)

    Theorem: maybe-expressionp-of-get-builtin-function-in/out/pre-post.precondition?

    (defthm
     maybe-expressionp-of-get-builtin-function-in/out/pre-post.precondition?
     (b* (((mv ?err? ?foundp ?inputs
               ?outputs ?precondition? ?postcondition?)
           (get-builtin-function-in/out/pre-post name types)))
       (maybe-expressionp precondition?))
     :rule-classes :rewrite)

    Theorem: maybe-expressionp-of-get-builtin-function-in/out/pre-post.postcondition?

    (defthm
     maybe-expressionp-of-get-builtin-function-in/out/pre-post.postcondition?
     (b* (((mv ?err? ?foundp ?inputs
               ?outputs ?precondition? ?postcondition?)
           (get-builtin-function-in/out/pre-post name types)))
       (maybe-expressionp postcondition?))
     :rule-classes :rewrite)

    Theorem: get-builtin-function-in/out/pre-post-of-identifier-fix-name

    (defthm get-builtin-function-in/out/pre-post-of-identifier-fix-name
      (equal (get-builtin-function-in/out/pre-post (identifier-fix name)
                                                   types)
             (get-builtin-function-in/out/pre-post name types)))

    Theorem: get-builtin-function-in/out/pre-post-identifier-equiv-congruence-on-name

    (defthm
     get-builtin-function-in/out/pre-post-identifier-equiv-congruence-on-name
     (implies
        (identifier-equiv name name-equiv)
        (equal (get-builtin-function-in/out/pre-post name types)
               (get-builtin-function-in/out/pre-post name-equiv types)))
     :rule-classes :congruence)

    Theorem: get-builtin-function-in/out/pre-post-of-type-list-fix-types

    (defthm get-builtin-function-in/out/pre-post-of-type-list-fix-types
     (equal
       (get-builtin-function-in/out/pre-post name (type-list-fix types))
       (get-builtin-function-in/out/pre-post name types)))

    Theorem: get-builtin-function-in/out/pre-post-type-list-equiv-congruence-on-types

    (defthm
     get-builtin-function-in/out/pre-post-type-list-equiv-congruence-on-types
     (implies
        (type-list-equiv types types-equiv)
        (equal (get-builtin-function-in/out/pre-post name types)
               (get-builtin-function-in/out/pre-post name types-equiv)))
     :rule-classes :congruence)