Collect all the functions in a term, in the course of the worklist algorithm.
(atj-collect-fns-in-term term gen? worklist-gen worklist-chk called-fns collected-gen collected-chk deep$ guards$) → (mv new-worklist-gen new-worklist-chk new-called-fns unsuppported-return-last?)
See the overview of the worklist algorithm first.
This is called on the defining body of the function removed from the worklist, and recursively on subterms of the defining body.
Besides the term, this function takes as arguments
the two worklists and the two collected lists:
the
This function also takes an argument flag
Since variables and quoted constants contain no functions, we return the worklists unchanged in these cases.
A term
A term
If we encounter a call of return-last of some other form,
we immediately return because such other forms are not supported.
In this case, the third result of the function is set to
If we encounter a call of anything other than return-last, we recursively process the arguments, propagating any error signaled by the third result.
If the call is of a lambda expression, we conclude by recursively processing the body of the lambda expression.
Otherwise, the call is of a named function (not return-last).
We add the function to the appropriate worklist
(the exact worklist is determined by the
We also return a duplicate-free list of the function symbols called by the term for which Java code must be generated.
Theorem:
(defthm return-type-of-atj-collect-fns-in-term.new-worklist-gen (implies (and (pseudo-termp term) (booleanp gen?) (symbol-listp worklist-gen) (symbol-listp worklist-chk) (symbol-listp called-fns) (symbol-listp collected-gen) (symbol-listp collected-chk) (booleanp deep$) (booleanp guards$)) (b* (((mv ?new-worklist-gen ?new-worklist-chk ?new-called-fns ?unsuppported-return-last?) (atj-collect-fns-in-term term gen? worklist-gen worklist-chk called-fns collected-gen collected-chk deep$ guards$))) (symbol-listp new-worklist-gen))) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-atj-collect-fns-in-term.new-worklist-chk (implies (and (pseudo-termp term) (booleanp gen?) (symbol-listp worklist-gen) (symbol-listp worklist-chk) (symbol-listp called-fns) (symbol-listp collected-gen) (symbol-listp collected-chk) (booleanp deep$) (booleanp guards$)) (b* (((mv ?new-worklist-gen ?new-worklist-chk ?new-called-fns ?unsuppported-return-last?) (atj-collect-fns-in-term term gen? worklist-gen worklist-chk called-fns collected-gen collected-chk deep$ guards$))) (symbol-listp new-worklist-chk))) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-atj-collect-fns-in-term.new-called-fns (implies (and (pseudo-termp term) (booleanp gen?) (symbol-listp worklist-gen) (symbol-listp worklist-chk) (symbol-listp called-fns) (symbol-listp collected-gen) (symbol-listp collected-chk) (booleanp deep$) (booleanp guards$)) (b* (((mv ?new-worklist-gen ?new-worklist-chk ?new-called-fns ?unsuppported-return-last?) (atj-collect-fns-in-term term gen? worklist-gen worklist-chk called-fns collected-gen collected-chk deep$ guards$))) (symbol-listp new-called-fns))) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-atj-collect-fns-in-term.unsuppported-return-last? (b* (((mv ?new-worklist-gen ?new-worklist-chk ?new-called-fns ?unsuppported-return-last?) (atj-collect-fns-in-term term gen? worklist-gen worklist-chk called-fns collected-gen collected-chk deep$ guards$))) (booleanp unsuppported-return-last?)) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-atj-collect-fns-in-terms.new-worklist-gen (implies (and (pseudo-term-listp terms) (booleanp gen?) (symbol-listp worklist-gen) (symbol-listp worklist-chk) (symbol-listp called-fns) (symbol-listp collected-gen) (symbol-listp collected-chk) (booleanp deep$) (booleanp guards$)) (b* (((mv ?new-worklist-gen ?new-worklist-chk ?new-called-fns ?unsuppported-return-last?) (atj-collect-fns-in-terms terms gen? worklist-gen worklist-chk called-fns collected-gen collected-chk deep$ guards$))) (symbol-listp new-worklist-gen))) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-atj-collect-fns-in-terms.new-worklist-chk (implies (and (pseudo-term-listp terms) (booleanp gen?) (symbol-listp worklist-gen) (symbol-listp worklist-chk) (symbol-listp called-fns) (symbol-listp collected-gen) (symbol-listp collected-chk) (booleanp deep$) (booleanp guards$)) (b* (((mv ?new-worklist-gen ?new-worklist-chk ?new-called-fns ?unsuppported-return-last?) (atj-collect-fns-in-terms terms gen? worklist-gen worklist-chk called-fns collected-gen collected-chk deep$ guards$))) (symbol-listp new-worklist-chk))) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-atj-collect-fns-in-terms.new-called-fns (implies (and (pseudo-term-listp terms) (booleanp gen?) (symbol-listp worklist-gen) (symbol-listp worklist-chk) (symbol-listp called-fns) (symbol-listp collected-gen) (symbol-listp collected-chk) (booleanp deep$) (booleanp guards$)) (b* (((mv ?new-worklist-gen ?new-worklist-chk ?new-called-fns ?unsuppported-return-last?) (atj-collect-fns-in-terms terms gen? worklist-gen worklist-chk called-fns collected-gen collected-chk deep$ guards$))) (symbol-listp new-called-fns))) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-atj-collect-fns-in-terms.unsuppported-return-last? (b* (((mv ?new-worklist-gen ?new-worklist-chk ?new-called-fns ?unsuppported-return-last?) (atj-collect-fns-in-terms terms gen? worklist-gen worklist-chk called-fns collected-gen collected-chk deep$ guards$))) (booleanp unsuppported-return-last?)) :rule-classes :rewrite)