-
Notifications
You must be signed in to change notification settings - Fork 0
/
abstractions.lisp
900 lines (668 loc) · 40.5 KB
/
abstractions.lisp
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(defvar *prover-main-start-time* nil)
(defvar *prover-init-start-time* nil)
(defmacro announce (message &rest args)
`(progn
(when (or *debug-p* *announce-p*)
(terpri)
(format t ,message ,@args))
t))
(defmacro announce1 (message &rest args)
`(progn
(terpri)
(format t ,message ,@args)
t))
(defmacro defrule (expansion-type (language-type abox-type &key inherit-from args) &body body)
`(eval-when (:compile-toplevel :load-toplevel :execute)
(progn
(defvar1 ,(intern (format nil "*TIME-SPEND-IN-~A*" expansion-type)) 0)
(defmethod ,(intern (string-upcase (format nil "get-code-for-~A" expansion-type)))
((language ,language-type) (abox ,abox-type)
&rest args
&key positive-code negative-code after-successful-clash-repair-code body-code
,@args
&allow-other-keys)
(declare (ignorable positive-code negative-code after-successful-clash-repair-code body-code
,@args))
,(if inherit-from
`(apply
(symbol-function ',(intern (string-upcase (format nil "get-code-for-~A" expansion-type))))
(make-language ',inherit-from)
(make-instance ',abox-type :dont-initialize t)
args)
`(let* ((code
(tree-map #'(lambda (item)
(case item
;; ,@(mapcar #'(lambda (x)
;; `(,x (or ,x ',x)))
;; args)
(+insert-positive-code+ `(progn
(incf ,(intern (format nil "*TIME-SPEND-IN-~A*" ',expansion-type))
(- (get-internal-run-time) *start-time*))
,@(or positive-code (list t))))
(+insert-negative-code+ `(progn
(incf ,(intern (format nil "*TIME-SPEND-IN-~A*" ',expansion-type))
(- (get-internal-run-time) *start-time*))
,@(or negative-code (list t))))
(+insert-after-successful-clash-repair-code+
`(progn ,@after-successful-clash-repair-code))
(+insert-body-code+ `(progn
(incf ,(intern (format nil "*TIME-SPEND-IN-~A*" ',expansion-type))
(- (get-internal-run-time) *start-time*))
,@(or body-code (list t))))
(otherwise item)))
',`(let ((*start-time* (get-internal-run-time)))
(declare (ignorable *start-time*))
,@body)
; ',(cons 'progn body)
))
(let-list (list ,@(mapcar #'(lambda (x)
`(list ',x ,x))
args))))
`(progn
(announce "~%>>> Now performing ~A (Level ~A)~%" ',',expansion-type level)
(let ,let-list
(declare (ignorable ,@(mapcar #'first let-list)))
,code)))))
;;; 2. Method f. (perform! ...)
(defmethod ,(intern (string-upcase (format nil "get-code-for-~A!" expansion-type)))
((language ,language-type) (abox ,abox-type)
&rest args
&key positive-code negative-code after-successful-clash-repair-code body-code
,@args
&allow-other-keys)
(declare (ignorable positive-code negative-code after-successful-clash-repair-code body-code
,@args))
,(if inherit-from
`(apply
(symbol-function ',(intern (string-upcase (format nil "get-code-for-~A!" expansion-type))))
(make-language ',inherit-from)
(make-instance ',abox-type :dont-initialize t)
args)
`(let* ((code
(tree-map #'(lambda (item)
(case item
,@(mapcar #'(lambda (x)
`(,x (or ,x ',x)))
args)
(+insert-positive-code+ `(progn
(incf ,(intern (format nil "*TIME-SPEND-IN-~A*" ',expansion-type))
(- (get-internal-run-time) *start-time*))
,@(or positive-code (list t))))
(+insert-negative-code+ `(progn
(incf ,(intern (format nil "*TIME-SPEND-IN-~A*" ',expansion-type))
(- (get-internal-run-time) *start-time*))
,@(or negative-code (list t))))
(+insert-after-successful-clash-repair-code+
`(progn ,@after-successful-clash-repair-code))
(+insert-body-code+ `(progn
(incf ,(intern (format nil "*TIME-SPEND-IN-~A*" ',expansion-type))
(- (get-internal-run-time) *start-time*))
,@(or body-code (list t))))
(otherwise item)))
',`(let ((*start-time* (get-internal-run-time)))
(declare (ignorable *start-time*))
,@body))))
`(progn
(announce "~%>>> Now performing ~A (Level ~A)~%" ',',expansion-type level)
,code)))))))
#|
(defun show-incarnation-info (type)
(format t "~%~%***** ~A OF ~A : ~A, TBOX ~A
LANGUAGE: ~A
NODES: ~A
EDGES: ~A
----------------------
BLOCKING ENABLED: ~A
DYNAMIC BLOCKING: ~A
----------------------
COMBINED-SOME-ALL: ~A
DELETE NODES: ~A
REUSE NODES: ~A
ALL COMPLETIONS: ~A
MAINTAIN STATE: ~A
KEEP DET. ASSERT.: ~A
----------------------
MODEL CACHING: ~A
SUBTABLEAU CACHING: ~A
USE CACHED MODELS: ~A
USE UNSAT CACHE: ~A
----------------------
COMPUTE CORE MODEL: ~A
STORE IND MODELS: ~A
STORE RETR.MODEL: ~A
----------------------
SEMANTIC BRANCHING: ~A
NON DETERMINISM: ~A
----------------------
TBOX: ~A
STORE: ~A
META CONSTRAINTS: ~A~%~%"
type
*cur-abox* (type-of *cur-abox*) (tbox *cur-abox*)
(type-of *language*)
(no-of-nodes *cur-abox*)
(no-of-edges *cur-abox*)
*blocking-enabled-p*
*dynamic-blocking-p*
*combined-some-all-rule-p*
*delete-nodes-p*
*reuse-nodes-p*
*compute-all-completions-p*
*maintain-prover-state-p*
*keep-det-assertions-p*
*cache-models-p*
*subtableau-caching-p*
*use-cached-models-p*
*use-unsat-cache-p*
*compute-core-model-p*
*store-ind-models-p*
*store-instance-retrieval-model-p*
*semantic-branching-p*
*non-determinism-p*
*cur-tbox*
*cur-store*
*meta-constraints*))
|#
(defun show-incarnation-info (type)
(format t "~%~%***** ~A OF ~A : ~A, TBOX ~A
LANGUAGE: ~A
NODES: ~A
EDGES: ~A
-------------------------------------------------------------"
type
*cur-abox* (type-of *cur-abox*) (tbox *cur-abox*)
(type-of *language*)
(no-of-nodes *cur-abox*)
(no-of-edges *cur-abox*))
(dolist (slot *prover-specials*)
(when (and (boundp slot)
(or (member (symbol-value slot) '(t nil))
(member slot '(*strategy*))
(numberp (symbol-value slot))))
(format t "~%~57,A : ~A"
slot
(symbol-value slot)))))
(defmacro define-prover ( ( (prover-name language-type abox-type) &body keylist) &body body)
(when (and keylist (not (eq (first keylist) '&key)))
(error "Bad syntax! ~A" keylist))
(let* ((init-code
(rest (assoc :init body)))
(rollback-code
(rest (assoc :rollback body)))
(main-code
(rest (assoc :main body)))
(success-code
(rest (assoc :success body)))
(keys (remove :init
(remove :main
(remove :rollback
(remove :success
(mapcar #'first (mapcar #'ensure-list (rest keylist)))))))))
(setf *language-dispatcher* (make-language language-type)
*abox-dispatcher* (make-instance abox-type :dont-initialize t))
`(progn
,@(when init-code
`(,@(unless (member (first init-code) '(:copy :inherit-from :call-next-method))
`((defmethod get-init-code ((name (eql (quote ,prover-name))) (language ,language-type)
(abox ,abox-type))
(quote ,init-code))))
,@(when (eq (first init-code) :call-next-method)
`((defmethod get-init-code ((name (eql (quote ,prover-name))) (language ,language-type)
(abox ,abox-type))
(call-next-method))))
(defvar1 ,(intern (format nil "*TIME-SPEND-IN-PROVER-INIT-~A-~A*"
prover-name language-type))
0)
(defvar1 ,(intern (format nil "*TIME-SPEND-IN-PROVER-INIT-BEFORE-MAIN-~A-~A*"
prover-name language-type))
0)
(defvar1 ,(intern (format nil "*TIME-SPEND-IN-PROVER-MAIN-~A-~A*"
prover-name language-type))
0)
;;;
;;; INIT
;;;
(defmethod prover-init ((name (eql (quote ,prover-name))) (language ,language-type) (abox ,abox-type)
&key
(meta-constraints nil meta-constraints-specified-p)
(tbox nil tbox-specified-p)
(how-many nil how-many-specified-p)
(debug-p nil debug-specified-p)
(break-p nil break-specified-p)
(visualize-p nil visualize-specified-p)
(completion-found-hook nil completion-found-hook-specified-p)
(reuse-nodes-p nil reuse-nodes-specified-p)
(compute-all-completions-p nil compute-all-completions-specified-p)
(maintain-prover-state-p nil maintain-prover-state-specified-p)
(blocking-enabled-p nil blocking-enabled-specified-p)
(delete-nodes-p nil delete-nodes-specified-p)
(semantic-branching-p nil semantic-branching-specified-p)
(non-determinism-p nil non-determinism-specified-p)
(use-cached-models-p nil use-cached-models-specified-p)
(use-unsat-cache-p nil use-unsat-cache-specified-p)
(cache-models-p nil cache-models-specified-p)
(store-ind-models-p nil store-ind-models-specified-p)
(compute-core-model-p nil compute-core-model-specified-p)
(keep-det-assertions-p nil keep-det-assertions-specified-p)
(store-instance-retrieval-model-p nil store-instance-retrieval-model-specified-p)
(subtableau-caching-p nil subtableau-caching-specified-p)
,@(rest keylist) &allow-other-keys)
(declare (ignorable ,@keys))
(with-prover-standard-settings
(let* ((level 'prover-init)
(start-time (get-internal-run-time))
(rollback-to-action nil)
;;;
;;;
;;;
(*dont-invalidate-store-p* t)
(*maintain-history-p* t)
;;;
;;;
;;;
(*cur-abox* abox)
(*cur-tbox*
(or tbox
(tbox *cur-abox*)))
(*cur-store*
(concept-store *cur-tbox*))
(*cur-rbox* (rbox *cur-tbox*))
#+:use-membership-tables
(*unexpanded-table* (unexpanded-table *cur-abox*))
#+:use-membership-tables
(*expanded-table* (expanded-table *cur-abox*))
(*language* language))
(declare (ignorable level rollback-to-action))
(setf *prover-main-start-time* nil
*prover-init-start-time* (get-internal-run-time))
(with-concept-store (*cur-store*)
(let* ((*meta-constraints*
(if meta-constraints-specified-p
(append meta-constraints
(get-meta-constraints *cur-tbox*))
(get-meta-constraints *cur-tbox*)))
(*blocking-enabled-p*
(when
(if blocking-enabled-specified-p
blocking-enabled-p
(or *blocking-enabled-p*
*meta-constraints*
(needs-blocking-p *cur-tbox*)
(get-all-transitive-roles *cur-tbox*)))
t))
(*dynamic-blocking-p*
(and *blocking-enabled-p*
(is-dl-with-inverse-roles-p *language*)))
(*combined-some-all-rule-p*
(is-dl-with-combined-some-all-rule-p *language*))
(*propagation-of-transitive-all-concepts-p*
(and (is-dl-with-transitive-roles-p *language*)
(not *combined-some-all-rule-p*)
(get-all-transitive-roles *cur-tbox*)))
;;;
;;;
;;;
(*maintain-prover-state-p*
(if maintain-prover-state-specified-p
maintain-prover-state-p
*maintain-prover-state-p*))
(*delete-nodes-p*
(if delete-nodes-specified-p
delete-nodes-p
*delete-nodes-p*))
(*reuse-nodes-p*
(or (if reuse-nodes-specified-p
reuse-nodes-p
*reuse-nodes-p*)
(is-dl-with-rolebox-p language)))
;;;
;;;
;;;
(*semantic-branching-p*
(if semantic-branching-specified-p
semantic-branching-p
*semantic-branching-p*))
(*non-determinism-p*
(if non-determinism-specified-p
non-determinism-p
*non-determinism-p*))
;;;
;;;
;;;
(*use-cached-models-p*
(if use-cached-models-specified-p
use-cached-models-p
*use-cached-models-p*))
(*use-unsat-cache-p*
(if use-unsat-cache-specified-p
use-unsat-cache-p
*use-unsat-cache-p*))
(*cache-models-p*
(if cache-models-specified-p
cache-models-p
*cache-models-p*))
(*subtableau-caching-p*
(if subtableau-caching-specified-p
subtableau-caching-p
*subtableau-caching-p*))
(*store-ind-models-p*
(if store-ind-models-specified-p
store-ind-models-p
*store-ind-models-p*))
(*store-instance-retrieval-model-p*
(if store-instance-retrieval-model-specified-p
store-instance-retrieval-model-p
*store-instance-retrieval-model-p*))
(*compute-core-model-p*
(or (if compute-core-model-specified-p
compute-core-model-p
*compute-core-model-p*)
*store-instance-retrieval-model-p*))
(*keep-det-assertions-p*
(or *compute-core-model-p*
(if keep-det-assertions-specified-p
keep-det-assertions-p
*keep-det-assertions-p*)))
;;;
;;;
;;;
(*how-many*
(if how-many-specified-p
how-many
*how-many*))
(*debug-p*
(if debug-specified-p
debug-p
*debug-p*))
(*break-p*
(if break-specified-p
break-p
*break-p*))
(*visualize-p*
(if visualize-specified-p
visualize-p
*visualize-p*))
(*compute-all-completions-p*
(if compute-all-completions-specified-p
compute-all-completions-p
*compute-all-completions-p*))
(*completion-found-hook*
(if completion-found-hook-specified-p
completion-found-hook
*completion-found-hook*))
;;;
;;;
;;;
(next-round-p nil)
,@(when keys
(mapcar #'(lambda (key)
(list
(intern (format nil "*~A*" key))
key))
keys)))
(declare (special ,@(mapcar #'(lambda (key)
(intern (format nil "*~A*" key)))
keys)))
(declare (ignorable ,@(mapcar #'(lambda (key)
(intern (format nil "*~A*" key)))
keys)))
(declare (ignorable next-round-p level))
(when (and *keep-det-assertions-p* *maintain-prover-state-p*)
(error "Both *keep-det-assertions-p* and *maintain-prover-state-p* specified."))
(when (and *compute-core-model-p* *delete-nodes-p*)
(error "Both *compute-core-model-p* and *delete-noeds-p* specified."))
(when (not (or *maintain-prover-state-p*
*keep-det-assertions-p*))
(setf (action-timestamp-counter *cur-abox*) 0
(current-action *cur-abox*) nil
(choice-point-counter *cur-abox*) 0
rollback-to-action (get-current-action)))
(mapc #'delete-abox *completions*)
(setf *completions* nil)
(when (or *debug-p* *show-prover-incarnations-p*)
(show-incarnation-info 'sat-testing)
(describe-object abox t)
(loop-over-abox-nodes (node abox)
(describe-object node t) (terpri) (terpri)))
(unless (prepared-p *cur-store*)
(error "Store ~A is not prepared!" *cur-store*))
(unless (prepared-p *cur-tbox*)
(error "TBox ~A is not prepared!" *cur-tbox*))
(unless (prepared-p *cur-abox*)
(error "ABox ~A is not prepared!" *cur-abox*))
(catch 'exit
(let ((res
(multiple-value-list
(progn
,@(cond ((member (first init-code) '(:copy :call-next-method))
(get-init-code prover-name *language-dispatcher* *abox-dispatcher*))
((eq (first init-code) :inherit-from)
(get-init-code prover-name
(make-language (second init-code))
(make-instance (third init-code) :dont-initialize t)))
(t init-code))))))
(when *prover-main-start-time*
(incf ,(intern (format nil "*TIME-SPEND-IN-PROVER-MAIN-~A-~A*"
prover-name language-type))
(- (get-internal-run-time) *prover-main-start-time*)))
(when (first res) ; erfuellbar?
(let ((*maintain-history-p* nil))
(cond (*keep-det-assertions-p*
(announce "Now computing deterministic assertions")
(delete-non-det-assertions *cur-abox*)
(when *compute-core-model-p*
(announce "Now computing core model")
(compute-core-model *cur-abox*))
(when *store-instance-retrieval-model-p*
(let ((root-node (find-node *cur-abox* 1)))
(unless root-node
(error "root node?!"))
(announce "Now making instance retrieval models for ~A"
(first (last (told-concepts root-node))))
(unless (core-model root-node)
(error "no core model for root node?"))
(announce "Adding ~A (core model of root node) as instance retrieval model of concept ~A"
(core-model root-node)
(first (last (told-concepts root-node))))
(setf (instance-retrieval-model
(first (last (told-concepts root-node))))
(core-model root-node))))
;;; ist richtig, denn die beibehaltenen Assertionen
;;; erscheinen nun auf TOLD CONCEPTS!
(loop-over-abox-nodes (node abox)
(setf (slot-value node 'choice-points) nil)
(setf (slot-value node 'initial-concept) nil)
(reset-label (description node))))
((not *maintain-prover-state-p*)
,(if rollback-code
`(progn ,@rollback-code)
`(rollback))))))
(incf ,(intern (format nil "*TIME-SPEND-IN-PROVER-INIT-~A-~A*"
prover-name language-type))
(- (get-internal-run-time) start-time))
(values-list res))))))))))
;;;
;;; MAIN
;;;
,@(when main-code
`(,@(unless (member (first main-code) '(:copy :inherit-from :call-next-method))
`((defmethod get-main-code ((name (eql (quote ,prover-name))) (language ,language-type)
(abox ,abox-type))
(quote ,main-code))))
,@(when (eq (first main-code) :call-next-method)
`((defmethod get-main-code ((name (eql (quote ,prover-name))) (language ,language-type)
(abox ,abox-type))
(call-next-method))))
(defmethod prover-main ((name (eql (quote ,prover-name))) (language ,language-type) (abox ,abox-type)
&key
(level 0)
,@(rest keylist) &allow-other-keys)
(declare (ignorable ,@keys))
(setf *abox* abox)
(unless *prover-main-start-time* ; bei der ersten Inkarnation setzen
(setf *prover-main-start-time* (get-internal-run-time))
(unless *prover-init-start-time* (error "No prover init start time?!"))
(unless ,(intern (format nil "*TIME-SPEND-IN-PROVER-INIT-BEFORE-MAIN-~A-~A*"
prover-name language-type))
(error "!"))
(incf ,(intern (format nil "*TIME-SPEND-IN-PROVER-INIT-BEFORE-MAIN-~A-~A*"
prover-name language-type))
(- (get-internal-run-time) *prover-init-start-time*)))
(let ((level (1+ level))
(next-round-p t)
(round 0)
(return-value nil))
(declare (ignorable next-round-p level))
(loop while next-round-p do
(incf round)
(setf next-round-p nil)
(when (or *debug-p* (and *show-prover-incarnations-p* (= 1 level)))
(show-incarnation-info 'prover-main))
(when *debug-p*
(format t "~%~%-----------------------------------------------------------------------------------")
(format t "~%**** INCARNATION LEVEL ~A, ROUND ~A OF PROVER ~A *****~%~%" level round ',language-type)
(describe-object abox t)
(loop-over-abox-nodes (node abox)
(describe-object node t) (terpri) (terpri)))
(setf return-value
(multiple-value-list
(progn
,@(cond ((member (first main-code) '(:copy :call-next-method))
(get-main-code prover-name *language-dispatcher* *abox-dispatcher*))
((eq (first main-code) :inherit-from)
(get-main-code prover-name
(make-language (second main-code))
(make-instance (third main-code) :dont-initialize t)))
(t main-code)))))
finally return (values-list return-value)
)))))
;;;
;;; SUCCESS
;;;
,@(when success-code
`(,@(unless (member (first success-code) '(:copy :inherit-from :call-next-method))
`((defmethod get-success-code ((name (eql (quote ,prover-name))) (language ,language-type)
(abox ,abox-type))
(quote ,success-code))))
,@(when (eq (first success-code) :call-next-method)
`((defmethod get-success-code ((name (eql (quote ,prover-name))) (language ,language-type)
(abox ,abox-type))
(call-next-method))))
(defmethod prover-success ((name (eql (quote ,prover-name))) (language ,language-type) (abox ,abox-type)
&key
,@(rest keylist) &allow-other-keys)
(declare (ignorable ,@keys))
(setf (slot-value abox 'satisfiable) t)
,@(cond ((member (first success-code) '(:copy :call-next-method))
(get-success-code prover-name *language-dispatcher* *abox-dispatcher*))
((eq (first success-code) :inherit-from)
(get-success-code prover-name
(make-language (second success-code))
(make-instance (third success-code) :dont-initialize t)))
(t success-code))))))))
;;;
;;;
;;;
(defmacro perform ( ( expansion-type &rest args &key abox-type language-type &allow-other-keys) &body body )
(let ((positive-code
(rest (assoc :positive body)))
(negative-code
(rest (assoc :negative body)))
(body
(rest (assoc :body body)))
(after-successful-clash-repair
(rest (assoc :after-successful-clash-repair body)))
(abox (if abox-type
(make-instance abox-type :dont-initialize t)
*abox-dispatcher*))
(language (if language-type
(make-instance language-type :dont-initialize t)
*language-dispatcher*)))
`(unless next-round-p
(block prover
,(apply (symbol-function (intern (string-upcase (format nil "get-code-for-~A" expansion-type))))
language abox
:positive-code positive-code
:negative-code negative-code
:after-successful-clash-repair-code after-successful-clash-repair
:body-code body
args)))))
(defmacro perform! ( ( expansion-type &rest args &key abox-type language-type &allow-other-keys) &body body )
(let ((positive-code
(rest (assoc :positive body)))
(negative-code
(rest (assoc :negative body)))
(body
(rest (assoc :body body)))
(after-successful-clash-repair
(rest (assoc :after-successful-clash-repair body)))
(abox (if abox-type
(make-instance abox-type :dont-initialize t)
*abox-dispatcher*))
(language (if language-type
(make-instance language-type :dont-initialize t)
*language-dispatcher*)))
`(unless next-round-p
(block prover
,(apply (symbol-function (intern (string-upcase (format nil "get-code-for-~A!" expansion-type))))
language abox
:positive-code positive-code
:negative-code negative-code
:after-successful-clash-repair-code after-successful-clash-repair
:body-code body
args)))))
;;;
;;;
;;;
(defmacro rollback ()
`(rollback-to abox rollback-to-action))
(defmacro success ()
`(prover-success name language abox))
(defmacro start-main ()
`(prover-main name language abox))
(defmacro restart-main ()
`(prover-main name language abox :level level))
(defmacro next-round ()
`(setf next-round-p t))
;;;
;;;
;;;
(defmacro completion-found ()
`(progn
(announce "COMPLETION FOUND!~%~%")
(let ((bad-nodes
(remove-if #'(lambda (x)
(or (not (active-p x))
(complete-p x)
(blocked-p x)
(cache-satisfiable-p x)))
(get-nodes abox))))
(when (some #'(lambda (x)
(and (active-p x)
(blocked-p x)))
(get-nodes abox))
(error "Strategy error!"))
(when bad-nodes
(dolist (node bad-nodes)
(describe-object node t))
(error "Strategy error: Nodes ~A are not complete" bad-nodes)))
(cond (*visualize-p*
(visualize abox)
(break))
(*completion-found-hook*
(funcall *completion-found-hook* abox)))
(when (and *break-p*
(not *visualize-p*))
(break))
(when *compute-all-completions-p*
(push (copy abox) *completions*)
(when (and *how-many*
(>= (length *completions*)
*how-many*))
(throw 'exit t)))
t))