• 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
          • Language
            • Abstract-syntax
            • Integer-ranges
            • Implementation-environments
            • Dynamic-semantics
            • Static-semantics
            • Grammar
            • Types
              • Type
                • Typep
                  • Type-fix
                  • Type-case
                  • Type-count
                  • Type-equiv
                  • Type-array
                  • Type-kind
                  • Type-struct
                  • Type-pointer
                  • Type-sint
                  • Type-uchar
                  • Type-void
                  • Type-ushort
                  • Type-ulong
                  • Type-ullong
                  • Type-uint
                  • Type-sshort
                  • Type-slong
                  • Type-sllong
                  • Type-schar
                  • Type-char
                • Type-name-list-to-type-list
                • Tyname-to-type
                • Member-type-list->name-list
                • Type-completep
                • Member-type
                • Member-type-add-first
                • Member-type-add-last
                • Init-type
                • Type-option
                • Member-type-lookup
                • Tyspecseq-to-type
                • Member-type-list-option
                • Type-promoted-arithmeticp
                • Type-list-result
                • Member-type-list-result
                • Integer-type-bits-nulfun
                • Init-type-result
                • Type-result
                • Type-nonchar-integerp
                • Type-nonchar-integer-listp
                • Type-arithmetic-listp
                • Type-integer-listp
                • Integer-type-xdoc-string
                • Type-unsigned-integerp
                • Type-signed-integerp
                • Integer-type-minbits
                • Integer-type-bits
                • Type-scalarp
                • Type-integerp
                • Type-arithmeticp
                • Type-realp
                • Type-list
                • *nonchar-integer-types*
                • Member-type-list
                • Ident-type-map
                • Type-set
                • Type-option-set
                • Symbol-type-alist
                • Type-option-list
              • Integer-formats-definitions
              • Computation-states
              • Portable-ascii-identifiers
              • Values
              • Integer-operations
              • Object-designators
              • Operations
              • Errors
              • Tag-environments
              • Function-environments
              • Character-sets
              • Flexible-array-member-removal
              • Arithmetic-operations
              • Pointer-operations
              • Real-operations
              • Array-operations
              • Scalar-operations
              • Structure-operations
            • 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
    • Type

    Typep

    Recognizer for type structures.

    Signature
    (typep x) → *

    Definitions and Theorems

    Function: typep

    (defun typep (x)
      (declare (xargs :guard t))
      (and (consp x)
           (cond ((or (atom x) (eq (car x) :void))
                  (and (true-listp (cdr x))
                       (eql (len (cdr x)) 0)
                       (b* nil t)))
                 ((eq (car x) :char)
                  (and (true-listp (cdr x))
                       (eql (len (cdr x)) 0)
                       (b* nil t)))
                 ((eq (car x) :schar)
                  (and (true-listp (cdr x))
                       (eql (len (cdr x)) 0)
                       (b* nil t)))
                 ((eq (car x) :uchar)
                  (and (true-listp (cdr x))
                       (eql (len (cdr x)) 0)
                       (b* nil t)))
                 ((eq (car x) :sshort)
                  (and (true-listp (cdr x))
                       (eql (len (cdr x)) 0)
                       (b* nil t)))
                 ((eq (car x) :ushort)
                  (and (true-listp (cdr x))
                       (eql (len (cdr x)) 0)
                       (b* nil t)))
                 ((eq (car x) :sint)
                  (and (true-listp (cdr x))
                       (eql (len (cdr x)) 0)
                       (b* nil t)))
                 ((eq (car x) :uint)
                  (and (true-listp (cdr x))
                       (eql (len (cdr x)) 0)
                       (b* nil t)))
                 ((eq (car x) :slong)
                  (and (true-listp (cdr x))
                       (eql (len (cdr x)) 0)
                       (b* nil t)))
                 ((eq (car x) :ulong)
                  (and (true-listp (cdr x))
                       (eql (len (cdr x)) 0)
                       (b* nil t)))
                 ((eq (car x) :sllong)
                  (and (true-listp (cdr x))
                       (eql (len (cdr x)) 0)
                       (b* nil t)))
                 ((eq (car x) :ullong)
                  (and (true-listp (cdr x))
                       (eql (len (cdr x)) 0)
                       (b* nil t)))
                 ((eq (car x) :struct)
                  (and (true-listp (cdr x))
                       (eql (len (cdr x)) 1)
                       (b* ((tag (std::da-nth 0 (cdr x))))
                         (identp tag))))
                 ((eq (car x) :pointer)
                  (and (true-listp (cdr x))
                       (eql (len (cdr x)) 1)
                       (b* ((to (std::da-nth 0 (cdr x))))
                         (typep to))))
                 (t (and (eq (car x) :array)
                         (and (true-listp (cdr x))
                              (eql (len (cdr x)) 2))
                         (b* ((of (std::da-nth 0 (cdr x)))
                              (size (std::da-nth 1 (cdr x))))
                           (and (typep of)
                                (pos-optionp size))))))))

    Theorem: consp-when-typep

    (defthm consp-when-typep
      (implies (typep x) (consp x))
      :rule-classes :compound-recognizer)