-
Notifications
You must be signed in to change notification settings - Fork 0
/
alchf-rplus-prover.lisp
206 lines (160 loc) · 6.46 KB
/
alchf-rplus-prover.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
;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(define-prover ((abox-sat alchf-rplus abox))
(:init :call-next-method)
(:main
(perform (deterministic-expansion)
(:body
(if clashes
(handle-clashes)
(perform (or-expansion)
(:positive
(if clashes
(handle-clashes)
(restart-main)))
(:negative
(perform (make-models-for-nodes)
(:body
(perform (feature-expansion)
(:positive
(if clashes
(handle-clashes)
(perform (block-nodes :blocked succ)
(:body
(perform (model-merging :node succ)
(:body
(next-round)))))))
(:negative
(perform (some-expansion)
(:positive
(if clashes
(handle-clashes)
(perform (block-nodes :blocked new-node)
(:body
(perform (model-merging :node new-node)
(:body
(next-round)))))))
(:negative
(let ((*blocking-enabled-p* nil))
(perform (make-models-for-nodes)
(:body
(perform (make-models-for-old-nodes)
(:body
(success)))))))))))))))))))
(define-prover ((abox-sat alchf-rplus abox1))
(:init :call-next-method)
(:main
(perform (focused-deterministic-expansion)
(:body
(if clashes
(handle-clashes)
(perform (or-expansion)
(:positive
(if clashes
(handle-clashes)
(restart-main)))
(:negative
(perform (feature-expansion)
(:positive
(if clashes
(handle-clashes)
(perform (block-nodes :blocked succ)
(:body
(perform (model-merging :node succ)
(:body
(next-round)))))))
(:negative
(perform (some-expansion)
(:positive
(if clashes
(handle-clashes)
(perform (block-nodes :blocked new-node)
(:body
(perform (model-merging :node new-node)
(:body
(next-round)))))))
(:negative
(perform (pop-active-nodes-heap)
(:positive
(next-round))
(:negative
(let ((*blocking-enabled-p* nil))
(perform (make-models-for-nodes)
(:body
(perform (make-models-for-old-nodes)
(:body
(success)))))))))))))))))))
#|
(progn
(with-kb (test test :delete-if-exists-p t)
(defrole r :transitive t)
(deffeature f :parents (r))
(unless (sat? (and (some r c) (all r (some r c))) :recompute-p t :debug-p t)
(error "prover error")))
(with-kb (test test :delete-if-exists-p t)
(defrole r :transitive t)
(deffeature f :parents (r))
(unless (sat? (and (some f (and c (some f c)))
(all r (some f d)))
:recompute-p t :debug-p t)
(error "prover error")))
(with-kb (test test :delete-if-exists-p t)
(defrole r :transitive t)
(deffeature f :parents (r))
(when (sat? (and (some f (some f c))
(all r (not d))
(all r (or (not c)
(some f d))))
:recompute-p t :debug-p t)
(error "prover error")))
(with-kb (test test :delete-if-exists-p t)
(defrole r :transitive t)
(deffeature f :parents (r))
(unless (sat? (and (some f (some f c))
(all r (not d))
(all r (or (not c)
(some f d)
(and (some f (some r c))
(all r (some r c))))))
:recompute-p t :debug-p t)
(error "prover error")))
(with-kb (test test :delete-if-exists-p t)
(defrole r :transitive t)
(deffeature f :parents (r))
(when (sat? (and (all r (and (not c) (not e) (not d)))
(some f (some f top))
(all r (or (some f d)
(some f c)
(some f e))))
:recompute-p t
:debug-p t)
(error "prover error")))
(with-kb (test test :delete-if-exists-p t)
;;; interessanter Fall -
;;; hier existiert bereits ein "g"-Nachfolger fuer "a"
;;; wird (a (some f top)) expandiert, dann entsteht ein
;;; neuer "g"-Nachfolger (weil Oberfeature von "f").
;;; da beim ALCHF-Prover aber kein Merging stattfindet,
;;; muss also gleich bei der erzeugenden Feature-Expansion-Rule
;;; darauf geachtet werden, ob bereits Feature-Nachfolger von
;;; Oberfeatures von dem zu erzeugenden Feature-Nachfolger
;;; existieren; in dem Fall muss dieser Knoten genommen werden,
;;; und es darf kein neuer Erzeugt werden! s. Code und Kommentar in
;;; feature-expansion.lisp
;;; Nachtrag: verstehe ich nicht mehr - eigentlich sollte dann dieser
;;; Constraint bereits durch "look-for-somes" bzw. "look-for-featueres"
;;; in deterministic-expansion.lisp as expandiert gekennzeichnet worden sein?
;;; Pruefen!
(deffeature g)
(deffeature f :parents (r g))
(transitive r)
(instance a (all r (not c)))
(related a b g)
(instance a (some f top))
(related b c g)
(instance b (some f c))
(false! (abox-sat? test :debug-p t))))
|#