• 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
            • 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-gen-cfun-correct-thm
                  • Atc-typed-formals
                  • Atc-gen-outer-bindings-and-hyps
                  • Atc-gen-fundef
                  • Atc-gen-exec-stmt-while-for-loop
                  • Atc-gen-context-preamble
                  • Atc-gen-pop-frame-thm
                  • Atc-gen-loop-correct-thm
                  • Atc-gen-loop-body-correct-thm
                  • Atc-gen-init-scope-thms
                  • Atc-gen-fun-correct-thm
                  • Atc-gen-fn-result-thm
                  • Atc-gen-loop
                  • Atc-gen-loop-test-correct-thm
                  • Atc-check-guard-conjunct
                    • Atc-find-affected
                    • Atc-gen-cfun-final-compustate
                    • Atc-gen-init-inscope-auto
                    • Atc-gen-init-inscope-static
                    • Atc-gen-push-init-thm
                    • Atc-gen-loop-measure-fn
                    • Atc-gen-fun-endstate
                    • Atc-gen-loop-termination-thm
                    • Atc-gen-formal-thm
                    • Atc-gen-loop-final-compustate
                    • Atc-gen-loop-measure-thm
                    • Atc-gen-object-disjoint-hyps
                    • Atc-loop-body-term-subst
                    • Atc-gen-omap-update-formals
                    • Atc-gen-loop-tthm-formula
                    • Atc-gen-init-inscope
                    • Atc-gen-fn-def*
                    • Atc-gen-param-declon-list
                    • Atc-formal-affectablep
                    • Atc-gen-cfun-fun-env-thm
                    • Atc-gen-add-var-formals
                    • Atc-gen-cfun-fun-env-thm-name
                    • Atc-gen-fn-guard
                    • Atc-filter-exec-fun-args
                    • Atc-gen-context-preamble-aux-aux
                    • Atc-typed-formals-to-extobjs
                    • Atc-formal-affectable-listp
                  • 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-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
              • Pure-expression-execution
            • Transformation-tools
            • Language
            • 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
    • Atc-function-and-loop-generation

    Atc-check-guard-conjunct

    C type and argument derived from a guard conjunct, if any.

    Signature
    (atc-check-guard-conjunct conjunct prec-tags prec-objs) 
      → 
    (mv type defobj-pred arg)
    Arguments
    conjunct — Guard (pseudo-termp conjunct).
    prec-tags — Guard (atc-string-taginfo-alistp prec-tags).
    prec-objs — Guard (atc-string-objinfo-alistp prec-objs).
    Returns
    type — Type (type-optionp type).
    defobj-pred — Type (symbolp defobj-pred).
    arg — Type (symbolp arg).

    This is used to determine the types of the formal parameters of functions from the conjuncts used in the guard, as explained in the user documentation.

    The conjunct must have the form (recognizer var) or (star (recognizer var)), where recognizer is a recognizer of a C type and var is a variable. If the recognizer is a known one for integer array types, the star wrapper is disallowed, and the integer array type is readily determined. If the recognizer is a known one for integer types, the star wrapper may be present or not, and distinguishes between the integer type and the pointer type to the integer type. Otherwise, there are two possibilities. One is that the recognizer is the one of a defstruct, of the form struct-<tag>-p: in this case, the type is the structure type or a pointer type to it, depending on the absence or presence of the star wrapper. The other possibility is that the recognizer is the one of a defobject, of the form object-<name>-p: in this case, the star wrapper is disallowed, and the type is the one of the object. In this last case, we also return the object-<name>-p name; in all other cases, this result is nil.

    If the recognizer does not have any of the above forms, we return nil as all results. If the argument is not a variable, we also return nil as all results.

    As explained in the user documentation, we also allow the conjuncts to be wrapped with mbt. To handle these, we preliminarily conditionally unwrap the conjuncts.

    Definitions and Theorems

    Function: atc-check-guard-conjunct

    (defun atc-check-guard-conjunct (conjunct prec-tags prec-objs)
     (declare
          (xargs :guard (and (pseudo-termp conjunct)
                             (atc-string-taginfo-alistp prec-tags)
                             (atc-string-objinfo-alistp prec-objs))))
     (let ((__function__ 'atc-check-guard-conjunct))
       (declare (ignorable __function__))
       (b*
        ((conjunct (b* (((mv mbtp arg)
                         (check-mbt-call conjunct))
                        ((when mbtp) arg))
                     conjunct))
         ((when (or (variablep conjunct)
                    (fquotep conjunct)
                    (flambda-applicationp conjunct)))
          (mv nil nil nil))
         (fn (ffn-symb conjunct))
         (arg (fargn conjunct 1))
         ((mv okp pointerp recog arg)
          (if (eq fn 'star)
              (if (or (variablep arg)
                      (fquotep arg)
                      (flambda-applicationp arg))
                  (mv nil nil nil nil)
                (mv t t (ffn-symb arg) (fargn arg 1)))
            (mv t nil fn arg)))
         ((when (not okp)) (mv nil nil nil))
         ((unless (symbolp arg))
          (mv nil nil nil))
         ((mv type defobj-pred)
          (b*
            (((when (eq recog 'scharp))
              (mv (type-schar) nil))
             ((when (eq recog 'ucharp))
              (mv (type-uchar) nil))
             ((when (eq recog 'sshortp))
              (mv (type-sshort) nil))
             ((when (eq recog 'ushortp))
              (mv (type-ushort) nil))
             ((when (eq recog 'sintp))
              (mv (type-sint) nil))
             ((when (eq recog 'uintp))
              (mv (type-uint) nil))
             ((when (eq recog 'slongp))
              (mv (type-slong) nil))
             ((when (eq recog 'ulongp))
              (mv (type-ulong) nil))
             ((when (eq recog 'sllongp))
              (mv (type-sllong) nil))
             ((when (eq recog 'ullongp))
              (mv (type-ullong) nil))
             ((when (eq recog 'schar-arrayp))
              (mv (type-array (type-schar) nil) nil))
             ((when (eq recog 'uchar-arrayp))
              (mv (type-array (type-uchar) nil) nil))
             ((when (eq recog 'sshort-arrayp))
              (mv (type-array (type-sshort) nil) nil))
             ((when (eq recog 'ushort-arrayp))
              (mv (type-array (type-ushort) nil) nil))
             ((when (eq recog 'sint-arrayp))
              (mv (type-array (type-sint) nil) nil))
             ((when (eq recog 'uint-arrayp))
              (mv (type-array (type-uint) nil) nil))
             ((when (eq recog 'slong-arrayp))
              (mv (type-array (type-slong) nil) nil))
             ((when (eq recog 'ulong-arrayp))
              (mv (type-array (type-ulong) nil) nil))
             ((when (eq recog 'sllong-arrayp))
              (mv (type-array (type-sllong) nil) nil))
             ((when (eq recog 'ullong-arrayp))
              (mv (type-array (type-ullong) nil) nil))
             ((mv okp struct/object tag/name p)
              (atc-check-symbol-3part recog))
             ((unless (and okp (equal (symbol-name p) "P")))
              (mv nil nil))
             ((when (equal (symbol-name struct/object)
                           "STRUCT"))
              (b* ((tag (symbol-name tag/name))
                   (info (cdr (assoc-equal tag prec-tags)))
                   ((unless info) (mv nil nil))
                   ((unless (atc-tag-infop info))
                    (raise "Internal error: malformed ATC-TAG-INFO ~x0."
                           info)
                    (mv nil nil))
                   (info (atc-tag-info->defstruct info))
                   ((unless (eq recog
                                (defstruct-info->recognizer info)))
                    (mv nil nil))
                   ((when (and (defstruct-info->flexiblep info)
                               (not pointerp)))
                    (mv nil nil)))
                (mv (type-struct (defstruct-info->tag info))
                    nil)))
             ((when (equal (symbol-name struct/object)
                           "OBJECT"))
              (b* ((name (symbol-name tag/name))
                   (info (cdr (assoc-equal name prec-objs)))
                   ((unless info) (mv nil nil))
                   ((unless (atc-obj-infop info))
                    (raise "Internal error: malformed ATC-OBJ-INFO ~x0."
                           info)
                    (mv nil nil))
                   (info (atc-obj-info->defobject info))
                   ((unless (eq recog
                                (defobject-info->recognizer info)))
                    (mv nil nil)))
                (mv (defobject-info->type info)
                    (defobject-info->recognizer info)))))
            (mv nil nil)))
         ((unless type) (mv nil nil nil))
         ((when (and pointerp (type-case type :array)))
          (mv nil nil nil))
         (type (if pointerp (type-pointer type) type)))
        (mv type defobj-pred arg))))

    Theorem: type-optionp-of-atc-check-guard-conjunct.type

    (defthm type-optionp-of-atc-check-guard-conjunct.type
      (b* (((mv ?type ?defobj-pred ?arg)
            (atc-check-guard-conjunct conjunct prec-tags prec-objs)))
        (type-optionp type))
      :rule-classes :rewrite)

    Theorem: symbolp-of-atc-check-guard-conjunct.defobj-pred

    (defthm symbolp-of-atc-check-guard-conjunct.defobj-pred
      (b* (((mv ?type ?defobj-pred ?arg)
            (atc-check-guard-conjunct conjunct prec-tags prec-objs)))
        (symbolp defobj-pred))
      :rule-classes :rewrite)

    Theorem: symbolp-of-atc-check-guard-conjunct.arg

    (defthm symbolp-of-atc-check-guard-conjunct.arg
      (b* (((mv ?type ?defobj-pred ?arg)
            (atc-check-guard-conjunct conjunct prec-tags prec-objs)))
        (symbolp arg))
      :rule-classes :rewrite)