Codebase list cafeobj / 35ce207
Improved checking extra variables in RHS. Vars introduced by := are no harm, but for other cases, system marks them as 'bad' and does not use them in rewriting. tswd 8 years ago
2 changed file(s) with 13 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
591591 rule)
592592 (loop
593593 (setq rule (car rr-current))
594 (when (apply-rule rule term)
595 (setq rr-mark rr-current)
596 (loop (unless (apply-rule rule term) (return nil))))
597 (setq rr-current (cdr rr-current))
598 (when (eq rr-current rr-mark) (return nil)))))))
594 (unless (eq (axiom-kind rule) :bad-rule)
595 (when (apply-rule rule term)
596 (setq rr-mark rr-current)
597 (loop (unless (apply-rule rule term) (return nil))))
598 (setq rr-current (cdr rr-current))
599 (when (eq rr-current rr-mark) (return nil))))))))
599600
600601 (defun apply-rules-with-different-top (term rules)
601602 (declare (type term term)
603604 (values (or null t)))
604605 (block the-end
605606 (dolist (rule rules nil)
606 (when (apply-rule rule term) (return-from the-end t)))))
607 (unless (eq (axiom-kind rule) :bad-rule)
608 (when (apply-rule rule term) (return-from the-end t))))))
607609
608610 (defun apply-rules (term strategy)
609611 (declare (type term term)
116116 (cond ((and lhsv
117117 (or (not (subsetp rhs-vars lhsv))
118118 (not (subsetp cond-vars lhsv))))
119 (if (or (term-contains-match-op (axiom-lhs rule))
120 (term-contains-match-op (axiom-rhs rule)))
119 (if (or (term-contains-match-op (axiom-rhs rule))
120 (term-contains-match-op (axiom-condition rule)))
121121 ;; it's ok to have extra variables in RHS side.
122122 (progn
123123 (add-rule-to-module module rule)
126126 (term-head (axiom-lhs rule))
127127 rule)
128128 (specialize-rule rule module)))
129 ;; else we don't allow it
129 ;; else we don't allow it as rewrite rule
130130 (progn
131131 (setf (axiom-kind rule) ':bad-rule)
132 (add-rule-to-module module rule)
132133 (with-output-chaos-warning ()
133134 (format t "RHS of the axiom has extra variable(s) which does not occur in LHS.")
134 (format t "~%... ignored.")
135 (format t "~%... ignored as rewrite rule.")
135136 (return-from gen-rule-internal nil)))))
136137 ((and (axiom-is-behavioural rule)
137138 (not (and (term-can-be-in-beh-axiom? (axiom-lhs rule))