1 ;;; -*- Mode: LISP; Package: (PRIMORDIAL :USE CL :COLON-MODE :EXTERNAL); Base: 10; Syntax: Ansi-common-lisp -*-
3 ;;; LaHaShem HaAretz U'Mloah
5 ;;; This file contains a set of functions for testing Screamer prior to
6 ;;; release. Run the function (PRIME-ORDEAL). If it returns T and doesn't
7 ;;; produce any error messages then Screamer is probably OK.
9 (in-package :screamer-user
)
11 (screamer:define-screamer-package
:primordial
(:use
:iterate
))
13 (in-package :primordial
)
15 (defun equal-set?
(x y
)
16 (and (subsetp x y
:test
#'equal
) (subsetp y x
:test
#'equal
)))
18 (defun attacks (qi qj distance
)
19 (or (= qi qj
) (= qi
(+ qj distance
)) (= qi
(- qj distance
))))
21 (defun check-queens (queen queens
&optional
(distance 1))
23 (if (attacks queen
(first queens
) distance
) (fail))
24 (check-queens queen
(rest queens
) (1+ distance
))))
26 (defun n-queens (n &optional queens
)
27 (if (= (length queens
) n
)
29 (let ((queen (an-integer-between 1 n
)))
30 (check-queens queen queens
)
31 (n-queens n
(cons queen queens
)))))
33 (defun test1 () (= (length (all-values (n-queens 4))) 2))
35 (defun test2 () (= (length (all-values (n-queens 8))) 92))
37 (defun a-bit () (either 0 1))
39 ;;; note: DOLIST and DOTIMES work nondeterministically because PUSH doesn't
40 ;;; destructively modify the list that is being collected so each list
41 ;;; returned as a nondeterministic value is available after backtracking.
42 ;;; note: Tests 3 through 6 are commented out since they all contain
43 ;;; nondeterministc DOTIMES and DOLIST which don't work under CMU
44 ;;; Common Lisp and I don't have time to figure out why.
47 (defun test3-internal (n)
50 (dotimes (i n
) (push (either 0 1) collection
))
55 (equal-set?
(all-values (test3-internal 2)) '((0 0) (1 0) (0 1) (1 1))))
58 (defun test4-internal (n)
59 (local (let (collection)
60 (dotimes (i n
) (push (a-bit) collection
))
65 (equal-set?
(all-values (test3-internal 2)) '((0 0) (1 0) (0 1) (1 1))))
68 (defun test5-internal (list)
69 (local (let (collection)
70 (dolist (e list
) (push (either 0 1) collection
))
75 (equal-set?
(all-values (test3-internal 2)) '((0 0) (1 0) (0 1) (1 1))))
78 (defun test6-internal (list)
79 (local (let (collection)
80 (dolist (e list
) (push (a-bit) collection
))
85 (equal-set?
(all-values (test3-internal 2)) '((0 0) (1 0) (0 1) (1 1))))
87 ;;; Problems with LOOP:
88 ;;; 1. Symbolics implementation of LOOP expands directly into RPLACD without
89 ;;; going through SETF. This foils the LOCAL declaration.
90 ;;; 2. Results disappear upon ALL-VALUES internal backtracking.
91 ;;; 3. Lucid expands LOOP into a MULTIPLE-VALUE-CALL.
94 (defun test7-internal (n) (local (loop repeat n collect
(either 0 1))))
98 (equal-set?
(all-values (test7-internal 2)) '((1 1) (0 1) (1 0) (0 0))))
101 (defun test8-internal (n) (local (loop repeat n collect
(a-bit))))
105 (equal-set?
(all-values (test8-internal 2)) '((1 1) (0 1) (1 0) (0 0))))
107 ;;; Problems with ITERATE:
108 ;;; 1. Beta conversion of (let ((#:foo nil)) (setf foo 'bar)) is unsound.
109 ;;; 2. Results disappear upon ALL-VALUES internal backtracking.
112 (defun test9-internal (n)
113 (local (iterate (repeat n
) (collect (either 0 1)))))
117 (equal-set?
(all-values (test9-internal 2)) '((1 1) (0 1) (1 0) (0 0))))
120 (defun test10-internal (n) (local (iterate (repeat n
) (collect (a-bit)))))
124 (equal-set?
(all-values (test10-internal 2)) '((1 1) (0 1) (1 0) (0 0))))
128 (local (LET* ((COUNT789)
136 (IF (<= COUNT789
0) (GO LOOP-END-NIL
))
138 (SETQ TEMP791
(LIST (A-BIT)))
142 (SETF (CDR END-POINTER790
) TEMP791
)
143 (SETQ RESULT788 TEMP791
))))
146 (SETQ COUNT789
(1- COUNT789
))
152 (let ((x (make-variable)))
153 (assert! (numberpv x
))
154 (and (known?
(numberpv x
))
155 (not (known?
(notv (numberpv x
))))
156 (not (known?
(realpv x
)))
157 (not (known?
(notv (realpv x
))))
158 (not (known?
(integerpv x
)))
159 (not (known?
(notv (integerpv x
)))))))
162 (let ((x (make-variable)))
163 (assert! (notv (numberpv x
)))
164 (and (known?
(andv (notv (numberpv x
))
166 (notv (integerpv x
))))
167 (not (known?
(numberpv x
)))
168 (not (known?
(realpv x
)))
169 (not (known?
(integerpv x
))))))
172 (let ((x (make-variable)))
174 (and (known?
(andv (numberpv x
) (realpv x
)))
175 (not (known?
(notv (numberpv x
))))
176 (not (known?
(notv (realpv x
))))
177 (not (known?
(integerpv x
)))
178 (not (known?
(notv (integerpv x
)))))))
181 (let ((x (make-variable)))
182 (assert! (notv (realpv x
)))
183 (and (known?
(andv (notv (realpv x
)) (notv (integerpv x
))))
184 (not (known?
(numberpv x
)))
185 (not (known?
(notv (numberpv x
))))
186 (not (known?
(realpv x
)))
187 (not (known?
(integerpv x
))))))
190 (let ((x (make-variable)))
191 (assert! (integerpv x
))
192 (and (known?
(andv (integerpv x
) (realpv x
) (numberpv x
)))
193 (not (known?
(notv (numberpv x
))))
194 (not (known?
(notv (realpv x
))))
195 (not (known?
(notv (integerpv x
)))))))
198 (let ((x (make-variable)))
199 (assert! (notv (integerpv x
)))
200 (and (known?
(notv (integerpv x
)))
201 (not (known?
(numberpv x
)))
202 (not (known?
(realpv x
)))
203 (not (known?
(notv (numberpv x
))))
204 (not (known?
(notv (realpv x
))))
205 (not (known?
(integerpv x
))))))
208 (let ((x (make-variable)))
209 (assert! (numberpv x
))
210 (assert! (notv (realpv x
)))
211 (and (known?
(andv (numberpv x
) (notv (realpv x
)) (notv (integerpv x
))))
212 (not (known?
(notv (numberpv x
))))
213 (not (known?
(realpv x
)))
214 (not (known?
(integerpv x
))))))
217 (let ((x (make-variable)))
218 (assert! (numberpv x
))
219 (assert! (notv (integerpv x
)))
220 (and (known?
(andv (numberpv x
) (notv (integerpv x
))))
221 (not (known?
(notv (numberpv x
))))
222 (not (known?
(realpv x
)))
223 (not (known?
(notv (realpv x
))))
224 (not (known?
(integerpv x
))))))
227 (let ((x (make-variable)))
229 (assert! (notv (integerpv x
)))
230 (and (known?
(andv (numberpv x
) (realpv x
) (notv (integerpv x
))))
231 (not (known?
(notv (numberpv x
))))
232 (not (known?
(notv (realpv x
))))
233 (not (known?
(integerpv x
))))))
236 (let ((x (make-variable)))
237 (null (all-values (assert! (numberpv x
)) (assert! (notv (numberpv x
)))))))
240 (let ((x (make-variable)))
241 (null (all-values (assert! (realpv x
)) (assert! (notv (realpv x
)))))))
244 (let ((x (make-variable)))
245 (null (all-values (assert! (integerpv x
)) (assert! (notv (integerpv x
)))))))
248 (let* ((x (make-variable))
250 (p2 (notv (numberpv x
)))
252 (p4 (notv (realpv x
)))
254 (p6 (notv (integerpv x
))))
264 (let* ((x (make-variable))
266 (p2 (notv (numberpv x
)))
268 (p4 (notv (realpv x
)))
270 (p6 (notv (integerpv x
))))
272 (and (not (known? p1
))
280 (let* ((x (make-variable))
282 (p2 (notv (numberpv x
)))
284 (p4 (notv (realpv x
)))
286 (p6 (notv (integerpv x
))))
296 (let* ((x (make-variable))
298 (p2 (notv (numberpv x
)))
300 (p4 (notv (realpv x
)))
302 (p6 (notv (integerpv x
))))
304 (and (not (known? p1
))
312 (let* ((x (make-variable))
314 (p2 (notv (numberpv x
)))
316 (p4 (notv (realpv x
)))
318 (p6 (notv (integerpv x
))))
328 (let* ((x (make-variable))
330 (p2 (notv (numberpv x
)))
332 (p4 (notv (realpv x
)))
334 (p6 (notv (integerpv x
))))
336 (and (not (known? p1
))
344 (let* ((x (make-variable))
346 (p2 (notv (numberpv x
))))
347 (null (all-values (assert! p1
) (assert! p2
)))))
350 (let ((x (make-variable)))
354 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
356 (memberv x
'(d e f
4 5 6 4.0 5.0 6.0 #c
(4 0.0) #c
(5 0.0) #c
(6 0.0))))))))
359 (let ((x (make-variable)))
361 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
363 (memberv x
'(a b c
4 5 6 4.0 5.0 6.0 #c
(4 0.0) #c
(5 0.0) #c
(6 0.0))))
364 (and (known?
(andv (notv (numberpv x
))
366 (notv (integerpv x
))))
367 (not (known?
(numberpv x
)))
368 (not (known?
(realpv x
)))
369 (not (known?
(integerpv x
))))))
372 (let ((x (make-variable)))
374 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
376 (memberv x
'(d e f
1 2 3 4.0 5.0 6.0 #c
(4 0.0) #c
(5 0.0) #c
(6 0.0))))
377 (and (known?
(andv (numberpv x
) (realpv x
) (integerpv x
)))
378 (not (known?
(notv (numberpv x
))))
379 (not (known?
(notv (realpv x
))))
380 (not (known?
(notv (integerpv x
)))))))
383 (let ((x (make-variable)))
385 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
387 (memberv x
'(d e f
4 5 6 1.0 2.0 3.0 #c
(4 0.0) #c
(5 0.0) #c
(6 0.0))))
388 (and (known?
(andv (numberpv x
) (realpv x
) (notv (integerpv x
))))
389 (not (known?
(notv (numberpv x
))))
390 (not (known?
(notv (realpv x
))))
391 (not (known?
(integerpv x
))))))
394 (let ((x (make-variable)))
396 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
398 (memberv x
'(d e f
4 5 6 4.0 5.0 6.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
399 (and (known?
(andv (numberpv x
) (notv (realpv x
)) (notv (integerpv x
))))
400 (not (known?
(notv (numberpv x
))))
401 (not (known?
(realpv x
)))
402 (not (known?
(integerpv x
))))))
405 (let ((x (make-variable)))
407 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
409 (memberv x
'(b c d
2 3 4 2.0 3.0 4.0 #c
(2 0.0) #c
(3 0.0) #c
(4 0.0))))
410 (equal-set?
(all-values (solution x
(static-ordering #'linear-force
)))
411 '(b c
2 3 2.0 3.0 #c
(2 0.0) #c
(3 0.0)))))
414 (let ((x (make-variable)))
416 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
418 (memberv x
'(b c d
2 3 4 2.0 3.0 4.0 #c
(2 0.0) #c
(3 0.0) #c
(4 0.0))))
419 (assert! (numberpv x
))
420 (equal-set?
(all-values (solution x
(static-ordering #'linear-force
)))
421 '(2 3 2.0 3.0 #c
(2 0.0) #c
(3 0.0)))))
424 (let ((x (make-variable)))
426 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
428 (memberv x
'(b c d
2 3 4 2.0 3.0 4.0 #c
(2 0.0) #c
(3 0.0) #c
(4 0.0))))
429 (assert! (notv (numberpv x
)))
430 (equal-set?
(all-values (solution x
(static-ordering #'linear-force
)))
434 (let ((x (make-variable)))
436 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
438 (memberv x
'(b c d
2 3 4 2.0 3.0 4.0 #c
(2 0.0) #c
(3 0.0) #c
(4 0.0))))
440 (equal-set?
(all-values (solution x
(static-ordering #'linear-force
)))
444 (let ((x (make-variable)))
446 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
448 (memberv x
'(b c d
2 3 4 2.0 3.0 4.0 #c
(2 0.0) #c
(3 0.0) #c
(4 0.0))))
449 (assert! (notv (realpv x
)))
450 (equal-set?
(all-values (solution x
(static-ordering #'linear-force
)))
451 '(b c
#c
(2 0.0) #c
(3 0.0)))))
454 (let ((x (make-variable)))
456 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
458 (memberv x
'(b c d
2 3 4 2.0 3.0 4.0 #c
(2 0.0) #c
(3 0.0) #c
(4 0.0))))
459 (assert! (integerpv x
))
460 (equal-set?
(all-values (solution x
(static-ordering #'linear-force
)))
464 (let ((x (make-variable)))
466 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
468 (memberv x
'(b c d
2 3 4 2.0 3.0 4.0 #c
(2 0.0) #c
(3 0.0) #c
(4 0.0))))
469 (assert! (notv (integerpv x
)))
470 (equal-set?
(all-values (solution x
(static-ordering #'linear-force
)))
471 '(b c
2.0 3.0 #c
(2 0.0) #c
(3 0.0)))))
474 (let ((x (make-variable)))
476 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
478 (memberv x
'(b c d
2 3 4 2.0 3.0 4.0 #c
(2 0.0) #c
(3 0.0) #c
(4 0.0))))
479 (assert! (numberpv x
))
480 (assert! (notv (integerpv x
)))
481 (equal-set?
(all-values (solution x
(static-ordering #'linear-force
)))
482 '(2.0
3.0 #c
(2 0.0) #c
(3 0.0)))))
485 (let ((x (make-variable)))
487 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
489 (memberv x
'(b c d
2 3 4 2.0 3.0 4.0 #c
(2 0.0) #c
(3 0.0) #c
(4 0.0))))
490 (assert! (numberpv x
))
491 (assert! (notv (realpv x
)))
492 (equal-set?
(all-values (solution x
(static-ordering #'linear-force
)))
493 '(#c
(2 0.0) #c
(3 0.0)))))
496 (let ((x (make-variable)))
498 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
500 (memberv x
'(b c d
2 3 4 2.0 3.0 4.0 #c
(2 0.0) #c
(3 0.0) #c
(4 0.0))))
502 (assert! (notv (integerpv x
)))
503 (equal-set?
(all-values (solution x
(static-ordering #'linear-force
)))
507 (let* ((x (make-variable))
509 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
511 (memberv x
'(d e f
4 5 6 4.0 5.0 6.0 #c
(4 0.0) #c
(5 0.0) #c
(6 0.0)))))
512 (null (all-values (assert! p1
) (assert! p2
)))))
515 (let* ((x (make-variable))
517 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
519 (memberv x
'(a b c
4 5 6 4.0 5.0 6.0 #c
(4 0.0) #c
(5 0.0) #c
(6 0.0))))
521 (p4 (notv (numberpv x
)))
523 (p6 (notv (realpv x
)))
525 (p8 (notv (integerpv x
))))
528 (and (not (known? p3
))
536 (let* ((x (make-variable))
538 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
540 (memberv x
'(d e f
1 2 3 4.0 5.0 6.0 #c
(4 0.0) #c
(5 0.0) #c
(6 0.0))))
542 (p4 (notv (numberpv x
)))
544 (p6 (notv (realpv x
)))
546 (p8 (notv (integerpv x
))))
557 (let* ((x (make-variable))
559 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
561 (memberv x
'(d e f
4 5 6 1.0 2.0 3.0 #c
(4 0.0) #c
(5 0.0) #c
(6 0.0))))
563 (p4 (notv (numberpv x
)))
565 (p6 (notv (realpv x
)))
567 (p8 (notv (integerpv x
))))
578 (let* ((x (make-variable))
580 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
582 (memberv x
'(d e f
4 5 6 4.0 5.0 6.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
584 (p4 (notv (numberpv x
)))
586 (p6 (notv (realpv x
)))
588 (p8 (notv (integerpv x
))))
599 (let* ((x (make-variable))
601 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
603 (memberv x
'(b c d
2 3 4 2.0 3.0 4.0 #c
(2 0.0) #c
(3 0.0) #c
(4 0.0))))
604 (p3 (memberv x
'(b c
2 3 2.0 3.0 #c
(2 0.0) #c
(3 0.0)))))
610 (let* ((x (make-variable))
612 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
614 (memberv x
'(b c d
2 3 4 2.0 3.0 4.0 #c
(2 0.0) #c
(3 0.0) #c
(4 0.0))))
615 (p3 (memberv x
'(2 3 2.0 3.0 #c
(2 0.0) #c
(3 0.0))))
623 (let* ((x (make-variable))
625 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
627 (memberv x
'(b c d
2 3 4 2.0 3.0 4.0 #c
(2 0.0) #c
(3 0.0) #c
(4 0.0))))
628 (p3 (memberv x
'(b c
)))
629 (p4 (notv (numberpv x
))))
636 (let* ((x (make-variable))
638 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
640 (memberv x
'(b c d
2 3 4 2.0 3.0 4.0 #c
(2 0.0) #c
(3 0.0) #c
(4 0.0))))
641 (p3 (memberv x
'(2 3 2.0 3.0)))
649 (let* ((x (make-variable))
651 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
653 (memberv x
'(b c d
2 3 4 2.0 3.0 4.0 #c
(2 0.0) #c
(3 0.0) #c
(4 0.0))))
654 (p3 (memberv x
'(b c
#c
(2 0.0) #c
(3 0.0))))
655 (p4 (notv (realpv x
))))
662 (let* ((x (make-variable))
664 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
666 (memberv x
'(b c d
2 3 4 2.0 3.0 4.0 #c
(2 0.0) #c
(3 0.0) #c
(4 0.0))))
667 (p3 (memberv x
'(2 3)))
675 (let* ((x (make-variable))
677 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
679 (memberv x
'(b c d
2 3 4 2.0 3.0 4.0 #c
(2 0.0) #c
(3 0.0) #c
(4 0.0))))
680 (p3 (memberv x
'(b c
2.0 3.0 #c
(2 0.0) #c
(3 0.0))))
681 (p4 (notv (integerpv x
))))
688 (let* ((x (make-variable))
690 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
692 (memberv x
'(b c d
2 3 4 2.0 3.0 4.0 #c
(2 0.0) #c
(3 0.0) #c
(4 0.0))))
693 (p3 (memberv x
'(2.0
3.0 #c
(2 0.0) #c
(3 0.0))))
694 (p4 (andv (numberpv x
) (notv (integerpv x
)))))
701 (let* ((x (make-variable))
703 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
705 (memberv x
'(b c d
2 3 4 2.0 3.0 4.0 #c
(2 0.0) #c
(3 0.0) #c
(4 0.0))))
706 (p3 (memberv x
'(#c
(2 0.0) #c
(3 0.0))))
707 (p4 (andv (numberpv x
) (notv (realpv x
)))))
714 (let* ((x (make-variable))
716 (memberv x
'(a b c
1 2 3 1.0 2.0 3.0 #c
(1 0.0) #c
(2 0.0) #c
(3 0.0))))
718 (memberv x
'(b c d
2 3 4 2.0 3.0 4.0 #c
(2 0.0) #c
(3 0.0) #c
(4 0.0))))
719 (p3 (memberv x
'(2.0
3.0)))
720 (p4 (andv (realpv x
) (notv (integerpv x
)))))
727 (let* ((x (make-variable))
728 (p1 (notv (memberv x
'(a b c d
))))
729 (p2 (memberv x
'(c d e f g h
)))
730 (p3 (notv (memberv x
'(g h i j
))))
731 (p4 (andv (memberv x
'(e f
)) (notv (memberv x
'(a b c d g h i j z
))))))
738 (let* ((x (make-variable))
739 (p1 (notv (memberv x
'(a b c d
))))
740 (p2 (memberv x
'(c d g h
)))
741 (p3 (notv (memberv x
'(g h i j
)))))
742 (null (all-values (assert! p1
) (assert! p2
) (assert! p3
)))))
745 (let ((x (an-integer-betweenv 0 4))
746 (y (an-integer-betweenv 8 12))
747 (z (a-member-ofv '(-1 6 13))))
748 (assert! (<=v x z y
))
749 (known?
(memberv z
'(6)))))
752 (let* ((x (make-variable))
755 (p1 (andv (integerpv x
) (>=v x
0) (<=v x
4)))
756 (p2 (andv (integerpv y
) (>=v y
8) (<=v y
12)))
757 (p3 (memberv z
'(-1 6 13)))
759 (p5 (andv (memberv z
'(6)) (notv (memberv z
'(-1 13))))))
766 (defun test64-internal (n)
767 (let ((q (make-array (list n n
)))
769 (iterate (for i from
0 below n
)
770 (iterate (for j from
0 below n
)
771 (setf (aref q i j
) (make-variable))
772 (assert! (booleanpv (aref q i j
)))))
773 (iterate (for i from
0 below n
)
775 (iterate (for j from
0 below n
)
776 (setf row
(orv row
(aref q i j
))))
777 (setf top
(andv top row
)))
778 (iterate (for j from
0 below n
)
780 (iterate (for i from
0 below n
)
781 (setf column
(orv column
(aref q i j
))))
782 (setf top
(andv top column
)))
784 (for i from
0 below n
)
786 (for j from
0 below n
)
788 (for k from
0 below n
)
790 (setf top
(andv top
(notv (andv (aref q i j
) (aref q i k
))))))
792 (setf top
(andv top
(notv (andv (aref q i j
) (aref q k j
))))))
793 (if (and (/= k
0) (< (+ i k
) n
) (< (+ j k
) n
))
795 (andv top
(notv (andv (aref q i j
) (aref q
(+ i k
) (+ j k
)))))))
796 (if (and (/= k
0) (< (+ i k
) n
) (>= (- j k
) 0))
798 (andv top
(notv (andv (aref q i j
) (aref q
(+ i k
) (- j k
)))))))
799 (if (and (/= k
0) (>= (- i k
) 0) (< (+ j k
) n
))
801 (andv top
(notv (andv (aref q i j
) (aref q
(- i k
) (+ j k
)))))))
802 (if (and (/= k
0) (>= (- i k
) 0) (>= (- j k
) 0))
804 (andv top
(notv (andv (aref q i j
)
805 (aref q
(- i k
) (- j k
))))))))))
811 (for i from
0 below n
)
812 (iterate (for j from
0 below n
)
813 (in outer
(collect (aref q i j
)))))
814 (static-ordering #'linear-force
))))))
816 (defun test64 () (= (test64-internal 8) 92))
818 (defun test65-internal (n)
819 (let ((q (make-array (list n n
))))
820 (iterate (for i from
0 below n
)
821 (iterate (for j from
0 below n
)
822 (setf (aref q i j
) (make-variable))
823 (assert! (booleanpv (aref q i j
)))))
824 (iterate (for i from
0 below n
)
826 (iterate (for j from
0 below n
)
827 (setf row
(orv row
(aref q i j
))))
829 (iterate (for j from
0 below n
)
831 (iterate (for i from
0 below n
)
832 (setf column
(orv column
(aref q i j
))))
835 (for i from
0 below n
)
837 (for j from
0 below n
)
839 (for k from
0 below n
)
841 (assert! (notv (andv (aref q i j
) (aref q i k
)))))
843 (assert! (notv (andv (aref q i j
) (aref q k j
)))))
844 (if (and (/= k
0) (< (+ i k
) n
) (< (+ j k
) n
))
845 (assert! (notv (andv (aref q i j
) (aref q
(+ i k
) (+ j k
))))))
846 (if (and (/= k
0) (< (+ i k
) n
) (>= (- j k
) 0))
847 (assert! (notv (andv (aref q i j
) (aref q
(+ i k
) (- j k
))))))
848 (if (and (/= k
0) (>= (- i k
) 0) (< (+ j k
) n
))
849 (assert! (notv (andv (aref q i j
) (aref q
(- i k
) (+ j k
))))))
850 (if (and (/= k
0) (>= (- i k
) 0) (>= (- j k
) 0))
851 (assert! (notv (andv (aref q i j
) (aref q
(- i k
) (- j k
)))))))))
856 (for i from
0 below n
)
857 (iterate (for j from
0 below n
)
858 (in outer
(collect (aref q i j
)))))
859 (static-ordering #'linear-force
))))))
861 (defun test65 () (= (test65-internal 8) 92))
864 (let ((x (an-integer-betweenv 1 4))
865 (y (a-member-ofv '(5 7))))
866 (known?
(funcallv #'(lambda (x y z
) (< x y z
)) x y
10))))
869 (let ((x (an-integer-betweenv 1 4))
870 (y (a-member-ofv '(5 7))))
871 (known?
(notv (funcallv #'(lambda (x y z
) (> x y z
)) x y
10)))))
874 (let ((w (an-integer-betweenv 1 4))
875 (x (a-member-ofv '(5 7)))
876 (y (a-member-ofv '(8 10))))
877 (known?
(applyv #'(lambda (w x y z
) (< w x y z
)) w x
(list y
11)))))
880 (let ((w (an-integer-betweenv 1 4))
881 (x (a-member-ofv '(5 7)))
882 (y (a-member-ofv '(8 10))))
883 (known?
(notv (applyv #'(lambda (w x y z
) (> w x y z
)) w x
(list y
11))))))
885 (defun prime-ordeal ()
887 (unless (test1) (format t
"~% Test 1 failed") (setf bug? t
))
888 (unless (test2) (format t
"~% Test 2 failed") (setf bug? t
))
889 (unless (test11) (format t
"~% Test 11 failed") (setf bug? t
))
890 (unless (test12) (format t
"~% Test 12 failed") (setf bug? t
))
891 (unless (test13) (format t
"~% Test 13 failed") (setf bug? t
))
892 (unless (test14) (format t
"~% Test 14 failed") (setf bug? t
))
893 (unless (test15) (format t
"~% Test 15 failed") (setf bug? t
))
894 (unless (test16) (format t
"~% Test 16 failed") (setf bug? t
))
895 (unless (test17) (format t
"~% Test 17 failed") (setf bug? t
))
896 (unless (test18) (format t
"~% Test 18 failed") (setf bug? t
))
897 (unless (test19) (format t
"~% Test 19 failed") (setf bug? t
))
898 (unless (test20) (format t
"~% Test 20 failed") (setf bug? t
))
899 (unless (test21) (format t
"~% Test 21 failed") (setf bug? t
))
900 (unless (test22) (format t
"~% Test 22 failed") (setf bug? t
))
901 (unless (test23) (format t
"~% Test 23 failed") (setf bug? t
))
902 (unless (test24) (format t
"~% Test 24 failed") (setf bug? t
))
903 (unless (test25) (format t
"~% Test 25 failed") (setf bug? t
))
904 (unless (test26) (format t
"~% Test 26 failed") (setf bug? t
))
905 (unless (test27) (format t
"~% Test 27 failed") (setf bug? t
))
906 (unless (test28) (format t
"~% Test 28 failed") (setf bug? t
))
907 (unless (test29) (format t
"~% Test 29 failed") (setf bug? t
))
908 (unless (test30) (format t
"~% Test 30 failed") (setf bug? t
))
909 (unless (test31) (format t
"~% Test 31 failed") (setf bug? t
))
910 (unless (test32) (format t
"~% Test 32 failed") (setf bug? t
))
911 (unless (test33) (format t
"~% Test 33 failed") (setf bug? t
))
912 (unless (test34) (format t
"~% Test 34 failed") (setf bug? t
))
913 (unless (test35) (format t
"~% Test 35 failed") (setf bug? t
))
914 (unless (test36) (format t
"~% Test 36 failed") (setf bug? t
))
915 (unless (test37) (format t
"~% Test 37 failed") (setf bug? t
))
916 (unless (test38) (format t
"~% Test 38 failed") (setf bug? t
))
917 (unless (test39) (format t
"~% Test 39 failed") (setf bug? t
))
918 (unless (test40) (format t
"~% Test 40 failed") (setf bug? t
))
919 (unless (test41) (format t
"~% Test 41 failed") (setf bug? t
))
920 (unless (test42) (format t
"~% Test 42 failed") (setf bug? t
))
921 (unless (test43) (format t
"~% Test 43 failed") (setf bug? t
))
922 (unless (test44) (format t
"~% Test 44 failed") (setf bug? t
))
923 (unless (test45) (format t
"~% Test 45 failed") (setf bug? t
))
924 (unless (test46) (format t
"~% Test 46 failed") (setf bug? t
))
925 (unless (test47) (format t
"~% Test 47 failed") (setf bug? t
))
926 (unless (test48) (format t
"~% Test 48 failed") (setf bug? t
))
927 (unless (test49) (format t
"~% Test 49 failed") (setf bug? t
))
928 (unless (test50) (format t
"~% Test 50 failed") (setf bug? t
))
929 (unless (test51) (format t
"~% Test 51 failed") (setf bug? t
))
930 (unless (test52) (format t
"~% Test 52 failed") (setf bug? t
))
931 (unless (test53) (format t
"~% Test 53 failed") (setf bug? t
))
932 (unless (test54) (format t
"~% Test 54 failed") (setf bug? t
))
933 (unless (test55) (format t
"~% Test 55 failed") (setf bug? t
))
934 (unless (test56) (format t
"~% Test 56 failed") (setf bug? t
))
935 (unless (test57) (format t
"~% Test 57 failed") (setf bug? t
))
936 (unless (test58) (format t
"~% Test 58 failed") (setf bug? t
))
937 (unless (test59) (format t
"~% Test 59 failed") (setf bug? t
))
938 (unless (test60) (format t
"~% Test 60 failed") (setf bug? t
))
939 (unless (test61) (format t
"~% Test 61 failed") (setf bug? t
))
940 (unless (test62) (format t
"~% Test 62 failed") (setf bug? t
))
941 (unless (test63) (format t
"~% Test 63 failed") (setf bug? t
))
942 (unless (test64) (format t
"~% Test 64 failed") (setf bug? t
))
943 (unless (test65) (format t
"~% Test 65 failed") (setf bug? t
))
944 (unless (test66) (format t
"~% Test 66 failed") (setf bug? t
))
945 (unless (test67) (format t
"~% Test 67 failed") (setf bug? t
))
946 (unless (test68) (format t
"~% Test 68 failed") (setf bug? t
))
947 (unless (test69) (format t
"~% Test 69 failed") (setf bug? t
))
948 (if bug?
(error "Screamer has a bug")))
951 ;;; Tam V'Nishlam Shevah L'El Borei Olam