• 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
        • Soft
        • C
          • Syntax-for-tools
          • Atc
            • Atc-implementation
              • Atc-abstract-syntax
              • Atc-pretty-printer
              • Atc-event-and-code-generation
                • Atc-symbolic-computation-states
                • Atc-symbolic-execution-rules
                • Atc-gen-ext-declon-lists
                • Atc-function-and-loop-generation
                • Atc-statement-generation
                • Atc-gen-fileset
                • Atc-gen-everything
                • Atc-gen-obj-declon
                • Atc-gen-fileset-event
                • Atc-tag-tables
                • Atc-expression-generation
                • Atc-generation-contexts
                • Atc-gen-wf-thm
                • Term-checkers-atc
                  • Atc-check-cfun-call
                  • Atc-check-struct-write-array
                  • Atc-check-struct-read-array
                  • Atc-check-struct-write-scalar
                  • Atc-check-loop-call
                  • Atc-check-struct-read-scalar
                  • Atc-check-mv-let
                  • Atc-check-array-write
                  • Atc-check-let
                  • Atc-check-array-read
                  • Atc-check-integer-write
                    • Atc-check-declar/assign-n
                    • Atc-check-condexpr
                    • Atc-check-boolean-from-type
                    • Atc-check-integer-read
                    • Atc-check-sint-from-boolean
                  • Atc-variable-tables
                  • Term-checkers-common
                  • Atc-gen-init-fun-env-thm
                  • Atc-gen-appconds
                  • Read-write-variables
                  • Atc-gen-thm-assert-events
                  • Test*
                  • Atc-gen-prog-const
                  • Atc-gen-expr-bool
                  • Atc-theorem-generation
                  • Atc-tag-generation
                  • Atc-gen-expr-pure
                  • Atc-function-tables
                  • Atc-object-tables
                • Fty-pseudo-term-utilities
                • Atc-term-recognizers
                • Atc-input-processing
                • Atc-shallow-embedding
                • Atc-process-inputs-and-gen-everything
                • Atc-table
                • Atc-fn
                • Atc-pretty-printing-options
                • Atc-types
                • Atc-macro-definition
              • Atc-tutorial
            • Language
            • Representation
            • Transformation-tools
            • Insertion-sort
            • Pack
          • Bv
          • Imp-language
          • Event-macros
          • Java
          • Riscv
          • 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
    • Term-checkers-atc

    Atc-check-integer-write

    Check if a term may represent a write of an integer by pointer.

    Signature
    (atc-check-integer-write val) → (mv erp yes/no fn arg type)
    Arguments
    val — Guard (pseudo-termp val).
    Returns
    yes/no — Type (booleanp yes/no).
    fn — Type (symbolp fn).
    arg — Type (pseudo-termp arg).
    type — Type (typep type).

    A write of an integer by pointer is represented by a let of the form

    (let ((<var> (<type>-write <int>))) ...)

    where <var> is a variable of pointer-to-integer type and <int> is a term that yields the integer to write.

    This ACL2 function takes as argument the value term of the let, i.e. (<type>-write <int>), and checks if it has the expected form, returning, if successful, the function <type>-write, the argument <int>, and the integer type.

    Definitions and Theorems

    Function: atc-check-integer-write

    (defun atc-check-integer-write (val)
     (declare (xargs :guard (pseudo-termp val)))
     (let ((__function__ 'atc-check-integer-write))
      (declare (ignorable __function__))
      (b*
       (((reterr) nil nil nil (irr-type))
        ((acl2::fun (no))
         (retok nil nil nil (irr-type)))
        ((mv okp fn args)
         (fty-check-fn-call val))
        ((unless okp) (no))
        ((mv okp fixtype write)
         (atc-check-symbol-2part fn))
        (type (fixtype-to-integer-type fixtype))
        ((unless (and okp (eq write 'write) type))
         (no))
        ((unless (equal (symbol-package-name fn) "C"))
         (reterr
          (msg
           "Invalid function ~x0 encountered: ~
                          it has the form of a write of an integer by pointer, ~
                          but it is not in the \"C\" package."
           fn)))
        ((unless (list-lenp 1 args))
         (reterr (raise "Internal error: ~x0 not applied to 1 argument."
                        fn)))
        (arg (first args)))
       (retok t fn arg type))))

    Theorem: booleanp-of-atc-check-integer-write.yes/no

    (defthm booleanp-of-atc-check-integer-write.yes/no
      (b* (((mv acl2::?erp ?yes/no ?fn ?arg ?type)
            (atc-check-integer-write val)))
        (booleanp yes/no))
      :rule-classes :rewrite)

    Theorem: symbolp-of-atc-check-integer-write.fn

    (defthm symbolp-of-atc-check-integer-write.fn
      (b* (((mv acl2::?erp ?yes/no ?fn ?arg ?type)
            (atc-check-integer-write val)))
        (symbolp fn))
      :rule-classes :rewrite)

    Theorem: pseudo-termp-of-atc-check-integer-write.arg

    (defthm pseudo-termp-of-atc-check-integer-write.arg
      (b* (((mv acl2::?erp ?yes/no ?fn ?arg ?type)
            (atc-check-integer-write val)))
        (pseudo-termp arg))
      :rule-classes :rewrite)

    Theorem: typep-of-atc-check-integer-write.type

    (defthm typep-of-atc-check-integer-write.type
      (b* (((mv acl2::?erp ?yes/no ?fn ?arg ?type)
            (atc-check-integer-write val)))
        (typep type))
      :rule-classes :rewrite)

    Theorem: pseudo-term-count-of-atc-check-integer-write

    (defthm pseudo-term-count-of-atc-check-integer-write
      (b* (((mv acl2::?erp ?yes/no ?fn ?arg ?type)
            (atc-check-integer-write val)))
        (implies yes/no
                 (< (pseudo-term-count arg)
                    (pseudo-term-count val))))
      :rule-classes :linear)

    Theorem: type-nonchar-integerp-of-atc-check-integer-write

    (defthm type-nonchar-integerp-of-atc-check-integer-write
      (b* (((mv acl2::?erp ?yes/no ?fn ?arg ?type)
            (atc-check-integer-write val)))
        (implies yes/no (type-nonchar-integerp type))))