1
; ACL2 Version 6.5 -- A Computational Logic for Applicative Common Lisp
2
; Copyright (C) 2014, Regents of the University of Texas
1
; ACL2 Version 7.0 -- A Computational Logic for Applicative Common Lisp
2
; Copyright (C) 2015, Regents of the University of Texas
4
4
; This version of ACL2 is a descendent of ACL2 Version 1.9, Copyright
5
5
; (C) 1997 Computational Logic, Inc. See the documentation topic NOTE-2-0.
798
798
(merge-sort-length cl-set) nil nil))
799
799
ens (match-free-override wrld) wrld state ttree)))))
801
(defun measure-clause-for-branch (name tc measure-alist rel wrld)
801
(defun measure-clause-for-branch (name tc measure-alist rel debug-info wrld)
803
803
; Name is the name of some function, say f0, in a mutually recursive
804
804
; clique. Tc is a tests-and-call in the termination machine of f0 and hence
824
824
(formals f1 wrld)
826
826
(cdr (assoc-eq f1 measure-alist))))
827
(concl (mcons-term* rel m1-prime m0)))
829
(dumb-negate-lit-lst tests)
827
(concl (mcons-term* rel m1-prime m0))
828
(clause (add-literal concl
829
(dumb-negate-lit-lst tests)
831
(maybe-add-extra-info-lit debug-info call clause wrld)))
832
(defun measure-clauses-for-fn1 (name t-machine measure-alist rel wrld)
833
(defun measure-clauses-for-fn1 (name t-machine measure-alist rel debug-info
833
835
(cond ((null t-machine) nil)
834
(t (conjoin-clause-to-clause-set
836
(t (conjoin-clause-to-clause-set-extra-info
835
837
(measure-clause-for-branch name
840
843
(measure-clauses-for-fn1 name
846
(defun measure-clauses-for-fn (name t-machine measure-alist mp rel wrld)
850
(defun measure-clauses-for-fn (name t-machine measure-alist mp rel
848
853
; We form all of the clauses that are required to be theorems for the admission
849
854
; of name with the given termination machine and measures. Mp is the "domain
871
(measure-clauses-for-fn1 name t-machine measure-alist rel wrld))
872
(t (conjoin-clause-to-clause-set
873
(add-literal (mcons-term* mp (cdr (assoc-eq name measure-alist)))
875
(measure-clauses-for-fn1 name t-machine measure-alist rel wrld)))))
876
(measure-clauses-for-fn1 name t-machine measure-alist rel
878
`(:measure (:relation ,name)))
880
(t (conjoin-clause-to-clause-set-extra-info
881
(let ((mp-call (mcons-term* mp (cdr (assoc-eq name measure-alist)))))
882
(maybe-add-extra-info-lit (and measure-debug
883
`(:measure (:domain ,name)))
885
(add-literal mp-call nil t)
887
(measure-clauses-for-fn1 name t-machine measure-alist rel
889
`(:measure (:relation ,name)))
877
(defun measure-clauses-for-clique (names t-machines measure-alist mp rel wrld)
892
(defun measure-clauses-for-clique (names t-machines measure-alist mp rel
879
895
; We assume we can obtain from wrld the 'formals for each fn in names.
881
897
(cond ((null names) nil)
882
(t (conjoin-clause-sets
898
(t (conjoin-clause-sets+
883
900
(measure-clauses-for-fn (car names)
902
measure-alist mp rel measure-debug wrld)
888
903
(measure-clauses-for-clique (cdr names)
905
measure-alist mp rel measure-debug
894
908
(defun tilde-*-measure-phrase1 (alist wrld)
937
951
(t (find-?-measure (cdr measure-alist)))))
939
953
(defun prove-termination (names t-machines measure-alist mp rel hints otf-flg
940
bodies ctx ens wrld state ttree)
954
bodies measure-debug ctx ens wrld state ttree)
942
956
; Given a list of the functions introduced in a mutually recursive clique,
943
957
; their t-machines, the measure-alist for the clique, a domain predicate mp on
2058
2072
(t (value nil)))
2060
2074
((wrld1 (update-w big-mutrec wrld))
2061
(pair (prove-termination names nil nil mp rel nil otf-flg bodies
2075
(pair (prove-termination names nil nil mp rel nil otf-flg bodies nil
2062
2076
ctx ens wrld1 state nil)))
2064
2078
; We know that pair is of the form (col . ttree), where col is the column
2164
2180
subversive-p))))
2166
2182
(defun put-induction-info (names arglists measures ruler-extenders-lst bodies
2167
mp rel hints otf-flg big-mutrec ctx ens wrld
2183
mp rel hints otf-flg big-mutrec measure-debug
2170
2186
; WARNING: This function installs a world. That is safe at the time of this
2171
2187
; writing because this function is only called by defuns-fn0, which is only
2237
2253
(triple (prove-termination-recursive
2238
2254
names arglists measures t-machines mp rel hints
2239
otf-flg bodies ctx ens wrld1 state)))
2255
otf-flg bodies measure-debug ctx ens wrld1 state)))
2240
2256
(let* ((col (car triple))
2241
2257
(measure-alist (cadr triple))
2242
2258
(ttree (cddr triple)))
5660
5676
; Keep this in sync with deflabel XARGS.
5662
5678
'(:guard :guard-hints :guard-debug
5663
:hints :measure :ruler-extenders :mode :non-executable :normalize
5679
:hints :measure :measure-debug
5680
:ruler-extenders :mode :non-executable :normalize
5664
5681
:otf-flg #+:non-standard-analysis :std-hints
5665
5682
:stobjs :verify-guards :well-founded-relation
7592
7609
nil ; guard-debug default
7611
(measure-debug (get-unambiguous-xargs-flg :MEASURE-DEBUG
7613
nil ; guard-debug default
7594
7615
(split-types-lst (get-boolean-unambiguous-xargs-flg-lst
7595
7616
:SPLIT-TYPES fives nil ctx state))
7596
7617
(normalizeps (get-boolean-unambiguous-xargs-flg-lst
7862
7884
; violate the translate conventions on stobjs.
7864
7886
; - t or nil, used to add calls of EXTRA-INFO to guard conjectures
7888
; - t or nil, used to add calls of EXTRA-INFO to measure conjectures
7865
7889
; split-types-terms
7866
7890
; - list of translated terms, each corresponding to type
7867
7891
; declarations made for a definition with XARGS keyword
8147
8173
(wrld4 (update-w big-mutrec
8148
8174
(putprop-x-lst2-unless names 'split-types-term
8149
8175
split-types-terms *t* wrld3)))
8151
; Rockwell Addition: To save time, the nu-rewriter doesn't look at
8152
; functions unless they contain nu-rewrite targets, as defined in
8153
; rewrite.lisp. Here is where I store the property that says whether a
8154
; function is a target.
8158
(cond ((eq (car names) 'NTH)
8159
(putprop 'nth 'nth-update-rewriter-targetp
8161
((getprop (car names) 'recursivep nil
8162
'current-acl2-world wrld4)
8164
; Nth-update-rewriter does not go into recursive functions. We could consider
8165
; redoing this computation when installing a new definition rule, as well as
8166
; the putprop below, but that's a heuristic decision that doesn't seem to be so
8170
((nth-update-rewriter-targetp (car bodies) wrld4)
8172
; This precomputation of whether the body of the function is a
8173
; potential target for nth-update-rewriter is insensitive to whether
8174
; the functions being seen are disabled. If the function being
8175
; defined calls a non-recursive function that uses NTH, then this
8176
; function is marked as being a target. If later that subroutine is
8177
; disabled, then nth-update-rewriter will not go into it and this
8178
; function may no longer really be a potential target. But if we do
8179
; not ``memoize'' the computation this way then it may be
8180
; exponentially slow, going repeatedly into large bodies called
8181
; more than one time in a function.
8183
(putprop (car names)
8184
'nth-update-rewriter-targetp
8187
8176
#+:non-standard-analysis
8189
8178
(value (or (eq (ld-skip-proofsp state) 'include-book)
8203
8192
#-:non-standard-analysis
8204
8193
(value (caddr tuple))))
8207
8196
(putprop-body-lst names arglists bodies normalizeps
8208
8197
(getprop (car names) 'recursivep nil
8209
'current-acl2-world wrld5)
8210
(make-controller-alist names wrld5)
8198
'current-acl2-world wrld4)
8199
(make-controller-alist names wrld4)
8211
8200
#+:non-standard-analysis std-p
8212
ens wrld5 wrld5 nil)
8201
ens wrld4 wrld4 nil)
8214
(update-w big-mutrec wrld6)
8203
(update-w big-mutrec wrld5)
8216
(wrld7 ttree2 state)
8205
(wrld6 ttree2 state)
8217
8206
(putprop-type-prescription-lst names
8219
8208
(fn-rune-nume (car names)
8221
ens wrld6 ttree2 state)
8210
ens wrld5 ttree2 state)
8223
(update-w big-mutrec wrld7)
8212
(update-w big-mutrec wrld6)
8225
((wrld8 (update-w big-mutrec
8226
(putprop-level-no-lst names wrld7)))
8214
((wrld7 (update-w big-mutrec
8215
(putprop-level-no-lst names wrld6)))
8216
(wrld8 (update-w big-mutrec
8217
(putprop-primitive-recursive-defunp-lst
8227
8219
(wrld9 (update-w big-mutrec
8228
(putprop-primitive-recursive-defunp-lst
8230
(wrld9a (update-w big-mutrec
8231
(putprop-hereditarily-constrained-fnnames-lst
8232
names bodies wrld9)))
8220
(putprop-hereditarily-constrained-fnnames-lst
8221
names bodies wrld8)))
8233
8222
(wrld10 (update-w big-mutrec
8234
8223
(put-invariant-risk
8237
8226
non-executablep
8238
8227
(update-doc-database-lst names docs pairs
8240
8229
(wrld11 (update-w big-mutrec
8241
8230
(putprop-x-lst1
8242
8231
names 'pequivs nil
8292
8281
(defun defuns-fn0 (names arglists docs pairs guards measures
8293
8282
ruler-extenders-lst mp rel hints guard-hints std-hints
8294
otf-flg guard-debug bodies symbol-class normalizeps
8295
split-types-terms non-executablep
8283
otf-flg guard-debug measure-debug bodies symbol-class
8284
normalizeps split-types-terms non-executablep
8296
8285
#+:non-standard-analysis std-p
8297
8286
ctx wrld state)
8771
8761
(wrld (nth 18 tuple))
8772
8762
(non-executablep (nth 19 tuple))
8773
8763
(guard-debug (nth 20 tuple))
8774
(split-types-terms (nth 21 tuple)))
8764
(measure-debug (nth 21 tuple))
8765
(split-types-terms (nth 22 tuple)))
8776
8767
((pair (defuns-fn0