• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • 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
        • 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-contextualize
                    • Atc-premise
                    • Atc-contextualize-compustate
                    • Atc-context
                    • Atc-context-extend
                    • Irr-atc-context
                    • Atc-premise-list
                  • 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
            • 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
    • Atc-generation-contexts

    Atc-contextualize

    Put a formula into a context.

    Signature
    (atc-contextualize formula 
                       context fn? fn-guard? compst-var? 
                       limit-var? limit-bound? preamblep wrld) 
     
      → 
    formula1
    Arguments
    formula — An untranslated term.
    context — Guard (atc-contextp context).
    fn? — Guard (symbolp fn?).
    fn-guard? — Guard (symbolp fn-guard?).
    compst-var? — Guard (symbolp compst-var?).
    limit-var? — Guard (symbolp limit-var?).
    limit-bound? — Guard (pseudo-termp limit-bound?).
    preamblep — Guard (booleanp preamblep).
    wrld — Guard (plist-worldp wrld).
    Returns
    formula1 — An untranslated term.

    We go through the context elements, generating code for them and ending with the term given as input.

    We also add, around the resulting term from the process described above, additional premises:

    • The fact that the computation state variable is a computation state.
    • The preamble from the context.
    • The fact that the guard of the target function fn holds on the formals of the function.
    • The fact that the limit variable is an integer.
    • The fact that the limit variable is greater than or equal to a given bound (expressed as a term).

    If preamblep is nil, we omit the preamble from the context. This is used to generate some claims within the ACL2 proof builder.

    If fn-guard? is nil, we omit the guard hypothesis. This is used to generate some claims within the ACL2 proof builder. In this case, fn? must be nil too.

    If compst-var? is nil, we avoid all the premises and hypotheses that concern computation states. Some of the theorems we generate do not involve computation states: they apply just to ACL2 terms that represent shallowly embedded C code; they do not apply to relations between ACL2 terms and deeply embedded C code.

    If limit-var? is nil, we avoid the hypotheses that concern limits. Some of the theorems we generate (e.g. for pure expressions) do not involve execution recursion limits. In this case, limit-bound? must be nil too.

    Definitions and Theorems

    Function: atc-contextualize-aux

    (defun atc-contextualize-aux (formula premises skip-cs)
     (declare (xargs :guard (and (atc-premise-listp premises)
                                 (booleanp skip-cs))))
     (let ((__function__ 'atc-contextualize-aux))
      (declare (ignorable __function__))
      (b* (((when (endp premises)) formula)
           (premise (car premises)))
       (atc-premise-case
        premise :compustate
        (if skip-cs (atc-contextualize-aux formula (cdr premises)
                                           skip-cs)
         (cons 'let
               (cons (cons (cons premise.var (cons premise.term 'nil))
                           'nil)
                     (cons (atc-contextualize-aux formula (cdr premises)
                                                  skip-cs)
                           'nil))))
        :cvalue
        (cons 'let
              (cons (cons (cons premise.var (cons premise.term 'nil))
                          'nil)
                    (cons (atc-contextualize-aux formula (cdr premises)
                                                 skip-cs)
                          'nil)))
        :cvalues
        (cons
         'mv-let
         (cons premise.vars
               (cons premise.term
                     (cons (atc-contextualize-aux formula (cdr premises)
                                                  skip-cs)
                           'nil))))
        :test
        (cons 'implies
              (cons (cons 'test* (cons premise.term 'nil))
                    (cons (atc-contextualize-aux formula (cdr premises)
                                                 skip-cs)
                          'nil)))))))

    Function: atc-contextualize

    (defun atc-contextualize
           (formula context fn? fn-guard? compst-var?
                    limit-var? limit-bound? preamblep wrld)
     (declare (xargs :guard (and (atc-contextp context)
                                 (symbolp fn?)
                                 (symbolp fn-guard?)
                                 (symbolp compst-var?)
                                 (symbolp limit-var?)
                                 (pseudo-termp limit-bound?)
                                 (booleanp preamblep)
                                 (plist-worldp wrld))))
     (let ((__function__ 'atc-contextualize))
      (declare (ignorable __function__))
      (b*
       ((skip-cs (not compst-var?))
        (formula
          (atc-contextualize-aux formula (atc-context->premises context)
                                 skip-cs))
        (hyps
         (append
          (and compst-var?
               (cons (cons 'compustatep
                           (cons compst-var? 'nil))
                     'nil))
          (and preamblep
               (atc-context->preamble context))
          (and fn-guard?
               (cons (cons fn-guard? (formals+ fn? wrld))
                     'nil))
          (and
           limit-var?
           (cons (cons 'integerp (cons limit-var? 'nil))
                 (cons (cons '>=
                             (cons limit-var? (cons limit-bound? 'nil)))
                       'nil)))))
        ((when (and (not fn-guard?) fn?))
         (raise "Internal error: FN-GUARD? is NIL but FN? is ~x0."
                fn?))
        ((when (and (not limit-var?) limit-bound?))
         (raise
            "Internal error: LIMIT-VAR? is NIL but LIMIT-BOUND? is ~x0."
            limit-bound?))
        (formula (cons 'implies
                       (cons (cons 'and hyps)
                             (cons formula 'nil)))))
       formula)))