Treatment of =*= proof in which match method is not computed yet.
This is symptomatic treatment, no fundamental fix. Had no problem prior 1.5.3.
tswd
8 years ago
263 | 263 | ;;; BASIC PROCS for REWRITE RULE APPLICATION |
264 | 264 | (defvar *memo-debug* nil) |
265 | 265 | |
266 | #| NOT USED | |
267 | (defmacro term-replace-with-memo (old new) | |
268 | (once-only (old new) | |
269 | ` (if (and (not (term-is-builtin-constant? ,old)) | |
270 | (or *always-memo* | |
271 | (method-has-memo (term-head ,old)))) | |
272 | (let ((term-memo (simple-copy-term ,old))) | |
273 | (when *memo-debug* | |
274 | (when (term-equational-equal term-memo ,new) | |
275 | (with-output-chaos-warning () | |
276 | (format t "E-E term is about to hashed!") | |
277 | (terpri) | |
278 | (term-print-with-sort ,new))) | |
279 | (format t "~%[memo]: ") | |
280 | (term-print-with-sort term-memo) | |
281 | (format t "~% ==> ") | |
282 | (term-print-with-sort ,new)) | |
283 | (set-hashed-term term-memo *term-memo-table* ,new) | |
284 | (term-replace ,old ,new)) | |
285 | (term-replace ,old ,new)))) | |
286 | |# | |
287 | ||
288 | 266 | (declaim (inline term-replace-dd-simple)) |
289 | 267 | #-gcl |
290 | 268 | (defun term-replace-dd-simple (old new) |
339 | 317 | (rhs-instance nil)) |
340 | 318 | (multiple-value-bind (global-state subst no-match E-equal) |
341 | 319 | ;; first we find matching rewrite rule |
342 | (funcall (rule-first-match-method rule) (rule-lhs rule) term) | |
320 | (funcall (or (rule-first-match-method rule) | |
321 | (progn | |
322 | (with-output-chaos-warning () | |
323 | (format t "Internal, no 'matching-mehod' is assigned for:") | |
324 | (print-next) | |
325 | (print-axiom-brief rule)) | |
326 | (compute-rule-method rule) | |
327 | (rule-first-match-method rule))) | |
328 | (rule-lhs rule) | |
329 | term) | |
343 | 330 | ;; stat, count up number of matching trials |
344 | 331 | (incf $$matches) |
345 | 332 | (setq *cafein-current-subst* subst) ; I don't remember for what this is used |
816 | 803 | ;; return t iff the rule is applied. |
817 | 804 | is-applied)) |
818 | 805 | |
819 | #|| -- moved to reducer.lisp | |
820 | (defun simplify-on-top (term) | |
821 | (declare (type term term) | |
822 | (values t)) | |
823 | (if (term-is-application-form? term) | |
824 | (apply-rules-with-different-top term | |
825 | (method-rules-with-different-top | |
826 | (term-method term))) | |
827 | term)) | |
828 | ||# | |
829 | ||
830 | 806 | ;;; |
831 | 807 | ;;; REWRITE ENGINE |
832 | 808 | ;;; |
843 | 819 | (declare (type term term) |
844 | 820 | (type list strategy) |
845 | 821 | (values (or null t))) |
846 | ;; | |
847 | 822 | (when *rewrite-debug* |
848 | 823 | (with-output-simple-msg () |
849 | 824 | (format t "[reduce-term](NF=~a,LP=~a): " (term-is-reduced? term) (term-is-lowest-parsed? term)) |
857 | 832 | (unless (term-is-lowest-parsed? term) |
858 | 833 | (multiple-value-bind (xterm assoc?) |
859 | 834 | (update-lowest-parse term) |
835 | (declare (ignore xterm)) | |
860 | 836 | (when (or assoc? |
861 | 837 | (not (method= (term-method term) top))) |
862 | 838 | (when *rewrite-debug* |
1643 | 1619 | (setq $$term saved-$$term) |
1644 | 1620 | term)))) |
1645 | 1621 | |
1646 | ;;; **** | |
1647 | ;;; INIT | |
1648 | ;;; **** | |
1649 | ;;;(eval-when (:execute :load-toplevel) | |
1650 | ;;; (setf (symbol-function 'apply-one-rule) | |
1651 | ;;; #'apply-one-rule-simple)) | |
1652 | ||
1653 | 1622 | ;;; EOF |
1654 | 1623 |
471 | 471 | ;;; |
472 | 472 | (defun compute-rule-method (rule) |
473 | 473 | (declare (type axiom rule) |
474 | (values t)) | |
474 | (values t)) | |
475 | (when *on-axiom-debug* | |
476 | (format t "~%[CRM] compute rule method") | |
477 | (format t "~% (~x) " (addr-of rule)) | |
478 | (print-axiom-brief rule)) | |
475 | 479 | (let ((m (choose-match-method (axiom-lhs rule) |
476 | (axiom-condition rule) | |
477 | (axiom-kind rule)))) | |
480 | (axiom-condition rule) | |
481 | (axiom-kind rule)))) | |
478 | 482 | (setf (axiom-first-match-method rule) (car m)) |
479 | 483 | (setf (axiom-next-match-method rule) (cdr m)) |
480 | 484 | rule)) |
481 | ||
485 | ||
482 | 486 | ;;; RULE-COPY : rule -> rule |
483 | 487 | ;;;----------------------------------------------------------------------------- |
484 | 488 | ;;; Returns a copy of "rule". The variable occuring in the rule are also |
614 | 618 | (values list)) |
615 | 619 | (do* ((lst rs (cdr lst)) |
616 | 620 | (r (car lst) (car lst))) |
617 | ((null lst) (cons rule rs)) | |
621 | ((null lst) (cons rule rs)) | |
618 | 622 | (when (rule-is-similar? rule r) |
619 | (when (and *chaos-verbose* | |
623 | (when (and (or *chaos-verbose* *on-axiom-debug*) | |
620 | 624 | (not (eq rule r)) |
621 | 625 | (not (member (axiom-kind rule) .ext-rule-kinds.))) |
622 | 626 | (with-output-msg () |
630 | 634 | (let ((newlhs (axiom-lhs rule)) |
631 | 635 | (oldlhs (axiom-lhs r))) |
632 | 636 | (when (and (not (term-is-variable? newlhs)) |
633 | (not (term-is-variable? oldlhs)) | |
634 | (not (method= (term-method newlhs) (term-method oldlhs))) | |
635 | (sort<= (term-sort oldlhs) (term-sort newlhs))) | |
636 | (rplaca lst rule)) | |
637 | (not (term-is-variable? oldlhs)) | |
638 | (not (method= (term-method newlhs) (term-method oldlhs))) | |
639 | (sort<= (term-sort oldlhs) (term-sort newlhs))) | |
640 | (rplaca lst rule)) | |
637 | 641 | (return-from adjoin-rule rs))))) |
638 | 642 | |
639 | 643 | ;;; RULE-OCCURS : rule ruleset -> Bool |
714 | 718 | (declare (type module module) |
715 | 719 | (type axiom ax) |
716 | 720 | (values t)) |
717 | (if (memq (axiom-type ax) '(:equation :pignose-axiom :pignose-goal)) | |
718 | (setf (module-equations module) | |
719 | (adjoin-rule ax (module-equations module))) | |
721 | (with-in-module (module) | |
722 | (if (memq (axiom-type ax) '(:equation :pignose-axiom :pignose-goal)) | |
723 | (setf (module-equations module) | |
724 | (adjoin-rule ax (module-equations module))) | |
720 | 725 | (setf (module-rules module) |
721 | (adjoin-rule ax (module-rules module))))) | |
726 | (adjoin-rule ax (module-rules module)))))) | |
722 | 727 | |
723 | 728 | (defun add-rule-to-module (module rule) |
724 | 729 | (declare (type module module) |
725 | 730 | (type axiom rule) |
726 | 731 | (values t)) |
727 | (add-rule-to-method rule | |
728 | (term-head (axiom-lhs rule)) | |
729 | (module-opinfo-table module)) | |
730 | (pushnew rule (module-rewrite-rules module) | |
731 | :test #'rule-is-similar?)) | |
732 | (with-in-module (module) | |
733 | (add-rule-to-method rule | |
734 | (term-head (axiom-lhs rule)) | |
735 | (module-opinfo-table module)) | |
736 | (pushnew rule (module-rewrite-rules module) | |
737 | :test #'rule-is-similar?))) | |
732 | 738 | |
733 | 739 | (defun add-rule-to-method (rule method |
734 | 740 | &optional (opinfo-table *current-opinfo-table*)) |