File: step-limits.lisp

package info (click to toggle)
acl2 7.2dfsg-3
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 198,968 kB
  • ctags: 182,300
  • sloc: lisp: 2,415,261; ansic: 5,675; perl: 5,577; xml: 3,576; sh: 3,255; cpp: 2,835; makefile: 2,440; ruby: 2,402; python: 778; ml: 763; yacc: 709; csh: 355; php: 171; lex: 162; tcl: 44; java: 24; asm: 23; haskell: 17
file content (249 lines) | stat: -rw-r--r-- 5,920 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
; Matt Kaufmann

; This book provides a test for the correct implementation of step-limits.

(in-package "ACL2")

(include-book "misc/eval" :dir :system)

(must-succeed
; 435 steps exactly in a version between ACL2 4.2 and 4.3
 (with-prover-step-limit
  435
  (thm
   (equal (append x (append y z))
          (append (append x y) z)))))

(must-fail
; 435 steps exactly in a version between ACL2 4.2 and 4.3
 (with-prover-step-limit
  434
  (thm
   (equal (append x (append y z))
          (append (append x y) z)))))

(must-fail
; 435 steps exactly in a version between ACL2 4.2 and 4.3
 (with-prover-step-limit
  200 ; we thus expect 201 steps used; "more than 200" reported for the thm
  (thm
   (equal (append x (append y z))
          (append (append x y) z)))))

(set-prover-step-limit 300)

; The following fails without the inner with-prover-step-limit having flag t,
; because otherwise more than the allocated 300 steps are charged to the
; must-fail form (i.e., to the make-event form generated by the call of
; must-fail).
(must-fail
 (with-prover-step-limit
  :start
  t
  (thm
   (equal (append x (append y z))
          (append (append x y) z)))))

; The following fails unless the extra argument of t is given to the inner
; with-prover-step-limit, because otherwise more than the allocated 300 steps
; are charged to the must-succeed form (i.e., to the make-event form generated
; by the call of must-succeed).
(must-succeed
 (with-prover-step-limit
  500
  t
  (thm
   (equal (append x (append y z))
          (append (append x y) z)))))

(with-prover-step-limit
 200
 (must-fail
  (with-prover-step-limit
   :start
   t
   (thm
    (equal (append x (append y z))
           (append (append x y) z))))))

(set-prover-step-limit 500)

(must-succeed
 (thm
  (equal (append x (append y z))
         (append (append x y) z))))

(must-fail
 (with-prover-step-limit
  300
  (thm
   (equal (append x (append y z))
          (append (append x y) z)))))

; See long comments "The following fails ...." above for why we need the call
; of with-prover-step-limit just below, with third argument t.
(must-fail
 (with-prover-step-limit
  :start
  t
  (encapsulate
   ()
   (defthm test1
     (equal (append x (append y z))
            (append (append x y) z))
     :rule-classes nil)
   (defthm test2
     (equal (append x (append y z))
            (append (append x y) z))
     :rule-classes nil))))

; As above:
(with-prover-step-limit
 500
 (must-fail
  (with-prover-step-limit
   :start
   t
   (encapsulate
    ()
    (defthm test1
      (equal (append x (append y z))
             (append (append x y) z))
      :rule-classes nil)
    (defthm test2
      (equal (append x (append y z))
             (append (append x y) z))
      :rule-classes nil)))))

; See long comments "The following fails ...." above for why we need the call
; of with-prover-step-limit just below, with third argument t.
(must-fail ; fails at the very end
 (with-prover-step-limit
  :start
  t
  (encapsulate
   ()
   (defthm test1
     (equal (append x (append y z))
            (append (append x y) z))
     :rule-classes nil)
   (with-prover-step-limit
    500
    (defthm test2
      (equal (append x (append y z))
             (append (append x y) z))
      :rule-classes nil)))))

; As above:
(with-prover-step-limit
 500
 (must-fail ; fails at the very end
  (with-prover-step-limit
   :start
   t
   (encapsulate
    ()
    (defthm test1
      (equal (append x (append y z))
             (append (append x y) z))
      :rule-classes nil)
    (with-prover-step-limit
     500
     (defthm test2
       (equal (append x (append y z))
              (append (append x y) z))
       :rule-classes nil))))))

(must-succeed
 (with-prover-step-limit
  1000
  t
  (encapsulate
   ()
   (defthm test1
     (equal (append x (append y z))
            (append (append x y) z))
     :rule-classes nil)
   (with-prover-step-limit
    500
    (defthm test2
      (equal (append x (append y z))
             (append (append x y) z))
      :rule-classes nil)))))

; Extra argument of t is needed as usual, because we exceed the global limit of
; 500.
(must-fail
 (with-prover-step-limit
  1000
  t
  (encapsulate
   ()
   (defthm test1
     (equal (append x (append y z))
            (append (append x y) z))
     :rule-classes nil)
   (with-prover-step-limit
    200
    (defthm test2
      (equal (append x (append y z))
             (append (append x y) z))
      :rule-classes nil)))))

(must-succeed
 (encapsulate
  ()
  (with-prover-step-limit
   500
   t ; Don't charge for this first defthm
   (defthm test1
     (equal (append x (append y z))
            (append (append x y) z))
     :rule-classes nil))
  (defthm test2
    (equal (append x (append y z))
           (append (append x y) z))
    :rule-classes nil)))

; Essentially the same as just above.
(must-succeed
 (with-prover-step-limit
  500
  (encapsulate
   ()
   (with-prover-step-limit
    500
    t ; Don't charge for this first defthm
    (defthm test1
      (equal (append x (append y z))
             (append (append x y) z))
      :rule-classes nil))
   (defthm test2
     (equal (append x (append y z))
            (append (append x y) z))
     :rule-classes nil))))

(set-prover-step-limit 200)

; As usual, we need the extra argument t below in order to avoid having the
; entire must-fail form exceed the limit of 200 steps.
(must-fail
 (with-prover-step-limit
  :start
  t
  (progn
    (set-prover-step-limit 500)
    (defthm test3
      (equal (append x (append y z))
             (append (append x y) z))))))

; Setting an explicit limit (even nil, for "unlimited") overrides the global
; default step limit from set-prover-step-limit.
(with-prover-step-limit
 nil
 (progn
   (set-prover-step-limit 500)
   (local ; avoid adding test3 to database upon include-book
    (defthm test3
      (equal (append x (append y z))
             (append (append x y) z))))))