• 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
                • Atc-gen-fileset
                • Atc-gen-everything
                • Atc-gen-obj-declon
                • Atc-gen-fileset-event
                • Atc-tag-tables
                • Atc-expression-generation
                  • Atc-gen-expr-struct-read-array
                  • Atc-gen-expr-pure/bool
                  • Atc-gen-expr-integer-read
                  • Atc-gen-expr-cond
                  • Atc-gen-expr-binary
                  • Atc-gen-expr-or
                  • Atc-gen-expr-array-read
                  • Expr-gin
                  • Exprs-gin
                  • Atc-gen-expr-and
                  • Atc-gen-expr-struct-read-scalar
                  • Exprs-gout
                  • Atc-gen-expr-unary
                  • Atc-gen-expr-conv
                  • Expr-gout
                  • Atc-gen-expr-bool-from-type
                  • Atc-gen-expr-sint-from-bool
                  • Atc-gen-expr-const
                  • Atc-gen-expr-var
                    • Atc-gen-expr-pure-list
                    • Irr-exprs-gout
                    • Irr-expr-gout
                  • 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-expression-generation

    Atc-gen-expr-var

    Generate a C expression from an ACL2 variable.

    Signature
    (atc-gen-expr-var var gin state) → gout
    Arguments
    var — Guard (symbolp var).
    gin — Guard (expr-ginp gin).
    Returns
    gout — Type (expr-goutp gout).

    An ACL2 variable is translated to a C variable. Its information is looked up in the symbol table.

    If the variable has pointer or array type and is not an external object, its correctness theorem equates it to the -ptr variable, because the variable itself contains the pointed object or array.

    Definitions and Theorems

    Function: atc-gen-expr-var

    (defun atc-gen-expr-var (var gin state)
     (declare (xargs :stobjs (state)))
     (declare (xargs :guard (and (symbolp var) (expr-ginp gin))))
     (let ((__function__ 'atc-gen-expr-var))
      (declare (ignorable __function__))
      (b*
       (((expr-gin gin) gin)
        (info (atc-get-var var gin.inscope))
        ((when (not info))
         (raise
          "Internal error: the variable ~x0 in function ~x1 ~
                    has no associated information."
          var gin.fn)
         (irr-expr-gout))
        (type (atc-var-info->type info))
        (var-thm (atc-var-info->thm info))
        (expr (expr-ident (make-ident :name (symbol-name var))))
        ((when (not gin.proofs))
         (make-expr-gout :expr expr
                         :type type
                         :term var
                         :events nil
                         :thm-name nil
                         :thm-index gin.thm-index
                         :names-to-avoid gin.names-to-avoid))
        (hints
         (cons
          (cons
           '"Goal"
           (cons
            ':in-theory
            (cons
             (cons
                'quote
                (cons (cons var-thm
                            '(exec-expr-pure-when-ident
                                  (:e expr-kind)
                                  (:e expr-ident->get)
                                  exec-ident-open-via-object (:e identp)
                                  (:e ident->name)
                                  objdesign-of-var-of-const-identifier))
                      'nil))
             'nil)))
          'nil))
        (objdes
            (cons 'objdesign-of-var
                  (cons (cons 'ident
                              (cons (cons 'quote
                                          (cons (symbol-name var) 'nil))
                                    'nil))
                        (cons gin.compst-var 'nil))))
        ((mv thm-event
             thm-name thm-index names-to-avoid)
         (atc-gen-expr-pure-correct-thm
              gin.fn
              gin.fn-guard gin.context expr type
              (if (and (or (type-case type :pointer)
                           (type-case type :array))
                       (not (atc-var-info->externalp info)))
                  (add-suffix-to-fn var "-PTR")
                var)
              var objdes gin.compst-var
              hints nil gin.prec-tags gin.thm-index
              gin.names-to-avoid state)))
       (make-expr-gout :expr expr
                       :type type
                       :term var
                       :events (list thm-event)
                       :thm-name thm-name
                       :thm-index thm-index
                       :names-to-avoid names-to-avoid))))

    Theorem: expr-goutp-of-atc-gen-expr-var

    (defthm expr-goutp-of-atc-gen-expr-var
      (b* ((gout (atc-gen-expr-var var gin state)))
        (expr-goutp gout))
      :rule-classes :rewrite)