other
(in-package "ACL2")
warranted-fns-of-world1function
(defun warranted-fns-of-world1 (x wrld) (declare (xargs :mode :logic :guard (plist-worldp wrld))) (cond ((atom x) nil) ((and (weak-badge-userfn-structure-tuplep (car x)) (access-badge-userfn-structure-tuple-warrantp (car x)) (symbolp (car (car x))) (function-symbolp (car (car x)) wrld)) (cons (car (car x)) (warranted-fns-of-world1 (cdr x) wrld))) (t nil)))
warranted-fns-of-worldfunction
(defun warranted-fns-of-world (wrld) (declare (xargs :mode :logic :guard (plist-worldp wrld) :verify-guards nil)) (and (alistp (table-alist 'badge-table wrld)) (warranted-fns-of-world1 (cdr (assoc-eq :badge-userfn-structure (table-alist 'badge-table wrld))) wrld)))
other
(partial-encapsulate (((ev-fncall+-fns * * * * * * *) => *)) nil (logic) (local (defun ev-fncall+-fns (fn args wrld big-n safe-mode gc-off strictp) (declare (ignore fn args big-n safe-mode gc-off)) (and (not strictp) (warranted-fns-of-world wrld)))) (local (defthm all-function-symbolps-ev-fncall+-fns-lemma (all-function-symbolps (warranted-fns-of-world1 x wrld) wrld))) (defthm all-function-symbolps-ev-fncall+-fns (let ((fns (ev-fncall+-fns fn args wrld big-n safe-mode gc-off nil))) (all-function-symbolps fns wrld))) (local (defthm subsetp-equal-cons (implies (subsetp-equal x y) (subsetp-equal x (cons a y))))) (local (defthm subsetp-equal-x-x (subsetp-equal x x))) (defthm ev-fncall+-fns-is-subset-of-badged-fns-of-world (subsetp (ev-fncall+-fns fn args wrld big-n safe-mode gc-off nil) (warranted-fns-of-world wrld))) (defthm function-symbolp-ev-fncall+-fns-strictp (let ((fn (ev-fncall+-fns fn args wrld big-n safe-mode gc-off t))) (and (symbolp fn) (or (null fn) (function-symbolp fn wrld)))) :rule-classes nil))
ev-fncall+-wfunction
(defun ev-fncall+-w (fn args w safe-mode gc-off strictp) (let* ((big-n (big-n)) (fns (ev-fncall+-fns fn args w big-n safe-mode gc-off strictp))) (mv-let (erp val latches) (ev-fncall-rec-logical fn args nil w nil big-n safe-mode gc-off nil t nil (and (not strictp) fns)) (declare (ignore latches)) (mv erp val fns))))
ev-fncall+function
(defun ev-fncall+ (fn args strictp state) (ev-fncall+-w fn args (w state) (f-get-global 'safe-mode state) (gc-off state) strictp))
*geneqv-iff*constant
(defconst *geneqv-iff* (list (make congruence-rule :rune *fake-rune-for-anonymous-enabled-rule* :nume nil :equiv 'iff)))
refinementpfunction
(defun refinementp (equiv1 equiv2 wrld) (cond ((eq equiv1 'equal) t) ((eq equiv2 'equal) nil) ((eq equiv1 equiv2) t) (t (member-eq equiv2 (cdr (getpropc equiv1 'coarsenings nil wrld))))))
geneqv-refinementp1function
(defun geneqv-refinementp1 (coarsenings geneqv) (cond ((null geneqv) nil) ((member-eq (access congruence-rule (car geneqv) :equiv) coarsenings) (access congruence-rule (car geneqv) :rune)) (t (geneqv-refinementp1 coarsenings (cdr geneqv)))))
geneqv-refinementpfunction
(defun geneqv-refinementp (equiv geneqv wrld) (cond ((eq equiv 'equal) *fake-rune-for-anonymous-enabled-rule*) ((null geneqv) nil) (t (geneqv-refinementp1 (getpropc equiv 'coarsenings nil wrld) geneqv))))
some-congruence-rule-disabledpfunction
(defun some-congruence-rule-disabledp (geneqv ens) (cond ((null geneqv) nil) ((enabled-numep (access congruence-rule (car geneqv) :nume) ens) (some-congruence-rule-disabledp (cdr geneqv) ens)) (t t)))
filter-geneqv1function
(defun filter-geneqv1 (geneqv ens) (cond ((null geneqv) nil) ((enabled-numep (access congruence-rule (car geneqv) :nume) ens) (cons (car geneqv) (filter-geneqv1 (cdr geneqv) ens))) (t (filter-geneqv1 (cdr geneqv) ens))))
filter-geneqvfunction
(defun filter-geneqv (geneqv ens) (cond ((some-congruence-rule-disabledp geneqv ens) (filter-geneqv1 geneqv ens)) (t geneqv)))
some-geneqv-disabledpfunction
(defun some-geneqv-disabledp (lst ens) (cond ((null lst) nil) ((some-congruence-rule-disabledp (car lst) ens) t) (t (some-geneqv-disabledp (cdr lst) ens))))
filter-geneqv-lst1function
(defun filter-geneqv-lst1 (lst ens) (cond ((null lst) nil) (t (cons (filter-geneqv (car lst) ens) (filter-geneqv-lst1 (cdr lst) ens)))))
filter-geneqv-lstfunction
(defun filter-geneqv-lst (lst ens) (cond ((null ens) lst) ((some-geneqv-disabledp lst ens) (filter-geneqv-lst1 lst ens)) (t lst)))
refinementp1function
(defun refinementp1 (equiv1 coarsenings1 equiv2) (cond ((eq equiv1 'equal) t) ((eq equiv2 'equal) nil) ((eq equiv1 equiv2) t) (t (member-eq equiv2 coarsenings1))))
pair-congruence-rules-with-coarseningsfunction
(defun pair-congruence-rules-with-coarsenings (geneqv wrld) (cond ((null geneqv) nil) (t (cons (cons (car geneqv) (cdr (getpropc (access congruence-rule (car geneqv) :equiv) 'coarsenings nil wrld))) (pair-congruence-rules-with-coarsenings (cdr geneqv) wrld)))))
add-to-cr-and-coarseningsfunction
(defun add-to-cr-and-coarsenings (new-cr new-cr-coarsenings old-crs-and-coarsenings both-tests-flg) (cond ((null old-crs-and-coarsenings) (list (cons new-cr (cdr new-cr-coarsenings)))) ((and both-tests-flg (refinementp1 (car new-cr-coarsenings) (cdr new-cr-coarsenings) (access congruence-rule (car (car old-crs-and-coarsenings)) :equiv))) old-crs-and-coarsenings) ((refinementp1 (access congruence-rule (car (car old-crs-and-coarsenings)) :equiv) (cdr (car old-crs-and-coarsenings)) (car new-cr-coarsenings)) (add-to-cr-and-coarsenings new-cr new-cr-coarsenings (cdr old-crs-and-coarsenings) nil)) (t (cons (car old-crs-and-coarsenings) (add-to-cr-and-coarsenings new-cr new-cr-coarsenings (cdr old-crs-and-coarsenings) both-tests-flg)))))
union-geneqv1function
(defun union-geneqv1 (geneqv1 old-crs-and-coarsenings wrld) (cond ((null geneqv1) old-crs-and-coarsenings) (t (union-geneqv1 (cdr geneqv1) (add-to-cr-and-coarsenings (car geneqv1) (getpropc (access congruence-rule (car geneqv1) :equiv) 'coarsenings nil wrld) old-crs-and-coarsenings t) wrld))))
union-geneqvfunction
(defun union-geneqv (geneqv1 geneqv2 wrld) (strip-cars (union-geneqv1 geneqv1 (pair-congruence-rules-with-coarsenings geneqv2 wrld) wrld)))
pairwise-union-geneqvfunction
(defun pairwise-union-geneqv (lst1 lst2 wrld) (cond ((null lst1) nil) (t (cons (union-geneqv (car lst1) (car lst2) wrld) (pairwise-union-geneqv (cdr lst1) (cdr lst2) wrld)))))
geneqv-lst1function
(defun geneqv-lst1 (congruences geneqv ens wrld) (cond ((null congruences) nil) (t (let ((ans (geneqv-lst1 (cdr congruences) geneqv ens wrld))) (cond ((geneqv-refinementp (caar congruences) geneqv wrld) (cond ((null ans) (filter-geneqv-lst (cdar congruences) ens)) (t (pairwise-union-geneqv (filter-geneqv-lst (cdar congruences) ens) ans wrld)))) (t ans))))))
geneqv-lstfunction
(defun geneqv-lst (fn geneqv ens wrld) (cond ((flambdap fn) nil) ((eq fn 'if) (list *geneqv-iff* geneqv geneqv)) (t (let ((congruences (getpropc fn 'congruences nil wrld))) (cond ((null congruences) nil) ((null geneqv) (filter-geneqv-lst (cdr (assoc-eq 'equal congruences)) ens)) (t (geneqv-lst1 congruences geneqv ens wrld)))))))
subst-expr1mutual-recursion
(mutual-recursion (defun subst-expr1 (new old term) (declare (xargs :guard (and (pseudo-termp new) (pseudo-termp old) (pseudo-termp term)))) (cond ((equal term old) new) ((variablep term) term) ((fquotep term) term) (t (cons-term (ffn-symb term) (subst-expr1-lst new old (fargs term)))))) (defun subst-expr1-lst (new old args) (declare (xargs :guard (and (pseudo-termp new) (pseudo-termp old) (pseudo-term-listp args)))) (cond ((endp args) nil) (t (cons (subst-expr1 new old (car args)) (subst-expr1-lst new old (cdr args)))))))
subst-expr-errorfunction
(defun subst-expr-error (const) (declare (xargs :guard nil)) (er hard 'subst-expr-error "An attempt was made to substitute for the explicit value ~x0. ~ The substitution functions were optimized to disallow this." const))
subst-exprfunction
(defun subst-expr (new old term) (declare (xargs :guard (and (pseudo-termp new) (pseudo-termp old) (not (quotep old)) (pseudo-termp term)))) (cond ((variablep old) (subst-var new old term)) ((fquotep old) (subst-expr-error old)) (t (subst-expr1 new old term))))
comment-fnfunction
(defun comment-fn (x y) (declare (xargs :guard t)) `(return-last 'progn '(:comment . ,X) ,Y))
commentmacro
(defmacro comment (x y) (comment-fn x y))
other
(defattach hide-with-comment-p constant-t-function-arity-0)
hide-with-commentfunction
(defun hide-with-comment (reason term wrld state) (declare (xargs :mode :program :stobjs state)) (cond ((or (null reason) (null (hide-with-comment-p))) (fcons-term* 'hide term)) (t (flet ((comment-fn+ (x y) (comment-fn (concatenate 'string x "; see :DOC comment") y)) (reason-string (erp scons-term-p wrld state) (let* ((fn (and (consp erp) (eq (car erp) 'ev-fncall-null-body-er) (symbolp (cdr erp)) (cdr erp))) (fn (if (eq fn :non-exec) 'non-exec fn))) (and fn (let* ((non-executablep (getpropc fn 'non-executablep nil wrld)) (skip-pkg-prefix (symbol-in-current-package-p fn state)) (str0 (if scons-term-p "Failed attempt (during substitution) to call " "Failed attempt to call ")) (str1 (cond ((eq fn 'non-exec) "") (non-executablep "non-executable function ") (t "constrained function "))) (str2 (cond ((or (eq fn 'non-exec) (null (attachment-pair fn wrld))) "") ((warrant-function-namep fn wrld) ": warrant functions are not executable during proofs") (t ": its attachment is ignored during proofs")))) (if skip-pkg-prefix (concatenate 'string str0 str1 (symbol-name fn) str2) (concatenate 'string str0 str1 (symbol-package-name fn) "::" (symbol-name fn) str2))))))) (case-match reason ((:non-executable . erp) (let ((reason-string (reason-string erp nil wrld state))) (fcons-term* 'hide (if reason-string (comment-fn+ reason-string term) term)))) ((:scons-term . erp) (let ((reason-string (reason-string erp t wrld state))) (fcons-term* 'hide (if reason-string (comment-fn+ reason-string term) term)))) ((:expand rune . skip-pkg-prefix) (fcons-term* 'hide (comment-fn+ (let ((name (if skip-pkg-prefix (symbol-name (base-symbol rune)) (concatenate 'string (symbol-package-name (base-symbol rune)) "::" (symbol-name (base-symbol rune)))))) (concatenate 'string "Unable to expand using the rule " name)) term))) ((:missing-warrant . fn?) (fcons-term* 'hide (comment-fn+ (let* ((disabledp (consp fn?)) (fn (if disabledp (car fn?) fn?)) (skip-pkg-prefix (symbol-in-current-package-p fn state)) (fn-str (if skip-pkg-prefix (symbol-name fn) (concatenate 'string (symbol-package-name fn) "::" (symbol-name fn))))) (concatenate 'string "Call failed because " (if disabledp (concatenate 'string "the rule " fn-str " is disabled") (concatenate 'string "the warrant for " fn-str " is not known to be true")))) term))) (& (er hard 'hide-with-comment "Unexpected reason supplied to ~x0!" 'hide-with-comment)))))))
scons-termfunction
(defun scons-term (fn args ens wrld state ttree) (cond ((and (all-quoteps args) (or (flambdap fn) (and (enabled-xfnp fn ens wrld) (not (getpropc fn 'constrainedp nil wrld))))) (cond ((flambdap fn) (mv nil (cons-term fn args) ttree)) ((eq fn 'if) (mv t (if (cadr (car args)) (cadr args) (caddr args)) ttree)) ((programp fn wrld) (mv nil (cons-term fn args) ttree)) (t (mv-let (erp val bad-fn) (pstk (ev-fncall+ fn (strip-cadrs args) t state)) (cond (erp (cond (bad-fn (mv nil (cons-term fn args) ttree)) (t (mv t (hide-with-comment (cons :scons-term erp) (cons-term fn args) wrld state) (push-lemma (fn-rune-nume 'hide nil nil wrld) ttree))))) (t (mv t (kwote val) (push-lemma (fn-rune-nume fn nil t wrld) ttree)))))))) ((and (eq fn 'equal) (equal (car args) (cadr args))) (mv t *t* (puffert ttree))) (t (mv nil (cons-term fn args) ttree))))
subst-equiv-expr1mutual-recursion
(mutual-recursion (defun subst-equiv-expr1 (equiv new old geneqv term ens wrld state ttree) (cond ((and (equal term old) (geneqv-refinementp equiv geneqv wrld)) (mv t new (push-lemma (geneqv-refinementp equiv geneqv wrld) ttree))) ((or (variablep term) (fquotep term) (eq (ffn-symb term) 'hide)) (mv nil term ttree)) (t (mv-let (hitp1 args ttree) (subst-equiv-expr1-lst equiv new old (geneqv-lst (ffn-symb term) geneqv ens wrld) (fargs term) ens wrld state ttree) (mv-let (hitp2 new-term ttree) (scons-term (ffn-symb term) args ens wrld state ttree) (mv (or hitp1 hitp2) new-term ttree)))))) (defun subst-equiv-expr1-lst (equiv new old geneqv-lst args ens wrld state ttree) (cond ((null args) (mv nil nil ttree)) (t (mv-let (hitp1 arg ttree) (subst-equiv-expr1 equiv new old (car geneqv-lst) (car args) ens wrld state ttree) (mv-let (hitp2 args ttree) (subst-equiv-expr1-lst equiv new old (cdr geneqv-lst) (cdr args) ens wrld state ttree) (mv (or hitp1 hitp2) (cons arg args) ttree)))))))
subst-equiv-exprfunction
(defun subst-equiv-expr (equiv new old geneqv term ens wrld state ttree) (cond ((and (nvariablep old) (fquotep old)) (mv (subst-expr-error old) term ttree)) (t (subst-equiv-expr1 equiv new old geneqv term ens wrld state ttree))))
*anonymous-var*constant
(defconst *anonymous-var* '|Anonymous variable|)
equal-mod-alistmutual-recursion
(mutual-recursion (defun equal-mod-alist (term1 alist1 term2) (cond ((variablep term1) (let ((temp (assoc-eq term1 alist1))) (cond (temp (equal (cdr temp) term2)) (t (equal term1 term2))))) ((fquotep term1) (equal term1 term2)) ((variablep term2) nil) ((fquotep term2) (cond ((and (not (flambdap (ffn-symb term1))) (assoc-eq (ffn-symb term1) *primitive-formals-and-guards*)) (equal term2 (sublis-var alist1 term1))) (t nil))) ((equal (ffn-symb term1) (ffn-symb term2)) (equal-mod-alist-lst (fargs term1) alist1 (fargs term2))) (t nil))) (defun equal-mod-alist-lst (term1-lst alist1 term2-lst) (cond ((endp term1-lst) t) (t (and (equal-mod-alist (car term1-lst) alist1 (car term2-lst)) (equal-mod-alist-lst (cdr term1-lst) alist1 (cdr term2-lst)))))))
equal-mod-alist2mutual-recursion
(mutual-recursion (defun equal-mod-alist2 (term1 alist1 term2 alist2) (cond ((variablep term1) (let ((pair1 (assoc-eq term1 alist1))) (cond (pair1 (equal-mod-alist term2 alist2 (cdr pair1))) ((variablep term2) (let ((pair2 (assoc-eq term2 alist2))) (eq term1 (if pair2 (cdr pair2) term2)))) (t nil)))) ((variablep term2) (let ((pair2 (assoc-eq term2 alist2))) (cond (pair2 (equal-mod-alist term1 alist1 (cdr pair2))) (t nil)))) ((fquotep term1) (equal-mod-alist term2 alist2 term1)) ((fquotep term2) (equal-mod-alist term1 alist1 term2)) ((equal (ffn-symb term1) (ffn-symb term2)) (equal-mod-alist2-lst (fargs term1) alist1 (fargs term2) alist2)) (t nil))) (defun equal-mod-alist2-lst (term1-lst alist1 term2-lst alist2) (cond ((endp term1-lst) t) (t (and (equal-mod-alist2 (car term1-lst) alist1 (car term2-lst) alist2) (equal-mod-alist2-lst (cdr term1-lst) alist1 (cdr term2-lst) alist2))))))
one-way-unify1-term-alistmutual-recursion
(mutual-recursion (defun one-way-unify1-term-alist (pat term term-alist alist) (declare (xargs :guard (and (pseudo-termp pat) (pseudo-termp term) (alistp term-alist) (alistp alist)))) (cond ((eq pat *anonymous-var*) (mv t alist)) ((variablep pat) (let ((pair (assoc-eq pat alist))) (cond ((null pair) (mv t (acons pat (if term-alist (list* :sublis-var term term-alist) term) alist))) ((and (consp pair) (consp (cdr pair)) (eq (car (cdr pair)) :sublis-var)) (cond ((null term-alist) (mv (equal-mod-alist (cadr (cdr pair)) (cddr (cdr pair)) term) alist)) (t (mv (equal-mod-alist2 (cadr (cdr pair)) (cddr (cdr pair)) term term-alist) alist)))) ((null term-alist) (mv (equal term (cdr pair)) alist)) (t (mv (equal-mod-alist term term-alist (cdr pair)) alist))))) ((fquotep pat) (cond ((if (null term-alist) (equal term pat) (equal-mod-alist term term-alist pat)) (mv t alist)) (t (mv nil alist)))) ((variablep term) (let ((pair (assoc-eq term term-alist))) (cond (pair (one-way-unify1-term-alist pat (cdr pair) nil alist)) (t (mv nil alist))))) ((fquotep term) (mv-let (pat1 term1 pat2 term2) (one-way-unify1-quotep-subproblems pat term) (cond ((eq pat1 t) (mv t alist)) ((eq pat1 nil) (mv nil alist)) ((eq pat2 nil) (one-way-unify1-term-alist pat1 term1 nil alist)) (t (mv-let (ans alist1) (one-way-unify1-term-alist pat1 term1 nil alist) (cond ((eq ans nil) (mv nil alist)) (t (mv-let (ans alist2) (one-way-unify1-term-alist pat2 term2 nil alist1) (cond (ans (mv ans alist2)) (t (mv nil alist))))))))))) ((equal (ffn-symb pat) (ffn-symb term)) (mv-let (ans alist1) (one-way-unify1-term-alist-lst (fargs pat) (fargs term) term-alist alist) (cond (ans (mv ans alist1)) ((eq (ffn-symb pat) 'equal) (let ((pat1 (fargn pat 1)) (pat2 (fargn pat 2)) (term1 (fargn term 1)) (term2 (fargn term 2))) (mv-let (ans alist1) (one-way-unify1-term-alist pat2 term1 term-alist alist) (cond (ans (mv-let (ans alist2) (one-way-unify1-term-alist pat1 term2 term-alist alist1) (cond (ans (mv ans alist2)) (t (mv nil alist))))) (t (mv nil alist)))))) (t (mv nil alist))))) (t (mv nil alist)))) (defun one-way-unify1-term-alist-lst (pl tl term-alist alist) (declare (xargs :guard (and (pseudo-term-listp pl) (pseudo-term-listp tl) (alistp term-alist) (alistp alist)))) (cond ((null pl) (mv t alist)) (t (mv-let (ans alist) (one-way-unify1-term-alist (car pl) (car tl) term-alist alist) (cond (ans (one-way-unify1-term-alist-lst (cdr pl) (cdr tl) term-alist alist)) (t (mv nil alist))))))))
other
(defrec pequiv-info (((rewritten-args-rev . rest-args) alist . bkptr) geneqv fn . deep-pequiv-lst) t)
*empty-pequivs-property*constant
(defconst *empty-pequivs-property* (make pequivs-property :deep nil :shallow nil :deep-pequiv-p nil))
pequivs-property-fieldmacro
(defmacro pequivs-property-field (prop field) (declare (xargs :guard (and (member-eq field '(:deep :shallow :deep-pequiv-p)) (not (keywordp prop))))) `(let ((prop ,PROP)) (and prop (access pequivs-property prop ,FIELD))))
next-pequivfunction
(defun next-pequiv (pequiv rewritten-args-rev rest-args alist) (let ((pattern (access pequiv pequiv :pattern))) (mv-let (flg unify-subst) (one-way-unify1-term-alist-lst (access pequiv-pattern pattern :pre-rev) rewritten-args-rev nil (access pequiv pequiv :unify-subst)) (cond ((null flg) nil) (t (mv-let (flg unify-subst) (one-way-unify1-term-alist-lst (access pequiv-pattern pattern :post) rest-args alist unify-subst) (cond ((null flg) nil) ((equal (access pequiv pequiv :unify-subst) unify-subst) (change pequiv pequiv :pattern (access pequiv-pattern pattern :next))) (t (change pequiv pequiv :pattern (access pequiv-pattern pattern :next) :unify-subst unify-subst)))))))))
next-pequivsfunction
(defun next-pequivs (deep-pequiv-lst rewritten-args-rev rest-args alist bkptr parent-fn child-fn ens next-deep-pequiv-lst next-shallow-pequiv-lst) (cond ((endp deep-pequiv-lst) (mv next-deep-pequiv-lst next-shallow-pequiv-lst)) (t (let* ((deep-pequiv (car deep-pequiv-lst)) (pat (access pequiv deep-pequiv :pattern)) (next (access pequiv-pattern pat :next)) (next-pequiv (assert$ (not (variablep next)) (and (eq parent-fn (access pequiv-pattern pat :fn)) (eql bkptr (access pequiv-pattern pat :posn)) (if child-fn (eq child-fn (access pequiv-pattern next :fn)) (enabled-numep (access congruence-rule (access pequiv deep-pequiv :congruence-rule) :nume) ens)) (next-pequiv deep-pequiv rewritten-args-rev rest-args alist))))) (cond ((not next-pequiv) (next-pequivs (cdr deep-pequiv-lst) rewritten-args-rev rest-args alist bkptr parent-fn child-fn ens next-deep-pequiv-lst next-shallow-pequiv-lst)) ((variablep (access pequiv-pattern next :next)) (next-pequivs (cdr deep-pequiv-lst) rewritten-args-rev rest-args alist bkptr parent-fn child-fn ens next-deep-pequiv-lst (cons next-pequiv next-shallow-pequiv-lst))) (t (next-pequivs (cdr deep-pequiv-lst) rewritten-args-rev rest-args alist bkptr parent-fn child-fn ens (cons next-pequiv next-deep-pequiv-lst) next-shallow-pequiv-lst)))))))
next-pequivs-alistfunction
(defun next-pequivs-alist (deep-pequiv-alist rewritten-args-rev rest-args alist bkptr parent-fn parent-geneqv wrld ens next-deep-pequiv-lst next-shallow-pequiv-lst) (cond ((endp deep-pequiv-alist) (mv next-deep-pequiv-lst next-shallow-pequiv-lst)) ((geneqv-refinementp (caar deep-pequiv-alist) parent-geneqv wrld) (mv-let (next-deep-pequiv-lst next-shallow-pequiv-lst) (next-pequivs (cdar deep-pequiv-alist) rewritten-args-rev rest-args alist bkptr parent-fn nil ens next-deep-pequiv-lst next-shallow-pequiv-lst) (next-pequivs-alist (cdr deep-pequiv-alist) rewritten-args-rev rest-args alist bkptr parent-fn parent-geneqv wrld ens next-deep-pequiv-lst next-shallow-pequiv-lst))) (t (next-pequivs-alist (cdr deep-pequiv-alist) rewritten-args-rev rest-args alist bkptr parent-fn parent-geneqv wrld ens next-deep-pequiv-lst next-shallow-pequiv-lst))))
extend-pequiv-lstfunction
(defun extend-pequiv-lst (pequiv-lst ens acc) (cond ((endp pequiv-lst) acc) (t (extend-pequiv-lst (cdr pequiv-lst) ens (cond ((enabled-numep (access congruence-rule (access pequiv (car pequiv-lst) :congruence-rule) :nume) ens) (cons (car pequiv-lst) acc)) (t acc))))))
accumulate-shallow-pequiv-alistfunction
(defun accumulate-shallow-pequiv-alist (alist geneqv wrld ens acc) (cond ((endp alist) acc) (t (accumulate-shallow-pequiv-alist (cdr alist) geneqv wrld ens (cond ((geneqv-refinementp (caar alist) geneqv wrld) (extend-pequiv-lst (cdar alist) ens acc)) (t acc))))))
pequivs-for-rewrite-argsfunction
(defun pequivs-for-rewrite-args (fn geneqv pequiv-info wrld ens) (cond ((flambdap fn) (mv nil nil)) (t (let* ((prop (getpropc fn 'pequivs nil wrld)) (shallow-pequiv-alist (pequivs-property-field prop :shallow))) (cond ((not pequiv-info) (mv (and (pequivs-property-field prop :deep-pequiv-p) :none) (accumulate-shallow-pequiv-alist shallow-pequiv-alist geneqv wrld ens nil))) (t (let ((deep-pequiv-lst (access pequiv-info pequiv-info :deep-pequiv-lst)) (rewritten-args-rev (access pequiv-info pequiv-info :rewritten-args-rev)) (rest-args (access pequiv-info pequiv-info :rest-args)) (alist (access pequiv-info pequiv-info :alist)) (bkptr (access pequiv-info pequiv-info :bkptr)) (parent-fn (access pequiv-info pequiv-info :fn))) (mv-let (next-deep-pequiv-lst next-shallow-pequiv-lst) (next-pequivs deep-pequiv-lst rewritten-args-rev rest-args alist bkptr parent-fn fn nil nil nil) (mv-let (next-deep-pequiv-lst next-shallow-pequiv-lst) (next-pequivs-alist (pequivs-property-field prop :deep) rewritten-args-rev rest-args alist bkptr parent-fn (access pequiv-info pequiv-info :geneqv) wrld ens next-deep-pequiv-lst next-shallow-pequiv-lst) (mv (or next-deep-pequiv-lst (and (pequivs-property-field prop :deep-pequiv-p) :none)) (accumulate-shallow-pequiv-alist shallow-pequiv-alist geneqv wrld ens next-shallow-pequiv-lst)))))))))))
pequiv-info-for-rewritefunction
(defun pequiv-info-for-rewrite (fn bkptr rewritten-args-rev args alist geneqv deep-pequiv-lst) (cond ((or (null deep-pequiv-lst) (flambdap fn) (variablep (car args)) (fquotep (car args))) nil) (t (make pequiv-info :rewritten-args-rev rewritten-args-rev :rest-args (cdr args) :alist alist :bkptr bkptr :fn fn :geneqv geneqv :deep-pequiv-lst (and (consp deep-pequiv-lst) deep-pequiv-lst)))))
reduce-geneqv-for-equivfunction
(defun reduce-geneqv-for-equiv (equiv wrld geneqv) (cond ((endp geneqv) (mv nil nil)) (t (mv-let (changedp rest) (reduce-geneqv-for-equiv equiv wrld (cdr geneqv)) (cond ((refinementp (access congruence-rule (car geneqv) :equiv) equiv wrld) (mv t rest)) (changedp (mv t (cons (car geneqv) rest))) (t (mv nil geneqv)))))))
geneqv-for-rewritefunction
(defun geneqv-for-rewrite (shallow-pequiv-lst fn bkptr rewritten-args-rev rest-args alist wrld geneqv) (cond ((null shallow-pequiv-lst) geneqv) (t (let* ((pequiv (car shallow-pequiv-lst)) (pat (access pequiv pequiv :pattern)) (congruence-rule (access pequiv pequiv :congruence-rule)) (equiv (access congruence-rule congruence-rule :equiv))) (geneqv-for-rewrite (cdr shallow-pequiv-lst) fn bkptr rewritten-args-rev rest-args alist wrld (cond ((or (not (eq fn (access pequiv-pattern pat :fn))) (not (eql bkptr (access pequiv-pattern pat :posn))) (geneqv-refinementp equiv geneqv wrld)) geneqv) (t (mv-let (flg unify-subst) (one-way-unify1-term-alist-lst (access pequiv-pattern pat :pre-rev) rewritten-args-rev nil (access pequiv pequiv :unify-subst)) (cond ((null flg) geneqv) (t (mv-let (flg unify-subst) (one-way-unify1-term-alist-lst (access pequiv-pattern pat :post) rest-args alist unify-subst) (declare (ignore unify-subst)) (cond ((null flg) geneqv) (t (mv-let (changedp geneqv) (reduce-geneqv-for-equiv equiv wrld geneqv) (declare (ignore changedp)) (cons congruence-rule geneqv)))))))))))))))
geneqv-and-pequiv-info-for-rewritefunction
(defun geneqv-and-pequiv-info-for-rewrite (fn bkptr rewritten-args-rev args alist parent-geneqv child-geneqv deep-pequiv-lst shallow-pequiv-lst wrld) (mv (geneqv-for-rewrite shallow-pequiv-lst fn bkptr rewritten-args-rev (cdr args) alist wrld child-geneqv) (pequiv-info-for-rewrite fn bkptr rewritten-args-rev args alist parent-geneqv deep-pequiv-lst)))
ffnnamespmutual-recursion
(mutual-recursion (defun ffnnamesp (fns term) (cond ((variablep term) nil) ((fquotep term) nil) ((flambda-applicationp term) (or (member-equal (ffn-symb term) fns) (ffnnamesp fns (lambda-body (ffn-symb term))) (ffnnamesp-lst fns (fargs term)))) ((member-eq (ffn-symb term) fns) t) (t (ffnnamesp-lst fns (fargs term))))) (defun ffnnamesp-lst (fns l) (if (null l) nil (or (ffnnamesp fns (car l)) (ffnnamesp-lst fns (cdr l))))))
collect-ffnnamesmutual-recursion
(mutual-recursion (defun collect-ffnnames (fns term ans) (cond ((variablep term) ans) ((fquotep term) ans) ((flambda-applicationp term) (collect-ffnnames fns (lambda-body (ffn-symb term)) (collect-ffnnames-lst fns (fargs term) (if (member-equal (ffn-symb term) fns) (add-to-set-equal (ffn-symb term) ans) ans)))) (t (collect-ffnnames-lst fns (fargs term) (if (member-eq (ffn-symb term) fns) (add-to-set-eq (ffn-symb term) ans) ans))))) (defun collect-ffnnames-lst (fns l ans) (cond ((null l) ans) (t (collect-ffnnames-lst fns (cdr l) (collect-ffnnames fns (car l) ans))))))
comm-equalfunction
(defun comm-equal (fn lhs rhs term) (and (nvariablep term) (not (fquotep term)) (eq fn (ffn-symb term)) (if (equal rhs (fargn term 2)) (equal lhs (fargn term 1)) (and (equal rhs (fargn term 1)) (equal lhs (fargn term 2))))))
member-term2function
(defun member-term2 (fn lhs rhs cl) (cond ((null cl) nil) ((comm-equal fn lhs rhs (car cl)) cl) (t (member-term2 fn lhs rhs (cdr cl)))))
member-complement-term2function
(defun member-complement-term2 (fn lhs rhs cl) (cond ((null cl) nil) ((and (ffn-symb-p (car cl) 'not) (comm-equal fn lhs rhs (fargn (car cl) 1))) cl) (t (member-complement-term2 fn lhs rhs (cdr cl)))))
member-complement-term1function
(defun member-complement-term1 (lit cl) (cond ((null cl) nil) ((and (ffn-symb-p (car cl) 'not) (equal lit (fargn (car cl) 1))) cl) (t (member-complement-term1 lit (cdr cl)))))
member-termmutual-recursion
(mutual-recursion (defun member-term (lit cl) (cond ((variablep lit) (member-eq lit cl)) ((fquotep lit) (member-equal lit cl)) ((or (eq (ffn-symb lit) 'equal) (eq (ffn-symb lit) 'iff)) (member-term2 (ffn-symb lit) (fargn lit 1) (fargn lit 2) cl)) ((eq (ffn-symb lit) 'not) (member-complement-term (fargn lit 1) cl)) (t (member-equal lit cl)))) (defun member-complement-term (lit cl) (cond ((variablep lit) (member-complement-term1 lit cl)) ((fquotep lit) (member-complement-term1 lit cl)) ((or (eq (ffn-symb lit) 'equal) (eq (ffn-symb lit) 'iff)) (member-complement-term2 (ffn-symb lit) (fargn lit 1) (fargn lit 2) cl)) (t (or (and (eq (ffn-symb lit) 'not) (member-term (fargn lit 1) cl)) (member-complement-term1 lit cl))))))
instr-listpfunction
(defun instr-listp (l) (cond ((atom l) (equal l nil)) (t (and (or (integerp (car l)) (let ((carl (car l))) (case-match carl (('push . x) (pseudo-termp x)) (('push-local . n) (integerp n)) (('push-frame-ptr) t) (('go . x) (integerp x)) (('test . x) (integerp x)) (('call . term) (pseudo-termp term)) (('ret . lst) (pseudo-term-listp lst))))) (instr-listp (cdr l))))))
spliced-instr-listpfunction
(defun spliced-instr-listp (l) (cond ((atom l) (equal l nil)) (t (and (let ((carl (car l))) (case-match carl (('push . x) (pseudo-termp x)) (('push-local . n) (integerp n)) (('push-frame-ptr) t) (('test . x) (spliced-instr-listp x)) (('call . term) (pseudo-termp term)) (('ret . lst) (pseudo-term-listp lst)))) (spliced-instr-listp (cdr l))))))
next-tagfunction
(defun next-tag (l) (declare (xargs :guard (instr-listp l))) (cond ((null l) 1) ((and (consp (car l)) (eq (caar l) 'test)) (+ 2 (cdr (car l)))) (t (next-tag (cdr l)))))
if-compile-formalfunction
(defun if-compile-formal (var rformals i) (declare (xargs :guard (and (symbolp var) (true-listp rformals) (member-eq var rformals)))) (cond ((eq var (car rformals)) i) (t (if-compile-formal var (cdr rformals) (1+ i)))))
ffnnamep-hidemutual-recursion
(mutual-recursion (defun ffnnamep-hide (fn term lambda-exp) (cond ((variablep term) nil) ((fquotep term) nil) ((flambda-applicationp term) (or (equal fn (ffn-symb term)) (and lambda-exp (ffnnamep-hide fn (lambda-body (ffn-symb term)) lambda-exp)) (ffnnamep-hide-lst fn (fargs term) lambda-exp))) ((eq (ffn-symb term) fn) t) ((eq (ffn-symb term) 'hide) nil) (t (ffnnamep-hide-lst fn (fargs term) lambda-exp)))) (defun ffnnamep-hide-lst (fn l lambda-exp) (declare (xargs :guard (and (symbolp fn) (pseudo-term-listp l)))) (if (null l) nil (or (ffnnamep-hide fn (car l) lambda-exp) (ffnnamep-hide-lst fn (cdr l) lambda-exp)))))
if-compilemutual-recursion
(mutual-recursion (defun if-compile (term lambda-exp ac rformals) (declare (xargs :guard (pseudo-termp term))) (cond ((variablep term) (cond (rformals (cons (cons 'push-local (if-compile-formal term rformals 0)) ac)) (t (cons (cons 'push term) ac)))) ((or (fquotep term) (eq (ffn-symb term) 'hide)) (cons (cons 'push term) ac)) ((flambdap (ffn-symb term)) (cond ((and lambda-exp (ffnnamep-hide 'if (lambda-body (ffn-symb term)) lambda-exp)) (cons (cons 'ret (lambda-formals (ffn-symb term))) (if-compile (lambda-body (ffn-symb term)) lambda-exp (cons '(push-frame-ptr) (if-compile-lst (fargs term) lambda-exp ac rformals)) (revappend (lambda-formals (ffn-symb term)) nil)))) ((or (ffnnamep-hide-lst 'if (fargs term) lambda-exp) rformals) (cons (cons 'call term) (if-compile-lst (fargs term) lambda-exp ac rformals))) (t (cons (cons 'push term) ac)))) ((eq (ffn-symb term) 'if) (let* ((test-seg (if-compile (fargn term 1) lambda-exp ac rformals)) (n (next-tag test-seg))) (cons (+ n 1) (if-compile (fargn term 3) lambda-exp (cons n (cons (cons 'go (+ n 1)) (if-compile (fargn term 2) lambda-exp (cons (cons 'test n) test-seg) rformals))) rformals)))) ((or (ffnnamep-hide-lst 'if (fargs term) lambda-exp) rformals) (cons (cons 'call term) (if-compile-lst (fargs term) lambda-exp ac rformals))) (t (cons (cons 'push term) ac)))) (defun if-compile-lst (l lambda-exp ac rformals) (declare (xargs :guard (pseudo-term-listp l))) (cond ((null l) ac) (t (if-compile-lst (cdr l) lambda-exp (if-compile (car l) lambda-exp ac rformals) rformals)))))
if-interp-assume-truefunction
(defun if-interp-assume-true (not-flg term assumptions) (cond ((variablep term) (if not-flg (cons :not (cons term assumptions)) (cons term assumptions))) ((eq (ffn-symb term) 'not) (if-interp-assume-true (not not-flg) (fargn term 1) assumptions)) (t (if not-flg (cons :not (cons term assumptions)) (cons term assumptions)))))
if-interp-switchfunction
(defun if-interp-switch (assumptions) (cond ((eq (car assumptions) :not) (cdr assumptions)) (t (cons :not assumptions))))
if-interp-assumed-value0function
(defun if-interp-assumed-value0 (var assumptions) (cond ((null assumptions) nil) ((eq (car assumptions) :not) (cond ((eq var (cadr assumptions)) 'f) (t (if-interp-assumed-value0 var (cddr assumptions))))) ((eq (car assumptions) var) 't) (t (if-interp-assumed-value0 var (cdr assumptions)))))
if-interp-assumed-value1function
(defun if-interp-assumed-value1 (term assumptions) (cond ((null assumptions) nil) ((eq (car assumptions) :not) (cond ((equal term (cadr assumptions)) 'f) (t (if-interp-assumed-value1 term (cddr assumptions))))) ((equal (car assumptions) term) 't) (t (if-interp-assumed-value1 term (cdr assumptions)))))
if-interp-assumed-value2-equal-constantfunction
(defun if-interp-assumed-value2-equal-constant (arg const1 assumptions) (cond ((null assumptions) nil) ((eq (car assumptions) :not) (let ((term (cadr assumptions))) (cond ((variablep term) (if-interp-assumed-value2-equal-constant arg const1 (cddr assumptions))) ((and (eq 'equal (ffn-symb term)) (or (and (equal arg (fargn term 1)) (equal const1 (fargn term 2))) (and (equal arg (fargn term 2)) (equal const1 (fargn term 1))))) 'f) (t (if-interp-assumed-value2-equal-constant arg const1 (cddr assumptions)))))) (t (let ((term (car assumptions))) (cond ((variablep term) (if-interp-assumed-value2-equal-constant arg const1 (cdr assumptions))) (t (let ((term-fn (ffn-symb term))) (cond ((eq term-fn 'equal) (cond ((or (and (equal arg (fargn term 1)) (equal const1 (fargn term 2))) (and (equal arg (fargn term 2)) (equal const1 (fargn term 1)))) 't) ((or (and (equal arg (fargn term 1)) (quotep (fargn term 2)) (not (equal const1 (fargn term 2)))) (and (equal arg (fargn term 2)) (quotep (fargn term 1)) (not (equal const1 (fargn term 1))))) 'f) (t (if-interp-assumed-value2-equal-constant arg const1 (cdr assumptions))))) (t (if-interp-assumed-value2-equal-constant arg const1 (cdr assumptions)))))))))))
if-interp-assumed-value2function
(defun if-interp-assumed-value2 (fn arg1 arg2 assumptions) (cond ((null assumptions) nil) ((eq (car assumptions) :not) (let ((term (cadr assumptions))) (cond ((variablep term) (if-interp-assumed-value2 fn arg1 arg2 (cddr assumptions))) ((and (eq fn (ffn-symb term)) (or (and (equal arg1 (fargn term 1)) (equal arg2 (fargn term 2))) (and (equal arg1 (fargn term 2)) (equal arg2 (fargn term 1))))) 'f) (t (if-interp-assumed-value2 fn arg1 arg2 (cddr assumptions)))))) ((let* ((term (car assumptions)) (term-fn (and (nvariablep term) (ffn-symb term)))) (and (eq fn term-fn) (or (and (equal arg1 (fargn term 1)) (equal arg2 (fargn term 2))) (and (equal arg1 (fargn term 2)) (equal arg2 (fargn term 1)))))) 't) (t (if-interp-assumed-value2 fn arg1 arg2 (cdr assumptions)))))
if-interp-assumed-value3function
(defun if-interp-assumed-value3 (term assumptions) (cond ((null assumptions) nil) ((eq (car assumptions) :not) (cond ((equal term (cadr assumptions)) 'f) (t (if-interp-assumed-value3 term (cddr assumptions))))) ((equal (car assumptions) term) 't) ((and (ffn-symb-p (car assumptions) 'integerp) (equal (fargn term 1) (fargn (car assumptions) 1))) 't) (t (if-interp-assumed-value3 term (cdr assumptions)))))
if-interp-assumed-value4function
(defun if-interp-assumed-value4 (term assumptions) (cond ((null assumptions) nil) ((eq (car assumptions) :not) (cond ((equal term (cadr assumptions)) 'f) ((and (ffn-symb-p (cadr assumptions) 'rationalp) (equal (fargn term 1) (fargn (cadr assumptions) 1))) 'f) (t (if-interp-assumed-value4 term (cddr assumptions))))) ((equal (car assumptions) term) 't) (t (if-interp-assumed-value4 term (cdr assumptions)))))
if-interp-assumed-value-xfunction
(defun if-interp-assumed-value-x (term assumptions) (cond ((variablep term) (if-interp-assumed-value0 term assumptions)) ((eq (ffn-symb term) 'equal) (cond ((quotep (fargn term 1)) (if-interp-assumed-value2-equal-constant (fargn term 2) (fargn term 1) assumptions)) ((quotep (fargn term 2)) (if-interp-assumed-value2-equal-constant (fargn term 1) (fargn term 2) assumptions)) (t (if-interp-assumed-value2 (ffn-symb term) (fargn term 1) (fargn term 2) assumptions)))) ((eq (ffn-symb term) 'iff) (if-interp-assumed-value2 (ffn-symb term) (fargn term 1) (fargn term 2) assumptions)) ((eq (ffn-symb term) 'rationalp) (if-interp-assumed-value3 term assumptions)) ((eq (ffn-symb term) 'integerp) (if-interp-assumed-value4 term assumptions)) (t (if-interp-assumed-value1 term assumptions))))
if-interp-assumed-valuefunction
(defun if-interp-assumed-value (term assumptions) (cond ((variablep term) (if-interp-assumed-value0 term assumptions)) ((eq (ffn-symb term) 'not) (let ((temp (if-interp-assumed-value-x (fargn term 1) assumptions))) (cond ((eq temp t) 'f) ((eq temp 'f) t) (t nil)))) (t (if-interp-assumed-value-x term assumptions))))
convert-assumptions-to-clause-segmentfunction
(defun convert-assumptions-to-clause-segment (assumptions ans known-constants) (cond ((or (null assumptions) (eq (car assumptions) :ignore-when-converting-to-clause)) ans) ((eq (car assumptions) :not) (let ((test (cadr assumptions))) (cond ((and (ffn-symb-p test 'equal) (or (quotep (fargn test 1)) (quotep (fargn test 2)))) (cond ((quotep (fargn test 1)) (let* ((x (fargn test 2)) (const2 (fargn test 1)) (temp (assoc-equal x known-constants))) (cond ((and temp (not (equal const2 (cdr temp)))) (convert-assumptions-to-clause-segment (cddr assumptions) ans known-constants)) (t (convert-assumptions-to-clause-segment (cddr assumptions) (cons test ans) known-constants))))) ((quotep (fargn test 2)) (let* ((x (fargn test 1)) (const2 (fargn test 2)) (temp (assoc-equal x known-constants))) (cond ((and temp (not (equal const2 (cdr temp)))) (convert-assumptions-to-clause-segment (cddr assumptions) ans known-constants)) (t (convert-assumptions-to-clause-segment (cddr assumptions) (cons test ans) known-constants))))) (t (convert-assumptions-to-clause-segment (cddr assumptions) (cons test ans) known-constants)))) (t (convert-assumptions-to-clause-segment (cddr assumptions) (cons test ans) known-constants))))) (t (let ((test (car assumptions))) (cond ((and (ffn-symb-p test 'equal) (or (quotep (fargn test 1)) (quotep (fargn test 2)))) (cond ((quotep (fargn test 1)) (convert-assumptions-to-clause-segment (cdr assumptions) (cons (list 'not test) ans) (cons (cons (fargn test 2) (fargn test 1)) known-constants))) ((quotep (fargn test 2)) (convert-assumptions-to-clause-segment (cdr assumptions) (cons (list 'not test) ans) (cons (cons (fargn test 1) (fargn test 2)) known-constants))) (t (convert-assumptions-to-clause-segment (cdr assumptions) (cons (list 'not test) ans) known-constants)))) (t (convert-assumptions-to-clause-segment (cdr assumptions) (cons (list 'not test) ans) known-constants)))))))
convert-clause-to-assumptionsfunction
(defun convert-clause-to-assumptions (clause ans) (cond ((null clause) (cons :ignore-when-converting-to-clause ans)) (t (convert-clause-to-assumptions (cdr clause) (if-interp-assume-true t (car clause) ans)))))
simplifiable-mv-nth1function
(defun simplifiable-mv-nth1 (n cons-term alist) (cond ((variablep cons-term) (let ((temp (assoc-eq cons-term alist))) (cond (temp (mv-let (term1 rewritep) (simplifiable-mv-nth1 n (cdr temp) nil) (declare (ignore rewritep)) (mv term1 nil))) (t (mv nil nil))))) ((fquotep cons-term) (cond ((and (true-listp (cadr cons-term)) (> (length (cadr cons-term)) n)) (mv (kwote (nth n (cadr cons-term))) t)) (t (mv nil nil)))) ((eq (ffn-symb cons-term) 'cons) (if (= n 0) (mv (fargn cons-term 1) t) (simplifiable-mv-nth1 (1- n) (fargn cons-term 2) alist))) (t (mv nil nil))))
other
(defattach simplifiable-mv-nth-p constant-t-function-arity-0)
simplifiable-mv-nthfunction
(defun simplifiable-mv-nth (term alist) (cond ((simplifiable-mv-nth-p) (let ((arg1 (cond ((variablep (fargn term 1)) (let ((temp (assoc-eq (fargn term 1) alist))) (cond (temp (cdr temp)) (t (fargn term 1))))) (t (fargn term 1))))) (cond ((and (quotep arg1) (integerp (cadr arg1)) (>= (cadr arg1) 0)) (simplifiable-mv-nth1 (cadr arg1) (fargn term 2) alist)) (t (mv nil nil))))) (t (mv nil nil))))
call-stackfunction
(defun call-stack (fn lst stack assumptions ac) (declare (xargs :guard (and (true-listp lst) (true-listp stack) (>= (length stack) (length lst))))) (cond ((null lst) (cons (cond ((eq fn 'not) (let ((x (car ac))) (cond ((quotep x) (if (eq (cadr x) nil) *t* *nil*)) (t (let ((temp (if-interp-assumed-value x assumptions))) (cond ((eq temp t) *nil*) ((eq temp 'f) *t*) (t (list 'not x)))))))) ((eq fn 'equal) (cond ((equal (car ac) (cadr ac)) *t*) ((and (quotep (car ac)) (quotep (cadr ac))) *nil*) ((and (equal (car ac) *t*) (ffn-symb-p (cadr ac) 'equal)) (cadr ac)) ((and (equal (cadr ac) *t*) (ffn-symb-p (car ac) 'equal)) (car ac)) (t (fcons-term fn ac)))) ((eq fn '<) (cond ((equal (car ac) (cadr ac)) *nil*) ((and (quotep (car ac)) (quotep (cadr ac)) (rationalp (cadr (car ac))) (rationalp (cadr (cadr ac)))) (if (< (cadr (car ac)) (cadr (cadr ac))) *t* *nil*)) (t (cons-term fn ac)))) ((eq fn 'iff) (let ((arg1 (car ac)) (arg2 (cadr ac))) (cond ((equal arg1 arg2) *t*) (t (let ((temp1 (if (quotep arg1) (if (eq (cadr arg1) nil) 'f t) (if-interp-assumed-value arg1 assumptions))) (temp2 (if (quotep arg2) (if (eq (cadr arg2) nil) 'f t) (if-interp-assumed-value arg2 assumptions)))) (cond ((and temp1 temp2) (if (eq temp1 temp2) *t* *nil*)) (t (fcons-term fn ac)))))))) ((eq fn 'mv-nth) (let ((term (fcons-term fn ac))) (mv-let (term1 rewritep) (simplifiable-mv-nth term nil) (declare (ignore rewritep)) (or term1 term)))) (t (cons-term fn ac))) stack)) (t (call-stack fn (cdr lst) (cdr stack) assumptions (cons (car stack) ac)))))
ret-stackfunction
(defun ret-stack (lst stack) (cond ((null lst) stack) (t (ret-stack (cdr lst) (cdr stack)))))
extra-info-lit-pfunction
(defun extra-info-lit-p (lit) (and (ffn-symb-p lit 'not) (let ((atm (fargn lit 1))) (and (nvariablep atm) (eq (ffn-symb atm) *extra-info-fn*)))))
subsetp-equal-mod-extra-info-litsfunction
(defun subsetp-equal-mod-extra-info-lits (x y) (declare (xargs :guard (and (true-listp y) (true-listp x)))) (cond ((endp x) t) ((or (extra-info-lit-p (car x)) (member-equal (car x) y)) (subsetp-equal-mod-extra-info-lits (cdr x) y)) (t nil)))
quick-and-dirty-subsumption-replacement-step1function
(defun quick-and-dirty-subsumption-replacement-step1 (cl1 cl2) (cond ((null cl1) 'subsumed2) ((extra-info-lit-p (car cl1)) (quick-and-dirty-subsumption-replacement-step1 (cdr cl1) cl2)) ((null cl2) 'subsumed1) ((extra-info-lit-p (car cl2)) (quick-and-dirty-subsumption-replacement-step1 cl1 (cdr cl2))) ((equal (car cl1) (car cl2)) (let ((ans (quick-and-dirty-subsumption-replacement-step1 (cdr cl1) (cdr cl2)))) (cond ((symbolp ans) ans) (t (cons (car cl1) ans))))) ((and (complementaryp (car cl1) (car cl2)) (subsetp-equal-mod-extra-info-lits (cdr cl1) (cdr cl2))) (cdr cl2)) (t nil)))
quick-and-dirty-subsumption-replacement-stepfunction
(defun quick-and-dirty-subsumption-replacement-step (cl1 lst) (cond ((null lst) nil) ((time-limit5-reached-p "Out of time in subsumption ~ (quick-and-dirty-subsumption-replacement-step).") nil) (t (let ((cl3 (quick-and-dirty-subsumption-replacement-step1 cl1 (car lst)))) (cond ((eq cl3 'subsumed1) 'subsumed1) (t (let ((ans (quick-and-dirty-subsumption-replacement-step cl1 (cdr lst)))) (cond ((eq cl3 'subsumed2) ans) ((eq ans 'subsumed1) ans) ((null cl3) (cons (car lst) ans)) (t (cons cl3 ans))))))))))
quick-and-dirty-srs-builtinfunction
(defun quick-and-dirty-srs-builtin (cl1 ac) (declare (ignore cl1 ac) (xargs :mode :logic :guard t)) t)
other
(defattach quick-and-dirty-srs quick-and-dirty-srs-builtin)
if-interp-add-clausefunction
(defun if-interp-add-clause (assumptions cl ac pflg) (cond (pflg t) (t (let ((cl1 (convert-assumptions-to-clause-segment assumptions cl nil))) (cond ((quick-and-dirty-srs cl1 ac) (let ((ans (quick-and-dirty-subsumption-replacement-step cl1 ac))) (cond ((eq ans 'subsumed1) ac) (t (cons cl1 ans))))) (t (cons cl1 ac)))))))
if-interpfunction
(defun if-interp (instrs stack frame-ptr-stack assumptions ac pflg) (declare (type (or null (unsigned-byte 60)) pflg)) (cond ((null instrs) (let ((v (car stack))) (or (cond ((quotep v) (cond ((equal v *nil*) (if-interp-add-clause assumptions nil ac pflg)) (t ac))) (t (let ((assumed-val (if-interp-assumed-value v assumptions))) (cond ((eq assumed-val t) ac) ((eq assumed-val 'f) (if-interp-add-clause assumptions nil ac pflg)) (t (if-interp-add-clause assumptions (list v) ac pflg)))))) pflg))) ((and pflg (zpf pflg)) 0) (t (let ((caarinstrs (caar instrs)) (pflg (and pflg (1-f pflg)))) (declare (type (or null (unsigned-byte 60)) pflg)) (case caarinstrs (push (if-interp (cdr instrs) (cons (cdr (car instrs)) stack) frame-ptr-stack assumptions ac pflg)) (push-local (if-interp (cdr instrs) (cons (nth (cdr (car instrs)) (car frame-ptr-stack)) stack) frame-ptr-stack assumptions ac pflg)) (push-frame-ptr (if-interp (cdr instrs) stack (cons stack frame-ptr-stack) assumptions ac pflg)) (ret (if-interp (cdr instrs) (cons (car stack) (ret-stack (cdr (car instrs)) (cdr stack))) (cdr frame-ptr-stack) assumptions ac pflg)) (call (if-interp (cdr instrs) (call-stack (cadr (car instrs)) (cddr (car instrs)) stack assumptions nil) frame-ptr-stack assumptions ac pflg)) (test (let* ((v (car stack)) (stack (cdr stack))) (cond ((quotep v) (cond ((equal v *nil*) (if-interp (cdr (car instrs)) stack frame-ptr-stack assumptions ac pflg)) (t (if-interp (cdr instrs) stack frame-ptr-stack assumptions ac pflg)))) (t (let ((temp (if-interp-assumed-value v assumptions))) (cond ((eq temp 'f) (if-interp (cdr (car instrs)) stack frame-ptr-stack assumptions ac pflg)) ((eq temp t) (if-interp (cdr instrs) stack frame-ptr-stack assumptions ac pflg)) (pflg (let ((assumptions (if-interp-assume-true nil v assumptions))) (let ((pflg (if-interp (cdr instrs) stack frame-ptr-stack assumptions ac pflg))) (cond ((eq pflg t) t) (t (if-interp (cdr (car instrs)) stack frame-ptr-stack (if-interp-switch assumptions) ac pflg)))))) (t (let ((assumptions (if-interp-assume-true nil v assumptions))) (if-interp (cdr instrs) stack frame-ptr-stack assumptions (if-interp (cdr (car instrs)) stack frame-ptr-stack (if-interp-switch assumptions) ac pflg) pflg))))))))))))))
splice-instrs1function
(defun splice-instrs1 (instrs ans alist) (declare (xargs :guard (instr-listp instrs))) (cond ((null instrs) ans) ((atom (car instrs)) (splice-instrs1 (cdr instrs) ans (cons (cons (car instrs) ans) alist))) (t (let ((caarinstrs (caar instrs))) (case caarinstrs ((push push-local push-frame-ptr call ret) (splice-instrs1 (cdr instrs) (cons (car instrs) ans) alist)) (test (splice-instrs1 (cdr instrs) (cons (cons 'test (cdr (assoc (cdr (car instrs)) alist))) ans) alist)) (go (splice-instrs1 (cdr instrs) (cdr (assoc (cdr (car instrs)) alist)) alist)))))))
splice-instrsfunction
(defun splice-instrs (instrs) (declare (xargs :guard (instr-listp instrs))) (splice-instrs1 instrs nil nil))
strip-branchesfunction
(defun strip-branches (term assumptions lambda-exp) (declare (xargs :guard (pseudo-termp term))) (cond ((and (ffn-symb-p term 'if) (equal (fargn term 3) *nil*)) (union-equal (strip-branches (fargn term 1) assumptions lambda-exp) (strip-branches (fargn term 2) assumptions lambda-exp))) (t (if-interp (splice-instrs (if-compile term lambda-exp nil nil)) nil nil assumptions nil nil))))
merge-lengthfunction
(defun merge-length (l1 l2) (declare (xargs :guard (and (true-list-listp l1) (true-list-listp l2)))) (cond ((null l1) l2) ((null l2) l1) ((<= (length (car l1)) (length (car l2))) (cons (car l1) (merge-length (cdr l1) l2))) (t (cons (car l2) (merge-length l1 (cdr l2))))))
merge-sort-lengthfunction
(defun merge-sort-length (l) (declare (xargs :guard (true-list-listp l))) (cond ((null (cdr l)) l) (t (merge-length (merge-sort-length (evens l)) (merge-sort-length (odds l))))))
member-equal-+-function
(defun member-equal-+- (lit clause) (cond ((null clause) nil) ((equal lit (car clause)) '+) ((complementaryp lit (car clause)) '-) (t (member-equal-+- lit (cdr clause)))))
arg1-almost-subsumes-arg2function
(defun arg1-almost-subsumes-arg2 (arg1 arg2) (declare (xargs :guard (and (pseudo-term-listp arg1) (pseudo-term-listp arg2)))) (cond ((null arg1) 'subsumed) ((extra-info-lit-p (car arg1)) (arg1-almost-subsumes-arg2 (cdr arg1) arg2)) (t (let ((sign (member-equal-+- (car arg1) arg2))) (cond ((null sign) nil) ((eq sign '+) (arg1-almost-subsumes-arg2 (cdr arg1) arg2)) ((subsetp-equal-mod-extra-info-lits (cdr arg1) arg2) arg1) (t nil))))))
find-subsumer-replacement-recfunction
(defun find-subsumer-replacement-rec (cl l len-cl) (declare (xargs :guard (and (pseudo-term-listp cl) (pseudo-term-list-listp l) (equal len-cl (length cl))))) (cond ((null l) (mv nil nil)) ((> (len (car l)) len-cl) (find-subsumer-replacement-rec cl (cdr l) len-cl)) (t (let ((here (arg1-almost-subsumes-arg2 (car l) cl))) (cond ((eq here 'subsumed) (mv here (car l))) (t (mv-let (rst cl0) (find-subsumer-replacement-rec cl (cdr l) len-cl) (cond ((eq rst 'subsumed) (mv rst cl0)) (t (mv (or here rst) nil))))))))))
find-subsumer-replacementfunction
(defun find-subsumer-replacement (cl l) (declare (xargs :guard (and (pseudo-term-listp cl) (pseudo-term-list-listp l)))) (find-subsumer-replacement-rec cl l (length cl)))
remove-one-complementfunction
(defun remove-one-complement (lit cl) (declare (xargs :guard (and (pseudo-termp lit) (pseudo-term-listp cl)))) (cond ((null cl) nil) ((complementaryp lit (car cl)) (cdr cl)) (t (cons (car cl) (remove-one-complement lit (cdr cl))))))
weak-disc-treefunction
(defun weak-disc-tree (x) (and (or (consp x) (equal x nil)) (cond ((equal (car x) 'node) (and (true-listp x) (equal (length x) 4) (pseudo-termp (cadr x)) (weak-disc-tree (caddr x)) (weak-disc-tree (cadddr x)))) (t (pseudo-term-list-listp (cdr x))))))
sweep-clauses1function
(defun sweep-clauses1 (tree ac) (declare (xargs :guard (weak-disc-tree tree))) (cond ((eq (car tree) 'node) (sweep-clauses1 (caddr tree) (sweep-clauses1 (cadddr tree) ac))) (t (append (cdr tree) ac))))
sweep-clausesfunction
(defun sweep-clauses (tree) (declare (xargs :guard (weak-disc-tree tree))) (sweep-clauses1 tree nil))
filter-with-and-withoutfunction
(defun filter-with-and-without (x l with-lst without-lst) (cond ((null l) (mv with-lst without-lst)) ((or (extra-info-lit-p x) (member-equal-+- x (car l))) (filter-with-and-without x (cdr l) (cons (car l) with-lst) without-lst)) (t (filter-with-and-without x (cdr l) with-lst (cons (car l) without-lst)))))
disc-treefunction
(defun disc-tree (x) (and (or (consp x) (equal x nil)) (cond ((equal (car x) 'node) (and (true-listp x) (equal (length x) 4) (pseudo-termp (cadr x)) (disc-tree (caddr x)) (disc-tree (cadddr x)) (mv-let (with-lst without-lst) (filter-with-and-without (cadr x) (sweep-clauses (caddr x)) nil nil) (declare (ignore with-lst)) (null without-lst)) (mv-let (with-lst without-lst) (filter-with-and-without (cadr x) (sweep-clauses (cadddr x)) nil nil) (declare (ignore without-lst)) (null with-lst)))) (t (pseudo-term-list-listp (cdr x))))))
find-clauses1function
(defun find-clauses1 (clause tree ac) (declare (xargs :guard (and (disc-tree tree) (pseudo-term-listp clause) (pseudo-term-list-listp ac)))) (cond ((eq (car tree) 'node) (cond ((or (extra-info-lit-p (cadr tree)) (member-equal-+- (cadr tree) clause)) (find-clauses1 clause (caddr tree) (find-clauses1 clause (cadddr tree) ac))) (t (find-clauses1 clause (cadddr tree) ac)))) (t (append (cdr tree) ac))))
find-clausesfunction
(defun find-clauses (clause tree) (find-clauses1 clause tree nil))
remove-one-+-function
(defun remove-one-+- (x l) (cond ((null l) nil) ((equal x (car l)) (cdr l)) ((complementaryp x (car l)) (cdr l)) (t (cons (car l) (remove-one-+- x (cdr l))))))
store-clause1function
(defun store-clause1 (clause undisc-lits tree) (declare (xargs :guard (and (pseudo-term-listp clause) (pseudo-term-listp undisc-lits) (disc-tree tree)))) (cond ((eq (car tree) 'node) (cond ((extra-info-lit-p (cadr tree)) (list 'node (cadr tree) (store-clause1 clause undisc-lits (caddr tree)) (cadddr tree))) ((member-equal-+- (cadr tree) clause) (list 'node (cadr tree) (store-clause1 clause (remove-one-+- (cadr tree) undisc-lits) (caddr tree)) (cadddr tree))) (t (list 'node (cadr tree) (caddr tree) (store-clause1 clause undisc-lits (cadddr tree)))))) ((null undisc-lits) (cons 'tip (cons clause (cdr tree)))) ((extra-info-lit-p (car undisc-lits)) (store-clause1 clause (cdr undisc-lits) tree)) (t (mv-let (with-lst without-lst) (filter-with-and-without (car undisc-lits) (cdr tree) nil nil) (store-clause1 clause undisc-lits (list 'node (car undisc-lits) (cons 'tip with-lst) (cons 'tip without-lst)))))))
store-clausefunction
(defun store-clause (cl tree) (store-clause1 cl cl tree))
substitute1-acfunction
(defun substitute1-ac (new old seq acc) (declare (xargs :guard (and (true-listp acc) (true-listp seq) (member-equal old seq)))) (cond ((endp seq) (er hard 'substitute "Attempted to substitute ~x0 for ~x1 into a sequence in which the ~ latter was not an element." new old)) ((equal old (car seq)) (revappend acc (cons new (cdr seq)))) (t (substitute1-ac new old (cdr seq) (cons (car seq) acc)))))
substitute1function
(defun substitute1 (new old seq) (declare (xargs :guard (and (true-listp seq) (member-equal old seq)))) (substitute1-ac new old seq nil))
replace-clause1function
(defun replace-clause1 (clause undisc-lits new-clause tree) (declare (xargs :guard (and (pseudo-term-listp clause) (pseudo-term-listp undisc-lits) (disc-tree tree)))) (cond ((eq (car tree) 'node) (cond ((member-equal-+- (cadr tree) clause) (list 'node (cadr tree) (replace-clause1 clause (remove-one-+- (cadr tree) undisc-lits) new-clause (caddr tree)) (cadddr tree))) (t (list 'node (cadr tree) (caddr tree) (replace-clause1 clause undisc-lits new-clause (cadddr tree)))))) ((member-equal clause (cdr tree)) (cons (car tree) (substitute1 new-clause clause (cdr tree)))) (t tree)))
replace-clausefunction
(defun replace-clause (clause new-clause tree) (declare (xargs :guard (and (pseudo-term-listp clause) (disc-tree tree)))) (replace-clause1 clause clause new-clause tree))
extra-info-litsfunction
(defun extra-info-lits (cl acc) (cond ((endp cl) acc) ((extra-info-lit-p (car cl)) (extra-info-lits (cdr cl) (cons (car cl) acc))) (t (extra-info-lits (cdr cl) acc))))
merge-extra-info-litsfunction
(defun merge-extra-info-lits (cl cl0 tree) (let ((lits (extra-info-lits cl nil))) (cond (lits (replace-clause cl0 (rev-union-equal lits cl0) tree)) (t tree))))
subsumption-replacement-loopfunction
(defun subsumption-replacement-loop (todo done-tree again-flg) (declare (xargs :guard (and (pseudo-term-list-listp todo) (disc-tree done-tree)))) (cond ((null todo) (cond (again-flg (cond ((time-limit5-reached-p "Out of time in subsumption (subsumption-replacement-loop).") nil) (t (subsumption-replacement-loop (merge-sort-length (sweep-clauses done-tree)) nil nil)))) (t (sweep-clauses done-tree)))) (t (mv-let (x cl0) (find-subsumer-replacement (car todo) (find-clauses (car todo) done-tree)) (cond ((null x) (subsumption-replacement-loop (cdr todo) (store-clause (car todo) done-tree) again-flg)) ((eq x 'subsumed) (subsumption-replacement-loop (cdr todo) (merge-extra-info-lits (car todo) cl0 done-tree) again-flg)) (t (subsumption-replacement-loop (cdr todo) (store-clause (remove-one-complement (car x) (car todo)) done-tree) t)))))))
clausifyfunction
(defun clausify (term assumptions lambda-exp sr-limit) (declare (xargs :guard (pseudo-termp term))) (let ((clauses (pstk (strip-branches term assumptions lambda-exp)))) (cond ((or (null sr-limit) (<= (length clauses) sr-limit)) (pstk (subsumption-replacement-loop (merge-sort-length clauses) nil nil))) (t clauses))))
find-rewriting-equivalencefunction
(defun find-rewriting-equivalence (lhs type-alist geneqv wrld ttree) (cond ((null type-alist) (mv nil nil ttree)) (t (let ((entry (car type-alist))) (cond ((not (variablep (car entry))) (let ((rw-equivp (cond ((and (eq (ffn-symb (car entry)) 'hide) (not (variablep (fargn (car entry) 1))) (eq (ffn-symb (fargn (car entry) 1)) 'rewrite-equiv)) (car entry))))) (cond ((if rw-equivp (ts-disjointp (cadr entry) *ts-nil*) (ts= (cadr entry) *ts-t*)) (let* ((equiv-term (cond (rw-equivp (fargn (fargn (car entry) 1) 1)) (t (car entry)))) (rune (and (not (flambdap (ffn-symb equiv-term))) (geneqv-refinementp (ffn-symb equiv-term) geneqv wrld)))) (cond ((and rune (equal (fargn equiv-term 1) lhs)) (mv rw-equivp equiv-term (cons-tag-trees (cddr entry) (push-lemma rune ttree)))) (t (find-rewriting-equivalence lhs (cdr type-alist) geneqv wrld ttree))))) (t (find-rewriting-equivalence lhs (cdr type-alist) geneqv wrld ttree))))) (t (find-rewriting-equivalence lhs (cdr type-alist) geneqv wrld ttree)))))))
obj-tablefunction
(defun obj-table (term ts ts-ttree obj geneqv wrld ttree) (declare (ignore obj)) (cond ((ts= ts *ts-t*) (mv *t* (cons-tag-trees ts-ttree ttree))) ((ts= ts *ts-nil*) (mv *nil* (cons-tag-trees ts-ttree ttree))) ((ts= ts *ts-zero*) (mv *0* (cons-tag-trees ts-ttree ttree))) (t (let ((rune (geneqv-refinementp 'iff geneqv wrld))) (cond (rune (cond ((ts-subsetp *ts-nil* ts) (mv term ttree)) (t (mv *t* (push-lemma rune (cons-tag-trees ts-ttree ttree)))))) (t (mv term ttree)))))))
rewrite-solidify-recfunction
(defun rewrite-solidify-rec (bound term type-alist obj geneqv ens wrld ttree pot-lst pt) (declare (type (unsigned-byte 60) bound)) (cond ((quotep term) (cond ((equal term *nil*) (mv *nil* ttree)) (t (let ((rune (geneqv-refinementp 'iff geneqv wrld))) (cond (rune (mv *t* (push-lemma rune ttree))) (t (mv term ttree))))))) ((ffn-symb-p term 'if) (mv term ttree)) ((and (ffn-symb-p term 'hide) (let ((e (fargn term 1))) (case-match e (('rewrite-equiv (equiv x x)) (prog2$ x (equivalence-relationp equiv wrld))) (& nil)))) (mv *t* (push-lemma (fn-rune-nume 'hide nil nil wrld) (push-lemma (fn-rune-nume 'rewrite-equiv nil nil wrld) ttree)))) (t (mv-let (rw-equivp eterm ttree) (find-rewriting-equivalence term type-alist geneqv wrld ttree) (cond (eterm (let ((new-bound (cond ((not rw-equivp) bound) ((zpf bound) (prog2$ (er hard 'rewrite-solidify "You appear to have hit the unusual case ~ of a loop in the replacement of terms by ~ equivalent terms using rewrite-equiv. ~ The term ~x0 is involved in the loop." rw-equivp) 0)) (t (1-f bound))))) (declare (type (unsigned-byte 60) new-bound)) (rewrite-solidify-rec new-bound (fargn eterm 2) type-alist obj geneqv ens wrld ttree pot-lst pt))) (t (mv-let (ts ts-ttree) (cond ((not (eq obj '?)) (type-set term nil t type-alist ens wrld nil pot-lst pt)) (t (assoc-type-alist term type-alist wrld))) (if (null ts) (mv term ttree) (obj-table term ts ts-ttree obj geneqv wrld ttree)))))))))
*rewrite-equiv-solidify-iteration-bound*constant
(defconst *rewrite-equiv-solidify-iteration-bound* 100)
rewrite-solidifyfunction
(defun rewrite-solidify (term type-alist obj geneqv ens wrld ttree pot-lst pt) (rewrite-solidify-rec *rewrite-equiv-solidify-iteration-bound* term type-alist obj geneqv ens wrld ttree pot-lst pt))
rewrite-if11function
(defun rewrite-if11 (term type-alist geneqv wrld ttree) (mv-let (ts ts-ttree) (look-in-type-alist term type-alist wrld) (cond ((ts= ts *ts-nil*) (mv *nil* (cons-tag-trees ts-ttree ttree))) ((and (equal geneqv *geneqv-iff*) (ts-disjointp ts *ts-nil*)) (mv *t* (cons-tag-trees ts-ttree ttree))) (t (mv term ttree)))))
other
(defattach (rewrite-if-avoid-swap constant-nil-function-arity-0))
rewrite-if1function
(defun rewrite-if1 (test left right swapped-p type-alist geneqv ens ok-to-force wrld ttree) (flet ((if-call (test left right swapped-p) (cond ((and swapped-p (rewrite-if-avoid-swap)) (mcons-term* 'if (dumb-negate-lit test) right left)) (t (mcons-term* 'if test left right))))) (cond ((equal left right) (mv left ttree)) ((equal right *nil*) (cond ((equal test left) (mv test ttree)) ((equal left *t*) (mv-let (ts ts-ttree) (type-set test ok-to-force nil type-alist ens wrld ttree nil nil) (cond ((ts-subsetp ts *ts-boolean*) (mv test ts-ttree)) (t (rewrite-if11 (if-call test left right swapped-p) type-alist geneqv wrld ttree))))) (t (rewrite-if11 (if-call test left right swapped-p) type-alist geneqv wrld ttree)))) ((and swapped-p (equal left *nil*) (equal right *t*) (rewrite-if-avoid-swap)) (mv (fcons-term* 'not test) ttree)) (t (rewrite-if11 (if-call test left right swapped-p) type-alist geneqv wrld ttree)))))
member-equal-mod-alistfunction
(defun member-equal-mod-alist (term1 alist1 term2-lst) (cond ((endp term2-lst) nil) ((equal-mod-alist term1 alist1 (car term2-lst)) t) (t (member-equal-mod-alist term1 alist1 (cdr term2-lst)))))
not-to-be-rewrittenp1function
(defun not-to-be-rewrittenp1 (fn lst) (cond ((null lst) nil) ((equal fn (ffn-symb (car lst))) t) (t (not-to-be-rewrittenp1 fn (cdr lst)))))
not-to-be-rewrittenpfunction
(defun not-to-be-rewrittenp (term alist terms-to-be-ignored-by-rewrite) (cond ((not-to-be-rewrittenp1 (ffn-symb term) terms-to-be-ignored-by-rewrite) (member-equal-mod-alist term alist terms-to-be-ignored-by-rewrite)) (t nil)))
rewrite-recognizerfunction
(defun rewrite-recognizer (recog-tuple arg type-alist ens force-flg wrld ttree pot-lst pt) (mv-let (ts ttree+) (type-set arg force-flg nil type-alist ens wrld ttree pot-lst pt) (cond ((ts-intersectp ts (access recognizer-tuple recog-tuple :true-ts)) (cond ((ts-intersectp ts (access recognizer-tuple recog-tuple :false-ts)) (mv (mcons-term* (access recognizer-tuple recog-tuple :fn) arg) ttree)) (t (mv *t* (push-lemma (access recognizer-tuple recog-tuple :rune) ttree+))))) (t (mv *nil* (push-lemma (access recognizer-tuple recog-tuple :rune) ttree+))))))
remove-invisible-fncallsfunction
(defun remove-invisible-fncalls (term invisible-fns) (cond ((or (variablep term) (fquotep term) (flambda-applicationp term)) term) ((member-eq (ffn-symb term) invisible-fns) (remove-invisible-fncalls (fargn term 1) invisible-fns)) (t term)))
term-order+function
(defun term-order+ (x1 x2 invisible-fns) (let ((x1-guts (remove-invisible-fncalls x1 invisible-fns)) (x2-guts (remove-invisible-fncalls x2 invisible-fns))) (cond ((equal x1-guts x2-guts) (term-order x1 x2)) (t (term-order x1-guts x2-guts)))))
invisible-fnsfunction
(defun invisible-fns (fns alist acc) (declare (xargs :guard (and (symbol-listp fns) (or (true-listp acc) (eq acc t))))) (cond ((null fns) (if (eq acc t) nil acc)) ((eq acc t) (invisible-fns (cdr fns) alist (cdr (assoc-eq (car fns) alist)))) ((null acc) nil) (t (invisible-fns (cdr fns) alist (intersection-eq (cdr (assoc-eq (car fns) alist)) acc)))))
loop-stopperp-recfunction
(defun loop-stopperp-rec (loop-stopper sbst wrld) (cond ((null loop-stopper) nil) (t (let ((pre (cdr (assoc-eq (car (car loop-stopper)) sbst))) (post (cdr (assoc-eq (cadr (car loop-stopper)) sbst)))) (cond ((equal pre post) (loop-stopperp-rec (cdr loop-stopper) sbst wrld)) (t (term-order+ post pre (invisible-fns (cddr (car loop-stopper)) (invisible-fns-table wrld) t))))))))
loop-stopperpfunction
(defun loop-stopperp (loop-stopper sbst wrld) (or (null loop-stopper) (loop-stopperp-rec loop-stopper sbst wrld)))
other
(defrec rewrite-rule (rune nume hyps equiv lhs rhs subclass heuristic-info backchain-limit-lst var-info . match-free) nil)
relevant-ground-lemmasfunction
(defun relevant-ground-lemmas (hyp wrld) (mv-let (not-flg hyp) (strip-not hyp) (declare (ignore not-flg)) (cond ((variablep hyp) nil) ((fquotep hyp) nil) ((flambda-applicationp hyp) nil) (t (getpropc (ffn-symb hyp) 'lemmas nil wrld)))))
search-ground-units1function
(defun search-ground-units1 (hyp unify-subst lemmas type-alist ens force-flg wrld ttree) (cond ((null lemmas) (mv nil unify-subst ttree nil)) ((and (enabled-numep (access rewrite-rule (car lemmas) :nume) ens) (not (eq (access rewrite-rule (car lemmas) :subclass) 'meta)) (null (access rewrite-rule (car lemmas) :hyps)) (not (access rewrite-rule (car lemmas) :var-info)) (geneqv-refinementp (access rewrite-rule (car lemmas) :equiv) *geneqv-iff* wrld)) (mv-let (knownp nilp nilp-ttree) (known-whether-nil (access rewrite-rule (car lemmas) :rhs) type-alist ens force-flg nil wrld ttree) (cond ((and knownp (not nilp)) (mv-let (ans unify-subst) (one-way-unify1 hyp (access rewrite-rule (car lemmas) :lhs) unify-subst) (cond (ans (let ((rune (access rewrite-rule (car lemmas) :rune))) (with-accumulated-persistence rune (flg final-unify-subst final-ttree final-lemmas) t (mv t unify-subst (push-lemma (geneqv-refinementp (access rewrite-rule (car lemmas) :equiv) *geneqv-iff* wrld) (push-lemma rune nilp-ttree)) (cdr lemmas))))) (t (search-ground-units1 hyp unify-subst (cdr lemmas) type-alist ens force-flg wrld ttree))))) (t (search-ground-units1 hyp unify-subst (cdr lemmas) type-alist ens force-flg wrld ttree))))) (t (search-ground-units1 hyp unify-subst (cdr lemmas) type-alist ens force-flg wrld ttree))))
search-ground-unitsfunction
(defun search-ground-units (hyp unify-subst type-alist ens force-flg wrld ttree) (let ((lemmas (relevant-ground-lemmas hyp wrld))) (mv-let (winp unify-subst ttree rest-lemmas) (search-ground-units1 hyp unify-subst lemmas type-alist ens force-flg wrld ttree) (declare (ignore rest-lemmas)) (mv winp unify-subst ttree))))
if-tautologypfunction
(defun if-tautologyp (term) (declare (xargs :guard (pseudo-termp term))) (posp (if-interp (splice-instrs (if-compile term t nil nil)) nil nil nil nil 100000)))
expand-some-non-rec-fnsmutual-recursion
(mutual-recursion (defun expand-some-non-rec-fns (fns term wrld) (cond ((variablep term) term) ((fquotep term) term) (t (let ((args (expand-some-non-rec-fns-lst fns (fargs term) wrld))) (cond ((member-equal (ffn-symb term) fns) (subcor-var (formals (ffn-symb term) wrld) args (bbody (ffn-symb term)))) (t (cons-term (ffn-symb term) args))))))) (defun expand-some-non-rec-fns-lst (fns lst wrld) (cond ((null lst) nil) (t (cons (expand-some-non-rec-fns fns (car lst) wrld) (expand-some-non-rec-fns-lst fns (cdr lst) wrld))))))
tautologypfunction
(defun tautologyp (term wrld) (cond ((and (ffn-symb-p term 'implies) (equal (fargn term 1) (fargn term 2))) t) (t (if-tautologyp (expand-some-non-rec-fns '(iff implies eq atom eql = /= null zerop synp return-last plusp minusp listp mv-list cons-with-hint wormhole-eval force case-split double-rewrite) term wrld)))))
being-openedp-recfunction
(defun being-openedp-rec (fn fnstack) (cond ((null fnstack) nil) ((consp (car fnstack)) (or (eq fn (caar fnstack)) (being-openedp-rec fn (cdr fnstack)))) (t (or (eq fn (car fnstack)) (being-openedp-rec fn (cdr fnstack))))))
other
(defattach being-openedp-limited-for-nonrec constant-t-function-arity-0)
being-openedpmacro
(defmacro being-openedp (fn fnstack clique settled-down-p) (declare (xargs :guard (symbolp fnstack))) `(and ,FNSTACK (let ((clique ,CLIQUE)) (and (or clique (not ,SETTLED-DOWN-P) (not (being-openedp-limited-for-nonrec))) (being-openedp-rec (if clique (car clique) ,FN) ,FNSTACK)))))
recursive-fn-on-fnstackpfunction
(defun recursive-fn-on-fnstackp (fnstack) (cond ((null fnstack) nil) ((and (consp (car fnstack)) (not (eq (caar fnstack) :term))) t) (t (recursive-fn-on-fnstackp (cdr fnstack)))))
fnstack-term-memberfunction
(defun fnstack-term-member (term fnstack) (cond ((null fnstack) nil) ((and (consp (car fnstack)) (eq (caar fnstack) :term) (equal (cdar fnstack) term)) t) (t (fnstack-term-member term (cdr fnstack)))))
var-counts1mutual-recursion
(mutual-recursion (defun var-counts1 (arg rhs acc) (declare (xargs :guard (and (pseudo-termp rhs) (natp acc)) :verify-guards nil)) (cond ((equal arg rhs) (1+ acc)) ((variablep rhs) acc) ((fquotep rhs) acc) ((eq (ffn-symb rhs) 'if) (max (var-counts1 arg (fargn rhs 2) acc) (var-counts1 arg (fargn rhs 3) acc))) (t (var-counts1-lst arg (fargs rhs) acc)))) (defun var-counts1-lst (arg lst acc) (declare (xargs :guard (and (pseudo-term-listp lst) (natp acc)))) (cond ((endp lst) acc) (t (var-counts1-lst arg (cdr lst) (var-counts1 arg (car lst) acc))))))
var-countsfunction
(defun var-counts (lhs-args rhs) (declare (xargs :guard (and (true-listp lhs-args) (pseudo-termp rhs)))) (cond ((endp lhs-args) nil) (t (cons (var-counts1 (car lhs-args) rhs 0) (var-counts (cdr lhs-args) rhs)))))
count-ifsmutual-recursion
(mutual-recursion (defun count-ifs (term) (declare (xargs :guard (pseudo-termp term))) (cond ((variablep term) 0) ((fquotep term) 0) ((eq (ffn-symb term) 'hide) 0) ((eq (ffn-symb term) 'if) (+ 1 (count-ifs (fargn term 1)) (count-ifs (fargn term 2)) (count-ifs (fargn term 3)))) (t (count-ifs-lst (fargs term))))) (defun count-ifs-lst (lst) (declare (xargs :guard (pseudo-term-listp lst))) (cond ((endp lst) 0) (t (+ (count-ifs (car lst)) (count-ifs-lst (cdr lst)))))))
too-many-ifs0function
(defun too-many-ifs0 (args counts diff ctx) (declare (type (signed-byte 61) diff) (xargs :guard (and (pseudo-term-listp args) (integer-listp counts) (equal (len args) (len counts))))) (cond ((endp args) (> diff 0)) ((eql (car counts) 1) (too-many-ifs0 (cdr args) (cdr counts) diff ctx)) (t (let ((count1 (the-fixnum! (count-ifs (car args)) ctx))) (declare (type (unsigned-byte 60) count1)) (too-many-ifs0 (cdr args) (cdr counts) (the-fixnum! (+ (the-fixnum! (* count1 (1- (car counts))) ctx) diff) ctx) ctx)))))
too-many-ifs-pre-rewrite-builtinfunction
(defun too-many-ifs-pre-rewrite-builtin (args counts) (declare (xargs :guard (and (pseudo-term-listp args) (integer-listp counts) (equal (len args) (len counts))))) (too-many-ifs0 args counts 0 'too-many-ifs-pre-rewrite))
other
(defattach (too-many-ifs-pre-rewrite too-many-ifs-pre-rewrite-builtin) :skip-checks t)
occur-cnt-boundedmutual-recursion
(mutual-recursion (defun occur-cnt-bounded (term1 term2 a m bound-m) (declare (type (signed-byte 61) a m bound-m) (xargs :measure (acl2-count term2) :ruler-extenders (:lambdas) :guard (and (pseudo-termp term2) (signed-byte-p *fixnum-bits* (+ bound-m m)) (<= 0 a) (<= 0 m) (<= 0 bound-m) (<= a (+ bound-m m))) :verify-guards nil)) (the-fixnum (cond ((equal term1 term2) (if (<= a bound-m) (the-fixnum (+ a m)) -1)) ((variablep term2) a) ((fquotep term2) a) (t (occur-cnt-bounded-lst term1 (fargs term2) a m bound-m))))) (defun occur-cnt-bounded-lst (term1 lst a m bound-m) (declare (type (signed-byte 61) a m bound-m) (xargs :measure (acl2-count lst) :ruler-extenders (:lambdas) :guard (and (pseudo-term-listp lst) (signed-byte-p *fixnum-bits* (+ bound-m m)) (<= 0 a) (<= 0 m) (<= 0 bound-m) (<= a (+ bound-m m))))) (the-fixnum (cond ((endp lst) a) (t (let ((new (occur-cnt-bounded term1 (car lst) a m bound-m))) (declare (type (signed-byte 61) new)) (if (eql new -1) -1 (occur-cnt-bounded-lst term1 (cdr lst) new m bound-m))))))))
too-many-ifs1function
(defun too-many-ifs1 (args val lhs rhs ctx) (declare (type (signed-byte 61) lhs rhs) (xargs :guard (and (pseudo-term-listp args) (pseudo-termp val) (<= 0 lhs) (<= lhs rhs) (<= (count-ifs-lst args) rhs)))) (cond ((endp args) nil) (t (let ((x (the-fixnum! (count-ifs (car args)) ctx))) (declare (type (signed-byte 61) x)) (cond ((eql x 0) (too-many-ifs1 (cdr args) val lhs rhs ctx)) (t (let ((lhs (occur-cnt-bounded (car args) val lhs x (the-fixnum (- rhs x))))) (declare (type (signed-byte 61) lhs)) (if (eql lhs -1) -1 (too-many-ifs1 (cdr args) val lhs rhs ctx)))))))))
too-many-ifs-post-rewrite-builtinfunction
(defun too-many-ifs-post-rewrite-builtin (args val) (declare (xargs :guard (and (pseudo-term-listp args) (pseudo-termp val)))) (let* ((ctx 'too-many-ifs-post-rewrite-builtin) (rhs (the-fixnum! (count-ifs-lst args) ctx))) (cond ((int= rhs 0) nil) (t (too-many-ifs1 args val 0 rhs ctx)))))
other
(defattach (too-many-ifs-post-rewrite too-many-ifs-post-rewrite-builtin) :skip-checks t)
all-args-occur-in-top-clausepfunction
(defun all-args-occur-in-top-clausep (args top-clause) (cond ((null args) t) (t (and (dumb-occur-lst (car args) top-clause) (all-args-occur-in-top-clausep (cdr args) top-clause)))))
max-form-countmutual-recursion
(mutual-recursion (defun max-form-count (term) (the (unsigned-byte 60) (cond ((variablep term) 0) ((fquotep term) (cons-count-bounded (cadr term))) ((eq (ffn-symb term) 'if) (max (max-form-count (fargn term 2)) (max-form-count (fargn term 3)))) (t (max-form-count-lst (fargs term) 1))))) (defun max-form-count-lst (lst acc) (declare (type (unsigned-byte 60) acc)) (the (unsigned-byte 60) (cond ((>= acc (fn-count-evg-max-val)) (fn-count-evg-max-val)) ((null lst) acc) (t (max-form-count-lst (cdr lst) (+f acc (max-form-count (car lst)))))))))
controller-complexity1function
(defun controller-complexity1 (flg args controller-pocket) (cond ((null args) 0) ((eq (car controller-pocket) flg) (+ (max-form-count (car args)) (controller-complexity1 flg (cdr args) (cdr controller-pocket)))) (t (controller-complexity1 flg (cdr args) (cdr controller-pocket)))))
controller-complexityfunction
(defun controller-complexity (flg term controller-alist) (controller-complexity1 flg (fargs term) (cdr (assoc-eq (ffn-symb term) controller-alist))))
controller-pocket-simplerpfunction
(defun controller-pocket-simplerp (call result controller-alist) (< (controller-complexity t result controller-alist) (controller-complexity t call controller-alist)))
constant-controller-pocketp1function
(defun constant-controller-pocketp1 (args controller-pocket) (cond ((null args) t) ((car controller-pocket) (and (quotep (car args)) (constant-controller-pocketp1 (cdr args) (cdr controller-pocket)))) (t (constant-controller-pocketp1 (cdr args) (cdr controller-pocket)))))
constant-controller-pocketpfunction
(defun constant-controller-pocketp (term controller-alist) (constant-controller-pocketp1 (fargs term) (cdr (assoc-eq (ffn-symb term) controller-alist))))
some-controller-pocket-constant-and-non-controller-simplerpfunction
(defun some-controller-pocket-constant-and-non-controller-simplerp (call result controller-alist) (and (constant-controller-pocketp result controller-alist) (< (controller-complexity nil result controller-alist) (controller-complexity nil call controller-alist))))
rewrite-fncallpmutual-recursion
(mutual-recursion (defun rewrite-fncallp (call result cliquep top-clause current-clause controller-alist) (cond ((variablep result) t) ((fquotep result) t) ((flambda-applicationp result) (rewrite-fncallp-listp call (fargs result) cliquep top-clause current-clause controller-alist)) ((if cliquep (member-eq (ffn-symb result) cliquep) (eq (ffn-symb result) (ffn-symb call))) (and (or (all-args-occur-in-top-clausep (fargs result) top-clause) (dumb-occur-lst result current-clause) (controller-pocket-simplerp call result controller-alist) (some-controller-pocket-constant-and-non-controller-simplerp call result controller-alist)) (rewrite-fncallp-listp call (fargs result) cliquep top-clause current-clause controller-alist))) (t (rewrite-fncallp-listp call (fargs result) cliquep top-clause current-clause controller-alist)))) (defun rewrite-fncallp-listp (call lst cliquep top-clause current-clause controller-alist) (cond ((null lst) t) (t (and (rewrite-fncallp call (car lst) cliquep top-clause current-clause controller-alist) (rewrite-fncallp-listp call (cdr lst) cliquep top-clause current-clause controller-alist))))))
contains-rewritable-callpmutual-recursion
(mutual-recursion (defun contains-rewritable-callp (fn term cliquep terms-to-be-ignored-by-rewrite) (cond ((variablep term) nil) ((fquotep term) nil) ((flambda-applicationp term) (contains-rewritable-callp-lst fn (fargs term) cliquep terms-to-be-ignored-by-rewrite)) ((and (if cliquep (member-eq (ffn-symb term) cliquep) (eq (ffn-symb term) fn)) (not (member-equal term terms-to-be-ignored-by-rewrite))) t) (t (contains-rewritable-callp-lst fn (fargs term) cliquep terms-to-be-ignored-by-rewrite)))) (defun contains-rewritable-callp-lst (fn lst cliquep terms-to-be-ignored-by-rewrite) (cond ((null lst) nil) (t (or (contains-rewritable-callp fn (car lst) cliquep terms-to-be-ignored-by-rewrite) (contains-rewritable-callp-lst fn (cdr lst) cliquep terms-to-be-ignored-by-rewrite))))))
other
(defrec linear-lemma ((nume . hyps) max-term concl backchain-limit-lst rune . match-free) nil)
other
(defrec rewrite-constant ((((current-enabled-structure . pt) nonlinearp . forbidden-fns) (heavy-linearp . oncep-override) rewriter-state . backchain-limit-rw) ((restrictions-alist . current-literal) case-split-limitations . expand-lst) ((terms-to-be-ignored-by-rewrite . active-theory) fns-to-be-ignored-by-rewrite . top-clause) (force-info . current-clause) rw-cache-state . splitter-output) t)
*default-rw-cache-state*constant
(defconst *default-rw-cache-state* :atom)
*empty-rewrite-constant*constant
(defconst *empty-rewrite-constant* (make rewrite-constant :active-theory :standard :rewriter-state nil :case-split-limitations nil :forbidden-fns nil :splitter-output t :current-clause nil :current-enabled-structure nil :current-literal nil :expand-lst nil :fns-to-be-ignored-by-rewrite nil :force-info nil :nonlinearp nil :heavy-linearp t :oncep-override :clear :pt nil :restrictions-alist nil :rw-cache-state *default-rw-cache-state* :terms-to-be-ignored-by-rewrite nil :top-clause nil :backchain-limit-rw nil))
other
(defattach heavy-linear-p constant-nil-function-arity-0)
other
(defrec metafunction-context (rdepth type-alist obj geneqv wrld fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree unify-subst) t)
ok-to-forcefunction
(defun ok-to-force (rcnst) (let ((force-info (access rewrite-constant rcnst :force-info))) (cond ((eq force-info t) (and (enabled-numep *force-xnume* (access rewrite-constant rcnst :current-enabled-structure)) t)) ((eq force-info 'weak) nil) (t (er hard 'ok-to-force "OK-TO-FORCE called on apparently uninitialized rewrite constant, ~ ~x0." rcnst)))))
plist-to-alistfunction
(defun plist-to-alist (lst) (cond ((null lst) nil) (t (cons (cons (car lst) (cadr lst)) (plist-to-alist (cddr lst))))))
adjust-rdepthmacro
(defmacro adjust-rdepth (rdepth) `(1-f ,RDEPTH))
add-rewrite-argsfunction
(defun add-rewrite-args (extra-formals keyword-extra-formals alist) (cond ((null extra-formals) nil) (t (cons (let ((pair (assoc-eq (car keyword-extra-formals) alist))) (cond (pair (cdr pair)) (t (car extra-formals)))) (add-rewrite-args (cdr extra-formals) (cdr keyword-extra-formals) alist)))))
step-limit-startfunction
(defun step-limit-start (state) (let ((rec (f-get-global 'step-limit-record state))) (cond (rec (access step-limit-record rec :start)) (t (step-limit-from-table (w state))))))
step-limit-strictpfunction
(defun step-limit-strictp (state) (let ((rec (f-get-global 'step-limit-record state))) (cond (rec (access step-limit-record rec :strictp)) (t nil))))
initial-step-limitfunction
(defun initial-step-limit (wrld state) (declare (xargs :guard (and (plist-worldp wrld) (alistp (table-alist 'acl2-defaults-table wrld)) (let ((val (cdr (assoc-eq :step-limit (table-alist 'acl2-defaults-table wrld))))) (or (null val) (and (natp val) (<= val *default-step-limit*)))) (state-p state) (boundp-global 'step-limit-record state) (boundp-global 'last-step-limit state)))) (let ((rec (f-get-global 'step-limit-record state))) (cond (rec (or (access step-limit-record rec :sub-limit) (f-get-global 'last-step-limit state))) (t (step-limit-from-table wrld)))))
step-limit-error1function
(defun step-limit-error1 (ctx str start where state) (declare (ignorable state)) (the (signed-byte 61) (prog2$ (er hard? ctx str start where) -1)))
step-limit-errormacro
(defmacro step-limit-error (superior-context-p) (let ((str "The prover step-limit, which is ~x0 in the ~@1, has been ~ exceeded. See :DOC set-prover-step-limit.") (ctx ''step-limit)) (cond (superior-context-p `(er-soft ,CTX "Step-limit" ,STR (step-limit-start state) "context immediately above the one just completed")) (t `(the-fixnum (step-limit-error1 ,CTX ,STR (step-limit-start state) "current context" state))))))
decrement-step-limitmacro
(defmacro decrement-step-limit (step-limit) (declare (xargs :guard (symbolp step-limit))) `(the (signed-byte 61) (cond ((< 0 (the-fixnum ,STEP-LIMIT)) (1-f ,STEP-LIMIT)) ((eql -1 (the-fixnum ,STEP-LIMIT)) -1) (t (assert$ (eql 0 (the-fixnum ,STEP-LIMIT)) (cond ((step-limit-strictp state) (step-limit-error nil)) (t -1)))))))
rewrite-entrymacro
(defmacro rewrite-entry (&rest args) (declare (xargs :guard (and (true-listp args) (consp (car args)) (keyword-value-listp (cdr args))))) (let* ((call0 (append (car args) (add-rewrite-args '(rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) '(:rdepth :step-limit :type-alist :obj :geneqv :pequiv-info :wrld :state :fnstack :ancestors :backchain-limit :simplify-clause-pot-lst :rcnst :gstack :ttree) (plist-to-alist (if (eq (caar args) 'rewrite) (remove-keyword :step-limit (cdr args)) (cdr args)))))) (call (cond ((not (eq (caar args) 'rewrite)) call0) (t (let ((call1 `(let ((step-limit (decrement-step-limit step-limit))) (declare (type (signed-byte 61) step-limit)) ,CALL0)) (step-limit-tail (assoc-keyword :step-limit (cdr args)))) (cond (step-limit-tail `(let ((step-limit ,(CADR STEP-LIMIT-TAIL))) ,CALL1)) (t call1))))))) call))
*fake-rune-for-linear*constant
(defconst *fake-rune-for-linear* '(:fake-rune-for-linear nil))
*fake-rune-for-linear-equalities*constant
(defconst *fake-rune-for-linear-equalities* '(:fake-rune-for-linear-equalities nil))
push-gframemacro
(defmacro push-gframe (sys-fn bkptr &rest args) `(cond ((or (f-get-global 'gstackp state) (f-get-global 'dmrp state)) (cons (make gframe :sys-fn ,SYS-FN :bkptr ,BKPTR :args (list* ,@ARGS)) gstack)) (t nil)))
initial-gstackmacro
(defmacro initial-gstack (sys-fn bkptr &rest args) `(let ((gstack nil)) (push-gframe ,SYS-FN ,BKPTR ,@ARGS)))
tilde-@-bkptr-phrasefunction
(defun tilde-@-bkptr-phrase (calling-sys-fn called-sys-fn bkptr) (case called-sys-fn (rewrite (cond ((integerp bkptr) (cond ((member-eq calling-sys-fn '(rewrite-with-lemma rewrite-quoted-constant-with-lemma add-linear-lemma)) (msg " the atom of the ~n0 hypothesis" (list bkptr))) ((eq calling-sys-fn 'simplify-clause) (msg " the atom of the ~n0 literal" (list bkptr))) (t (msg " the ~n0 argument" (list bkptr))))) ((consp bkptr) (msg " the rhs of the ~n0 hypothesis" (list (cdr bkptr)))) ((symbolp bkptr) (case bkptr (body " the body") (lambda-body " the lambda body") (lambda-object-body " the body of the lambda object") (rewritten-body " the rewritten body") (expansion " the expansion") (equal-consp-hack-car " the equality of the cars") (equal-consp-hack-cdr " the equality of the cdrs") (rhs " the rhs of the conclusion") (meta " the result of the metafunction") (nth-update " the result of the nth/update rewriter") (multiply-alists2 " the product of two polys") (forced-assumption " a forced assumption") (proof-builder " proof-builder top level") (otherwise (er hard 'tilde-@-bkptr-phrase "When ~x0 calls ~x1 we get an unrecognized ~ bkptr, ~x2." calling-sys-fn called-sys-fn bkptr)))) (t (er hard 'tilde-@-bkptr-phrase "When ~x0 calls ~x1 we get an unrecognized bkptr, ~x2." calling-sys-fn called-sys-fn bkptr)))) ((rewrite-with-lemma setup-simplify-clause-pot-lst simplify-clause add-terms-and-lemmas add-linear-lemma non-linear-arithmetic synp) "") (t (er hard 'tilde-@-bkptr-phrase "When ~x0 calls ~x1 we get an unrecognized bkptr, ~x2." calling-sys-fn called-sys-fn bkptr))))
get-rule-fieldmacro
(defmacro get-rule-field (x field) (declare (xargs :guard (let ((fields '(:rune :hyps :lhs :rhs :max-term))) (and (not (member-eq x fields)) (member-eq field fields))))) `(let ((x ,X)) (cond ((eq (record-type x) 'rewrite-rule) ,(COND ((MEMBER-EQ FIELD '(:LHS :RHS)) `(COND ((AND (EQ (ACCESS REWRITE-RULE X :SUBCLASS) 'REWRITE-QUOTED-CONSTANT) (EQL (CAR (ACCESS REWRITE-RULE X :HEURISTIC-INFO)) 2)) (ACCESS REWRITE-RULE X ,(IF (EQ FIELD :LHS) :RHS :LHS))) (T (ACCESS REWRITE-RULE X ,FIELD)))) ((EQ FIELD ':MAX-TERM) :GET-RULE-FIELD-NONE) (T `(ACCESS REWRITE-RULE X ,FIELD)))) ((eq (record-type x) 'linear-lemma) ,(COND ((MEMBER-EQ FIELD '(:LHS :RHS)) :GET-RULE-FIELD-NONE) (T `(ACCESS LINEAR-LEMMA X ,FIELD)))) (t (er hard 'get-rule-field "The object ~x0 is neither a rewrite-rule record nor a ~ linear-lemma record." x)))))
show-geneqvfunction
(defun show-geneqv (x with-runes-p) (cond ((endp x) nil) (t (cons (cond ((eq with-runes-p t) (list (access congruence-rule (car x) :equiv) (access congruence-rule (car x) :rune))) ((eq with-runes-p 'non-prims) (cond ((or (eq (car (access congruence-rule (car x) :rune)) :fake-rune-for-anonymous-enabled-rule) (equal (access congruence-rule (car x) :rune) '(:equivalence iff-is-an-equivalence))) (access congruence-rule (car x) :equiv)) ((eq (car (access congruence-rule (car x) :rune)) :congruence) (list (access congruence-rule (car x) :equiv) (cadr (access congruence-rule (car x) :rune)))) (t (list (access congruence-rule (car x) :equiv) (access congruence-rule (car x) :rune))))) (t (access congruence-rule (car x) :equiv))) (show-geneqv (cdr x) with-runes-p)))))
cw-gframefunction
(defun cw-gframe (i calling-sys-fn frame evisc-tuple) (case (access gframe frame :sys-fn) (simplify-clause (cw "~x0. Simplifying the clause~% ~Y12" i (access gframe frame :args) evisc-tuple)) (setup-simplify-clause-pot-lst (cw "~x0. Setting up the linear pot list for the clause~% ~Y12" i (access gframe frame :args) evisc-tuple)) (rewrite (let ((term (car (access gframe frame :args))) (alist (cadr (access gframe frame :args))) (obj (caddr (access gframe frame :args))) (geneqv (cdddr (access gframe frame :args)))) (cw "~x0. Rewriting (to ~@6)~@1,~% ~Y23,~#4~[~/ under the ~ substitution~%~*5~]~#7~[~/~| Geneqv: ~y8~]" i (tilde-@-bkptr-phrase calling-sys-fn 'rewrite (access gframe frame :bkptr)) term evisc-tuple (if alist 1 0) (tilde-*-alist-phrase alist evisc-tuple 5) (cond ((eq obj nil) "falsify") ((eq obj t) "establish") (t "simplify")) (if geneqv 1 0) (show-geneqv geneqv 'non-prims)))) ((rewrite-with-lemma rewrite-quoted-constant-with-lemma) (let ((term (car (access gframe frame :args))) (lemma (cadr (access gframe frame :args))) (geneqv (cddr (access gframe frame :args)))) (cw "~x0. Attempting to apply ~F1 to~% ~Y23~|~#4~[~/ Preserving: ~x5~]~|~#6~[~/ Geneqv: ~y7~]" i (get-rule-field lemma :rune) term evisc-tuple (if (eq (access rewrite-rule lemma :equiv) 'equal) 0 1) (access rewrite-rule lemma :equiv) (if geneqv 1 0) (show-geneqv geneqv 'non-prims)))) (add-linear-lemma (let ((term (car (access gframe frame :args))) (lemma (cdr (access gframe frame :args)))) (cw "~x0. Attempting to apply ~F1 to~% ~Y23" i (get-rule-field lemma :rune) term evisc-tuple))) (add-terms-and-lemmas (cw "~x0. Attempting to apply linear arithmetic to ~@1~% ~Y23" i (let ((obj (cdr (access gframe frame :args)))) (cond ((eq obj nil) (msg "falsify the term list")) ((eq obj t) "establish the term list") (t "the clause"))) (car (access gframe frame :args)) evisc-tuple)) (non-linear-arithmetic (cw "~x0. Attempting to apply non-linear arithmetic to the list of ~ ~x1 var~#2~[~/s~]:~% ~Y23" i (length (access gframe frame :args)) (access gframe frame :args) evisc-tuple)) (synp (let ((synp-fn (access gframe frame :args))) (cw "~x0. Entering ~x1 for hypothesis ~x2~%" i synp-fn (access gframe frame :bkptr)))) (otherwise (er hard 'cw-gframe "Unrecognized sys-fn, ~x0" (access gframe frame :sys-fn)))))
cw-gstack1function
(defun cw-gstack1 (i calling-sys-fn lst evisc-tuple) (cond ((null lst) nil) (t (prog2$ (cw-gframe i calling-sys-fn (car lst) evisc-tuple) (cw-gstack1 (1+ i) (access gframe (car lst) :sys-fn) (cdr lst) evisc-tuple)))))
cw-gstack-fnfunction
(defun cw-gstack-fn (evisc-tuple frames) (let ((gstack nil) (ctx 'cw-gstack)) (cond ((null gstack) (cw "There is no gstack to print. If you have enabled stack monitoring ~ with ``:BRR t'' this is likely due to the loop you wish to ~ investigate occurring in so-called preprocessing, where monitoring ~ is not done, rather than in the rewriter proper. You may obtain ~ better results by replaying the problematic event with a hint ~ of:~%(("Goal" :DO-NOT '(preprocess)).~%See :DOC hints, in ~ particular the discussion of :DO-NOT.~%")) ((and evisc-tuple (not (standard-evisc-tuplep evisc-tuple))) (er hard ctx "Illegal :evisc-tuple argument to ~x0: ~x1. See :DOC cw-gstack." 'cw-gstack evisc-tuple)) ((not (or (null frames) (and (integerp frames) (< 0 frames)) (and (true-listp frames) (eql (length frames) 2) (natp (car frames)) (natp (cadr frames)) (<= (car frames) (cadr frames))))) (er hard ctx "Illegal :frames argument to ~x0: ~x1. See :DOC cw-gstack." 'cw-gstack frames)) (t (let ((start (cond ((or (null frames) (integerp frames)) 1) ((<= (car frames) (length gstack)) (car frames)) (t (length gstack))))) (cw-gstack1 start nil (cond ((null frames) (reverse gstack)) (t (let* ((rev-gstack (reverse gstack)) (len (length gstack)) (n (min (if (integerp frames) frames (cadr frames)) len))) (nthcdr (1- start) (take n rev-gstack))))) evisc-tuple))))))
cw-gstackmacro
(defmacro cw-gstack (&key (evisc-tuple 'nil evisc-tuplep) (frames 'nil)) (declare (xargs :guard t)) `(cw-gstack-fn ,(IF EVISC-TUPLEP EVISC-TUPLE '(TERM-EVISC-TUPLE T STATE)) ,FRAMES))
other
(defrec brr-status (entry-code (brr-monitored-runes . brr-gstack) brr-local-alist . brr-previous-status) t)
make-initial-brr-statusfunction
(defun make-initial-brr-status (monitored-runes) (make brr-status :entry-code :enter :brr-monitored-runes monitored-runes :brr-gstack nil :brr-local-alist nil :brr-previous-status nil))
dive-to-deepest-brr-statusfunction
(defun dive-to-deepest-brr-status (whs) (let ((prev-whs (access brr-status whs :brr-previous-status))) (if (null prev-whs) whs (dive-to-deepest-brr-status prev-whs))))
top-level-brr-statusfunction
(defun top-level-brr-status (whs) (make-initial-brr-status (access brr-status (dive-to-deepest-brr-status whs) :brr-monitored-runes)))
brr-depth1function
(defun brr-depth1 (whs) (let ((prev-whs (access brr-status whs :brr-previous-status))) (cond ((null prev-whs) 0) (t (+ 1 (brr-depth1 prev-whs))))))
brr-depthfunction
(defun brr-depth (state) (brr-depth1 (f-get-global 'wormhole-status state)))
brr-wormholemacro
(defmacro brr-wormhole (entry-lambda input-alist test-form aliases) (let ((aliases `(append ,ALIASES '((:exit 0 (lambda nil (prog2$ (cw "The keyword command :EXIT is ~ disabled inside BRR. Exit BRR ~ with :ok or :go, or use :a! to ~ abort; or exit ACL2 entirely ~ with ~x0.~%" '(exit)) (value :invisible)))) (:quit 0 (lambda nil (prog2$ (cw "The keyword command :QUIT is ~ disabled inside BRR. Quit BRR ~ with :ok or :go, or use :a! to ~ abort; or quit ACL2 entirely ~ with ~x0.~%" '(quit)) (value :invisible)))))))) `(wormhole 'brr ,ENTRY-LAMBDA ,INPUT-ALIST `(er-progn (set-ld-keyword-aliases! ,,ALIASES) (set-ld-prompt 'brr-prompt state) (mv-let (erp val state) ,,TEST-FORM (cond (erp (value (er hard 'brr-wormhole "The test-form provided to brr-wormhole has ~ signalled an error. This is a programming error ~ by the ACL2 developers. Please report this."))) (val (er-progn (set-ld-error-action :continue state) (with-output :off :all (disable-ubt (msg "Note that ~x0 was executed when an interactive ~ break occurred due to a monitored rule; see ~ :DOC break-rewrite." 'disable-ubt))) (value :invisible))) (t (value :q))))) :ld-prompt nil :ld-missing-input-ok nil :ld-always-skip-top-level-locals nil :ld-pre-eval-filter :all :ld-pre-eval-print nil :ld-post-eval-print :command-conventions :ld-error-triples t :ld-error-action :error :ld-query-control-alist nil :ld-verbose nil)))
get-brr-localfunction
(defun get-brr-local (var state) (let ((whs (f-get-global 'wormhole-status state))) (cdr (assoc-eq var (access brr-status whs :brr-local-alist)))))
put-brr-localfunction
(defun put-brr-local (var val state) (if (eq (f-get-global 'wormhole-name state) 'brr) (let* ((whs (f-get-global 'wormhole-status state)) (alist (access brr-status whs :brr-local-alist)) (new-whs (change brr-status whs :brr-local-alist (put-assoc-eq var val alist)))) (set-persistent-whs-and-ephemeral-whs 'brr new-whs state)) (prog2$ (illegal 'put-brr-local "It is illegal to call put-brr-local unless you are under ~ break-rewrite and you are not. The arguments to ~ put-brr-local were ~x0 and ~x1" (list (cons #\0 var) (cons #\1 val))) state)))
put-brr-localsfunction
(defun put-brr-locals (alist state) (if (eq (f-get-global 'wormhole-name state) 'brr) (let* ((whs (f-get-global 'wormhole-status state)) (alist1 (access brr-status whs :brr-local-alist)) (new-whs (change brr-status whs :brr-local-alist (put-assoc-eq-alist alist1 alist)))) (set-persistent-whs-and-ephemeral-whs 'brr new-whs state)) (prog2$ (illegal 'put-brr-locals "It is illegal to call put-brr-locals unless you are under ~ break-rewrite and you are not. The alist argument to ~ put-brr-locals was ~x0." (list (cons #\0 alist))) state)))
push-brr-statusfunction
(defun push-brr-status (state) (let* ((input (f-get-global 'wormhole-input state)) (gstack (cdr (assoc-eq 'brr-gstack input))) (alist (cdr (assoc-eq 'brr-local-alist input))) (whs (f-get-global 'wormhole-status state)) (new-whs (change brr-status whs :brr-gstack gstack :brr-local-alist alist :brr-previous-status whs))) (set-persistent-whs-and-ephemeral-whs 'brr new-whs state)))
pop-brr-statusfunction
(defun pop-brr-status (state) (let* ((whs (f-get-global 'wormhole-status state)) (prev-whs (access brr-status whs :brr-previous-status))) (if (null prev-whs) state (set-persistent-whs-and-ephemeral-whs 'brr prev-whs state))))
decode-type-alistfunction
(defun decode-type-alist (type-alist) (cond ((null type-alist) nil) (t (cons (cons (caar type-alist) (decode-type-set (cadar type-alist))) (decode-type-alist (cdr type-alist))))))
translate-break-conditionfunction
(defun translate-break-condition (xterm ctx state) (er-let* ((term (translate xterm '(nil) nil t ctx (w state) state))) (let* ((used-vars (all-vars term)) (bad-vars (set-difference-eq used-vars '(state)))) (cond (bad-vars (er soft ctx "The only variable allowed in a break condition ~ is STATE. Your form, ~x0, contains the ~ variable~#1~[~/s~] ~&2." xterm (if (cdr bad-vars) 1 0) (reverse bad-vars))) (t (value term))))))
eval-break-conditionfunction
(defun eval-break-condition (rune term ctx state) (cond ((equal term *t*) (value t)) ((not (termp term (w state))) (er soft ctx "The monitored rune ~x0 has a non-trivial break :condition, ~X12, ~ which is no longer a term. This is presumably because an undo ~ erased some critical definition after the monitor was installed. We ~ are aborting this proof attempt and suggest you inspect ~ :monitored-runes." rune term nil)) (t (mv-let (erp okp latches) (ev term (list (cons 'state (coerce-state-to-object state))) state nil nil t) (declare (ignore latches)) (cond (erp (pprogn (error-fms nil ctx nil (car okp) (cdr okp) state) (er soft ctx "The break condition installed on ~x0 could not be ~ evaluated. We are aborting this proof attempt." rune))) (t (value okp)))))))
*default-free-vars-display-limit*constant
(defconst *default-free-vars-display-limit* 30)
set-free-vars-display-limitmacro
(defmacro set-free-vars-display-limit (n) `(let ((n ,N)) (prog2$ (or (natp n) (er hard 'set-free-vars-display-limit "The argument to set-free-vars-display-limit should ~ evaluate to a natural number, but it was given an ~ argument that evaluated to ~x0." n)) (f-put-global 'free-vars-display-limit n state))))
free-vars-display-limitfunction
(defun free-vars-display-limit (state) (if (f-boundp-global 'free-vars-display-limit state) (let ((val (f-get-global 'free-vars-display-limit state))) (if (or (natp val) (null val)) val *default-free-vars-display-limit*)) *default-free-vars-display-limit*))
limit-failure-reasonmutual-recursion
(mutual-recursion (defun limit-failure-reason (failures-remaining failure-reason elided-p) (declare (xargs :guard (natp failures-remaining))) (case-match failure-reason ((hyp 'free-vars . alist) (cond ((zp failures-remaining) (mv 0 (list hyp 'free-vars 'elided) t)) ((eq (car alist) 'hyp-vars) (mv (1- failures-remaining) failure-reason elided-p)) (t (mv-let (new-failures-remaining new-alist elided-p) (limit-failure-reason-alist (1- failures-remaining) alist elided-p) (cond ((eql failures-remaining new-failures-remaining) (mv failures-remaining failure-reason elided-p)) (t (mv new-failures-remaining (list* hyp 'free-vars new-alist) elided-p))))))) (& (mv (if (zp failures-remaining) failures-remaining (1- failures-remaining)) failure-reason elided-p)))) (defun limit-failure-reason-alist (failures-remaining alist elided-p) (cond ((null alist) (mv failures-remaining alist elided-p)) (t (mv-let (failures-remaining-1 failure-reason elided-p) (limit-failure-reason failures-remaining (cdar alist) elided-p) (mv-let (failures-remaining-2 rest-alist elided-p) (limit-failure-reason-alist failures-remaining-1 (cdr alist) elided-p) (mv failures-remaining-2 (cond ((and (not (zp failures-remaining)) (eql failures-remaining failures-remaining-2)) alist) (t (cons (cond ((and (not (zp failures-remaining)) (eql failures-remaining failures-remaining-1)) (car alist)) (t (cons (caar alist) failure-reason))) rest-alist))) elided-p)))))))
fix-free-failure-reasonmutual-recursion
(mutual-recursion (defun fix-free-failure-reason (failure-reason) (case-match failure-reason ((& 'free-vars 'hyp-vars . &) failure-reason) ((bkptr 'free-vars . failure-reason-lst) (list* bkptr 'free-vars (fix-free-failure-reason-alist failure-reason-lst nil))) (& failure-reason))) (defun fix-free-failure-reason-alist (x acc) (cond ((endp x) acc) (t (fix-free-failure-reason-alist (cdr x) (cons (cons (caar x) (fix-free-failure-reason (cdar x))) acc))))))
ancestor-backchain-runefunction
(defun ancestor-backchain-rune (ancestor) (and (access ancestor ancestor :bkptr) (let ((tokens (access ancestor ancestor :tokens))) (assert$ (and tokens (null (cdr tokens))) (car tokens)))))
other
(defrec forward-chaining-rule ((rune . nume) trigger hyps concls . match-free) nil)
other
(defrec elim-rule (((nume . crucial-position) destructor-term . destructor-terms) (hyps . equiv) (lhs . rhs) . rune) nil)
other
(defrec induction-rule (nume (pattern . condition) scheme . rune) nil)
scan-to-defpkgfunction
(defun scan-to-defpkg (name wrld) (cond ((null wrld) nil) ((and (eq (caar wrld) 'event-landmark) (eq (cadar wrld) 'global-value) (eq (access-event-tuple-type (cddar wrld)) 'defpkg) (equal name (access-event-tuple-namex (cddar wrld)))) wrld) (t (scan-to-defpkg name (cdr wrld)))))
multiple-assoc-terminal-substringp1function
(defun multiple-assoc-terminal-substringp1 (x i alist) (cond ((null alist) nil) ((terminal-substringp x (caar alist) i (1- (length (caar alist)))) (cons (car alist) (multiple-assoc-terminal-substringp1 x i (cdr alist)))) (t (multiple-assoc-terminal-substringp1 x i (cdr alist)))))
multiple-assoc-terminal-substringpfunction
(defun multiple-assoc-terminal-substringp (x alist) (multiple-assoc-terminal-substringp1 x (1- (length x)) alist))
possibly-add-lisp-extensionfunction
(defun possibly-add-lisp-extension (str) (let ((len (length str))) (cond ((and (> len 5) (eql (char str (- len 5)) #\.) (eql (char str (- len 4)) #\l) (eql (char str (- len 3)) #\i) (eql (char str (- len 2)) #\s) (eql (char str (- len 1)) #\p)) str) (t (string-append str ".lisp")))))
stuff-standard-oifunction
(defun stuff-standard-oi (cmds state) (declare (xargs :guard (true-listp cmds))) (cond ((null cmds) state) (t (pprogn (f-put-global 'ld-pre-eval-print t state) (f-put-global 'standard-oi (append cmds (cond ((symbolp (f-get-global 'standard-oi state)) (cons '(set-ld-pre-eval-print nil state) (f-get-global 'standard-oi state))) (t (f-get-global 'standard-oi state)))) state)))))
defun-mode-prompt-stringfunction
(defun defun-mode-prompt-string (state) (if (raw-mode-p state) "P" (case (default-defun-mode (w state)) (:logic (if (gc-off state) (if (ld-skip-proofsp state) "s" "") (if (ld-skip-proofsp state) "!s" "!"))) (otherwise (if (gc-off state) (if (ld-skip-proofsp state) "ps" "p") (if (ld-skip-proofsp state) "p!s" "p!"))))))
brr-promptfunction
(defun brr-prompt (channel state) (the2s (unsigned-byte 60) (fmt1 "~F0 ~s1~sr ~@2>" (list (cons #\0 (brr-depth state)) (cons #\1 (f-get-global 'current-package state)) (cons #\2 (defun-mode-prompt-string state)) (cons #\r "")) 0 channel state nil)))
ts<function
(defun ts< (x y) (cond ((ts= x y) nil) ((ts= x *ts-t*) t) ((ts= y *ts-t*) nil) ((ts= x *ts-non-nil*) t) ((ts= y *ts-non-nil*) nil) ((ts= x *ts-nil*) t) ((ts= y *ts-nil*) nil) ((ts-subsetp x y) t) (t nil)))
add-to-type-alist-segmentsfunction
(defun add-to-type-alist-segments (ts term segs) (cond ((or (endp segs) (ts< ts (caar segs))) (cons (cons ts (list term)) segs)) ((ts= ts (caar segs)) (cons (cons ts (cons term (cdar segs))) (cdr segs))) (t (cons (car segs) (add-to-type-alist-segments ts term (cdr segs))))))
merge-term-orderfunction
(defun merge-term-order (l1 l2) (declare (xargs :guard (and (pseudo-term-listp l1) (pseudo-term-listp l2)))) (cond ((endp l1) l2) ((endp l2) l1) ((term-order (car l1) (car l2)) (cons (car l1) (merge-term-order (cdr l1) l2))) (t (cons (car l2) (merge-term-order l1 (cdr l2))))))
merge-sort-term-orderfunction
(defun merge-sort-term-order (l) (declare (xargs :guard (pseudo-term-listp l))) (cond ((endp (cdr l)) l) (t (merge-term-order (merge-sort-term-order (evens l)) (merge-sort-term-order (odds l))))))
sort-type-alist-segmentsfunction
(defun sort-type-alist-segments (segs) (if (endp segs) nil (cons (cons (caar segs) (merge-sort-term-order (cdar segs))) (sort-type-alist-segments (cdr segs)))))
type-alist-segmentsfunction
(defun type-alist-segments (type-alist acc) (if (endp type-alist) (sort-type-alist-segments acc) (type-alist-segments (cdr type-alist) (add-to-type-alist-segments (cadar type-alist) (caar type-alist) acc))))
print-termsfunction
(defun print-terms (terms iff-flg wrld evisc-tuple) (if (endp terms) terms (prog2$ (cw "~Y01" (untranslate (car terms) iff-flg wrld) evisc-tuple) (print-terms (cdr terms) iff-flg wrld evisc-tuple))))
print-type-alist-segmentsfunction
(defun print-type-alist-segments (segs wrld evisc-tuple) (if (endp segs) segs (prog2$ (cw "-----~%Terms with type ~x0:~%" (decode-type-set (caar segs))) (prog2$ (print-terms (cdar segs) (member (caar segs) (list *ts-t* *ts-non-nil* *ts-nil* *ts-boolean*)) wrld evisc-tuple) (print-type-alist-segments (cdr segs) wrld evisc-tuple)))))
print-type-alistfunction
(defun print-type-alist (type-alist wrld evisc-tuple) (print-type-alist-segments (type-alist-segments type-alist nil) wrld evisc-tuple))
print-pot-lstfunction
(defun print-pot-lst (pot-lst evisc-tuple) (cond ((null pot-lst) (cw "~%")) (t (prog2$ (cw "-----~|For maximal term ~X02~|the list of polynomials is:~|~X12~|" (access linear-pot (car pot-lst) :var) (append (show-poly-lst (access linear-pot (car pot-lst) :negatives) nil) (show-poly-lst (access linear-pot (car pot-lst) :positives) nil)) evisc-tuple) (print-pot-lst (cdr pot-lst) evisc-tuple)))))
decode-logical-namefunction
(defun decode-logical-name (name wrld) (cond ((symbolp name) (cond ((eq name :here) (scan-to-event wrld)) (t (let ((n (getpropc name 'absolute-event-number nil wrld))) (cond ((null n) nil) (t (lookup-world-index 'event n wrld))))))) ((and (stringp name) (find-non-hidden-package-entry name (global-val 'known-package-alist wrld))) (cond ((find-package-entry name *initial-known-package-alist*) (lookup-world-index 'event 0 wrld)) (t (scan-to-defpkg name wrld)))) (t nil)))
access-x-rule-runefunction
(defun access-x-rule-rune (x rule) (case x (recognizer-tuple (access recognizer-tuple rule :rune)) (type-prescription (access type-prescription rule :rune)) (congruence-rule (access congruence-rule rule :rune)) (pequiv (access congruence-rule (access pequiv rule :congruence-rule) :rune)) (rewrite-rule (access rewrite-rule rule :rune)) (well-founded-relation-rule (cddr rule)) (linear-lemma (access linear-lemma rule :rune)) (forward-chaining-rule (access forward-chaining-rule rule :rune)) (built-in-clause (access built-in-clause rule :rune)) (elim-rule (access elim-rule rule :rune)) (generalize-rule (access generalize-rule rule :rune)) (induction-rule (access induction-rule rule :rune)) (type-set-inverter-rule (access type-set-inverter-rule rule :rune)) (otherwise (er hard 'access-x-rule-rune "Unrecognized rule class, ~x0." x))))
collect-x-rules-of-runefunction
(defun collect-x-rules-of-rune (x rune lst ans) (cond ((null lst) ans) ((equal rune (access-x-rule-rune x (car lst))) (collect-x-rules-of-rune x rune (cdr lst) (add-to-set-equal (car lst) ans))) (t (collect-x-rules-of-rune x rune (cdr lst) ans))))
collect-congruence-rules-of-rune-in-geneqv-lstfunction
(defun collect-congruence-rules-of-rune-in-geneqv-lst (geneqv-lst rune ans) (cond ((null geneqv-lst) ans) (t (collect-congruence-rules-of-rune-in-geneqv-lst (cdr geneqv-lst) rune (collect-x-rules-of-rune 'congruence-rule rune (car geneqv-lst) ans)))))
collect-congruence-rules-of-runefunction
(defun collect-congruence-rules-of-rune (congruences rune ans) (cond ((null congruences) ans) (t (collect-congruence-rules-of-rune (cdr congruences) rune (collect-congruence-rules-of-rune-in-geneqv-lst (cdr (car congruences)) rune ans)))))
collect-pequivs-of-runefunction
(defun collect-pequivs-of-rune (alist rune ans) (cond ((null alist) ans) (t (collect-pequivs-of-rune (cdr alist) rune (collect-x-rules-of-rune 'pequiv rune (cdr (car alist)) ans)))))
find-rules-of-rune2function
(defun find-rules-of-rune2 (rune sym key val ans) (let ((token (car rune))) (cond ((eq key 'global-value) (case sym (well-founded-relation-alist (if (eq token :well-founded-relation) (collect-x-rules-of-rune 'well-founded-relation-rule rune val ans) ans)) (built-in-clauses (if (eq token :built-in-clause) (collect-x-rules-of-rune 'built-in-clause rune val ans) ans)) (type-set-inverter-rules (if (eq token :type-set-inverter) (collect-x-rules-of-rune 'type-set-inverter-rule rune val ans) ans)) (generalize-rules (if (eq token :generalize) (collect-x-rules-of-rune 'generalize-rule rune val ans) ans)) (otherwise ans))) (t (case key (lemmas (if (member-eq token '(:rewrite :meta :definition)) (collect-x-rules-of-rune 'rewrite-rule rune val ans) ans)) (linear-lemmas (if (eq token :linear) (collect-x-rules-of-rune 'linear-lemma rune val ans) ans)) (eliminate-destructors-rules (if (eq token :elim) (collect-x-rules-of-rune 'elim-rule rune val ans) ans)) (congruences (if (member-eq token '(:congruence :equivalence)) (collect-congruence-rules-of-rune val rune ans) ans)) (pequivs (if (eq token :congruence) (collect-pequivs-of-rune (access pequivs-property val :deep) rune (collect-pequivs-of-rune (access pequivs-property val :shallow) rune ans)) ans)) (coarsenings ans) (forward-chaining-rules (if (eq token :forward-chaining) (collect-x-rules-of-rune 'forward-chaining-rule rune val ans) ans)) (type-prescriptions (if (eq token :type-prescription) (collect-x-rules-of-rune 'type-prescription rune val ans) ans)) (induction-rules (if (eq token :induction) (collect-x-rules-of-rune 'induction-rule rune val ans) ans)) (recognizer-alist (if (eq token :compound-recognizer) (collect-x-rules-of-rune 'recognizer-tuple rune val ans) ans)) (otherwise ans))))))
find-rules-of-rune1function
(defun find-rules-of-rune1 (rune props ans) (cond ((null props) ans) ((eq (cddar props) *acl2-property-unbound*) (find-rules-of-rune1 rune (cdr props) ans)) (t (find-rules-of-rune1 rune (cdr props) (find-rules-of-rune2 rune (caar props) (cadar props) (cddar props) ans)))))
world-to-next-eventfunction
(defun world-to-next-event (wrld) (cond ((null wrld) nil) ((and (eq (caar wrld) 'event-landmark) (eq (cadar wrld) 'global-value)) nil) (t (cons (car wrld) (world-to-next-event (cdr wrld))))))
world-to-next-non-deeper-eventfunction
(defun world-to-next-non-deeper-event (n wrld) (cond ((null wrld) nil) ((and (eq (caar wrld) 'event-landmark) (eq (cadar wrld) 'global-value) (<= (access-event-tuple-depth (cddr (car wrld))) n)) nil) (t (cons (car wrld) (world-to-next-non-deeper-event n (cdr wrld))))))
actual-propsfunction
(defun actual-props (props seen acc) (cond ((null props) (prog2$ (fast-alist-free seen) (reverse acc))) ((member-eq (cadar props) (cdr (hons-get (caar props) seen))) (actual-props (cdr props) seen acc)) ((eq (cddr (car props)) *acl2-property-unbound*) (actual-props (cdr props) (hons-acons (caar props) (cons (cadar props) (cdr (hons-get (caar props) seen))) seen) acc)) (t (actual-props (cdr props) (hons-acons (caar props) (cons (cadar props) (cdr (hons-get (caar props) seen))) seen) (cons (car props) acc)))))
find-rules-of-runefunction
(defun find-rules-of-rune (rune wrld) (declare (xargs :guard (and (plist-worldp wrld) (runep rune wrld)))) (let* ((wrld-tail (decode-logical-name (base-symbol rune) wrld)) (depth (access-event-tuple-depth (cddr (car wrld-tail))))) (find-rules-of-rune1 rune (actual-props (world-to-next-non-deeper-event depth (cdr wrld-tail)) 'find-rules-of-rune1 nil) nil)))
backchain-limit-enforcersfunction
(defun backchain-limit-enforcers (position ancestors wrld) (cond ((endp ancestors) nil) (t (let* ((rune (ancestor-backchain-rune (car ancestors))) (rule (and rune (car (find-rules-of-rune rune wrld))))) (cond (rule (let* ((linearp (eq (car rune) :linear)) (backchain-limit-lst (if linearp (access linear-lemma rule :backchain-limit-lst) (access rewrite-rule rule :backchain-limit-lst))) (bkptr (access ancestor (car ancestors) :bkptr)) (hyp-backchain-limit (and backchain-limit-lst (if (and (not linearp) (eq (access rewrite-rule rule :subclass) 'meta)) backchain-limit-lst (nth (1- bkptr) backchain-limit-lst))))) (cond ((and hyp-backchain-limit (>= (1+ position) hyp-backchain-limit)) (cons (cons position hyp-backchain-limit) (backchain-limit-enforcers (1+ position) (cdr ancestors) wrld))) (t (backchain-limit-enforcers (1+ position) (cdr ancestors) wrld))))))))))
tilde-*-ancestors-stack-msg1function
(defun tilde-*-ancestors-stack-msg1 (i ancestors wrld evisc-tuple) (cond ((endp ancestors) nil) ((ancestor-binding-hyp-p (car ancestors)) (cons (msg "~c0. Binding Hyp: ~Q12~|~ ~ ~ ~ ~ ~ Unify-subst: ~Q32~%" (cons i 2) (untranslate (dumb-negate-lit (ancestor-binding-hyp/hyp (car ancestors))) t wrld) evisc-tuple (ancestor-binding-hyp/unify-subst (car ancestors))) (tilde-*-ancestors-stack-msg1 (+ 1 i) (cdr ancestors) wrld evisc-tuple))) (t (cons (let ((tokens (access ancestor (car ancestors) :tokens))) (msg "~c0. Hyp: ~Q12~|~ ~ ~ ~ ~ ~ Rune~#3~[: ~x4~/s: ~x3~]~%" (cons i 2) (untranslate (dumb-negate-lit (access ancestor (car ancestors) :lit)) t wrld) evisc-tuple tokens (car tokens))) (tilde-*-ancestors-stack-msg1 (+ 1 i) (cdr ancestors) wrld evisc-tuple)))))
tilde-*-ancestors-stack-msgfunction
(defun tilde-*-ancestors-stack-msg (ancestors wrld evisc-tuple) (list "" "~@*" "~@*" "~@*" (tilde-*-ancestors-stack-msg1 0 ancestors wrld evisc-tuple)))
semi-initialize-brr-wormholefunction
(defun semi-initialize-brr-wormhole (state) (cond ((eq (f-get-global 'wormhole-name state) 'brr) nil) (t (wormhole-eval 'brr '(lambda (whs) (change brr-status whs :brr-monitored-runes (access brr-status (top-level-brr-status whs) :brr-monitored-runes) :brr-gstack nil :brr-local-alist nil :brr-previous-status nil)) nil))))
show-ancestors-stack-msgfunction
(defun show-ancestors-stack-msg (state evisc-tuple) (msg "Ancestors stack (most recent entry on top):~%~*0~%Use ~x1 to see ~ actual ancestors stack.~%" (tilde-*-ancestors-stack-msg (get-brr-local 'ancestors state) (w state) evisc-tuple) '(get-brr-local 'ancestors state)))
tilde-@-failure-reason-phrase1-backchain-limitfunction
(defun tilde-@-failure-reason-phrase1-backchain-limit (hyp-number ancestors state evisc-tuple) (msg "a backchain limit was reached while processing :HYP ~x0. ~@1" hyp-number (let ((pairs (backchain-limit-enforcers 0 ancestors (w state)))) (cond ((null pairs) (let ((str " Note that the brr command, :ANCESTORS, will show you the ~ ancestors stack.")) (cond ((backchain-limit (w state) :rewrite) (msg "This appears to be due to the global backchain-limit of ~ ~x0.~@1" (backchain-limit (w state) :rewrite) str)) (t (msg "Note that the limit is 0 for that :HYP."))))) (t (msg "The ancestors stack is below. The ~#0~[entry~/entries~] at ~ index ~&0 ~#0~[shows~/each show~] a rune whose ~#0~[~/respective ~ ~]backchain limit of ~v1 has been reached, for backchaining ~ through its indicated hypothesis.~|~%~@2" (strip-cars pairs) (strip-cdrs pairs) (show-ancestors-stack-msg state evisc-tuple)))))))
get-evgfunction
(defun get-evg (q ctx) (if (quotep q) (cadr q) (er hard ctx "We expected a quotep in this context, variables, but ~x0 is not a ~ quotep!" q)))
get-brr-one-way-unify-infofunction
(defun get-brr-one-way-unify-info (lemma rcnst) (declare (xargs :guard (and (or (weak-rewrite-rule-p lemma) (weak-linear-lemma-p lemma)) (weak-rewrite-constant-p rcnst)))) (if (eq (record-type lemma) 'rewrite-rule) (mv (access rewrite-rule lemma :rune) :lhs (if (and (eq (access rewrite-rule lemma :subclass) 'rewrite-quoted-constant) (let ((heuristic-info (access rewrite-rule lemma :heuristic-info))) (and (consp heuristic-info) (eql (car heuristic-info) 2)))) (access rewrite-rule lemma :rhs) (access rewrite-rule lemma :lhs)) (let ((restrictions-alist (access rewrite-constant rcnst :restrictions-alist))) (if (alistp restrictions-alist) (cdr (assoc-equal (access rewrite-rule lemma :rune) restrictions-alist)) nil))) (mv (access linear-lemma lemma :rune) :max-term (access linear-lemma lemma :max-term) nil)))
abstract-pat1mutual-recursion
(mutual-recursion (defun abstract-pat1 (k-flg pat vars) (declare (xargs :guard (and (or (eq k-flg t) (natp k-flg)) (pseudo-termp pat) (true-listp vars)) :verify-guards nil :measure (acl2-count pat))) (cond ((eql k-flg 0) (let ((new-var (genvar 'brr "GENSYM" 0 vars))) (mv new-var (cons new-var vars)))) ((variablep pat) (mv pat vars)) ((fquotep pat) (cond ((and (eq k-flg t) (consp (unquote pat)) (eq (car (unquote pat)) 'lambda)) (let ((new-var (genvar 'brr "GENSYM" 0 vars))) (mv new-var (cons new-var vars)))) (t (mv pat vars)))) (t (mv-let (new-args new-vars) (abstract-pat1-lst (if (natp k-flg) (- k-flg 1) k-flg) (fargs pat) vars) (mv (fcons-term (ffn-symb pat) new-args) new-vars))))) (defun abstract-pat1-lst (k-flg pats vars) (declare (xargs :guard (and (or (eq k-flg t) (natp k-flg)) (pseudo-term-listp pats) (true-listp vars)) :measure (acl2-count pats))) (cond ((endp pats) (mv nil vars)) (t (mv-let (new-arg new-vars) (abstract-pat1 k-flg (car pats) vars) (mv-let (new-args new-vars) (abstract-pat1-lst k-flg (cdr pats) new-vars) (mv (cons new-arg new-args) new-vars)))))))
abstract-patfunction
(defun abstract-pat (k-flg pat) (declare (xargs :guard (and (or (eq k-flg t) (natp k-flg)) (pseudo-termp pat)))) (mv-let (new-pat vars) (abstract-pat1 k-flg pat (all-vars pat)) (declare (ignore vars)) new-pat))
alistp-listpfunction
(defun alistp-listp (x) (declare (xargs :guard t)) (cond ((atom x) (eq x nil)) (t (and (alistp (car x)) (alistp-listp (cdr x))))))
one-way-unify-restrictions1function
(defun one-way-unify-restrictions1 (pat term restrictions) (declare (xargs :guard (and (pseudo-termp pat) (pseudo-termp term) (alistp-listp restrictions)))) (cond ((endp restrictions) (mv nil nil)) (t (mv-let (unify-ans unify-subst) (one-way-unify1 pat term (car restrictions)) (cond (unify-ans (mv unify-ans unify-subst)) (t (one-way-unify-restrictions1 pat term (cdr restrictions))))))))
one-way-unify-restrictionsfunction
(defun one-way-unify-restrictions (pat term restrictions) (declare (xargs :guard (and (pseudo-termp pat) (pseudo-termp term) (alistp-listp restrictions)))) (cond ((null restrictions) (one-way-unify pat term)) (t (one-way-unify-restrictions1 pat term restrictions))))
symbol-alist-to-keyword-value-listfunction
(defun symbol-alist-to-keyword-value-list (alist) (declare (xargs :guard (alistp alist))) (cond ((endp alist) nil) (t (cons (car (car alist)) (cons (cdr (car alist)) (symbol-alist-to-keyword-value-list (cdr alist)))))))
brr-criteria-alistpfunction
(defun brr-criteria-alistp (alist) (declare (xargs :guard t)) (cond ((atom alist) (equal alist nil)) ((not (consp (car alist))) nil) ((eq (car (car alist)) :depth) (and (natp (cdr (car alist))) (brr-criteria-alistp (cdr alist)))) ((eq (car (car alist)) :abstraction) (and (pseudo-termp (cdr (car alist))) (brr-criteria-alistp (cdr alist)))) ((eq (car (car alist)) :lambda) (and (booleanp (cdr (car alist))) (brr-criteria-alistp (cdr alist)))) (t (brr-criteria-alistp (cdr alist)))))
make-built-in-brr-near-miss-msgfunction
(defun make-built-in-brr-near-miss-msg (brr-cmd-name pat alist depth-criterion-satisfiedp abstraction-criterion-satisfiedp lambda-criterion-satisfiedp) (declare (xargs :guard (and (pseudo-termp pat) (brr-criteria-alistp alist) (implies depth-criterion-satisfiedp (natp (cdr (assoc-eq :depth alist))))))) (let* ((depth-msg (if depth-criterion-satisfiedp (list (msg "* The abstraction of ~x0 to depth ~x1, namely the ~ pattern ~X23, matches :TARGET." brr-cmd-name (cdr (assoc-eq :depth alist)) (abstract-pat (cdr (assoc-eq :depth alist)) pat) nil)) nil)) (abstraction-msg (if abstraction-criterion-satisfiedp (list (msg "* The :ABSTRACTION pattern provided in your ~ monitor, ~x0, matches :TARGET." (cdr (assoc-eq :abstraction alist)))) nil)) (lambda-msg (if lambda-criterion-satisfiedp (list (msg "* ~x0 matches :TARGET except at one or more quoted ~ LAMBDA constants." brr-cmd-name)) nil)) (reasons (append depth-msg abstraction-msg lambda-msg))) (msg "However, this is considered a NEAR MISS under the break criteria, ~ ~X01, specified when this rule was monitored. The following ~ ~#2~[criterion is~/criteria are~] satisfied.~%~%~*3" (symbol-alist-to-keyword-value-list alist) nil (if (cdr reasons) 1 0) (list "" "~@*~%~%" "~@*~%~%" "~@*~%~%" reasons))))
built-in-brr-near-misspfunction
(defun built-in-brr-near-missp (msgp lemma target rcnst criteria-alist) (declare (xargs :guard (and (or (weak-rewrite-rule-p lemma) (weak-linear-lemma-p lemma)) (pseudo-termp target) (weak-rewrite-constant-p rcnst) (brr-criteria-alistp criteria-alist)))) (mv-let (rune brr-cmd-name pattern restrictions) (get-brr-one-way-unify-info lemma rcnst) (declare (ignore rune)) (cond ((and (pseudo-termp pattern) (alistp-listp restrictions)) (let* ((depth-arg (assoc-eq :depth criteria-alist)) (depth-criterion-satisfiedp (if (cdr depth-arg) (mv-let (flg unify-subst) (one-way-unify-restrictions (abstract-pat (cdr depth-arg) pattern) target restrictions) (declare (ignore unify-subst)) flg) nil)) (abstraction-arg (if (and (not msgp) depth-criterion-satisfiedp) nil (assoc-eq :abstraction criteria-alist))) (abstraction-criterion-satisfiedp (if (cdr abstraction-arg) (mv-let (flg unify-subst) (one-way-unify-restrictions (cdr abstraction-arg) target restrictions) (declare (ignore unify-subst)) flg) nil)) (lambda-arg (if (and (not msgp) (or depth-criterion-satisfiedp abstraction-criterion-satisfiedp)) nil (assoc-eq :lambda criteria-alist))) (lambda-criterion-satisfiedp (if (cdr lambda-arg) (mv-let (flg unify-subst) (one-way-unify-restrictions (abstract-pat (cdr lambda-arg) pattern) target restrictions) (declare (ignore unify-subst)) flg) nil))) (if (or depth-criterion-satisfiedp abstraction-criterion-satisfiedp lambda-criterion-satisfiedp) (if msgp (make-built-in-brr-near-miss-msg brr-cmd-name pattern criteria-alist depth-criterion-satisfiedp abstraction-criterion-satisfiedp lambda-criterion-satisfiedp) t) nil))) (t nil))))
other
(defattach (brr-near-missp built-in-brr-near-missp) :skip-checks t)
tilde-@-failure-reason-free-phrasemutual-recursion
(mutual-recursion (defun tilde-@-failure-reason-free-phrase (hyp-number alist level unify-subst evisc-tuple state) (cond ((null alist) "") (t (let ((new-unify-subst (caar alist)) (new-failure-reason (cdar alist))) (msg "~t0[~x1]~*2~|~@3~@4~@5" (if (< hyp-number 10) (* 4 level) (1- (* 4 level))) hyp-number (tilde-*-alist-phrase (alist-difference-eq new-unify-subst unify-subst) evisc-tuple (+ 4 (* 4 level))) (if (let ((fr (if (and (consp new-failure-reason) (eq (car new-failure-reason) 'cached)) (cdr new-failure-reason) new-failure-reason))) (and (consp fr) (integerp (car fr)) (or (not (and (consp (cdr fr)) (eq (cadr fr) 'free-vars))) (and (consp (cdr fr)) (consp (cddr fr)) (member-eq (caddr fr) '(hyp-vars elided)))))) "Failed because " "") (tilde-@-failure-reason-phrase1 new-failure-reason (1+ level) new-unify-subst evisc-tuple nil state) (tilde-@-failure-reason-free-phrase hyp-number (cdr alist) level unify-subst evisc-tuple state)))))) (defun tilde-@-failure-reason-phrase1 (failure-reason level unify-subst evisc-tuple free-vars-display-limit state) (cond ((eq failure-reason 'time-out) "we ran out of time.") ((eq failure-reason 'refinement-failure) "the rule's equivalence relation is not a refinement of the geneqv.") ((eq failure-reason 'near-miss) "the pattern (:LHS or :MAX-TERM) did not match the :TARGET.") ((eq failure-reason 'loop-stopper) "it permutes a big term forward.") ((eq failure-reason 'too-many-ifs-pre-rewrite) "the unrewritten :RHS contains too many IFs for the given args.") ((eq failure-reason 'too-many-ifs-post-rewrite) "the rewritten :RHS contains too many IFs for the given args.") ((eq failure-reason 'rewrite-fncallp) "the :REWRITTEN-RHS is judged heuristically unattractive.") ((member-eq failure-reason '(linearize-unrewritten-produced-disjunction linearize-rewritten-produced-disjunction)) (msg "the ~@0 term generated a disjunction of two conjunctions of ~ polynomials." (if (eq failure-reason 'linearize-rewritten-produced-disjunction) 'rewritten 'unrewritten))) ((eq failure-reason 'linear-possible-loop) "the rewritten term was judged to have the potential to cause a loop ~ related to linear arithmetic.") ((and (consp failure-reason) (integerp (car failure-reason))) (let ((n (car failure-reason))) (case (cdr failure-reason) (time-out (msg "we ran out of time while processing :HYP ~x0." n)) (ancestors (msg ":HYP ~x0 is judged more complicated than its ~ ancestors (type :ANCESTORS to see the ancestors ~ and :PATH to see how we got to this point)." n)) (known-nil (msg ":HYP ~x0 is known nil by type-set." n)) (otherwise (cond ((eq (cadr failure-reason) 'free-vars) (mv-let (failures-remaining failure-reason elided-p) (if free-vars-display-limit (limit-failure-reason free-vars-display-limit failure-reason nil) (mv nil failure-reason nil)) (declare (ignore failures-remaining)) (cond ((eq (caddr failure-reason) 'hyp-vars) (msg ":HYP ~x0 contains free variable~#1~[~/s~] ~&1, for ~ which no suitable ~#1~[binding was~/bindings were~] ~ found." n (set-difference-equal (cdddr failure-reason) (strip-cars unify-subst)))) ((eq (caddr failure-reason) 'elided) (msg ":HYP ~x0 contains free variables (further reasons ~ elided, as noted above)." n)) (t (msg "~@0~@1" (if (eql level 1) (msg ":HYP ~x0 ~@1. The following display summarizes ~ the attempts to relieve hypotheses by binding ~ free variables; see :DOC free-variables.~|~@2~%" n (if (let* ((hyp (nth (1- n) (get-rule-field (get-brr-local 'lemma state) :hyps))) (evg (and (ffn-symb-p hyp 'synp) (quotep (fargn hyp 2)) (unquote (fargn hyp 2))))) (and evg (consp evg) (eq (car evg) 'bind-free))) (msg "uses ~x0 to produce unsuccessful free ~ variable bindings" 'bind-free) "contains free variables") (if elided-p (msg " Also, if you want to avoid ~ ``reasons elided'' notes below, then ~ evaluate (assign free-vars-display-limit ~ k) for larger k (currently ~x0, default ~ ~x1); then :failure-reason will show the ~ first k or so failure sub-reasons before ~ eliding. Note that you may want to do ~ this evaluation outside break-rewrite, ~ so that it persists.~|" free-vars-display-limit *default-free-vars-display-limit*) "")) "") (tilde-@-failure-reason-free-phrase n (cddr failure-reason) level unify-subst evisc-tuple state)))))) ((eq (cadr failure-reason) 'backchain-limit) (tilde-@-failure-reason-phrase1-backchain-limit n (cddr failure-reason) state evisc-tuple)) ((eq (cadr failure-reason) 'rewrote-to) (msg ":HYP ~x0 rewrote to ~X12.~@3" n (cddr failure-reason) evisc-tuple (if (equal (cddr failure-reason) *nil*) " (See :DOC tail-biting if this surprises you.)" ""))) ((member-eq (cadr failure-reason) '(syntaxp syntaxp-extended bind-free bind-free-extended)) (let ((synp-fn (case (cadr failure-reason) (syntaxp-extended 'syntaxp) (bind-free-extended 'bind-free) (otherwise (cadr failure-reason))))) (cond ((caddr failure-reason) (msg "the evaluation of the ~x0 test in :HYP ~x1 ~ produced the error ``~@2''" synp-fn n (cadddr failure-reason))) (t (msg "the ~x0 test in :HYP ~x1 evaluated to NIL." synp-fn n))))) (t (er hard 'tilde-@-failure-reason-phrase1 "Unrecognized failure reason, ~x0." failure-reason))))))) ((and (consp failure-reason) (eq (car failure-reason) 'normalizer-failed-to-evaluate)) (msg "the normalizer, ~x0, simplified to a non-constant, ~x1." (cadr failure-reason) (caddr failure-reason))) ((and (consp failure-reason) (eq (car failure-reason) 'normalizer-returned-same-constant)) (msg "the normalizer, ~x0, simplified to the same constant, ~x1." (cadr failure-reason) (caddr failure-reason))) ((and (consp failure-reason) (eq (car failure-reason) 'cached)) (msg "~@0~|*NOTE*: This failure was cached earlier. Use the hint ~ :RW-CACHE-STATE ~x1 to disable failure caching." (tilde-@-failure-reason-phrase1 (cdr failure-reason) level unify-subst evisc-tuple free-vars-display-limit state) nil)) (t (er hard 'tilde-@-failure-reason-phrase1 "Unrecognized failure reason, ~x0." failure-reason)))))
tilde-@-failure-reason-phrasefunction
(defun tilde-@-failure-reason-phrase (failure-reason level unify-subst evisc-tuple free-vars-display-limit state) (tilde-@-failure-reason-phrase1 (fix-free-failure-reason failure-reason) level unify-subst evisc-tuple free-vars-display-limit state))
brr-resultfunction
(defun brr-result (state) (let ((result (get-brr-local 'brr-result state))) (cond ((eq (record-type (get-brr-local 'lemma state)) 'linear-lemma) (show-poly-lst result)) (t result))))
*brkpt1-aliases*constant
(defconst *brkpt1-aliases* (flet ((not-yet-evaled-fn nil `(lambda nil (prog2$ (cw "~F0 has not yet been :EVALed.~%" (get-rule-field (get-brr-local 'lemma state) :rune)) (value :invisible)))) (lhs-fn (plusp) `(lambda nil (let ((val (get-rule-field (get-brr-local 'lemma state) :lhs))) (cond ((eq val :get-rule-field-none) (er soft :lhs ":LHS is only legal for a :REWRITE rule.")) (t (prog2$ (cw "~X01~|" val ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE))) (value :invisible))))))) (max-term-fn (plusp) `(lambda nil (let ((val (get-rule-field (get-brr-local 'lemma state) :max-term))) (cond ((eq val :get-rule-field-none) (er soft :max-term ":MAX-TERM is only legal for a :LINEAR rule.")) (t (prog2$ (cw "~X01~|" val ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE))) (value :invisible))))))) (ancestors-fn (plusp) `(lambda nil (prog2$ (cw "~@0" (show-ancestors-stack-msg state ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE)))) (value :invisible)))) (btm-fn (plusp) `(lambda nil (prog2$ (let* ((whs (f-get-global 'wormhole-status state)) (gstack (access brr-status whs :brr-gstack))) (cw-gframe (length gstack) nil (car gstack) ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE)))) (value :invisible)))) (frame-fn (plusp) `(lambda (n) (let* ((whs (f-get-global 'wormhole-status state)) (rgstack (reverse (access brr-status whs :brr-gstack)))) (cond ((and (integerp n) (>= n 1) (<= n (length rgstack))) (prog2$ (cw-gframe n (if (= n 1) nil (access gframe (nth (- n 2) rgstack) :sys-fn)) (nth (- n 1) rgstack) ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE))) (value :invisible))) (t (er soft :frame ":FRAME must be given an integer argument ~ between 1 and ~x0." (length rgstack))))))) (initial-ttree-fn (plusp) `(lambda nil (let ((lemma (get-brr-local 'lemma state))) (cond ((eq (record-type lemma) 'linear-lemma) (er soft :initial-ttree ":INITIAL-TTREE is not legal for a ~ :LINEAR rule.")) (t (prog2$ (cw "~X01~|" (get-brr-local 'initial-ttree state) ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE))) (value :invisible))))))) (path-fn (plusp) `(lambda nil (prog2$ (cw-gstack :evisc-tuple ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE))) (value :invisible)))) (pot-list-fn (plusp) `(lambda nil (let ((pot-list (get-brr-local 'pot-list state))) (prog2$ (if pot-list (prog2$ (cw "~%Display of linear pot-list:~|") (print-pot-lst pot-list ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE)))) (cw "~%The linear pot-list is empty.~|")) (value :invisible))))) (target-fn (plusp) `(lambda nil (prog2$ (cw "~X01~|" (get-brr-local 'target state) ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE))) (value :invisible)))) (top-fn (plusp) `(lambda nil (prog2$ (cw-gframe 1 nil (car (reverse (access brr-status (f-get-global 'wormhole-status state) :brr-gstack))) ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE))) (value :invisible)))) (type-alist-fn (plusp) `(lambda nil (prog2$ (cw "~%Decoded type-alist:~%") (prog2$ (print-type-alist-segments (type-alist-segments (get-brr-local 'type-alist state) nil) (w state) ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE))) (prog2$ (cw "~%==========~%Use ~x0 to see actual ~ type-alist.~%" '(get-brr-local 'type-alist state)) (value :invisible)))))) (geneqv-fn (plusp) `(lambda nil (prog2$ (cw "~%Geneqv:~%~Y01" (show-geneqv (get-brr-local 'geneqv state) 'non-prims) ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE))) (prog2$ (cw "~%==========~%Use ~x0 to see actual geneqv ~ data structure.~%" '(get-brr-local 'geneqv state)) (value :invisible))))) (unify-subst-fn (plusp) `(lambda nil (prog2$ (cw "~*0" (tilde-*-alist-phrase (get-brr-local 'unify-subst state) ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE)) 5)) (value :invisible))))) `((:ancestors 0 ,(ANCESTORS-FN NIL)) (:ancestors+ 0 ,(ANCESTORS-FN T)) (:btm 0 ,(BTM-FN NIL)) (:btm+ 0 ,(BTM-FN T)) (:eval 0 (lambda nil (proceed-from-brkpt1 'break t :eval state))) (:eval! 0 (lambda nil (proceed-from-brkpt1 'break :none :eval! state))) (:eval$ 1 (lambda (runes) (proceed-from-brkpt1 'break runes :eval$ state))) (:explain-near-miss 0 (lambda nil (explain-near-miss1 (get-brr-local 'target state) 30 (evisc-tuple 10 20 nil nil) state))) (:explain-near-miss+ 0 (lambda nil (explain-near-miss1 (get-brr-local 'target state) nil nil state))) (:failure-reason 0 ,(NOT-YET-EVALED-FN)) (:failure-reason+ 0 ,(NOT-YET-EVALED-FN)) (:final-ttree 0 ,(NOT-YET-EVALED-FN)) (:final-ttree+ 0 ,(NOT-YET-EVALED-FN)) (:frame 1 ,(FRAME-FN NIL)) (:frame+ 1 ,(FRAME-FN T)) (:go 0 (lambda nil (proceed-from-brkpt1 'print t :go state))) (:go! 0 (lambda nil (proceed-from-brkpt1 'print :none :go! state))) (:go$ 1 (lambda (runes) (proceed-from-brkpt1 'print runes :go$ state))) (:help 0 (lambda nil (doc 'brr-commands))) (:hyp 1 (lambda (n) (cond ((and (integerp n) (>= n 1) (<= n (length (get-rule-field (get-brr-local 'lemma state) :hyps)))) (prog2$ (cw "~X01~|" (nth (1- n) (get-rule-field (get-brr-local 'lemma state) :hyps)) nil) (value :invisible))) (t (er soft :hyp ":HYP must be given an integer argument between 1 and ~x0." (length (get-rule-field (get-brr-local 'lemma state) :hyps))))))) (:hyps 0 (lambda nil (prog2$ (cw "~x0~|" (get-rule-field (get-brr-local 'lemma state) :hyps)) (value :invisible)))) (:initial-ttree 0 ,(INITIAL-TTREE-FN NIL)) (:initial-ttree+ 0 ,(INITIAL-TTREE-FN T)) (:lhs 0 ,(LHS-FN NIL)) (:lhs+ 0 ,(LHS-FN T)) (:max-term 0 ,(MAX-TERM-FN NIL)) (:max-term+ 0 ,(MAX-TERM-FN T)) (:ok 0 (lambda nil (proceed-from-brkpt1 'silent t :ok state))) (:ok! 0 (lambda nil (proceed-from-brkpt1 'silent :none :ok! state))) (:ok$ 1 (lambda (runes) (proceed-from-brkpt1 'silent runes :ok$ state))) (:path 0 ,(PATH-FN NIL)) (:path+ 0 ,(PATH-FN T)) (:poly-list 0 ,(NOT-YET-EVALED-FN)) (:poly-list+ 0 ,(NOT-YET-EVALED-FN)) (:pot-list 0 ,(POT-LIST-FN NIL)) (:pot-list+ 0 ,(POT-LIST-FN T)) (:q 0 (lambda nil (prog2$ (cw "Proceed with some flavor of :ok, :go, or :eval, or ~ use :a! to abort.~%") (value :invisible)))) (:rewritten-rhs 0 ,(NOT-YET-EVALED-FN)) (:rewritten-rhs+ 0 ,(NOT-YET-EVALED-FN)) (:rhs 0 (lambda nil (let ((val (get-rule-field (get-brr-local 'lemma state) :rhs))) (cond ((eq val :get-rule-field-none) (er soft :rhs ":RHS is only legal for a :REWRITE rule.")) (t (prog2$ (cw "~x0~|" val) (value :invisible))))))) (:standard-help 0 help) (:target 0 ,(TARGET-FN NIL)) (:target+ 0 ,(TARGET-FN T)) (:top 0 ,(TOP-FN NIL)) (:top+ 0 ,(TOP-FN T)) (:type-alist 0 ,(TYPE-ALIST-FN NIL)) (:type-alist+ 0 ,(TYPE-ALIST-FN T)) (:geneqv 0 ,(GENEQV-FN NIL)) (:geneqv+ 0 ,(GENEQV-FN T)) (:unify-subst 0 ,(UNIFY-SUBST-FN NIL)) (:unify-subst+ 0 ,(UNIFY-SUBST-FN T)) (:wonp 0 ,(NOT-YET-EVALED-FN)))))
*brkpt2-aliases*constant
(defconst *brkpt2-aliases* (flet ((already-evaled-fn nil '(lambda nil (prog2$ (cw "You already have run some flavor ~ of :eval.~%") (value :invisible)))) (lhs-fn (plusp) `(lambda nil (let ((val (get-rule-field (get-brr-local 'lemma state) :lhs))) (cond ((eq val :get-rule-field-none) (er soft :lhs ":LHS is only legal for a :REWRITE rule.")) (t (prog2$ (cw "~X01~|" val ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE))) (value :invisible))))))) (max-term-fn (plusp) `(lambda nil (let ((val (get-rule-field (get-brr-local 'lemma state) :max-term))) (cond ((eq val :get-rule-field-none) (er soft :max-term ":MAX-TERM is only legal for a :LINEAR rule.")) (t (prog2$ (cw "~X01~|" val ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE))) (value :invisible))))))) (ancestors-fn (plusp) `(lambda nil (prog2$ (cw "~@0" (show-ancestors-stack-msg state ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE)))) (value :invisible)))) (btm-fn (plusp) `(lambda nil (prog2$ (let* ((whs (f-get-global 'wormhole-status state)) (gstack (access brr-status whs :brr-gstack))) (cw-gframe (length gstack) nil (car gstack) ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE)))) (value :invisible)))) (failure-reason-fn (plusp) `(lambda nil (prog2$ (if (get-brr-local 'wonp state) (cw "? ~F0 succeeded.~%" (get-rule-field (get-brr-local 'lemma state) :rune)) (cw "~@0~|" (tilde-@-failure-reason-phrase (get-brr-local 'failure-reason state) 1 (get-brr-local 'unify-subst state) ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE)) (free-vars-display-limit state) state))) (value :invisible)))) (final-ttree-fn (plusp) `(lambda nil (let ((lemma (get-brr-local 'lemma state))) (cond ((eq (record-type lemma) 'linear-lemma) (er soft :final-ttree ":FINAL-TTREE is not legal for a :LINEAR ~ rule.")) (t (prog2$ (cw "~X01~|" (get-brr-local 'final-ttree state) ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE))) (value :invisible))))))) (frame-fn (plusp) `(lambda (n) (let* ((whs (f-get-global 'wormhole-status state)) (rgstack (reverse (access brr-status whs :brr-gstack)))) (cond ((and (integerp n) (>= n 1) (<= n (length rgstack))) (prog2$ (cw-gframe n (if (= n 1) nil (access gframe (nth (- n 2) rgstack) :sys-fn)) (nth (- n 1) rgstack) ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE))) (value :invisible))) (t (er soft :frame ":FRAME must be given an integer argument ~ between 1 and ~x0." (length rgstack))))))) (initial-ttree-fn (plusp) `(lambda nil (let ((lemma (get-brr-local 'lemma state))) (cond ((eq (record-type lemma) 'linear-lemma) (er soft :initial-ttree ":INITIAL-TTREE is not legal for a ~ :LINEAR rule.")) (t (prog2$ (cw "~X01~|" (get-brr-local 'initial-ttree state) ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE))) (value :invisible))))))) (path-fn (plusp) `(lambda nil (prog2$ (cw-gstack :evisc-tuple ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE))) (value :invisible)))) (poly-list-fn (plusp) `(lambda nil (let ((lemma (get-brr-local 'lemma state))) (cond ((eq (record-type lemma) 'linear-lemma) (prog2$ (cond ((get-brr-local 'wonp state) (cw "~X01~|" (brr-result state) ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE)))) (t (cw "? ~F0 failed.~%" (get-rule-field lemma :rune)))) (value :invisible))) (t (er soft :poly-list ":POLY-LIST is only legal for a :LINEAR ~ rule.")))))) (pot-list-fn (plusp) `(lambda nil (let ((pot-list (get-brr-local 'pot-list state))) (prog2$ (if pot-list (prog2$ (cw "~%Display of linear pot-list:~|") (print-pot-lst pot-list ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE)))) (cw "~%The linear pot-list is empty.~|")) (value :invisible))))) (rewritten-rhs-fn (plusp) `(lambda nil (let ((lemma (get-brr-local 'lemma state))) (cond ((eq (record-type lemma) 'rewrite-rule) (prog2$ (cond ((or (get-brr-local 'wonp state) (member-eq (get-brr-local 'failure-reason state) '(too-many-ifs rewrite-fncallp))) (cw "~X01~|" (get-brr-local 'brr-result state) ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE)))) (t (cw "? ~F0 failed.~%" (get-rule-field lemma :rune)))) (value :invisible))) (t (er soft :rewritten-rhs ":REWRITTEN-RHS is only legal for a ~ :REWRITE rule.")))))) (target-fn (plusp) `(lambda nil (prog2$ (cw "~X01~|" (get-brr-local 'target state) ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE))) (value :invisible)))) (top-fn (plusp) `(lambda nil (prog2$ (cw-gframe 1 nil (car (reverse (access brr-status (f-get-global 'wormhole-status state) :brr-gstack))) ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE))) (value :invisible)))) (type-alist-fn (plusp) `(lambda nil (prog2$ (cw "~%Decoded type-alist:~%") (prog2$ (print-type-alist-segments (type-alist-segments (get-brr-local 'type-alist state) nil) (w state) ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE))) (prog2$ (cw "~%==========~%Use ~x0 to see actual ~ type-alist.~%" '(get-brr-local 'type-alist state)) (value :invisible)))))) (geneqv-fn (plusp) `(lambda nil (prog2$ (cw "~%Geneqv:~%~Y01" (show-geneqv (get-brr-local 'geneqv state) 'non-prims) ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE))) (prog2$ (cw "~%==========~%Use ~x0 to see actual geneqv ~ data structure.~%" '(get-brr-local 'geneqv state)) (value :invisible))))) (unify-subst-fn (plusp) `(lambda nil (prog2$ (cw "~*0" (tilde-*-alist-phrase (get-brr-local 'unify-subst state) ,(IF PLUSP NIL '(BRR-EVISC-TUPLE STATE)) 5)) (value :invisible))))) `((:ancestors 0 ,(ANCESTORS-FN NIL)) (:ancestors+ 0 ,(ANCESTORS-FN T)) (:btm 0 ,(BTM-FN NIL)) (:btm+ 0 ,(BTM-FN T)) (:eval 0 ,(ALREADY-EVALED-FN)) (:eval! 0 ,(ALREADY-EVALED-FN)) (:eval$ 1 (lambda (runes) (prog2$ runes ,(ALREADY-EVALED-FN)))) (:explain-near-miss 0 (lambda nil (explain-near-miss1 (get-brr-local 'target state) 30 (evisc-tuple 10 20 nil nil) state))) (:explain-near-miss+ 0 (lambda nil (explain-near-miss1 (get-brr-local 'target state) nil nil state))) (:failure-reason 0 ,(FAILURE-REASON-FN NIL)) (:failure-reason+ 0 ,(FAILURE-REASON-FN T)) (:final-ttree 0 ,(FINAL-TTREE-FN NIL)) (:final-ttree+ 0 ,(FINAL-TTREE-FN T)) (:frame 1 ,(FRAME-FN NIL)) (:frame+ 1 ,(FRAME-FN T)) (:go 0 (lambda nil (exit-brr state))) (:go! 0 (lambda nil (exit-brr state))) (:go$ 1 (lambda (runes) (prog2$ runes (exit-brr state)))) (:help 0 (lambda nil (doc 'brr-commands))) (:hyp 1 (lambda (n) (cond ((and (integerp n) (>= n 1) (<= n (length (get-rule-field (get-brr-local 'lemma state) :hyps)))) (prog2$ (cw "~X01~|" (nth (1- n) (get-rule-field (get-brr-local 'lemma state) :hyps)) nil) (value :invisible))) (t (er soft :hyp ":HYP must be given an integer argument between 1 and ~x0." (length (get-rule-field (get-brr-local 'lemma state) :hyps))))))) (:hyps 0 (lambda nil (prog2$ (cw "~x0~|" (get-rule-field (get-brr-local 'lemma state) :hyps)) (value :invisible)))) (:initial-ttree 0 ,(INITIAL-TTREE-FN NIL)) (:initial-ttree+ 0 ,(INITIAL-TTREE-FN T)) (:lhs 0 ,(LHS-FN NIL)) (:lhs+ 0 ,(LHS-FN T)) (:max-term 0 ,(MAX-TERM-FN NIL)) (:max-term+ 0 ,(MAX-TERM-FN T)) (:ok 0 (lambda nil (exit-brr state))) (:ok! 0 (lambda nil (exit-brr state))) (:ok$ 1 (lambda (runes) (prog2$ runes (exit-brr state)))) (:path 0 ,(PATH-FN NIL)) (:path+ 0 ,(PATH-FN T)) (:poly-list 0 ,(POLY-LIST-FN NIL)) (:poly-list+ 0 ,(POLY-LIST-FN T)) (:pot-list 0 ,(POT-LIST-FN NIL)) (:pot-list+ 0 ,(POT-LIST-FN T)) (:q 0 (lambda nil (prog2$ (cw "Proceed with some flavor of :ok, :go, or :eval, ~ or use :a! to abort.~%") (value :invisible)))) (:rewritten-rhs 0 ,(REWRITTEN-RHS-FN NIL)) (:rewritten-rhs+ 0 ,(REWRITTEN-RHS-FN T)) (:rhs 0 (lambda nil (let ((val (get-rule-field (get-brr-local 'lemma state) :rhs))) (cond ((eq val :get-rule-field-none) (er soft :rhs ":RHS is only legal for a :REWRITE rule.")) (t (prog2$ (cw "~x0~|" val) (value :invisible))))))) (:standard-help 0 help) (:target 0 ,(TARGET-FN NIL)) (:target+ 0 ,(TARGET-FN T)) (:top 0 ,(TOP-FN NIL)) (:top+ 0 ,(TOP-FN T)) (:type-alist 0 ,(TYPE-ALIST-FN NIL)) (:type-alist+ 0 ,(TYPE-ALIST-FN T)) (:geneqv 0 ,(GENEQV-FN NIL)) (:geneqv+ 0 ,(GENEQV-FN T)) (:unify-subst 0 ,(UNIFY-SUBST-FN NIL)) (:unify-subst+ 0 ,(UNIFY-SUBST-FN T)) (:wonp 0 (lambda nil (prog2$ (if (get-brr-local 'wonp state) (cw "? ~F0 succeeded.~%" (get-rule-field (get-brr-local 'lemma state) :rune)) (cw "? ~F0 failed.~%" (get-rule-field (get-brr-local 'lemma state) :rune))) (value :invisible)))))))
other
(defrec brr-data-1 (((lemma . target) unify-subst type-alist . geneqv) (pot-list . ancestors) rcnst initial-ttree . gstack) nil)
other
(defrec brr-data-2 ((failure-reason unify-subst . brr-result) rcnst final-ttree . gstack) nil)
other
(defrec brr-data (pre post . completed) nil)
brr-data-pmutual-recursion
(mutual-recursion (defun brr-data-p (completed-p x) (declare (xargs :guard t :measure (acl2-count x))) (and (weak-brr-data-p x) (weak-brr-data-1-p (access brr-data x :pre)) (if completed-p (weak-brr-data-2-p (access brr-data x :post)) (null (access brr-data x :post))) (brr-data-listp t (access brr-data x :completed)))) (defun brr-data-listp (completed-p lst) (declare (xargs :guard t :measure (acl2-count lst))) (cond ((atom lst) (null lst)) ((brr-data-p completed-p (car lst)) (brr-data-listp completed-p (cdr lst))) (t nil))))
other
(defstub update-brr-data-1 (lemma target unify-subst type-alist geneqv ancestors initial-ttree gstack rcnst pot-lst whs-data) t)
other
(defstub update-brr-data-2 (wonp failure-reason unify-subst gstack brr-result final-ttree rcnst ancestors whs-data) t)
brkpt1-brr-data-entry-builtinfunction
(defun brkpt1-brr-data-entry-builtin (ancestors gstack rcnst state) (declare (xargs :stobjs state) (ignore gstack rcnst state)) (null ancestors))
brkpt2-brr-data-entry-builtinfunction
(defun brkpt2-brr-data-entry-builtin (ancestors gstack rcnst state) (declare (xargs :stobjs state) (ignore gstack rcnst state)) (null ancestors))
update-brr-data-1-builtinfunction
(defun update-brr-data-1-builtin (lemma target unify-subst type-alist geneqv ancestors initial-ttree gstack rcnst pot-lst whs-data) (declare (xargs :guard t)) (let ((ctx 'update-brr-data-1-builtin)) (cond ((listp whs-data) (let* ((pending (car whs-data)) (completed (cdr whs-data))) (cons (cons (make brr-data :pre (make brr-data-1 :lemma lemma :target target :unify-subst unify-subst :type-alist type-alist :geneqv geneqv :ancestors ancestors :initial-ttree initial-ttree :gstack gstack :rcnst rcnst :pot-list pot-lst) :post nil :completed nil) pending) completed))) (t (er hard? ctx "Implementation error: Found whs-data not a listp:~|~y0" whs-data)))))
update-brr-data-2-builtinfunction
(defun update-brr-data-2-builtin (wonp failure-reason unify-subst gstack brr-result final-ttree rcnst ancestors whs-data) (declare (xargs :guard t) (ignore ancestors)) (let ((ctx 'update-brr-data-2-builtin)) (cond ((listp whs-data) (let* ((pending (car whs-data)) (completed (cdr whs-data))) (cond ((not (consp pending)) (er hard? ctx "Implementation error: Found bad whs-data ((car pending) not a ~ cons):~|~y0" whs-data)) ((null wonp) (cons (cdr pending) completed)) ((not (weak-brr-data-p (car pending))) (er hard? ctx "Implementation error: Found bad whs-data ((car pending) not a ~ brr-data record)):~|~y0" whs-data)) (t (let ((x (make brr-data-2 :failure-reason failure-reason :unify-subst unify-subst :gstack gstack :brr-result brr-result :final-ttree final-ttree :rcnst rcnst))) (cond ((consp (cdr pending)) (cond ((not (weak-brr-data-p (cadr pending))) (er hard? ctx "Implementation error: Found whs-data (bad (cadr ~ pending)):~|~y0" whs-data)) (t (cons (cons (change brr-data (cadr pending) :completed (cons (change brr-data (car pending) :post x) (access brr-data (cadr pending) :completed))) (cddr pending)) completed)))) (t (cons nil (cons (change brr-data (car pending) :post x) completed))))))))) (t (er hard? ctx "Implementation error: Found whs-data not a listp:~|~y0" whs-data)))))
set-brr-data-attachmentsmacro
(defmacro set-brr-data-attachments (&optional (suffix 'builtin)) (declare (xargs :guard (or (symbolp suffix) (stringp suffix)))) (let* ((suffix (cond ((symbolp suffix) (symbol-name suffix)) (t suffix))) (suffix (concatenate 'string "-" suffix)) (update-brr-data-1-suffix (add-suffix 'update-brr-data-1 suffix)) (update-brr-data-2-suffix (add-suffix 'update-brr-data-2 suffix)) (brkpt1-bde-suffix (add-suffix 'brkpt1-brr-data-entry suffix)) (brkpt2-bde-suffix (add-suffix 'brkpt2-brr-data-entry suffix))) `(with-output :off :all (progn (defattach (update-brr-data-1 ,UPDATE-BRR-DATA-1-SUFFIX) :system-ok t) (defattach (update-brr-data-2 ,UPDATE-BRR-DATA-2-SUFFIX) :system-ok t) (defattach (brkpt1-brr-data-entry ,BRKPT1-BDE-SUFFIX) :system-ok t) (defattach (brkpt2-brr-data-entry ,BRKPT2-BDE-SUFFIX) :system-ok t)))))
set-wormhole-data-fastfunction
(defun set-wormhole-data-fast (whs data) (declare (xargs :guard t)) (if (consp whs) (cons (car whs) data) (cons :enter data)))
brr-data-mirrorfunction
(defun brr-data-mirror (lst acc) (declare (xargs :guard (and (brr-data-listp t lst) (true-listp acc)))) (cond ((endp lst) acc) (t (let* ((x1 (car lst)) (c (access brr-data x1 :completed)) (x2 (if (null c) x1 (change brr-data x1 :completed (brr-data-mirror c nil))))) (brr-data-mirror (cdr lst) (cons x2 acc))))))
brr-data-lstfunction
(defun brr-data-lst (state) (declare (xargs :stobjs state)) (er-let* ((status (get-persistent-whs 'brr-data state))) (value (let ((data (wormhole-data status))) (cond ((consp data) (ec-call (brr-data-mirror (cdr data) nil))) (t nil))))))
clear-brr-data-lstfunction
(defun clear-brr-data-lst nil (declare (xargs :guard t)) (wormhole-eval 'brr-data '(lambda (whs) (set-wormhole-data-fast whs nil)) nil))
with-brr-datamacro
(defmacro with-brr-data (form &key (global-var 'brr-data-lst) (brr-data-returned 'nil)) (let* ((form1 `(state-global-let* ((gstackp :brr-data)) ,FORM)) (form2 (if global-var `(mv-let (erp val state) ,FORM1 (er-progn (set-brr-data-lst ,GLOBAL-VAR) (mv erp val state))) form1)) (form3 (if brr-data-returned `(mv-let (erp val state) ,FORM2 (declare (ignore val)) ,(IF GLOBAL-VAR `(MV ERP (@ ,GLOBAL-VAR) STATE) `(ER-LET* ((X (BRR-DATA-LST STATE))) (MV ERP (REVERSE X) STATE)))) form2)) (form4 `(cond (t ,FORM3)))) `(prog2$ (clear-brr-data-lst) ,FORM4)))
addr^pfunction
(defun addr^p (addr) (declare (xargs :guard t)) (cond ((atom addr) (eq addr nil)) ((eq (car addr) '^) nil) ((posp (car addr)) (if (and (consp (cdr addr)) (eq (cadr addr) '^)) (eq (cddr addr) nil) (addr^p (cdr addr)))) (t nil)))
safe-nthfunction
(defun safe-nth (n x) (declare (xargs :guard t)) (if (natp n) (if (consp x) (if (= n 0) (car x) (safe-nth (- n 1) (cdr x))) nil) (if (consp x) (car x) nil)))
safe-nthcdrfunction
(defun safe-nthcdr (n x) (declare (xargs :guard t)) (if (natp n) (if (consp x) (if (= n 0) x (safe-nthcdr (- n 1) (cdr x))) (if (= n 0) x nil)) x))
terminal-markerfunction
(defun terminal-marker (x) (declare (xargs :guard t)) (if (consp x) (terminal-marker (cdr x)) x))
get-addr^function
(defun get-addr^ (addr x) (declare (xargs :guard (addr^p addr) :measure (acl2-count addr))) (cond ((endp addr) x) (t (let* ((n (- (car addr) 1)) (k (len x)) (up-flg (and (cdr addr) (eq (cadr addr) '^))) (addr1 (if up-flg nil (cdr addr)))) (cond ((< n k) (get-addr^ addr1 (if up-flg (safe-nthcdr n x) (safe-nth n x)))) ((= n k) (get-addr^ addr1 (if up-flg (list '. (terminal-marker x)) '.))) ((= n (+ 1 k)) (get-addr^ addr1 (if up-flg (list (terminal-marker x)) (terminal-marker x)))) (t nil))))))
update-nthcdrfunction
(defun update-nthcdr (n val x) (declare (xargs :guard (and (natp n) (<= n (len x))))) (cond ((zp n) val) (t (cons (car x) (update-nthcdr (- n 1) val (cdr x))))))
put-addr^function
(defun put-addr^ (addr val x) (cond ((endp addr) val) ((and (consp (cdr addr)) (eq (cadr addr) '^)) (cond ((= (car addr) 1) val) (t (let* ((n (- (car addr) 1)) (k (len x))) (cond ((< n k) (update-nthcdr n val x)) ((or (= n k) (= n (+ 1 k))) (update-nthcdr k (if (and (consp val) (eq (car val) '.) (consp (cdr val)) (null (cddr val))) (cadr val) val) x)) (t x)))))) (t (let* ((n (- (car addr) 1)) (k (len x))) (cond ((< n k) (update-nth n (put-addr^ (cdr addr) val (nth n x)) x)) ((and (or (= n k) (= n (+ k 1))) (null (cdr addr))) (update-nthcdr k (if (and (consp val) (eq (car val) '.) (consp (cdr val)) (null (cddr val))) (cadr val) val) x)) (t x))))))
compare-objects1mutual-recursion
(mutual-recursion (defun compare-objects1 (x y raddr ans) (declare (xargs :mode :program)) (cond ((equal x y) ans) ((or (atom x) (atom y)) (cons (list (reverse raddr) x y) ans)) (t (compare-objects1-lst x y 1 raddr ans)))) (defun compare-objects1-lst (x y n raddr ans) (cond ((equal x y) ans) ((consp x) (cond ((consp y) (let ((ans1 (compare-objects1 (car x) (car y) (cons n raddr) ans))) (compare-objects1-lst (cdr x) (cdr y) (+ 1 n) raddr ans1))) (t (cons (list (reverse (cons '^ (cons n raddr))) x (list '. y)) ans)))) ((consp y) (cons (list (reverse (cons '^ (cons n raddr))) (list '. x) y) ans)) (t (cons (list (reverse (cons (+ 1 n) raddr)) x y) ans)))))
make-compare-objects-placeholderfunction
(defun make-compare-objects-placeholder (x) (declare (xargs :guard (or (integerp x) (and (symbolp x) (standard-char-listp (coerce (symbol-name x) 'list)))))) (if (integerp x) (packn (list ':|<s| x '>)) (intern-in-package-of-symbol (string-append "<" (string-append (string-downcase (symbol-name x)) ">")) :keyword)))
compare-objects-loop$1function
(defun compare-objects-loop$1 (lst i ans) (declare (xargs :mode :program)) (cond ((endp lst) ans) (t (let ((name (make-compare-objects-placeholder i))) (compare-objects-loop$1 (cdr lst) (- i 1) (cons (cons name (car lst)) ans))))))
compare-objects-loop$2function
(defun compare-objects-loop$2 (lst obj) (declare (xargs :mode :program)) (cond ((endp lst) obj) (t (let* ((named-triplet (car lst)) (name (car named-triplet)) (addr (cadr named-triplet))) (compare-objects-loop$2 (cdr lst) (put-addr^ addr name obj))))))
compare-objects-loop$3function
(defun compare-objects-loop$3 (lst) (declare (xargs :mode :program)) (cond ((endp lst) t) (t (let ((addri (cadr (car lst))) (xi (caddr (car lst))) (yi (cadddr (car lst)))) (and (if (and (consp xi) (eq (car xi) '.)) (and (consp (cdr xi)) (null (cddr xi))) t) (if (and (consp yi) (eq (car yi) '.)) (and (consp (cdr yi)) (null (cddr yi))) t) (if (or (and (consp xi) (eq (car xi) '.)) (and (consp yi) (eq (car yi) '.))) (and (consp addri) (eq (car (last addri)) '^)) t) (compare-objects-loop$3 (cdr lst)))))))
compare-objects-loop$4function
(defun compare-objects-loop$4 (lst) (declare (xargs :mode :program)) (cond ((endp lst) nil) (t (cons (list (car (car lst)) (cadr (car lst)) (if (and (consp (caddr (car lst))) (eq (car (caddr (car lst))) '.)) (cadr (caddr (car lst))) (caddr (car lst))) (if (and (consp (cadddr (car lst))) (eq (car (cadddr (car lst))) '.)) (cadr (cadddr (car lst))) (cadddr (car lst)))) (compare-objects-loop$4 (cdr lst))))))
compare-objects-loop$5function
(defun compare-objects-loop$5 (flg lst obj) (declare (xargs :mode :program)) (cond ((endp lst) obj) (t (let* ((named-triplet (car lst)) (addri (cadr named-triplet)) (xi-or-yi (if flg (caddr named-triplet) (cadddr named-triplet)))) (compare-objects-loop$5 flg (cdr lst) (put-addr^ addri xi-or-yi obj))))))
compare-objects-loop$6function
(defun compare-objects-loop$6 (lst) (declare (xargs :mode :program)) (cond ((endp lst) nil) (t (cons (list (car (car lst)) (caddr (car lst)) (cadddr (car lst))) (compare-objects-loop$6 (cdr lst))))))
compare-objectsfunction
(defun compare-objects (x y) (declare (xargs :mode :program)) (let* ((triplets (compare-objects1 x y nil nil)) (named-triplets (compare-objects-loop$1 triplets (length triplets) nil)) (common-obj (compare-objects-loop$2 named-triplets x))) (cond ((compare-objects-loop$3 named-triplets) (let* ((named-triplets-without-bogus-dots (compare-objects-loop$4 named-triplets)) (x-prime (compare-objects-loop$5 t named-triplets-without-bogus-dots common-obj)) (y-prime (compare-objects-loop$5 nil named-triplets-without-bogus-dots common-obj))) (cond ((and (equal x-prime x) (equal y-prime y)) (let ((named-doublets (compare-objects-loop$6 named-triplets-without-bogus-dots))) `((:obj ,COMMON-OBJ) (:legend ,NAMED-DOUBLETS)))) (t (er hard 'compare-objects "Compare-objects does not satisfy its intended spec that ~ the original x and y can be obtained from the common ~ object by hitting, with put-addr^, the addr of each name ~ <si> with the simplified replacements, xi and yi, stripped ~ of any bogus dots. Please send this error message ~ (complete with the display below) to the ~ implementors.~%~Y01~%Thanks." (list (list :x x) (list :y y) (list :named-triplets named-triplets) (list :named-triplets-without-bogus-dots named-triplets-without-bogus-dots) (list :x-prime x-prime) (list :y-prime y-prime)) nil))))) (t (er hard 'compare-objects "We thought compare-objects1 never reported a replacement ~ containing a bogus dot unless the replacement was of the form ~ (|.| z) and the associated address ended in ^. Please send this ~ error message (complete with the display below) to the ~ implementors.~%~Y01~%~Y21.~%Thanks." x nil y)))))
get-actual-brr-evisc-tuplefunction
(defun get-actual-brr-evisc-tuple (state) (let ((tuple (f-get-global 'brr-evisc-tuple state))) (cond ((eq tuple :default) (let ((tuple (f-get-global 'term-evisc-tuple state))) (cond ((eq tuple :default) (evisc-tuple 5 7 nil nil)) (t tuple)))) (t tuple))))
keyword-to-lc-string-alistfunction
(defun keyword-to-lc-string-alist (keywords) (cond ((endp keywords) nil) ((keywordp (car keywords)) (cons (cons (car keywords) (string-downcase (symbol-name (car keywords)))) (keyword-to-lc-string-alist (cdr keywords)))) (t (keyword-to-lc-string-alist (cdr keywords)))))
explain-near-miss2function
(defun explain-near-miss2 (pat-cmd pat-term target-term large-cons-count evisc-tuple state) (declare (xargs :mode :program)) (mv-let (ans1 alist1 addr alist subtarget) (one-way-unify-fr pat-term target-term) (cond ((or (null pat-term) (not (or (eq pat-cmd :lhs) (eq pat-cmd :max-term)))) (er soft 'explain-near-miss "Explain-near-miss is meant to be invoked when (brr@ :lemma) is a ~ lemma of rule-class :rewrite, :linear, or :rewrite-quoted-constant ~ and the current value of (brr@ :lemma) is none of these.")) ((not (or (null large-cons-count) (natp large-cons-count))) (er soft 'explain-near-miss "The large-cons-count argument must be nil or a natural, but you ~ supplied ~x0." large-cons-count)) ((not (or (eq evisc-tuple t) (standard-evisc-tuplep evisc-tuple))) (er soft 'explain-near-miss "The evisc-tuple argument must be nil (meaning no evisceration), ~ t (meaning use the brr evisc-tuple), or a standard evisceration ~ 4-tuple. You supplied ~x0." evisc-tuple)) (t (let ((evisc-tuple (cond ((eq evisc-tuple nil) nil) ((eq evisc-tuple t) (get-actual-brr-evisc-tuple state)) (t evisc-tuple)))) (cond (ans1 (mv-let (ans2 alist2) (one-way-unify pat-term target-term) (cond (ans2 (let ((state (fmt-abbrev "Explain-near-miss is meant to be invoked only ~ after the rule's triggering pattern, ~X01, fails ~ to match the target term, ~X21. But these two ~ terms do match, under the substitution ~X31 (here ~ printed as a list of doublets, (var term), rather ~ than a list of pairs (var . term)). The ~ triggering-pattern and target term may be ~ obtained from within a near miss break with the ~ commands ~x4 and :TARGET." `((#\0 . ,PAT-TERM) (#\1 . ,EVISC-TUPLE) (#\2 . ,TARGET-TERM) (#\3 . ,(PAIRLIS$ (STRIP-CARS ALIST2) (PAIRLIS-X2 (STRIP-CDRS ALIST2) NIL))) (#\4 . ,PAT-CMD)) 0 *standard-co* state "~%~%"))) (value :invisible))) (t (prog2$ (er hard 'explain-near-miss "There is a bug in ONE-WAY-UNIFY-FR. It reports ~ that the pattern ~X01 matches the term ~X21 under ~ substitution ~X31, even though ONE-WAY-UNIFY ~ reports that the pattern and term do not match! ~ Please provide the implementors with this ~ information." pat-term nil target-term alist1) (value :invisible)))))) (t (let* ((subpat (fetch-addr addr pat-term)) (instantiated-subpat (sublis-var alist subpat)) (marked-pat (put-addr^ addr (make-compare-objects-placeholder 'pat) pat-term)) (doublet-alist (pairlis$ (strip-cars alist) (pairlis-x2 (strip-cdrs alist) nil))) (two-quotesp (and (quotep instantiated-subpat) (quotep subtarget))) (compare-objectsp (or two-quotesp (and (nvariablep instantiated-subpat) (not (fquotep instantiated-subpat)) (flambdap (ffn-symb instantiated-subpat)) (nvariablep subtarget) (not (fquotep subtarget)) (flambdap (ffn-symb subtarget)) (not (equal (ffn-symb instantiated-subpat) (ffn-symb subtarget)))))) (obj1 (if compare-objectsp (if two-quotesp instantiated-subpat (ffn-symb instantiated-subpat)) nil)) (obj2 (if compare-objectsp (if two-quotesp subtarget (ffn-symb subtarget)) nil)) (largep (if compare-objectsp (or (null large-cons-count) (>= (cons-count-bounded-ac obj1 0 large-cons-count) large-cons-count) (>= (cons-count-bounded-ac obj2 0 large-cons-count) large-cons-count)) nil)) (obj-and-legend (compare-objects obj1 obj2))) (let ((state (fmt-abbrev "~%The ACL2 match algorithm attempted to match ~xe with ~ :TARGET by finding a substitution, s, such that ~xe/s ~ = :TARGET. That attempt failed when trying to match ~ the subterm of ~xe marked <pat> in ~xe' below.~%~%~ ~xe:~_f ~Y01~ ~xe':~_f~Y21~ :TARGET: ~Y31~%~ Below we show the substitution, s, computed prior to ~ the failure; the subterm of ~xe we're calling <pat>; ~ the instantiated subterm, <pat>/s; and the ~ corresponding subterm, <tar>, of :TARGET.~%~%~ s: ~Y61~ <pat>: ~Y51~ <pat>/s: ~Y81~ <tar>: ~Y71~%~ For the rewriter to get past this failure the match ~ algorithm must be able to extend substitution s to s' ~ so that <pat>/s' is equal to <tar> and our match ~ algorithm could not find such an extension.~%~%In case ~ you want to manually explore <pat> and <tar> they may ~ be obtained by executing the following forms in the ~ break caused by this near miss~%~%<pat>: ~Yc1<tar>: ~ ~Yd1~%(Note: The substitution, s, is displayed above ~ as a list of ``doublets'' rather than pairs. I.e., ~ ((var1 term1) ...) instead of ((var1 . term1) ...). ~ If you wish to instantiate <pat> using sublis-var you ~ must convert the doublets to pairs. Finally, be ~ advised that instantiating a term can produce a quoted ~ object, e.g., (sublis-var '((x . '13)) '(cons x x)) is ~ '(13 . 13), not (cons '13 '13).)~%~ ~#9~[~/~%Since <pat>/s and <tar> are ~#a~[quoted ~ objects, those objects~/applications of lambda ~ expressions, those lambda expressions~] must be ~ identical for the match algorithm to succeed. ~ Because they are ``large'' it might be difficult to ~ see where they differ. So we show you below.~%~%Let ~ x be ~#a~[<pat>/s~/the lambda expression being ~ applied in <pat>/s, i.e., (fn-symb <pat/s>)~] and let ~ y be ~#a~[<tar>~/(fn-symb <tar>)~]. Below is the ~ output of (compare-objects x y). The object labeled ~ :OBJ shows the basic structure of x and y with ~ certain substructures replaced by tokens, <si>, ~ i=1,2,.... These <si> mark where x and y differ. The ~ :LEGEND is a list of elements, each of the form (<si> ~ xi yi) meaning ``at <si>, x contains xi but y ~ contains yi.''~%~%~Yb1~]~%See :DOC ~ explain-near-miss~#9~[~/ and :DOC compare-objects~] ~ for details." `((#\0 . ,PAT-TERM) (#\1 . ,(EVISC-TUPLE (CADR EVISC-TUPLE) (CADDR EVISC-TUPLE) (KEYWORD-TO-LC-STRING-ALIST (CONS ':|<pat>| (STRIP-CARS (CADR (ASSOC-EQ :LEGEND OBJ-AND-LEGEND))))) NIL)) (#\2 . ,MARKED-PAT) (#\3 . ,TARGET-TERM) (#\5 . ,SUBPAT) (#\6 . ,DOUBLET-ALIST) (#\7 . ,SUBTARGET) (#\8 . ,INSTANTIATED-SUBPAT) (#\9 . ,(IF (AND COMPARE-OBJECTSP LARGEP) 1 0)) (#\a . ,(IF TWO-QUOTESP 0 1)) (#\b . ,OBJ-AND-LEGEND) (#\c . ,`(FETCH-ADDR ',ADDR (BRR@ ,PAT-CMD))) (#\d . ,`(FETCH-ADDR ',ADDR (BRR@ :TARGET))) (#\e . ,PAT-CMD) (#\f . ,(IF (EQ PAT-CMD :MAX-TERM) 0 5))) 0 *standard-co* state "~%~%"))) (value :invisible))))))))))
explain-near-miss1function
(defun explain-near-miss1 (target-term large-cons-count evisc-tuple state) (declare (xargs :mode :program)) (let* ((pat-cmd (get-brr-local 'brr-cmd-name-for-pattern state)) (pat-term (get-brr-local 'pattern state))) (explain-near-miss2 pat-cmd pat-term target-term large-cons-count evisc-tuple state)))
refinement-failure-brkpt1function
(defun refinement-failure-brkpt1 (lemma target type-alist geneqv ancestors initial-ttree gstack rcnst simplify-clause-pot-lst state) (cond ((not (f-get-global 'gstackp state)) nil) (t (mv-let (rune brr-cmd-name pattern restrictions) (get-brr-one-way-unify-info lemma rcnst) (brr-wormhole '(lambda (whs) (set-wormhole-entry-code whs (let ((temp (assoc-equal (get-rule-field lemma :rune) (access brr-status whs :brr-monitored-runes)))) (if (and temp (cdr (assoc-eq :rf (cdr temp)))) :enter :skip)))) `((brr-gstack . ,GSTACK) (brr-local-alist (rune . ,RUNE) (brr-cmd-name-for-pattern . ,BRR-CMD-NAME) (pattern . ,PATTERN) (restrictions . ,RESTRICTIONS) (lemma . ,LEMMA) (target . ,TARGET) (type-alist . ,TYPE-ALIST) (geneqv . ,GENEQV) (pot-list . ,SIMPLIFY-CLAUSE-POT-LST) (ancestors . ,ANCESTORS) (rcnst . ,RCNST) (initial-ttree . ,INITIAL-TTREE))) '(pprogn (push-brr-status state) (let ((pair (assoc-equal (get-rule-field (get-brr-local 'lemma state) :rune) (access brr-status (f-get-global 'wormhole-status state) :brr-monitored-runes)))) (mv-let (erp okp state) (eval-break-condition (car pair) (cdr (assoc-eq :condition (cdr pair))) 'wormhole state) (cond (erp (pprogn (stuff-standard-oi '(:a!) state) (value t))) (okp (pprogn (cond ((true-listp okp) (stuff-standard-oi okp state)) (t state)) (prog2$ (cw "~%(~F0 Breaking ~F1 on ~X23:~|~%The ~ equivalence relation, ~x4, of this rule is ~ not a refinement of the current geneqv, ~x5. ~ Use :path or :path+ to see how the geneqv ~ evolved. See :DOC refinement-failure for ~ advice about how to deal with this kind of ~ problem.~%~%" (brr-depth state) (get-rule-field (get-brr-local 'lemma state) :rune) (get-brr-local 'target state) (brr-evisc-tuple state) (access rewrite-rule (get-brr-local 'lemma state) :equiv) (show-geneqv (get-brr-local 'geneqv state) 'non-prim)) (value t)))) (t (pprogn (pop-brr-status state) (value nil))))))) *brkpt1-aliases*)))))
near-miss-brkpt1function
(defun near-miss-brkpt1 (lemma target type-alist geneqv ancestors initial-ttree gstack rcnst simplify-clause-pot-lst state) (cond ((not (f-get-global 'gstackp state)) nil) (t (mv-let (rune brr-cmd-name pattern restrictions) (get-brr-one-way-unify-info lemma rcnst) (brr-wormhole '(lambda (whs) (set-wormhole-entry-code whs (let ((pair (assoc-equal (get-rule-field lemma :rune) (access brr-status whs :brr-monitored-runes)))) (cond ((null pair) :skip) ((brr-near-missp nil lemma target rcnst (cdr pair)) :enter) (t :skip))))) `((brr-gstack . ,GSTACK) (brr-local-alist (rune . ,RUNE) (brr-cmd-name-for-pattern . ,BRR-CMD-NAME) (pattern . ,PATTERN) (restrictions . ,RESTRICTIONS) (lemma . ,LEMMA) (target . ,TARGET) (type-alist . ,TYPE-ALIST) (geneqv . ,GENEQV) (pot-list . ,SIMPLIFY-CLAUSE-POT-LST) (ancestors . ,ANCESTORS) (rcnst . ,RCNST) (initial-ttree . ,INITIAL-TTREE))) '(pprogn (push-brr-status state) (let ((pair (assoc-equal (get-rule-field (get-brr-local 'lemma state) :rune) (access brr-status (f-get-global 'wormhole-status state) :brr-monitored-runes)))) (mv-let (erp okp state) (eval-break-condition (car pair) (cdr (assoc-eq :condition (cdr pair))) 'wormhole state) (cond (erp (pprogn (stuff-standard-oi '(:a!) state) (value t))) (okp (pprogn (cond ((true-listp okp) (stuff-standard-oi okp state)) (t state)) (prog2$ (cw "~%(~F0 Breaking ~F1 on ~X23:~|~%The pattern in ~ this rule failed to match the target~#4~[~/ ~ under the restrictions ~x5~]. ~@6" (brr-depth state) (get-rule-field (get-brr-local 'lemma state) :rune) (get-brr-local 'target state) (brr-evisc-tuple state) (if (get-brr-local 'restrictions state) 1 0) (get-brr-local 'restrictions state) (brr-near-missp t (get-brr-local 'lemma state) (get-brr-local 'target state) (get-brr-local 'restrictions state) (cdr (assoc-equal (get-brr-local 'rune state) (access brr-status (f-get-global 'wormhole-status state) :brr-monitored-runes))))) (value t)))) (t (pprogn (pop-brr-status state) (value nil))))))) *brkpt1-aliases*)))))
brkpt1function
(defun brkpt1 (lemma target unify-subst type-alist geneqv ancestors initial-ttree gstack rcnst simplify-clause-pot-lst state) (cond (t (let ((gstackp (f-get-global 'gstackp state))) (cond ((not gstackp) nil) (t (prog2$ (and (eq gstackp :brr-data) (brkpt1-brr-data-entry ancestors gstack rcnst state) (wormhole-eval 'brr-data '(lambda (whs) (set-wormhole-data-fast whs (update-brr-data-1 lemma target unify-subst type-alist geneqv ancestors initial-ttree gstack rcnst simplify-clause-pot-lst (wormhole-data whs)))) (list :no-wormhole-lock lemma target unify-subst type-alist geneqv simplify-clause-pot-lst ancestors rcnst initial-ttree gstack))) (brr-wormhole '(lambda (whs) (set-wormhole-entry-code whs (if (assoc-equal (get-rule-field lemma :rune) (access brr-status whs :brr-monitored-runes)) :enter :skip))) `((brr-gstack . ,GSTACK) (brr-local-alist (lemma . ,LEMMA) (target . ,TARGET) (unify-subst . ,UNIFY-SUBST) (type-alist . ,TYPE-ALIST) (geneqv . ,GENEQV) (pot-list . ,SIMPLIFY-CLAUSE-POT-LST) (ancestors . ,ANCESTORS) (rcnst . ,RCNST) (initial-ttree . ,INITIAL-TTREE))) '(pprogn (push-brr-status state) (let ((pair (assoc-equal (get-rule-field (get-brr-local 'lemma state) :rune) (access brr-status (f-get-global 'wormhole-status state) :brr-monitored-runes)))) (mv-let (erp okp state) (eval-break-condition (car pair) (cdr (assoc-eq :condition (cdr pair))) 'wormhole state) (cond (erp (pprogn (stuff-standard-oi '(:a!) state) (value t))) (okp (pprogn (cond ((true-listp okp) (stuff-standard-oi okp state)) (t state)) (prog2$ (cw "~%(~F0 Breaking ~F1 on ~X23:~|" (brr-depth state) (get-rule-field (get-brr-local 'lemma state) :rune) (get-brr-local 'target state) (brr-evisc-tuple state)) (value t)))) (t (pprogn (pop-brr-status state) (value nil))))))) *brkpt1-aliases*))))))))
brkpt2function
(defun brkpt2 (wonp failure-reason unify-subst gstack brr-result final-ttree rcnst ancestors state) (cond (t (let ((gstackp (f-get-global 'gstackp state))) (cond ((not gstackp) nil) (t (prog2$ (brr-wormhole '(lambda (whs) (set-wormhole-entry-code whs (if (equal gstack (access brr-status whs :brr-gstack)) :enter :skip))) `((brr-gstack . ,GSTACK) (brr-local-alist (wonp . ,WONP) (failure-reason . ,FAILURE-REASON) (unify-subst . ,UNIFY-SUBST) (brr-result . ,BRR-RESULT) (rcnst . ,RCNST) (final-ttree . ,FINAL-TTREE))) '(cond ((eq (get-brr-local 'action state) 'silent) (prog2$ (cw "~F0)~%" (brr-depth state)) (pprogn (pop-brr-status state) (value nil)))) ((eq (get-brr-local 'action state) 'print) (pprogn (put-brr-locals (cdr (assoc-eq 'brr-local-alist (f-get-global 'wormhole-input state))) state) (prog2$ (if (get-brr-local 'wonp state) (cw "~%~F0 ~F1 produced ~X23.~|~F0)~%" (brr-depth state) (get-rule-field (get-brr-local 'lemma state) :rune) (brr-result state) (brr-evisc-tuple state)) (cw "~%~F0x ~F1 failed because ~@2~|~F0)~%" (brr-depth state) (get-rule-field (get-brr-local 'lemma state) :rune) (tilde-@-failure-reason-phrase (get-brr-local 'failure-reason state) 1 (get-brr-local 'unify-subst state) (brr-evisc-tuple state) (free-vars-display-limit state) state))) (pprogn (pop-brr-status state) (value nil))))) (t (pprogn (put-brr-locals (cdr (assoc-eq 'brr-local-alist (f-get-global 'wormhole-input state))) state) (er-progn (set-standard-oi (get-brr-local 'saved-standard-oi state) state) (cond ((consp (f-get-global 'standard-oi state)) (set-ld-pre-eval-print t state)) (t (value nil))) (prog2$ (if (get-brr-local 'wonp state) (cw "~%~F0! ~F1 produced ~X23.~|~%" (brr-depth state) (get-rule-field (get-brr-local 'lemma state) :rune) (brr-result state) (brr-evisc-tuple state)) (cw "~%~F0x ~F1 failed because ~@2~|~%" (brr-depth state) (get-rule-field (get-brr-local 'lemma state) :rune) (tilde-@-failure-reason-phrase (get-brr-local 'failure-reason state) 1 (get-brr-local 'unify-subst state) (brr-evisc-tuple state) (free-vars-display-limit state) state))) (value t)))))) *brkpt2-aliases*) (and (not (eq failure-reason 'near-miss)) (not (eq failure-reason 'refinement-failure)) (eq gstackp :brr-data) (brkpt2-brr-data-entry ancestors gstack rcnst state) (wormhole-eval 'brr-data '(lambda (whs) (set-wormhole-data-fast whs (update-brr-data-2 wonp failure-reason unify-subst gstack brr-result final-ttree rcnst ancestors (wormhole-data whs)))) (list :no-wormhole-lock wonp failure-reason unify-subst gstack brr-result final-ttree rcnst))))))))))
show-brr-data-1function
(defun show-brr-data-1 (x) (declare (xargs :guard (weak-brr-data-1-p x))) (list :target (access brr-data-1 x :target) :unify-subst (alist-to-doublets (access brr-data-1 x :unify-subst)) :type-alist (alist-to-doublets (decode-type-alist (access brr-data-1 x :type-alist))) :lemma (let ((lemma (access brr-data-1 x :lemma))) (and (consp lemma) (access-x-rule-rune (car lemma) lemma))) :gstack (access brr-data-1 x :gstack)))
show-brr-data-2function
(defun show-brr-data-2 (x) (declare (xargs :guard (weak-brr-data-2-p x))) (list* :brr-result (access brr-data-2 x :brr-result) (let ((failure-reason (access brr-data-2 x :failure-reason))) (and failure-reason (list :failure-reason failure-reason)))))
show-brr-datamutual-recursion
(mutual-recursion (defun show-brr-data (x) (declare (xargs :guard (brr-data-p t x))) (and (mbt (brr-data-p t x)) (append (show-brr-data-1 (access brr-data x :pre)) (show-brr-data-2 (access brr-data x :post)) (list :completed (show-brr-data-lst (access brr-data x :completed)))))) (defun show-brr-data-lst (x) (declare (xargs :guard (brr-data-listp t x))) (cond ((endp x) nil) (t (cons (show-brr-data (car x)) (show-brr-data-lst (cdr x)))))))
brr-data-2-for-term-1mutual-recursion
(mutual-recursion (defun brr-data-2-for-term-1 (subterm-p term brr-data) (or (brr-data-2-for-term subterm-p term (access brr-data brr-data :completed)) (let* ((post (access brr-data brr-data :post)) (brr-result (access brr-data-2 post :brr-result))) (and (if subterm-p (dumb-occur term brr-result) (equal term brr-result)) post)))) (defun brr-data-2-for-term (subterm-p term brr-data-lst) (cond ((endp brr-data-lst) nil) (t (or (brr-data-2-for-term-1 subterm-p term (car brr-data-lst)) (brr-data-2-for-term subterm-p term (cdr brr-data-lst)))))))
matching-subtermmutual-recursion
(mutual-recursion (defun matching-subterm (pat term alist target) (mv-let (flg alist2) (one-way-unify1 pat term alist) (declare (ignore alist2)) (cond ((and flg (not (dumb-occur term target))) term) ((or (variablep term) (fquotep term)) nil) (t (matching-subterm-lst pat (fargs term) alist target))))) (defun matching-subterm-lst (pat lst alist target) (cond ((endp lst) nil) (t (or (matching-subterm pat (car lst) alist target) (matching-subterm-lst pat (cdr lst) alist target))))))
cw-gstack-for-term-fn1-1mutual-recursion
(mutual-recursion (defun cw-gstack-for-term-fn1-1 (subterm-p term brr-data alist) (let* ((pre (access brr-data brr-data :pre)) (target (access brr-data-1 pre :target)) (post (access brr-data brr-data :post)) (brr-result (access brr-data-2 post :brr-result)) (subterm (cond ((eq alist :none) (and (not (dumb-occur term target)) (if subterm-p (dumb-occur term brr-result) (equal term brr-result)) term)) (subterm-p (matching-subterm term brr-result alist target)) (t (mv-let (flg alist2) (one-way-unify1 term brr-result alist) (declare (ignore alist2)) (and flg (not (dumb-occur brr-result target)) brr-result)))))) (cond (subterm (let ((d-2 (brr-data-2-for-term subterm-p subterm (access brr-data brr-data :completed)))) (cond ((null d-2) (mv nil post nil)) (t (mv post d-2 nil))))) (t (cw-gstack-for-term-fn1 subterm-p term (access brr-data brr-data :completed) alist))))) (defun cw-gstack-for-term-fn1 (subterm-p term brr-data-lst alist) (cond ((endp brr-data-lst) (mv nil nil nil)) (t (mv-let (earlier-d-2 d-2 rest) (cw-gstack-for-term-fn1-1 subterm-p term (car brr-data-lst) alist) (cond (d-2 (mv earlier-d-2 d-2 (append rest (cdr brr-data-lst)))) (t (cw-gstack-for-term-fn1 subterm-p term (cdr brr-data-lst) alist))))))))
symbol-name-lstfunction
(defun symbol-name-lst (lst) (declare (xargs :guard (symbol-listp lst))) (cond ((endp lst) nil) (t (cons (symbol-name (car lst)) (symbol-name-lst (cdr lst))))))
acl2-query-simulate-interactionfunction
(defun acl2-query-simulate-interaction (msg alist controlledp ans state) (cond ((and (atom ans) (or controlledp (and (not (f-get-global 'window-interfacep state)) (not (eq (standard-co state) *standard-co*))))) (pprogn (fms msg alist (standard-co state) state (ld-evisc-tuple state)) (princ$ ans (standard-co state) state) (newline (standard-co state) state) state)) (t state)))
acl2-query1function
(defun acl2-query1 (id qt alist state) (let ((dv (cdr-assoc-query-id id (ld-query-control-alist state))) (msg "ACL2 Query (~x0): ~@1 (~*2): ") (alist1 (list (cons #\0 id) (cons #\1 (cons (car qt) alist)) (cons #\2 (list "" "~s*" "~s* or " "~s*, " (symbol-name-lst (evens (cdr qt)))))))) (cond ((null dv) (pprogn (io? query nil state (alist1 msg) (fms msg alist1 *standard-co* state (ld-evisc-tuple state))) (er-let* ((ans (read-object *standard-oi* state))) (let ((temp (and (symbolp ans) (assoc-keyword (intern (symbol-name ans) "KEYWORD") (cdr qt))))) (cond (temp (pprogn (acl2-query-simulate-interaction msg alist1 nil ans state) (value (cadr temp)))) (t (acl2-query1 id qt alist state))))))) ((eq dv t) (pprogn (acl2-query-simulate-interaction msg alist1 t (cadr qt) state) (value (caddr qt)))) (t (let ((temp (assoc-keyword (if (consp dv) (car dv) dv) (cdr qt)))) (cond ((null temp) (er soft 'acl2-query "The default response, ~x0, supplied in ~ ld-query-control-alist for the ~x1 query, is not one ~ of the expected responses. The ~x1 query ~ is~%~%~@2~%~%Note the expected responses above. See ~ :DOC ld-query-control-alist." (if (consp dv) (car dv) dv) id (cons msg alist1))) (t (pprogn (acl2-query-simulate-interaction msg alist1 t dv state) (value (cadr temp))))))))))
acl2-queryfunction
(defun acl2-query (id qt alist state) (cond ((atom qt) (value qt)) ((not (and (or (stringp (car qt)) (and (consp (car qt)) (stringp (caar qt)))) (consp (cdr qt)) (keyword-value-listp (cdr qt)))) (er soft 'acl2-query "The object ~x0 is not a query tree! See the comment in ~ acl2-query." qt)) (t (er-let* ((qt1 (acl2-query1 id qt alist state))) (acl2-query id qt1 alist state)))))
brr-data-queryfunction
(defun brr-data-query (id state) (acl2-query id '("Attempt to present another result?" :y t :n nil :? ("reply with y to continue, or with n to quit" :y t :n nil)) nil state))
cw-gstack-for-term-fnfunction
(defun cw-gstack-for-term-fn (id subterm-p multiple tterm brr-data-lst alist state) (cond ((null brr-data-lst) (value (eq multiple :more))) (t (mv-let (earlier-d2 d-2 rest) (cw-gstack-for-term-fn1 subterm-p tterm brr-data-lst alist) (cond (d-2 (progn$ (cw-gstack1 1 nil (reverse (access brr-data-2 d-2 :gstack)) nil) (let ((brr-result (access brr-data-2 d-2 :brr-result)) (earlier-brr-result (and earlier-d2 (access brr-data-2 earlier-d2 :brr-result)))) (cw "The resulting (translated) term is~| ~ ~y0.~|~#1~[~/Note: The first lemma application above ~ that provides a suitable result is at frame ~x2, and ~ ~#3~[it's the same result as above.~/that result ~ is~| ~y4.~]~]~|" brr-result (if earlier-d2 1 0) (and earlier-d2 (length (access brr-data-2 earlier-d2 :gstack))) (if (equal brr-result earlier-brr-result) 0 1) earlier-brr-result)) (cond ((not multiple) (value :quit)) (t (er-let* ((action (if multiple (brr-data-query id state) (value nil)))) (cond ((eq action t) (cw-gstack-for-term-fn id subterm-p :more tterm rest alist state)) (t (value :quit)))))))) (t (assert$ (null rest) (value (eq multiple :more)))))))))
cw-gstack-for-term*-fnfunction
(defun cw-gstack-for-term*-fn (id subterm-p multiple uterm+ brr-data-lst state) (mv-let (vars uterm freep) (case-match uterm+ ((':free vars uterm) (mv vars uterm t)) (& (mv nil uterm+ nil))) (er-let* ((tterm (cond ((and (consp uterm) (eq (car uterm) :free)) (er soft id "An input of the form (:FREE ..) must be of the ~ form (:FREE vars x). The input ~x0 is thus ~ illegal. See :DOC cw-gstack-for-term." uterm)) (t (translate uterm t nil nil id (w state) state)))) (alist (cond ((not (arglistp vars)) (er soft id "The first argument of :FREE must be a list of ~ distinct variables, but ~f0 is not. See :DOC ~ cw-gstack-for-term." vars)) ((not freep) (value :none)) (t (let ((all-vars (all-vars tterm))) (cond ((subsetp-eq vars all-vars) (let ((bound-vars (set-difference-eq all-vars vars))) (value (pairlis$ bound-vars bound-vars)))) (t (er soft id "For a :FREE expression, each specified ~ variable must occur in the specified ~ term. But ~&0 ~#0~[does~/do~] not occur ~ in the term, ~x1. See :DOC ~ cw-gstack-for-term." (set-difference-eq vars all-vars) tterm))))))) (ans (cw-gstack-for-term-fn id subterm-p multiple tterm brr-data-lst alist state))) (prog2$ (cond ((eq ans t) (cw "There are no more results.~|")) ((eq ans nil) (cw "There are no results.~|")) (t nil)) (value :invisible)))))
cw-gstack-for-term*macro
(defmacro cw-gstack-for-term* (uterm+ &key (global-var 'brr-data-lst)) `(cw-gstack-for-term*-fn 'cw-gstack-for-term* nil t ',UTERM+ (@ ,GLOBAL-VAR) state))
cw-gstack-for-subterm*macro
(defmacro cw-gstack-for-subterm* (uterm+ &key (global-var 'brr-data-lst)) `(cw-gstack-for-term*-fn 'cw-gstack-for-subterm* t t ',UTERM+ (@ ,GLOBAL-VAR) state))
cw-gstack-for-termmacro
(defmacro cw-gstack-for-term (uterm+ &key (global-var 'brr-data-lst)) `(cw-gstack-for-term*-fn 'cw-gstack-for-term nil nil ',UTERM+ (@ ,GLOBAL-VAR) state))
cw-gstack-for-subtermmacro
(defmacro cw-gstack-for-subterm (uterm+ &key (global-var 'brr-data-lst)) `(cw-gstack-for-term*-fn 'cw-gstack-for-subterm t nil ',UTERM+ (@ ,GLOBAL-VAR) state))
set-brr-data-lstmacro
(defmacro set-brr-data-lst (global-var &optional (action ':observation)) (declare (xargs :guard (and (member-eq action '(:observation :error :silent)) global-var (symbolp global-var)))) `(er-let* ((x (brr-data-lst state)) (y (cond ((null x) (case ,ACTION (:observation (pprogn (observation nil "There is no brr-data available.") (value nil))) (:error (er soft nil "There is no brr-data available.")) (otherwise (value nil)))) (t (value x))))) (pprogn (f-put-global ',GLOBAL-VAR y state) (case ,ACTION (:observation (observation nil "~x0 = ~x1" '(length (@ ,GLOBAL-VAR)) (len y))) (otherwise state)) (value :invisible))))
binds-to-constants-pfunction
(defun binds-to-constants-p (unify-subst) (cond ((endp unify-subst) t) (t (let ((pair (car unify-subst))) (and (or (eq (car pair) (cdr pair)) (quotep (cdr pair))) (binds-to-constants-p (cdr unify-subst)))))))
expand-permission-result1function
(defun expand-permission-result1 (term expand-lst geneqv wrld) (if expand-lst (let ((x (car expand-lst))) (cond ((eq x :lambdas) (cond ((flambda-applicationp term) (mv (lambda-body (ffn-symb term)) nil (pairlis$ (lambda-formals (ffn-symb term)) (fargs term)) nil nil)) (t (expand-permission-result1 term (cdr expand-lst) geneqv wrld)))) ((not (geneqv-refinementp (access expand-hint x :equiv) geneqv wrld)) (expand-permission-result1 term (cdr expand-lst) geneqv wrld)) (t (let* ((alist (access expand-hint x :alist)) (alist-none-p (eq alist :none)) (alist-constants-p (and (not alist-none-p) (eq (car alist) :constants))) (alist (if alist-constants-p (cdr alist) alist))) (mv-let (flg unify-subst0) (cond (alist-none-p (mv (equal (access expand-hint x :pattern) term) nil)) (t (one-way-unify1 (access expand-hint x :pattern) term alist))) (let ((flg (and flg (if alist-constants-p (binds-to-constants-p unify-subst0) t)))) (cond (flg (mv-let (flg unify-subst) (one-way-unify (access expand-hint x :lhs) term) (cond (flg (mv (access expand-hint x :rhs) (access expand-hint x :hyp) unify-subst (access expand-hint x :rune) (and (or alist-none-p alist-constants-p) (length expand-lst)))) (t (expand-permission-result1 term (cdr expand-lst) geneqv wrld))))) (t (expand-permission-result1 term (cdr expand-lst) geneqv wrld))))))))) (mv nil nil nil nil nil)))
remove1-by-positionfunction
(defun remove1-by-position (target-index lst acc) (declare (xargs :guard (and (true-listp lst) (true-listp acc) (natp target-index) (< target-index (len lst))))) (cond ((zp target-index) (revappend acc (cdr lst))) (t (remove1-by-position (1- target-index) (cdr lst) (cons (car lst) acc)))))
expand-permission-resultfunction
(defun expand-permission-result (term rcnst geneqv wrld) (let ((expand-lst (access rewrite-constant rcnst :expand-lst))) (mv-let (new-term hyp unify-subst rune posn-from-end) (expand-permission-result1 term expand-lst geneqv wrld) (cond (posn-from-end (assert$ new-term (mv new-term hyp unify-subst rune (let ((expand-lst (access rewrite-constant rcnst :expand-lst))) (change rewrite-constant rcnst :expand-lst (remove1-by-position (- (length expand-lst) posn-from-end) expand-lst nil)))))) (t (mv new-term hyp unify-subst rune rcnst))))))
expand-permission-pfunction
(defun expand-permission-p (term rcnst geneqv wrld) (mv-let (new-term hyp unify-subst rune new-rcnst) (expand-permission-result term rcnst geneqv wrld) (declare (ignore hyp unify-subst rune)) (and new-term new-rcnst)))
ev-fncall!function
(defun ev-fncall! (fn args state aok) (declare (xargs :guard (let ((wrld (w state))) (and (symbolp fn) (not (eq fn 'return-last)) (function-symbolp fn wrld) (all-nils (stobjs-in fn wrld)) (equal (stobjs-out fn wrld) '(nil)) (eq (symbol-class fn wrld) :common-lisp-compliant) (mv-let (erp val latches) (ev (guard fn nil wrld) (pairlis$ (formals fn wrld) args) state nil t aok) (assert$ (null latches) (and (null erp) val))))))) (ev-fncall fn args nil state nil nil aok))
ev-fncall-metafunction
(defun ev-fncall-meta (fn args state) (declare (xargs :guard (and (symbolp fn) (function-symbolp fn (w state))))) (let nil (cond ((eq (symbol-class fn (w state)) :common-lisp-compliant) (ev-fncall! fn args state t)) (t (ev-fncall fn args nil state nil nil t)))))
ev-synpfunction
(defun ev-synp (synp-term unify-subst mfc state) (let* ((unify-subst1 (if mfc (cons (cons 'mfc mfc) unify-subst) unify-subst)) (unify-subst2 (if mfc (cons (cons 'state (coerce-state-to-object state)) unify-subst1) unify-subst))) (ev (get-evg synp-term 'ev-synp) unify-subst2 state nil t t)))
bad-synp-alist1function
(defun bad-synp-alist1 (alist unify-subst vars-to-be-bound wrld) (declare (xargs :guard (alistp alist))) (if (null alist) nil (or (let ((key (caar alist)) (value (cdar alist))) (cond ((not (legal-variablep key)) (msg "the key ~x0 is not a legal variable" key)) ((assoc-eq key unify-subst) (msg "the key ~x0 is already bound in the unifying ~ substitution, ~x1" key unify-subst)) ((not (termp value wrld)) (msg "the value ~x0 bound to key ~x1 is not a legal term ~ (translated into ACL2 internal form) in the current ~ ACL2 world" value key)) ((and (not (eq vars-to-be-bound t)) (not (member-eq key vars-to-be-bound))) (msg "the key ~x0 is not a member of the specified list of ~ variables to be bound, ~x1" key vars-to-be-bound)) (t nil))) (bad-synp-alist1 (cdr alist) unify-subst vars-to-be-bound wrld))))
bad-synp-alist1-lstfunction
(defun bad-synp-alist1-lst (alist-lst unify-subst vars-to-be-bound wrld) (cond ((endp alist-lst) nil) (t (or (bad-synp-alist1 (car alist-lst) unify-subst vars-to-be-bound wrld) (bad-synp-alist1-lst (cdr alist-lst) unify-subst vars-to-be-bound wrld)))))
bind-free-infofunction
(defun bind-free-info (x unify-subst vars-to-be-bound wrld) (cond ((and (true-listp x) (alistp (car x))) (or (bad-synp-alist1-lst x unify-subst (get-evg vars-to-be-bound 'bad-synp-alist) wrld) t)) ((alistp x) (bad-synp-alist1 x unify-subst (get-evg vars-to-be-bound 'bad-synp-alist) wrld)) (t "it is not an alist")))
evgs-or-tfunction
(defun evgs-or-t (lst alist) (cond ((endp lst) nil) ((variablep (car lst)) (let ((temp (assoc-eq (car lst) alist))) (if (and temp (quotep (cdr temp))) (let ((rest (evgs-or-t (cdr lst) alist))) (cond ((eq rest t) t) (t (cons (cadr (cdr temp)) rest)))) t))) ((fquotep (car lst)) (let ((rest (evgs-or-t (cdr lst) alist))) (cond ((eq rest t) t) (t (cons (cadr (car lst)) rest))))) (t t)))
search-type-alist+function
(defun search-type-alist+ (term typ type-alist unify-subst ttree wrld) (mv-let (term alt-term) (cond ((or (variablep term) (fquotep term) (not (equivalence-relationp (ffn-symb term) wrld))) (mv term nil)) (t (mv term (fcons-term* (ffn-symb term) (fargn term 2) (fargn term 1))))) (search-type-alist-rec term alt-term typ type-alist unify-subst ttree)))
oncepfunction
(defun oncep (nume-runes match-free rune nume) (if (or (eq nume-runes :clear) (<= (car nume-runes) nume)) (eq match-free :once) (member-equal rune (cdr nume-runes))))
zero-depthpmacro
(defmacro zero-depthp (depth) `(eql (the-fixnum ,DEPTH) 0))
rdepth-errormacro
(defmacro rdepth-error (form &optional preprocess-p) (if preprocess-p (let ((ctx ''preprocess)) `(prog2$ (er-hard ,CTX "Call depth" "The call depth limit of ~x0 has been exceeded in the ACL2 ~ preprocessor (a sort of rewriter). There might be a loop ~ caused by some set of enabled simple rules. To see why ~ the limit was exceeded, ~@1retry the proof with :hints~% ~ :do-not '(preprocess)~%and then follow the directions in ~ the resulting error message. See :DOC rewrite-stack-limit ~ for a possible solution when there is not a loop." (rewrite-stack-limit wrld) (if (f-get-global 'gstackp state) "" "execute~% :brr t~%and next ")) ,FORM)) (let ((ctx ''rewrite)) `(prog2$ (er-hard ,CTX "Call depth" "The call depth limit of ~x0 has been exceeded in the ACL2 ~ rewriter. To see why the limit was exceeded, ~@1execute the ~ form (cw-gstack) or, for less verbose output, instead try ~ (cw-gstack :frames 30). You may then notice a loop caused ~ by some set of enabled rules, some of which you can then ~ disable; see :DOC disable. For a possible solution when ~ there is not a loop, see :DOC rewrite-stack-limit." (rewrite-stack-limit wrld) (if (f-get-global 'gstackp state) "" "first execute~% :brr t~%and then try the proof again, and ~ then ")) ,FORM))))
bad-synp-hyp-msg1function
(defun bad-synp-hyp-msg1 (hyp bound-vars all-vars-bound-p wrld) (if (ffnnamep 'synp hyp) (cond ((not (eq (ffn-symb hyp) 'synp)) (mv (cons "a call of syntaxp or bind-free should occur only ~ at the top level of a hypothesis, but in ~x0 it ~ appears elsewhere but not at the top level." (list (cons #\0 (untranslate hyp t wrld)))) bound-vars all-vars-bound-p)) ((not (all-quoteps (fargs hyp))) (mv (cons "a call of ~x0 in a hypothesis should be made on quoted ~ arguments, but that is not true for the hypothesis, ~x1." (list (cons #\0 'synp) (cons #\1 (untranslate hyp nil wrld)))) bound-vars all-vars-bound-p)) (t (let* ((term-to-be-evaluated (unquote (fargn hyp 3))) (vars (all-vars term-to-be-evaluated)) (saved-term (unquote (fargn hyp 2))) (vars-to-be-bound (unquote (fargn hyp 1)))) (cond ((not (termp term-to-be-evaluated wrld)) (mv (cons "the term to be evaluated by the syntaxp or ~ bind-free hypothesis must be an ACL2 term, but ~ this is not the case in ~x0. The term's internal ~ (translated) form is ~x1." (list (cons #\0 (untranslate hyp nil wrld)) (cons #\1 term-to-be-evaluated))) bound-vars all-vars-bound-p)) ((or (variablep saved-term) (fquotep saved-term) (not (member-eq (ffn-symb saved-term) '(syntaxp bind-free)))) (mv (cons "a synp hyp has been found which does not appear to ~ have come from a syntaxp or bind-free hypothesis: ~ ~x0. This is not, at present, allowed. If we are ~ in error or you believe we have been otherwise too ~ restrictive, please contact the maintainers of ~ ACL2." (list (cons #\0 (untranslate hyp nil wrld)))) bound-vars all-vars-bound-p)) ((and (not (equal vars-to-be-bound nil)) (not (equal vars-to-be-bound t)) (or (collect-non-legal-variableps vars-to-be-bound) all-vars-bound-p (intersectp-eq vars-to-be-bound bound-vars))) (mv (cons "the vars to be bound by a bind-free hypothesis ~ must be either t or a list of variables which ~ are not already bound. This is not the case in ~ ~x0. The vars to be bound are ~x1 and the vars ~ already bound are ~x2." (list (cons #\0 (untranslate hyp t wrld)) (cons #\1 vars-to-be-bound) (cons #\2 (if all-vars-bound-p '<all_variables> (reverse bound-vars))))) bound-vars all-vars-bound-p)) ((and (not all-vars-bound-p) (not (subsetp-eq (set-difference-eq vars '(state mfc)) bound-vars))) (mv (cons "any vars, other than ~x2 and ~x3, used in ~ the term to be evaluated by a ~ syntaxp or bind-free hypothesis must already be ~ bound. This does not appear to be the case ~ in ~x0. The vars already bound are ~x1." (list (cons #\0 (untranslate hyp t wrld)) (cons #\1 (reverse bound-vars)) (cons #\2 'mfc) (cons #\3 'state))) bound-vars all-vars-bound-p)) ((or (member-eq 'state vars) (member-eq 'mfc vars)) (cond ((or (member-eq 'state bound-vars) (member-eq 'mfc bound-vars) all-vars-bound-p) (mv (cons "we do not allow the use of state or mfc ~ in a syntaxp or bind-free hypothesis ~ in a context where either state or ~ mfc is already bound. This restriction ~ is violated in ~x0. The vars already ~ bound are ~x1." (list (cons #\0 (untranslate hyp nil wrld)) (cons #\1 (if all-vars-bound-p '<all_variables> (reverse bound-vars))))) bound-vars all-vars-bound-p)) ((or (not (eq 'state (car vars))) (member-eq 'state (cdr vars)) (not (eq 'mfc (cadr vars))) (member-eq 'mfc (cddr vars)) (and (not all-vars-bound-p) (not (subsetp-eq (cddr vars) bound-vars)))) (mv (cons "if either state or mfc is a member of the ~ vars of the term to be evaluated, we ~ require that both mfc and state be present ~ and that they be the last two args of the ~ term, in that order. We also require that ~ the remaining vars be already bound. This ~ does not appear to be the case in ~x0. The ~ vars already bound are ~x1." (list (cons #\0 (untranslate hyp nil wrld)) (cons #\1 (if all-vars-bound-p '<all_variables> (reverse bound-vars))))) bound-vars all-vars-bound-p)) (t (mv nil (cond ((eq vars-to-be-bound nil) bound-vars) ((eq vars-to-be-bound t) bound-vars) (t (union-eq vars-to-be-bound bound-vars))) (or all-vars-bound-p (equal vars-to-be-bound t)))))) (t (mv nil (cond ((equal vars-to-be-bound nil) bound-vars) ((equal vars-to-be-bound t) bound-vars) (t (union-eq vars-to-be-bound bound-vars))) (or all-vars-bound-p (equal vars-to-be-bound t)))))))) (mv nil (union-eq (all-vars hyp) bound-vars) all-vars-bound-p)))
bad-synp-hyp-msgfunction
(defun bad-synp-hyp-msg (hyps bound-vars all-vars-bound-p wrld) (if (null hyps) nil (mv-let (bad-synp-hyp-msg bound-vars all-vars-bound-p) (bad-synp-hyp-msg1 (car hyps) bound-vars all-vars-bound-p wrld) (or bad-synp-hyp-msg (bad-synp-hyp-msg (cdr hyps) bound-vars all-vars-bound-p wrld)))))
sl-letmacro
(defmacro sl-let (vars form &rest rest) (let ((new-vars (cons 'step-limit vars))) `(mv-let ,NEW-VARS ,FORM (declare (type (signed-byte 61) step-limit)) ,@REST)))
rewrite-entry-extending-failuremacro
(defmacro rewrite-entry-extending-failure (unify-subst failure-reason form &rest args) `(mv-let (step-limitxx relieve-hyps-ansxx failure-reason-lstxx unify-substxx ttreexx allpxx rw-cache-alist-newxx) (rewrite-entry ,FORM ,@ARGS) (mv step-limitxx relieve-hyps-ansxx (and (null relieve-hyps-ansxx) (cons (check-vars-not-free (step-limitxx relieve-hyps-ansxx failure-reason-lstxx unify-substxx ttreexx allpxx rw-cache-alist-newxx) (cons ,UNIFY-SUBST ,FAILURE-REASON)) failure-reason-lstxx)) unify-substxx ttreexx allpxx rw-cache-alist-newxx)))
extend-unify-substfunction
(defun extend-unify-subst (alist unify-subst) (append (pairlis$ (strip-cars alist) (quote-normal-form (strip-cdrs alist))) unify-subst))
relieve-hyp-synpfunction
(defun relieve-hyp-synp (rune hyp0 unify-subst rdepth type-alist wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree bkptr) (let* ((synp-fn (car (get-evg (fargn hyp0 2) 'relieve-hyp))) (mfc (if (member-eq 'state (all-vars (get-evg (fargn hyp0 3) 'relieve-hyp))) (make metafunction-context :rdepth rdepth :type-alist type-alist :obj '? :geneqv nil :wrld wrld :fnstack fnstack :ancestors ancestors :backchain-limit backchain-limit :simplify-clause-pot-lst simplify-clause-pot-lst :rcnst rcnst :gstack (if bkptr (push-gframe 'synp bkptr (if (eq synp-fn 'syntaxp) synp-fn 'bind-free)) gstack) :ttree ttree :unify-subst unify-subst) nil))) (mv-let (erp val latches) (ev-synp (fargn hyp0 3) unify-subst mfc state) (declare (ignore latches)) (cond ((or erp (null val)) (let ((sym (cond ((null mfc) synp-fn) ((eq synp-fn 'syntaxp) 'syntaxp-extended) ((eq synp-fn 'bind-free) 'bind-free-extended) (t synp-fn)))) (mv nil (list sym erp val) unify-subst ttree))) ((eq synp-fn 'syntaxp) (cond ((eq val t) (mv t nil unify-subst (push-lemma (fn-rune-nume 'synp nil nil wrld) ttree))) (t (mv (er hard 'relieve-hyp "The evaluation of the SYNTAXP test in :HYP ~x0 of ~ rule ~x1 produced something other than t or nil, ~ ~x2. This was unexpected and is illegal. Please ~ contact the maintainers of ACL2 with a description ~ of the situation that led to this message." (get-evg (fargn hyp0 1) 'relieve-hyp) rune val) nil unify-subst ttree)))) (t (let ((info (bind-free-info val unify-subst (fargn hyp0 1) wrld))) (cond ((eq info nil) (mv t nil (extend-unify-subst val unify-subst) (push-lemma (fn-rune-nume 'synp nil nil wrld) ttree))) ((eq info t) (mv :unify-subst-list nil val (push-lemma (fn-rune-nume 'synp nil nil wrld) ttree))) (t (mv (er hard 'relieve-hyp "The evaluation of the BIND-FREE form in ~ hypothesis ~p0 of rule ~x1 produced the result ~ ~x2, which is illegal because ~@3." (untranslate hyp0 t wrld) rune val info) nil unify-subst ttree)))))))))
push-lemma+macro
(defmacro push-lemma+ (rune ttree rcnst ancestors rhs rewritten-rhs) `(cond ((and (null ,ANCESTORS) (access rewrite-constant ,RCNST :splitter-output) (ffnnamep-hide 'if ,RHS t) (ffnnamep-hide 'if ,REWRITTEN-RHS t)) (let ((rune ,RUNE) (ttree ,TTREE)) (add-to-tag-tree 'splitter-if-intro rune (push-lemma rune ttree)))) (t (push-lemma ,RUNE ,TTREE))))
push-splitter?macro
(defmacro push-splitter? (rune ttree rcnst ancestors rhs rewritten-rhs) (declare (xargs :guard (symbolp rune))) `(cond ((and ,RUNE (null ,ANCESTORS) (access rewrite-constant ,RCNST :splitter-output) (ffnnamep-hide 'if ,RHS t) (ffnnamep-hide 'if ,REWRITTEN-RHS t)) (add-to-tag-tree 'splitter-if-intro ,RUNE ,TTREE)) (t ,TTREE)))
prepend-step-limitmacro
(defmacro prepend-step-limit (n form) (let ((vars (if (consp n) n (make-var-lst 'x n)))) `(mv-let ,VARS ,FORM (mv step-limit ,@VARS))))
free-failure-pmacro
(defmacro free-failure-p (r) `(eq (car ,R) :rw-cache-alist))
combine-free-failure-reasonsother
(defabbrev combine-free-failure-reasons (r1 r2) (mv-let (flg alist) (combine-free-failure-alists (cdr r1) (cdr r2)) (cond (flg (mv t r2)) (t (mv nil (cons :rw-cache-alist alist))))))
combine-free-failure-alistsfunction
(defun combine-free-failure-alists (a1 a2) (cond ((endp a1) (mv t a2)) (t (let ((pair (assoc-equal (caar a1) a2))) (cond (pair (let ((failure-reason-1 (cdar a1)) (failure-reason-2 (cdr pair))) (mv-let (flg a2) (cond ((not (free-failure-p failure-reason-2)) (mv t a2)) ((not (free-failure-p failure-reason-1)) (mv nil (put-assoc-equal (caar a1) failure-reason-1 a2))) (t (mv-let (flg2 new-reason) (combine-free-failure-reasons failure-reason-1 failure-reason-2) (cond (flg2 (mv t a2)) (t (mv nil (put-assoc-equal (caar a1) new-reason a2))))))) (cond (flg (combine-free-failure-alists (cdr a1) a2)) (t (mv-let (flg alist) (combine-free-failure-alists (cdr a1) a2) (declare (ignore flg)) (mv nil alist))))))) (t (mv-let (flg alist) (combine-free-failure-alists (cdr a1) a2) (declare (ignore flg)) (mv nil (cons (car a1) alist)))))))))
combine-sorted-rw-cache-lists1function
(defun combine-sorted-rw-cache-lists1 (l1 l2) (cond ((endp l1) (mv t l2)) ((endp l2) (mv nil l1)) ((and (equal (access rw-cache-entry (car l1) :unify-subst) (access rw-cache-entry (car l2) :unify-subst)) (equal (access rw-cache-entry (car l1) :hyp-info) (access rw-cache-entry (car l2) :hyp-info))) (mv-let (flg lst) (combine-sorted-rw-cache-lists1 (cdr l1) (cdr l2)) (let ((r1 (access rw-cache-entry (car l1) :failure-reason)) (r2 (access rw-cache-entry (car l2) :failure-reason))) (cond ((and (free-failure-p r1) (free-failure-p r2)) (mv-let (flg2 failure-reason) (combine-free-failure-reasons r1 r2) (cond ((and flg flg2) (mv t l2)) (t (mv nil (cons (change rw-cache-entry (car l2) :failure-reason failure-reason) lst)))))) (flg (mv flg l2)) (t (mv nil (cons (car l2) lst))))))) ((lexorder (car l1) (car l2)) (mv-let (flg lst) (combine-sorted-rw-cache-lists1 (cdr l1) l2) (declare (ignore flg)) (mv nil (cons (car l1) lst)))) (t (mv-let (flg lst) (combine-sorted-rw-cache-lists1 l1 (cdr l2)) (cond (flg (mv t l2)) (t (mv nil (cons (car l2) lst))))))))
split-psorted-list1function
(defun split-psorted-list1 (lst acc) (cond ((endp lst) (mv acc nil)) ((eq (car lst) t) (assert$ (not (member-eq t (cdr lst))) (mv acc (cdr lst)))) (t (split-psorted-list1 (cdr lst) (cons (car lst) acc)))))
split-psorted-listfunction
(defun split-psorted-list (lst) (cond ((member-eq t (cdr lst)) (split-psorted-list1 (cdr lst) (list (car lst)))) (t (mv lst nil))))
merge-lexorder-fastfunction
(defun merge-lexorder-fast (l1 l2) (declare (xargs :guard (and (true-listp l1) (true-listp l2)) :measure (+ (len l1) (len l2)))) (cond ((endp l1) (mv t l2)) ((endp l2) (mv nil l1)) ((lexorder (car l1) (car l2)) (mv-let (flg x) (merge-lexorder-fast (cdr l1) l2) (declare (ignore flg)) (mv nil (cons (car l1) x)))) (t (mv-let (flg x) (merge-lexorder-fast l1 (cdr l2)) (cond (flg (mv t l2)) (t (mv nil (cons (car l2) x))))))))
merge-sort-lexorder-fastfunction
(defun merge-sort-lexorder-fast (l) (declare (xargs :guard (true-listp l) :measure (len l))) (cond ((endp (cdr l)) l) ((endp (cddr l)) (cond ((lexorder (car l) (cadr l)) l) (t (list (cadr l) (car l))))) (t (let* ((n (length l)) (a (ash n -1))) (mv-let (flg x) (merge-lexorder-fast (merge-sort-lexorder-fast (take a l)) (merge-sort-lexorder-fast (nthcdr a l))) (declare (ignore flg)) x)))))
sort-rw-cache-listfunction
(defun sort-rw-cache-list (lst) (cond ((eq (car lst) t) (cdr lst)) ((null (cdr lst)) lst) (t (mv-let (front back) (split-psorted-list lst) (mv-let (flg ans) (combine-sorted-rw-cache-lists1 (merge-sort-lexorder-fast front) back) (declare (ignore flg)) ans)))))
combine-rw-cache-listsfunction
(defun combine-rw-cache-lists (lst1 lst2) (cond ((null lst1) (mv t lst2)) ((null lst2) (mv nil lst1)) ((eq (car lst2) t) (mv-let (flg ans) (combine-sorted-rw-cache-lists1 (sort-rw-cache-list lst1) (cdr lst2)) (cond (flg (mv t lst2)) (t (mv nil (cons t ans)))))) (t (mv nil (cons t (mv-let (flg ans) (combine-sorted-rw-cache-lists1 (sort-rw-cache-list lst1) (sort-rw-cache-list lst2)) (declare (ignore flg)) ans))))))
merge-rw-cachesfunction
(defun merge-rw-caches (alist1 alist2) (cond ((endp alist1) (mv t alist2)) ((endp alist2) (mv nil alist1)) ((eq (caar alist1) (caar alist2)) (mv-let (flg rest) (merge-rw-caches (cdr alist1) (cdr alist2)) (mv-let (flg2 objs) (combine-rw-cache-lists (cdar alist1) (cdar alist2)) (cond ((and flg flg2) (mv t alist2)) (flg2 (mv nil (cons (car alist2) rest))) (t (mv nil (acons (caar alist2) objs rest))))))) ((symbol< (caar alist1) (caar alist2)) (mv-let (flg rest) (merge-rw-caches (cdr alist1) alist2) (declare (ignore flg)) (mv nil (cons (car alist1) rest)))) (t (mv-let (flg rest) (merge-rw-caches alist1 (cdr alist2)) (cond (flg (mv t alist2)) (t (mv nil (cons (car alist2) rest))))))))
sorted-rw-cache-pmacro
(defmacro sorted-rw-cache-p (cache) `(eq (car ,CACHE) t))
cdr-sort-rw-cachefunction
(defun cdr-sort-rw-cache (cache) (assert$ cache (cond ((sorted-rw-cache-p cache) (cdr cache)) (t (mv-let (front back) (split-psorted-list cache) (mv-let (flg ans) (merge-rw-caches (merge-sort-symbol-alistp front) back) (declare (ignore flg)) ans))))))
combine-rw-cachesfunction
(defun combine-rw-caches (c1 c2) (cond ((null c1) (mv t c2)) ((null c2) (mv nil c1)) (t (mv-let (flg x) (merge-rw-caches (cdr-sort-rw-cache c1) (cdr-sort-rw-cache c2)) (cond ((and flg (sorted-rw-cache-p c2)) (mv t c2)) (t (mv nil (cons t x))))))))
unify-subst-subsetpfunction
(defun unify-subst-subsetp (a1 a2) (cond ((endp a1) t) ((endp a2) nil) ((eq (caar a1) (caar a2)) (and (equal (cdar a1) (cdar a2)) (unify-subst-subsetp (cdr a1) (cdr a2)))) (t (unify-subst-subsetp a1 (cdr a2)))))
rw-cache-list-lookupfunction
(defun rw-cache-list-lookup (unify-subst hyps recs) (cond ((endp recs) nil) ((eq (car recs) t) (rw-cache-list-lookup unify-subst hyps (cdr recs))) ((let* ((rec (car recs)) (failure-reason (access rw-cache-entry rec :failure-reason)) (hyp-info (access rw-cache-entry rec :hyp-info))) (and (cond ((free-failure-p failure-reason) (and (equal hyps hyp-info) (equal (access rw-cache-entry rec :unify-subst) unify-subst))) (t (and (equal hyp-info (nth (1- (car failure-reason)) hyps)) (unify-subst-subsetp (access rw-cache-entry rec :unify-subst) unify-subst)))) rec))) (t (rw-cache-list-lookup unify-subst hyps (cdr recs)))))
relieve-hyp-failure-entry-skip-p-builtinfunction
(defun relieve-hyp-failure-entry-skip-p-builtin (rune unify-subst hyps ttree step-limit) (declare (ignore rune unify-subst hyps ttree step-limit) (xargs :mode :logic :guard t)) nil)
other
(defattach (relieve-hyp-failure-entry-skip-p relieve-hyp-failure-entry-skip-p-builtin))
rw-cache-active-pmacro
(defmacro rw-cache-active-p (rcnst) `(member-eq (access rewrite-constant ,RCNST :rw-cache-state) '(t :atom)))
assoc-rw-cachefunction
(defun assoc-rw-cache (key alist) (cond ((endp alist) nil) ((eq (car alist) t) (assoc-eq key (cdr alist))) ((eql key (caar alist)) (car alist)) (t (assoc-rw-cache key (cdr alist)))))
put-assoc-rw-cache1function
(defun put-assoc-rw-cache1 (key val alist) (cond ((atom alist) (list (cons key val))) ((eq (car alist) t) (cons (car alist) (put-assoc-eq key val (cdr alist)))) ((eq key (caar alist)) (cons (cons key val) (cdr alist))) (t (cons (car alist) (put-assoc-rw-cache1 key val (cdr alist))))))
put-assoc-rw-cachefunction
(defun put-assoc-rw-cache (key val alist) (cond ((assoc-rw-cache key alist) (put-assoc-rw-cache1 key val alist)) (t (acons key val alist))))
relieve-hyp-failure-entryfunction
(defun relieve-hyp-failure-entry (rune unify-subst hyps ttree step-limit) (let* ((cache (tagged-objects 'rw-cache-any-tag ttree)) (entry (and cache (rw-cache-list-lookup unify-subst hyps (cdr (assoc-rw-cache (base-symbol rune) cache)))))) (cond ((null entry) nil) ((relieve-hyp-failure-entry-skip-p rune unify-subst hyps ttree step-limit) nil) (t entry))))
maybe-extend-tag-treefunction
(defun maybe-extend-tag-tree (tag vals ttree) (cond ((null vals) ttree) (t (extend-tag-tree tag vals ttree))))
accumulate-rw-cache1function
(defun accumulate-rw-cache1 (replace-p tag new-ttree old-ttree) (let ((new-vals (tagged-objects tag new-ttree)) (old-vals (tagged-objects tag old-ttree))) (cond ((and replace-p (equal new-vals old-vals)) nil) (old-vals (cond (replace-p (assert$ new-vals (extend-tag-tree tag new-vals (remove-tag-from-tag-tree! tag old-ttree)))) (t (mv-let (flg objs) (combine-rw-caches new-vals old-vals) (assert$ objs (cond (flg old-ttree) (t (extend-tag-tree tag objs (remove-tag-from-tag-tree! tag old-ttree))))))))) (new-vals (extend-tag-tree tag new-vals old-ttree)) (t nil))))
accumulate-rw-cachefunction
(defun accumulate-rw-cache (replace-p new-ttree old-ttree) (let ((ttree1 (or (accumulate-rw-cache1 replace-p 'rw-cache-nil-tag new-ttree old-ttree) old-ttree))) (or (accumulate-rw-cache1 replace-p 'rw-cache-any-tag new-ttree ttree1) ttree1)))
accumulate-rw-cache?function
(defun accumulate-rw-cache? (replace-p new-ttree old-ttree) (let* ((ttree1-or-nil (accumulate-rw-cache1 replace-p 'rw-cache-nil-tag new-ttree old-ttree)) (ttree1 (or ttree1-or-nil old-ttree)) (ttree2-or-nil (accumulate-rw-cache1 replace-p 'rw-cache-any-tag new-ttree ttree1))) (or ttree2-or-nil ttree1-or-nil)))
restrict-alist-to-all-vars1function
(defun restrict-alist-to-all-vars1 (alist term) (declare (xargs :guard (and (symbol-alistp alist) (pseudo-termp term)))) (cond ((endp alist) (mv nil nil)) (t (mv-let (changedp rest) (restrict-alist-to-all-vars1 (cdr alist) term) (cond ((dumb-occur-var (caar alist) term) (cond (changedp (mv t (cons (car alist) rest))) (t (mv nil alist)))) (t (mv t rest)))))))
all-vars-boundpmutual-recursion
(mutual-recursion (defun all-vars-boundp (term alist) (declare (xargs :guard (and (pseudo-termp term) (symbol-alistp alist)))) (cond ((variablep term) (assoc-eq term alist)) ((fquotep term) t) (t (all-vars-lst-boundp (fargs term) alist)))) (defun all-vars-lst-boundp (lst alist) (declare (xargs :guard (and (pseudo-term-listp lst) (symbol-alistp alist)))) (cond ((endp lst) t) (t (and (all-vars-boundp (car lst) alist) (all-vars-lst-boundp (cdr lst) alist))))))
restrict-alist-to-all-varsfunction
(defun restrict-alist-to-all-vars (alist term) (cond ((all-vars-boundp term alist) (mv-let (changedp result) (restrict-alist-to-all-vars1 alist term) (declare (ignore changedp)) result)) (t alist)))
push-rw-cache-entryfunction
(defun push-rw-cache-entry (entry tag rune ttree) (let* ((cache (tagged-objects tag ttree)) (base (base-symbol rune)) (recs (and cache (cdr (assoc-rw-cache base cache))))) (cond ((null cache) (extend-tag-tree tag (list (cons base (list entry))) ttree)) (t (extend-tag-tree tag (put-assoc-rw-cache base (cons entry recs) cache) (remove-tag-from-tag-tree tag ttree))))))
other
(defstub rw-cache-debug-action (rune target unify-subst relieve-hyp-failure-reason step-limit) t)
rw-cache-debug-builtinfunction
(defun rw-cache-debug-builtin (rune target unify-subst failure-reason step-limit) (declare (ignore rune target unify-subst failure-reason step-limit) (xargs :guard t)) nil)
rw-cache-debug-action-builtinfunction
(defun rw-cache-debug-action-builtin (rune target unify-subst failure-reason step-limit) (declare (xargs :guard t)) (cw "@@ rw-cache-debug:~|~x0~|" (list :step-limit step-limit :rune rune :target target :unify-subst unify-subst :relieve-hyp-failure-reason failure-reason)))
encapsulate
(encapsulate (((rw-cacheable-failure-reason *) => * :formals (failure-reason) :guard (and (consp failure-reason) (posp (car failure-reason))))) (logic) (local (defun rw-cacheable-failure-reason (failure-reason) failure-reason)))
rw-cacheable-failure-reason-builtinfunction
(defun rw-cacheable-failure-reason-builtin (failure-reason) (declare (xargs :guard (and (consp failure-reason) (posp (car failure-reason))))) (and (consp (cdr failure-reason)) (member-eq (cadr failure-reason) '(rewrote-to syntaxp bind-free))))
other
(defattach (rw-cacheable-failure-reason rw-cacheable-failure-reason-builtin) :skip-checks t)
rw-cacheable-nil-tagfunction
(defun rw-cacheable-nil-tag (failure-reason) (and (consp (cdr failure-reason)) (cond ((eq (cadr failure-reason) 'rewrote-to) (equal (cddr failure-reason) *nil*)) (t (assert$ (member-eq (cadr failure-reason) '(syntaxp bind-free)) t)))))
note-relieve-hyp-failurefunction
(defun note-relieve-hyp-failure (rune unify-subst failure-reason ttree hyps step-limit) (cond ((and failure-reason (rw-cacheable-failure-reason failure-reason)) (let* ((hyp (nth (1- (car failure-reason)) hyps)) (entry (make rw-cache-entry :unify-subst (restrict-alist-to-all-vars unify-subst (cond ((ffn-symb-p hyp 'synp) (let ((qterm (fargn hyp 3))) (cond ((quotep qterm) (unquote qterm)) (t hyp)))) (t hyp))) :failure-reason failure-reason :hyp-info hyp :step-limit step-limit)) (ttree (cond ((rw-cacheable-nil-tag failure-reason) (push-rw-cache-entry entry 'rw-cache-nil-tag rune ttree)) (t ttree)))) (push-rw-cache-entry entry 'rw-cache-any-tag rune ttree))) (t ttree)))
replace-free-rw-cache-entry1function
(defun replace-free-rw-cache-entry1 (unify-subst hyps entry recs) (cond ((endp recs) (list entry)) ((and (not (eq (car recs) t)) (free-failure-p (access rw-cache-entry (car recs) :failure-reason)) (equal unify-subst (access rw-cache-entry (car recs) :unify-subst)) (equal hyps (access rw-cache-entry (car recs) :hyp-info))) (cons entry (cdr recs))) (t (cons (car recs) (replace-free-rw-cache-entry1 unify-subst hyps entry (cdr recs))))))
replace-free-rw-cache-entryfunction
(defun replace-free-rw-cache-entry (entry tag rune unify-subst hyps ttree) (let* ((cache (tagged-objects tag ttree)) (base (base-symbol rune)) (recs (cdr (assoc-rw-cache base cache)))) (extend-tag-tree tag (put-assoc-rw-cache base (replace-free-rw-cache-entry1 unify-subst hyps entry recs) cache) (remove-tag-from-tag-tree tag ttree))))
rw-cache-alist-nil-tag-pfunction
(defun rw-cache-alist-nil-tag-p (alist) (cond ((endp alist) nil) (t (or (let ((failure-reason (cdar alist))) (cond ((free-failure-p failure-reason) (rw-cache-alist-nil-tag-p (cdr failure-reason))) (t (rw-cacheable-nil-tag failure-reason)))) (rw-cache-alist-nil-tag-p (cdr alist))))))
merge-free-failure-reasons-nil-tagother
(defabbrev merge-free-failure-reasons-nil-tag (r1 r2) (mv-let (flg alist) (merge-free-failure-alists-nil-tag (cdr r1) (cdr r2)) (cond (flg (mv t r2)) (t (assert$ alist (mv nil (cons :rw-cache-alist alist)))))))
merge-free-failure-alists-nil-tagfunction
(defun merge-free-failure-alists-nil-tag (a1 a2) (cond ((endp a1) (mv t a2)) (t (let* ((failure-reason (cdar a1)) (free-p (free-failure-p failure-reason))) (cond ((and (not free-p) (not (rw-cacheable-nil-tag failure-reason))) (merge-free-failure-alists-nil-tag (cdr a1) a2)) (t (mv-let (flg a2) (let ((pair (assoc-equal (caar a1) a2))) (cond ((and pair (not (free-failure-p (cdr pair)))) (mv t a2)) ((not free-p) (mv nil (cond (pair (put-assoc-equal (caar a1) failure-reason a2)) (t (acons (caar a1) failure-reason a2))))) (t (mv-let (flg2 sub-reason) (merge-free-failure-reasons-nil-tag failure-reason (cdr pair)) (cond (flg2 (mv t a2)) (pair (mv nil (put-assoc-equal (caar a1) sub-reason a2))) (t (mv nil (acons (caar a1) sub-reason a2)))))))) (cond (flg (merge-free-failure-alists-nil-tag (cdr a1) a2)) (t (mv-let (flg alist) (merge-free-failure-alists-nil-tag (cdr a1) a2) (declare (ignore flg)) (mv nil alist)))))))))))
note-rw-cache-free-nil-tagfunction
(defun note-rw-cache-free-nil-tag (rune unify-subst hyps ttree new-rw-cache-alist step-limit) (cond ((rw-cache-alist-nil-tag-p new-rw-cache-alist) (let* ((cache (tagged-objects 'rw-cache-nil-tag ttree)) (base (base-symbol rune)) (recs (and cache (cdr (assoc-rw-cache base cache)))) (entry (rw-cache-list-lookup unify-subst hyps recs)) (failure-reason (and entry (access rw-cache-entry entry :failure-reason)))) (cond ((and entry (not (free-failure-p failure-reason))) ttree) (t (mv-let (flg alist) (merge-free-failure-alists-nil-tag new-rw-cache-alist (cdr failure-reason)) (cond (flg ttree) (entry (replace-free-rw-cache-entry (change rw-cache-entry entry :failure-reason (cons :rw-cache-alist alist)) 'rw-cache-nil-tag rune unify-subst hyps ttree)) (t (let ((new-entry (make rw-cache-entry :unify-subst unify-subst :failure-reason (cons :rw-cache-alist alist) :hyp-info hyps :step-limit step-limit))) (cond ((null cache) (extend-tag-tree 'rw-cache-nil-tag (list (cons base (list new-entry))) ttree)) ((null recs) (extend-tag-tree 'rw-cache-nil-tag (acons base (cons new-entry nil) cache) (remove-tag-from-tag-tree 'rw-cache-nil-tag ttree))) (t (push-rw-cache-entry new-entry 'rw-cache-nil-tag rune ttree))))))))))) (t ttree)))
note-relieve-hyps-failure-freefunction
(defun note-relieve-hyps-failure-free (rune unify-subst hyps ttree old-entry old-rw-cache-alist new-rw-cache-alist step-limit) (assert$ new-rw-cache-alist (mv-let (flg alist) (cond (old-rw-cache-alist (combine-free-failure-alists new-rw-cache-alist old-rw-cache-alist)) (t (mv nil new-rw-cache-alist))) (cond (flg ttree) (t (let ((ttree (note-rw-cache-free-nil-tag rune unify-subst hyps ttree new-rw-cache-alist step-limit))) (cond (old-entry (replace-free-rw-cache-entry (change rw-cache-entry old-entry :failure-reason (cons :rw-cache-alist alist)) 'rw-cache-any-tag rune unify-subst hyps ttree)) (t (push-rw-cache-entry (make rw-cache-entry :unify-subst unify-subst :failure-reason (cons :rw-cache-alist alist) :hyp-info hyps :step-limit step-limit) 'rw-cache-any-tag rune ttree)))))))))
rw-cache-enter-contextfunction
(defun rw-cache-enter-context (ttree) (maybe-extend-tag-tree 'rw-cache-any-tag (tagged-objects 'rw-cache-nil-tag ttree) (remove-tag-from-tag-tree 'rw-cache-any-tag ttree)))
erase-rw-cachefunction
(defun erase-rw-cache (ttree) (remove-tag-from-tag-tree 'rw-cache-nil-tag (remove-tag-from-tag-tree 'rw-cache-any-tag ttree)))
rw-cache-exit-contextfunction
(defun rw-cache-exit-context (old-ttree new-ttree) (mv-let (flg new-any) (combine-rw-caches (tagged-objects 'rw-cache-any-tag new-ttree) (tagged-objects 'rw-cache-any-tag old-ttree)) (declare (ignore flg)) (maybe-extend-tag-tree 'rw-cache-any-tag new-any (maybe-extend-tag-tree 'rw-cache-nil-tag (tagged-objects 'rw-cache-nil-tag old-ttree) (erase-rw-cache new-ttree)))))
restore-rw-cache-any-tagfunction
(defun restore-rw-cache-any-tag (new-ttree old-ttree) (maybe-extend-tag-tree 'rw-cache-any-tag (tagged-objects 'rw-cache-any-tag old-ttree) (maybe-extend-tag-tree 'rw-cache-nil-tag (tagged-objects 'rw-cache-nil-tag old-ttree) (erase-rw-cache new-ttree))))
cons-tag-trees-rw-cachefunction
(defun cons-tag-trees-rw-cache (ttree1 ttree2) (let ((rw-cache-any1 (tagged-objects 'rw-cache-any-tag ttree1)) (rw-cache-any2 (tagged-objects 'rw-cache-any-tag ttree2)) (rw-cache-nil1 (tagged-objects 'rw-cache-nil-tag ttree1)) (rw-cache-nil2 (tagged-objects 'rw-cache-nil-tag ttree2))) (cond ((and rw-cache-any1 rw-cache-any2) (mv-let (flg-any cache-any) (combine-rw-caches rw-cache-any1 rw-cache-any2) (declare (ignore flg-any)) (cond ((and rw-cache-nil1 rw-cache-nil2) (mv-let (flg-nil cache-nil) (combine-rw-caches rw-cache-nil1 rw-cache-nil2) (declare (ignore flg-nil)) (extend-tag-tree 'rw-cache-any-tag cache-any (extend-tag-tree 'rw-cache-nil-tag cache-nil (cons-tag-trees (erase-rw-cache ttree1) (erase-rw-cache ttree2)))))) (t (extend-tag-tree 'rw-cache-any-tag cache-any (cons-tag-trees (remove-tag-from-tag-tree 'rw-cache-any-tag ttree1) (remove-tag-from-tag-tree 'rw-cache-any-tag ttree2))))))) ((and rw-cache-nil1 rw-cache-nil2) (mv-let (flg-nil cache-nil) (combine-rw-caches rw-cache-nil1 rw-cache-nil2) (declare (ignore flg-nil)) (extend-tag-tree 'rw-cache-nil-tag cache-nil (cons-tag-trees (remove-tag-from-tag-tree 'rw-cache-nil-tag ttree1) (remove-tag-from-tag-tree 'rw-cache-nil-tag ttree2))))) (t (cons-tag-trees ttree1 ttree2)))))
normalize-rw-any-cachefunction
(defun normalize-rw-any-cache (ttree) (let ((cache (tagged-objects 'rw-cache-any-tag ttree))) (cond ((or (null cache) (sorted-rw-cache-p cache)) ttree) (t (extend-tag-tree 'rw-cache-any-tag (cons t (cdr-sort-rw-cache cache)) (remove-tag-from-tag-tree 'rw-cache-any-tag ttree))))))
cons-tag-trees-rw-cache-firstfunction
(defun cons-tag-trees-rw-cache-first (ttree1 ttree2) (maybe-extend-tag-tree 'rw-cache-any-tag (tagged-objects 'rw-cache-any-tag ttree1) (maybe-extend-tag-tree 'rw-cache-nil-tag (tagged-objects 'rw-cache-nil-tag ttree1) (cons-tag-trees (erase-rw-cache ttree1) (erase-rw-cache ttree2)))))
tag-tree-tags-subsetpmacro
(defmacro tag-tree-tags-subsetp (ttree tags) `(alist-keys-subsetp ,TTREE ,TAGS))
rw-cachefunction
(defun rw-cache (ttree) (cond ((tag-tree-tags-subsetp ttree '(rw-cache-nil-tag rw-cache-any-tag)) ttree) (t (maybe-extend-tag-tree 'rw-cache-any-tag (tagged-objects 'rw-cache-any-tag ttree) (maybe-extend-tag-tree 'rw-cache-nil-tag (tagged-objects 'rw-cache-nil-tag ttree) nil)))))
rw-cached-failure-pairfunction
(defun rw-cached-failure-pair (unify-subst rw-cache-alist) (let* ((cached-failure-reason-raw (and rw-cache-alist (cdr (assoc-equal unify-subst rw-cache-alist)))) (cached-failure-reason-free-p (and (consp cached-failure-reason-raw) (free-failure-p cached-failure-reason-raw)))) (mv (and cached-failure-reason-free-p cached-failure-reason-raw) (and (not cached-failure-reason-free-p) cached-failure-reason-raw))))
extend-rw-cache-alist-freefunction
(defun extend-rw-cache-alist-free (rcnst new-unify-subst inferior-rw-cache-alist-new rw-cache-alist-new) (cond ((and inferior-rw-cache-alist-new (rw-cache-active-p rcnst)) (put-assoc-equal new-unify-subst (cons :rw-cache-alist inferior-rw-cache-alist-new) rw-cache-alist-new)) (t rw-cache-alist-new)))
rw-cache-add-failure-reasonfunction
(defun rw-cache-add-failure-reason (rcnst new-unify-subst failure-reason rw-cache-alist-new) (cond ((and (rw-cache-active-p rcnst) failure-reason (rw-cacheable-failure-reason failure-reason)) (acons new-unify-subst failure-reason rw-cache-alist-new)) (t rw-cache-alist-new)))
add-linear-lemma-finishfunction
(defun add-linear-lemma-finish (concl force-flg rune rewritten-p term type-alist wrld state simplify-clause-pot-lst rcnst ttree) (let ((lst (linearize concl t type-alist (access rewrite-constant rcnst :current-enabled-structure) force-flg wrld (push-lemma rune ttree) state))) (cond ((and (null lst) rewritten-p) (mv nil :null-lst 'irrelevant 'irrelevant)) ((cdr lst) (mv nil simplify-clause-pot-lst (if rewritten-p 'linearize-rewritten-produced-disjunction 'linearize-unrewritten-produced-disjunction) nil)) ((null lst) (mv nil simplify-clause-pot-lst nil nil)) ((new-and-ugly-linear-varsp (car lst) (<= *max-linear-pot-loop-stopper-value* (loop-stopper-value-of-var term simplify-clause-pot-lst)) term) (mv nil simplify-clause-pot-lst 'linear-possible-loop nil)) (t (mv-let (contradictionp new-pot-lst) (add-polys (car lst) simplify-clause-pot-lst (access rewrite-constant rcnst :pt) (access rewrite-constant rcnst :nonlinearp) type-alist (access rewrite-constant rcnst :current-enabled-structure) force-flg wrld) (cond (contradictionp (mv contradictionp nil nil (car lst))) (t (mv nil (set-loop-stopper-values (new-vars-in-pot-lst new-pot-lst simplify-clause-pot-lst nil) new-pot-lst term (loop-stopper-value-of-var term simplify-clause-pot-lst)) nil (car lst)))))))))
make-stack-from-alistfunction
(defun make-stack-from-alist (term alist) (if alist (let* ((vars-of-term (all-vars term)) (formals (strip-cars alist)) (actuals (strip-cdrs alist)) (free (set-difference-eq vars-of-term formals))) (list (cons (append free formals) (append free actuals)))) nil))
lambda-nest-hidepfunction
(defun lambda-nest-hidep (term) (and (lambda-applicationp term) (let ((body (lambda-body (ffn-symb term)))) (cond ((variablep body) nil) ((fquotep body) nil) ((eq (ffn-symb body) 'hide) t) (t (lambda-nest-hidep body))))))
lambda-nest-unhidefunction
(defun lambda-nest-unhide (term) (if (lambda-applicationp term) (make-lambda-application (lambda-formals (ffn-symb term)) (lambda-nest-unhide (lambda-body (ffn-symb term))) (fargs term)) (fargn term 1)))
memo-activepother
(defabbrev memo-activep (memo) (or (eq memo :start) (consp memo)))
activate-memoother
(defabbrev activate-memo (memo) (if (eq memo t) :start memo))
intersection1-eqfunction
(defun intersection1-eq (x y) (declare (xargs :guard (and (true-listp x) (true-listp y) (or (symbol-listp x) (symbol-listp y))))) (cond ((endp x) nil) ((member-eq (car x) y) (car x)) (t (intersection1-eq (cdr x) y))))
forbidden-fns-in-termfunction
(defun forbidden-fns-in-term (term forbidden-fns) (intersection-eq (all-fnnames term) forbidden-fns))
forbidden-fns-in-term-listfunction
(defun forbidden-fns-in-term-list (lst forbidden-fns) (intersection-eq (all-fnnames-lst lst) forbidden-fns))
all-fnnames-lst-lst1function
(defun all-fnnames-lst-lst1 (cl-lst acc) (cond ((endp cl-lst) acc) (t (all-fnnames-lst-lst1 (cdr cl-lst) (all-fnnames1 t (car cl-lst) acc)))))
forbidden-fns-in-term-list-listfunction
(defun forbidden-fns-in-term-list-list (cl-lst forbidden-fns) (intersection-eq (all-fnnames-lst-lst1 cl-lst nil) forbidden-fns))
forbidden-fnsfunction
(defun forbidden-fns (wrld state) (let* ((forbidden-fns0 (cond ((eq (f-get-global 'temp-touchable-fns state) t) nil) ((f-get-global 'temp-touchable-fns state) (set-difference-eq (global-val 'untouchable-fns wrld) (f-get-global 'temp-touchable-fns state))) (t (global-val 'untouchable-fns wrld))))) (reverse-strip-cars (and (not (ttag wrld)) *ttag-fns*) forbidden-fns0)))
other
(set-table-guard skip-meta-termp-checks-table (and (or (null val) (ttag world)) (eq key t) (or (eq val t) (symbol-listp val))) :topic set-skip-meta-termp-checks :coda (and val (not (ttag world)) (msg "An active trust tag is required for setting ~ ~x0 except when clearing it." 'skip-meta-termp-checks-table)))
set-skip-meta-termp-checks!macro
(defmacro set-skip-meta-termp-checks! (x) (declare (xargs :guard (or (booleanp x) (symbol-listp x)))) `(table skip-meta-termp-checks-table t ',X))
set-skip-meta-termp-checksmacro
(defmacro set-skip-meta-termp-checks (x) `(local (set-skip-meta-termp-checks! ,X)))
skip-meta-termp-checksfunction
(defun skip-meta-termp-checks (fn wrld) (let ((val (cdr (assoc-eq t (table-alist 'skip-meta-termp-checks-table wrld))))) (or (eq val t) (and val (member-eq fn val)))))
collect-bad-fn-arity-infofunction
(defun collect-bad-fn-arity-info (alist wrld bad-arity-alist non-logic-fns) (cond ((endp alist) (if (or bad-arity-alist non-logic-fns) (cons (reverse bad-arity-alist) non-logic-fns) nil)) (t (let ((arity (arity (car (car alist)) wrld))) (collect-bad-fn-arity-info (cdr alist) wrld (if (or (null arity) (eql arity (cdr (car alist)))) bad-arity-alist (cons (car alist) bad-arity-alist)) (if (or (null arity) (programp (car (car alist)) wrld)) (cons (car (car alist)) non-logic-fns) non-logic-fns))))))
bad-arities-msgfunction
(defun bad-arities-msg (name token fn hyp-fn wf-thm-name1 wf-thm-name2 bad-arity-info) (msg "The ~s0 ~x1 has a now-invalid well-formedness guarantee. Its ~s2, ~x3, ~ ~#4~[was proved in ~x7 to return a ~x6~/and its corresponding hypothesis ~ metafunction, ~x5, were proved in ~x7 and ~x8 to return ~x6s~] under the ~ assumption that certain function symbols were in :logic mode and had ~ certain arities. But that assumption is now invalid, presumably because of ~ redefinition. ~@9We cannot trust the well-formedness guarantee." (if (eq token :meta) "metatheorem" "clause-processor correctness theorem") name (if (eq token :meta) (if fn "metafunction" "hypothesis metafunction") "clause-processor") (or fn hyp-fn) (if (and fn hyp-fn) 1 0) hyp-fn (if (eq token :meta) 'logic-termp 'logic-term-list-listp) wf-thm-name1 wf-thm-name2 (let ((bad-arities-alist (car bad-arity-info)) (non-logic-fns (cdr bad-arity-info))) (msg "~@0~@1" (if (null bad-arities-alist) "" (msg "The following alist pairs function symbols with their ~ assumed arities: ~X01. Each symbol had the specified arity ~ when ~x2 was proved but this is no longer the case. " bad-arities-alist nil name)) (if (null non-logic-fns) "" (msg "The symbol~#0~[ ~x0 is no longer a :logic mode function ~ symbol~/s ~&0 are no longer :logic mode function symbols~] ~ even though this was the case when ~x2 was proved. " non-logic-fns nil name))))))
all-ffn-symbsmacro
(defmacro all-ffn-symbs (term ans) `(all-fnnames1 nil ,TERM ,ANS))
all-ffn-symbs-lstmacro
(defmacro all-ffn-symbs-lst (lst ans) `(all-fnnames1 t ,LST ,ANS))
apply$-rule-namefunction
(defun apply$-rule-name (fn) (declare (xargs :guard (symbolp fn))) (intern-in-package-of-symbol (coerce (append '(#\A #\P #\P #\L #\Y #\$ #\-) (coerce (symbol-name fn) 'list)) 'string) fn))
push-warrantsfunction
(defun push-warrants (fns target type-alist ens wrld ok-to-force ttree ttree0) (cond ((endp fns) (mv nil ttree)) (t (let* ((fn (car fns)) (warrant-name (warrant-name fn)) (warrant (fcons-term* warrant-name)) (apply$-rule-name (apply$-rule-name fn)) (fn-apply$-rule (list :rewrite apply$-rule-name))) (assert$ (and (function-symbolp warrant-name wrld) (logicp warrant-name wrld)) (cond ((enabled-runep fn-apply$-rule ens wrld) (mv-let (knownp nilp ttree) (known-whether-nil warrant type-alist ens nil nil wrld ttree) (cond (knownp (cond ((not nilp) (push-warrants (cdr fns) target type-alist ens wrld ok-to-force (push-lemma fn-apply$-rule ttree) ttree0)) (t (mv fn ttree0)))) (ok-to-force (let* ((ok-to-force (cond ((not (eq ok-to-force t)) ok-to-force) ((enabled-numep *immediate-force-modep-xnume* ens) :immediate) (t :force))) (immediatep (eq ok-to-force :immediate))) (mv-let (force-flg ttree) (force-assumption fn-apply$-rule target warrant type-alist nil immediatep t (push-lemma fn-apply$-rule ttree)) (declare (ignore force-flg)) (push-warrants (cdr fns) target type-alist ens wrld ok-to-force ttree ttree0)))) (t (mv fn ttree0))))) (t (mv (list apply$-rule-name) ttree0))))))))
*fake-rune-for-cert-data*constant
(defconst *fake-rune-for-cert-data* '(:fake-rune-for-cert-data nil))
*fake-rune-alist*constant
(defconst *fake-rune-alist* (list (cons (car *fake-rune-for-linear*) "linear arithmetic") (cons (car *fake-rune-for-linear-equalities*) "equality generation from inequalities") (cons (car *fake-rune-for-type-set*) "primitive type reasoning") (cons (car *fake-rune-for-cert-data*) "previously-computed data")))
merge-runesfunction
(defun merge-runes (l1 l2) (cond ((null l1) l2) ((null l2) l1) ((rune-< (car l1) (car l2)) (cons (car l1) (merge-runes (cdr l1) l2))) (t (cons (car l2) (merge-runes l1 (cdr l2))))))
merge-sort-runesfunction
(defun merge-sort-runes (l) (cond ((null (cdr l)) l) (t (merge-runes (merge-sort-runes (evens l)) (merge-sort-runes (odds l))))))
fn-slot-from-geneqvpfunction
(defun fn-slot-from-geneqvp (geneqv) (cond ((endp geneqv) nil) ((eq 'fn-equal (access congruence-rule (car geneqv) :equiv)) t) (t (fn-slot-from-geneqvp (cdr geneqv)))))
partition-userfns-by-warrantpfunction
(defun partition-userfns-by-warrantp (fns wrld haves have-nots) (cond ((endp fns) (mv haves have-nots)) ((or (hons-get (car fns) (unquote (getpropc '*badge-prim-falist* 'const nil wrld))) (assoc-eq (car fns) (unquote (getpropc '*apply$-boot-fns-badge-alist* 'const nil wrld)))) (partition-userfns-by-warrantp (cdr fns) wrld haves have-nots)) ((get-warrantp (car fns) wrld) (partition-userfns-by-warrantp (cdr fns) wrld (add-to-set-eq (car fns) haves) have-nots)) (t (partition-userfns-by-warrantp (cdr fns) wrld haves (add-to-set-eq (car fns) have-nots)))))
rewrite-lambda-object-pre-warningfunction
(defun rewrite-lambda-object-pre-warning (evg not-well-formedp progs pre-have-no-warrants wrld) (let* ((violations (if not-well-formedp 0 (if progs 1 (if pre-have-no-warrants 2 3))))) (let ((state-vars (default-state-vars nil))) (warning$-cw1 'rewrite-lambda-object "rewrite-lambda-object" "We refused to try to rewrite the quoted lambda-like ~ object~%~Y01because ~#2~[it is not well-formed (e.g., ~ contains free variables, has a body that is not a term, ~ or that contains unbadged function symbols)~/it contains ~ the :program mode function symbol~#3~[~/s~] ~&3~/it ~ contains the function symbol~#4~[~/s~] ~&4 for which no ~ warrant~#4~[ has~/s have~] been issued~/we didn't like ~ it but failed to record why~]. See :DOC ~ rewrite-lambda-object." evg nil violations progs pre-have-no-warrants))))
rewrite-lambda-object-post-warningfunction
(defun rewrite-lambda-object-post-warning (evg rewritten-body post-have-no-warrants ttree wrld) (let* ((free-vars (set-difference-eq (all-vars rewritten-body) (lambda-object-formals evg))) (untamep (not (executable-tamep rewritten-body wrld))) (violations (if free-vars (if (cdr free-vars) (if untamep 0 1) (if untamep 2 3)) (if untamep 4 (if post-have-no-warrants 5 6))))) (let ((state-vars (default-state-vars nil))) (warning$-cw1 'rewrite-lambda-object "rewrite-lambda-object" "The body of the well-formed (and tame) lambda ~ object~%~Y01rewrote to~%~Y21which was rejected because ~ ~#3~[it contains the variables ~&4 not listed among the ~ formals, and it is not tame~/it contains the variables ~ ~&4 not listed among the formals~/it contains the ~ variable ~&4 not listed among the formals, and it is not ~ tame~/it contains the variable ~&4 not listed among the ~ formals~/it is not tame~/it contains the function ~ symbol~#5~[ ~&5 for which no warrant has~/s ~&5 for ~ which no warrants have~] been issued~/some necessary ~ warrant is not assumed true in the current prover ~ environment~]. The following runes were used to produce ~ this rejected object: ~X61. See :DOC ~ rewrite-lambda-object." evg nil `(lambda ,(LAMBDA-OBJECT-FORMALS EVG) ,REWRITTEN-BODY) violations free-vars post-have-no-warrants (merge-sort-runes (all-runes-in-ttree ttree nil))))))
collect-0-ary-hypsfunction
(defun collect-0-ary-hyps (type-alist) (cond ((endp type-alist) nil) ((and (consp (car (car type-alist))) (null (cdr (car (car type-alist))))) (cons (car type-alist) (collect-0-ary-hyps (cdr type-alist)))) (t (collect-0-ary-hyps (cdr type-alist)))))
*rewrite-lambda-modep-xrune*constant
(defconst *rewrite-lambda-modep-xrune* '(:executable-counterpart rewrite-lambda-modep))
*rewrite-lambda-modep-def-rune*constant
(defconst *rewrite-lambda-modep-def-rune* '(:definition rewrite-lambda-modep))
formal-cons-to-componentsfunction
(defun formal-cons-to-components (term) (cond ((variablep term) (mv nil nil nil)) ((fquotep term) (let ((evg (unquote term))) (if (consp evg) (mv t (kwote (car evg)) (kwote (cdr evg))) (mv nil nil nil)))) ((eq (ffn-symb term) 'cons) (mv t (fargn term 1) (fargn term 2))) (t (mv nil nil nil))))
recover-subst-from-formal-var-alistfunction
(defun recover-subst-from-formal-var-alist (term) (cond ((variablep term) (mv nil nil)) ((equal term *nil*) (mv t nil)) (t (mv-let (flg pair rest) (formal-cons-to-components term) (cond ((null flg) (mv nil nil)) (t (mv-let (flg key val) (formal-cons-to-components pair) (cond ((null flg) (mv nil nil)) ((and (quotep key) (eq (legal-variable-or-constant-namep (unquote key)) 'variable)) (mv-let (flg sigma) (recover-subst-from-formal-var-alist rest) (cond ((null flg) (mv nil nil)) (t (mv t (cons (cons (unquote key) val) sigma)))))) (t (mv nil nil))))))))))
extend-subst-on-unbound-varsfunction
(defun extend-subst-on-unbound-vars (vars alist) (cond ((endp vars) alist) ((assoc-eq (car vars) alist) (extend-subst-on-unbound-vars (cdr vars) alist)) (t (cons (cons (car vars) *nil*) (extend-subst-on-unbound-vars (cdr vars) alist)))))
rewrite-standard-exitmacro
(defmacro rewrite-standard-exit (fn rewritten-args) `(sl-let (rewritten-term ttree) (rewrite-entry (rewrite-primitive ,FN ,REWRITTEN-ARGS)) (rewrite-entry (rewrite-with-lemmas rewritten-term))))
rewritemutual-recursion
(mutual-recursion (defun rewrite (term alist bkptr rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 3 (signed-byte 61) (let ((gstack (push-gframe 'rewrite bkptr term alist obj geneqv)) (rdepth (adjust-rdepth rdepth))) (declare (type (unsigned-byte 60) rdepth)) (cond ((zero-depthp rdepth) (rdepth-error (mv step-limit (sublis-var alist term) ttree))) ((time-limit5-reached-p "Out of time in the rewriter (rewrite).") (mv step-limit nil nil)) ((variablep term) (rewrite-entry (rewrite-solidify-plus (let ((temp (assoc-eq term alist))) (cond (temp (cdr temp)) (t term)))))) ((fquotep term) (rewrite-entry (rewrite-quoted-constant term))) ((eq (ffn-symb term) 'if) (cond ((equal (fargn term 2) (fargn term 3)) (rewrite-entry (rewrite (fargn term 2) alist 2))) (t (sl-let (rewritten-test ttree) (rewrite-entry (rewrite (fargn term 1) alist 1) :obj (cond ((eq obj '?) '?) (t (let ((arg2 (if (equal (fargn term 1) (fargn term 2)) *t* (fargn term 2)))) (cond ((quotep arg2) (if (unquote arg2) obj (not obj))) (t (let ((arg3 (fargn term 3))) (cond ((quotep arg3) (if (unquote arg3) (not obj) obj)) (t '?)))))))) :geneqv *geneqv-iff* :pequiv-info nil) (rewrite-entry (rewrite-if rewritten-test (fargn term 1) (fargn term 2) (fargn term 3) alist)))))) ((and (eq (ffn-symb term) 'return-last) (not (equal (fargn term 1) ''progn))) (rewrite-entry (rewrite (fargn term 3) alist 3) :ttree (push-lemma (fn-rune-nume 'return-last nil nil wrld) ttree))) ((eq (ffn-symb term) 'hide) (let* ((stack (make-stack-from-alist (fargn term 1) alist)) (inst-term (if alist (fcons-term* 'hide (make-lambda-application (caar stack) (fargn term 1) (cdar stack))) term)) (new-rcnst (expand-permission-p inst-term rcnst geneqv wrld))) (cond (new-rcnst (rewrite-entry (rewrite (fargn term 1) alist 1) :ttree (push-lemma (fn-rune-nume 'hide nil nil wrld) ttree) :rcnst new-rcnst)) (t (rewrite-entry (rewrite-with-lemmas inst-term)))))) ((lambda-nest-hidep term) (let* ((new-body (lambda-nest-unhide term)) (stack (make-stack-from-alist new-body alist)) (inst-term (fcons-term* 'hide (if alist (make-lambda-application (caar stack) new-body (cdar stack)) new-body))) (new-rcnst (expand-permission-p inst-term rcnst geneqv wrld))) (cond (new-rcnst (rewrite-entry (rewrite (fargn inst-term 1) nil 1) :ttree (push-lemma (fn-rune-nume 'hide nil nil wrld) ttree) :rcnst new-rcnst)) (t (rewrite-entry (rewrite-with-lemmas inst-term)))))) ((eq (ffn-symb term) 'implies) (sl-let (rewritten-test ttree) (rewrite-entry (rewrite (fargn term 1) alist 1) :obj '? :geneqv *geneqv-iff* :pequiv-info nil) (cond ((equal rewritten-test *nil*) (mv step-limit *t* ttree)) (t (sl-let (rewritten-concl ttree) (rewrite-entry (rewrite (fargn term 2) alist 2) :obj '? :geneqv *geneqv-iff* :pequiv-info nil) (cond ((equal rewritten-concl *nil*) (mv step-limit (dumb-negate-lit rewritten-test) ttree)) ((or (quotep rewritten-concl) (equal rewritten-test rewritten-concl)) (mv step-limit *t* ttree)) ((quotep rewritten-test) (let ((rune (geneqv-refinementp 'iff geneqv wrld))) (cond (rune (mv step-limit rewritten-concl (push-lemma rune ttree))) (t (mv step-limit (fcons-term* 'if rewritten-concl *t* *nil*) ttree))))) (t (mv step-limit (subcor-var (formals 'implies wrld) (list rewritten-test rewritten-concl) (bbody 'implies)) ttree)))))))) ((eq (ffn-symb term) 'double-rewrite) (sl-let (term ttree) (rewrite-entry (rewrite (fargn term 1) alist 1)) (rewrite-entry (rewrite term nil bkptr) :ttree (push-lemma (fn-rune-nume 'double-rewrite nil nil wrld) ttree)))) ((not-to-be-rewrittenp term alist (access rewrite-constant rcnst :terms-to-be-ignored-by-rewrite)) (prepend-step-limit 2 (rewrite-solidify (sublis-var alist term) type-alist obj geneqv (access rewrite-constant rcnst :current-enabled-structure) wrld ttree simplify-clause-pot-lst (access rewrite-constant rcnst :pt)))) (t (let ((fn (ffn-symb term))) (mv-let (term ttree) (if (and (eq fn 'do$) (quotep (fargn term 6)) (unquote (fargn term 6))) (mv (cons-term fn (list (fargn term 1) (fargn term 2) (fargn term 3) (fargn term 4) (fargn term 5) *nil*)) (push-lemma (fn-rune-nume 'do$ nil nil wrld) ttree)) (mv term ttree)) (mv-let (mv-nth-result mv-nth-rewritep) (if (eq fn 'mv-nth) (simplifiable-mv-nth term alist) (mv nil nil)) (cond (mv-nth-result (let ((ttree (push-lemma (fn-rune-nume 'mv-nth nil nil wrld) ttree)) (step-limit (1+f step-limit))) (declare (type (signed-byte 61) step-limit)) (if mv-nth-rewritep (rewrite-entry (rewrite mv-nth-result alist 2)) (rewrite-entry (rewrite-solidify-plus mv-nth-result))))) (t (let ((ens (access rewrite-constant rcnst :current-enabled-structure))) (mv-let (deep-pequiv-lst shallow-pequiv-lst) (pequivs-for-rewrite-args fn geneqv pequiv-info wrld ens) (sl-let (rewritten-args ttree) (rewrite-entry (rewrite-args (fargs term) alist 1 nil deep-pequiv-lst shallow-pequiv-lst geneqv fn) :obj '? :geneqv (geneqv-lst fn geneqv ens wrld) :pequiv-info nil) (cond ((and (or (flambdap fn) (logicp fn wrld)) (all-quoteps rewritten-args) (or (flambda-applicationp term) (and (enabled-xfnp fn ens wrld) (not (getpropc fn 'constrainedp nil wrld))))) (cond ((flambda-applicationp term) (rewrite-entry (rewrite (lambda-body fn) (pairlis$ (lambda-formals fn) rewritten-args) 'lambda-body))) (t (let ((ok-to-force (ok-to-force rcnst))) (mv-let (erp val apply$ed-fns) (pstk (ev-fncall+ fn (strip-cadrs rewritten-args) nil state)) (mv-let (erp2 ttree) (cond ((or erp (null apply$ed-fns)) (mv erp ttree)) (t (push-warrants apply$ed-fns (cons-term fn rewritten-args) type-alist ens wrld ok-to-force ttree ttree))) (cond (erp2 (let ((new-term1 (cons-term fn rewritten-args))) (sl-let (new-term2 ttree) (rewrite-entry (rewrite-with-lemmas new-term1)) (cond ((equal new-term1 new-term2) (mv step-limit (hide-with-comment (if erp (cons :non-executable erp) (cons :missing-warrant erp2)) new-term1 wrld state) (push-lemma (fn-rune-nume 'hide nil nil wrld) ttree))) (t (mv step-limit new-term2 ttree)))))) (t (mv step-limit (kwote val) (push-lemma (fn-rune-nume fn nil t wrld) ttree)))))))))) ((and (eq fn 'ev$) (global-val 'projects/apply/base-includedp wrld) (active-runep '(:rewrite ev$-opener)) (quotep (car rewritten-args))) (let ((x (unquote (car rewritten-args))) (y (cadr rewritten-args))) (mv-let (flg sigma) (recover-subst-from-formal-var-alist y) (cond ((null flg) (rewrite-standard-exit fn rewritten-args)) ((not (and (termp x wrld) (executable-tamep x wrld))) (rewrite-standard-exit fn rewritten-args)) (t (mv-let (warranted-fns unwarranted-fns) (partition-userfns-by-warrantp (all-fnnames x) wrld nil nil) (cond (unwarranted-fns (rewrite-standard-exit fn rewritten-args)) (t (let ((new-alist (extend-subst-on-unbound-vars (all-vars x) sigma))) (mv-let (erp ttree1) (push-warrants warranted-fns term type-alist ens wrld (ok-to-force rcnst) (push-lemma? (active-runep '(:rewrite ev$-opener)) ttree) ttree) (cond (erp (rewrite-standard-exit fn rewritten-args)) (t (rewrite-entry (rewrite x new-alist 'expansion) :ttree ttree1))))))))))))) (t (rewrite-standard-exit fn rewritten-args)))))))))))))))) (defun rewrite-solidify-plus (term rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 3 (signed-byte 61) (mv-let (new-term new-ttree) (rewrite-solidify term type-alist obj geneqv (access rewrite-constant rcnst :current-enabled-structure) wrld ttree simplify-clause-pot-lst (access rewrite-constant rcnst :pt)) (cond ((or (eq obj '?) (variablep new-term) (fquotep new-term) (member-equal (ffn-symb new-term) (access rewrite-constant rcnst :fns-to-be-ignored-by-rewrite)) (flambda-applicationp term) (not (equal geneqv *geneqv-iff*)) (not (equal term new-term))) (mv step-limit new-term new-ttree)) (t (sl-let (rewrittenp term1 ttree) (rewrite-entry (rewrite-with-lemmas1 term (getpropc (ffn-symb new-term) 'lemmas nil wrld))) (declare (ignore rewrittenp)) (mv step-limit term1 ttree))))))) (defun assume-true-false-heavy-linearp (test rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj)) (mv-let (must-be-true must-be-false true-type-alist false-type-alist ts-ttree) (assume-true-false test nil (ok-to-force rcnst) nil type-alist (access rewrite-constant rcnst :current-enabled-structure) wrld simplify-clause-pot-lst (access rewrite-constant rcnst :pt) nil) (cond ((or must-be-true must-be-false) (mv step-limit must-be-true must-be-false true-type-alist false-type-alist simplify-clause-pot-lst simplify-clause-pot-lst ts-ttree)) (t (let ((test+ (list test))) (sl-let (contradictionp true-pot-lst) (rewrite-entry (add-terms-and-lemmas test+ nil t) :obj t) (cond (contradictionp (mv step-limit nil t nil false-type-alist nil simplify-clause-pot-lst (push-lemma *fake-rune-for-linear* (access poly contradictionp :ttree)))) (t (sl-let (contradictionp false-pot-lst) (rewrite-entry (add-terms-and-lemmas test+ nil nil) :obj nil) (cond (contradictionp (mv step-limit t nil true-type-alist nil simplify-clause-pot-lst nil (push-lemma *fake-rune-for-linear* (access poly contradictionp :ttree)))) (t (mv step-limit nil nil true-type-alist false-type-alist true-pot-lst false-pot-lst nil)))))))))))) (defun rewrite-if-finish (test unrewritten-test left right alist swapped-p must-be-true must-be-false true-type-alist false-type-alist true-pot-lst false-pot-lst ts-ttree rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (cond (must-be-true (if (and unrewritten-test (geneqv-refinementp 'iff geneqv wrld) (equal unrewritten-test left)) (mv step-limit *t* (cons-tag-trees ts-ttree ttree)) (rewrite-entry (rewrite left alist 2) :type-alist true-type-alist :simplify-clause-pot-lst true-pot-lst :ttree (cons-tag-trees ts-ttree ttree)))) (must-be-false (rewrite-entry (rewrite right alist 3) :type-alist false-type-alist :simplify-clause-pot-lst false-pot-lst :ttree (cons-tag-trees ts-ttree ttree))) (t (let ((ttree (normalize-rw-any-cache ttree))) (sl-let (rewritten-left ttree) (if (and unrewritten-test (geneqv-refinementp 'iff geneqv wrld) (equal unrewritten-test left)) (mv step-limit *t* ttree) (sl-let (rw-left ttree1) (rewrite-entry (rewrite left alist 2) :type-alist true-type-alist :simplify-clause-pot-lst true-pot-lst :ttree (rw-cache-enter-context ttree)) (mv step-limit rw-left (rw-cache-exit-context ttree ttree1)))) (sl-let (rewritten-right ttree1) (rewrite-entry (rewrite right alist 3) :type-alist false-type-alist :simplify-clause-pot-lst false-pot-lst :ttree (rw-cache-enter-context ttree)) (mv-let (rewritten-term ttree) (rewrite-if1 test rewritten-left rewritten-right swapped-p type-alist geneqv (access rewrite-constant rcnst :current-enabled-structure) (ok-to-force rcnst) wrld (rw-cache-exit-context ttree ttree1)) (rewrite-entry (rewrite-with-lemmas rewritten-term))))))))) (defun rewrite-if (test unrewritten-test left right alist rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 3 (signed-byte 61) (mv-let (test unrewritten-test left right swapped-p) (cond ((and (ffn-symb-p test 'if) (equal (fargn test 2) *nil*) (equal (fargn test 3) *t*)) (mv (fargn test 1) nil right left t)) (t (mv test unrewritten-test left right nil))) (cond ((quotep test) (if (cadr test) (if (and unrewritten-test (geneqv-refinementp 'iff geneqv wrld) (equal unrewritten-test left)) (mv step-limit *t* ttree) (rewrite-entry (rewrite left alist 2))) (rewrite-entry (rewrite right alist 3)))) ((eq (access rewrite-constant rcnst :heavy-linearp) :heavy) (sl-let (must-be-true must-be-false true-type-alist false-type-alist true-pot-lst false-pot-lst ts-ttree) (rewrite-entry (assume-true-false-heavy-linearp test)) (rewrite-entry (rewrite-if-finish test unrewritten-test left right alist swapped-p must-be-true must-be-false true-type-alist false-type-alist true-pot-lst false-pot-lst ts-ttree)))) (t (mv-let (must-be-true must-be-false true-type-alist false-type-alist ts-ttree) (if ancestors (assume-true-false test nil (ok-to-force rcnst) nil type-alist (access rewrite-constant rcnst :current-enabled-structure) wrld simplify-clause-pot-lst (access rewrite-constant rcnst :pt) nil) (assume-true-false test nil (ok-to-force rcnst) nil type-alist (access rewrite-constant rcnst :current-enabled-structure) wrld nil nil nil)) (rewrite-entry (rewrite-if-finish test unrewritten-test left right alist swapped-p must-be-true must-be-false true-type-alist false-type-alist simplify-clause-pot-lst simplify-clause-pot-lst ts-ttree)))))))) (defun rewrite-args (args alist bkptr rewritten-args-rev deep-pequiv-lst shallow-pequiv-lst parent-geneqv parent-fn rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit) (ignore pequiv-info)) (the-mv 3 (signed-byte 61) (cond ((null args) (mv step-limit (reverse rewritten-args-rev) ttree)) (t (mv-let (child-geneqv child-pequiv-info) (geneqv-and-pequiv-info-for-rewrite parent-fn bkptr rewritten-args-rev args alist parent-geneqv (car geneqv) deep-pequiv-lst shallow-pequiv-lst wrld) (sl-let (rewritten-arg ttree) (rewrite-entry (rewrite (car args) alist bkptr) :geneqv child-geneqv :pequiv-info child-pequiv-info) (rewrite-entry (rewrite-args (cdr args) alist (1+ bkptr) (cons rewritten-arg rewritten-args-rev) deep-pequiv-lst shallow-pequiv-lst parent-geneqv parent-fn) :pequiv-info nil :geneqv (cdr geneqv)))))))) (defun rewrite-primitive (fn args rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore geneqv pequiv-info obj) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 3 (signed-byte 61) (cond ((flambdap fn) (mv step-limit (fcons-term fn args) ttree)) ((eq fn 'equal) (rewrite-entry (rewrite-equal (car args) (cadr args) nil nil) :obj '? :geneqv nil :pequiv-info nil)) (t (let* ((ens (access rewrite-constant rcnst :current-enabled-structure)) (recog-tuple (most-recent-enabled-recog-tuple fn wrld ens))) (cond (recog-tuple (prepend-step-limit 2 (rewrite-recognizer recog-tuple (car args) type-alist ens (ok-to-force rcnst) wrld ttree simplify-clause-pot-lst (access rewrite-constant rcnst :pt)))) (t (mv step-limit (cons-term fn args) ttree)))))))) (defun rewrite-equal (lhs rhs lhs-ancestors rhs-ancestors rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 3 (signed-byte 61) (cond ((equal lhs rhs) (mv step-limit *t* (puffert ttree))) ((and (quotep lhs) (quotep rhs)) (mv step-limit *nil* (puffert ttree))) (t (mv-let (ts-lookup ttree-lookup) (assoc-type-alist (fcons-term* 'equal lhs rhs) type-alist wrld) (cond ((and ts-lookup (ts= ts-lookup *ts-t*)) (mv step-limit *t* (cons-tag-trees ttree-lookup ttree))) ((and ts-lookup (ts= ts-lookup *ts-nil*)) (mv step-limit *nil* (cons-tag-trees ttree-lookup ttree))) (t (let ((ens (access rewrite-constant rcnst :current-enabled-structure)) (ok-to-force (ok-to-force rcnst))) (mv-let (ts-lhs ttree-lhs) (type-set lhs ok-to-force nil type-alist ens wrld ttree simplify-clause-pot-lst (access rewrite-constant rcnst :pt)) (mv-let (ts-rhs ttree+) (type-set rhs ok-to-force nil type-alist ens wrld ttree-lhs simplify-clause-pot-lst (access rewrite-constant rcnst :pt)) (mv-let (ts-equality ttree-equality) (type-set-equal ts-lhs ts-rhs ttree+ ttree) (cond ((ts= ts-equality *ts-t*) (mv step-limit *t* ttree-equality)) ((ts= ts-equality *ts-nil*) (mv step-limit *nil* ttree-equality)) ((equal-x-cons-x-yp lhs rhs) (mv step-limit *nil* (puffert ttree))) ((and (ts-subsetp ts-lhs *ts-boolean*) (equal rhs *t*)) (mv step-limit lhs (puffert ttree-lhs))) ((and (ts-subsetp ts-rhs *ts-boolean*) (equal lhs *t*)) (mv step-limit rhs (puffert ttree+))) ((equal lhs *nil*) (mv step-limit (mcons-term* 'if rhs *nil* *t*) (puffert ttree))) ((equal rhs *nil*) (mv step-limit (mcons-term* 'if lhs *nil* *t*) (puffert ttree))) ((equalityp lhs) (mv step-limit (mcons-term* 'if lhs (mcons-term* 'equal rhs *t*) (mcons-term* 'if rhs *nil* *t*)) (puffert ttree))) ((equalityp rhs) (mv step-limit (mcons-term* 'if rhs (mcons-term* 'equal lhs *t*) (mcons-term* 'if lhs *nil* *t*)) (puffert ttree))) ((and (ts-subsetp ts-lhs *ts-cons*) (ts-subsetp ts-rhs *ts-cons*) (not (member-equal lhs lhs-ancestors)) (not (member-equal rhs rhs-ancestors))) (let ((alist (list (cons 'lhs lhs) (cons 'rhs rhs)))) (sl-let (equal-cars new-ttree) (sl-let (cars ttree0) (rewrite-entry (rewrite-args '((car lhs) (car rhs)) alist 1 nil nil nil nil 'equal) :obj '? :geneqv nil :pequiv-info nil :ttree ttree+) (rewrite-entry (rewrite-equal (car cars) (cadr cars) (cons lhs lhs-ancestors) (cons rhs rhs-ancestors)) :obj nil :geneqv nil :pequiv-info nil :ttree ttree0)) (cond ((equal equal-cars *t*) (sl-let (equal-cdrs new-ttree) (sl-let (cdrs ttree0) (rewrite-entry (rewrite-args '((cdr lhs) (cdr rhs)) alist 1 nil nil nil nil 'equal) :obj '? :geneqv nil :pequiv-info nil :ttree new-ttree) (rewrite-entry (rewrite-equal (car cdrs) (cadr cdrs) (cons lhs lhs-ancestors) (cons rhs rhs-ancestors)) :obj nil :geneqv nil :pequiv-info nil :ttree ttree0)) (cond ((equal equal-cdrs *t*) (mv step-limit *t* (puffert new-ttree))) ((equal equal-cdrs *nil*) (mv step-limit *nil* (puffert new-ttree))) (t (mv step-limit (mcons-term* 'equal lhs rhs) (accumulate-rw-cache t new-ttree ttree)))))) ((equal equal-cars *nil*) (mv step-limit *nil* (puffert new-ttree))) (t (let ((ttree (accumulate-rw-cache t new-ttree ttree))) (sl-let (equal-cdrs new-ttree) (sl-let (cdrs ttree0) (rewrite-entry (rewrite-args '((cdr lhs) (cdr rhs)) alist 1 nil nil nil nil 'equal) :obj '? :geneqv nil :pequiv-info nil :ttree ttree) (rewrite-entry (rewrite-equal (car cdrs) (cadr cdrs) (cons lhs lhs-ancestors) (cons rhs rhs-ancestors)) :obj nil :geneqv nil :pequiv-info nil :ttree ttree0)) (cond ((equal equal-cdrs *nil*) (mv step-limit *nil* (puffert new-ttree))) (t (mv step-limit (mcons-term* 'equal lhs rhs) (accumulate-rw-cache t new-ttree ttree))))))))))) (t (mv step-limit (mcons-term* 'equal lhs rhs) ttree)))))))))))))) (defun relieve-hyp (rune target hyp0 unify-subst bkptr memo rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 6 (signed-byte 61) (cond ((ffn-symb-p hyp0 'synp) (mv-let (wonp failure-reason unify-subst ttree) (relieve-hyp-synp rune hyp0 unify-subst rdepth type-alist wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree bkptr) (mv step-limit wonp failure-reason unify-subst ttree memo))) (t (mv-let (forcep1 bind-flg) (binding-hyp-p hyp0 unify-subst wrld) (let ((hyp (if forcep1 (fargn hyp0 1) hyp0))) (cond (bind-flg (sl-let (rewritten-rhs ttree) (rewrite-entry (rewrite (fargn hyp 2) unify-subst (if (or (f-get-global 'gstackp state) (f-get-global 'dmrp state)) (cons 'rhs bkptr) nil)) :obj '? :ancestors (cons (make-ancestor-binding-hyp hyp unify-subst) ancestors) :geneqv (and (not (eq (ffn-symb hyp) 'equal)) (cadr (geneqv-lst (ffn-symb hyp) *geneqv-iff* (access rewrite-constant rcnst :current-enabled-structure) wrld))) :pequiv-info nil) (mv step-limit t nil (cons (cons (fargn hyp 1) rewritten-rhs) unify-subst) ttree memo))) ((free-varsp hyp unify-subst) (mv-let (term typ compound-rec-rune?) (term-and-typ-to-lookup hyp wrld (access rewrite-constant rcnst :current-enabled-structure)) (mv step-limit term typ unify-subst (push-lemma? compound-rec-rune? ttree) memo))) (t (let* ((memo-active (memo-activep memo)) (memo-entry (and (consp memo) (cdr (assoc bkptr memo)))) (hyp-vars (if memo-entry (car memo-entry) (and memo-active (all-vars hyp0)))) (restricted-unify-subst (and memo-active (restrict-alist hyp-vars unify-subst))) (old-entry (and memo-entry (assoc-equal restricted-unify-subst (cdr memo-entry))))) (cond (old-entry (mv step-limit t nil unify-subst (cons-tag-trees-rw-cache (cdr old-entry) ttree) memo)) (t (sl-let (relieve-hyp-ans failure-reason unify-subst ttree0) (let ((ttree (if memo-active (rw-cache ttree) ttree))) (mv-let (lookup-hyp-ans unify-subst ttree) (lookup-hyp hyp type-alist wrld unify-subst ttree (access rewrite-constant rcnst :current-enabled-structure)) (cond (lookup-hyp-ans (mv step-limit t nil unify-subst ttree)) (t (let* ((inst-hyp (sublis-var unify-subst hyp)) (forcer-fn (and forcep1 (ffn-symb hyp0))) (force-flg (ok-to-force rcnst)) (forcep (and forcep1 force-flg))) (mv-let (knownp nilp nilp-ttree) (known-whether-nil inst-hyp type-alist (access rewrite-constant rcnst :current-enabled-structure) force-flg nil wrld ttree) (cond (knownp (cond (nilp (mv step-limit nil 'known-nil unify-subst ttree)) (t (mv step-limit t nil unify-subst nilp-ttree)))) (t (mv-let (on-ancestorsp assumed-true) (ancestors-check inst-hyp ancestors (list rune)) (cond ((and on-ancestorsp assumed-true) (mv step-limit t nil unify-subst ttree)) ((or on-ancestorsp (backchain-limit-reachedp backchain-limit ancestors)) (mv-let (force-flg ttree) (cond ((not forcep) (mv nil ttree)) (t (force-assumption rune target inst-hyp type-alist nil (immediate-forcep forcer-fn (access rewrite-constant rcnst :current-enabled-structure)) force-flg ttree))) (cond (force-flg (mv step-limit t nil unify-subst ttree)) (t (mv step-limit nil (if on-ancestorsp 'ancestors (cons 'backchain-limit ancestors)) unify-subst ttree))))) (t (mv-let (not-flg atm) (strip-not hyp) (sl-let (rewritten-atm new-ttree) (rewrite-entry (rewrite atm unify-subst bkptr) :obj (if not-flg nil t) :geneqv *geneqv-iff* :pequiv-info nil :ancestors (push-ancestor (dumb-negate-lit inst-hyp) (list rune) ancestors bkptr)) (cond (not-flg (if (equal rewritten-atm *nil*) (mv step-limit t nil unify-subst new-ttree) (mv-let (force-flg new-ttree) (if (and forcep (not (equal rewritten-atm *t*))) (force-assumption rune target (mcons-term* 'not rewritten-atm) type-alist (mcons-term* 'not (sublis-var unify-subst atm)) (immediate-forcep forcer-fn (access rewrite-constant rcnst :current-enabled-structure)) force-flg new-ttree) (mv nil new-ttree)) (cond (force-flg (mv step-limit t nil unify-subst new-ttree)) (t (mv step-limit nil (cons 'rewrote-to (dumb-negate-lit rewritten-atm)) unify-subst (accumulate-rw-cache t new-ttree ttree))))))) ((if-tautologyp rewritten-atm) (mv step-limit t nil unify-subst new-ttree)) (t (mv-let (force-flg new-ttree) (cond ((and forcep (not (equal rewritten-atm *nil*))) (force-assumption rune target rewritten-atm type-alist (sublis-var unify-subst atm) (immediate-forcep forcer-fn (access rewrite-constant rcnst :current-enabled-structure)) force-flg new-ttree)) (t (mv nil new-ttree))) (cond (force-flg (mv step-limit t nil unify-subst new-ttree)) (t (mv step-limit nil (cons 'rewrote-to rewritten-atm) unify-subst (accumulate-rw-cache t new-ttree ttree)))))))))))))))))))) (cond (relieve-hyp-ans (mv step-limit relieve-hyp-ans failure-reason unify-subst (if memo-active (cons-tag-trees-rw-cache-first ttree ttree0) ttree0) (cond (memo-entry (put-assoc-eql bkptr (list* hyp-vars (cons (cons restricted-unify-subst ttree0) (cdr memo-entry))) memo)) (memo-active (put-assoc-eql bkptr (list* hyp-vars (cons (cons restricted-unify-subst ttree0) nil)) (if (eq memo :start) nil memo))) (t memo)))) (t (mv step-limit relieve-hyp-ans failure-reason unify-subst (accumulate-rw-cache t ttree0 ttree) memo))))))))))))))) (defun relieve-hyps1-unify-subst-lst (unify-subst-lst rune target hyps backchain-limit-lst unify-subst bkptr unify-subst0 ttree0 allp rw-cache-alist rw-cache-alist-new rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 7 (signed-byte 61) (let ((new-unify-subst (extend-unify-subst (car unify-subst-lst) unify-subst))) (mv-let (cached-failure-reason-free cached-failure-reason) (rw-cached-failure-pair new-unify-subst rw-cache-alist) (sl-let (relieve-hyps-ans failure-reason unify-subst1 ttree1 allp inferior-rw-cache-alist-new) (cond (cached-failure-reason (mv step-limit nil (and (f-get-global 'gstackp state) (cons 'cached cached-failure-reason)) unify-subst ttree allp nil)) (t (rewrite-entry (relieve-hyps1 rune target (cdr hyps) (cdr backchain-limit-lst) new-unify-subst (1+ bkptr) unify-subst0 ttree0 allp (cdr cached-failure-reason-free) nil) :obj nil :geneqv nil :pequiv-info nil))) (let ((rw-cache-alist-new (extend-rw-cache-alist-free rcnst new-unify-subst inferior-rw-cache-alist-new rw-cache-alist-new))) (cond (relieve-hyps-ans (mv step-limit relieve-hyps-ans nil unify-subst1 ttree1 allp rw-cache-alist-new)) (t (let ((rw-cache-alist-new (rw-cache-add-failure-reason rcnst new-unify-subst failure-reason rw-cache-alist-new))) (cond ((endp (cdr unify-subst-lst)) (mv step-limit nil (and (f-get-global 'gstackp state) (list (cons new-unify-subst failure-reason))) unify-subst0 (accumulate-rw-cache t ttree1 ttree0) nil rw-cache-alist-new)) (t (rewrite-entry-extending-failure new-unify-subst failure-reason (relieve-hyps1-unify-subst-lst (cdr unify-subst-lst) rune target hyps backchain-limit-lst unify-subst bkptr unify-subst0 ttree0 allp rw-cache-alist rw-cache-alist-new) :obj nil :geneqv nil :pequiv-info nil :ttree (accumulate-rw-cache t ttree1 ttree0))))))))))))) (defun relieve-hyps1 (rune target hyps backchain-limit-lst unify-subst bkptr unify-subst0 ttree0 allp rw-cache-alist rw-cache-alist-new rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 7 (signed-byte 61) (cond ((null hyps) (mv step-limit t nil unify-subst ttree allp rw-cache-alist-new)) (t (sl-let (relieve-hyp-ans failure-reason new-unify-subst new-ttree allp) (with-accumulated-persistence rune ((the (signed-byte 61) step-limit) relieve-hyp-ans failure-reason new-unify-subst new-ttree allp) relieve-hyp-ans (rewrite-entry (relieve-hyp rune target (car hyps) unify-subst bkptr allp) :backchain-limit (new-backchain-limit (car backchain-limit-lst) backchain-limit ancestors) :obj nil :geneqv nil :pequiv-info nil) bkptr) (cond ((eq relieve-hyp-ans t) (rewrite-entry (relieve-hyps1 rune target (cdr hyps) (cdr backchain-limit-lst) new-unify-subst (1+ bkptr) unify-subst0 ttree0 allp rw-cache-alist rw-cache-alist-new) :obj nil :geneqv nil :pequiv-info nil :ttree new-ttree)) ((eq relieve-hyp-ans :unify-subst-list) (sl-let (relieve-hyps-ans failure-reason-lst unify-subst ttree allp rw-cache-alist-new) (rewrite-entry (relieve-hyps1-unify-subst-lst new-unify-subst rune target hyps backchain-limit-lst unify-subst bkptr unify-subst0 ttree0 (activate-memo allp) rw-cache-alist rw-cache-alist-new) :obj nil :geneqv nil :pequiv-info nil) (mv step-limit relieve-hyps-ans (and (null relieve-hyps-ans) (cond ((null (f-get-global 'gstackp state)) nil) (t (list* bkptr 'free-vars (reverse failure-reason-lst))))) unify-subst ttree allp rw-cache-alist-new))) (relieve-hyp-ans (let* ((hyp (car hyps)) (forcep1 (and (nvariablep hyp) (or (eq (ffn-symb hyp) 'force) (eq (ffn-symb hyp) 'case-split)))) (forcer-fn (and forcep1 (ffn-symb hyp))) (hyp (if forcep1 (fargn hyp 1) (car hyps))) (force-flg (ok-to-force rcnst)) (forcep (and forcep1 force-flg))) (sl-let (relieve-hyps-ans failure-reason-lst unify-subst ttree allp rw-cache-alist-new) (rewrite-entry (relieve-hyps1-free-1 relieve-hyp-ans failure-reason hyp type-alist forcer-fn forcep force-flg rune target hyps backchain-limit-lst unify-subst bkptr unify-subst0 ttree0 (activate-memo allp) rw-cache-alist rw-cache-alist-new) :obj nil :geneqv nil :pequiv-info nil) (mv step-limit relieve-hyps-ans (and (null relieve-hyps-ans) (cond ((null (f-get-global 'gstackp state)) nil) (failure-reason-lst (list* bkptr 'free-vars failure-reason-lst)) (t (list* bkptr 'free-vars 'hyp-vars (reverse (set-difference-assoc-eq (all-vars hyp) unify-subst)))))) unify-subst ttree allp rw-cache-alist-new)))) (t (mv step-limit nil (cons bkptr failure-reason) unify-subst0 (accumulate-rw-cache t new-ttree ttree0) allp rw-cache-alist-new)))))))) (defun relieve-hyps1-free-1 (term typ hyp rest-type-alist forcer-fn forcep force-flg rune target hyps backchain-limit-lst unify-subst bkptr unify-subst0 ttree0 allp rw-cache-alist rw-cache-alist-new rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 7 (signed-byte 61) (mv-let (ans new-unify-subst new-ttree new-rest-type-alist) (search-type-alist+ term typ rest-type-alist unify-subst ttree wrld) (cond (ans (mv-let (cached-failure-reason-free cached-failure-reason) (rw-cached-failure-pair new-unify-subst rw-cache-alist) (sl-let (relieve-hyps-ans failure-reason unify-subst1 ttree1 allp inferior-rw-cache-alist-new) (cond (cached-failure-reason (mv step-limit nil (and (f-get-global 'gstackp state) (cons 'cached cached-failure-reason)) unify-subst ttree allp nil)) (t (rewrite-entry (relieve-hyps1 rune target (cdr hyps) (cdr backchain-limit-lst) new-unify-subst (1+ bkptr) unify-subst0 ttree0 allp (cdr cached-failure-reason-free) nil) :obj nil :geneqv nil :pequiv-info nil :ttree new-ttree))) (let ((rw-cache-alist-new (extend-rw-cache-alist-free rcnst new-unify-subst inferior-rw-cache-alist-new rw-cache-alist-new))) (cond (relieve-hyps-ans (mv step-limit relieve-hyps-ans nil unify-subst1 ttree1 allp rw-cache-alist-new)) (t (let ((rw-cache-alist-new (rw-cache-add-failure-reason rcnst new-unify-subst failure-reason rw-cache-alist-new))) (cond ((not allp) (mv step-limit nil (and (f-get-global 'gstackp state) (list (cons new-unify-subst failure-reason))) unify-subst0 (accumulate-rw-cache t ttree1 ttree0) nil rw-cache-alist-new)) (t (rewrite-entry-extending-failure new-unify-subst failure-reason (relieve-hyps1-free-1 term typ hyp new-rest-type-alist forcer-fn forcep force-flg rune target hyps backchain-limit-lst unify-subst bkptr unify-subst0 ttree0 allp rw-cache-alist rw-cache-alist-new) :obj nil :geneqv nil :pequiv-info nil :ttree (accumulate-rw-cache t ttree1 ttree))))))))))) (t (rewrite-entry (relieve-hyps1-free-2 hyp (relevant-ground-lemmas hyp wrld) forcer-fn forcep (access rewrite-constant rcnst :current-enabled-structure) force-flg rune target hyps backchain-limit-lst unify-subst bkptr unify-subst0 ttree0 allp rw-cache-alist rw-cache-alist-new) :obj nil :geneqv nil :pequiv-info nil)))))) (defun relieve-hyps1-free-2 (hyp lemmas forcer-fn forcep ens force-flg rune target hyps backchain-limit-lst unify-subst bkptr unify-subst0 ttree0 allp rw-cache-alist rw-cache-alist-new rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 7 (signed-byte 61) (cond ((endp lemmas) (let ((fully-bound-unify-subst (if force-flg (bind-free-vars-to-unbound-free-vars (all-vars hyp) unify-subst) unify-subst))) (mv-let (force-flg ttree) (cond ((not forcep) (mv nil ttree)) (t (force-assumption rune target (sublis-var fully-bound-unify-subst hyp) type-alist nil (immediate-forcep forcer-fn (access rewrite-constant rcnst :current-enabled-structure)) force-flg ttree))) (cond (force-flg (mv-let (cached-failure-reason-free cached-failure-reason) (rw-cached-failure-pair fully-bound-unify-subst rw-cache-alist) (cond (cached-failure-reason (mv step-limit nil (and (f-get-global 'gstackp state) (list (cons fully-bound-unify-subst (cons 'cached cached-failure-reason)))) unify-subst0 (accumulate-rw-cache t ttree ttree0) allp rw-cache-alist-new)) (t (sl-let (relieve-hyps-ans failure-reason unify-subst1 ttree1 allp inferior-rw-cache-alist-new) (rewrite-entry (relieve-hyps1 rune target (cdr hyps) (cdr backchain-limit-lst) fully-bound-unify-subst (1+ bkptr) unify-subst0 ttree0 allp (cdr cached-failure-reason-free) nil) :obj nil :geneqv nil :pequiv-info nil) (let ((rw-cache-alist-new (extend-rw-cache-alist-free rcnst fully-bound-unify-subst inferior-rw-cache-alist-new rw-cache-alist-new))) (cond (relieve-hyps-ans (mv step-limit relieve-hyps-ans nil unify-subst1 ttree1 allp rw-cache-alist-new)) (t (mv step-limit nil (and (f-get-global 'gstackp state) (list (cons fully-bound-unify-subst failure-reason))) unify-subst0 (accumulate-rw-cache t ttree1 ttree0) allp (rw-cache-add-failure-reason rcnst fully-bound-unify-subst failure-reason rw-cache-alist-new)))))))))) (t (mv step-limit nil nil unify-subst0 (accumulate-rw-cache t ttree ttree0) allp rw-cache-alist-new)))))) (t (mv-let (winp new-unify-subst new-ttree rest-lemmas) (search-ground-units1 hyp unify-subst lemmas type-alist ens force-flg wrld ttree) (cond (winp (mv-let (cached-failure-reason-free cached-failure-reason) (rw-cached-failure-pair new-unify-subst rw-cache-alist) (sl-let (relieve-hyps-ans failure-reason unify-subst1 ttree1 allp inferior-rw-cache-alist-new) (cond (cached-failure-reason (mv step-limit nil (and (f-get-global 'gstackp state) (list (cons new-unify-subst (cons 'cached cached-failure-reason)))) unify-subst ttree allp nil)) (t (rewrite-entry (relieve-hyps1 rune target (cdr hyps) (cdr backchain-limit-lst) new-unify-subst (1+ bkptr) unify-subst0 ttree0 allp (cdr cached-failure-reason-free) nil) :obj nil :geneqv nil :pequiv-info nil :ttree new-ttree))) (let ((rw-cache-alist-new (extend-rw-cache-alist-free rcnst new-unify-subst inferior-rw-cache-alist-new rw-cache-alist-new))) (cond (relieve-hyps-ans (mv step-limit relieve-hyps-ans nil unify-subst1 ttree1 allp rw-cache-alist-new)) (t (let ((rw-cache-alist-new (rw-cache-add-failure-reason rcnst new-unify-subst failure-reason rw-cache-alist-new))) (cond ((not allp) (mv step-limit nil (and (f-get-global 'gstackp state) (list (cons new-unify-subst failure-reason))) unify-subst0 (accumulate-rw-cache t ttree1 ttree0) nil rw-cache-alist-new)) (t (rewrite-entry-extending-failure new-unify-subst failure-reason (relieve-hyps1-free-2 hyp rest-lemmas forcer-fn forcep ens force-flg rune target hyps backchain-limit-lst unify-subst bkptr unify-subst0 ttree0 allp rw-cache-alist rw-cache-alist-new) :obj nil :geneqv nil :pequiv-info nil :ttree (accumulate-rw-cache t ttree1 ttree))))))))))) (t (rewrite-entry (relieve-hyps1-free-2 hyp nil forcer-fn forcep ens force-flg rune target hyps backchain-limit-lst unify-subst bkptr unify-subst0 ttree0 allp rw-cache-alist rw-cache-alist-new) :obj nil :geneqv nil :pequiv-info nil)))))))) (defun relieve-hyps (rune target hyps backchain-limit-lst unify-subst allp rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 5 (signed-byte 61) (cond ((null hyps) (mv step-limit t nil unify-subst ttree)) (t (let* ((ttree-saved ttree) (rw-cache-active-p (rw-cache-active-p rcnst)) (cached-failure-entry (and rw-cache-active-p (relieve-hyp-failure-entry rune unify-subst hyps ttree step-limit))) (cached-failure-reason-raw (and cached-failure-entry (access rw-cache-entry cached-failure-entry :failure-reason))) (cached-failure-reason-free-p (and (consp cached-failure-reason-raw) (free-failure-p cached-failure-reason-raw))) (cached-failure-reason-free (and cached-failure-reason-free-p (equal (access rw-cache-entry cached-failure-entry :hyp-info) hyps) cached-failure-reason-raw)) (cached-failure-reason (and (not cached-failure-reason-free-p) cached-failure-reason-raw)) (debug (and cached-failure-reason (rw-cache-debug rune target unify-subst cached-failure-reason step-limit)))) (cond ((and cached-failure-reason (not debug)) (mv step-limit nil (and (f-get-global 'gstackp state) (cons 'cached cached-failure-reason)) unify-subst ttree)) (t (let ((step-limit-saved step-limit) (unify-subst-saved unify-subst) (old-rw-cache-alist (cdr cached-failure-reason-free))) (sl-let (relieve-hyps-ans failure-reason unify-subst ttree allp new-rw-cache-alist) (rewrite-entry (relieve-hyps1 rune target hyps backchain-limit-lst unify-subst 1 unify-subst ttree allp old-rw-cache-alist nil) :obj nil :geneqv nil :pequiv-info nil :rcnst (if (eq (access rewrite-constant rcnst :active-theory) :standard) rcnst (change rewrite-constant rcnst :active-theory :standard))) (declare (ignore allp)) (cond ((and debug relieve-hyps-ans) (prog2$ (rw-cache-debug-action rune target unify-subst-saved cached-failure-reason step-limit-saved) (mv step-limit nil cached-failure-reason unify-subst-saved ttree-saved))) (t (mv step-limit relieve-hyps-ans failure-reason unify-subst (cond ((or relieve-hyps-ans backchain-limit (not rw-cache-active-p)) ttree) (new-rw-cache-alist (note-relieve-hyps-failure-free rune unify-subst hyps ttree cached-failure-entry old-rw-cache-alist new-rw-cache-alist step-limit-saved)) (t (note-relieve-hyp-failure rune unify-subst failure-reason ttree hyps step-limit-saved))))))))))))))) (defun rewrite-with-lemma (term lemma rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 4 (signed-byte 61) (let ((gstack (push-gframe 'rewrite-with-lemma nil term lemma geneqv)) (rdepth (adjust-rdepth rdepth))) (declare (type (unsigned-byte 60) rdepth)) (cond ((zero-depthp rdepth) (rdepth-error (mv step-limit nil term ttree))) ((eq (access rewrite-rule lemma :subclass) 'meta) (cond ((geneqv-refinementp (access rewrite-rule lemma :equiv) geneqv wrld) (let* ((meta-fn (access rewrite-rule lemma :lhs)) (args (cond ((eq (access rewrite-rule lemma :rhs) 'extended) (list term (make metafunction-context :rdepth rdepth :type-alist type-alist :obj obj :geneqv geneqv :wrld wrld :fnstack fnstack :ancestors ancestors :backchain-limit backchain-limit :simplify-clause-pot-lst simplify-clause-pot-lst :rcnst rcnst :gstack gstack :ttree ttree :unify-subst nil) (coerce-state-to-object state))) (t (list term)))) (rune (access rewrite-rule lemma :rune))) (with-accumulated-persistence rune ((the (signed-byte 61) step-limit) flg term ttree) flg (mv-let (erp val latches) (pstk (ev-fncall-meta meta-fn args state)) (declare (ignore latches)) (cond (erp (mv step-limit nil term ttree)) ((equal term val) (mv step-limit nil term ttree)) (t (let* ((user-says-skip-termp-checkp (skip-meta-termp-checks meta-fn wrld)) (well-formedness-guarantee (access rewrite-rule lemma :heuristic-info)) (not-skipped (and (not user-says-skip-termp-checkp) (not well-formedness-guarantee))) (bad-arity-info (if (and well-formedness-guarantee (not user-says-skip-termp-checkp)) (collect-bad-fn-arity-info (cdr well-formedness-guarantee) wrld nil nil) nil))) (cond (bad-arity-info (let ((name (nth 0 (car well-formedness-guarantee))) (fn (nth 1 (car well-formedness-guarantee))) (thm-name1 (nth 2 (car well-formedness-guarantee))) (hyp-fn (nth 3 (car well-formedness-guarantee))) (thm-name2 (nth 4 (car well-formedness-guarantee)))) (mv step-limit (er hard 'rewrite-with-lemma "~@0" (bad-arities-msg name :meta fn hyp-fn thm-name1 thm-name2 bad-arity-info)) term ttree))) ((and not-skipped (not (termp val wrld))) (mv step-limit (er hard 'rewrite-with-lemma "The metafunction ~x0 produced the non-termp ~ ~x1 on the input term ~x2. The proof of the ~ correctness of ~x0 establishes that the ~ quotations of these two s-expressions have ~ the same value, but our implementation ~ additionally requires that ~x0 produce a ~ term. See :DOC termp. You might consider ~ proving a well-formedness guarantee to avoid ~ this runtime test altogether. See :DOC ~ well-formedness-guarantee." meta-fn val term) term ttree)) ((and not-skipped (not (logic-termp val wrld))) (mv step-limit (er hard 'rewrite-with-lemma "The metafunction ~x0 produced the termp ~x1 ~ on the input term ~x2. The proof of the ~ correctness of ~x0 establishes that the ~ quotations of these two s-expressions have ~ the same value, but our implementation ~ additionally requires that ~x0 produce a ~ term with no :program mode function symbols. ~ ~ The term produced has :program mode ~ function symbol~#3~[~/s~] ~&3. You might ~ consider proving a well-formedness guarantee ~ to avoid this runtime test altogether. See ~ :DOC well-formedness-guarantee." meta-fn val term (collect-programs (all-ffn-symbs val nil) wrld)) term ttree)) ((and not-skipped (forbidden-fns-in-term val (access rewrite-constant rcnst :forbidden-fns))) (mv step-limit (er hard 'rewrite-with-lemma "The metafunction ~x0 produced the termp ~x1 ~ on the input term ~x2. The proof of the ~ correctness of ~x0 establishes that the ~ quotations of these two s-expressions have ~ the same value, but our implementation ~ additionally requires that certain forbidden ~ function symbols not be called. However, ~ the forbidden function symbol~#3~[ ~&3 is~/s ~ ~&3 are~] called in the term produced by ~ ~x0. See :DOC meta and :DOC ~ set-skip-meta-termp-checks and :DOC ~ well-formedness-guarantee." meta-fn val term (forbidden-fns-in-term val (access rewrite-constant rcnst :forbidden-fns))) term ttree)) (t (mv-let (extra-evaled-hyp val) (cond ((and (ffn-symb-p val 'if) (equal (fargn val 3) term)) (mv (fargn val 1) (fargn val 2))) (t (mv *t* val))) (let ((hyp-fn (access rewrite-rule lemma :hyps))) (mv-let (erp evaled-hyp latches) (if (eq hyp-fn nil) (mv nil *t* nil) (pstk (ev-fncall-meta hyp-fn args state))) (declare (ignore latches)) (cond (erp (mv step-limit nil term ttree)) (t (let* ((user-says-skip-termp-checkp (skip-meta-termp-checks hyp-fn wrld)) (not-skipped (and (not user-says-skip-termp-checkp) (not well-formedness-guarantee))) (bad-arity-info (if (and well-formedness-guarantee (not user-says-skip-termp-checkp)) (collect-bad-fn-arity-info (cdr well-formedness-guarantee) wrld nil nil) nil))) (cond (bad-arity-info (let ((name (nth 0 (car well-formedness-guarantee))) (hyp-fn (nth 3 (car well-formedness-guarantee))) (thm-name2 (nth 4 (car well-formedness-guarantee)))) (mv step-limit (er hard 'rewrite-with-lemma "~@0" (bad-arities-msg name :meta nil hyp-fn thm-name2 nil bad-arity-info)) term ttree))) ((and not-skipped (not (termp evaled-hyp wrld))) (mv step-limit (er hard 'rewrite-with-lemma "The hypothesis metafunction ~x0 ~ produced the non-termp ~x1 on the ~ input term ~x2. Our ~ implementation requires that ~x0 ~ produce a term. See :DOC termp. ~ You might consider proving a ~ well-formedness guarantee. See ~ :DOC well-formedness-guarantee to ~ avoid this runtime check ~ altogether. See :DOC ~ well-formedness-guarantee." hyp-fn evaled-hyp term) term ttree)) ((and not-skipped (not (logic-termp evaled-hyp wrld))) (mv step-limit (er hard 'rewrite-with-lemma "The hypothesis metafunction ~x0 ~ produced the termp ~x1 on the ~ input term ~x2. The proof of the ~ correctness of ~x0 establishes ~ that the quotations of these two ~ s-expressions have the same value, ~ but our implementation ~ additionally requires that ~x0 ~ produce a term with no :program ~ mode function symbols. The term ~ produced has :program mode ~ function symbol~#3~[~/s~] ~&3. ~ You might consider proving a ~ well-formedness guarantee to avoid ~ this runtime test altogether. See ~ :DOC well-formedness-guarantee." hyp-fn evaled-hyp term (collect-programs (all-ffn-symbs evaled-hyp nil) wrld)) term ttree)) ((and not-skipped (forbidden-fns-in-term evaled-hyp (access rewrite-constant rcnst :forbidden-fns))) (mv step-limit (er hard 'rewrite-with-lemma "The hypothesis metafunction ~x0 ~ produced the termp ~x1 on the ~ input term ~x2. Our ~ implementation additionally ~ requires that certain forbidden ~ function symbols not be called. ~ However, the forbidden function ~ symbol~#3~[ ~&3 is~/s ~&3 are~] ~ called in the term produced by ~ ~x0. See :DOC meta and :DOC ~ set-skip-meta-termp-checks and ~ :DOC well-formedness-guarantee." hyp-fn evaled-hyp term (forbidden-fns-in-term evaled-hyp (access rewrite-constant rcnst :forbidden-fns))) term ttree)) (t (let* ((hyps0 (flatten-ands-in-lit (quote-normal-form evaled-hyp))) (extra-hyps (flatten-ands-in-lit (quote-normal-form extra-evaled-hyp))) (hyps (append? hyps0 extra-hyps)) (vars (and hyps (all-vars term))) (rule-backchain-limit (access rewrite-rule lemma :backchain-limit-lst)) (bad-synp-hyp-msg (and hyps0 (bad-synp-hyp-msg hyps0 vars nil wrld))) (bad-synp-hyp-msg-extra (and extra-hyps (bad-synp-hyp-msg extra-hyps vars nil wrld)))) (cond (bad-synp-hyp-msg (mv step-limit (er hard 'rewrite-with-lemma "The hypothesis metafunction ~ ~x0, when applied to the input ~ term ~x1, produced a term ~ whose use of synp is illegal ~ because ~@2" hyp-fn term bad-synp-hyp-msg) term ttree)) (bad-synp-hyp-msg-extra (mv step-limit (er hard 'rewrite-with-lemma "The metafunction ~x0, when ~ applied to the input term ~x1, ~ produced a term with an ~ implicit hypothesis (see :DOC ~ meta-implicit-hypothesis), ~ whose use of synp is illegal ~ because ~@2" meta-fn term bad-synp-hyp-msg-extra) term ttree)) (t (sl-let (relieve-hyps-ans failure-reason unify-subst ttree) (rewrite-entry (relieve-hyps rune term hyps (and rule-backchain-limit (assert$ (natp rule-backchain-limit) (make-list (length hyps) :initial-element rule-backchain-limit))) (and hyps (pairlis$ vars vars)) nil) :obj nil :geneqv nil :pequiv-info nil) (declare (ignore failure-reason)) (cond (relieve-hyps-ans (sl-let (rewritten-rhs ttree) (with-accumulated-persistence rune ((the (signed-byte 61) step-limit) rewritten-rhs ttree) t (rewrite-entry (rewrite (quote-normal-form val) unify-subst 'meta)) :conc hyps) (mv step-limit t rewritten-rhs (push-lemma (geneqv-refinementp (access rewrite-rule lemma :equiv) geneqv wrld) (push-lemma+ rune ttree rcnst ancestors val rewritten-rhs))))) (t (mv step-limit nil term ttree)))))))))))))))))))))))) (t (mv step-limit nil term ttree)))) ((not (geneqv-refinementp (access rewrite-rule lemma :equiv) geneqv wrld)) (progn$ (refinement-failure-brkpt1 lemma term type-alist geneqv ancestors ttree gstack rcnst simplify-clause-pot-lst state) (brkpt2 nil 'refinement-failure nil gstack nil nil rcnst ancestors state) (mv step-limit nil term ttree))) ((eq (access rewrite-rule lemma :subclass) 'definition) (sl-let (rewritten-term ttree) (rewrite-entry (rewrite-fncall lemma term)) (mv step-limit (not (equal term rewritten-term)) rewritten-term ttree))) ((and (or (null (access rewrite-rule lemma :hyps)) (not (eq obj t)) (not (equal (access rewrite-rule lemma :rhs) *nil*))) (or (flambdap (ffn-symb term)) (not (being-openedp (ffn-symb term) fnstack (recursivep (ffn-symb term) t wrld) (eq (access rewrite-constant rcnst :rewriter-state) 'settled-down))) (not (ffnnamep (ffn-symb term) (access rewrite-rule lemma :rhs))))) (let ((lhs (access rewrite-rule lemma :lhs)) (rune (access rewrite-rule lemma :rune))) (mv-let (unify-ans unify-subst) (one-way-unify-restrictions lhs term (cdr (assoc-equal rune (access rewrite-constant rcnst :restrictions-alist)))) (cond ((and unify-ans (null (brkpt1 lemma term unify-subst type-alist geneqv ancestors ttree gstack rcnst simplify-clause-pot-lst state))) (cond ((null (loop-stopperp (access rewrite-rule lemma :heuristic-info) unify-subst wrld)) (prog2$ (brkpt2 nil 'loop-stopper unify-subst gstack nil nil rcnst ancestors state) (mv step-limit nil term ttree))) (t (with-accumulated-persistence rune ((the (signed-byte 61) step-limit) flg term ttree) flg (sl-let (relieve-hyps-ans failure-reason unify-subst ttree) (rewrite-entry (relieve-hyps rune term (access rewrite-rule lemma :hyps) (access rewrite-rule lemma :backchain-limit-lst) unify-subst (not (oncep (access rewrite-constant rcnst :oncep-override) (access rewrite-rule lemma :match-free) rune (access rewrite-rule lemma :nume)))) :obj nil :geneqv nil :pequiv-info nil) (cond (relieve-hyps-ans (sl-let (rewritten-rhs ttree) (with-accumulated-persistence rune ((the (signed-byte 61) step-limit) rewritten-rhs ttree) t (rewrite-entry (rewrite (access rewrite-rule lemma :rhs) unify-subst 'rhs)) :conc (access rewrite-rule lemma :hyps)) (prog2$ (brkpt2 t nil unify-subst gstack rewritten-rhs ttree rcnst ancestors state) (mv step-limit t rewritten-rhs (push-lemma (geneqv-refinementp (access rewrite-rule lemma :equiv) geneqv wrld) (push-lemma+ rune ttree rcnst ancestors (access rewrite-rule lemma :rhs) rewritten-rhs)))))) (t (prog2$ (brkpt2 nil failure-reason unify-subst gstack nil nil rcnst ancestors state) (mv step-limit nil term ttree))))))))) (t (progn$ (near-miss-brkpt1 lemma term type-alist geneqv ancestors ttree gstack rcnst simplify-clause-pot-lst state) (brkpt2 nil 'near-miss unify-subst gstack nil nil rcnst ancestors state) (mv step-limit nil term ttree))))))) (t (mv step-limit nil term ttree)))))) (defun rewrite-with-lemmas1 (term lemmas rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 4 (signed-byte 61) (cond ((null lemmas) (mv step-limit nil term ttree)) ((if (eq (access rewrite-constant rcnst :active-theory) :standard) (not (enabled-numep (access rewrite-rule (car lemmas) :nume) (access rewrite-constant rcnst :current-enabled-structure))) (not (enabled-arith-numep (access rewrite-rule (car lemmas) :nume) (global-val 'global-arithmetic-enabled-structure wrld)))) (rewrite-entry (rewrite-with-lemmas1 term (cdr lemmas)))) (t (sl-let (rewrittenp rewritten-term ttree) (rewrite-entry (rewrite-with-lemma term (car lemmas))) (cond (rewrittenp (mv step-limit t rewritten-term ttree)) (t (rewrite-entry (rewrite-with-lemmas1 term (cdr lemmas)))))))))) (defun rewrite-fncall (rule term rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 3 (signed-byte 61) (let* ((fn (ffn-symb term)) (args (fargs term)) (body (if (null rule) (or (lambda-body fn) (er hard 'rewrite-fncall "We had thought that a lambda function symbol ~ always has a non-nil lambda-body, but the ~ following lambda does not: ~x0" fn)) (or (access rewrite-rule rule :rhs) "We had thought that a rewrite-rule always has a non-nil ~ :rhs, but the following rewrite rule does not: ~x0"))) (recursivep (and rule (car (access rewrite-rule rule :heuristic-info))))) (cond ((and (not (flambdap fn)) (or (being-openedp fn fnstack recursivep (eq (access rewrite-constant rcnst :rewriter-state) 'settled-down)) (fnstack-term-member term fnstack) (and recursivep (member-eq :rewrite-lambda-object fnstack)))) (prepend-step-limit 2 (rewrite-solidify term type-alist obj geneqv (access rewrite-constant rcnst :current-enabled-structure) wrld ttree simplify-clause-pot-lst (access rewrite-constant rcnst :pt)))) ((null rule) (cond ((and (not (recursive-fn-on-fnstackp fnstack)) (too-many-ifs-pre-rewrite args (var-counts (lambda-formals fn) body))) (prepend-step-limit 2 (rewrite-solidify term type-alist obj geneqv (access rewrite-constant rcnst :current-enabled-structure) wrld ttree simplify-clause-pot-lst (access rewrite-constant rcnst :pt)))) (t (sl-let (rewritten-body ttree1) (rewrite-entry (rewrite body (pairlis$ (lambda-formals fn) args) 'lambda-body) :fnstack fnstack) (cond ((and (not (recursive-fn-on-fnstackp fnstack)) (too-many-ifs-post-rewrite args rewritten-body)) (prepend-step-limit 2 (rewrite-solidify term type-alist obj geneqv (access rewrite-constant rcnst :current-enabled-structure) wrld (accumulate-rw-cache t ttree1 ttree) simplify-clause-pot-lst (access rewrite-constant rcnst :pt)))) (t (mv step-limit rewritten-body ttree1))))))) (t (let* ((new-fnstack (cons (or recursivep fn) fnstack)) (rune (access rewrite-rule rule :rune))) (mv-let (unify-ans unify-subst) (one-way-unify-restrictions (access rewrite-rule rule :lhs) term (cdr (assoc-equal rune (access rewrite-constant rcnst :restrictions-alist)))) (cond ((and unify-ans (null (brkpt1 rule term unify-subst type-alist geneqv ancestors ttree gstack rcnst simplify-clause-pot-lst state))) (with-accumulated-persistence (access rewrite-rule rule :rune) ((the (signed-byte 61) step-limit) term-out ttree) (not (eq term term-out)) (cond ((and (null recursivep) (not (recursive-fn-on-fnstackp fnstack)) (too-many-ifs-pre-rewrite args (access rewrite-rule rule :var-info))) (prog2$ (brkpt2 nil 'too-many-ifs-pre-rewrite unify-subst gstack :rewritten-rhs-avoided ttree rcnst ancestors state) (prepend-step-limit 2 (rewrite-solidify term type-alist obj geneqv (access rewrite-constant rcnst :current-enabled-structure) wrld ttree simplify-clause-pot-lst (access rewrite-constant rcnst :pt))))) (t (sl-let (relieve-hyps-ans failure-reason unify-subst ttree1) (cond ((and (eq fn (base-symbol rune))) (mv step-limit t nil unify-subst ttree)) (t (rewrite-entry (relieve-hyps rune term (access rewrite-rule rule :hyps) nil unify-subst nil) :obj nil :geneqv nil :pequiv-info nil))) (cond (relieve-hyps-ans (with-accumulated-persistence rune ((the (signed-byte 61) step-limit) term-out ttree) t (sl-let (rewritten-body new-ttree1) (rewrite-entry (rewrite body unify-subst 'body) :fnstack new-fnstack :ttree ttree1) (let ((ttree1 (restore-rw-cache-any-tag new-ttree1 ttree1))) (cond ((null recursivep) (cond ((and (not (recursive-fn-on-fnstackp fnstack)) (too-many-ifs-post-rewrite args rewritten-body)) (prog2$ (brkpt2 nil 'too-many-ifs-post-rewrite unify-subst gstack rewritten-body ttree1 rcnst ancestors state) (prepend-step-limit 2 (rewrite-solidify term type-alist obj geneqv (access rewrite-constant rcnst :current-enabled-structure) wrld (accumulate-rw-cache t ttree1 ttree) simplify-clause-pot-lst (access rewrite-constant rcnst :pt))))) (t (prog2$ (brkpt2 t nil unify-subst gstack rewritten-body ttree1 rcnst ancestors state) (mv step-limit rewritten-body (push-lemma+ rune ttree1 rcnst ancestors body rewritten-body)))))) ((rewrite-fncallp term rewritten-body (if (cdr recursivep) recursivep nil) (access rewrite-constant rcnst :top-clause) (access rewrite-constant rcnst :current-clause) (cdr (access rewrite-rule rule :heuristic-info))) (cond ((contains-rewritable-callp fn rewritten-body (if (cdr recursivep) recursivep nil) (access rewrite-constant rcnst :terms-to-be-ignored-by-rewrite)) (sl-let (rewritten-body ttree2) (rewrite-entry (rewrite rewritten-body nil 'rewritten-body) :fnstack (cons (cons :term term) fnstack) :ttree ttree1) (let ((ttree2 (restore-rw-cache-any-tag (push-lemma+ rune ttree2 rcnst ancestors body rewritten-body) ttree1))) (prog2$ (brkpt2 t nil unify-subst gstack rewritten-body ttree2 rcnst ancestors state) (mv step-limit rewritten-body ttree2))))) (t (prog2$ (brkpt2 t nil unify-subst gstack rewritten-body ttree1 rcnst ancestors state) (mv step-limit rewritten-body (push-lemma+ rune ttree1 rcnst ancestors body rewritten-body)))))) (t (prog2$ (brkpt2 nil 'rewrite-fncallp unify-subst gstack rewritten-body ttree1 rcnst ancestors state) (prepend-step-limit 2 (rewrite-solidify term type-alist obj geneqv (access rewrite-constant rcnst :current-enabled-structure) wrld (accumulate-rw-cache t ttree1 ttree) simplify-clause-pot-lst (access rewrite-constant rcnst :pt)))))))) :conc (access rewrite-rule rule :hyps))) (t (prog2$ (brkpt2 nil failure-reason unify-subst gstack nil nil rcnst ancestors state) (prepend-step-limit 2 (rewrite-solidify term type-alist obj geneqv (access rewrite-constant rcnst :current-enabled-structure) wrld (accumulate-rw-cache t ttree1 ttree) simplify-clause-pot-lst (access rewrite-constant rcnst :pt))))))))))) (t (progn$ (near-miss-brkpt1 rule term type-alist geneqv ancestors ttree gstack rcnst simplify-clause-pot-lst state) (brkpt2 nil 'near-miss unify-subst gstack nil nil rcnst ancestors state) (prepend-step-limit 2 (rewrite-solidify term type-alist obj geneqv (access rewrite-constant rcnst :current-enabled-structure) wrld ttree simplify-clause-pot-lst (access rewrite-constant rcnst :pt))))))))))))) (defun rewrite-with-lemmas (term rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 3 (signed-byte 61) (cond ((variablep term) (rewrite-entry (rewrite-solidify-plus term))) ((fquotep term) (mv step-limit term ttree)) ((member-equal (ffn-symb term) (access rewrite-constant rcnst :fns-to-be-ignored-by-rewrite)) (mv step-limit term ttree)) ((flambda-applicationp term) (mv-let (new-term hyp unify-subst rune rcnst) (expand-permission-result term rcnst geneqv wrld) (cond (new-term (assert$ (and (null rune) (null hyp)) (rewrite-entry (rewrite new-term unify-subst 'expansion)))) (t (rewrite-entry (rewrite-fncall nil term)))))) (t (sl-let (rewrittenp rewritten-term ttree) (rewrite-entry (rewrite-with-linear term) :geneqv nil :pequiv-info nil) (cond (rewrittenp (mv step-limit rewritten-term ttree)) (t (sl-let (rewrittenp rewritten-term ttree) (rewrite-entry (rewrite-with-lemmas1 term (getpropc (ffn-symb term) 'lemmas nil wrld))) (cond (rewrittenp (mv step-limit rewritten-term ttree)) (t (mv-let (new-term hyp alist rune rcnst) (expand-permission-result term rcnst geneqv wrld) (cond ((and hyp new-term) (with-accumulated-persistence rune ((the (signed-byte 61) step-limit) new-term ttree) t (sl-let (rewritten-test ttree) (rewrite-entry (rewrite hyp alist 'expansion) :geneqv *geneqv-iff* :pequiv-info nil :obj t :ttree (push-lemma? rune ttree)) (let ((ens (access rewrite-constant rcnst :current-enabled-structure))) (mv-let (must-be-true must-be-false true-type-alist false-type-alist ts-ttree) (assume-true-false rewritten-test nil (ok-to-force rcnst) nil type-alist ens wrld nil nil :fta) (declare (ignore false-type-alist)) (cond (must-be-true (sl-let (rewritten-new-term ttree) (rewrite-entry (rewrite new-term alist 'expansion) :type-alist true-type-alist :ttree (cons-tag-trees ts-ttree ttree)) (mv step-limit rewritten-new-term (push-splitter? rune ttree rcnst ancestors new-term rewritten-new-term)))) (t (let ((hide-reason (and rune (not (assoc-eq (car rune) *fake-rune-alist*)) (list* :expand rune (symbol-in-current-package-p (base-symbol rune) state))))) (cond (must-be-false (mv step-limit (hide-with-comment hide-reason term wrld state) (push-lemma (fn-rune-nume 'hide nil nil wrld) (cons-tag-trees ts-ttree ttree)))) (t (sl-let (rewritten-left ttree1) (rewrite-entry (rewrite new-term alist 2) :type-alist true-type-alist :ttree (rw-cache-enter-context ttree)) (mv-let (final-term ttree) (rewrite-if11 (fcons-term* 'if rewritten-test rewritten-left (hide-with-comment hide-reason term wrld state)) type-alist geneqv wrld (push-lemma (fn-rune-nume 'hide nil nil wrld) (rw-cache-exit-context ttree ttree1))) (mv step-limit final-term (push-splitter? rune ttree rcnst ancestors new-term final-term)))))))))))))) (new-term (with-accumulated-persistence rune ((the (signed-byte 61) step-limit) new-term ttree) t (sl-let (final-term ttree) (rewrite-entry (rewrite new-term alist 'expansion) :ttree (push-lemma? rune ttree)) (mv step-limit final-term (push-splitter? rune ttree rcnst ancestors new-term final-term))))) (t (prepend-step-limit 2 (rewrite-solidify term type-alist obj geneqv (access rewrite-constant rcnst :current-enabled-structure) wrld ttree simplify-clause-pot-lst (access rewrite-constant rcnst :pt)))))))))))))))) (defun rewrite-linear-term (term alist rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 3 (signed-byte 61) (mv-let (not-flg atm) (strip-not term) (cond ((and (nvariablep atm) (or (eq (ffn-symb atm) '<) (eq (ffn-symb atm) 'equal))) (let ((rcnst1 (if (access rewrite-constant rcnst :nonlinearp) (change rewrite-constant rcnst :active-theory :arithmetic) rcnst))) (sl-let (lhs ttree) (rewrite-entry (rewrite (fargn atm 1) alist 1) :obj '? :geneqv nil :pequiv-info nil :rcnst rcnst1) (sl-let (rhs ttree) (rewrite-entry (rewrite (fargn atm 2) alist 2) :obj '? :geneqv nil :pequiv-info nil :rcnst rcnst1) (cond (not-flg (mv step-limit (mcons-term* 'not (mcons-term* (ffn-symb atm) lhs rhs)) ttree)) (t (mv step-limit (mcons-term* (ffn-symb atm) lhs rhs) ttree))))))) (t (mv step-limit (sublis-var alist term) ttree)))))) (defun rewrite-linear-term-lst (term-lst ttrees rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 3 (signed-byte 61) (if (null term-lst) (mv step-limit nil nil) (sl-let (term1 ttree1) (rewrite-entry (rewrite-linear-term (car term-lst) nil) :obj nil :geneqv nil :pequiv-info nil :type-alist (cleanse-type-alist type-alist (collect-parents (car ttrees))) :ttree (car ttrees)) (sl-let (term-lst ttree-lst) (rewrite-entry (rewrite-linear-term-lst (cdr term-lst) (cdr ttrees)) :obj nil :geneqv nil :pequiv-info nil :ttree nil) (mv step-limit (cons term1 term-lst) (cons ttree1 ttree-lst))))))) (defun add-linear-lemma (term lemma rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 3 (signed-byte 61) (let ((gstack (push-gframe 'add-linear-lemma nil term lemma)) (rdepth (adjust-rdepth rdepth))) (mv-let (unify-ans unify-subst) (one-way-unify (access linear-lemma lemma :max-term) term) (cond ((and unify-ans (null (brkpt1 lemma term unify-subst type-alist nil ancestors nil gstack rcnst simplify-clause-pot-lst state))) (let ((rune (access linear-lemma lemma :rune))) (with-accumulated-persistence rune ((the (signed-byte 61) step-limit) contradictionp pot-lst) (or contradictionp (not (eq pot-lst simplify-clause-pot-lst))) (sl-let (relieve-hyps-ans failure-reason unify-subst ttree1) (rewrite-entry (relieve-hyps rune term (access linear-lemma lemma :hyps) (access linear-lemma lemma :backchain-limit-lst) unify-subst (not (oncep (access rewrite-constant rcnst :oncep-override) (access linear-lemma lemma :match-free) rune (access linear-lemma lemma :nume)))) :obj nil :geneqv nil :pequiv-info nil :ttree nil) (cond (relieve-hyps-ans (sl-let (rewritten-concl ttree2) (with-accumulated-persistence rune ((the (signed-byte 61) step-limit) rewritten-concl ttree2) t (rewrite-entry (rewrite-linear-term (access linear-lemma lemma :concl) unify-subst) :obj nil :geneqv nil :pequiv-info nil :ttree ttree1) :conc (access linear-lemma lemma :hyps)) (let ((force-flg (ok-to-force rcnst))) (mv-let (contradictionp new-pot-lst failure-reason brr-result) (add-linear-lemma-finish rewritten-concl force-flg rune t term type-alist wrld state simplify-clause-pot-lst rcnst ttree2) (cond (contradictionp (prog2$ (brkpt2 t nil unify-subst gstack brr-result nil rcnst ancestors state) (mv step-limit contradictionp nil))) (t (mv-let (contradictionp new-pot-lst failure-reason brr-result) (let ((unrewritten-concl-to-try (and (or (eq new-pot-lst :null-lst) (eq (access rewrite-constant rcnst :rewriter-state) 'settled-down)) (sublis-var unify-subst (access linear-lemma lemma :concl))))) (cond ((and unrewritten-concl-to-try (not (equal rewritten-concl unrewritten-concl-to-try))) (add-linear-lemma-finish unrewritten-concl-to-try force-flg rune nil term type-alist wrld state (if (eq new-pot-lst :null-lst) simplify-clause-pot-lst new-pot-lst) rcnst (push-lemma rune (accumulate-rw-cache t ttree2 ttree1)))) (t (mv nil new-pot-lst failure-reason brr-result)))) (cond (contradictionp (prog2$ (brkpt2 t nil unify-subst gstack brr-result nil rcnst ancestors state) (mv step-limit contradictionp nil))) (failure-reason (prog2$ (brkpt2 nil failure-reason unify-subst gstack brr-result nil rcnst ancestors state) (mv step-limit nil new-pot-lst))) (t (prog2$ (brkpt2 t nil unify-subst gstack brr-result nil rcnst ancestors state) (mv step-limit nil new-pot-lst))))))))))) (t (prog2$ (brkpt2 nil failure-reason unify-subst gstack nil nil rcnst ancestors state) (mv step-limit nil simplify-clause-pot-lst)))))))) (t (progn$ (near-miss-brkpt1 lemma term type-alist nil ancestors nil gstack rcnst simplify-clause-pot-lst state) (brkpt2 nil 'near-miss unify-subst gstack nil nil rcnst ancestors state) (mv step-limit nil simplify-clause-pot-lst)))))))) (defun add-linear-lemmas (term linear-lemmas rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 3 (signed-byte 61) (cond ((null linear-lemmas) (mv step-limit nil simplify-clause-pot-lst)) ((not (enabled-numep (access linear-lemma (car linear-lemmas) :nume) (access rewrite-constant rcnst :current-enabled-structure))) (rewrite-entry (add-linear-lemmas term (cdr linear-lemmas)) :obj nil :geneqv nil :pequiv-info nil :ttree nil)) (t (sl-let (contradictionp new-pot-lst) (rewrite-entry (add-linear-lemma term (car linear-lemmas)) :obj nil :geneqv nil :pequiv-info nil :ttree nil) (cond (contradictionp (mv step-limit contradictionp nil)) (t (rewrite-entry (add-linear-lemmas term (cdr linear-lemmas)) :obj nil :geneqv nil :pequiv-info nil :ttree nil :simplify-clause-pot-lst new-pot-lst)))))))) (defun multiply-alists2 (alist-entry1 alist-entry2 poly rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 2 (signed-byte 61) (let* ((leaves1 (binary-*-leaves (car alist-entry1))) (leaves2 (binary-*-leaves (car alist-entry2))) (leaves (merge-arith-term-order leaves1 leaves2)) (tree (binary-*-tree leaves)) (coeff (* (cdr alist-entry1) (cdr alist-entry2))) (temp-entry (mcons-term* 'binary-* (kwote coeff) tree))) (sl-let (new-entry new-ttree) (rewrite-entry (rewrite temp-entry nil 'multiply-alists2) :obj '? :geneqv nil :pequiv-info nil :rcnst (change rewrite-constant rcnst :active-theory :arithmetic) :ttree nil) (let ((new-poly (add-linear-term new-entry 'rhs poly))) (mv step-limit (change poly new-poly :ttree (cons-tag-trees-rw-cache new-ttree (access poly new-poly :ttree)) :parents (marry-parents (collect-parents new-ttree) (access poly new-poly :parents))))))))) (defun multiply-alists1 (alist-entry alist2 poly rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 2 (signed-byte 61) (cond ((null alist2) (mv step-limit poly)) (t (sl-let (temp-poly) (rewrite-entry (multiply-alists2 alist-entry (car alist2) poly) :obj nil :geneqv nil :pequiv-info nil :ttree nil) (rewrite-entry (multiply-alists1 alist-entry (cdr alist2) temp-poly) :obj nil :geneqv nil :pequiv-info nil :ttree nil)))))) (defun multiply-alists (alist1 alist2 poly rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 2 (signed-byte 61) (cond ((null alist1) (mv step-limit poly)) (t (sl-let (temp-poly) (rewrite-entry (multiply-alists1 (car alist1) alist2 poly) :obj nil :geneqv nil :pequiv-info nil :ttree nil) (rewrite-entry (multiply-alists (cdr alist1) alist2 temp-poly) :obj nil :geneqv nil :pequiv-info nil :ttree nil)))))) (defun multiply-polys1 (alist1 const1 rel1 alist2 const2 rel2 poly rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree rel1 rel2) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 2 (signed-byte 61) (let* ((temp-poly1 (if (eql const2 0) poly (multiply-alist-and-const alist1 const2 poly))) (temp-poly2 (if (eql const1 0) temp-poly1 (multiply-alist-and-const alist2 const1 temp-poly1)))) (rewrite-entry (multiply-alists alist1 alist2 temp-poly2) :obj nil :geneqv nil :pequiv-info nil :ttree nil)))) (defun multiply-polys (poly1 poly2 rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 2 (signed-byte 61) (let ((alist1 (access poly poly1 :alist)) (ttree1 (access poly poly1 :ttree)) (const1 (access poly poly1 :constant)) (rel1 (access poly poly1 :relation)) (parents1 (access poly poly1 :parents)) (ratp1 (access poly poly1 :rational-poly-p)) (alist2 (access poly poly2 :alist)) (ttree2 (access poly poly2 :ttree)) (const2 (access poly poly2 :constant)) (rel2 (access poly poly2 :relation)) (parents2 (access poly poly2 :parents)) (ratp2 (access poly poly2 :rational-poly-p))) (let ((pre-poly (make poly :alist nil :ttree (cons-tag-trees-rw-cache ttree1 ttree2) :parents (marry-parents parents1 parents2) :constant (* const1 const2) :relation (if (and (eq rel1 '<) (eq rel2 '<)) '< '<=) :rational-poly-p (and ratp1 ratp2)))) (sl-let (poly) (rewrite-entry (multiply-polys1 alist1 const1 rel1 alist2 const2 rel2 pre-poly) :obj nil :geneqv nil :pequiv-info nil :ttree nil) (mv step-limit (normalize-poly poly))))))) (defun multiply-pots2 (poly big-poly-list new-poly-list rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 2 (signed-byte 61) (cond ((null big-poly-list) (mv step-limit new-poly-list)) ((or (access poly poly :rational-poly-p) (access poly (car big-poly-list) :rational-poly-p)) (sl-let (new-poly) (rewrite-entry (multiply-polys poly (car big-poly-list)) :obj nil :geneqv nil :pequiv-info nil :ttree nil) (rewrite-entry (multiply-pots2 poly (cdr big-poly-list) (cons new-poly new-poly-list)) :obj nil :geneqv nil :pequiv-info nil :ttree nil))) (t (rewrite-entry (multiply-pots2 poly (cdr big-poly-list) new-poly-list) :obj nil :geneqv nil :pequiv-info nil :ttree nil))))) (defun multiply-pots1 (poly-list big-poly-list new-poly-list rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 2 (signed-byte 61) (cond ((null poly-list) (mv step-limit new-poly-list)) (t (sl-let (new-new-poly-list) (rewrite-entry (multiply-pots2 (car poly-list) big-poly-list new-poly-list) :obj nil :geneqv nil :pequiv-info nil :ttree nil) (rewrite-entry (multiply-pots1 (cdr poly-list) big-poly-list new-new-poly-list) :obj nil :geneqv nil :pequiv-info nil :ttree nil)))))) (defun multiply-pots-super-filter (var-list pot-lst-to-look-in rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 2 (signed-byte 61) (cond ((null var-list) (mv step-limit nil)) ((null (cdr var-list)) (mv step-limit (shortest-polys-with-var (car var-list) pot-lst-to-look-in (access rewrite-constant rcnst :pt)))) (t (sl-let (big-poly-list) (rewrite-entry (multiply-pots-super-filter (cdr var-list) pot-lst-to-look-in) :obj nil :geneqv nil :pequiv-info nil :ttree nil) (rewrite-entry (multiply-pots1 (shortest-polys-with-var (car var-list) pot-lst-to-look-in (access rewrite-constant rcnst :pt)) big-poly-list nil) :obj nil :geneqv nil :pequiv-info nil :ttree nil)))))) (defun multiply-pots-filter (var-list pot-lst-to-look-in rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 2 (signed-byte 61) (sl-let (poly-list1) (rewrite-entry (multiply-pots1 (bounds-polys-with-var (car var-list) pot-lst-to-look-in (access rewrite-constant rcnst :pt)) (polys-with-var (cadr var-list) pot-lst-to-look-in) nil) :obj nil :geneqv nil :pequiv-info nil :ttree nil) (rewrite-entry (multiply-pots1 (bounds-polys-with-var (cadr var-list) pot-lst-to-look-in (access rewrite-constant rcnst :pt)) (polys-with-var (car var-list) pot-lst-to-look-in) poly-list1) :obj nil :geneqv nil :pequiv-info nil :ttree nil)))) (defun multiply-pots (var-list pot-lst-to-look-in rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 2 (signed-byte 61) (cond ((null var-list) (mv step-limit nil)) ((null (cdr var-list)) (mv step-limit (polys-with-var (car var-list) pot-lst-to-look-in))) (t (sl-let (big-poly-list) (rewrite-entry (multiply-pots (cdr var-list) pot-lst-to-look-in) :obj nil :geneqv nil :pequiv-info nil :ttree nil) (rewrite-entry (multiply-pots1 (polys-with-var (car var-list) pot-lst-to-look-in) big-poly-list nil) :obj nil :geneqv nil :pequiv-info nil :ttree nil)))))) (defun add-multiplied-polys-filter (var-list products-already-tried pot-lst-to-look-in rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 4 (signed-byte 61) (cond ((product-already-triedp var-list products-already-tried) (mv step-limit nil simplify-clause-pot-lst products-already-tried)) (t (sl-let (poly-list1) (rewrite-entry (multiply-pots-filter var-list pot-lst-to-look-in) :obj nil :geneqv nil :pequiv-info nil :ttree nil) (let ((poly-list2 (polys-with-pots poly-list1 simplify-clause-pot-lst nil))) (mv-let (contradictionp new-pot-lst) (add-polys poly-list2 simplify-clause-pot-lst (access rewrite-constant rcnst :pt) (access rewrite-constant rcnst :nonlinearp) type-alist (access rewrite-constant rcnst :current-enabled-structure) (ok-to-force rcnst) wrld) (mv step-limit contradictionp new-pot-lst (cons (sort-arith-term-order var-list) products-already-tried))))))))) (defun add-multiplied-polys (var-list products-already-tried pot-lst-to-look-in rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 4 (signed-byte 61) (cond ((null (cdr var-list)) (mv step-limit nil simplify-clause-pot-lst products-already-tried)) ((product-already-triedp var-list products-already-tried) (mv step-limit nil simplify-clause-pot-lst products-already-tried)) ((or (too-many-polysp var-list pot-lst-to-look-in 1) (< 4 (length var-list))) (sl-let (poly-list) (rewrite-entry (multiply-pots-super-filter var-list pot-lst-to-look-in) :obj nil :geneqv nil :pequiv-info nil :ttree nil) (mv-let (contradictionp new-pot-lst) (add-polys poly-list simplify-clause-pot-lst (access rewrite-constant rcnst :pt) (access rewrite-constant rcnst :nonlinearp) type-alist (access rewrite-constant rcnst :current-enabled-structure) (ok-to-force rcnst) wrld) (mv step-limit contradictionp new-pot-lst (cons (sort-arith-term-order var-list) products-already-tried))))) (t (sl-let (poly-list) (rewrite-entry (multiply-pots var-list pot-lst-to-look-in) :obj nil :geneqv nil :pequiv-info nil :ttree nil) (mv-let (contradictionp new-pot-lst) (add-polys poly-list simplify-clause-pot-lst (access rewrite-constant rcnst :pt) (access rewrite-constant rcnst :nonlinearp) type-alist (access rewrite-constant rcnst :current-enabled-structure) (ok-to-force rcnst) wrld) (mv step-limit contradictionp new-pot-lst (cons (sort-arith-term-order var-list) products-already-tried)))))))) (defun deal-with-product1 (part-of-new-var var-list pot-lst-to-look-in pot-lst-to-step-down products-already-tried rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 4 (signed-byte 61) (cond ((equal part-of-new-var *1*) (if (null (cdr var-list)) (mv step-limit nil simplify-clause-pot-lst products-already-tried) (rewrite-entry (add-multiplied-polys var-list products-already-tried pot-lst-to-look-in) :obj nil :geneqv nil :pequiv-info nil :ttree nil))) ((null pot-lst-to-step-down) (mv step-limit nil simplify-clause-pot-lst products-already-tried)) (t (let ((new-part-of-new-var (part-of (access linear-pot (car pot-lst-to-step-down) :var) part-of-new-var))) (cond (new-part-of-new-var (sl-let (contradictionp new-pot-list products-already-tried) (rewrite-entry (deal-with-product1 new-part-of-new-var (cons (access linear-pot (car pot-lst-to-step-down) :var) var-list) pot-lst-to-look-in pot-lst-to-look-in products-already-tried) :obj nil :geneqv nil :pequiv-info nil :ttree nil) (cond (contradictionp (mv step-limit contradictionp nil products-already-tried)) (t (rewrite-entry (deal-with-product1 part-of-new-var var-list pot-lst-to-look-in (cdr pot-lst-to-step-down) products-already-tried) :obj nil :geneqv nil :pequiv-info nil :ttree nil :simplify-clause-pot-lst new-pot-list))))) (t (rewrite-entry (deal-with-product1 part-of-new-var var-list pot-lst-to-look-in (cdr pot-lst-to-step-down) products-already-tried) :obj nil :geneqv nil :pequiv-info nil :ttree nil)))))))) (defun deal-with-product (new-var pot-lst-to-look-in pot-lst-to-step-down products-already-tried rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 4 (signed-byte 61) (cond ((eq (fn-symb new-var) 'binary-*) (rewrite-entry (deal-with-product1 new-var nil pot-lst-to-look-in pot-lst-to-step-down products-already-tried) :obj nil :geneqv nil :pequiv-info nil :ttree nil)) (t (mv step-limit nil simplify-clause-pot-lst products-already-tried))))) (defun deal-with-factor (new-var pot-lst-to-look-in pot-lst-to-step-down products-already-tried rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 4 (signed-byte 61) (cond ((null pot-lst-to-step-down) (mv step-limit nil simplify-clause-pot-lst products-already-tried)) (t (let ((part-of-pot-var (part-of new-var (access linear-pot (car pot-lst-to-step-down) :var)))) (cond ((and part-of-pot-var (not (equal new-var (access linear-pot (car pot-lst-to-step-down) :var)))) (sl-let (contradictionp new-pot-list products-already-tried) (rewrite-entry (deal-with-product1 part-of-pot-var (list new-var) pot-lst-to-look-in pot-lst-to-look-in products-already-tried) :obj nil :geneqv nil :pequiv-info nil :ttree nil) (cond (contradictionp (mv step-limit contradictionp nil products-already-tried)) (t (rewrite-entry (deal-with-factor new-var pot-lst-to-look-in (cdr pot-lst-to-step-down) products-already-tried) :obj nil :geneqv nil :pequiv-info nil :ttree nil :simplify-clause-pot-lst new-pot-list))))) (t (rewrite-entry (deal-with-factor new-var pot-lst-to-look-in (cdr pot-lst-to-step-down) products-already-tried) :obj nil :geneqv nil :pequiv-info nil :ttree nil)))))))) (defun deal-with-division (new-var inverse-var pot-lst-to-look-in pot-lst-to-step-down products-already-tried rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 4 (signed-byte 61) (cond ((null pot-lst-to-step-down) (mv step-limit nil simplify-clause-pot-lst products-already-tried)) (t (let ((part-of (part-of inverse-var (access linear-pot (car pot-lst-to-step-down) :var)))) (cond (part-of (sl-let (contradictionp new-pot-lst products-already-tried) (rewrite-entry (add-multiplied-polys-filter (list new-var (access linear-pot (car pot-lst-to-step-down) :var)) products-already-tried pot-lst-to-look-in) :obj nil :geneqv nil :pequiv-info nil :ttree nil) (cond (contradictionp (mv step-limit contradictionp nil nil)) (t (rewrite-entry (deal-with-division new-var inverse-var pot-lst-to-look-in (cdr pot-lst-to-step-down) products-already-tried) :obj nil :geneqv nil :pequiv-info nil :ttree nil :simplify-clause-pot-lst new-pot-lst))))) (t (rewrite-entry (deal-with-division new-var inverse-var pot-lst-to-look-in (cdr pot-lst-to-step-down) products-already-tried) :obj nil :geneqv nil :pequiv-info nil :ttree nil)))))))) (defun non-linear-arithmetic1 (new-vars pot-lst products-already-tried rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 3 (signed-byte 61) (cond ((null new-vars) (mv step-limit nil simplify-clause-pot-lst)) (t (let ((inverted-var (invert-var (car new-vars)))) (sl-let (contradictionp new-pot-lst1 products-already-tried) (if (good-bounds-in-pot inverted-var pot-lst (access rewrite-constant rcnst :pt)) (rewrite-entry (deal-with-division (car new-vars) inverted-var pot-lst pot-lst products-already-tried) :obj nil :geneqv nil :pequiv-info nil :ttree nil) (mv step-limit nil simplify-clause-pot-lst products-already-tried)) (cond (contradictionp (mv step-limit contradictionp nil)) (t (sl-let (contradictionp new-pot-lst2 products-already-tried) (rewrite-entry (deal-with-product (car new-vars) pot-lst pot-lst products-already-tried) :obj nil :geneqv nil :pequiv-info nil :ttree nil :simplify-clause-pot-lst new-pot-lst1) (cond (contradictionp (mv step-limit contradictionp nil)) (t (sl-let (contradictionp new-pot-lst3 products-already-tried) (rewrite-entry (deal-with-factor (car new-vars) pot-lst pot-lst products-already-tried) :obj nil :geneqv nil :pequiv-info nil :ttree nil :simplify-clause-pot-lst new-pot-lst2) (cond (contradictionp (mv step-limit contradictionp nil)) (t (rewrite-entry (non-linear-arithmetic1 (cdr new-vars) pot-lst products-already-tried) :obj nil :geneqv nil :pequiv-info nil :ttree nil :simplify-clause-pot-lst new-pot-lst3))))))))))))))) (defun non-linear-arithmetic (new-vars pot-lst products-already-tried rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 3 (signed-byte 61) (cond ((null new-vars) (mv step-limit nil simplify-clause-pot-lst)) (t (let ((gstack (push-gframe 'non-linear-arithmetic nil new-vars)) (rdepth (adjust-rdepth rdepth))) (declare (type (unsigned-byte 60) rdepth)) (rewrite-entry (non-linear-arithmetic1 new-vars pot-lst products-already-tried) :obj nil :geneqv nil :pequiv-info nil :ttree nil)))))) (defun add-polys-and-lemmas2-nl (new-vars old-pot-lst rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 3 (signed-byte 61) (cond ((null new-vars) (let ((new-vars (expanded-new-vars-in-pot-lst simplify-clause-pot-lst old-pot-lst))) (cond ((null new-vars) (mv step-limit nil simplify-clause-pot-lst)) (t (rewrite-entry (add-polys-and-lemmas2-nl new-vars simplify-clause-pot-lst) :obj nil :geneqv nil :pequiv-info nil :ttree nil))))) (t (mv-let (contradictionp new-pot-lst) (add-polys-from-type-set (car new-vars) simplify-clause-pot-lst type-alist (access rewrite-constant rcnst :pt) (ok-to-force rcnst) (access rewrite-constant rcnst :current-enabled-structure) wrld) (cond (contradictionp (mv step-limit contradictionp nil)) (t (sl-let (contradictionp new-pot-lst) (if (and (nvariablep (car new-vars)) (not (flambda-applicationp (car new-vars))) (access rewrite-constant rcnst :heavy-linearp)) (rewrite-entry (add-linear-lemmas (car new-vars) (getpropc (ffn-symb (car new-vars)) 'linear-lemmas nil wrld)) :obj nil :geneqv nil :pequiv-info nil :ttree nil :simplify-clause-pot-lst new-pot-lst) (mv step-limit nil new-pot-lst)) (cond (contradictionp (mv step-limit contradictionp nil)) (t (mv-let (contradictionp new-pot-lst) (add-inverse-polys (car new-vars) type-alist wrld new-pot-lst (ok-to-force rcnst) (access rewrite-constant rcnst :current-enabled-structure) (access rewrite-constant rcnst :pt)) (cond (contradictionp (mv step-limit contradictionp nil)) (t (rewrite-entry (add-polys-and-lemmas2-nl (cdr new-vars) old-pot-lst) :obj nil :geneqv nil :pequiv-info nil :ttree nil :simplify-clause-pot-lst new-pot-lst)))))))))))))) (defun add-polys-and-lemmas1-nl (old-pot-lst cnt rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 3 (signed-byte 61) (cond ((<= *non-linear-rounds-value* cnt) (mv step-limit nil simplify-clause-pot-lst)) (t (let ((new-vars (expanded-new-vars-in-pot-lst simplify-clause-pot-lst old-pot-lst))) (sl-let (contradictionp new-pot-lst1) (cond ((null new-vars) (mv step-limit nil simplify-clause-pot-lst)) (t (rewrite-entry (add-polys-and-lemmas2-nl new-vars old-pot-lst) :obj nil :geneqv nil :pequiv-info nil :ttree nil))) (cond (contradictionp (mv step-limit contradictionp nil)) (t (let ((new-vars (new-vars-in-pot-lst new-pot-lst1 old-pot-lst t))) (cond ((null new-vars) (mv step-limit nil new-pot-lst1)) (t (sl-let (contradictionp new-pot-lst2) (rewrite-entry (non-linear-arithmetic new-vars new-pot-lst1 nil) :obj nil :geneqv nil :pequiv-info nil :ttree nil :simplify-clause-pot-lst new-pot-lst1) (cond (contradictionp (mv step-limit contradictionp nil)) (t (rewrite-entry (add-polys-and-lemmas1-nl new-pot-lst1 (1+ cnt)) :obj nil :geneqv nil :pequiv-info nil :ttree nil :simplify-clause-pot-lst new-pot-lst2))))))))))))))) (defun add-polys-and-lemmas1 (new-vars old-pot-lst rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 3 (signed-byte 61) (cond ((null new-vars) (let ((new-vars (new-vars-in-pot-lst simplify-clause-pot-lst old-pot-lst nil))) (cond ((null new-vars) (mv step-limit nil simplify-clause-pot-lst)) (t (rewrite-entry (add-polys-and-lemmas1 new-vars simplify-clause-pot-lst) :obj nil :geneqv nil :pequiv-info nil :ttree nil))))) (t (sl-let (contradictionp new-pot-lst) (cond ((or (flambda-applicationp (car new-vars)) (not (access rewrite-constant rcnst :heavy-linearp))) (mv step-limit nil simplify-clause-pot-lst)) (t (rewrite-entry (add-linear-lemmas (car new-vars) (getpropc (ffn-symb (car new-vars)) 'linear-lemmas nil wrld)) :obj nil :geneqv nil :pequiv-info nil :ttree nil))) (cond (contradictionp (mv step-limit contradictionp nil)) (t (rewrite-entry (add-polys-and-lemmas1 (cdr new-vars) old-pot-lst) :obj nil :geneqv nil :pequiv-info nil :ttree nil :simplify-clause-pot-lst new-pot-lst)))))))) (defun add-polys-and-lemmas (lst disjunctsp rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 3 (signed-byte 61) (mv-let (contradictionp new-pot-lst) (add-polys lst simplify-clause-pot-lst (access rewrite-constant rcnst :pt) (access rewrite-constant rcnst :nonlinearp) type-alist (access rewrite-constant rcnst :current-enabled-structure) (ok-to-force rcnst) wrld) (cond (contradictionp (mv step-limit contradictionp nil)) ((and (access rewrite-constant rcnst :nonlinearp) (or (not disjunctsp) (null ancestors))) (rewrite-entry (add-polys-and-lemmas1-nl simplify-clause-pot-lst 0) :obj nil :geneqv nil :pequiv-info nil :ttree nil :simplify-clause-pot-lst new-pot-lst)) (t (rewrite-entry (add-polys-and-lemmas1 (new-vars-in-pot-lst new-pot-lst simplify-clause-pot-lst nil) new-pot-lst) :obj nil :geneqv nil :pequiv-info nil :ttree nil :simplify-clause-pot-lst new-pot-lst)))))) (defun add-disjunct-polys-and-lemmas (lst1 lst2 rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 3 (signed-byte 61) (sl-let (contradictionp new-pot-lst1) (rewrite-entry (add-polys-and-lemmas lst1 t) :obj nil :geneqv nil :pequiv-info nil :ttree nil) (cond (contradictionp (rewrite-entry (add-polys-and-lemmas (infect-polys lst2 (access poly contradictionp :ttree) (collect-parents (access poly contradictionp :ttree))) t) :obj nil :geneqv nil :pequiv-info nil :ttree nil)) (t (sl-let (contradictionp new-pot-lst2) (rewrite-entry (add-polys-and-lemmas lst2 t) :obj nil :geneqv nil :pequiv-info nil :ttree nil) (declare (ignore new-pot-lst2)) (cond (contradictionp (mv step-limit nil (infect-new-polys new-pot-lst1 simplify-clause-pot-lst (access poly contradictionp :ttree)))) (t (mv step-limit nil simplify-clause-pot-lst))))))))) (defun add-disjuncts-polys-and-lemmas (split-lst to-do-later pot-lst0 rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore obj geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 4 (signed-byte 61) (cond ((null split-lst) (let ((eqp (equal pot-lst0 simplify-clause-pot-lst))) (cond ((or eqp (null to-do-later)) (mv step-limit nil simplify-clause-pot-lst (not eqp))) (t (sl-let (contradictionp pot-lst changedp) (rewrite-entry (add-disjuncts-polys-and-lemmas to-do-later nil simplify-clause-pot-lst) :obj nil :geneqv nil :pequiv-info nil :ttree nil) (declare (ignore changedp)) (mv step-limit contradictionp pot-lst t)))))) (t (sl-let (contradictionp new-pot-lst) (rewrite-entry (add-disjunct-polys-and-lemmas (car (car split-lst)) (cadr (car split-lst))) :obj nil :geneqv nil :pequiv-info nil :ttree nil) (cond (contradictionp (mv step-limit contradictionp nil nil)) (t (rewrite-entry (add-disjuncts-polys-and-lemmas (cdr split-lst) (if (equal new-pot-lst simplify-clause-pot-lst) (cons (car split-lst) to-do-later) to-do-later) pot-lst0) :obj nil :geneqv nil :pequiv-info nil :ttree nil :simplify-clause-pot-lst new-pot-lst)))))))) (defun add-terms-and-lemmas (term-lst ttrees positivep rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore geneqv pequiv-info ttree) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 3 (signed-byte 61) (let ((gstack (push-gframe 'add-terms-and-lemmas nil term-lst obj)) (rdepth (adjust-rdepth rdepth))) (declare (type (unsigned-byte 60) rdepth)) (sl-let (term-lst ttree-lst) (if (and (access rewrite-constant rcnst :nonlinearp) (access rewrite-constant rcnst :heavy-linearp)) (rewrite-entry (rewrite-linear-term-lst term-lst ttrees) :obj nil :geneqv nil :pequiv-info nil :ttree nil) (mv step-limit term-lst ttrees)) (mv-let (poly-lst split-lst) (linearize-lst term-lst ttree-lst positivep type-alist (access rewrite-constant rcnst :current-enabled-structure) (ok-to-force rcnst) wrld state) (sl-let (contradictionp basic-pot-lst) (rewrite-entry (add-polys-and-lemmas poly-lst nil) :obj nil :geneqv nil :pequiv-info nil :ttree nil) (cond (contradictionp (mv step-limit contradictionp nil)) (t (sl-let (contradictionp new-pot-lst changedp) (rewrite-entry (add-disjuncts-polys-and-lemmas split-lst nil basic-pot-lst) :obj nil :geneqv nil :pequiv-info nil :ttree nil :simplify-clause-pot-lst basic-pot-lst) (cond (contradictionp (mv step-limit contradictionp nil)) ((and changedp (eq obj '?) (eq (access rewrite-constant rcnst :rewriter-state) 'settled-down)) (rewrite-entry (add-polys-and-lemmas1 (new-vars-in-pot-lst new-pot-lst nil nil) new-pot-lst) :obj nil :geneqv nil :pequiv-info nil :ttree nil :simplify-clause-pot-lst new-pot-lst)) (t (mv step-limit nil new-pot-lst)))))))))))) (defun rewrite-with-linear (term rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (ignore geneqv pequiv-info) (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 4 (signed-byte 61) (let ((positivep (eq obj nil))) (cond ((and (not (eq obj '?)) (mv-let (not-flg atm) (strip-not term) (declare (ignore not-flg)) (or (equalityp atm) (inequalityp atm)))) (sl-let (contradictionp irrelevant-pot-lst) (rewrite-entry (add-terms-and-lemmas (list term) nil positivep) :geneqv nil :pequiv-info nil :ttree nil) (declare (ignore irrelevant-pot-lst)) (cond (contradictionp (mv step-limit t (if positivep *nil* *t*) (push-lemma *fake-rune-for-linear* (cons-tag-trees-rw-cache (access poly contradictionp :ttree) ttree)))) (t (mv step-limit nil term ttree))))) (t (mv step-limit nil term ttree)))))) (defun rewrite-quoted-constant-with-lemma (term lemma rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 4 (signed-byte 61) (let* ((gstack (push-gframe 'rewrite-quoted-constant-with-lemma nil term lemma geneqv)) (rdepth (adjust-rdepth rdepth)) (temp (access rewrite-rule lemma :heuristic-info)) (n (car temp)) (loop-stopper (cdr temp))) (declare (type (unsigned-byte 60) rdepth) (type integer n)) (cond ((zero-depthp rdepth) (rdepth-error (mv step-limit nil term ttree))) ((not (geneqv-refinementp (access rewrite-rule lemma :equiv) geneqv wrld)) (mv step-limit nil term ttree)) (t (let ((lhs (if (eql n 2) (access rewrite-rule lemma :rhs) (access rewrite-rule lemma :lhs))) (rhs (if (eql n 2) (access rewrite-rule lemma :lhs) (access rewrite-rule lemma :rhs))) (rune (access rewrite-rule lemma :rune))) (mv-let (unify-ans unify-subst) (cond ((eql n 1) (mv (equal term lhs) nil)) ((eql n 2) (mv t (list (cons lhs term)))) ((eql n 3) (one-way-unify-restrictions lhs term (cdr (assoc-equal rune (access rewrite-constant rcnst :restrictions-alist))))) (t (mv nil (er hard 'rewrite-quoted-constant-with-lemma "We've encountered a :rewrite-quoted-constant ~ rule, namely ~x0, with an unrecognized form ~ number, ~x1." rune n)))) (cond ((and unify-ans (null (brkpt1 lemma term unify-subst type-alist geneqv ancestors ttree gstack rcnst simplify-clause-pot-lst state))) (cond ((null (loop-stopperp loop-stopper unify-subst wrld)) (prog2$ (brkpt2 nil 'loop-stopper unify-subst gstack nil nil rcnst ancestors state) (mv step-limit nil term ttree))) (t (with-accumulated-persistence rune ((the (signed-byte 61) step-limit) flg term ttree) flg (sl-let (relieve-hyps-ans failure-reason unify-subst ttree) (rewrite-entry (relieve-hyps rune term (access rewrite-rule lemma :hyps) (access rewrite-rule lemma :backchain-limit-lst) unify-subst (not (oncep (access rewrite-constant rcnst :oncep-override) (access rewrite-rule lemma :match-free) rune (access rewrite-rule lemma :nume)))) :obj nil :geneqv nil :pequiv-info nil) (cond (relieve-hyps-ans (sl-let (rewritten-rhs ttree) (with-accumulated-persistence rune ((the (signed-byte 61) step-limit) rewritten-rhs ttree) t (rewrite-entry (rewrite rhs unify-subst 'rhs)) :conc (access rewrite-rule lemma :hyps)) (cond ((or (eql n 1) (and (eql n 2) (quotep rewritten-rhs) (not (equal term rewritten-rhs))) (eql n 3)) (prog2$ (brkpt2 t nil unify-subst gstack rewritten-rhs ttree rcnst ancestors state) (mv step-limit t rewritten-rhs (push-lemma (geneqv-refinementp (access rewrite-rule lemma :equiv) geneqv wrld) (push-lemma+ rune ttree rcnst ancestors rhs rewritten-rhs))))) (t (prog2$ (brkpt2 nil (list (if (quotep rewritten-rhs) 'normalizer-returned-same-constant 'normalizer-failed-to-evaluate) (sublis-var unify-subst rhs) rewritten-rhs) unify-subst gstack nil nil rcnst ancestors state) (mv step-limit nil term ttree)))))) (t (prog2$ (brkpt2 nil failure-reason unify-subst gstack nil nil rcnst ancestors state) (mv step-limit nil term ttree))))))))) (t (mv step-limit nil term ttree)))))))))) (defun rewrite-quoted-constant-with-lemmas (term lemmas rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit)) (the-mv 4 (signed-byte 61) (cond ((null lemmas) (mv step-limit nil term ttree)) ((not (enabled-numep (access rewrite-rule (car lemmas) :nume) (access rewrite-constant rcnst :current-enabled-structure))) (rewrite-entry (rewrite-quoted-constant-with-lemmas term (cdr lemmas)))) (t (sl-let (rewrittenp rewritten-term ttree) (rewrite-entry (rewrite-quoted-constant-with-lemma term (car lemmas))) (cond (rewrittenp (mv step-limit t rewritten-term ttree)) (t (rewrite-entry (rewrite-quoted-constant-with-lemmas term (cdr lemmas)))))))))) (defun rewrite-quoted-constant (term rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (sl-let (rewrittenp rewritten-term ttree1) (rewrite-entry (rewrite-quoted-constant-with-lemmas term (global-val 'rewrite-quoted-constant-rules wrld))) (cond (rewrittenp (mv step-limit rewritten-term ttree1)) ((fn-slot-from-geneqvp geneqv) (sl-let (evg1 ttree1) (rewrite-entry (rewrite-lambda-object (unquote term))) (cond ((equal evg1 (unquote term)) (mv step-limit term ttree)) (t (mv step-limit (kwote evg1) (cons-tag-trees ttree1 ttree)))))) (t (mv step-limit term ttree))))) (defun rewrite-lambda-object (evg rdepth step-limit type-alist obj geneqv pequiv-info wrld state fnstack ancestors backchain-limit simplify-clause-pot-lst rcnst gstack ttree) (declare (type (unsigned-byte 60) rdepth) (type (signed-byte 61) step-limit) (ignore obj geneqv pequiv-info ancestors simplify-clause-pot-lst)) (the-mv 3 (signed-byte 61) (cond ((or (symbolp evg) (not (enabled-numep *rewrite-lambda-modep-xnume* (access rewrite-constant rcnst :current-enabled-structure)))) (mv step-limit evg ttree)) ((well-formed-lambda-objectp evg wrld) (let* ((formals (lambda-object-formals evg)) (dcl (lambda-object-dcl evg)) (body (lambda-object-body evg)) (type-alist1 (collect-0-ary-hyps type-alist)) (fns (all-fnnames body)) (progs (collect-programs fns wrld))) (mv-let (pre-have-warrants pre-have-no-warrants) (partition-userfns-by-warrantp fns wrld nil nil) (cond ((and (null progs) (null pre-have-no-warrants)) (sl-let (rewritten-body ttree1) (if (enabled-numep *rewrite-lambda-modep-def-nume* (access rewrite-constant rcnst :current-enabled-structure)) (sl-let (temp-rewritten-body temp-ttree1) (rewrite-entry (rewrite body nil 'lambda-object-body) :fnstack (cons :rewrite-lambda-object fnstack) :type-alist type-alist1 :obj '? :geneqv nil :pequiv-info nil :ancestors nil :simplify-clause-pot-lst nil :ttree nil) (mv-let (temp-rewritten-body temp-ttree1) (normalize temp-rewritten-body nil nil (access rewrite-constant rcnst :current-enabled-structure) wrld temp-ttree1 (backchain-limit wrld :ts)) (mv step-limit temp-rewritten-body temp-ttree1))) (mv step-limit (clean-up-dirty-lambda-object-body :all body wrld (remove-guard-holders-lamp)) ttree)) (cond ((equal rewritten-body body) (cond ((null dcl) (mv step-limit evg ttree)) (t (mv step-limit `(lambda ,FORMALS ,BODY) ttree)))) ((or (not (subsetp-eq (all-vars rewritten-body) formals)) (not (executable-tamep rewritten-body wrld))) (prog2$ (rewrite-lambda-object-post-warning evg rewritten-body nil ttree1 wrld) (mv step-limit evg ttree))) (t (mv-let (post-have-warrants post-have-no-warrants) (partition-userfns-by-warrantp (all-fnnames rewritten-body) wrld nil nil) (cond (post-have-no-warrants (prog2$ (rewrite-lambda-object-post-warning evg rewritten-body post-have-no-warrants ttree1 wrld) (mv step-limit evg ttree))) (t (mv-let (erp ttree2) (push-warrants (union-eq pre-have-warrants post-have-warrants) body type-alist1 (access rewrite-constant rcnst :current-enabled-structure) wrld (ok-to-force rcnst) ttree1 ttree) (cond (erp (prog2$ (rewrite-lambda-object-post-warning evg rewritten-body nil ttree1 wrld) (mv step-limit evg ttree))) (t (let ((ttree3 (push-lemma *rewrite-lambda-modep-xrune* (cons-tag-trees ttree2 ttree)))) (mv step-limit `(lambda ,FORMALS ,REWRITTEN-BODY) (if (enabled-numep *rewrite-lambda-modep-def-nume* (access rewrite-constant rcnst :current-enabled-structure)) (push-lemma *rewrite-lambda-modep-def-rune* ttree3) ttree3))))))))))))) (t (prog2$ (rewrite-lambda-object-pre-warning evg nil progs pre-have-no-warrants wrld) (mv step-limit evg ttree))))))) (t (prog2$ (and (consp evg) (eq (car evg) 'lambda) (rewrite-lambda-object-pre-warning evg t nil nil wrld)) (mv step-limit evg ttree)))))))