• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
        • Syntax-for-tools
        • Atc
          • Atc-implementation
            • Atc-abstract-syntax
            • Atc-pretty-printer
            • Atc-event-and-code-generation
            • Fty-pseudo-term-utilities
            • Atc-term-recognizers
            • Atc-input-processing
            • Atc-shallow-embedding
              • Defstruct
              • Defobject
                • Defobject-implementation
                  • Defobject-info
                  • Defobject-gen-everything
                  • Defobject-process-name
                  • Defobject-info-option
                  • Defobject-term-to-expr
                  • Term-checkers-common
                    • Atc-check-binop
                    • Atc-check-iconst
                    • Atc-check-unop
                      • Atc-check-conv
                      • Atc-check-symbol-5part
                      • Atc-check-symbol-4part
                      • Atc-check-symbol-3part
                      • Atc-check-symbol-2part
                    • Defobject-process-init
                    • Defobject-process-init-term
                    • Defobject-table-record-event
                    • Defobject-process-type
                    • Defobject-process-inputs
                    • Defobject-table-lookup
                    • Defobject-process-init-terms
                    • Defobject-process-inputs-and-gen-everything
                    • Defobject-fn
                    • Defobject-table-definition
                    • *defobject-table*
                    • Defobject-macro-definition
                • Atc-let-designations
                • Pointer-types
                • Atc-conditional-expressions
              • 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
        • Farray
        • Rp-rewriter
        • Instant-runoff-voting
        • Imp-language
        • Sidekick
        • Leftist-trees
        • Java
        • Taspi
        • Riscv
        • Bitcoin
        • Des
        • Ethereum
        • X86isa
        • Sha-2
        • Yul
        • Zcash
        • Proof-checker-itp13
        • Regex
        • ACL2-programming-language
        • Json
        • Jfkr
        • Equational
        • Cryptography
        • Poseidon
        • Where-do-i-place-my-book
        • Axe
        • Aleo
        • Bigmems
        • Builtins
        • Execloader
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Community
      • Proof-automation
      • ACL2
      • Macro-libraries
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Term-checkers-common

    Atc-check-unop

    Check if a term may represent a unary expression.

    Signature
    (atc-check-unop term) 
      → 
    (mv erp yes/no fn arg in-type out-type op)
    Arguments
    term — Guard (pseudo-termp term).
    Returns
    yes/no — Type (booleanp yes/no).
    fn — Type (symbolp fn).
    arg — Type (pseudo-termp arg).
    in-type — Type (typep in-type).
    out-type — Type (typep out-type).
    op — Type (unopp op).

    If the term is a call of one of the ACL2 functions that represent C unary operators, we return the function, the argument term the input and output types, and the C operator.

    If the term does not have that form, we return an indication of failure. The term may represent some other kind of C expression.

    Definitions and Theorems

    Function: atc-check-unop

    (defun atc-check-unop (term)
     (declare (xargs :guard (pseudo-termp term)))
     (let ((__function__ 'atc-check-unop))
      (declare (ignorable __function__))
      (b*
       (((reterr)
         nil nil nil (irr-type)
         (irr-type)
         (irr-unop))
        ((acl2::fun (no))
         (retok nil nil nil (irr-type)
                (irr-type)
                (irr-unop)))
        ((mv okp fn args)
         (fty-check-fn-call term))
        ((unless okp) (no))
        ((mv okp op fixtype)
         (atc-check-symbol-2part fn))
        (in-type (fixtype-to-integer-type fixtype))
        ((unless (and okp
                      (member-eq op '(plus minus bitnot lognot))
                      in-type))
         (no))
        ((unless (equal (symbol-package-name fn) "C"))
         (reterr
          (msg
           "Invalid function ~x0 encountered: ~
                          it has the form of an integer unary operation function, ~
                          but it is not in the \"C\" package."
           fn)))
        ((unless (list-lenp 1 args))
         (reterr (raise "Internal error: ~x0 not applied to 1 argument."
                        term)))
        (arg (first args))
        ((mv out-type unop)
         (case op
           (plus (mv (promote-type in-type) (unop-plus)))
           (minus (mv (promote-type in-type)
                      (unop-minus)))
           (bitnot (mv (promote-type in-type)
                       (unop-bitnot)))
           (lognot (mv (type-sint) (unop-lognot)))
           (t (prog2$ (impossible)
                      (mv (irr-type) (irr-unop)))))))
       (retok t fn arg in-type out-type unop))))

    Theorem: booleanp-of-atc-check-unop.yes/no

    (defthm booleanp-of-atc-check-unop.yes/no
      (b* (((mv acl2::?erp
                ?yes/no ?fn ?arg ?in-type ?out-type ?op)
            (atc-check-unop term)))
        (booleanp yes/no))
      :rule-classes :rewrite)

    Theorem: symbolp-of-atc-check-unop.fn

    (defthm symbolp-of-atc-check-unop.fn
      (b* (((mv acl2::?erp
                ?yes/no ?fn ?arg ?in-type ?out-type ?op)
            (atc-check-unop term)))
        (symbolp fn))
      :rule-classes :rewrite)

    Theorem: pseudo-termp-of-atc-check-unop.arg

    (defthm pseudo-termp-of-atc-check-unop.arg
      (b* (((mv acl2::?erp
                ?yes/no ?fn ?arg ?in-type ?out-type ?op)
            (atc-check-unop term)))
        (pseudo-termp arg))
      :rule-classes :rewrite)

    Theorem: typep-of-atc-check-unop.in-type

    (defthm typep-of-atc-check-unop.in-type
      (b* (((mv acl2::?erp
                ?yes/no ?fn ?arg ?in-type ?out-type ?op)
            (atc-check-unop term)))
        (typep in-type))
      :rule-classes :rewrite)

    Theorem: typep-of-atc-check-unop.out-type

    (defthm typep-of-atc-check-unop.out-type
      (b* (((mv acl2::?erp
                ?yes/no ?fn ?arg ?in-type ?out-type ?op)
            (atc-check-unop term)))
        (typep out-type))
      :rule-classes :rewrite)

    Theorem: unopp-of-atc-check-unop.op

    (defthm unopp-of-atc-check-unop.op
      (b* (((mv acl2::?erp
                ?yes/no ?fn ?arg ?in-type ?out-type ?op)
            (atc-check-unop term)))
        (unopp op))
      :rule-classes :rewrite)

    Theorem: pseudo-term-count-of-atc-check-unop-arg

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

    Theorem: type-nonchar-integerp-of-atc-check-unop-in-type

    (defthm type-nonchar-integerp-of-atc-check-unop-in-type
      (b* (((mv acl2::?erp
                ?yes/no ?fn ?arg ?in-type ?out-type ?op)
            (atc-check-unop term)))
        (implies yes/no
                 (type-nonchar-integerp in-type))))

    Theorem: type-nonchar-integerp-of-atc-check-unop-out-type

    (defthm type-nonchar-integerp-of-atc-check-unop-out-type
      (b* (((mv acl2::?erp
                ?yes/no ?fn ?arg ?in-type ?out-type ?op)
            (atc-check-unop term)))
        (implies yes/no
                 (type-nonchar-integerp out-type))))