• 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

    Check-type

    Check if a type is statically well-formed.

    Signature
    (check-type type ctxt) → yes/no
    Arguments
    type — Guard (typep type).
    ctxt — Guard (contextp ctxt).
    Returns
    yes/no — Type (booleanp yes/no).

    The primitive types are always well-formed. The collection types and the option type are well-formed iff their argument types are. A defined type is well-formed iff it references a defined type in the existing top-level constructs, or one of the types being currently defined.

    Definitions and Theorems

    Function: check-type

    (defun check-type (type ctxt)
     (declare (xargs :guard (and (typep type) (contextp ctxt))))
     (let ((__function__ 'check-type))
      (declare (ignorable __function__))
      (type-case
           type
           :boolean t
           :character t
           :string t
           :integer t
           :set (check-type type.element ctxt)
           :sequence (check-type type.element ctxt)
           :map (and (check-type type.domain ctxt)
                     (check-type type.range ctxt))
           :option (check-type type.base ctxt)
           :defined
           (bool-fix
                (or (get-type-definition type.name (context->tops ctxt))
                    (member-equal type.name (context->types ctxt)))))))

    Theorem: booleanp-of-check-type

    (defthm booleanp-of-check-type
      (b* ((yes/no (check-type type ctxt)))
        (booleanp yes/no))
      :rule-classes :rewrite)

    Theorem: check-type-of-type-fix-type

    (defthm check-type-of-type-fix-type
      (equal (check-type (type-fix type) ctxt)
             (check-type type ctxt)))

    Theorem: check-type-type-equiv-congruence-on-type

    (defthm check-type-type-equiv-congruence-on-type
      (implies (type-equiv type type-equiv)
               (equal (check-type type ctxt)
                      (check-type type-equiv ctxt)))
      :rule-classes :congruence)

    Theorem: check-type-of-context-fix-ctxt

    (defthm check-type-of-context-fix-ctxt
      (equal (check-type type (context-fix ctxt))
             (check-type type ctxt)))

    Theorem: check-type-context-equiv-congruence-on-ctxt

    (defthm check-type-context-equiv-congruence-on-ctxt
      (implies (context-equiv ctxt ctxt-equiv)
               (equal (check-type type ctxt)
                      (check-type type ctxt-equiv)))
      :rule-classes :congruence)