Generate a context preamble from the formals of a function.
(atc-gen-context-preamble typed-formals compst-var fenv-var prog-const) → terms
As explained in atc-context, the logical contexts for the generated theorems includes a preamble of premises that is a list of untranslated terms. This is calculated from the typed formals of the ACL2 function that is translated to a C function.
For each formal
In addition, for each formal
For each formal
For each formal
Function:
(defun atc-gen-context-preamble-aux-aux (this-var-ptr typed-formals-rest) (declare (xargs :guard (and (symbolp this-var-ptr) (atc-symbol-varinfo-alistp typed-formals-rest)))) (let ((__function__ 'atc-gen-context-preamble-aux-aux)) (declare (ignorable __function__)) (b* (((when (endp typed-formals-rest)) nil) ((cons other-var other-info) (car typed-formals-rest))) (if (and (member-equal (type-kind (atc-var-info->type other-info)) '(:pointer :array)) (not (atc-var-info->externalp other-info))) (cons (cons 'object-disjointp (cons (cons 'value-pointer->designator (cons this-var-ptr 'nil)) (cons (cons 'value-pointer->designator (cons (add-suffix-to-fn other-var "-PTR") 'nil)) 'nil))) (atc-gen-context-preamble-aux-aux this-var-ptr (cdr typed-formals-rest))) (atc-gen-context-preamble-aux-aux this-var-ptr (cdr typed-formals-rest))))))
Theorem:
(defthm true-listp-of-atc-gen-context-preamble-aux-aux (b* ((terms (atc-gen-context-preamble-aux-aux this-var-ptr typed-formals-rest))) (true-listp terms)) :rule-classes :rewrite)
Function:
(defun atc-gen-context-preamble-aux (typed-formals compst-var) (declare (xargs :guard (and (atc-symbol-varinfo-alistp typed-formals) (symbolp compst-var)))) (let ((__function__ 'atc-gen-context-preamble-aux)) (declare (ignorable __function__)) (b* (((when (endp typed-formals)) (mv nil nil)) ((cons var info) (car typed-formals)) (type (atc-var-info->type info)) (externalp (atc-var-info->externalp info)) ((mv terms-about-this-formal terms-about-this-and-other-formals) (if externalp (mv (cons (cons 'equal (cons var (cons (cons 'read-object (cons (cons 'objdesign-static (cons (cons 'ident (cons (symbol-name var) 'nil)) 'nil)) (cons compst-var 'nil))) 'nil))) 'nil) nil) (if (member-eq (type-kind type) '(:pointer :array)) (b* ((var-ptr (add-suffix-to-fn var "-PTR")) (var-objdes (add-suffix-to-fn var "-OBJDES")) (reftype (if (type-case type :pointer) (type-pointer->to type) (type-array->of type))) (terms-about-this-formal (cons (cons 'valuep (cons var-ptr 'nil)) (cons (cons 'equal (cons (cons 'value-kind (cons var-ptr 'nil)) '(:pointer))) (cons (cons 'value-pointer-validp (cons var-ptr 'nil)) (cons (cons 'equal (cons var-objdes (cons (cons 'value-pointer->designator (cons var-ptr 'nil)) 'nil))) (cons (cons 'equal (cons (cons 'objdesign-kind (cons var-objdes 'nil)) '(:alloc))) (cons (cons 'equal (cons (cons 'value-pointer->reftype (cons var-ptr 'nil)) (cons (type-to-maker reftype) 'nil))) (cons (cons 'equal (cons var (cons (cons 'read-object (cons var-objdes (cons compst-var 'nil))) 'nil))) 'nil)))))))) (terms-about-this-and-other-formals (atc-gen-context-preamble-aux-aux var-ptr (cdr typed-formals)))) (mv terms-about-this-formal terms-about-this-and-other-formals)) (mv nil nil)))) ((mv more-terms-about-single-formals more-terms-about-formal-pairs) (atc-gen-context-preamble-aux (cdr typed-formals) compst-var))) (mv (append terms-about-this-formal more-terms-about-single-formals) (append terms-about-this-and-other-formals more-terms-about-formal-pairs)))))
Theorem:
(defthm true-listp-of-atc-gen-context-preamble-aux.terms-about-single-formals (b* (((mv ?terms-about-single-formals ?terms-about-formal-pairs) (atc-gen-context-preamble-aux typed-formals compst-var))) (true-listp terms-about-single-formals)) :rule-classes :rewrite)
Theorem:
(defthm true-listp-of-atc-gen-context-preamble-aux.terms-about-formal-pairs (b* (((mv ?terms-about-single-formals ?terms-about-formal-pairs) (atc-gen-context-preamble-aux typed-formals compst-var))) (true-listp terms-about-formal-pairs)) :rule-classes :rewrite)
Function:
(defun atc-gen-context-preamble (typed-formals compst-var fenv-var prog-const) (declare (xargs :guard (and (atc-symbol-varinfo-alistp typed-formals) (symbolp compst-var) (symbolp fenv-var) (symbolp prog-const)))) (let ((__function__ 'atc-gen-context-preamble)) (declare (ignorable __function__)) (b* (((mv terms-about-single-formals terms-about-formal-pairs) (atc-gen-context-preamble-aux typed-formals compst-var))) (append (list (cons 'equal (cons fenv-var (cons (cons 'init-fun-env (cons (cons 'preprocess (cons prog-const 'nil)) 'nil)) 'nil)))) terms-about-single-formals terms-about-formal-pairs))))
Theorem:
(defthm true-listp-of-atc-gen-context-preamble (b* ((terms (atc-gen-context-preamble typed-formals compst-var fenv-var prog-const))) (true-listp terms)) :rule-classes :rewrite)