Calculate the rules from a list of rules that transitively define names in a list of rule names, collecting them into an accumulator (list of rules).
(calc-trans-rules-of-names workset accumulator rules) → result
This is a work set algorithm.
When the work set is empty,
we are done and we return the rules collected so far.
Otherwise, we remove one rule name from the work set
and take out of
The algorithm makes progress
either by reducing the length of
Function:
(defun calc-trans-rules-of-names (workset accumulator rules) (declare (xargs :guard (and (rulename-setp workset) (rulelistp accumulator) (rulelistp rules)))) (b* (((when (emptyp workset)) (rulelist-fix accumulator)) (rulename (head workset)) (workset (tail workset)) ((mv rulename-rules other-rules) (rules-of-name rulename rules)) ((when (not rulename-rules)) (calc-trans-rules-of-names workset accumulator rules)) (workset (union workset (rulelist-called-rules rulename-rules))) (accumulator (append accumulator rulename-rules))) (calc-trans-rules-of-names workset accumulator other-rules)))
Theorem:
(defthm rulelistp-of-calc-trans-rules-of-names (b* ((result (calc-trans-rules-of-names workset accumulator rules))) (rulelistp result)) :rule-classes :rewrite)