Generate an updated symbol table according to given criteria.
(atc-gen-new-inscope fn fn-guard inscope new-context compst-var rules prec-tags thm-index names-to-avoid wrld) → (mv new-inscope events names-to-avoid)
The initial symbol table is generated by atc-gen-init-inscope; see the documentation of that function. As we process ACL2 terms that represent C constructs, sometimes we need to generate an updated symbol table, which is mostly the same as the one just before the update, but with new theorems about the variables in it. For instance, when entering a scope, the new symbol table is almost the same, with the addition of a new empty scope; but the theorems about the variables in scope must be rephrased to be about the computation state updated with the new scope.
This ACL2 function goes through the given symbol table
The input context
The theorems of the updated symbol table are generated here.
They say that reading each C variable
yields the corresponding ACL2 variable
or the
Since the generated theorem names involve the names of the variables, which are always distinct in a symbol table generated by ATC, we use the same theorem index for all the theorems.
Function:
(defun atc-gen-new-inscope-aux (fn fn-guard scope new-context compst-var rules prec-tags thm-index names-to-avoid wrld) (declare (xargs :guard (and (symbolp fn) (symbolp fn-guard) (atc-symbol-varinfo-alistp scope) (atc-contextp new-context) (symbolp compst-var) (true-listp rules) (atc-string-taginfo-alistp prec-tags) (posp thm-index) (symbol-listp names-to-avoid) (plist-worldp wrld)))) (let ((__function__ 'atc-gen-new-inscope-aux)) (declare (ignorable __function__)) (b* (((when (endp scope)) (mv nil nil names-to-avoid)) ((cons var info) (car scope)) (type (atc-var-info->type info)) (thm (atc-var-info->thm info)) (externalp (atc-var-info->externalp info)) (type-pred (atc-type-to-recognizer type prec-tags)) (new-thm (pack fn '- var '-in-scope- thm-index)) ((mv new-thm names-to-avoid) (fresh-logical-name-with-$s-suffix new-thm nil names-to-avoid wrld)) (var/varptr (if (and (or (type-case type :pointer) (type-case type :array)) (not externalp)) (add-suffix-to-fn var "-PTR") var)) (formula1 (cons 'and (cons (cons 'objdesign-of-var (cons (cons 'ident (cons (symbol-name var) 'nil)) (cons compst-var 'nil))) (cons (cons 'equal (cons (cons 'read-object (cons (cons 'objdesign-of-var (cons (cons 'ident (cons (symbol-name var) 'nil)) (cons compst-var 'nil))) (cons compst-var 'nil))) (cons var/varptr 'nil))) (and (or (type-case type :pointer) (type-case type :array)) (not externalp) (cons (cons 'equal (cons (cons 'read-object (cons (add-suffix-to-fn var "-OBJDES") (cons compst-var 'nil))) (cons var 'nil))) 'nil)))))) (formula1 (atc-contextualize formula1 new-context fn fn-guard compst-var nil nil t wrld)) (formula2 (cons type-pred (cons var 'nil))) (formula2 (atc-contextualize formula2 new-context fn fn-guard nil nil nil nil wrld)) (formula (cons 'and (cons formula1 (cons formula2 'nil)))) (hints (cons (cons '"Goal" (cons ':in-theory (cons (cons 'quote (cons (cons thm rules) 'nil)) 'nil))) 'nil)) ((mv event &) (evmac-generate-defthm new-thm :formula formula :hints hints :enable nil)) (new-info (change-atc-var-info info :thm new-thm)) (rest (cdr scope)) ((mv new-rest events names-to-avoid) (atc-gen-new-inscope-aux fn fn-guard rest new-context compst-var rules prec-tags thm-index names-to-avoid wrld))) (mv (acons var new-info new-rest) (cons event events) names-to-avoid))))
Theorem:
(defthm atc-symbol-varinfo-alistp-of-atc-gen-new-inscope-aux.new-scope (implies (atc-symbol-varinfo-alistp scope) (b* (((mv ?new-scope ?events ?names-to-avoid) (atc-gen-new-inscope-aux fn fn-guard scope new-context compst-var rules prec-tags thm-index names-to-avoid wrld))) (atc-symbol-varinfo-alistp new-scope))) :rule-classes :rewrite)
Theorem:
(defthm pseudo-event-form-listp-of-atc-gen-new-inscope-aux.events (b* (((mv ?new-scope ?events ?names-to-avoid) (atc-gen-new-inscope-aux fn fn-guard scope new-context compst-var rules prec-tags thm-index names-to-avoid wrld))) (pseudo-event-form-listp events)) :rule-classes :rewrite)
Theorem:
(defthm symbol-listp-of-atc-gen-new-inscope-aux.names-to-avoid (implies (symbol-listp names-to-avoid) (b* (((mv ?new-scope ?events ?names-to-avoid) (atc-gen-new-inscope-aux fn fn-guard scope new-context compst-var rules prec-tags thm-index names-to-avoid wrld))) (symbol-listp names-to-avoid))) :rule-classes :rewrite)
Function:
(defun atc-gen-new-inscope (fn fn-guard inscope new-context compst-var rules prec-tags thm-index names-to-avoid wrld) (declare (xargs :guard (and (symbolp fn) (symbolp fn-guard) (atc-symbol-varinfo-alist-listp inscope) (atc-contextp new-context) (symbolp compst-var) (true-listp rules) (atc-string-taginfo-alistp prec-tags) (posp thm-index) (symbol-listp names-to-avoid) (plist-worldp wrld)))) (let ((__function__ 'atc-gen-new-inscope)) (declare (ignorable __function__)) (b* (((when (endp inscope)) (mv nil nil names-to-avoid)) (scope (car inscope)) ((mv new-scope events names-to-avoid) (atc-gen-new-inscope-aux fn fn-guard scope new-context compst-var rules prec-tags thm-index names-to-avoid wrld)) (scopes (cdr inscope)) ((mv new-scopes more-events names-to-avoid) (atc-gen-new-inscope fn fn-guard scopes new-context compst-var rules prec-tags thm-index names-to-avoid wrld))) (mv (cons new-scope new-scopes) (append events more-events) names-to-avoid))))
Theorem:
(defthm atc-symbol-varinfo-alist-listp-of-atc-gen-new-inscope.new-inscope (implies (atc-symbol-varinfo-alist-listp inscope) (b* (((mv ?new-inscope ?events ?names-to-avoid) (atc-gen-new-inscope fn fn-guard inscope new-context compst-var rules prec-tags thm-index names-to-avoid wrld))) (atc-symbol-varinfo-alist-listp new-inscope))) :rule-classes :rewrite)
Theorem:
(defthm pseudo-event-form-listp-of-atc-gen-new-inscope.events (b* (((mv ?new-inscope ?events ?names-to-avoid) (atc-gen-new-inscope fn fn-guard inscope new-context compst-var rules prec-tags thm-index names-to-avoid wrld))) (pseudo-event-form-listp events)) :rule-classes :rewrite)
Theorem:
(defthm symbol-listp-of-atc-gen-new-inscope.names-to-avoid (implies (symbol-listp names-to-avoid) (b* (((mv ?new-inscope ?events ?names-to-avoid) (atc-gen-new-inscope fn fn-guard inscope new-context compst-var rules prec-tags thm-index names-to-avoid wrld))) (symbol-listp names-to-avoid))) :rule-classes :rewrite)