• 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-statement-generation
                  • Stmt-gin
                  • Atc-gen-term-type-formula
                  • Atc-gen-stmt
                  • Atc-gen-block-item-var-asg
                  • Atc-gen-expr
                  • Atc-gen-return-stmt
                  • Atc-gen-mbt-block-items
                  • Atc-gen-loop-stmt
                  • Atc-gen-if/ifelse-stmt
                  • Atc-gen-cfun-call-stmt
                  • Atc-gen-block-item-struct-scalar-asg
                  • Atc-gen-block-item-struct-array-asg
                  • Atc-gen-block-item-list-append
                  • Atc-gen-block-item-integer-asg
                  • Atc-gen-block-item-declon
                  • Atc-gen-block-item-array-asg
                  • Stmt-gout
                  • Atc-gen-block-item-list-cons
                  • Atc-uterm-to-components
                  • Atc-gen-block-item-stmt
                  • Lstmt-gin
                  • Atc-gen-block-item-list-one
                    • Atc-gen-block-item-var-decl
                    • Atc-gen-block-item-asg
                    • Atc-gen-call-result-and-endstate
                    • Lstmt-gout
                    • Atc-ensure-formals-not-lost
                    • Atc-gen-block-item-list-none
                    • Atc-var-assignablep
                    • Atc-gen-stmt-value-term-and-type-formula
                    • Atc-remove-extobj-args
                    • Atc-affecting-term-for-let-p
                    • Atc-vars-assignablep
                    • Atc-make-lets-of-uterms
                    • Atc-symbolp-list
                    • Atc-make-mv-nth-terms
                    • Atc-make-mv-lets-of-uterms
                    • Atc-update-var-term-alist
                    • Irr-stmt-gout
                    • Irr-lstmt-gout
                  • 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-statement-generation

    Atc-gen-block-item-list-one

    Generate a list of C block items that consists of a given item.

    Signature
    (atc-gen-block-item-list-one term type item item-limit item-events 
                                 item-thm stmt-value new-compst 
                                 new-context new-inscope gin state) 
     
      → 
    gout
    Arguments
    term — Guard (pseudo-termp term).
    type — Guard (typep type).
    item — Guard (block-itemp item).
    item-limit — Guard (pseudo-termp item-limit).
    item-events — Guard (pseudo-event-form-listp item-events).
    item-thm — Guard (symbolp item-thm).
    stmt-value — An untranslated term.
    new-compst — An untranslated term.
    new-context — Guard (atc-contextp new-context).
    new-inscope — Guard (atc-symbol-varinfo-alist-listp new-inscope).
    gin — Guard (stmt-ginp gin).
    Returns
    gout — Type (stmt-goutp gout).

    This is used to lift generated block items to generated block item lists. Besides the (singleton) block item list, we also generate a theorem saying that exec-block-item-list applied to the quoted block item list yields an mv pair consisting of a statement value term and a possibly updated computation state; these are the same as the ones for the single item theorem.

    The limit for the block item list is 1 more than the limit for the block item, because we need 1 to go from exec-block-item-list to exec-block-item.

    When this function is called on a block item that is an if that returns void, new-compst is an if* whose branches have the form (exit-scope ...) (after expanding lets). The combination of the rules compustatep-of-exit-scope and compustatep-of-if*-when-both-compustatep serves to show that compustatep holds on the if*, as needed during the proof, without having to expand the if*.

    The new-inscope input is the variable table just after the block item.

    Definitions and Theorems

    Function: atc-gen-block-item-list-one

    (defun atc-gen-block-item-list-one
           (term type item item-limit item-events
                 item-thm stmt-value new-compst
                 new-context new-inscope gin state)
     (declare (xargs :stobjs (state)))
     (declare
         (xargs :guard (and (pseudo-termp term)
                            (typep type)
                            (block-itemp item)
                            (pseudo-termp item-limit)
                            (pseudo-event-form-listp item-events)
                            (symbolp item-thm)
                            (atc-contextp new-context)
                            (atc-symbol-varinfo-alist-listp new-inscope)
                            (stmt-ginp gin))))
     (let ((__function__ 'atc-gen-block-item-list-one))
      (declare (ignorable __function__))
      (b*
       (((stmt-gin gin) gin)
        (wrld (w state))
        (items (list item))
        (items-limit (pseudo-term-fncall '+
                                         (list (pseudo-term-quote 1)
                                               item-limit)))
        ((when (not gin.proofs))
         (make-stmt-gout :items items
                         :type type
                         :term term
                         :context new-context
                         :inscope new-inscope
                         :limit items-limit
                         :events item-events
                         :thm-name nil
                         :thm-index gin.thm-index
                         :names-to-avoid gin.names-to-avoid))
        (name (pack gin.fn '-correct- gin.thm-index))
        (thm-index (1+ gin.thm-index))
        ((mv name names-to-avoid)
         (fresh-logical-name-with-$s-suffix
              name nil gin.names-to-avoid wrld))
        (voidp (type-case type :void))
        (exec-formula
         (cons
             'equal
             (cons (cons 'exec-block-item-list
                         (cons (cons 'quote (cons items 'nil))
                               (cons gin.compst-var
                                     (cons gin.fenv-var
                                           (cons gin.limit-var 'nil)))))
                   (cons (cons 'mv
                               (cons stmt-value (cons new-compst 'nil)))
                         'nil))))
        (exec-formula
             (atc-contextualize exec-formula gin.context
                                gin.fn gin.fn-guard gin.compst-var
                                gin.limit-var items-limit t wrld))
        (uterm (untranslate$ term nil state))
        ((mv type-formula &)
         (atc-gen-term-type-formula
              uterm type
              gin.affect gin.inscope gin.prec-tags))
        (type-formula
             (atc-contextualize type-formula gin.context gin.fn
                                gin.fn-guard nil nil nil nil wrld))
        (formula (cons 'and
                       (cons exec-formula (cons type-formula 'nil))))
        (hints
         (cons
          (cons
           '"Goal"
           (cons
            ':in-theory
            (cons
             (cons
              'quote
              (cons
               (cons
                'exec-block-item-list-when-consp
                (cons
                 'not-zp-of-limit-variable
                 (cons
                  'mv-nth-of-cons
                  (cons
                   '(:e zp)
                   (cons
                    'value-optionp-when-valuep
                    (cons
                     '(:e value-optionp)
                     (cons
                      '(:e valuep)
                      (append
                       (and
                        (not voidp)
                        (list
                           (atc-type-to-valuep-thm type gin.prec-tags)))
                       (cons
                        item-thm
                        '(exec-block-item-list-of-nil
                          return-type-of-stmt-value-return
                          return-type-of-stmt-value-none
                          stmt-value-return->value?-of-stmt-value-return
                          stmt-value-return-of-value-option-fix-value?
                          value-option-fix-when-value-optionp
                          not-zp-of-limit-minus-const
                          compustatep-of-exit-scope
                          compustatep-of-update-object
                          compustatep-of-update-static-var
                          compustatep-of-if*-when-both-compustatep
                          uchar-array-length-of-uchar-array-write
                          schar-array-length-of-schar-array-write
                          ushort-array-length-of-ushort-array-write
                          sshort-array-length-of-sshort-array-write
                          uint-array-length-of-uint-array-write
                          sint-array-length-of-sint-array-write
                          ulong-array-length-of-ulong-array-write
                          slong-array-length-of-slong-array-write
                          ullong-array-length-of-ullong-array-write
                          sllong-array-length-of-sllong-array-write))))))))))
               'nil))
             'nil)))
          'nil))
        ((mv event &)
         (evmac-generate-defthm name
                                :formula formula
                                :hints hints
                                :enable nil)))
       (make-stmt-gout :items items
                       :type type
                       :term term
                       :context new-context
                       :inscope new-inscope
                       :limit items-limit
                       :events (append item-events (list event))
                       :thm-name name
                       :thm-index thm-index
                       :names-to-avoid names-to-avoid))))

    Theorem: stmt-goutp-of-atc-gen-block-item-list-one

    (defthm stmt-goutp-of-atc-gen-block-item-list-one
      (b* ((gout (atc-gen-block-item-list-one
                      term type item item-limit item-events
                      item-thm stmt-value new-compst
                      new-context new-inscope gin state)))
        (stmt-goutp gout))
      :rule-classes :rewrite)