35 | 35 |
(declaim (optimize (speed 3) (safety 0) #-GCL (debug 0)))
|
36 | 36 |
#+:chaos-debug
|
37 | 37 |
(declaim (optimize (speed 1) (safety 3) #-GCL (debug 3)))
|
38 | |
|
39 | |
;;; (defvar *gen-rule-debug* nil)
|
40 | 38 |
|
41 | 39 |
;;; GENERATE REWRITE RULES module : -> module'
|
42 | 40 |
;;;-----------------------------------------------------------------------------
|
|
581 | 579 |
(values t))
|
582 | 580 |
(when *gen-rule-debug*
|
583 | 581 |
(format t "~%[id-compl] given rule ~a, of kind ~a " r (axiom-kind r))
|
584 | |
(print-next)
|
585 | |
(print-chaos-object r))
|
|
582 |
(print-next))
|
586 | 583 |
(unless (axiom-kind r)
|
587 | 584 |
(let (varval
|
588 | 585 |
(res nil)
|
|
617 | 614 |
(setq sub1 (cons varval nil))
|
618 | 615 |
(setq newsubst (substitution-can (cons varval subst)))
|
619 | 616 |
(setq donesubst (cons (car sub1) donesubst))
|
620 | |
(setq new-axiom (insert-val sub1 a-axiom))
|
|
617 |
(setq new-axiom (insert-val sub1 a-axiom module))
|
621 | 618 |
(unless (or (null new-axiom)
|
622 | 619 |
(rule-inf-subst-member newsubst res))
|
623 | 620 |
(setq newres (cons (list new-axiom newsubst) newres)))))))
|
|
672 | 669 |
(when e
|
673 | 670 |
(setf (axiom-id-condition e) newidcond)))
|
674 | 671 |
(unless (eq r rul)
|
|
672 |
(when *gen-rule-debug*
|
|
673 |
(format t "~%[id-compl]=> ")
|
|
674 |
(print-chaos-object newrule))
|
675 | 675 |
(adjoin-axiom-to-module module newrule)))))))))
|
676 | 676 |
|
677 | 677 |
(defun test-bad-axiom (ax)
|
|
791 | 791 |
(eq val (cdr ye)))
|
792 | 792 |
(return t))))
|
793 | 793 |
|
794 | |
(defun insert-val (subs rul)
|
|
794 |
(defun insert-val (subs rul &optional (module *current-module*))
|
795 | 795 |
(declare (type list subs)
|
796 | 796 |
(type axiom rul)
|
797 | 797 |
(values (or null axiom)))
|
|
800 | 800 |
(*m-pattern-subst* nil))
|
801 | 801 |
(let ((newcond (if (is-true? (axiom-condition rul))
|
802 | 802 |
*BOOL-true*
|
803 | |
(term-simplify
|
804 | |
(normalize-for-identity-total
|
805 | |
(substitution-partial-image subs (axiom-condition rul)))))))
|
|
803 |
(term-simplify
|
|
804 |
(normalize-for-identity-total
|
|
805 |
(substitution-partial-image subs (axiom-condition rul)))
|
|
806 |
module))))
|
806 | 807 |
(if (is-false? newcond)
|
807 | 808 |
nil
|
808 | 809 |
(let ((rule nil)
|
|
811 | 812 |
(rhs (term-simplify
|
812 | 813 |
(normalize-for-identity-total
|
813 | 814 |
(substitution-partial-image subs
|
814 | |
(axiom-rhs rul)))))
|
|
815 |
(axiom-rhs rul)))
|
|
816 |
module))
|
815 | 817 |
(condition (if (is-true? newcond)
|
816 | 818 |
*BOOL-TRUE*
|
817 | 819 |
newcond)))
|
|
834 | 836 |
:labels (cons (car (create-rule-name 'dummy "idcomp")) (axiom-labels rul))))
|
835 | 837 |
;;
|
836 | 838 |
(when *gen-rule-debug*
|
837 | |
(format t "~%invert-val: ")
|
|
839 |
(format t "~%[insert-val]:----------")
|
838 | 840 |
(format t "~% given rule : ")
|
839 | 841 |
(print-chaos-object rul)
|
840 | 842 |
(format t "~% gen rule : ")
|
|
1039 | 1041 |
(theory-standard-form (normalize-for-identity tm)))
|
1040 | 1042 |
|
1041 | 1043 |
;;; rules for and or not == =/= identical nonidentical must not have conditions
|
1042 | |
(defun term-simplify (tm)
|
|
1044 |
(defun term-simplify (tm &optional (module *current-module*))
|
1043 | 1045 |
(declare (type term tm)
|
1044 | 1046 |
(values (or null term)))
|
1045 | 1047 |
(if (term-is-variable? tm)
|
1046 | 1048 |
nil
|
1047 | |
(if (term-is-constant? tm)
|
1048 | |
nil
|
1049 | |
(let ((meth (term-head tm)))
|
1050 | |
(dolist (subtm (term-subterms tm))
|
1051 | |
(term-simplify subtm))
|
1052 | |
(if (or (eq *BOOL-and* meth)
|
1053 | |
(eq *BOOL-or* meth)
|
1054 | |
(eq *BOOL-not* meth)
|
1055 | |
(eq *BOOL-if* meth))
|
1056 | |
(simplify-on-top tm)
|
1057 | |
(if (and (or (eq *BOOL-equal* meth)
|
1058 | |
(eq *BOOL-nonequal* meth)
|
1059 | |
(eq *identical* meth)
|
1060 | |
(eq *nonidentical* meth))
|
1061 | |
(term-is-ground? (term-arg-1 tm))
|
1062 | |
(term-is-ground? (term-arg-2 tm)))
|
1063 | |
(if (or (eq *BOOL-equal* meth)
|
1064 | |
(eq *identical* meth))
|
1065 | |
(if (term-is-similar? (term-arg-1 tm) (term-arg-2 tm))
|
1066 | |
(term-replace tm (simple-copy-term *BOOL-true*))
|
1067 | |
nil)
|
1068 | |
(if (term-is-similar? (term-arg-1 tm) (term-arg-2 tm))
|
1069 | |
(term-replace tm (simple-copy-term *BOOL-false*))
|
1070 | |
nil))
|
1071 | |
nil))
|
1072 | |
)))
|
|
1049 |
(if (term-is-constant? tm)
|
|
1050 |
nil
|
|
1051 |
(let ((meth (term-head tm)))
|
|
1052 |
(dolist (subtm (term-subterms tm))
|
|
1053 |
(term-simplify subtm module))
|
|
1054 |
(if (or (eq *BOOL-and* meth)
|
|
1055 |
(eq *BOOL-or* meth)
|
|
1056 |
(eq *BOOL-not* meth)
|
|
1057 |
(eq *BOOL-if* meth))
|
|
1058 |
(simplify-on-top tm module)
|
|
1059 |
(if (and (or (eq *BOOL-equal* meth)
|
|
1060 |
(eq *BOOL-nonequal* meth)
|
|
1061 |
(eq *identical* meth)
|
|
1062 |
(eq *nonidentical* meth))
|
|
1063 |
(term-is-ground? (term-arg-1 tm))
|
|
1064 |
(term-is-ground? (term-arg-2 tm)))
|
|
1065 |
(if (or (eq *BOOL-equal* meth)
|
|
1066 |
(eq *identical* meth))
|
|
1067 |
(if (term-is-similar? (term-arg-1 tm) (term-arg-2 tm))
|
|
1068 |
(term-replace tm (simple-copy-term *BOOL-true*))
|
|
1069 |
nil)
|
|
1070 |
(if (term-is-similar? (term-arg-1 tm) (term-arg-2 tm))
|
|
1071 |
(term-replace tm (simple-copy-term *BOOL-false*))
|
|
1072 |
nil))
|
|
1073 |
nil)))))
|
1073 | 1074 |
tm)
|
1074 | 1075 |
|
1075 | 1076 |
(defun normalize-for-identity (term)
|