• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • 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
          • 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-loop-call

    Check if a term may represent a C loop.

    Signature
    (atc-check-loop-call term var-term-alist prec-fns) 
      → 
    (mv yes/no fn args in-types affect loop limit)
    Arguments
    term — Guard (pseudo-termp term).
    var-term-alist — Guard (symbol-pseudoterm-alistp var-term-alist).
    prec-fns — Guard (atc-symbol-fninfo-alistp prec-fns).
    Returns
    yes/no — Type (booleanp yes/no).
    fn — Type (symbolp fn).
    args — Type (pseudo-term-listp args).
    in-types — Type (type-listp in-types).
    affect — Type (symbol-listp affect).
    loop — Type (stmtp loop).
    limit — Type (pseudo-termp limit).

    We check whether this is a call of a function that has been previously processed (i.e. it is in the prec-fns alist) and is recursive (indicated by the presence of the loop statement in its information). If the checks succeed, we return the function symbol, its arguments, the argument types, the variables affected by the loop, the associated loop statement, and the limit sufficient to execute the function call.

    The limit retrieved from the function table refers to the formal parameters. We must instantiate it to the actual parameters in order to obtain an appropriate limit for the call, but we also need to substitute all the bindings in order to obtain the real arguments of the call from the point of view of the top level of where this call term occurs.

    Definitions and Theorems

    Function: atc-check-loop-call

    (defun atc-check-loop-call (term var-term-alist prec-fns)
      (declare
           (xargs :guard (and (pseudo-termp term)
                              (symbol-pseudoterm-alistp var-term-alist)
                              (atc-symbol-fninfo-alistp prec-fns))))
      (let ((__function__ 'atc-check-loop-call))
        (declare (ignorable __function__))
        (b* (((acl2::fun (no))
              (mv nil nil nil nil nil (irr-stmt) nil))
             ((unless (pseudo-term-case term :fncall))
              (no))
             ((pseudo-term-fncall term) term)
             (fn+info (assoc-eq term.fn
                                (atc-symbol-fninfo-alist-fix prec-fns)))
             ((unless (consp fn+info)) (no))
             (info (cdr fn+info))
             (loop (atc-fn-info->loop? info))
             ((unless (stmtp loop)) (no))
             (in-types (atc-fn-info->in-types info))
             (affect (atc-fn-info->affect info))
             (limit (atc-fn-info->limit info))
             (limit (fty-fsublis-var var-term-alist limit)))
          (mv t term.fn
              term.args in-types affect loop limit))))

    Theorem: booleanp-of-atc-check-loop-call.yes/no

    (defthm booleanp-of-atc-check-loop-call.yes/no
      (b* (((mv ?yes/no ?fn acl2::?args ?in-types
                ?affect common-lisp::?loop ?limit)
            (atc-check-loop-call term var-term-alist prec-fns)))
        (booleanp yes/no))
      :rule-classes :rewrite)

    Theorem: symbolp-of-atc-check-loop-call.fn

    (defthm symbolp-of-atc-check-loop-call.fn
      (b* (((mv ?yes/no ?fn acl2::?args ?in-types
                ?affect common-lisp::?loop ?limit)
            (atc-check-loop-call term var-term-alist prec-fns)))
        (symbolp fn))
      :rule-classes :rewrite)

    Theorem: pseudo-term-listp-of-atc-check-loop-call.args

    (defthm pseudo-term-listp-of-atc-check-loop-call.args
      (b* (((mv ?yes/no ?fn acl2::?args ?in-types
                ?affect common-lisp::?loop ?limit)
            (atc-check-loop-call term var-term-alist prec-fns)))
        (pseudo-term-listp args))
      :rule-classes :rewrite)

    Theorem: type-listp-of-atc-check-loop-call.in-types

    (defthm type-listp-of-atc-check-loop-call.in-types
      (b* (((mv ?yes/no ?fn acl2::?args ?in-types
                ?affect common-lisp::?loop ?limit)
            (atc-check-loop-call term var-term-alist prec-fns)))
        (type-listp in-types))
      :rule-classes :rewrite)

    Theorem: symbol-listp-of-atc-check-loop-call.affect

    (defthm symbol-listp-of-atc-check-loop-call.affect
      (b* (((mv ?yes/no ?fn acl2::?args ?in-types
                ?affect common-lisp::?loop ?limit)
            (atc-check-loop-call term var-term-alist prec-fns)))
        (symbol-listp affect))
      :rule-classes :rewrite)

    Theorem: stmtp-of-atc-check-loop-call.loop

    (defthm stmtp-of-atc-check-loop-call.loop
      (b* (((mv ?yes/no ?fn acl2::?args ?in-types
                ?affect common-lisp::?loop ?limit)
            (atc-check-loop-call term var-term-alist prec-fns)))
        (stmtp loop))
      :rule-classes :rewrite)

    Theorem: pseudo-termp-of-atc-check-loop-call.limit

    (defthm pseudo-termp-of-atc-check-loop-call.limit
      (b* (((mv ?yes/no ?fn acl2::?args ?in-types
                ?affect common-lisp::?loop ?limit)
            (atc-check-loop-call term var-term-alist prec-fns)))
        (pseudo-termp limit))
      :rule-classes :rewrite)