id
int64 0
45.1k
| file_name
stringlengths 4
68
| file_path
stringlengths 14
193
| content
stringlengths 32
9.62M
| size
int64 32
9.62M
| language
stringclasses 1
value | extension
stringclasses 6
values | total_lines
int64 1
136k
| avg_line_length
float64 3
903k
| max_line_length
int64 3
4.51M
| alphanum_fraction
float64 0
1
| repo_name
stringclasses 779
values | repo_stars
int64 0
882
| repo_forks
int64 0
108
| repo_open_issues
int64 0
90
| repo_license
stringclasses 8
values | repo_extraction_date
stringclasses 146
values | sha
stringlengths 64
64
| __index_level_0__
int64 0
45.1k
| exdup_ids_cmlisp_stkv2
sequencelengths 1
47
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
12,505 | graph-visualizer3.lisp | lambdamikel_DLMAPS/src/graph-visualizer/graph-visualizer3.lisp | ;;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: GRAPH -*-
(in-package graph)
;;;
;;;
#|
(defmethod (setf bound-by) (val (object graph-item))
(if val
(mark object val)
(unmark object)))
(defmethod bound-by ((object graph-item))
(marked-p object))
|#
;;;
;;; Graph Visualizer
;;;
#|
(defconstant +text-style+
(make-text-style :sans-serif
:bold
:normal))
|#
(defconstant +text-style+
(make-text-style nil
:bold
:very-large))
(defconstant +button-text-style+
(make-text-style :sans-serif
:roman
:very-small))
(defvar *node-kinds* nil)
(defvar *edge-kinds* nil)
(defvar *graph* nil)
(defvar *selected-object* nil)
;;;
;;;
;;;
(defconstant +node-body-color+ +blue+)
(defconstant +node-contur-color+ +blue+)
(defconstant +edge-color+ +black+)
(defconstant +node-text-color+ +black+)
(defconstant +edge-text-color+ +black+)
(defconstant +node-colors+
(make-cyclic
(mapcar #'(lambda (rgb)
(make-rgb-color (first rgb)
(second rgb)
(third rgb)))
'((0 0 0)
(0 0 1) (0 1 0) (1 0 0)
(0 1 1) (1 1 0) (1 0 1)
(0 0 .6) (0 .6 0) (.6 0 0)
(0 .6 .6) (.6 .6 0) (.6 0 .6)
(.6 .6 .6)
(0 0 .5) (0 .5 0) (.5 0 0)
(0 .5 .5) (.5 .5 0) (.5 0 .5)
(.5 .5 .5)
(0 0 .4) (0 .4 0) (.4 0 0)
(0 .4 .4) (.4 .4 0) (.4 0 .4)
(.4 .4 .4)
(0 0 .3) (0 .3 0) (.3 0 0)
(0 .3 .3) (.3 .3 0) (.3 0 .3)
(.3 .3 .3)
(0 0 .2) (0 .2 0) (.2 0 0)
(0 .2 .2) (.2 .2 0) (.2 0 .2)
(.2 .2 .2)
(0 0 .1) (0 .1 0) (.1 0 0)
(0 .1 .1) (.1 .1 0) (.1 0 .1)
(.1 .1 .1)))))
(defconstant +edge-colors+ +node-colors+)
(defmethod color :around ((node node))
(let ((kind (kind node)))
(if (and (compute-color-from-kind-p node) kind)
(if *node-kinds*
(let ((pos (position kind *node-kinds* :test #'equal)))
(if pos
(nth pos +node-colors+)
(progn
(pushend kind *node-kinds*)
(nth (1- (length *node-kinds*)) +node-colors+))))
(progn
(setf *node-kinds* (list kind))
(nth 0 +node-colors+)))
(call-next-method))))
(defmethod color :around ((edge edge))
(let ((kind (kind edge)))
(if (and (compute-color-from-kind-p edge) kind)
(if *edge-kinds*
(let ((pos (position kind *edge-kinds* :test #'equal)))
(if pos
(nth pos +edge-colors+)
(progn
(pushend kind *edge-kinds*)
(nth (1- (length *edge-kinds*)) +edge-colors+))))
(progn
(setf *edge-kinds* (list kind))
(nth 0 +edge-colors+)))
(call-next-method))))
(defun reset-kinds ()
(setf *node-kinds* nil
*edge-kinds* nil))
;;;
;;;
;;;
(defvar *graph-visualizer* nil)
(defmacro with-graph-visualizer ((frame) &rest body)
`(let ((,frame *graph-visualizer*))
,@body))
(define-application-frame graph-visualizer ()
((bar :accessor bar :initform nil)
(resizer :accessor resizer :initform nil)
(process :initform nil
:accessor process)
(scale :initform 1 :reader scale)
(graphs :initform nil :reader graphs :initarg :graphs)
(graph :initform nil :reader graph :initarg :graph)
(kind-of-graph :initform 'polygon
:accessor kind-of-graph)
;;; Darstellungsoptionen
(show-nodes-p :initform t
:accessor show-nodes-p)
(show-edges-p :initform t
:accessor show-edges-p)
(show-node-info-p :initform t
:accessor show-node-info-p)
(show-edge-info-p :initform t
:accessor edge-info-p)
(show-color-nodes-p :initform t
:accessor show-color-nodes-p)
(show-color-edges-p :initform t
:accessor show-color-edges-p)
(show-backward-edges-p :initform t
:accessor show-backward-edges-p)
(show-forward-edges-p :initform t
:accessor show-forward-edges-p)
(show-loops-p :initform t
:accessor show-loops-p))
(:panes
(refresh-button (make-pane 'push-button
:label "Refresh"
:text-style +button-text-style+
:activate-callback #'(lambda (x)
(declare (ignore x))
(refresh))))
(new-button (make-pane 'push-button
:label "New"
:text-style +button-text-style+
:activate-callback #'(lambda (x)
(declare (ignore x))
(com-new) (refresh))))
(delete-button (make-pane 'push-button
:label "Delete"
:text-style +button-text-style+
:activate-callback #'(lambda (x)
(declare (ignore x))
(com-delete) (refresh))))
(delete-others-button (make-pane 'push-button
:label "Delete Others"
:text-style +button-text-style+
:activate-callback #'(lambda (x)
(declare (ignore x))
(com-delete-others) (refresh))))
(next-button (make-pane 'push-button
:label ">>"
:text-style +button-text-style+
:activate-callback #'(lambda (x)
(declare (ignore x))
(com-next) (refresh))))
(prev-button (make-pane 'push-button
:label "<<"
:text-style +button-text-style+
:activate-callback #'(lambda (x)
(declare (ignore x))
(com-prev) (refresh))))
(quit-button (make-pane 'push-button
:label "Quit"
:text-style +button-text-style+
:activate-callback #'(lambda (x)
(declare (ignore x))
(com-quit) (refresh))))
(display :application
:display-function #'draw-graph-visualizer
:incremental-redisplay t
:text-cursor nil
:borders t
:scroll-bars t)
(infopane :application
:text-style +text-style+
:text-cursor nil
:end-of-line-action :allow
:scroll-bars :both)
(info :application
:text-style +text-style+
:display-function
#'show-infos
:height '(2 :line)
:min-height '(2 :line)
:max-height '(2 :line)
:text-cursor nil
:end-of-line-action :allow
:text-margin 30
:scroll-bars nil)
(options :accept-values
:text-style +button-text-style+
:scroll-bars nil
:height '(2 :line)
:min-height '(2 :line)
:max-height '(2 :line)
:display-function
`(accept-values-pane-displayer
:displayer ,#'(lambda (frame stream)
(accept-options frame stream))))
(bar (setf *bar*
(make-pane 'slider
:show-value-p t
:text-style +button-text-style+
:value-changed-callback #'(lambda (slider value)
(declare (ignore slider))
(with-graph-visualizer (frame)
(with-slots (graph graphs) frame
(setf graph
(nth (round (* (/ value 100)
(1- (length graphs))))
graphs))
(refresh))))
:min-value 0 :max-value 100
:client 'bar
:id 'bar)))
(resizer (setf *resizer*
(make-pane 'slider
:show-value-p t
:text-style +button-text-style+
:value-changed-callback #'(lambda (slider value)
(declare (ignore slider))
(with-graph-visualizer (frame)
(with-slots (scale) frame
(setf scale value)
(refresh))))
:min-value 1 :max-value 10
:number-of-tick-marks 10
:number-of-quanta 20
:client 'resizer
:id 'resizer))))
(:layouts
(:default
#+(and :lispworks :win32)
(vertically ()
(2/3
(vertically ()
options
info
display
(horizontally ()
(1/4 new-button)
(1/4 delete-button)
(1/4 delete-others-button)
(1/4 quit-button)
+fill+)
(horizontally ()
(1/3 prev-button)
(1/3 refresh-button)
(1/3 next-button)
+fill+)
(horizontally ()
(1/2 bar)
(1/2 resizer)
+fill+)))
(1/3 infopane))
#-(and :lispworks :win32)
(vertically ()
(2/3
(vertically ()
options
info
display
(horizontally ()
(1/4 new-button)
(1/4 delete-button)
(1/4 delete-others-button)
(1/4 quit-button))
(horizontally ()
(1/9 prev-button)
(1/9 next-button)
(1/9 refresh-button)
(3/9 bar)
(3/9 resizer))))
(1/3 infopane)))))
;;;
;;; Drawing Functions
;;;
(defmethod show-infos ((frame graph-visualizer) stream)
(with-slots (graph graphs) frame
(when (and graph graphs)
(format stream "Number of Objects: ~A. Current Object: ~A. Info: ~A~%"
(length graphs)
(position graph graphs)
(info (graph frame))))))
(defun get-node-size ()
(with-graph-visualizer (frame)
(with-slots (graph) frame
(let* ((size (no-of-nodes graph))
(node-radius (/ 15 (max 1 size))))
node-radius))))
(defmethod draw-graph-visualizer ((frame graph-visualizer) stream &optional window-stream)
(when (graph frame)
(with-slots (graph scale
kind-of-graph
show-nodes-p show-edges-p
show-node-info-p show-edge-info-p
show-color-nodes-p show-color-edges-p
show-backward-edges-p show-forward-edges-p show-loops-p) frame
(multiple-value-bind (x y)
(bounding-rectangle-size (if window-stream
(bounding-rectangle (window-viewport window-stream))
(bounding-rectangle (window-viewport stream))))
(let* ((s (* 1.5 (* x (/ (get-node-size) 100))))
(x (- x (* 2 s)))
(y (- y (* 2 s))))
(with-translation (stream s s)
(with-translation (stream (if (eq kind-of-graph 'chain)
0
0)
(if (eq kind-of-graph 'chain)
(cond((and show-backward-edges-p
show-forward-edges-p)
(/ y 2))
(show-forward-edges-p
y)
(show-backward-edges-p
0)
(t y))
y))
(with-scaling (stream scale scale)
(with-scaling (stream (/ x 100)
(if (and show-backward-edges-p
show-forward-edges-p
(eq kind-of-graph 'chain))
(/ y 200)
(/ y 100)))
(setf *graph* graph)
(with-text-size (stream (if window-stream
:very-large
:small))
(draw-graph graph stream kind-of-graph
:print-p window-stream
:show-nodes-p show-nodes-p
:show-edges-p show-edges-p
:show-node-info-p show-node-info-p
:show-edge-info-p show-edge-info-p
:show-color-nodes-p show-color-nodes-p
:show-color-edges-p show-color-edges-p
:show-backward-edges-p show-backward-edges-p
:show-forward-edges-p show-forward-edges-p
:show-loops-p show-loops-p)))))))))))
;;;
;;; External Interface
;;;
(defmethod (setf graph) (value (frame graph-visualizer))
(with-slots (graphs graph bar) frame
(setf graph value)
(if (and graphs graph)
(let ((l (length graphs)))
(setf (gadget-value bar)
(* 100 (/ (position graph graphs) (max 1 (1- l)))))
(when bar (activate-gadget bar)))
(when bar (deactivate-gadget bar)))))
(defmethod (setf graphs) (value (frame graph-visualizer))
(with-slots (bar graphs graph) frame
(cond ((null value)
(setf graphs nil)
(setf graph nil)
(when bar (deactivate-gadget bar)))
((or (not (consp value))
(not (every #'(lambda (x)
(typep x 'graph))
value)))
(error "Bad objects in list!"))
(t
(setf graphs value)
(setf graph (first value))
(when bar (activate-gadget bar))))))
(defun set-objects (objects)
(with-graph-visualizer (frame)
(setf (graphs frame) objects)))
(defun prepend-objects (objects)
(with-graph-visualizer (frame)
(setf (graphs frame)
(append (graphs frame) objects))))
(defun append-objects (objects)
(with-graph-visualizer (frame)
(setf (graphs frame)
(append objects (graphs frame)))))
;;;
;;; Commands: Navigation
;;;
(define-graph-visualizer-command (com-delete :name "Delete" )
()
(with-graph-visualizer (frame)
(with-slots (graph graphs) frame
(when (and graph graphs)
(let ((ograph1 graph))
(com-next)
(if (cdr graphs)
(setf (graphs frame)
(delete ograph1 graphs))
(com-new)))))))
(define-graph-visualizer-command (com-next :name "Next" )
()
(with-graph-visualizer (frame)
(with-slots (graphs graph) frame
(let ((rest (member graph graphs)))
(setf (graph frame) ;; wichtig! accessor verwenden!
(if (cdr rest)
(first (cdr rest))
(first graphs)))))))
(define-graph-visualizer-command (com-prev :name "Prev" )
()
(with-graph-visualizer (frame)
(with-slots (graph graphs) frame
(let* ((rev (reverse graphs))
(rest (member graph rev)))
(setf (graph frame)
(if (cdr rest)
(first (cdr rest))
(first rev)))))))
(define-graph-visualizer-command (com-quit :name "Quit" )
()
(with-graph-visualizer (frame)
(with-slots (process) frame
(when process
#+:allegro
(mp:process-kill process))))
(with-graph-visualizer (frame)
(frame-exit frame)))
(define-graph-visualizer-command (com-new :name "New" )
()
(with-graph-visualizer (frame)
(setf (graphs frame) nil)))
(define-graph-visualizer-command (com-delete-others :name "Delete Others" )
()
(with-graph-visualizer (frame)
(setf (graphs frame)
(list (graph frame)))))
(define-graph-visualizer-command (com-refresh :name "Refresh" )
()
(refresh))
(defun refresh ()
(with-graph-visualizer (frame)
(dolist (pane '(display info))
(redisplay-frame-pane frame pane))))
;;;
;;; Graphik
;;;
(defun draw-marker (stream direction posx posy size)
(draw-arrow* stream posx posy (+ posx (* direction 2)) posy
:head-length (max 2 (/ 20 size))
:head-width (max 2 (/ 20 size))))
(defmethod item-pos ((node node))
(get-node-position (in-graph node) node))
(defmethod draw-graph ((graph graph) (stream stream) (kind-of-graph (eql 'chain))
&key
show-nodes-p
show-edges-p
show-node-info-p
show-edge-info-p
show-color-nodes-p
show-color-edges-p
show-backward-edges-p
show-forward-edges-p
show-loops-p
print-p)
(declare (ignore print-p))
(let* ((nodes (get-nodes graph))
(edges (get-edges graph))
(size (length nodes)))
(when nodes
(let* ((stepx (/ 100 (max 1 (1- size))))
(stepy (/ 100 (max 1 (1- size))))
(node-radius (get-node-size))
(loop-radius (/ node-radius 2))
(looptext-y loop-radius))
(when show-edges-p
(let ((edgeclusters nil))
(dolist (edge edges)
(with-slots (from to) edge
(let* ((from (item-pos from))
(to (item-pos to))
(found (find-if #'(lambda (x)
(and (equal (first x) from)
(equal (second x) to)))
edgeclusters)))
(if found
(push edge (third found))
(push (list from to (list edge)) edgeclusters)))))
(dolist (edgecluster edgeclusters)
(let* ((count (length (third edgecluster)))
(finestepy (/ stepy count))
(num 0))
(dolist (edge (third edgecluster))
(incf num)
(with-slots (from to) edge
(let ((from (item-pos from))
(to (item-pos to)))
(when (and from to)
(with-drawing-options (stream :ink (if show-color-edges-p
(color edge)
+edge-color+))
(let* ((height (- to from))
(y (+ (* (1- height) stepy)
(* num finestepy)))
(ym (+ (* (1- (abs height)) stepy)
(* num finestepy))))
(with-output-as-presentation (stream edge 'edge)
(cond ((and (zerop height) show-loops-p)
(draw-circle* stream
(+ (* to stepx) (* num (/ node-radius count)))
0
node-radius
:filled nil
:line-thickness 2)
(when show-edge-info-p
(draw-text* stream
(format nil "~A" (info edge
:for-graph-visualizer-p t))
(+ (* to stepx) node-radius
(* num (/ node-radius count)))
looptext-y
:text-style +text-style+
:ink +edge-text-color+)))
((and (plusp height) show-forward-edges-p)
(draw-ellipse* stream
(* (/ (+ from to) 2) stepx)
0
(* (- to (/ (+ from to) 2)) stepx)
0
0
y
:line-thickness 2
:filled nil
:start-angle
#+(or mcl lispworks) pi #-(or mcl lispworks) 0
:end-angle
#+(or mcl lispworks) 0 #-(or mcl lispworks) pi)
(draw-marker stream 1
(* (/ (+ from to) 2) stepx)
(- y)
size)
(when show-edge-info-p
(draw-text* stream
(format nil "~A" (info edge :for-graph-visualizer-p t))
(* (/ (+ from to) 2) stepx)
(- y)
:text-style +text-style+
:ink +edge-text-color+)))
((and (minusp height) show-backward-edges-p)
(draw-ellipse* stream
(* (/ (+ from to) 2) stepx)
0
(* (- to (/ (+ from to) 2)) stepx)
0
0
ym
:line-thickness 2
:filled nil
:start-angle #+(or mcl lispworks) 0 #-(or mcl lispworks) pi
:end-angle #+(or mcl lispworks) pi #-(or mcl lispworks) 0)
(draw-marker stream -1
(* (/ (+ from to) 2) stepx)
ym
size)
(when show-edge-info-p
(draw-text* stream
(format nil "~A" (info edge :for-graph-visualizer-p t))
(* (/ (+ from to) 2) stepx)
ym
:text-style +text-style+
:ink +edge-text-color+)))))))))))))))
(when show-nodes-p
(dolist (node nodes)
(with-output-as-presentation (stream node 'node)
(let ((pos (item-pos node)))
(draw-circle* stream (* pos stepx) 0 node-radius
:filled t
:ink (if show-color-nodes-p
(color node)
+node-body-color+))
(draw-circle* stream (* pos stepx) 0 node-radius
:filled nil
:line-thickness 2
:ink +node-contur-color+)
(when show-node-info-p
(with-text-size (stream :large)
(draw-text* stream
(format nil "~A" (info node :for-graph-visualizer-p t))
(- (* pos stepx) (* 1.6 node-radius))
(* 1.6 node-radius)
:text-style +text-style+
:ink +node-text-color+)))))))))))
#+:lispworks
(defmethod make-postscript-file ((frame graph-visualizer) filename)
(with-open-file (stream filename
:direction :output
:if-exists :supersede)
#| (let ((*standard-output* stream))
(when (dag-top dag)
(cl-user::psgraph (dag-top dag)
#'dag-node-children
#'(lambda (x) (list (dag-node-name x)))))) |#
(clim:with-output-to-postscript-stream (ps-stream stream
:orientation :portrait
:scale-to-fit t)
(draw-graph-visualizer frame ps-stream
(get-frame-pane frame 'display)))))
(defmethod draw-graph ((graph graph) (stream stream) (kind-of-graph (eql 'polygon))
&key
show-nodes-p
show-edges-p
show-node-info-p
show-edge-info-p
show-color-nodes-p
show-color-edges-p
show-backward-edges-p
show-forward-edges-p
show-loops-p
print-p)
(declare (ignore print-p))
(let* ((nodes (get-nodes graph))
(edges (get-edges graph))
(pi2 (/ pi 2))
(2pi (* 2 pi))
(size (max 1 (length nodes)))
(step (/ 2pi size))
(node-radius (get-node-size))
(node-radius2 (* 1.5 node-radius))
(loop-radius (* 1.2 node-radius))
(r 45)
(text-radius-ratio .3)
(node-label-offset (* 2 node-radius)))
(labels ((node-pos (index &optional (offset 0))
(values
(+ 50 (* (+ offset r) (cos (+ pi (* step index)))))
(+ (- 50) (* (+ offset r) (sin (+ pi (* step index))))))))
(when show-edges-p
(let ((edgeclusters nil))
(dolist (edge edges)
(with-slots (from to) edge
(let* ((from (item-pos from))
(to (item-pos to))
(found (find-if #'(lambda (x)
(and (equal (first x) from)
(equal (second x) to)))
edgeclusters)))
(if found
(push edge (third found))
(push (list from to (list edge)) edgeclusters)))))
(dolist (edgecluster edgeclusters)
(let* ((count (length (third edgecluster)))
(inc (unless (zerop (1- count))
(/ pi (1- count))))
(num 0))
(dolist (edge (third edgecluster))
(incf num)
(with-slots (from to) edge
(let* ((from (item-pos from))
(to (item-pos to))
(height (when (and from to)
(- to from))))
(when height
(multiple-value-bind (fromcx fromcy)
(node-pos from)
(multiple-value-bind (tocx tocy)
(node-pos to)
(let* ((orientation (if (eq from to)
0
(vector-orientation fromcx fromcy tocx tocy)))
(anglefrom (+ orientation (if (zerop (1- count))
0
(+ (- pi2) (* inc (1- num))))))
(angleto (- orientation (if (zerop (1- count))
0
(+ pi2 (* inc (1- num))))))
(fromx (+ fromcx (* node-radius (cos anglefrom))))
(fromy (+ fromcy (* node-radius (sin anglefrom))))
(tox (+ tocx (* node-radius (cos angleto))))
(toy (+ tocy (* node-radius (sin angleto))))
(fromx1 (+ fromcx (* node-radius2 (cos anglefrom))))
(fromy1 (+ fromcy (* node-radius2 (sin anglefrom))))
(textx (+ fromx (* text-radius-ratio (- tox fromx))))
(texty (+ fromy (* text-radius-ratio (- toy fromy)))))
(with-drawing-options (stream :ink (if show-color-edges-p
(color edge)
+edge-color+))
(with-output-as-presentation (stream edge 'edge)
(cond ((and (zerop height) show-loops-p)
(draw-circle* stream fromx fromy
loop-radius
:line-thickness 2
:filled nil)
(when show-edge-info-p
(draw-text* stream
(format nil "~A" (info edge :for-graph-visualizer-p t))
fromx1 fromy1
:text-style +text-style+
:ink +edge-text-color+)))
((or (and (plusp height) show-forward-edges-p)
(and (minusp height) show-backward-edges-p))
(draw-line* stream
fromx
fromy
tox
toy)
(draw-arrow* stream
fromx
fromy
(/ (+ fromx tox) 2)
(/ (+ fromy toy) 2)
:head-length (max 2 (/ 20 size))
:head-width (max 2 (/ 20 size)))
(when show-edge-info-p
(draw-text* stream
(format nil "~A" (info edge :for-graph-visualizer-p t))
textx
texty
:text-style +text-style+
:ink +edge-text-color+)))))))))))))))))
(when show-nodes-p
(dolist (node nodes)
(let ((pos (item-pos node)))
(multiple-value-bind (x y)
(node-pos pos)
(with-output-as-presentation (stream node 'node)
(draw-circle* stream x y node-radius
:filled t
:ink (if show-color-nodes-p
(color node)
+node-body-color+))
(draw-circle* stream x y node-radius
:filled nil
:ink +node-contur-color+)
(when show-node-info-p
(multiple-value-bind (x y)
(node-pos pos node-label-offset)
(with-text-size (stream :large)
(draw-text* stream
(format nil "~A" (info node :for-graph-visualizer-p t))
x y
:text-style +text-style+
:ink +node-text-color+))))))))))))
;;;
;;; Start
;;;
(defmethod accept-options ((frame graph-visualizer) stream)
(with-slots (kind-of-graph
show-nodes-p show-edges-p
show-node-info-p show-edge-info-p
show-color-nodes-p show-color-edges-p
show-backward-edges-p show-forward-edges-p show-loops-p) frame
(formatting-table (stream :multiple-columns t)
(formatting-row (stream)
(formatting-cell (stream)
(multiple-value-bind (object)
(accept 'completion
:query-identifier 'kind-of-graph
:prompt nil
:prompt-mode :raw
:stream stream
:default kind-of-graph
:view `(option-pane-view :items (chain polygon)))
(setf kind-of-graph object)))
(formatting-cell (stream)
(multiple-value-bind (object)
(accept 'boolean
:stream stream :default show-nodes-p
:prompt-mode :raw
:query-identifier 'show-nodes-p
:prompt
"Nodes")
(setf show-nodes-p object)))
(formatting-cell (stream)
(multiple-value-bind (object)
(accept 'boolean
:stream stream :default show-edges-p
:prompt-mode :raw
:query-identifier 'show-edges-p
:prompt
"Edges")
(setf show-edges-p object)))
(formatting-cell (stream)
(multiple-value-bind (object)
(accept 'boolean
:stream stream :default show-node-info-p
:prompt-mode :raw
:query-identifier 'show-node-info-p
:prompt
"Node Info")
(setf show-node-info-p object)))
(formatting-cell (stream)
(multiple-value-bind (object)
(accept 'boolean
:stream stream :default show-edge-info-p
:prompt-mode :raw
:query-identifier 'show-edge-info-p
:prompt
"Edge Info")
(setf show-edge-info-p object)))
(formatting-cell (stream)
(multiple-value-bind (object)
(accept 'boolean
:stream stream :default show-color-nodes-p
:prompt-mode :raw
:query-identifier 'show-color-nodes-p
:prompt
"Coloured Nodes")
(setf show-color-nodes-p object)))
(formatting-cell (stream)
(multiple-value-bind (object)
(accept 'boolean
:stream stream :default show-color-edges-p
:prompt-mode :raw
:query-identifier 'show-color-edges-p
:prompt
"Coloured Edges")
(setf show-color-edges-p object)))
(formatting-cell (stream)
(multiple-value-bind (object)
(accept 'boolean
:stream stream :default show-backward-edges-p
:prompt-mode :raw
:query-identifier 'show-backward-edges-p
:prompt
"Backward Edges")
(setf show-backward-edges-p object)))
(formatting-cell (stream)
(multiple-value-bind (object)
(accept 'boolean
:stream stream :default show-forward-edges-p
:prompt-mode :raw
:query-identifier 'show-forward-edges-p
:prompt
"Forward Edges")
(setf show-forward-edges-p object)))
(formatting-cell (stream)
(multiple-value-bind (object)
(accept 'boolean
:stream stream :default show-loops-p
:prompt-mode :raw
:query-identifier 'show-loops-p
:prompt
"Loops")
(setf show-loops-p object)))))))
;;;
;;; Interaktion
;;;
#+:lispworks
(define-graph-visualizer-command (com-ps-file :menu "Make Postscript File") ()
(with-graph-visualizer (frame)
(make-postscript-file frame
"graph.ps")))
(define-graph-visualizer-command (com-show-info :name "Show Info")
((object 'edge))
(with-graph-visualizer (frame)
(setf *selected-object* object)
(let ((stream (get-frame-pane frame 'infopane)))
(describe object stream))))
#+:allegro
(define-graph-visualizer-command (com-print :menu t)
()
(with-graph-visualizer (frame)
(with-open-stream
(pipe (excl:run-shell-command (format nil "lpr -P~A -h" '|r135_hp|)
:input :stream :wait nil))
(with-output-to-postscript-stream (stream pipe
:orientation :landscape
:scale-to-fit t)
(draw-graph-visualizer frame stream
(get-frame-pane frame 'display))))))
#+:allegro
(define-graph-visualizer-command (com-save :menu t)
()
(with-graph-visualizer (frame)
(with-open-file (file "~/rcc-visualizer-output.ps"
:direction :output :if-exists :supersede
:if-does-not-exist :create)
(with-output-to-postscript-stream (stream file
:orientation :portrait
:scale-to-fit t)
(draw-graph-visualizer frame stream
(get-frame-pane frame 'display))))))
;;;
;;; Translatoren
;;;
(define-presentation-to-command-translator object-to-command
(graph-item com-show-info graph-visualizer
:gesture :select)
(object)
(list object))
;;;
;;;
;;;
(defmethod visualize ((graphs list) &optional (kill-p t))
#| (unless (every #'(lambda (graph)
(<= (length (nodes graph)) 20))
graphs)
(error "Doesn't make sense to visualize graphs with more than 20 nodes with this program!")) |#
(with-graph-visualizer (frame)
(when (and frame kill-p)
(frame-exit frame)))
(let ((port (find-port))
(graphs (remove-duplicates graphs))
(frame (make-application-frame 'graph-visualizer
:width 850
:height 860)))
(setf *graph-visualizer* frame)
(setf (bar frame) *bar*)
(setf (resizer frame) *resizer*)
(setf (clim:text-style-mapping port +text-style+)
;;"-*-fixed-medium-r-semicondensed-*-11-*-*-*-*-*-*-*"
"fixed")
#+:allegro
(mp:process-run-function
"GRAPH Visualizer"
#'(lambda ()
(run-frame-top-level *graph-visualizer*)))
#+:lispworks
(mp:process-run-function
"GRAPH Visualizer"
nil
#'(lambda ()
(run-frame-top-level *graph-visualizer*)))
#+mcl
(ccl:process-run-function
"GRAPH Visualizer"
#'(lambda ()
(run-frame-top-level *graph-visualizer*)))
(setf (graphs frame) graphs)))
(defmethod visualize ((graph graph) &optional (kill-p t))
(visualize (list graph) kill-p))
;;;
;;; Demo: Ableitung eines gelabelten "Simple Graphs"
;;; Verwaltung der Knoten und Kanten über einfache Listen
;;; Achtung: *nicht* von Simple Graph erben!!!
;;;
#|
(defvar *all-graphs* nil)
(defpersistentclass simple-graph (graph)
((nodes :accessor nodes :initform nil)
(edges :accessor edges :initform nil)))
(defpersistentclass simple-node (node)
((label :accessor label :initarg :label :initform nil)))
(defpersistentclass simple-edge (edge)
((label :accessor label :initarg :label :initform nil)))
;;;
;;;
;;;
(defun make-simple-graph (name)
(make-instance 'simple-graph :name name))
(defmethod make-graph ((type (eql 'simple-graph)) &key name &allow-other-keys)
(make-simple-graph name))
(defmethod initialize-instance :after ((graph simple-graph) &rest initargs)
(push graph *all-graphs*))
(defmethod initialize-instance :after ((node simple-node) &rest initargs)
(push node (nodes (in-graph node))))
(defmethod initialize-instance :after ((edge simple-edge) &rest initargs)
(push edge (edges (in-graph edge))))
(defmethod find-graph ((graph-spec symbol) &rest args)
(find graph-spec *all-graphs* :key #'name))
(defmethod find-graph ((graph-spec integer) &rest args)
(find graph-spec *all-graphs* :key #'id :test #'=))
(defmethod find-node ((graph-spec simple-graph) (node-spec symbol) &rest args)
(find node-spec (nodes graph-spec) :key #'name))
(defmethod find-node ((graph-spec simple-graph) (node-spec integer) &rest args)
(find node-spec (nodes graph-spec) :key #'id :test #'=))
(defmethod find-node ((graph-spec simple-graph) (node-spec simple-node) &rest args)
(find node-spec (nodes graph-spec)))
(defmethod find-edge ((graph-spec simple-graph) (edge-spec symbol) &rest args)
(find edge-spec (edges graph-spec) :key #'name))
(defmethod find-edge ((graph-spec simple-graph) (edge-spec integer) &rest args)
(find edge-spec (edges graph-spec) :key #'id :test #'=))
(defmethod find-edge ((graph-spec simple-graph) (edge-spec simple-edge) &rest args)
(find edge-spec (edges graph-spec)))
(defmethod get-node-position ((graph-spec simple-graph) (node-spec simple-node) &rest args)
(let* ((nodes (get-nodes graph-spec)))
(position node-spec nodes)))
(defmethod no-of-nodes ((graph simple-graph) &rest args)
(length (nodes graph)))
(defmethod no-of-edges ((graph simple-graph) &rest args)
(length (edges graph)))
(defmethod delete-graph ((graph simple-graph) &rest args)
(setf *all-graphs*
(delete graph *all-graphs*)))
(defmethod copy-graph ((graph simple-graph) &key &allow-other-keys)
(let ((new-graph
(make-instance 'simple-graph
:name (name graph)
:edge-counter (edge-counter graph)
:node-counter (node-counter graph)
:id (id graph))))
(with-slots (nodes edges) new-graph
(setf nodes (mapcar #'(lambda (node)
(copy-graph-item new-graph node))
(nodes graph))
edges (mapcar #'(lambda (edge)
(copy-graph-item new-graph edge))
(edges graph))))
new-graph))
(defmethod make-node ((graph simple-graph) &key name label &allow-other-keys)
(make-instance 'simple-node
:in-graph graph
:label label
:name name))
(defmethod make-edge ((graph simple-graph) (from simple-node) (to simple-node) &key label &allow-other-keys)
(make-instance 'simple-edge
:in-graph graph
:from from
:to to
:label label
:name (intern (format nil "EDGE-~A-~A" (name from) (name to)))))
(defmethod delete-node ((graph simple-graph) (node simple-node) &key &allow-other-keys)
(unless (eq (in-graph node) graph)
(error "Node ~A not in graph ~A!" node graph))
(setf (nodes graph)
(delete node (nodes (in-graph node)))))
(defmethod delete-edge ((graph simple-graph) (edge simple-edge) &key &allow-other-keys)
(unless (eq (in-graph edge) graph)
(error "Edge ~A not in graph ~A!" edge graph))
(setf (edges (in-graph edge))
(delete edge (edges (in-graph edge)))))
(defmethod copy-node ((new-graph simple-graph) (node simple-node) &key &allow-other-keys)
(make-instance 'simple-node
:in-graph new-graph
:id (id node)
:label (label node)
:name (name node)))
(defmethod copy-edge ((new-graph simple-graph) (edge simple-edge) &key &allow-other-keys)
(make-instance 'simple-edge
:in-graph new-graph
:id (id edge)
:label (label edge)
:name (name edge)
:from (find-node new-graph (id (from edge)))
:to (find-node new-graph (id (to edge)))))
(defmethod get-nodes ((graph simple-graph) &rest args)
(reverse (nodes graph)))
(defmethod get-edges ((graph simple-graph) &rest args)
(reverse (edges graph)))
(defmethod get-edges-between ((graph simple-graph) (from simple-node) (to simple-node) &rest args)
(remove-if-not #'(lambda (edge)
(and (eq (from edge) from)
(eq (to edge) to)))
(get-edges graph)))
;;;
;;;
;;;
(defmethod info ((graph simple-graph) &key)
(format nil "Id: ~A Nodes: ~A, Edges: ~A"
(id graph)
(no-of-nodes graph)
(no-of-edges graph)))
(defmethod info ((node simple-node) &key for-graph-visualizer-p)
(if for-graph-visualizer-p
(print-object node nil)
(format nil "Id: ~A Label: ~A"
(id node) (label node))))
(defmethod info ((edge simple-edge) &key for-graph-visualizer-p)
(if for-graph-visualizer-p
(print-object edge nil)
(format nil "(~A/~A,~A/~A):~A"
(name (from edge))
(id (from edge))
(name (to edge))
(id (to edge))
(label edge))))
;;;
;;;
;;;
(defmethod kind ((graph simple-graph))
'kind-simple-graph)
(defmethod kind ((node simple-node))
(label node))
(defmethod kind ((edge simple-edge))
(label edge))
;;;
;;; wird nur verwendet, wenn kein "kind", ansonsten
;;; "compute-color-from-kind-p t" als default!
;;;
(defmethod color ((node simple-node))
+yellow+)
(defmethod color ((edge simple-edge))
+yellow+)
(let ((graph (make-graph 'simple-graph :name 'graph :delete-if-exists-p t)))
(setf x graph)
(setf a (make-node graph :name 'a :label 'label-a))
(setf b (make-node graph :name 'b :label 'label-b))
(setf c (make-node graph :name 'c :label 'label-c))
(setf d (make-node graph :name 'd :label 'label-a))
(delete-node 'graph 'd)
(setf ab1 (make-edge 'graph a b :label 'r1))
(setf ab2 (make-edge 'graph a b :label 'r2))
(visualize graph))
(let ((graph (make-graph 'simple-graph :name 'graph))
(graph (make-graph 'simple-graph :name 'graph)))
(princ *all-graphs*)
(delete-graph 'graphd :all-p nil :error-p nil)
(princ *all-graphs*)
(delete-graph 'graph :all-p t)
(princ *all-graphs*))
|#
| 50,804 | Common Lisp | .lisp | 1,106 | 26.223327 | 122 | 0.428804 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 45e70e5bdca98ef906b86e18288d33c0aeb83e16366cc3bc77c7ae1d28f0dc17 | 12,505 | [
-1
] |
12,506 | common15.lisp | lambdamikel_DLMAPS/src/thematic-substrate/common15.lisp | ;;; -*- Mode: Lisp; Syntax: Ansi-Common-Lisp; Package: THEMATIC-SUBSTRATE; Base: 10 -*-
(in-package :THEMATIC-SUBSTRATE)
;;;
;;;
;;;
(defconstant +racer-internal-datatype-property-roles+
'(RACER-INTERNAL%HAS-STRING-VALUE
RACER-INTERNAL%HAS-INTEGER-VALUE
RACER-INTERNAL%HAS-CARDINAL-VALUE
RACER-INTERNAL%HAS-REAL-VALUE
RACER-INTERNAL%HAS-BOOLEAN-VALUE))
(defconstant +racer-substrate-default-tbox+ 'cl-user::default)
;;;
;;;
;;;
(defconstant +cache-is-complete-marker+ :cache-complete-dvfkvf8974)
(defconstant +individual-exists-concept+ :individual-exists-7894jkjoif)
;;;
;;;
;;;
(defvar *racer-tbox* nil)
(defvar *racer-abox* nil)
;;;
;;;
;;;
;;;
(defconstant +default-hash-table-size+ 10000)
(defconstant +default-rehash-factor+ 1)
(defun mht (&key (size +default-hash-table-size+) (test #'eql))
(make-hash-table :size size :rehash-size (* +default-rehash-factor+ size) :test test))
;;;
;;;
;;;
(defconstant +table-size-concept-assertions-cache+ 3000)
(defconstant +table-size-constraint-entailed-cache+ 3000)
(defconstant +table-size-concept-instances-cache+ 3000)
(defconstant +table-size-known-concept-instances-cache+ 3000)
(defconstant +table-size-individual-instance-cache+ 10000)
(defconstant +table-size-individual-attribute-fillers-cache+ 3000)
(defconstant +table-size-role-assertions-in-range-cache+ 10000)
(defconstant +table-size-role-assertions-in-domain-cache+ 10000)
(defconstant +table-size-role-descendants-cache+ 100)
(defconstant +table-size-atomic-role-inverse-cache+ 100)
(defconstant +table-size-role-successors-cache+ 100)
(defconstant +table-size-new-inds-hash+ 100)
(defconstant +table-size-datatype-property-values-cache+ 100)
(defconstant +table-size-told-values-cache+ 100)
;;;
;;;
;;;
(defpersistentclass racer-descriptions-substrate (substrate)
;;; Knoten und Kanten mit Racer-Descriptions
((tbox :initarg :tbox :reader tbox :initform nil)
(racer-package :accessor racer-package :initarg :racer-package :initform :racer-user)))
(defpersistentclass dl-prover-substrate (substrate)
;;; Knoten und Kanten mit Descriptions, optionale assoziierte ABox-Objekte!
((qbox :initarg :qbox :reader qbox :initform nil)
(dbox :initarg :dbox :reader dbox :initform nil)
(prepared-p :accessor prepared-p :initform nil)
(saved-state-vector :accessor saved-state-vector :initform nil)
(needs-filler-reasoning-p :reader needs-filler-reasoning-p :initform nil)
(new-inds-hash :accessor new-inds-hash :initform (mht :size +table-size-new-inds-hash+ :test #'equal))
(abox-individuals-cache :accessor abox-individuals-cache :initform :unknown)
(concept-assertions-cache :accessor concept-assertions-cache
:initform (mht :size +table-size-concept-assertions-cache+))
;;;
;;;
;;;
(concept-instances-cache :accessor concept-instances-cache
:initform (mht :size +table-size-concept-instances-cache+ :test #'equal))
(known-concept-instances-cache :accessor known-concept-instances-cache
:initform (mht :size +table-size-known-concept-instances-cache+ :test #'equal))
(individual-instance-cache :accessor individual-instance-cache
:initform (mht :test #'equal :size +table-size-individual-instance-cache+))
(role-assertions-in-range-cache :accessor role-assertions-in-range-cache
:initform (mht :size +table-size-role-assertions-in-range-cache+))
(role-assertions-in-domain-cache :accessor role-assertions-in-domain-cache
:initform (mht :size +table-size-role-assertions-in-domain-cache+))
(role-descendants-cache :accessor role-descendants-cache
:initform (mht :size +table-size-role-descendants-cache+ :test #'equal))
(role-successors-cache :accessor role-successors-cache
:initform (mht :size +table-size-role-successors-cache+ :test #'equal))
(atomic-role-inverse-cache :accessor atomic-role-inverse-cache
:initform (mht :size +table-size-atomic-role-inverse-cache+ :test #'equal))
(all-roles-cache :accessor all-roles-cache :initform :unknown)
(transitive-roles-cache :accessor transitive-roles-cache :initform :unknown)
;;;
;;; die folgenden Slots / Hashtabellen dienen dazu, die Kommunikation mit
;;; dem RACER-Server zu beschleunigen (Cache fuer haeuftig gestellte Anfragen!)
;;;
(constraints-cache :accessor constraints-cache :initform :unknown)
(told-values-cache :accessor told-values-cache :initform (mht :size +table-size-told-values-cache+ :test #'eql))
(datatype-property-values-cache :accessor datatype-property-values-cache
:initform (mht :test #'equal :size +table-size-datatype-property-values-cache+))
(constraint-entailed-cache :accessor constraint-entailed-cache
:initform (mht :test #'equal :size +table-size-constraint-entailed-cache+))
(individual-attribute-fillers-cache :accessor individual-attribute-fillers-cache
:initform (mht :test #'equal :size +table-size-individual-attribute-fillers-cache+))))
(defpersistentclass racer-substrate (dl-prover-substrate racer-descriptions-substrate)
;;; Knoten und Kanten mit Descriptions, optionale assoziierte ABox-Objekte!
((tbox :initarg :tbox :reader tbox :initform nil)
(abox :initarg :abox :reader abox :initform nil)))
(defpersistentclass racer-dummy-substrate (racer-substrate) nil)
;;; nur fuer Ralf, keine Substrat-Objekte, nur ABox
;;; -> keine Substrate-Objekte-Unterklassen erforderlich, klar
#+:midelora
(defpersistentclass midelora-substrate (dl-prover-substrate prover::abox)
((abox :accessor abox)
(tbox :accessor tbox)))
#+:midelora
(defpersistentclass midelora-substrate1 (midelora-substrate prover::abox1))
#+:midelora
(defmethod update-instance-for-different-class :after ((old prover::abox) (substrate midelora-substrate) &rest initargs)
(declare (ignore initargs))
(setf (slot-value substrate 'abox) substrate
(slot-value substrate 'tbox) (prover::tbox substrate))
(reset-substrate substrate))
(defpersistentclass tbox-mirror-substrate (dl-prover-substrate))
(defpersistentclass racer-tbox-mirror-substrate (tbox-mirror-substrate racer-dummy-substrate)
((mirror-of-tbox :reader mirror-of-tbox)
(needs-filler-reasoning-p :initform nil)))
#+:midelora
(defpersistentclass midelora-tbox-mirror-substrate (tbox-mirror-substrate midelora-substrate)
((mirror-of-tbox :reader mirror-of-tbox)
(needs-filler-reasoning-p :initform nil)))
;;;
;;;
;;;
(defmethod establish-context-for ((substrate racer-substrate) continuation)
(let ((*racer-tbox* (tbox substrate))
(*racer-abox* (abox substrate)))
(if (next-method-p)
(call-next-method)
(funcall continuation))))
#-:dlmaps
(defmethod set-context-for ((substrate racer-substrate))
(setf *racer-tbox* (tbox substrate)
*racer-abox* (abox substrate)))
#+:dlmaps
(defmethod set-context-for progn ((substrate racer-substrate))
(setf *racer-tbox* (tbox substrate)
*racer-abox* (abox substrate)))
;;;
;;;
;;;
(defmethod reset-substrate :before ((substrate dl-prover-substrate) &key &allow-other-keys)
(without-timeout
(setf (saved-state-vector substrate) nil)
(setf (prepared-p substrate) nil)))
(defmethod reset-substrate :after ((substrate dl-prover-substrate) &key &allow-other-keys)
(without-timeout
(setf (saved-state-vector substrate)
(get-state-vector substrate))
(setf (prepared-p substrate) t)))
;;;
;;;
;;;
(defmethod reset-substrate ((substrate racer-substrate) &key &allow-other-keys)
(clear-repository substrate)
(reset-caches substrate)
(if (find-tbox (tbox substrate) nil)
(if (find-abox (abox substrate) nil)
(compute-abox-mirror substrate)
(nrql-error "Can't find ABox ~A!" (abox substrate)))
(nrql-error "Can't find TBox ~A!" (tbox substrate))))
#+:midelora
(defmethod reset-substrate ((substrate midelora-substrate) &key &allow-other-keys)
(clear-repository substrate)
(reset-caches substrate)
(compute-abox-mirror substrate))
(defmethod reset-substrate ((substrate racer-tbox-mirror-substrate) &key tbox)
(reset-caches substrate)
(setf (slot-value substrate 'tbox)
(or tbox
(mirror-of-tbox substrate)))
(if (find-tbox (tbox substrate) nil)
(compute-tbox-mirror substrate)
(nrql-error "Can't find TBox ~A!" (tbox substrate))))
#+:midelora
(defmethod reset-substrate ((substrate midelora-tbox-mirror-substrate) &key tbox)
(declare (ignorable tbox))
(reset-caches substrate)
(setf (slot-value substrate 'tbox)
(or tbox
(mirror-of-tbox substrate)))
(if (prover::find-tbox (tbox substrate) :error-p nil)
(compute-tbox-mirror substrate)
(nrql-error "Can't find TBox ~A!" (tbox substrate))))
;;;
;;;
;;;
(defmethod reset-caches ((substrate dl-prover-substrate))
(setf (constraints-cache substrate) :unknown)
(setf (abox-individuals-cache substrate) :unknown)
(setf (transitive-roles-cache substrate) :unknown)
(setf (all-roles-cache substrate) :unknown)
(dolist (slot '(concept-assertions-cache
atomic-role-inverse-cache
concept-instances-cache
known-concept-instances-cache
individual-instance-cache
role-assertions-in-range-cache
role-assertions-in-domain-cache
role-descendants-cache
role-successors-cache
told-values-cache
datatype-property-values-cache
constraint-entailed-cache
individual-attribute-fillers-cache))
(clrhash (slot-value substrate slot))))
;;;
;;; DL-Prover-Ankopplung per Delegation (plus Caching etc.)
;;;
(defmethod dl-all-individuals ((substrate racer-substrate) &rest args)
(apply #'all-individuals args))
#+:midelora
(defmethod dl-all-individuals ((substrate midelora-substrate) &rest args)
(apply #'prover::all-individuals args))
(defmethod dl-all-roles ((substrate racer-substrate) &rest args)
(apply #'all-roles args))
#+:midelora
(defmethod dl-all-roles ((substrate midelora-substrate) &rest args)
(apply #'prover::all-roles args))
(defmethod dl-all-features ((substrate racer-substrate) &rest args)
(apply #'all-features args))
#+:midelora
(defmethod dl-all-features ((substrate midelora-substrate) &rest args)
(apply #'prover::all-features args))
(defmethod dl-all-transitive-roles ((substrate racer-substrate) &rest args)
(apply #'all-transitive-roles args))
#+:midelora
(defmethod dl-all-transitive-roles ((substrate midelora-substrate) &rest args)
(apply #'prover::all-transitive-roles args))
(defmethod dl-all-constraints ((substrate racer-substrate) &rest args)
(apply #'all-constraints args))
#+:midelora
(defmethod dl-all-constraints ((substrate midelora-substrate) &rest args)
(declare (ignorable args))
nil)
(defmethod dl-all-concept-assertions-for-individual ((substrate racer-substrate) &rest args)
(apply #'all-concept-assertions-for-individual args))
#+:midelora
(defmethod dl-all-concept-assertions-for-individual ((substrate midelora-substrate) &rest args)
(apply #'prover::all-concept-assertions-for-individual args))
(defmethod dl-retrieve-concept-instances ((substrate racer-substrate) concept abox
&key (candidates nil candidates-supplied-p)
&allow-other-keys)
(if candidates-supplied-p
(retrieve-concept-instances concept abox candidates)
(retrieve-concept-instances concept abox)))
#+:midelora
(defmethod dl-retrieve-concept-instances ((substrate midelora-substrate) concept abox
&rest args &key &allow-other-keys)
(apply #'prover::get-concept-instances concept abox args))
(defmethod dl-individual-p ((substrate racer-substrate) &rest args)
(apply #'individual-p args))
#+:midelora
(defmethod dl-individual-p ((substrate midelora-substrate) &rest args)
(apply #'prover::individual-p args))
(defmethod dl-individual-instance-p ((substrate racer-substrate) &rest args)
(apply #'individual-instance-p args))
#+:midelora
(defmethod dl-individual-instance-p ((substrate midelora-substrate) &rest args)
(apply #'prover::individual-instance-p args))
(defmethod dl-constraint-entailed-p ((substrate racer-substrate) &rest args)
(apply #'constraint-entailed-p args))
#+:midelora
(defmethod dl-constraint-entailed-p ((substrate midelora-substrate) &rest args)
nil)
(defmethod dl-retrieve-individual-attribute-fillers ((substrate racer-substrate) &rest args)
(apply #'retrieve-individual-attribute-fillers args))
#+:midelora
(defmethod dl-retrieve-individual-attribute-fillers ((substrate midelora-substrate) &rest args)
nil)
(defmethod dl-all-role-assertions-for-individual-in-range ((substrate racer-substrate) &rest args)
(apply #'all-role-assertions-for-individual-in-range args))
#+:midelora
(defmethod dl-all-role-assertions-for-individual-in-range ((substrate midelora-substrate) &rest args)
(apply #'prover::all-role-assertions-for-individual-in-range args))
(defmethod dl-all-role-assertions-for-individual-in-domain ((substrate racer-substrate) &rest args)
(apply #'all-role-assertions-for-individual-in-domain args))
#+:midelora
(defmethod dl-all-role-assertions-for-individual-in-domain ((substrate midelora-substrate) &rest args)
(apply #'prover::all-role-assertions-for-individual-in-domain args))
(defmethod dl-atomic-role-descendants ((substrate racer-substrate) &rest args)
(apply #'atomic-role-descendants args))
#+:midelora
(defmethod dl-atomic-role-descendants ((substrate midelora-substrate) &rest args)
(apply #'prover::atomic-role-descendants args))
(defmethod dl-atomic-role-inverse ((substrate racer-substrate) &rest args)
(apply #'atomic-role-inverse args))
#+:midelora
(defmethod dl-atomic-role-inverse ((substrate midelora-substrate) &rest args)
(apply #'prover::atomic-role-inverse args))
(defmethod dl-all-role-assertions ((substrate racer-substrate) &rest args)
(apply #'all-role-assertions args))
#+:midelora
(defmethod dl-all-role-assertions ((substrate midelora-substrate) &rest args)
(apply #'prover::all-role-assertions args))
(defmethod dl-all-annotation-role-assertions ((substrate racer-substrate) &rest args)
(apply #'all-annotation-role-assertions args))
#+:midelora
(defmethod dl-all-annotation-role-assertions ((substrate midelora-substrate) &rest args)
nil)
(defmethod dl-all-attribute-assertions ((substrate racer-substrate) &rest args)
(apply #'all-attribute-assertions args))
#+:midelora
(defmethod dl-all-attribute-assertions ((substrate midelora-substrate) &rest args)
nil)
(defmethod dl-tbox-classified-p ((substrate racer-descriptions-substrate) &rest args)
(apply #'tbox-classified-p args))
#+:midelora
(defmethod dl-tbox-classified-p ((substrate midelora-substrate) &rest args)
(apply #'prover::tbox-classified-p args))
(defmethod dl-tbox-coherent-p ((substrate racer-descriptions-substrate) &rest args)
(apply #'tbox-coherent-p args))
#+:midelora
(defmethod dl-tbox-coheren-p ((substrate midelora-substrate) &rest args)
(apply #'prover::tbox-coherent-p args))
(defmethod dl-classify-tbox ((substrate racer-descriptions-substrate) &rest args)
(apply #'classify-tbox args))
#+:midelora
(defmethod dl-classify-tbox ((substrate midelora-substrate) &rest args)
(apply #'prover:classify-tbox args))
(defmethod dl-all-annotation-concept-assertions ((substrate racer-substrate) &rest args)
(apply #'all-annotation-concept-assertions args))
#+:midelora
(defmethod dl-all-annotation-concept-assertions ((substrate midelora-substrate) &rest args)
nil)
(defmethod dl-atomic-concept-ancestors ((substrate racer-substrate) &rest args)
(apply #'atomic-concept-ancestors args))
#+:midelora
(defmethod dl-atomic-concept-ancestors ((substrate midelora-substrate) &rest args)
nil)
(defmethod dl-atomic-concept-synonyms ((substrate racer-substrate) &rest args)
(apply #'atomic-concept-synonyms args))
#+:midelora
(defmethod dl-atomic-concept-synonyms ((substrate midelora-substrate) &rest args)
(apply #'prover::atomic-concept-synonyms args))
(defmethod dl-all-concept-assertions ((substrate racer-substrate) &rest args)
(apply #'all-concept-assertions args))
#+:midelora
(defmethod dl-all-concept-assertions ((substrate midelora-substrate) &rest args)
(apply #'prover::all-concept-assertions args))
;;;
;;;
;;;
(defmethod retrieve-annotation-values ((substrate racer-substrate) ind property)
(loop as concept in
(gethash ind (datatype-property-values-cache substrate))
when (eq (first concept) property)
collect (second concept)))
#+:midelora
(defmethod retrieve-annotation-values ((substrate midelora-substrate) ind property)
(declare (ignore ind property))
nil)
;;;
;;; Abstraktionen; nur diese Funktionen sollen im Query-Evaluation-Code verwendet werden!
;;;
(defmethod dl-prover-internal-individuals-related-p ((substrate racer-substrate) &rest args)
(apply #'internal-individuals-related-p args))
#+:midelora
(defmethod dl-prover-internal-individuals-related-p ((substrate midelora-substrate) &rest args)
(apply #'prover::individuals-related-p args))
(defmethod dl-prover-individual-synonyms ((substrate racer-substrate) ind)
(with-critical-section
(retrieve-individual-synonyms ind nil (abox substrate))))
#+:midelora
(defmethod dl-prover-individual-synonyms ((substrate midelora-substrate) ind)
(declare (ignorable ind))
nil)
(defmethod dl-prover-abox-consistent-p ((substrate racer-substrate) &rest args)
(apply #'abox-consistent-p args))
#+:midelora
(defmethod dl-prover-abox-consistent-p ((substrate midelora-substrate) &rest args)
(apply #'prover::abox-consistent-p args))
(defmethod dl-prover-transitive-role-p ((substrate dl-prover-substrate) role)
(with-critical-section
(when (eq (transitive-roles-cache substrate) :unknown)
(setf (transitive-roles-cache substrate)
(dl-all-transitive-roles substrate (tbox substrate))))
(member role (transitive-roles-cache substrate)
:test #'equal)))
(defmethod dl-prover-all-roles ((substrate dl-prover-substrate))
(with-critical-section
(when (eq (all-roles-cache substrate) :unknown)
(setf (all-roles-cache substrate)
(dl-all-roles substrate (tbox substrate))))
(all-roles-cache substrate)))
(defmethod dl-prover-role-successors-cache-complete-for-role-p ((substrate dl-prover-substrate) from role)
(with-critical-section
(dl-prover-is-known-role-successor-of-p substrate +cache-is-complete-marker+ from role)))
(defmethod dl-prover-register-role-successors-cache-is-complete-for-role ((substrate dl-prover-substrate) from role)
(with-critical-section
(dl-prover-register-role-successor substrate +cache-is-complete-marker+ from role)))
(defmethod dl-prover-all-role-successors ((substrate dl-prover-substrate) from role)
(with-critical-section
(if (dl-prover-role-successors-cache-complete-for-role-p substrate from role)
(let ((hash (gethash role (role-successors-cache substrate))))
(if hash
(let ((succs (gethash from hash))) ; +complete-marker+ entfernen!
;; (princ succs)
;; (terpri)
(rest succs))
(nrql-error "Runtime error: hashing problem")))
:unknown)))
(defmethod dl-prover-is-known-role-successor-of-p ((substrate dl-prover-substrate) to from role)
(with-critical-section
;;; auch wenn der Cache unvollstaendig ist!
;;; er wird nur verwendet beim Suchen in der ABox "racer-retrieve-individual-fillers"
;;; fuer (transitive) Rollen, um Such-Endlosschleifen (Zyklen) aufzuloesen!
;;;
(let ((hash (gethash role (role-successors-cache substrate))))
(if hash
(member to (gethash from hash))
nil))))
(defmethod dl-prover-register-role-successor ((substrate dl-prover-substrate) to from role)
(with-critical-section
(unless (gethash role (role-successors-cache substrate))
(setf (gethash role (role-successors-cache substrate))
(mht :size 1000 :test #'equal)))
(when (dl-prover-role-successors-cache-complete-for-role-p substrate from role)
(nrql-error "Runtime error: cache is already complete!"))
(multiple-value-bind (succs foundp)
(gethash from (gethash role (role-successors-cache substrate)))
(declare (ignorable succs))
(if foundp
(push to (gethash from (gethash role (role-successors-cache substrate))))
(setf (gethash from (gethash role (role-successors-cache substrate))) (list to))))))
(defmethod dl-prover-all-individuals ((substrate dl-prover-substrate))
(with-critical-section
(if (eq (abox-individuals-cache substrate) :unknown)
(unless *told-information-reasoning-p*
(values (setf (abox-individuals-cache substrate)
(dl-all-individuals substrate (abox substrate)))
t))
(values (abox-individuals-cache substrate) t))))
(defmethod dl-prover-individual-exists-p ((substrate dl-prover-substrate) ind)
(with-critical-section
(dl-prover-individual-instance-p substrate ind +individual-exists-concept+)))
(defmethod dl-prover-all-constraints ((substrate dl-prover-substrate))
(with-critical-section
(if (eq (constraints-cache substrate) :unknown)
(unless *told-information-reasoning-p*
(values (setf (constraints-cache substrate)
(dl-all-constraints substrate (abox substrate)))
t))
(values (constraints-cache substrate) t))))
(defmethod dl-prover-all-concept-assertions-for-individual ((substrate dl-prover-substrate) ind)
(with-critical-section
(multiple-value-bind (val foundp)
(gethash ind (concept-assertions-cache substrate))
(if foundp
(values val t)
(unless *told-information-reasoning-p*
(let ((assertions
(dl-all-concept-assertions-for-individual substrate ind (abox substrate))))
(setf (gethash ind (concept-assertions-cache substrate)) assertions)
(dolist (assertion assertions)
(let ((concept (second assertion)))
(setf (gethash (list ind concept) (individual-instance-cache substrate)) t)
(if (gethash concept (known-concept-instances-cache substrate))
(push ind (gethash concept (known-concept-instances-cache substrate)))
(setf (gethash concept (known-concept-instances-cache substrate)) (list ind)))))
(values assertions t)))))))
(defmethod dl-prover-retrieve-concept-instances ((substrate dl-prover-substrate) concept
&key (candidates nil candidates-supplied-p)
continuation)
(with-critical-section
(multiple-value-bind (val foundp)
(gethash concept (concept-instances-cache substrate))
(if foundp
;; zweiter Wert wichtig, um bei NIL-Ergebnis
;; zu sehen, dass vollständig bzw. bereits berechnet!
(if continuation
(progn
(dolist (x val)
(funcall continuation x))
(values val t))
(values val t))
(unless *told-information-reasoning-p*
(let* ((continuation
#'(lambda (ind)
(setf (gethash (list ind concept) (individual-instance-cache substrate)) t)
(when continuation
(funcall continuation ind))))
(inds (if candidates-supplied-p
(dl-retrieve-concept-instances substrate
concept (abox substrate)
:candidates candidates
:continuation continuation)
(dl-retrieve-concept-instances substrate
concept (abox substrate)
:continuation continuation))))
(setf (gethash concept (concept-instances-cache substrate)) inds)
(values inds t)))))))
(defmethod dl-prover-retrieve-known-concept-instances ((substrate dl-prover-substrate) concept)
(with-critical-section
(gethash concept (known-concept-instances-cache substrate))))
(defmethod dl-prover-individual-instance-p ((substrate dl-prover-substrate) ind concept)
(with-critical-section
(multiple-value-bind (val foundp)
(gethash (list ind concept) (individual-instance-cache substrate))
(if foundp
(values val t)
(unless *told-information-reasoning-p*
(let ((res
(if (eq concept +individual-exists-concept+)
(dl-individual-p substrate ind (abox substrate))
(dl-individual-instance-p substrate ind concept (abox substrate)))))
(setf (gethash (list ind concept) (individual-instance-cache substrate)) res)
(values res t)))))))
(defmethod dl-prover-constraint-entailed-p ((substrate dl-prover-substrate) constraint)
(with-critical-section
(multiple-value-bind (val foundp)
(gethash constraint (constraint-entailed-cache substrate))
(if foundp
(values val t)
(unless *told-information-reasoning-p*
(let ((res
(dl-constraint-entailed-p substrate constraint (abox substrate))))
(setf (gethash constraint (constraint-entailed-cache substrate)) res)
(values res t)))))))
(defmethod dl-prover-retrieve-individual-attribute-fillers ((substrate dl-prover-substrate) ind attribute)
(with-critical-section
(multiple-value-bind (val foundp)
(gethash (list ind attribute) (individual-attribute-fillers-cache substrate))
(if foundp
(values val t)
(unless *told-information-reasoning-p*
(let ((fillers
(dl-retrieve-individual-attribute-fillers substrate ind attribute (abox substrate))))
(setf (gethash (list ind attribute) (individual-attribute-fillers-cache substrate)) fillers)
(values fillers t)))))))
(defmethod dl-prover-all-role-assertions-for-individual-in-range ((substrate dl-prover-substrate) ind)
(with-critical-section
(multiple-value-bind (val foundp)
(gethash ind (role-assertions-in-range-cache substrate))
(if foundp
(values val t)
(unless *told-information-reasoning-p*
(let ((assertions
(dl-all-role-assertions-for-individual-in-range substrate ind (abox substrate))))
(setf (gethash ind (role-assertions-in-range-cache substrate)) assertions)
(values assertions t)))))))
(defmethod dl-prover-all-role-assertions-for-individual-in-domain ((substrate dl-prover-substrate) ind)
(with-critical-section
(multiple-value-bind (val foundp)
(gethash ind (role-assertions-in-domain-cache substrate))
(if foundp
(values val t)
(unless *told-information-reasoning-p*
(let ((assertions
(dl-all-role-assertions-for-individual-in-domain substrate ind (abox substrate))))
(setf (gethash ind (role-assertions-in-domain-cache substrate)) assertions)
(values assertions t)))))))
(defmethod dl-prover-atomic-role-descendants ((substrate dl-prover-substrate) role)
(with-critical-section
(multiple-value-bind (val foundp)
(gethash role (role-descendants-cache substrate))
(if foundp
(values val t)
(unless *told-information-reasoning-p*
(let ((roles
(dl-atomic-role-descendants substrate role (tbox substrate))))
(setf (gethash role (role-descendants-cache substrate)) roles)
(values roles t)))))))
(defmethod dl-prover-atomic-role-inverse ((substrate dl-prover-substrate) role)
(with-critical-section
(multiple-value-bind (val foundp)
(gethash role (atomic-role-inverse-cache substrate))
(if foundp
(values val t)
(unless *told-information-reasoning-p*
(let ((inv-role
(dl-atomic-role-inverse substrate role (tbox substrate))))
(setf (gethash role (atomic-role-inverse-cache substrate)) inv-role)
(values inv-role t)))))))
(defmethod dl-prover-told-value ((substrate racer-substrate) cd-object)
(with-critical-section
(with-slots (told-values-cache) substrate
(gethash cd-object told-values-cache))))
;;;
;;;
;;;
(defmethod dl-concept-p ((substrate racer-substrate) &rest args)
(apply #'concept-p args))
#+:midelora
(defmethod dl-concept-p ((substrate midelora-substrate) &rest args)
t)
(defmethod dl-all-atomic-concepts ((substrate racer-substrate) &rest args)
(apply #'all-atomic-concepts args))
#+:midelora
(defmethod dl-all-atomic-concepts ((substrate midelora-substrate) &rest args)
(apply #'prover::all-atomic-concepts args))
(defmethod dl-atomic-concept-children ((substrate racer-substrate) &rest args)
(apply #'atomic-concept-children args))
#+:midelora
(defmethod dl-atomic-concept-children ((substrate midelora-substrate) &rest args)
(apply #'prover::atomic-concept-children args))
;;;
;;; fuer ABox Augmentation (Rules etc.)
;;;
(defmethod dl-add-concept-assertion ((substrate racer-substrate) &rest args)
(apply #'add-concept-assertion args))
#+:midelora
(defmethod dl-add-concept-assertion ((substrate midelora-substrate) &rest args)
(apply #'prover::add-concept-assertion args))
(defmethod dl-add-role-assertion ((substrate racer-substrate) &rest args)
(apply #'add-role-assertion args))
#+:midelora
(defmethod dl-add-role-assertion ((substrate midelora-substrate) &rest args)
(apply #'prover::add-role-assertion args))
(defmethod dl-add-attribute-assertion ((substrate racer-substrate) &rest args)
(apply #'add-attribute-assertion args))
(defmethod dl-add-constraint-assertion ((substrate racer-substrate) &rest args)
(apply #'add-constraint-assertion args))
;;;
;;;
;;;
(defmethod dl-forget-concept-assertion ((substrate racer-substrate) &rest args)
(apply #'forget-concept-assertion args))
#+:midelora
(defmethod dl-forget-concept-assertion ((substrate midelora-substrate) &rest args)
(apply #'prover::forget-concept-assertion args))
(defmethod dl-forget-role-assertion ((substrate racer-substrate) &rest args)
(apply #'forget-role-assertion args))
#+:midelora
(defmethod dl-forget-role-assertion ((substrate midelora-substrate) &rest args)
(apply #'prover::forget-role-assertion args))
(defmethod dl-forget-constrained-assertion ((substrate racer-substrate) &rest args)
(apply #'forget-constrained-assertion args))
(defmethod dl-forget-constraint ((substrate racer-substrate) &rest args)
(apply #'forget-constraint args))
;;;
;;;
;;;
(defmethod dl-prover-forget-concept-assertion ((substrate dl-prover-substrate) &rest args)
(apply #'dl-forget-concept-assertion substrate args)
(substrate-needs-reset substrate))
(defmethod dl-prover-forget-role-assertion ((substrate dl-prover-substrate) &rest args)
(apply #'dl-forget-role-assertion substrate args)
(substrate-needs-reset substrate))
(defmethod dl-prover-forget-constrained-assertion ((substrate dl-prover-substrate) &rest args)
(apply #'dl-forget-constrained-assertion substrate args)
(substrate-needs-reset substrate))
(defmethod dl-prover-forget-constraint ((substrate dl-prover-substrate) &rest args)
(apply #'dl-forget-constraint substrate args)
(substrate-needs-reset substrate))
;;;
;;;
;;;
(defmethod dl-prover-add-concept-assertion ((substrate dl-prover-substrate) ind concept &key (to-abox-p t))
(with-critical-section
(let ((assertion (list ind concept)))
(when to-abox-p
(dl-add-concept-assertion substrate (abox substrate) ind concept)
(substrate-needs-reset substrate)
;;; die naechste Query braucht ein reintialisiertes
;;; Substrate, klar... dennoch sinnvoll mit dem
;;; veraenderten Substrate weiterzurechnen, s.
;;; mode 6
)
(with-slots (concept-assertions-cache individual-instance-cache) substrate
(setf (gethash (list ind concept) (individual-instance-cache substrate)) t)
(setf (gethash ind concept-assertions-cache)
(cons assertion (gethash ind concept-assertions-cache)))))))
(defmethod dl-prover-add-role-assertion ((substrate dl-prover-substrate) from to role &key (to-abox-p t))
(with-critical-section
(let ((assertion (list (list from to) role)))
(when to-abox-p
(dl-add-role-assertion substrate (abox substrate) from to role)
(substrate-needs-reset substrate))
(with-slots (role-assertions-in-domain-cache role-assertions-in-range-cache) substrate
(setf (gethash from role-assertions-in-domain-cache)
(cons assertion (gethash from role-assertions-in-domain-cache)))
(setf (gethash to role-assertions-in-range-cache)
(cons assertion (gethash to role-assertions-in-range-cache)))))))
#+:midelora
(defmethod dl-prover-add-attribute-assertion ((substrate midelora-substrate) ind object attribute &key (to-abox-p t))
(declare (ignorable ind object attribute to-abox-p))
nil)
(defmethod dl-prover-add-attribute-assertion ((substrate racer-substrate) ind object attribute &key (to-abox-p t))
(with-critical-section
(when to-abox-p
(dl-add-attribute-assertion substrate (abox substrate) ind object attribute)
(substrate-needs-reset substrate))
(with-slots (individual-attribute-fillers-cache) substrate
(setf (gethash (list ind attribute) individual-attribute-fillers-cache)
(cons object (gethash (list ind attribute) individual-attribute-fillers-cache))))))
#+:midelora
(defmethod dl-prover-add-constraint-assertion ((substrate midelora-substrate) constraint &key (to-abox-p t))
(declare (ignorable constraint to-abox-p))
nil)
(defmethod dl-prover-add-constraint-assertion ((substrate racer-substrate) constraint &key (to-abox-p t))
(with-critical-section
(when to-abox-p
(dl-add-constraint-assertion substrate (abox substrate) constraint)
(substrate-needs-reset substrate))
(with-slots (constraints-cache) substrate
(push constraint constraints-cache))))
;;;
;;;
;;;
#-:dlmaps
(defmethod find-node ((substrate racer-substrate) ind &key &allow-other-keys)
ind)
#-:dlmaps
(defmethod get-associated-substrate-node ((substrate racer-substrate) abox-ind)
(find-node substrate abox-ind :error-p nil))
;;;
;;;
;;;
(defun set-tbox (substrate
&key load-from-file error-p new-tbox-p tbox abox new-abox-p &allow-other-keys)
(let ((tbox-name
(or (convert-to-racer-tbox-name tbox (racer-package substrate))
;;(convert-to-racer-tbox-name tbox :cl-user)
(when (and abox new-abox-p)
;;; RACER-TBOXEN sind immer in cl-user!
+racer-substrate-default-tbox+))))
(with-slots (tbox) substrate
(setf tbox
(if load-from-file
(current-tbox)
(when tbox-name
(if new-tbox-p
(progn
(when (find-tbox tbox-name nil)
(forget-tbox tbox-name))
(init-tbox tbox-name)
tbox-name)
(or (if (find-tbox tbox-name nil)
tbox-name
nil)
(when error-p
(nrql-error "Can't find TBox ~A!" tbox-name))
tbox-name))))))))
(defun set-abox (substrate
&key load-from-file error-p new-abox-p abox &allow-other-keys)
(let ((abox-name
(convert-to-racer-abox-name abox (racer-package substrate))
;;(convert-to-racer-abox-name abox :cl-user)
))
(with-slots (abox tbox) substrate
(setf abox
(if load-from-file
(current-abox)
(when abox-name
(if new-abox-p
(progn
(when (find-abox abox-name nil)
(forget-abox abox-name))
(init-abox abox-name tbox)
abox-name)
(or (if (find-abox abox-name nil)
abox-name
nil)
(when error-p
(nrql-error "Can't find ABox ~A!" abox-name))
abox-name))))))))
;;;
;;;
;;;
(defmethod initialize-instance :after ((substrate racer-substrate) &rest args
&key load-from-file mirror-abox-p &allow-other-keys)
(declare (ignorable mirror-abox-p))
(with-critical-section
(when load-from-file
(let ((*package* (racer-package substrate)))
(load load-from-file)))
(apply #'set-tbox substrate args)
(apply #'set-abox substrate args)
(setf (slot-value substrate 'dbox)
(or (find-dbox (tbox substrate) :error-p nil)
(create-dbox (tbox substrate))))))
#+:midelora
(defmethod initialize-instance :after ((substrate midelora-substrate) &rest args)
(setf (slot-value substrate 'abox) substrate
(slot-value substrate 'tbox) (prover::tbox substrate))
(setf (slot-value substrate 'dbox)
(or (find-dbox (tbox substrate) :error-p nil)
(create-dbox (tbox substrate)))))
;;;
;;;
;;;
(defmethod delete-substrate :after ((substrate dl-prover-substrate) &key &allow-other-keys)
(when (dbox substrate)
(setf *all-dboxes*
(delete (dbox substrate) *all-dboxes*))))
;;;
;;;
;;;
(defmethod is-datatype-property-some-value-p ((substrate racer-substrate) concept)
(and (consp concept)
(eq (first concept) 'some)
(let ((qual (third concept)))
(and (consp qual)
(third qual) ; Wert auch wirklich vorhanden?
(member (second qual)
+racer-internal-datatype-property-roles+)))))
#+:midelora
(defmethod is-datatype-property-some-value-p ((substrate midelora-substrate) concept)
(declare (ignore concept))
nil)
(defmethod is-datatype-property-at-least-value-p ((substrate racer-substrate) concept)
(and (consp concept)
(eq (first concept) 'at-least)
(let ((qual (fourth concept)))
(and (consp qual)
(third qual) ; Wert auch wirklich vorhanden?
(member (second qual)
+racer-internal-datatype-property-roles+)))))
#+:midelora
(defmethod is-datatype-property-at-least-value-p ((substrate midelora-substrate) concept)
(declare (ignore concept))
nil)
;;;
;;;
;;;
(defmethod compute-abox-mirror ((substrate dl-prover-substrate) &key &allow-other-keys)
(with-critical-section
(let ((ancestors (mht :test #'equal :size 1000)))
(with-slots (abox tbox
told-values-cache
datatype-property-values-cache
individual-attribute-fillers-cache
role-assertions-in-domain-cache
role-assertions-in-range-cache
concept-assertions-cache
constraint-entailed-cache
individual-instance-cache) substrate
(labels ((register-is-instance-of (ind concept)
(if (gethash concept (known-concept-instances-cache substrate))
(push ind (gethash concept (known-concept-instances-cache substrate)))
(setf (gethash concept (known-concept-instances-cache substrate))
(list ind)))
(setf (gethash (list ind concept) (individual-instance-cache substrate)) t))
(rec-lookup (a &optional found)
(let ((val (gethash a told-values-cache))
(found (cons a found)))
(when val
(if (consp val)
(dolist (b val)
(unless (member b found)
(let ((x (rec-lookup b found)))
(when x
(return-from rec-lookup x)))))
val))))
(register-told-value-for (a b)
(let ((av (rec-lookup a))
(bv (rec-lookup b)))
(if (symbolp a)
(if (symbolp b)
;;; a = b
(if av
(setf (gethash b told-values-cache) av)
(if bv
(setf (gethash a told-values-cache) bv)
(progn
(if (gethash a told-values-cache)
(push b (gethash a told-values-cache))
(setf (gethash a told-values-cache) (list b)))
(if (gethash b told-values-cache)
(push a (gethash b told-values-cache))
(setf (gethash b told-values-cache) (list a))))))
;;; a = 3
(setf (gethash a told-values-cache) b))
(if (symbolp b)
;;; 3 = b
(setf (gethash b told-values-cache) a)
;;; 3 = 4
))))
(register-datatype-property-value (property ind property-value concept)
(if (gethash ind datatype-property-values-cache)
(push property-value (gethash ind datatype-property-values-cache))
(setf (gethash ind datatype-property-values-cache)
(list property-value)))
;;; also add to ABox!
(when *add-role-assertions-for-datatype-properties-p*
(let ((datatype-succs
(mapcar #'cadar
(remove-if-not #'(lambda (x)
(eq (second x) property))
(dl-prover-all-role-assertions-for-individual-in-domain
substrate ind)))))
;; is there a datatype successor which has the required concept assertion?
;; -> dont need to add another one!
(unless (some #'(lambda (succ)
(gethash (list succ concept)
(individual-instance-cache substrate)))
datatype-succs)
(let ((new-ind
(intern (format nil "~A-~A"
+secret-prefix+
(incf *sym-count*))
(racer-package substrate))))
(dl-prover-add-role-assertion substrate
ind
new-ind
property)
(dl-prover-add-concept-assertion substrate
new-ind
concept))))))
(get-implied-concepts-for-cache (concept)
(let ((concepts
(or (gethash concept ancestors)
(setf (gethash concept ancestors)
(remove-duplicates
(cons concept
(cons 'top
(cons '*top*
(if (consp concept)
(append
(when (and *ensure-tbox-classification-p*
(dl-tbox-classified-p substrate tbox)
*classify-concepts-in-instance-assertions-p*)
(append
(reduce #'append (dl-atomic-concept-ancestors substrate concept tbox))
(reduce #'append (mapcar #'ensure-list
(dl-atomic-concept-synonyms substrate concept tbox)))))
(case (first concept)
(and (reduce #'append
(mapcar #'get-implied-concepts-for-cache (rest concept))))
(some
(when (is-datatype-property-some-value-p substrate concept)
(let ((role (second concept))
(qual (third concept)))
(mapcar #'(lambda (qc)
`(some ,role ,qc))
(get-implied-concepts-for-cache qual)))))
(at-least
(when (is-datatype-property-at-least-value-p substrate concept)
(let ((role (third concept))
(qual (fourth concept))
(n (second concept)))
(mapcar #'(lambda (qc)
`(at-least ,n ,role ,qc))
(get-implied-concepts-for-cache qual)))))
((min max divisible not-divisible string= string<>
> >= < <= <> = equal unequal)
(let ((attrib (second concept)))
`((an ,attrib)
(a ,attrib))))
((a an)
(let ((attrib (second concept)))
`((an ,attrib)
(a ,attrib))))))
(when *ensure-tbox-classification-p*
(unless (dl-tbox-classified-p substrate tbox)
(dl-classify-tbox substrate tbox))
(append
(reduce #'append (dl-atomic-concept-ancestors substrate concept tbox))
(reduce #'append
(mapcar #'ensure-list
(dl-atomic-concept-synonyms substrate concept tbox)))))))))
:test #'equal)))))
;; (write concepts)
concepts)))
;;;
;;; Start Mirroring
;;;
(let ((*told-information-reasoning-p* nil)
(datatype-assertions nil))
;; (princ 1)
(dolist (c (dl-prover-all-constraints substrate))
(setf (gethash c constraint-entailed-cache) t)
(when (member (to-keyword (first c))
'(:= :equal :string= :boolean=))
(apply #'register-told-value-for (rest c))))
;; (princ 2)
(dolist (role (dl-prover-all-roles substrate))
(when
#+:racer-server (role-p role tbox)
#-:racer-server t
;; all-roles liefert mist!
(dl-prover-atomic-role-descendants substrate role)
(dl-prover-atomic-role-inverse substrate role)))
;; (princ 3)
(dolist (ind (dl-prover-all-individuals substrate))
(setf (gethash (list ind +individual-exists-concept+)
(individual-instance-cache substrate)) t)
(register-is-instance-of ind 'top)
(register-is-instance-of ind '*top*))
;; (princ 4)
(dolist (role-assertions (if *initial-abox-mirroring-p*
(list (dl-all-annotation-role-assertions substrate abox)
(dl-all-role-assertions substrate abox))
(list (dl-all-annotation-role-assertions substrate))))
(dolist (ra role-assertions)
(let ((from (first (first ra)))
(to (second (first ra))))
(if (gethash to role-assertions-in-range-cache)
(push ra (gethash to role-assertions-in-range-cache))
(setf (gethash to role-assertions-in-range-cache)
(list ra)))
(if (gethash from role-assertions-in-domain-cache)
(push ra (gethash from role-assertions-in-domain-cache))
(setf (gethash from role-assertions-in-domain-cache)
(list ra))))))
;; (princ 5)
(dolist (aa (dl-all-attribute-assertions substrate abox))
(let* ((aa (rest aa))
(from (first aa))
(to (second aa))
(attribute (third aa))
(entry (list from attribute)))
(if (gethash entry individual-attribute-fillers-cache)
(push to (gethash entry individual-attribute-fillers-cache))
(setf (gethash entry individual-attribute-fillers-cache)
(list to)))))
;; (princ 6)
(dolist (concept-assertions (list (dl-all-annotation-concept-assertions substrate abox)
(dl-all-concept-assertions substrate abox)))
(dolist (ca concept-assertions)
(let ((ind (first ca))
(concept (second ca)))
(when (gethash (list ind +individual-exists-concept+)
(individual-instance-cache substrate))
;;; hier sollen nur die ABox-Individuen bearbeitet werden;
;;; Racer gibt unter all-annotation-concept-assertions auch
;;; Klassen-Annotation etc. zurueck!
(if (gethash ind concept-assertions-cache)
(push ca (gethash ind concept-assertions-cache))
(setf (gethash ind concept-assertions-cache) (list ca)))
(let ((dtp-p
(or (is-datatype-property-some-value-p substrate concept)
(is-datatype-property-at-least-value-p substrate concept))))
(if (or *initial-abox-mirroring-p* dtp-p)
(progn
(when dtp-p
(push ca datatype-assertions))
(let ((concepts (get-implied-concepts-for-cache concept)))
(dolist (concept concepts) ; orig. concept ist in (get-implied-...) enthalten!
(register-is-instance-of ind concept))))
(register-is-instance-of ind concept)))))))
;; (princ 7)
(dolist (da datatype-assertions)
(let ((ind (first da))
(concept (second da)))
;;;
;;; Datatype-Property Encoding of Racer
;;;
(cond ((is-datatype-property-some-value-p substrate concept)
(let* ((property (second concept))
(internal-attribute (second (third concept)))
(property-value (list property
(third (third concept)))))
(declare (ignorable internal-attribute))
;;; e.g.
;;; (SOME |http://www.owl-ontologies.com/unnamed.owl#age|
;;; (EQUAL RACER-INTERNAL%HAS-INTEGER-VALUE 35))
(register-datatype-property-value property ind property-value
(third concept))))
((is-datatype-property-at-least-value-p substrate concept)
(let* ((property (third concept))
(internal-attribute (second (fourth concept)))
(property-value (list property
(third (fourth concept)))))
(declare (ignorable internal-attribute))
;;; e.g.
;;; (AT-LEAST 3 |http://www.owl-ontologies.com/unnamed.owl#id|
;;; (EQUAL RACER-INTERNAL%HAS-INTEGER-VALUE 35))
(register-datatype-property-value property ind property-value
(fourth concept)))))))))))))
(defmethod initialize-instance :after ((substrate tbox-mirror-substrate) &rest args
&key &allow-other-keys)
(declare (ignorable args))
(setf (slot-value substrate 'mirror-of-tbox)
(tbox substrate))
;; (setf (saved-state-vector substrate)
;; (get-state-vector substrate))
)
(defmethod compute-tbox-mirror ((substrate tbox-mirror-substrate))
(with-critical-section
(with-slots (abox tbox
mirror-of-tbox
role-descendants-cache
atomic-role-inverse-cache
concept-instances-cache
;; constraints-cache
abox-individuals-cache concept-assertions-cache
role-assertions-in-range-cache
role-assertions-in-domain-cache
individual-instance-cache
individual-attribute-fillers-cache) substrate
(let* ((package
#-:midelora (racer-package substrate)
#+:midelora (find-package :prover))
(has-child-role (change-package-of-description 'has-child
package))
(has-parent-role (change-package-of-description 'has-parent
package))
(has-descendant-role (change-package-of-description 'has-descendant
package))
(has-ancestor-role (change-package-of-description 'has-ancestor
package)))
(let ((concepts
(cons #-:midelora
'(racer::*top* racer::top)
#+:midelora
'(prover::top)
(cons #-:midelora
'(racer::*bottom* racer::bottom)
#+:midelora
'(prover::bottom)
(remove nil
(mapcar #'(lambda (x)
(let ((x (ensure-list x)))
(remove-if #'(lambda (x)
(case (to-keyword x)
((:bottom :*bottom* :top :*top*) t)
(otherwise
(not (dl-concept-p substrate x tbox)))))
x)))
(dl-all-atomic-concepts substrate tbox)))))))
(setf abox-individuals-cache (mapcar #'first concepts))
(dolist (concept concepts)
(let ((name (first concept)))
(setf (gethash (list name +individual-exists-concept+) individual-instance-cache) t)
(setf (gethash (list name name) individual-instance-cache) t)
(setf (gethash name concept-assertions-cache) (list name))
(dolist (equi concept)
(push equi (gethash name concept-assertions-cache))
(setf (gethash (list name equi) individual-instance-cache) t)
(dolist (concept2 concepts)
(unless (equal concept concept2)
(dolist (equi concept2)
(setf (gethash (list name equi) individual-instance-cache) nil))))
(setf (gethash equi concept-instances-cache)
(list name)))
(let* ((children (remove-if-not #'(lambda (x) (dl-concept-p substrate x tbox))
(mapcar #'first (dl-atomic-concept-children substrate name tbox))))
;; Annahme: der erste Name in der Liste der Synonyme ist
;; immer der Knotenname (Reihenfolge der Synonyme wie bei
;; all-atomic-concepts angenommen!)
(from-assertions (mapcar #'(lambda (child)
(list (list name child) has-child-role))
children)))
(setf (gethash name role-assertions-in-domain-cache) from-assertions)
(dolist (assertion from-assertions)
(let ((child (second (first assertion))))
(if (gethash child role-assertions-in-range-cache)
(push assertion (gethash child role-assertions-in-range-cache))
(setf (gethash child role-assertions-in-range-cache) (list assertion)))))))))
;(set-tbox substrate :tbox 'default :new-tbox-p nil)
;(set-abox substrate :abox 'default :new-abox-p nil)
(setf tbox nil
abox nil)
(setf (gethash has-parent-role role-descendants-cache) (list has-parent-role))
(setf (gethash has-child-role role-descendants-cache) (list has-child-role))
(setf (gethash has-descendant-role role-descendants-cache)
(list has-descendant-role has-child-role))
(setf (gethash has-ancestor-role role-descendants-cache)
(list has-ancestor-role has-parent-role))
(setf (transitive-roles-cache substrate)
(list has-descendant-role has-ancestor-role))
(dolist (pair (list (list has-parent-role has-child-role)
(list has-descendant-role has-ancestor-role)))
(setf (gethash (first pair) atomic-role-inverse-cache)
(second pair))
(setf (gethash (second pair) atomic-role-inverse-cache)
(first pair)))))))
;;;
;;;
;;;
(defmethod convert-to-dl-prover-individual-name ((substrate racer-substrate) ind)
(convert-to-racer-individual-name ind (racer-package substrate)))
#+:midelora
(defmethod convert-to-dl-prover-individual-name ((substrate midelora-substrate) ind)
(change-package-of-description ind (find-package :prover)))
(defmethod convert-to-dl-prover-attribute-expression ((substrate racer-substrate) attrib)
(convert-to-racer-attribute-expression attrib (racer-package substrate)))
| 63,060 | Common Lisp | .lisp | 1,173 | 38.821824 | 142 | 0.588527 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 145ce23564dd2fdb4a56377800732f5ff7c27b91de52ec7dafec3e884c2daa25 | 12,506 | [
-1
] |
12,507 | jepd-substrate4.lisp | lambdamikel_DLMAPS/src/thematic-substrate/jepd-substrate4.lisp | ;;; -*- Mode: Lisp; Syntax: Ansi-Common-Lisp; Package: THEMATIC-SUBSTRATE; Base: 10 -*-
(in-package :THEMATIC-SUBSTRATE)
;;;
;;;
;;;
(defgeneric compute-minimal-edge-label (rolebox-edge &key &allow-other-keys))
(defgeneric label-minimal-p (jepd-substrate &key &allow-other-keys))
(defgeneric compute-minimal-label (jepd-substrate &key &allow-other-keys))
(defgeneric add-missing-edges (jepd-substrate &key nodes &allow-other-keys))
;;;
;;;
;;;
(defpersistentclass jepd-node-description (rolebox-node-description))
(defpersistentclass jepd-edge-description (rolebox-edge-description))
(defpersistentclass jepd-substrate (rolebox-substrate))
(defpersistentclass jepd-substrate-node (rolebox-substrate-node))
(defpersistentclass jepd-substrate-edge (rolebox-substrate-edge))
(defun jepd-substrate-edge-p (edge)
(typep edge 'jepd-substrate-edge))
(defun jepd-substrate-node-p (edge)
(typep edge 'jepd-substrate-node))
;;;
;;;
;;;
(defmethod get-standard-node-description-class ((substrate jepd-substrate))
'jepd-node-description)
(defmethod get-standard-edge-description-class ((substrate jepd-substrate))
'jepd-edge-description)
(defmethod get-standard-edge-class ((substrate jepd-substrate))
'jepd-substrate-edge)
(defmethod get-standard-node-class ((substrate jepd-substrate))
'jepd-substrate-node)
;;;
;;;
;;;
;;;
;;;
;;;
(defmethod initialize-instance :after ((substrate jepd-substrate) &rest initargs &key (rbox *cur-rbox*))
(unless (typep (find-rbox rbox) 'jepd-rolebox)
(error "Give me a JEPD-rolebox!")))
;;;
;;;
;;;
(defmethod create-node ((substrate jepd-substrate) (name symbol) (description jepd-node-description)
&rest args)
(apply #'make-node substrate :name name :description description args))
(defmethod make-node ((substrate jepd-substrate) &rest args)
(apply #'call-next-method substrate args))
(defmethod create-edge ((substrate jepd-substrate) (from jepd-substrate-node) (to jepd-substrate-node)
(description jepd-edge-description)
&rest args)
(apply #'make-edge substrate from to
:description description
args))
(defmethod make-edge ((substrate jepd-substrate) (from jepd-substrate-node) (to jepd-substrate-node)
&rest args
&key
(error-p t)
description
(create-inverse-p t)
copy-p
&allow-other-keys)
(let ((edges (get-edges-between substrate from to :error-p nil)))
(when (and error-p
edges)
(error "~A is a JEPD substrate! Edge between ~A and ~A already exists!" substrate from to))
(let ((edge (apply #'call-next-method substrate from to
:description description
:create-inverse-p nil
args)))
(when (and (not copy-p)
create-inverse-p)
(cond ((eq from to)
;;; nur beim JEPD-Substrate kann ich sicher
;;; sein, dass die Inverse die Kante selbst ist!
;;; ansonsten können nämlich die Beschreibungen
;;; an den Kanten differieren, bzw. werden
;;; gebraucht, um eine Inkonsistenz festzustellen
;;; z.B. (1,1) : PP -> (1,1) : PPI
(with-slots (inverse-edge) edge
(setf inverse-edge edge)))
(t
(with-slots (rbox) substrate
(when rbox
(let* ((inv-description
(make-inverse-description rbox description)))
(when inv-description
(let* ((iedge (apply #'make-edge substrate to from
:description inv-description
:create-inverse-p nil
args)))
(with-slots (inverse-edge) iedge
(setf inverse-edge edge))
(with-slots (inverse-edge) edge
(setf inverse-edge iedge))))))))))
edge)))
;;;
;;;
;;;
(defmethod delete-edge ((substrate jepd-substrate) (edge jepd-substrate-edge)
&rest args
&key (delete-inverse-p t) (error-p t) &allow-other-keys)
(apply #'call-next-method substrate edge
:delete-inverse-p (and delete-inverse-p
(not (reflexive-edge-p edge)))
:error-p error-p
args))
;;;
;;;
;;;
(defmethod get-implied-label ((edge jepd-substrate-edge) &key (edges (get-edges (in-graph edge))) &allow-other-keys)
(with-slots (rbox) (in-graph edge)
(with-marked-objects (edges)
(let ((comps nil)
(support (get-support edge)))
(dolist (supp support)
(let ((r (first supp))
(s (second supp)))
(when (and (marked-p r)
(marked-p s))
(push (lookup rbox r s) comps))))
;;; make-and-description liefert nil, wenn equivalent zu *bottom*
(let* ((descriptions (cons (description edge)
(mapcar #'(lambda (comp)
(change-textual-description (copy (description edge)) comp))
comps)))
(label
(make-and-description (first descriptions)
:descriptions (rest descriptions))))
(if (inconsistent-p label)
(values nil support)
label))))))
(defmethod consistent-p ((substrate jepd-substrate) &key
(check-node-labels-p t)
(check-edge-labels-p t)
(edges (get-edges substrate)) strict-p &allow-other-keys)
(and
(=> check-node-labels-p (every #'consistent-p (get-nodes substrate)))
(=> check-edge-labels-p (every #'consistent-p (get-edges substrate)) )
(=> strict-p
;;; zw. jedem Paar Knoten genau eine Kante?
(every #'(lambda (i)
(every #'(lambda (j)
(let ((e (get-edges-between substrate i j)))
(and e
(not (cdr e)))))
(get-nodes substrate)))
(get-nodes substrate)))
(every #'get-implied-label edges)))
(defmethod compute-minimal-label ((substrate jepd-substrate) &key (edges (get-edges substrate)) &allow-other-keys)
(let ((change t))
(loop while change do
(setf change nil)
(dolist (edge edges)
(multiple-value-bind (new-label support)
(get-implied-label edge :edges edges)
(if (not new-label)
(return-from compute-minimal-label
(values nil support))
(setf change (not (implies-p (description edge) new-label))
(description edge) new-label)))))
substrate))
(defmethod add-missing-edges ((substrate jepd-substrate)
&key
(edge-constructor
#'(lambda (from to)
(create-edge substrate
from to
(make-edge-description
(get-standard-edge-description-class substrate)
(full-disjunctive-role (substrate-rbox substrate)))
:create-inverse-p t)))
&allow-other-keys)
(dolist (from-to-pair (get-missing-edges substrate :loops-p nil :inverses-p nil))
(apply edge-constructor from-to-pair))
substrate)
(defmethod apply-rolebox-axioms ((substrate jepd-substrate) &rest args &key
&allow-other-keys)
(apply #'add-missing-edges substrate args)
(compute-minimal-label substrate))
;;;
;;;
;;;
(defmethod eq-edge-p ((edge jepd-substrate-edge))
(equal '(eq) (textual-description (description edge))))
(defmethod eq-collapse ((substrate jepd-substrate))
(let ((eq-edges
(remove-if #'reflexive-edge-p
(remove-if-not #'eq-edge-p
(get-edges substrate)))))
(loop while eq-edges do
(let ((edge (first eq-edges)))
(setf eq-edges (delete edge eq-edges))
(setf eq-edges (delete (inverse-edge edge) eq-edges))
(join-nodes (from edge) (to edge))))
substrate))
(defmethod join-nodes ((a jepd-substrate-node) (b jepd-substrate-node))
(unless (eq (in-graph a) (in-graph b))
(error "Nodes are not in same graph!"))
(let ((description (make-and-description (description a)
:descriptions (list (description b))))
(graph (in-graph a)))
(delete-node graph b)
(change-description a description)))
;;;
;;; Prädikate
;;;
(defmethod label-minimal-p ((substrate jepd-substrate) &key &allow-other-keys)
(every #'(lambda (edge)
(let ((impl (get-implied-label edge)))
(and impl
(equivalent-p impl (description edge)))))
(get-edges substrate)))
#|
(with-rbox (test-box :type jepd-rolebox :roles (r eq)
:delete-if-exists-p t
:inverse-roles ((r r))
:delete-if-exists-p t
;:reflexive-roles (eq)
:axioms
((r r r)
(r eq r)
(eq eq eq)
(eq r r)))
(with-substrate (hello :type 'jepd-substrate :delete-if-exists-p t)
(setf *x* *cur-substrate*)
(node a (ncon a-descr))
(node b (ncon b-descr))
(node c (ncon c-descr))
(edge a b (econ r))
(edge b c (econ r))
;(edge a c (econ r))
(princ (label-minimal-p *cur-substrate*))
(terpri)
;(add-missing-edges *cur-substrate*)
;; (princ (label-minimal-p *cur-substrate*))
;(compute-minimal-label *cur-substrate*)
;(princ (label-minimal-p *cur-substrate*))
(apply-rolebox-axioms *cur-substrate*)
(visualize *cur-substrate*)))
(with-rbox (rcc5-rolebox)
(with-substrate (test :type 'jepd-substrate :delete-if-exists-p t)
(setf *x* *cur-substrate*)
(node a (ncon a))
(node b (ncon b))
(node c (ncon c))
(edge a b (econ pp))
(edge b c (econ pp))
(apply-rolebox-axioms *cur-substrate*)
(add-missing-edges *x*)
(compute-minimal-label *x*)
(visualize *x*)))
(with-rbox (rcc5-rolebox)
(with-substrate (hello :type 'jepd-substrate :delete-if-exists-p t)
(setf *x* *cur-substrate*)
(node n0 (ncon 0))
(node n1 (ncon 1))
(node n2 (ncon 2))
(node n3 (ncon 3))
(edge n0 n1 (econ ppi))
(edge n0 n2 (econ ppi))
(edge n1 n3 (econ ppi))
(edge n1 n2 (econ ppi))
(edge n2 n3 (econ pp))
(apply-rolebox-axioms *cur-substrate*)
(break "~A" (consistent-p *cur-substrate*))
(visualize *cur-substrate*)))
(with-rbox (rcc5-rolebox)
(with-substrate (hello :type 'jepd-substrate :delete-if-exists-p t)
(node a (ncon a-descr))
(node b (ncon b-descr))
(node c (ncon c-descr))
(setf *x* *cur-substrate*)
(edge a b (econ pp))
(edge b c (econ pp))
(add-missing-edges *cur-substrate*)
(compute-minimal-label *cur-substrate*)
(visualize *cur-substrate*)))
(with-rbox (rcc5-rolebox)
(with-substrate (hello :type 'jepd-substrate :delete-if-exists-p t)
(node a (ncon a-descr))
(node b (ncon b-descr))
(node c (ncon c-descr))
(setf *x* *cur-substrate*)
(edge a b (econ pp))
(edge a c (econ (pp dr)))
(edge b c (econ pp))
(compute-minimal-label *x*)
(visualize *x*)))
(with-rbox (rcc8-rolebox)
(with-substrate (hello :type 'jepd-substrate :delete-if-exists-p t)
(node u (ncon c-descr))
(node y (ncon b-descr))
(node z (ncon c-descr))
(setf *x* *cur-substrate*)
(edge y z (econ ec))
(edge y u (econ po))
(edge z u (econ (tpp ntpp)))
(add-missing-edges *x*)
;(scramble *x*)
(compute-minimal-label *x*)
(princ (consistent-p *x* :strict-p t))
(visualize *x*)))
(with-rbox (rcc8-rolebox)
(with-substrate (hello :type 'jepd-substrate :delete-if-exists-p t)
(node a (ncon a))
(node b (ncon b))
(node c (ncon c))
(node d (ncon d))
(node e (ncon e))
(node f (ncon f))
(node g (ncon g))
(setf *x* *cur-substrate*)
(edge a b (econ tpp))
(edge a c (econ tpp))
(edge c d (econ tpp))
(edge b d (econ tpp))
(edge a d (econ ntpp))
(edge d f (econ ntpp))
(edge d e (econ tpp))
(edge d g (econ tpp))
(edge e f (econ tpp))
(edge g f (econ tpp))
(edge c b (econ po))
(edge g e (econ po))
(edge b e (econ ntpp))
(edge c g (econ ntpp))
(edge a g (econ ntpp))
(edge a e (econ ntpp))
(add-missing-edges *x*)
;(scramble *x*)
(compute-minimal-label *x*)
(let ((completions
(get-all-atomic-configurations *x*
:final-check-fn #'consistent-p
:how-many 1000)))
(visualize completions))))
(with-rbox (rcc8-rolebox)
(with-substrate (hello :type 'jepd-substrate :delete-if-exists-p t)
(node a (ncon a))
(node b (ncon b))
(node c (ncon c))
(edge a b (econ eq))
(edge a c (econ po))
(setf *x* *cur-substrate*)
(add-missing-edges *x*)
(compute-minimal-label *x*)
(visualize (list *x*
(eq-collapse (copy *x*))))))
(with-rbox (rcc5-rolebox)
(with-substrate (test :type 'jepd-substrate :delete-if-exists-p t)
(setf *x* *cur-substrate*)
(node a (ncon a))
(node b (ncon b))
(node c (ncon c))
(node d (ncon d))
(edge a b (econ pp))
(edge b c (econ pp))
(edge b d (econ dr))
;(apply-rolebox-axioms *cur-substrate*)
;(add-missing-edges *x*)
;(compute-minimal-label *x*)
(visualize (list *x*
(let ((x (copy *x*)))
(add-missing-edges x)
x)
(let ((x (copy *x*)))
(apply-rolebox-axioms x)
x)))))
|#
| 14,870 | Common Lisp | .lisp | 371 | 28.797844 | 116 | 0.548307 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 90036de0840dc8a0c7833e14620cd49206c277c76f4bf2a26b58b35162ccfab5 | 12,507 | [
-1
] |
12,508 | racer-conversions3.lisp | lambdamikel_DLMAPS/src/thematic-substrate/racer-conversions3.lisp | ;;; -*- Mode: Lisp; Syntax: Ansi-Common-Lisp; Package: THEMATIC-SUBSTRATE; Base: 10 -*-
(in-package :THEMATIC-SUBSTRATE)
#+(and :midelora (not :dlmaps))
(defun nrql-error (&rest args)
(apply #'error args))
(defconstant +racer-cd-predicates+
'(:min :max :divisible :not-divisible :string= :string<>
:> :>= :< :<= :<> := :equal :unequal
:boolean= :boolean<>))
;;;
;;; Diese Funktionen bestimmen, was letztlich zum RACER-Server gesendet wird!!!
;;;
(defun convert-to-racer-individual-name (expr &optional package)
(normalize-name
(if package
(change-package-of-description expr
#-:dlmaps package
#+:dlmaps (or package :cl-user))
expr)))
(defun convert-to-racer-tbox-name (expr &optional package)
(normalize-name
(if package
(change-package-of-description expr
#-:dlmaps package
#+:dlmaps (or package :cl-user))
expr)))
(defun convert-to-racer-abox-name (expr &optional package)
(normalize-name
(if package
(change-package-of-description expr
#-:dlmaps package
#+:dlmaps (or package :cl-user))
expr)))
(defun convert-to-racer-role-expression (expr &optional package)
(normalize-racer-role
(if package
(change-package-of-description expr package)
expr)))
(defun convert-to-racer-attribute-expression (expr &optional package)
(if package
(change-package-of-description expr package)
expr))
(defun convert-to-racer-concept-expression (expr &optional package)
(normalize-racer-concept
(if package
(change-package-of-description expr package)
expr)))
(defun convert-to-racer-constraint-expression (expr &optional package)
(if package
(change-package-of-description expr package)
expr))
;;;
;;;
;;;
(defun normalize-racer-concept (concept)
(labels ((do-it (concept)
(if (consp concept)
(let ((op (intern (format nil "~A" (first concept)) :keyword))
(rel-op (first concept)))
(case op
((:not)
`(,rel-op ,(do-it (second concept))))
((:or :and)
`(,rel-op ,@(mapcar #'do-it (rest concept))))
((:some :all)
`(,rel-op ,(normalize-racer-role (second concept))
,(do-it (third concept))))
((:at-least :at-most :exactly)
`(,rel-op ,(second concept)
,(normalize-racer-role (third concept))
,@(when (fourth concept)
(list (do-it (fourth concept))))))
((:a :an :no)
`(,rel-op ,(second concept)))
((:min :max :divisible :not-divisible
:string= :string<>
:boolean= :boolean<>
:> :>= :< :<= :<> := :equal :unequal)
concept)
(otherwise
#-:dlmaps (nrql-error "Parser error: what is ~A?" concept)
#+:dlmaps (error "Parser error: what is ~A?" concept))))
concept)))
(do-it concept)))
(defun is-valid-racer-concept-expression-p (concept &key (tbox nil tbox-supplied-p))
(labels ((do-it (concept)
(or (and concept
(symbolp concept))
(and (consp concept)
(let ((op (intern (format nil "~A" (first concept)) :keyword)))
(case op
((:or :and :not)
(do-it (second concept)))
((:all :some)
(and (if tbox-supplied-p
(is-valid-racer-role-expression-p (second concept)
:tbox tbox)
(is-valid-racer-role-expression-p (second concept)))
(do-it (third concept))))
((:at-least :at-most :exactly)
(and (if tbox-supplied-p
(is-valid-racer-role-expression-p (third concept)
:tbox tbox)
(is-valid-racer-role-expression-p (third concept)))
(=> (fourth concept)
(do-it (fourth concept)))))
((:a :an :no)
(if tbox-supplied-p
(is-valid-racer-attribute-expression-p (second concept) :tbox tbox)
(is-valid-racer-attribute-expression-p (second concept))))
((:min :max :divisible :not-divisible)
(and (if tbox-supplied-p
(is-valid-racer-attribute-expression-p (second concept) :tbox tbox)
(is-valid-racer-attribute-expression-p (second concept)))
(integerp (third concept))))
((:string= :string<>)
(and (if tbox-supplied-p
(is-valid-racer-attribute-expression-p (second concept) :tbox tbox)
(is-valid-racer-attribute-expression-p (second concept)))
(or (if tbox-supplied-p
(is-valid-racer-attribute-expression-p (third concept) :tbox tbox)
(is-valid-racer-attribute-expression-p (third concept)))
(stringp (third concept)))))
((:boolean= :boolean<>)
(and (if tbox-supplied-p
(is-valid-racer-attribute-expression-p (second concept) :tbox tbox)
(is-valid-racer-attribute-expression-p (second concept)))
(or (if tbox-supplied-p
(is-valid-racer-attribute-expression-p (third concept) :tbox tbox)
(is-valid-racer-attribute-expression-p (third concept)))
(member (third concept) '(#T #F)))))
((:> :>= :< :<= :<> := :equal :unequal)
(and (is-valid-racer-aexpr-p (second concept))
(is-valid-racer-aexpr-p (third concept))))
(otherwise nil)))))))
(do-it concept)))
(defun is-valid-racer-constraint-expression-p (expr)
(declare (ignorable expr))
#|
(member (intern (format nil "~a" expr) :keyword)
'(:> :>= :< :<= :<> :=
:equal :unequal
:string= :string<>
:min :max :divisible :not-divisible))
|# t)
;;;
;;;
;;;
(defun normalize-racer-role (role)
(labels ((do-it (role &key negated-p inverse-p)
(if (symbolp role)
(if (not negated-p)
(if (not inverse-p)
role
`(inv ,role))
(if (not inverse-p)
`(not ,role)
`(not (inv ,role))))
(if (not (cdr role))
(do-it (car role)
:negated-p negated-p
:inverse-p inverse-p)
(ecase (first role)
(inv (do-it (second role)
:negated-p negated-p
:inverse-p (not inverse-p)))
(not (do-it (second role)
:negated-p (not negated-p)
:inverse-p inverse-p)))))))
(do-it role)))
(defun is-valid-racer-datatype-role-expression-p (role &key
(tbox nil tbox-supplied-p)
check-p)
(and (if tbox-supplied-p
(is-valid-racer-role-expression-p role
:check-p check-p
:tbox tbox)
(is-valid-racer-role-expression-p role
:check-p check-p))
(if tbox-supplied-p
(role-used-as-datatype-property-p role
tbox)
(role-used-as-datatype-property-p role (current-tbox)))))
(defun is-valid-racer-role-expression-p (role &key
allow-negated-roles-p (tbox nil tbox-supplied-p)
check-p)
(labels ((do-it (role)
(or (and role
(symbolp role)
;; (=> check-p
;; (role-p role))
(=> (and check-p
(if tbox-supplied-p
(role-p role tbox)
(role-p role)))
(not
(if tbox-supplied-p
(cd-attribute-p role tbox)
(cd-attribute-p role)))))
(when (consp role)
(let ((first (intern (format nil "~A" (first role))
:keyword)))
(case first
(:not
(and allow-negated-roles-p
(do-it (second role))))
(:inv
(do-it (second role)))
(otherwise nil)))))))
(do-it role)))
(defun is-valid-racer-attribute-expression-p (role &key check-p (tbox nil tbox-supplied-p))
(and role (symbolp role)
(=> check-p
(if tbox-supplied-p
(cd-attribute-p role tbox)
(cd-attribute-p role)))))
(defun is-valid-racer-aexpr-p (aexpr)
(declare (ignore aexpr))
; ist mir zu kompliziert das zu checken, ist eh eigentlich unnoetig...
t)
(defun negated-racer-role-p (role)
;;; Annahme: role ist valid-racer-role-expression-p
(and (consp role)
(eq (intern (format nil "~A" (first role)) :keyword) :not)))
;;;
;;;
;;;
(defun normalize-name (name)
(if (symbolp name)
name
(if (not (cdr name))
(car name)
#-:dlmaps (nrql-error "Parser error: bad name ~A" name)
#+:dlmaps (error "Parser error: bad name ~A" name))))
;;;
;;;
;;;
(defun racer-nnf (concept &optional negate-p)
(if (consp concept)
(let ((op (intern (format nil "~A" (first concept)) :keyword)))
(case op
((:not)
(racer-nnf (second concept) (not negate-p)))
(:and `(,(if negate-p 'or 'and)
,@(mapcar #'(lambda (x) (racer-nnf x negate-p)) (rest concept))))
(:or `(,(if negate-p 'and 'or)
,@(mapcar #'(lambda (x) (racer-nnf x negate-p)) (rest concept))))
(:all
`(,(if negate-p 'some 'all)
,(second concept) ,(racer-nnf (third concept)
negate-p)))
(:some
`(,(if negate-p 'all 'some)
,(second concept) ,(racer-nnf (third concept)
negate-p)))
(:at-least
(let ((n (second concept)))
(if (not negate-p)
(if (zerop (1- n))
`(some ,(third concept)
,(or (racer-nnf (fourth concept) nil)
'top))
`(at-least ,(second concept)
,(third concept)
,(or (racer-nnf (fourth concept) nil)
'top)))
(if (zerop (1- n))
`(all ,(third concept)
,(or (racer-nnf (fourth concept) t) 'bottom))
`(at-most ,(1- n)
,(third concept)
,(or (fourth concept) 'top))))))
(:at-most
(let ((n (second concept)))
(if (not negate-p)
(if (zerop n)
`(all ,(third concept)
,(or (racer-nnf (fourth concept) t)
'bottom))
`(at-most ,(second concept)
,(third concept)
,(or (racer-nnf (fourth concept) nil)
'top)))
(if (zerop n)
`(some ,(third concept)
,(or (racer-nnf (fourth concept) nil)
'bottom))
`(at-least ,(1+ n)
,(third concept)
,(or (fourth concept) 'top))))))
(:exactly
(racer-nnf `(and (at-least ,@(rest concept))
(at-most ,@(rest concept)))
negate-p))
((:a :an)
(if negate-p
`(no ,@(rest concept))
concept))
(:no
(if negate-p
`(a ,@(rest concept))
concept))
(:min
(if negate-p
`(max ,@(rest concept))
concept))
(:max
(if negate-p
`(min ,@(rest concept))
concept))
(:divisible
(if negate-p
`(not-divisible ,@(rest concept))
concept))
(:not-divisible
(if negate-p
`(divisible ,@(rest concept))
concept))
(:string=
(if negate-p
`(string<> ,@(rest concept))
concept))
(:string<>
(if negate-p
`(string= ,@(rest concept))
concept))
(:boolean=
(if negate-p
`(boolean<> ,@(rest concept))
concept))
(:boolean<>
(if negate-p
`(boolean= ,@(rest concept))
concept))
(:>
(if negate-p
`(<= ,@(rest concept))
concept))
(:>=
(if negate-p
`(< ,@(rest concept))
concept))
(:<
(if negate-p
`(>= ,@(rest concept))
concept))
(:<=
(if negate-p
`(> ,@(rest concept))
concept))
(:equal
(if negate-p
`(unequal ,@(rest concept))
concept))
(:unequal
(if negate-p
`(equal ,@(rest concept))
concept))
(otherwise
#-:dlmaps (nrql-error "Trying to compute NNF: what is ~A?" concept)
#+:dlmaps (error "Trying to compute NNF: what is ~A?" concept))))
(if negate-p
`(not ,concept)
concept)))
| 15,666 | Common Lisp | .lisp | 364 | 24.667582 | 106 | 0.416029 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 90674e0fc5645765552495aac572de4d92851591e9dd0945a7bcc8f16c32b772 | 12,508 | [
-1
] |
12,509 | substrate7.lisp | lambdamikel_DLMAPS/src/thematic-substrate/substrate7.lisp | ;;; -*- Mode: Lisp; Syntax: Ansi-Common-Lisp; Package: THEMATIC-SUBSTRATE; Base: 10 -*-
(in-package :THEMATIC-SUBSTRATE)
(defconstant +secret-marker+ (gensym))
(defparameter *non-determinism-p* nil)
(defparameter *debug-p* nil)
(defvar *all-substrates* nil)
(defvar *cur-substrate* nil)
;;;
;;; Vorgesehenes Interface
;;;
(defgeneric create-substrate (name &rest args &key delete-if-exists-p type &allow-other-keys))
(defgeneric delete-substrate (substrate-specifier &key &allow-other-keys))
(defgeneric find-substrate (substrate-specifier &key &allow-other-keys))
(defgeneric consistent-p (substrate &key &allow-other-keys))
(defgeneric inconsistent-p (substrate &key &allow-other-keys))
;;;
;;;
;;;
(defgeneric get-missing-edges (substrate &key nodes loops-p inverses-p &allow-other-keys))
(defgeneric get-underspecified-edges (substrate &key satisfying use-aux-description-p &allow-other-keys))
;;;
;;;
;;;
(defgeneric simplify (substrate &key error-p &allow-other-keys))
(defgeneric scramble (substrate &key nodes))
;;;
;;; Für Macros "in-substrate" und "with-substrate"
;;;
(defgeneric establish-context-for (substrate continuation))
(defgeneric set-context-for (substrate)
(:method-combination progn))
;;;
;;;
;;;
(defgeneric get-standard-node-class (substrate))
(defgeneric get-standard-edge-class (substrate))
(defgeneric get-standard-node-description-class (substrate))
(defgeneric get-standard-edge-description-class (substrate))
;;;
;;;
;;;
(defgeneric implies-p (substrate-object-a substrate-object-b
&key use-aux-description-p
&allow-other-keys))
(defgeneric equivalent-p (substrate-object-a substrate-object-b
&key use-aux-description-p
&allow-other-keys))
;;;
;;; Knoten
;;;
(defgeneric create-node (substrate name node-description
&key aux-description error-p delete-if-exists-p type
&allow-other-keys))
(defgeneric add-to-node (substrate node-specifier delta-description
&key error-p
&allow-other-keys))
;;;
;;; Kanten
;;;
(defgeneric create-edge (substrate node-specifier-from node-specifier-to edge-description
&key aux-description error-p type
&allow-other-keys))
(defgeneric equivalent-edge-present-p (substrate node-spec-from node-spec-to edge-description
&key use-aux-description-p
&allow-other-keys))
(defgeneric reflexive-edge-p (edge))
(defgeneric underspecified-p (edge &key use-aux-description-p &allow-other-keys))
(defgeneric get-disjuncts (edge &key use-aux-description-p &allow-other-keys))
(defgeneric inverse-edge (edge))
;;;
;;; Various Stuff
;;;
(defgeneric subgraph-isomorphic-p (substratea substrateb
&key nodes-a nodes-b permutations-p
edges-equivalent-fn nodes-equivalent-fn))
(defgeneric isomorphic-p (substratea substrateb
&key nodes-a nodes-b permutations-p
edges-equivalent-fn nodes-equivalent-fn))
(defgeneric has-next-configuration-p (substrate &key restart-from))
(defgeneric enumerate-atomic-configurations (substrate
&key restart-from how-many edges
sym-gen selector-fn manager-fn
final-check-f construction-check-fn
fn
&allow-other-keys))
(defgeneric get-all-atomic-configurations (substrate &key &allow-other-keys))
;;;
;;; Handling of the "aux description"
;;;
(defgeneric save-current-description (substrate
&key edges nodes save-node-labels-p save-edge-labels-p
&allow-other-keys))
(defgeneric pop-description-stack (substrate
&key edges nodes
&allow-other-keys))
;;;
;;; Das Basis-Substrate verwaltet lediglich Knoten und Kanten;
;;; Knoten müssen eindeutigen Namen tragen; beliebig viele Kanten
;;; zwischen zwei Knoten werden unterstützt. Knoten kennen ihre
;;; Nachfolger- und Vorgängerknoten.
;;; Kanten tragen "edge-descriptions", Knoten "node-descriptions";
;;; abstrakte Retrieval-Operation und eine "matches-p"-Operation
;;; sind vorgesehen. Das Substrate weiß nichts über inverse und
;;; reflexive Kanten etc. S. Rolebox-Substrate-Unterklasse.
;;;
(defpersistentclass substrate (graph)
((node-table :reader node-table
:initform
(let ((table (make-hash-table :size 1000 :rehash-size 1000)))
;(hcl:set-hash-table-weak table :both)
table))
(edge-table :reader edge-table
:initform
(let ((table (make-hash-table :size 10000 :rehash-size 10000 :test #'equal)))
;(hcl:set-hash-table-weak table :key)
table))
(cached-nodes :reader cached-nodes :initform nil :not-persistent)
(cached-edges :reader cached-edges :initform nil :not-persistent)
(max-counter :initform nil :accessor max-counter)
(counter :initform nil :accessor counter)
(reset-p :accessor reset-p :initform t)
(stack :initform nil :accessor stack)
(description-stack :initform nil :accessor description-stack)))
(defmethod get-nodes ((substrate substrate) &key (satisfying #'yes) (sort-p t) &allow-other-keys)
(if (and (cached-nodes substrate)
(equal (list satisfying sort-p)
(first (cached-nodes substrate))))
(second (cached-nodes substrate))
(let ((res nil))
(with-new-marking-context
(loop as node being the hash-value of (node-table substrate)
when (and (not (marked-p node))
(funcall satisfying node))
do
(progn
(mark node)
(push node res)))
(unmark res))
(when sort-p (setf res (sort res #'< :key #'id)))
(setf (slot-value substrate 'cached-nodes)
(list (list satisfying sort-p) res))
res)))
#|
(defmethod get-edges ((substrate substrate) &rest args)
(loop as val being the hash-value of (edge-table substrate)
collect val))
|#
(defmethod get-edges ((substrate substrate)
&key exclude-loops-p exclude-inverses-p (satisfying #'yes)
&allow-other-keys)
(if (and (cached-edges substrate)
(equal (list exclude-loops-p exclude-inverses-p satisfying)
(first (cached-edges substrate))))
(second (cached-edges substrate))
(let ((res nil))
(with-new-marking-context
(loop as edge being the hash-value of (edge-table substrate)
when (and
(not (consp edge))
(not (marked-p edge))
(=> (and exclude-inverses-p
(inverse-edge edge))
(< (id (from edge)) (id (to edge))))
;;; notwendige Sonderbehandlung für
;;; reflexive Kanten, die nicht selbst-invers
;;; sind (wegen unterschiedlicher Beschreibungen z.B.)
(=> (and exclude-inverses-p
(eq (from edge) (to edge))
(inverse-edge edge))
(not (marked-p (inverse-edge edge))))
(=> exclude-loops-p
(not (reflexive-edge-p edge)))
(funcall satisfying edge))
do
(progn
(mark edge)
(push edge res)))
(unmark res))
(setf (slot-value substrate 'cached-edges)
(list (list exclude-loops-p exclude-inverses-p satisfying)
res))
res)))
(defmacro loop-over-nodes ((var substrate) &body body)
`(maphash #'(lambda (key ,var)
(declare (ignorable ,var))
(when (integerp key)
,@body))
(node-table ,substrate)))
(defmacro loop-over-edges ((var substrate) &body body)
`(maphash #'(lambda (key ,var)
(declare (ignorable ,var))
(when (integerp key)
,@body))
(edge-table ,substrate)))
;;;
;;;
;;;
(defmethod consistent-p ((substrate substrate) &key
(check-node-labels-p t)
(check-edge-labels-p t)
&allow-other-keys)
(and (=> check-node-labels-p (every #'consistent-p (get-nodes substrate)))
(=> check-edge-labels-p (every #'consistent-p (get-edges substrate)) )))
(defmethod inconsistent-p ((obj substrate) &rest args)
;;; wegen Dreiwertigkeit!
(eq (apply #'consistent-p obj args) nil))
;;;
;;;
;;;
(defmethod get-standard-node-class ((substrate substrate))
'substrate-node)
(defmethod get-standard-edge-class ((substrate substrate))
'substrate-edge)
(defmethod get-standard-node-description-class ((substrate substrate))
'simple-node-description)
(defmethod get-standard-edge-description-class ((substrate substrate))
'simple-edge-description)
;;;
;;;
;;;
(defun get-substrate-name (symbol-or-string)
(intern
(string-upcase (format nil "~A" symbol-or-string))))
(defmethod create-substrate ((name symbol) &rest args &key (type 'substrate) &allow-other-keys)
(apply #'make-graph type :name name args))
(defmethod create-substrate ((name string) &rest args &key (type 'substrate) &allow-other-keys)
(apply #'make-graph type :name (get-substrate-name name) args))
(defmethod make-graph ((type symbol) &rest args
&key (error-p t) delete-if-exists-p name copy-p
&allow-other-keys)
(when delete-if-exists-p
(delete-graph name :all-p t :error-p nil))
(if (and (find-graph name :error-p nil)
(not copy-p))
(if error-p
(error "Substrate named ~A already exists!" name)
(return-from make-graph nil))
(apply #'make-instance type :allow-other-keys t
args)))
(defmethod initialize-instance :after ((substrate substrate) &rest initargs)
(push substrate *all-substrates*))
(defun all-substrates ()
*all-substrates*)
;;;
;;;
;;;
(defmethod establish-context-for ((substrate substrate) continuation)
(let ((*node-description-class*
(get-standard-node-description-class *cur-substrate*))
(*edge-description-class*
(get-standard-edge-description-class *cur-substrate*)))
(if (next-method-p)
(call-next-method)
(funcall continuation))))
(defmethod set-context-for progn ((substrate substrate))
(setf *node-description-class*
(get-standard-node-description-class *cur-substrate*)
*edge-description-class*
(get-standard-edge-description-class *cur-substrate*)))
;;;
;;;
;;;
(defmacro with-substrate* ((name &rest args &key all-args (delete-if-exists-p t) &allow-other-keys)
&rest body)
`(let ((*cur-substrate*
(or (let ((found
(find-substrate ,name)))
(if found
(if ,delete-if-exists-p
nil
found)
nil))
,(if all-args
`(apply #'create-substrate ,name
,all-args)
`(create-substrate ,name
,@args)))))
(establish-context-for *cur-substrate*
#'(lambda ()
,@body))))
(defmacro with-substrate ((name &rest args) &rest body)
`(with-substrate* ( (quote ,name) ,@args)
,@body))
;;;
;;;
;;;
(defmacro in-substrate* (name &rest args &key all-args delete-if-exists-p &allow-other-keys)
`(progn
(setf *cur-substrate*
(or (let ((found
(find-substrate ,name)))
(if found
(if ,delete-if-exists-p
nil
found)
nil))
,(if all-args
`(apply #'create-substrate ,name ,all-args)
`(create-substrate ,name ,@args))))
(set-context-for *cur-substrate*)
*cur-substrate*))
(defmacro in-substrate (name &rest args)
`(in-substrate* (quote ,name) ,@args))
(defun in-substrate-fn (name &rest args &key all-args delete-if-exists-p &allow-other-keys)
(progn
(setf *cur-substrate*
(or (let ((found
(find-substrate name)))
(if found
(if delete-if-exists-p
nil
found)
nil))
(if all-args
(apply #'create-substrate name all-args)
(apply #'create-substrate name args))))
(set-context-for *cur-substrate*)
*cur-substrate*))
;;;
;;;
;;;
(defmethod find-substrate ((substrate-spec t) &rest args)
(apply #'find-graph substrate-spec args))
(defmethod find-graph ((graph-spec symbol) &rest args)
(find graph-spec *all-substrates* :key #'name))
(defmethod find-graph ((graph-spec integer) &rest args)
(find graph-spec *all-substrates* :key #'graph::id :test #'=))
;;;
;;;
;;;
(defmethod delete-substrate ((substrate-spec t) &rest args &key &allow-other-keys)
(apply #'delete-graph substrate-spec args))
(defmethod delete-graph ((substrate substrate) &rest args &key &allow-other-keys)
(with-slots (node-table edge-table cached-nodes cached-edges stack description-stack) substrate
;;; warum muss ich das tun? der GC hat anscheinend Probleme sonst...
(when node-table
(clrhash node-table))
(when edge-table
(clrhash edge-table))
(setf cached-nodes nil
cached-edges nil
stack nil
description-stack nil)
;;;(hcl::mark-and-sweep 3)
#+:lispworks (hcl:gc-if-needed)
(setf *all-substrates*
(delete substrate *all-substrates*))
(when (eq substrate *cur-substrate*)
(setf *cur-substrate* nil))))
;;;
;;;
;;;
(defun delete-all-substrates (&key (satisfying #'yes))
(mapc #'delete-substrate
(get-all-substrates :satisfying satisfying)))
(defun get-all-substrates (&key (satisfying #'yes))
(remove-if-not satisfying *all-substrates*))
;;;
;;;
;;;
(defmethod copy ((substrate substrate) &rest args)
(apply #'copy-graph substrate args))
(defmethod copy-graph ((substrate substrate) &rest args &key name &allow-other-keys)
(let ((copy (apply #'create-substrate
(or name (format nil "Copy of ~A" (name substrate)))
:copy-p t
:type (type-of substrate)
args)))
(with-slots (node-counter edge-counter
counter max-counter
reset-p stack description-stack) substrate
(with-slots ((cnode-counter node-counter)
(cnode-counter node-counter)
(cedge-counter edge-counter)
(ccounter counter)
(cmax-counter max-counter)
(creset-p reset-p)
(cstack stack)
(cdescription-stack description-stack)) copy
(dolist (node (sort (get-nodes substrate) #'< :key #'id))
(copy-graph-item copy node))
(dolist (edge (sort (get-edges substrate) #'< :key #'id))
(copy-graph-item copy edge))
(setf cnode-counter node-counter
cedge-counter edge-counter
ccounter counter
cmax-counter max-counter
creset-p reset-p
cstack (copy-tree stack)
cdescription-stack (copy-tree description-stack))))
copy))
;;;
;;;
;;;
(defpersistentclass substrate-object (graph-item) ; abstrakt
((description :accessor description :initarg :description :initform nil)
(aux-description :accessor aux-description :initarg :aux-description :initform nil)
(description-stack :accessor description-stack :initform nil)))
;;;
;;;
;;;
(defmethod consistent-p ((obj substrate-object) &rest args &key use-aux-description-p &allow-other-keys)
(apply #'consistent-p
(if use-aux-description-p
(aux-description obj)
(description obj))
args))
(defmethod inconsistent-p ((obj substrate-object) &rest args)
(not (apply #'consistent-p obj args)))
(defmethod implies-p ((object-a substrate-object) (object-b substrate-object)
&key use-aux-description-p &allow-other-keys)
(if use-aux-description-p
(implies-p (aux-description object-a)
(aux-description object-b))
(implies-p (description object-a)
(description object-b))))
(defmethod equivalent-p ((object-a substrate-object) (object-b substrate-object) &rest args)
(and (apply #'implies-p object-a object-b args)
(apply #'implies-p object-b object-a args)))
;;;
;;;
;;;
(defpersistentclass substrate-node (substrate-object node)
((successors :reader successors :initarg :successors :initform nil)
(predecessors :reader predecessors :initarg :predecessors :initform nil)
(outgoing :reader outgoing :initarg :outgoing :initform nil)
(incoming :reader incoming :initarg :incoming :initform nil)))
(defmethod initialize-instance :after ((object substrate-node) &rest initargs)
(register-node object))
(defmethod register-node ((object substrate-node))
(with-slots (id name in-graph) object
(with-slots (node-table cached-nodes) in-graph
(setf cached-nodes nil)
(setf (gethash id node-table) object)
(when name
(setf (gethash name node-table) object)))))
(defmethod get-node-position ((substrate substrate) (node substrate-node) &rest args)
(let ((nodes (sort (get-nodes substrate) #'< :key #'id)))
(position node nodes)))
;;;
;;;
;;;
(defmethod create-node ((substrate t) (name symbol) (description node-description) &rest args)
(apply #'make-node substrate :name name :description description args))
(defmethod make-node ((substrate substrate)
&rest args
&key
name description aux-description
delete-if-exists-p id (error-p t) (type (get-standard-node-class substrate))
&allow-other-keys)
(if delete-if-exists-p
(delete-node substrate name :all-p t :error-p nil)
(when (apply #'find-node substrate name :error-p nil args)
(if error-p
(error "Node ~A already exists in substrate ~A!" name substrate)
(return-from make-node nil))))
(apply #'make-instance type
:id id
:in-graph substrate
:description description
:aux-description aux-description
:name name
:allow-other-keys t
args))
(defmacro node (name description &rest args)
`(create-node *cur-substrate* ',name ,description ,@args))
;;;
;;;
;;;
(defmethod add-to-node ((substrate t) (name t) (delta-description node-description)
&rest args &key error-p )
(let* ((substrate (find-substrate substrate :error-p error-p))
(node (find-node substrate name :error-p error-p)))
(when (and node substrate)
(apply #'add-to-node substrate node
delta-description args))))
(defmethod add-to-node ((substrate substrate) (node substrate-node) (delta-description node-description)
&key (mode :and) &allow-other-keys)
(change-description node
(ecase mode
(:and (make-and-description (description node)
:descriptions (list delta-description)))
(:or (make-or-description (description node)
:descriptions (list delta-description))))))
(defmacro add (name description &rest args)
`(add-to-node *cur-substrate* ',name ,description ,@args))
;;;
;;;
;;;
(defmethod find-node ((substrate substrate) (node substrate-node) &rest args &key &allow-other-keys)
(apply #'find-node substrate (id node) args))
(defmethod find-node ((substrate substrate) (id integer) &key &allow-other-keys)
(when (node-table substrate)
(gethash id (node-table substrate))))
(defmethod find-node ((substrate substrate) (name symbol) &key &allow-other-keys)
(when (node-table substrate)
(gethash name (node-table substrate))))
;;;
;;;
;;;
(defmethod delete-node ((substrate substrate) (node substrate-node) &key (delete-edges-p t) &allow-other-keys)
(with-slots (node-table cached-nodes) substrate
(setf cached-nodes nil)
(remhash (id node) node-table)
(remhash (name node) node-table)
(when delete-edges-p
(dolist (edge (outgoing node))
(delete-edge substrate edge :error-p t))
(dolist (edge (incoming node))
(delete-edge substrate edge :error-p t)))))
(defmacro del-node (node)
`(delete-node *cur-substrate* ',node))
;;;
;;;
;;;
(defpersistentclass substrate-edge (substrate-object edge))
(defmethod initialize-instance :after ((object substrate-edge) &rest initargs)
(register-edge object))
(defmethod register-edge ((object substrate-edge))
(with-slots (id in-graph from to) object
(with-slots (edge-table cached-edges) in-graph
(setf cached-edges nil)
(let* ((cons (cons (id from) (id to)))
(item (gethash cons edge-table)))
(if item
(setf (gethash cons edge-table)
(push object item))
(setf (gethash cons edge-table)
(list object))))
(setf (gethash id edge-table) object)
(push to (slot-value from 'successors))
(push from (slot-value to 'predecessors))
(push object (slot-value from 'outgoing))
(push object (slot-value to 'incoming)))))
;;;
;;;
;;;
(defmethod get-edges-between ((substrate substrate) (from substrate-node) (to substrate-node)
&rest args &key &allow-other-keys)
(when (edge-table substrate)
(gethash (cons (id from) (id to))
(edge-table substrate))))
;;;
;;;
;;;
(defmethod find-edge ((substrate substrate) (edge substrate-edge) &rest args &key &allow-other-keys)
(apply #'find-edge substrate (id edge) args))
(defmethod find-edge ((substrate substrate) (id integer) &key &allow-other-keys)
(when (edge-table substrate)
(gethash id (edge-table substrate))))
#|
(defmethod find-edge ((substrate substrate) (name symbol) &key &allow-other-keys)
(gethash name (edge-table substrate)))
|#
;;;
;;;
;;;
(defmethod delete-edge ((substrate substrate) (edge substrate-edge) &key (error-p t) &allow-other-keys)
(with-slots (edge-table cached-edges) substrate
(setf cached-edges nil)
(with-slots (id from to) edge
(if (not (gethash id edge-table))
(progn
(when error-p
(error "Edge ~A not present in ~A!" edge substrate))
nil)
(let ((cons (cons (id from) (id to))))
(unless (setf (gethash cons edge-table)
(delete edge (gethash cons edge-table)))
;;; keine Kanten mehr zwischen "from" und "to"?
(remhash cons edge-table)
(setf (slot-value from 'successors) (delete to (slot-value from 'successors)))
(setf (slot-value to 'predecessors) (delete from (slot-value to 'predecessors))))
(remhash id edge-table)
(setf (slot-value from 'outgoing) (delete edge (slot-value from 'outgoing)))
(setf (slot-value to 'incoming) (delete edge (slot-value to 'incoming))))))))
(defmacro del-edge (from to &key (error-p t) (all-p t))
(let ((var (gensym)))
`(let ((,var (get-edges-between *cur-substrate* ',from ',to)))
(if (and (cdr ,var) ,(not all-p))
(when ,error-p
(error "More than one edge between ~A and ~A - not unique, can't delete!" ',from ',to))
(dolist (edge ,var)
(delete-edge *cur-substrate* edge))))))
;;;
;;;
;;;
(defmethod create-edge ((substrate t) (from t) (to t) (description edge-description)
&rest args)
(apply #'make-edge substrate from to
:description description
args))
(defmethod make-edge ((substrate substrate) (from substrate-node) (to substrate-node)
&rest args
&key description aux-description id (type (get-standard-edge-class substrate))
&allow-other-keys)
(apply #'make-instance type
:id id
:name 'edge ;(intern (format nil "EDGE-~A-~A" (name from) (name to)))
:description description
:in-graph substrate
:aux-description aux-description
:from from
:to to
:allow-other-keys t
args))
(defmacro edge (from to description &rest args)
`(create-edge *cur-substrate* ',from ',to ,description ,@args))
;;;
;;;
;;;
(defmethod reflexive-edge-p ((edge substrate-edge))
(eq (from edge) (to edge)))
(defmethod underspecified-p ((edge substrate-edge) &key use-aux-description-p &allow-other-keys)
(if use-aux-description-p
(underspecified-p (aux-description edge))
(underspecified-p (description edge))))
(defmethod get-disjuncts ((edge substrate-edge) &key use-aux-description-p &allow-other-keys)
(if use-aux-description-p
(get-disjuncts (aux-description edge))
(get-disjuncts (description edge))))
(defmethod inverse-edge ((edge substrate-edge))
(subclass-responsibility 'inverse-edge))
(defmethod equivalent-edge-present-p ((substrate substrate) nodea nodeb (description edge-description)
&key aux-description-p &allow-other-keys)
(find-if #'(lambda (edge)
(equivalent-p (if aux-description-p
(aux-description edge)
(description edge))
description))
(get-edges-between substrate nodea nodeb)))
(defmethod =>-edge-present-p ((substrate substrate) nodea nodeb (description edge-description)
&key aux-description-p)
(find-if #'(lambda (edge)
(implies-p (if aux-description-p
(aux-description edge)
(description edge))
description))
(get-edges-between substrate nodea nodeb)))
(defmethod <=-edge-present-p ((substrate substrate) nodea nodeb (description edge-description)
&key aux-description-p)
(find-if #'(lambda (edge)
(implies-p description
(if aux-description-p
(aux-description edge)
(description edge))))
(get-edges-between substrate nodea nodeb)))
;;;
;;; Various Stuff
;;;
(defmethod subgraph-isomorphic-p ((a substrate) (b substrate)
&key
(nodes-a (get-nodes a))
(nodes-b (get-nodes b))
(permutations-p t)
(edges-equivalent-fn #'equivalent-p)
(nodes-equivalent-fn #'equivalent-p)
iso)
;;; is "a" an isomorphic subgraph of "b"?
(let* ((na nodes-a)
(nb nodes-b)
(na (if iso (intersection (mapcar #'first iso) na) na))
(nb (if iso (intersection (mapcar #'second iso) nb) nb)))
(with-marked-objects (na)
(when (<= (length na) (length nb))
(let* ((vec (make-array (1+ (apply #'max (mapcar #'id na)))))
(perms-to-check
(if (or (not permutations-p) iso)
(list nb)
(perm nb (length na))))
(res
(find-if #'(lambda (perm)
(mapc #'(lambda (a b)
(setf (aref vec (id a)) b))
na
perm)
(with-marked-objects (perm)
(and (every #'(lambda (node)
(funcall nodes-equivalent-fn
(description node)
(description (aref vec (id node)))))
na)
(every #'(lambda (edge)
(with-slots (description current-label) edge
(some #'(lambda (edge)
(funcall edges-equivalent-fn (description edge) description))
(get-edges-between b
(aref vec (id (from edge)))
(aref vec (id (to edge)))
:satisfying #'(lambda (x)
(and (marked-p (from x))
(marked-p (to x))))))))
(get-edges a)))))
perms-to-check)))
(when res
(mapcar #'(lambda (a x)
(list a x))
na res)))))))
(defmethod isomorphic-p ((a substrate) (b substrate)
&key (nodes-a (get-nodes a)) (nodes-b (get-nodes b)) (permutations-p t)
(edges-equivalent-fn #'equivalent-p)
(nodes-equivalent-fn #'equivalent-p)
iso)
(let ((iso (subgraph-isomorphic-p a b
:nodes-a nodes-a
:nodes-b nodes-b
:permutations-p permutations-p
:nodes-equivalent-fn nodes-equivalent-fn
:edges-equivalent-fn edges-equivalent-fn
:iso iso)))
(when iso
(subgraph-isomorphic-p b a
:nodes-a nodes-b
:nodes-b nodes-a
:permutations-p permutations-p
:nodes-equivalent-fn nodes-equivalent-fn
:edges-equivalent-fn edges-equivalent-fn
:iso (mapcar #'(lambda (x)
(reverse x))
iso))
iso)))
;;;
;;;
;;;
(defmethod copy-node ((substrate substrate) (node substrate-node) &rest args)
(apply #'make-node substrate
:name (name node)
:description (copy (description node))
:copy-p t
:id (id node)
:type (type-of node)
:aux-description (when (aux-description node)
(copy (aux-description node)))
:description-stack (copy-tree (description-stack node))
args))
(defmethod copy-edge ((substrate substrate) (edge substrate-edge) &rest args)
(apply #'make-edge substrate
(find-node substrate (id (from edge)))
(find-node substrate (id (to edge)))
:description (copy (description edge))
:aux-description (when (aux-description edge)
(copy (aux-description edge)))
:copy-p t
:id (id edge)
:type (type-of edge)
:description-stack (copy-tree (description-stack edge))
args))
;;;
;;;
;;;
(defmethod get-missing-edges ((substrate substrate) &key
(nodes (get-nodes substrate))
loops-p inverses-p)
(let ((res nil))
(loop as n on nodes do
(let ((i (first n)))
(when (and loops-p
(not (get-edges-between substrate i i)))
(push (list i i) res))
(dolist (j (rest n))
(if (get-edges-between substrate i j)
(if (not (get-edges-between substrate j i))
(when inverses-p
(push (list j i) res)))
(if (not (get-edges-between substrate j i))
(progn
(push (list i j) res)
(when inverses-p
(push (list j i) res)))
(when inverses-p
(push (list i j) res)))))))
res))
(defmethod get-underspecified-edges ((substrate substrate) &rest args &key (satisfying #'yes) &allow-other-keys)
(apply #'get-edges substrate
:satisfying #'(lambda (x)
(and (apply #'underspecified-p x args)
(funcall satisfying x)))
args))
;;;
;;;
;;;
(defmethod save-current-description ((substrate substrate) &key
(save-node-labels-p t)
(save-edge-labels-p t)
(edges (get-edges substrate))
(nodes (get-nodes substrate))
&allow-other-keys)
(dolist (node nodes)
(push (if save-node-labels-p
(aux-description node)
+secret-marker+)
(description-stack node))
(when save-node-labels-p
(setf (aux-description node)
(copy (description node)))))
(dolist (edge edges)
(push (if save-edge-labels-p
(aux-description edge)
+secret-marker+)
(description-stack edge))
(when save-edge-labels-p
(setf (aux-description edge)
(copy (description edge)))))
(push (copy-tree (stack substrate))
(description-stack substrate))
substrate)
(defmethod pop-description-stack ((substrate substrate) &key
(edges (get-edges substrate))
(nodes (get-nodes substrate))
&allow-other-keys)
(dolist (node nodes)
(setf (aux-description node)
(let ((descr (pop (description-stack node))))
(unless (eq descr +secret-marker+)
descr))))
(dolist (edge edges)
(setf (aux-description edge)
(let ((descr (pop (description-stack edge))))
(unless (eq descr +secret-marker+)
descr))))
(setf (stack substrate)
(pop (description-stack substrate)))
substrate)
;;;
;;;
;;;
(defmethod has-next-configuration-p ((substrate substrate)
&key restart-from)
(with-slots (reset-p stack counter max-counter) substrate
(or reset-p
(if restart-from
(with-slots (stack) substrate
(let ((stack-entry (find restart-from stack :key #'first)))
(second stack-entry)))
;;; sonst: irgendeine Kante hat noch ausstehende Symbole!
(some #'second stack)))))
(defmethod enumerate-atomic-configurations ((substrate substrate)
&rest args
&key
reset-p
how-many
restart-from
auto-pop-p
(edge-setter
#'(lambda (edge sym &rest args)
(declare (ignore args))
(change-textual-description (description edge) sym)))
(edges
(if *non-determinism-p*
(reorder (get-underspecified-edges substrate
:use-aux-description-p nil))
(get-underspecified-edges substrate :use-aux-description-p nil)))
(sym-gen #'(lambda (edge processed-edges &rest args)
(declare (ignore processed-edges args))
(if *non-determinism-p*
(reorder (get-disjuncts edge :use-aux-description-p t))
(get-disjuncts edge :use-aux-description-p t))))
(selector-fn #'(lambda (rem-edges processed-edges &rest args)
(declare (ignore processed-edges args))
(first rem-edges)))
(manager-fn #'(lambda (sel-edge edges processed-edges &rest args)
(declare (ignore args))
(values (remove sel-edge edges)
(cons sel-edge processed-edges))))
(save-node-labels-p t)
(save-edge-labels-p t)
(fn #'copy)
(final-check-fn #'yes)
(construction-check-fn #'yes)
&allow-other-keys)
(when reset-p
(apply #'reset-enumeration substrate args))
(labels ((do-it ()
(with-slots (reset-p stack description-stack counter max-counter) substrate
(if reset-p
(progn
(when *debug-p*
(format t "*** RESETING!~%"))
(save-current-description substrate
:save-node-labels-p save-node-labels-p
:save-edge-labels-p save-edge-labels-p)
(setf reset-p nil)
(setf stack
(list (list nil nil edges nil))) ; cur-edge, symbols, rem-edge, processed-edges
(setf max-counter how-many)
(setf counter 0))
(when (and max-counter
(> counter max-counter))
(return-from enumerate-atomic-configurations nil)))
(if (not stack)
(progn
(unless auto-pop-p (break "No stack!"))
;;; continue:
(pop-description-stack substrate)
(if stack
(do-it)
(return-from enumerate-atomic-configurations nil)))
(let* ((top (first stack))
(edge (first top))
(syms (second top))
(rem (third top))
(pro (fourth top)))
(when *debug-p*
(format t "STACK: ~A~%" stack)
(format t "STACK -> EDGE: ~A SYMS: ~A~% REM: ~A~% PRO: ~A~%" edge syms rem pro))
(cond ((and (not edge) rem)
(let ((edge (apply selector-fn rem pro args)))
(multiple-value-bind (new-rem new-pro)
(apply manager-fn edge rem pro args)
(when *debug-p* (format t "Chosing edge ~A~%" edge))
(setf (first top) edge)
(setf (second top) (apply sym-gen edge pro args))
(setf (third top) new-rem)
(setf (fourth top) new-pro)
(do-it))))
(edge
(let ((sym (first (second top))))
(setf (second top) (rest (second top)))
(cond (sym
(when *debug-p* (format t "Assigning edge ~A to ~A~%" edge sym))
(apply edge-setter edge sym :remaining (second top) args)
(when (apply construction-check-fn substrate pro args)
(when *debug-p* (format t "Construction check passed~%"))
(push (list nil nil rem pro) stack)))
(t
(when *debug-p*
(format t "No more alternatives for edge ~A; backtracking~%" edge ))
(pop stack)))
(do-it)))
((and (not edge) (not rem))
(pop stack)
(when *debug-p*
(format t "FINAL CHECK: ~A~%" (apply final-check-fn substrate args)))
(when (apply final-check-fn substrate args)
(when *debug-p* (format t "CONFIGURATION FOUND!~%" ))
(incf counter)
(return-from enumerate-atomic-configurations
(apply fn substrate args)))
(do-it))))))))
(when restart-from
(with-slots (stack) substrate
(let ((pos (position restart-from stack :key #'first)))
(when pos
(setf stack
(subseq stack pos))))))
(do-it)))
(defmethod reset-enumeration ((substrate substrate) &key &allow-other-keys)
(setf (reset-p substrate) t))
(defmethod get-all-atomic-configurations ((substrate substrate) &rest args &key (fn #'copy))
(apply #'reset-enumeration substrate args)
(let ((Res nil))
(loop
(let ((subs (apply #'enumerate-atomic-configurations substrate :fn fn :auto-pop-p t args)))
(if subs
(push subs res)
(return t))))
res))
;;;
;;;
;;;
(defmethod simplify ((substrate substrate)
&key (error-p t))
(let* ((edges (get-edges substrate))
(new-edges nil)
(del-edges nil))
(loop while edges do
(let* ((edge (first edges))
(from (from edge))
(to (to edge))
(supp (get-edges-between substrate from to)))
(setf edges (set-difference edges supp))
(let ((new-description
(apply #'make-and-description
(mapcar #'description supp))))
(unless new-description
(when error-p
(error "Unable to simplify ~A!" substrate))
(return-from simplify substrate))
(push (list (first supp) new-description) new-edges)
(setf del-edges (append (rest supp) del-edges)))))
(dolist (edge del-edges)
(delete-edge substrate edge))
(dolist (entry new-edges)
(let ((edge (first entry))
(new-descr (second entry)))
(change-description edge new-descr)))
substrate))
;;;
;;;
;;;
(defmethod change-description ((node substrate-node) (description node-description))
(setf (description node) description
(aux-description node) nil
(description-stack node) nil)
(setf (reset-p (in-graph node)) t))
(defmethod change-description ((edge substrate-edge) (description edge-description))
(setf (description edge) description
(aux-description edge) nil
(description-stack edge) nil)
(setf (reset-p (in-graph edge)) t))
;;;
;;;
;;;
(defmethod scramble ((substrate substrate) &key (nodes (get-nodes substrate)) new-order)
(let* ((reordered-nodes
(mapcar #'id (or new-order (reorder nodes))))
(edges (get-edges substrate)))
(with-slots (node-table edge-table
cached-nodes
cached-edges) substrate
(dolist (edge edges)
(with-slots (from to) edge
(remhash (cons (id from) (id to))
edge-table)))
(dolist (node nodes)
(remhash (id node) node-table))
(dolist (node nodes)
(let ((new-id (1+ (position (id node)
reordered-nodes))))
(setf (slot-value node 'id) new-id)
(setf (gethash new-id node-table) node)))
(dolist (edge edges)
(with-slots (from to) edge
(if (gethash (cons (id from) (id to)) edge-table)
(push edge (gethash (cons (id from) (id to)) edge-table))
(setf (gethash (cons (id from) (id to)) edge-table)
(list edge)))))
(setf cached-nodes nil
cached-edges nil)
substrate)))
;;;
;;; Interface zum Graph-Visualizer
;;;
(defmethod no-of-nodes ((graph substrate) &rest args)
(let ((no 0))
(loop-over-nodes (node graph)
(incf no))
no))
(defmethod no-of-edges ((graph substrate) &rest args)
(let ((no 0))
(loop-over-edges (node graph)
(incf no))
no))
;;;
;;;
;;;
(defmethod kind ((substrate substrate))
(type-of substrate))
(defmethod kind ((node substrate-node))
(or (textual-description (description node))
'null))
(defmethod kind ((edge substrate-edge))
(or (textual-description (description edge))
'null))
;;;
;;;
;;;
(defmethod info ((substrate substrate) &key &allow-other-keys)
(format nil "Name: ~A, Type: ~A, Nodes: ~A, Edges: ~A, Consistent: ~A"
(name substrate)
(type-of substrate)
(no-of-nodes substrate)
(no-of-edges substrate)
(consistent-p substrate)))
(defmethod info ((node substrate-node) &key &allow-other-keys)
(format nil "~A:~A/~A"
(name node)
(get-textual-description (description node))
(if (aux-description node)
(get-textual-description (aux-description node))
'none)))
(defmethod info ((edge substrate-edge) &key &allow-other-keys)
(format nil "~A:~A/~A"
(name edge)
(get-textual-description (description edge))
(if (aux-description edge)
(get-textual-description (aux-description edge))
'none)))
#|
(defmethod info ((node substrate-node) &key &allow-other-keys)
(format nil "~A"
(name node)))
(defmethod info ((edge substrate-edge) &key &allow-other-keys)
(format nil "(~A,~A) : ~A"
(name (from edge))
(name (to edge))
(get-textual-description (description edge))))
|#
;;;
;;;
;;;
#|
(progn
(setf x (create-substrate "test" :delete-if-exists-p t))
(create-node x 'a (make-node-description (get-standard-node-description-class x) 'a-descr) :delete-if-exists-p t)
(create-node x 'b (make-node-description (get-standard-node-description-class x) 'b-descr) :delete-if-exists-p t)
(princ (create-edge x 'a 'b (make-edge-description (get-standard-edge-description-class x) 'test) :error-p nil))
(setf xx (list x (scramble (copy x)))))
(with-substrate (hello :delete-if-exists-p t)
(node a (ncon a-descr))
(visualize (list *cur-substrate*)))
(with-substrate (hello :delete-if-exists-p t)
(node a (ncon a-descr))
(node a (ncon a-descr) :delete-if-exists-p t)
(node b (ncon b-descr))
(del-node b)
(node b (ncon b-descr))
(edge a b (econ ab-edge-descr))
(del-edge a b)
(edge a b (econ ab-edge-descr))
(edge b a (econ ba-edge-descr))
(edge b b (econ bb-edge-descr))
(del-edge b a)
(visualize (list *cur-substrate*
(copy *cur-substrate* :delete-if-exists-p t))))
(progn
(delete-all-substrates)
(in-substrate hello :delete-if-exists-p t)
(node a (ncon a-descr))
(node b (ncon b-descr))
(node c (ncon c-descr))
(node d (ncon d-descr))
(edge a b (econ ab-edge-descr))
(edge b a (econ ba-edge-descr))
(edge b b (econ bb-edge-descr))
(edge b c (econ bc-edge-descr))
(edge b d (econ bd-edge-descr))
(edge a d (econ ad-edge-descr))
(setf *x* *cur-substrate*
*y* (scramble (copy *cur-substrate*)))
(visualize (list *x* *y*))
(princ (isomorphic-p *x* *y*)))
(with-substrate (hello :type 'substrate :delete-if-exists-p t)
(node a (ncon a-descr))
(node b (ncon b-descr))
(node c (ncon c-descr))
(edge a b (econ (r s t)))
(edge b c (econ (1 2 3)))
(setf *x* *cur-substrate*)
(visualize (remove nil
(list (enumerate-atomic-configurations *x*)
(enumerate-atomic-configurations *x* :restart-from (first (get-edges-between *x* 'a 'b)))
(enumerate-atomic-configurations *x* :restart-from (first (get-edges-between *x* 'b 'c)))
(enumerate-atomic-configurations *x* :restart-from (first (get-edges-between *x* 'a 'b)))
(enumerate-atomic-configurations *x*)
(enumerate-atomic-configurations *x*)))))
(with-substrate (test :type 'substrate :delete-if-exists-p t)
(node u (ncon a))
(node v (ncon b))
(node w (ncon c))
(edge u v (econ (r s)))
(edge v w (econ (x y)))
(setf *x* *cur-substrate*)
(visualize (cons (copy *x*) (get-all-atomic-configurations *x*))))
;;;
;;; Demo: geschachtelte Verwendung von "enumerate-atomic-configurations"
;;; Verwendung des Description Stacks
;;;
(with-substrate (test :type 'substrate :delete-if-exists-p t)
(setf *x* *cur-substrate*)
(node a (ncon a))
(node b (ncon b))
(edge a b (econ (r s t)))
(visualize (remove nil (append
(list (enumerate-atomic-configurations *x*
:save-node-labels-p nil))
(progn
(node c (ncon c))
(edge b c (econ (t u)))
(prog1 (list (enumerate-atomic-configurations *x* :reset-p t :save-node-labels-p nil)
(enumerate-atomic-configurations *x*))
(pop-description-stack *x*)))
(delete-node *x* 'c)
(when (find-node *x* 'c) (error "!"))
(list (enumerate-atomic-configurations *x* :save-node-labels-p nil))
(list (enumerate-atomic-configurations *x*))))))
(progn
(setf *all-substrates* nil)
(with-substrate (test :type 'substrate :delete-if-exists-p t)
(setf *x* *cur-substrate*)
(node c (ncon c))
(node a (ncon a))
(node b (ncon b))
(edge a b (econ r))
(edge b c (econ s))
(visualize (list *x*
(scramble (copy *x*))))
(princ (get-missing-edges *x* :inverses-p nil :loops-p nil))))
(progn
(setf *all-substrates* nil)
(with-substrate (test :type 'substrate :delete-if-exists-p t)
(setf *x* *cur-substrate*)
(node a (ncon ax))
(node b (ncon bx))
(node c (ncon cx))
(add c (ncon ccc) :mode :and)
(edge a b (econ r))
(scramble *x*)
(princ (get-nodes *x*))
(visualize (list *x* (scramble (copy *x*))))))
(progn
(delete-all-substrates)
(in-substrate hello :delete-if-exists-p t)
(setf *x* *cur-substrate*)
(node a (ncon a-descr))
(node b (ncon b-descr))
(edge a b (econ ab-edge-descr))
(edge b a (econ ba-edge-descr))
(del-edge a b)
(princ (get-edges *x*))
(terpri)
(princ (get-edges-between *x* 'a 'b))
(princ (get-edges-between *x* 'b 'a)))
|#
| 54,053 | Common Lisp | .lisp | 1,214 | 30.567545 | 120 | 0.530141 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 1ea31c564e4e931c9f14c136c2871c859cfb7279ce05851e2a7aae36d085b0f3 | 12,509 | [
-1
] |
12,510 | rolebox.lisp | lambdamikel_DLMAPS/src/thematic-substrate/rolebox.lisp | ;;; -*- Mode: Lisp; Syntax: Ansi-Common-Lisp; Package: THEMATIC-SUBSTRATE; Base: 10 -*-
(in-package :THEMATIC-SUBSTRATE)
(defvar *cur-rbox* nil)
(defvar *all-rboxes* nil)
;;;
;;;
;;;
(defgeneric inv-role (rolebox role))
(defgeneric lookup (rolebox r s))
;;;
;;; Role Box
;;;
(defpersistentclass rolebox ()
((name :reader name :initarg :name)
(roles :reader roles :initarg :roles)
(reflexive-roles :reader reflexive-roles :initarg :reflexive-roles)
(n :reader n :initarg :n)
(roles-to-inverses :reader roles-to-inverses :initarg :roles-to-inverses)
(roles-to-ids :reader roles-to-ids :initarg :roles-to-ids)
(ids-to-roles :reader ids-to-roles :initarg :ids-to-roles)
(axioms :reader axioms :initform nil :initarg :axioms)
(table :reader table :initarg :table)))
(defmethod print-object ((rbox rolebox) stream)
(format stream "#<~A ~A>" (type-of rbox) (name rbox)))
(defun create-rbox (name roles
&key
(error-p t)
(delete-if-exists-p t)
inverse-roles reflexive-roles
axioms
(type 'rolebox))
(labels ((change-package (x) x))
(when delete-if-exists-p
(delete-rbox name :all-p t))
(if (find-rbox name :error-p nil)
(if error-p
(error "Rolebox named ~A already exists!" name)
(return-from create-rbox nil))
(if (not roles)
(error "No roles!")
(let* ((n (length roles))
(inverse-roles (mapcar #'change-package
(append inverse-roles
(mapcar #'reverse inverse-roles)
(mapcar #'(lambda (x)
(list x x))
reflexive-roles))))
(roles-to-ids (make-hash-table :size n))
(ids-to-roles (make-array (list n)))
(roles-to-inverses (make-hash-table :size n))
(axiom-table (make-array (list n n)))
(all-roles (mapcar #'change-package
(tree-flatten
(list inverse-roles
axioms))))
(roles (mapcar #'change-package roles))
(reflexive-roles (mapcar #'change-package reflexive-roles)))
(unless (subsetp all-roles roles)
(error "Undeclared roles: ~A!"
(set-difference all-roles roles)))
(loop as role in roles
as i from 0 to n do
(setf (gethash role roles-to-ids) i)
(setf (aref ids-to-roles i) role))
(loop as pair in inverse-roles
do
(let* ((role (first pair))
(inv (second pair))
(ret-inv (gethash role roles-to-inverses))
(ret-role (gethash inv roles-to-inverses)))
(if (or (and ret-inv
(not (eq inv ret-inv)))
(and ret-role
(not (eq role ret-role))))
(error "Bad inverses roles!")
(progn
(setf (gethash role roles-to-inverses) inv)
(setf (gethash inv roles-to-inverses) role)))))
(dolist (axiom axioms)
(let ((from (change-package (first axiom)))
(to (change-package (second axiom)))
(res (mapcar #'change-package (ensure-list (third axiom)))))
(when (member (list from to)
(mapcar #'butlast (remove axiom axioms))
:test #'equal)
(error "Double axiom for ~A o ~A!" from to))
(setf (aref axiom-table (gethash from roles-to-ids) (gethash to roles-to-ids))
(list res (mapcar #'(lambda (x) (gethash x roles-to-ids)) res)))))
(let ((rbox
(make-instance type
:axioms axioms
:name name
:n n
:reflexive-roles reflexive-roles
:table axiom-table
:roles roles
:roles-to-inverses roles-to-inverses
:roles-to-ids roles-to-ids
:ids-to-roles ids-to-roles)))
(push rbox *all-rboxes*)
rbox))))))
(defmacro with-rbox ((name &key
(error-p t)
roles
inverse-roles
reflexive-roles
delete-if-exists-p
(type 'rolebox)
axioms)
&rest body)
`(let ((*cur-rbox*
(or (and ,(not delete-if-exists-p) (find-rbox ',name :error-p nil))
(create-rbox ',name ',roles
:axioms ',axioms
:type ',type
:error-p ,error-p
:inverse-roles ',inverse-roles
:reflexive-roles ',reflexive-roles
:delete-if-exists-p ,delete-if-exists-p))))
,@body))
(defmacro in-rbox (name &key
(error-p t)
axioms
roles
inverse-roles
reflexive-roles
delete-if-exists-p
(type 'rolebox))
`(let ((x ni))
(with-rbox (,name :roles ,roles
:axioms ,axioms
:type ,type
:error-p ,error-p
:inverse-roles ',inverse-roles
:reflexive-roles ',reflexive-roles
:delete-if-exists-p ,delete-if-exists-p)
(setf x *cur-rbox*))
(setf *cur-rbox* x)))
(defun find-rbox (name &key (error-p t))
(if (typep name 'rolebox)
name
(or (find name *all-rboxes* :key #'name)
(progn
(=> error-p (error "Can't find role box ~A!" name))
nil))))
(defun delete-rbox (name &key all-p)
(loop
(let ((rbox (find-rbox name :error-p nil)))
(unless rbox (return))
(setf *all-rboxes*
(delete rbox *all-rboxes*))
(unless all-p (return)))))
;;;
;;;
;;;
(defmethod inv-role ((rbox rolebox) (role symbol))
(with-slots (roles-to-inverses) rbox
(or (gethash role roles-to-inverses)
`(inv ,role))))
(defmethod inv-role ((rbox rolebox) (role list))
(if (inv-role-p role)
(if (symbolp (second role))
(second role)
(inv-role rbox (inv-role rbox (second role))))
(mapcar #'(lambda (x) (inv-role rbox x)) role)))
(defun inv-role-p (x)
(and (consp x)
(eq (first x) 'inv)
(second x)
(not (cddr x))))
(defmethod full-disjunctive-role ((rbox rolebox))
(roles rbox))
;;;
;;;
;;;
(defmethod get-role ((rbox rolebox) (role symbol))
role)
(defmethod get-role ((rbox rolebox) (role list))
(if (inv-role-p role)
(inv-role rbox (second role))
(let ((role (mapcar #'(lambda (x) (get-role rbox x)) role)))
(if (member nil role)
nil
role))))
;;;
;;;
;;;
(defmethod encode ((box rolebox) (role symbol))
(gethash (get-role box role) (roles-to-ids box)))
(defmethod encode ((box rolebox) (role list))
(if (inv-role-p role)
(encode box (get-role box role))
(mapcar #'(lambda (r)
(encode box r))
role)))
(defmethod decode ((box rolebox) (role integer))
(when (and (not (minusp role))
(< role (n box)))
(aref (ids-to-roles box) role)))
(defmethod decode ((box rolebox) (role list))
(mapcar #'(lambda (r) (decode box r)) role))
;;;
;;;
;;;
(defmethod lookup ((box rolebox) (from symbol) (to symbol))
(with-slots (table) box
(let ((i (encode box (get-role box from)))
(j (encode box (get-role box to))))
(when (and i j)
(first (aref table i j))))))
(defmethod lookup ((box rolebox) from to)
(lookup box (ensure-list from) (ensure-list to)))
(defmethod lookup ((box rolebox) (from list) (to list)) ; aus Effizienzgruenden so gemacht
(let ((rfrom (if (inv-role-p from)
(get-role box from)
from))
(rto (if (inv-role-p to)
(get-role box to)
to)))
(if (or (inv-role-p from)
(inv-role-p to))
nil
(with-slots (table) box
(let ((dis nil))
(dolist (from rfrom)
(dolist (to rto)
(let ((i (get-role box from))
(j (get-role box to)))
(if (or (inv-role-p i)
(inv-role-p j))
(return-from lookup nil)
(let* ((i (encode box i))
(j (encode box j)))
(if (and i j)
(dolist (c (first (aref table i j)))
(push c dis))
(return-from lookup nil)))))))
(remove-duplicates dis))))))
;;;
;;;
;;;
(defpersistentclass jepd-rolebox (rolebox) nil)
(defmethod initialize-instance :after ((rolebox jepd-rolebox) &rest initargs)
(declare (ignorable initargs))
(when (cdr (reflexive-roles rolebox))
(error "More than one reflexive role found: ~A!" (reflexive-roles rolebox)))
(dolist (role (roles rolebox))
(unless (inv-role rolebox role)
(error "Missing inverse role: ~A!" role)))
(dolist (r (roles rolebox))
(dolist (s (roles rolebox))
(unless (lookup rolebox r s)
(error "Missing role axiom: ~A o ~A!" r s)))))
| 10,156 | Common Lisp | .lisp | 253 | 26.284585 | 92 | 0.482472 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | c369cb4625e398fc78cf6c344bad506880d42c2fcdfe9f38e9650a6aab50467a | 12,510 | [
-1
] |
12,511 | process.lisp | lambdamikel_DLMAPS/src/thematic-substrate/process.lisp | ;;; -*- Mode: Lisp; Syntax: Ansi-Common-Lisp; Package: THEMATIC-SUBSTRATE; Base: 10 -*-
(in-package :THEMATIC-SUBSTRATE)
(defmacro start-process (&body body)
#+:multiprocess-queries
`(#-:mcl mp:process-run-function
#+:mcl ccl:process-run-function
"Query Answering Process"
;;'(:size 1400000)
#-:mcl nil
#'(lambda ()
,@body))
#-:multiprocess-queries
`(progn
(funcall #'(lambda ()
,@body))
nil ; wichtig!
))
#|
#+:lispworks
(defmacro with-critical-section (&body body)
;; funktioniert nicht?!
`(lispworks:without-interrupts
,@body))
#-:lispworks
(defmacro with-critical-section (&body body)
`(error "Please implement macro with-critical-section (in macros.lisp)!"))
|#
(defvar *lock* nil)
(defmacro with-critical-section (&body body)
#+:multiprocess-queries
`(progn
(when (not (eq *lock* *process-id*))
(loop while *lock* do
(sleep +sleep-time+))
(when *lock*
(error "Someone stole the *lock*?!")))
(setf *lock* *process-id*)
(unwind-protect
;; (lispworks:without-preemption
;; funktioniert nicht!!!
,@body
(setf *lock* nil)))
#-:multiprocess-queries
`(progn
,@body))
| 1,363 | Common Lisp | .lisp | 45 | 22.688889 | 87 | 0.590256 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 59b539eb770ed5e6428377b8202823a501371c4361b15fb5c721d97c7701c80b | 12,511 | [
-1
] |
12,512 | descriptions5.lisp | lambdamikel_DLMAPS/src/thematic-substrate/descriptions5.lisp | ;;; -*- Mode: Lisp; Syntax: Ansi-Common-Lisp; Package: THEMATIC-SUBSTRATE; Base: 10 -*-
(in-package :THEMATIC-SUBSTRATE)
;;;
;;;
;;;
(defvar *node-description-class* nil)
(defvar *edge-description-class* nil)
;;;
;;;
;;;
(defpersistentclass semantic-entity () ; abstrakt
;;;
;;; die textual-description is sozusagen die Basis-Beschreibung!
;;; Bei einer edge-description z.B. die Liste der Rollen-Symbole, als Disjunktion interpretiert
;;; nur die description selbst weiß wie die "rohe" textual-description zu interpretieren ist
;;; (ob eine textual-descritpion vom Typ Liste z.B. eine Disjunktion oder Konjunktion repräsentiert)
;;;
((textual-description :accessor textual-description :initarg :textual-description)
(original-description :accessor original-description :initarg :original-description)
(constructor-sym :reader constructor-sym :initarg :constructor-sym :initform nil)))
(defmethod initialize-description ((descr semantic-entity))
t)
(defmethod initialize-instance :after ((object semantic-entity) &rest initargs &key dont-initialize-p)
(when (and (slot-boundp object 'textual-description)
(not (slot-boundp object 'original-description)))
(setf (original-description object)
(textual-description object)))
(unless dont-initialize-p
;;; Idee: hier läuft der Parser an, um die ursprüngliche textual-description zu
;;; bearbeiten; original-description memoriert den originalen Wert der Descr.
(initialize-description object)))
(defmethod change-textual-description ((description semantic-entity) textual-description &key reinitialize-p)
(setf (textual-description description) textual-description)
(when reinitialize-p (initialize-description description))
description)
(defmethod copy ((object semantic-entity) &rest args)
(subclass-responsibility 'copy))
(defmethod print-object ((object semantic-entity) stream)
(format stream "#<~A: ~A>" (type-of object) (textual-description object)))
;;;
;;; f. Graph-Visualizer
;;;
(defmethod get-textual-description ((object semantic-entity))
(format nil "~A" (textual-description object)))
;;;
;;; Mixins - keine Descriptions!
;;;
(defpersistentclass racer-concept-mixin ()
((racer-concept :reader racer-concept)
(racer-tbox :reader racer-tbox :initarg :racer-tbox :initform nil)))
(defpersistentclass racer-role-mixin ()
((racer-role :reader racer-role)
(racer-tbox :reader racer-tbox :initarg :racer-tbox :initform nil)
(allow-negated-roles-p :initarg :allow-negated-roles-p :initform nil)))
(defmethod dl-concept ((rcm racer-concept-mixin))
(racer-concept rcm))
(defmethod dl-role ((rcm racer-role-mixin))
(racer-role rcm))
;;;
;;;
;;;
(defmethod initialize-description :after ((descr racer-concept-mixin))
(with-slots (racer-package racer-concept racer-tbox textual-description) descr
(setf racer-concept
(convert-to-racer-concept-expression textual-description racer-package)
racer-tbox
(convert-to-racer-tbox-name racer-tbox racer-package))))
(defmethod initialize-description :after ((descr racer-role-mixin))
(with-slots (racer-package racer-role racer-tbox textual-description) descr
(setf racer-role
(convert-to-racer-role-expression textual-description)
racer-tbox
(convert-to-racer-tbox-name racer-tbox racer-package))))
;;;
;;;
;;;
(defmethod check-same-tbox-and-package ((descr1 racer-concept-mixin) (descr2 racer-concept-mixin))
(if (or (not (eq (racer-tbox descr1)
(racer-tbox descr2)))
(not (eq (racer-package descr1)
(racer-package descr2))))
(error "~A ~A must use the same TBox and/or package!" descr1 descr2)))
(defmethod check-same-tbox-and-package ((descr1 racer-role-mixin) (descr2 racer-role-mixin))
(if (or (not (eq (racer-tbox descr1)
(racer-tbox descr2)))
(not (eq (racer-package descr1)
(racer-package descr2))))
(error "~A ~A must use the same TBox and/or package!" descr1 descr2)))
;;;
;;;
;;;
(defmethod get-negated-concept ((descr racer-concept-mixin))
(let ((descr
(make-description 'racer-node-description
`(not ,(textual-description descr)))))
(initialize-description descr)
descr))
(defmethod concept-is-consistent-p ((descr racer-concept-mixin))
(concept-satisfiable-p
(convert-to-racer-concept-expression
(racer-concept descr)
(racer-package descr))
(racer-tbox descr)))
(defmethod concept-is-tautological-p ((descr racer-concept-mixin))
(not (concept-satisfiable-p
(convert-to-racer-concept-expression
`(not (and ,(racer-concept descr)))
(racer-package descr))
(racer-tbox descr))))
(defmethod concept-implies-p ((descr1 racer-concept-mixin) (descr2 racer-concept-mixin))
(check-same-tbox-and-package descr1 descr2)
(not (concept-satisfiable-p
(convert-to-racer-concept-expression
`(and ,(racer-concept descr1)
(not ,(racer-concept descr2)))
(racer-package descr1))
(racer-tbox descr1))))
;;;
;;;
;;;
(defmethod consistent-p ((descr racer-concept-mixin) &rest args)
(apply #'concept-is-consistent-p descr args))
(defmethod tautological-p ((descr racer-concept-mixin) &rest args)
(apply #'concept-is-tautological-p descr args))
(defmethod implies-p ((descr1 racer-concept-mixin) (descr2 racer-concept-mixin) &rest args)
(apply #'concept-implies-p descr1 descr2 args))
;;;
;;;
;;;
(defmethod role-is-consistent-p ((descr racer-role-mixin))
t)
(defmethod role-is-tautological-p ((descr racer-role-mixin))
nil)
(defmethod role-implies-p ((descr1 racer-role-mixin) (descr2 racer-role-mixin))
(check-same-tbox-and-package descr1 descr2)
(not (concept-satisfiable-p
(convert-to-racer-concept-expression
`(and (some ,(racer-role descr1) top)
(all ,(racer-role descr2) bottom))
(racer-package descr1))
(racer-tbox descr1))))
;;;
;;;
;;;
(defmethod consistent-p ((descr racer-role-mixin) &rest args)
(apply #'role-is-consistent-p descr args))
(defmethod tautological-p ((descr racer-role-mixin) &rest args)
(apply #'role-is-tautological-p descr args))
(defmethod implies-p ((descr1 racer-role-mixin) (descr2 racer-role-mixin) &rest args)
(apply #'role-implies-p descr1 descr2 args))
;;;
;;; Abstrakte Descriptions
;;; Achtung! Die "racer"-Descriptions sind für die SUBSTRATE-EBENE,
;;; *nicht* für die :racer-description-Ebene bei make-node etc.!!!!
;;;
(defpersistentclass description (semantic-entity)
((satisfiable :reader satisfiable :initform :not-tested)
(inconsistent :reader inconsistent :initform :not-tested)
(tautological :reader tautological :initform :not-tested)
(entails :reader entails :initform nil)
(not-entails :reader not-entails :initform nil)
(entailed-by :reader entailed-by :initform nil)
(not-entailed-by :reader not-entailed-by :initform nil)))
(defmethod make-description ((class symbol) descr &rest args &key type &allow-other-keys)
(apply #'make-instance (or type class)
:textual-description descr
:constructor-sym class
:allow-other-keys t
args))
(defmethod copy ((description description) &rest args)
(apply #'make-description
(constructor-sym description)
(copy-tree (textual-description description))
args))
;;;
;;;
;;;
(defpersistentclass node-description (description)) ;;; abstrakt
(defpersistentclass edge-description (description)) ;;; abstrakt
;;;
;;;
;;;
(defmethod get-inverse-description ((descr description))
(subclass-responsibility 'get-inverse-description))
(defmethod get-negated-description ((descr description))
(subclass-responsibility 'get-negated-description))
;;;
;;; Simple Descriptions: lediglich syntaktische Beschreibungen
;;;
(defpersistentclass simple-description (description)) ;;; abstrakt
(defpersistentclass simple-disjunctive-description (simple-description)) ; Liste = Disjunktion
(defpersistentclass simple-conjunctive-description (simple-description)) ; Liste = Konjunktion
;;; (defpersistentclass boolean-description (simple-description)) ;;; to be implemented
;;;
;;;
;;;
(defmethod underspecified-p ((description simple-disjunctive-description) &rest args)
(cdr (ensure-list (textual-description description))))
(defmethod get-disjuncts ((description simple-disjunctive-description) &rest args)
(ensure-list (textual-description description)))
;;;
;;;
;;;
(defmethod underspecified-p ((description simple-conjunctive-description) &rest args)
nil)
(defmethod get-conjuncts ((description simple-conjunctive-description) &rest args)
(ensure-list (textual-description description)))
;;;
;;;
;;;
(defmethod initialize-description :after ((object simple-description))
(with-slots (textual-description) object
(when (consp textual-description)
(setf (slot-value object 'textual-description)
(remove-duplicates textual-description
:test #'equal)))))
(defmethod print-object ((object simple-description) stream)
(format stream "#<~A: ~A>" (type-of object)
(textual-description object)))
;;;
;;; Achtung - bewusst redundant!!! Denke an unvollstaendige Algorithmen
;;;
(defmethod reset-sat-status ((description description))
'ok)
(defmethod reset-sat-status :before ((description description))
(with-slots (entails entailed-by
not-entails not-entailed-by
satisfiable tautological inconsistent) description
(setf satisfiable :not-tested
tautological :not-tested
inconsistent :not-tested
entails nil
entailed-by nil
not-entails nil
not-entailed-by nil)
description))
;;;
;;;
;;;
(defmethod consistent-p :around ((description description) &rest args)
(declare (ignorable args))
(with-slots (satisfiable inconsistent tautological) description
(when (eq satisfiable :not-tested)
(setf satisfiable (call-next-method))
(cond ((eq satisfiable t) ;;; auch :dont-know kann zurueckkommen!!! richtig so!
(setf inconsistent nil))
((not satisfiable)
(setf inconsistent t)
(setf tautological nil))))
satisfiable))
(defmethod inconsistent-p :around ((description description) &rest args)
(declare (ignorable args))
(with-slots (satisfiable inconsistent tautological) description
(when (eq inconsistent :not-tested)
(setf inconsistent (call-next-method))
(cond ((eq inconsistent t)
(setf satisfiable nil)
(setf tautological nil))
((not inconsistent)
(setf satisfiable t))))
inconsistent))
(defmethod tautological-p :around ((description description) &rest args)
(declare (ignorable args))
(with-slots (satisfiable inconsistent tautological) description
(when (eq tautological :not-tested)
(setf tautological (call-next-method))
(cond ((eq tautological t)
(setf satisfiable t)
(setf inconsistent nil))))
tautological))
;;;
;;; Reasoning; consistent-p sollte NIL, T, :UNKNOWN liefern
;;;
(defmethod consistent-p ((description description) &rest args)
(subclass-responsibility 'consistent-p))
(defmethod inconsistent-p ((description description) &rest args)
;;; Achtung! kann ja auch :dont-know zurueckkommen!
(eq (apply #'consistent-p description args) nil))
(defmethod tautological-p ((description description) &rest args)
(subclass-responsibility 'tautological-p))
;;;
;;;
;;;
;;;
(defmethod implies-p :around ((descr1 description) (descr2 description) &rest args)
(declare (ignorable args))
(call-next-method))
#|
;;; funktioniert nicht!
;;; denke an die Descriptions, die ihrer Beschreibungen wechseln,
;;; dabei aber Objektidentität behalten!
(if (member descr2 (entails descr1))
t
(if (member descr2 (not-entails descr1))
nil
(let ((res (call-next-method)))
(when (eq res t)
(push descr2
(slot-value descr1 'entails))
(push descr1
(slot-value descr2 'entailed-by)))
(when (eq res nil)
(push descr2
(slot-value descr1 'not-entails))
(push descr1
(slot-value descr2 'not-entailed-by)))
res))))
|#
;;;
;;;
;;;
(defmethod implies-p ((descr1 description) (descr2 description) &rest args)
(subclass-responsibility 'implies-p))
;;;
;;;
;;;
(defmethod equivalent-p ((descr1 description) (descr2 description) &rest args)
(and (apply #'implies-p descr1 descr2 args)
(apply #'implies-p descr2 descr1 args)))
;;;
;;;
;;;
(defun is-atom-p (expr)
(or (symbolp expr)
(and (consp expr)
(eq (first expr) :not)
(symbolp (second expr))
(not (cddr expr)))))
(defun negated-atoms-p (x y)
(and (is-atom-p x)
(is-atom-p y)
(or (and (symbolp x)
(consp y)
(symbolp (second y))
(eq (first y) :not)
(eq x (cadr y)))
(and (symbolp y)
(consp x)
(symbolp (second x))
(eq (first x) :not)
(eq y (cadr x))))))
(defun get-negated-atom (x)
(if (eq x :bottom)
:top
(if (eq x :top)
:bottom
(if (and (consp x)
(eq (first x) :not)
(symbolp (second x)))
(second x)
(if (symbolp x)
`(:not ,x)
(error "Bad atom: ~A!" x))))))
;;;
;;;
;;;
(defmethod get-negated-description ((description simple-disjunctive-description))
(if (consp (textual-description description))
(make-description 'simple-conjunctive-description
(mapcar #'get-negated-atom (textual-description description)))
(make-description 'simple-conjunctive-description
(get-negated-atom (textual-description description)))))
(defmethod get-negated-description ((description simple-conjunctive-description))
(if (consp (textual-description description))
(make-description 'simple-disjunctive-description
(mapcar #'get-negated-atom (textual-description description)))
(make-description 'simple-disjunctive-description
(get-negated-atom (textual-description description)))))
;;;
;;;
;;;
(defmethod inconsistent-p ((description simple-disjunctive-description) &rest args)
;;; Verfeinerungsbeduerftig
(every #'(lambda (x) (eq x :bottom))
(ensure-list (textual-description description))))
(defmethod consistent-p ((description simple-disjunctive-description) &rest args)
;;; Entscheidbar -> nil, T, kein :UNKNOWN mehr
(not (apply #'inconsistent-p description args)))
(defmethod tautological-p ((description simple-disjunctive-description) &rest args)
(apply #'inconsistent-p (get-negated-description description) args))
;;;
;;;
;;;
(defmethod implies-p ((descr1 simple-disjunctive-description) (descr2 simple-disjunctive-description) &rest args)
(every #'(lambda (x)
(apply #'inconsistent-p x args))
(let ((descr2 (get-negated-description descr2)))
(mapcar #'(lambda (disjunct)
(make-description 'simple-conjunctive-description
(cons disjunct (textual-description descr2))))
(ensure-list (textual-description descr1))))))
(defmethod implies-p ((descr1 simple-disjunctive-description) (descr2 simple-conjunctive-description) &rest args)
(every #'(lambda (x)
(apply #'inconsistent-p x args))
(mapcar #'(lambda (prod)
(make-description 'simple-conjunctive-description
prod))
(prod (ensure-list (textual-description descr2))
(mapcar #'get-negated-atom
(ensure-list (textual-description descr1)))))))
;;;
;;;
;;;
(defmethod inconsistent-p ((description simple-conjunctive-description) &rest args)
;;; Verfeinerungsbeduerftig
(or (some #'(lambda (x) (eq x :bottom)) (ensure-list (textual-description description)))
(loop as l on (ensure-list (textual-description description))
as x = (first l)
thereis (some #'(lambda (y)
(negated-atoms-p x y))
(rest l)))))
(defmethod consistent-p ((description simple-conjunctive-description) &rest args)
(not (apply #'inconsistent-p description args)))
(defmethod tautological-p ((description simple-conjunctive-description) &rest args)
(apply #'inconsistent-p (get-negated-description description) args))
;;;
;;;
;;;
(defmethod implies-p ((descr1 simple-conjunctive-description) (descr2 simple-conjunctive-description) &rest args)
(every #'(lambda (x)
(apply #'inconsistent-p x args))
(mapcar #'(lambda (disjunct)
(make-description 'simple-conjunctive-description
(cons (get-negated-atom disjunct)
(ensure-list (textual-description descr1)))))
(ensure-list (textual-description descr2)))))
(defmethod implies-p ((descr1 simple-conjunctive-description) (descr2 simple-disjunctive-description) &rest args)
(apply #'inconsistent-p
(make-description 'simple-conjunctive-description
(append (ensure-list (textual-description descr1))
(mapcar #'get-negated-atom (ensure-list (textual-description descr2)))))
args))
;;;
;;; Simple Beschreibungen
;;; Nodes: KONJUNKTIV
;;; Edges: DISJUNKTIV!!!
;;;
(defpersistentclass simple-node-description (node-description simple-conjunctive-description))
(defpersistentclass simple-edge-description (edge-description simple-disjunctive-description))
;;;
;;; Racer Descriptions: RACER-Beschreibungen inkl. TBox
;;; RACER ABox-"Reimplementation"
;;;
(defpersistentclass racer-description (description)
((racer-package :reader racer-package :initarg :racer-package :initform nil)))
(defpersistentclass racer-node-description (node-description racer-description racer-concept-mixin))
(defpersistentclass racer-edge-description (edge-description racer-description racer-role-mixin))
;;;
;;; Konstrukturen: Knoten
;;;
(defmethod make-node-description ((class symbol) descr &rest args)
(apply #'make-description class descr args))
(defmacro ncon (descr &rest args)
`(make-standard-node-description ',descr ,@args))
(defun make-standard-node-description (descr &rest args)
(apply #'make-node-description *node-description-class* descr args))
;;;
;;; Konstrukturen: Kanten
;;;
(defmethod make-edge-description ((class symbol) descr &rest args)
(apply #'make-description class descr args))
(defmacro econ (descr &rest args)
`(make-standard-edge-description ',descr ,@args))
(defun make-standard-edge-description (descr &rest args)
(apply #'make-edge-description *edge-description-class* descr args))
;;;
;;; AND/OR-Konstruktoren für Descriptions
;;;
(defmethod make-and-description :before ((descr description) &rest args &key descriptions &allow-other-keys)
(unless (every #'(lambda (x)
(eq (constructor-sym descr) (constructor-sym x)))
descriptions)
(error "Descriptions not all of same type!")))
(defmethod make-or-description :before ((descr description) &rest args &key descriptions &allow-other-keys)
(unless (every #'(lambda (x)
(eq (constructor-sym descr) (constructor-sym x)))
descriptions)
(error "Descriptions not all of same type!")))
;;;
;;; nur intern!
;;;
(defmethod make-union-description ((descr simple-description) &rest args &key descriptions &allow-other-keys)
(if descriptions
(apply #'make-description
(constructor-sym descr)
(reduce #'union
(mapcar #'(lambda (x) (ensure-list (textual-description x)))
(cons descr descriptions)))
args)
descr))
(defmethod make-intersection-description ((descr simple-description) &rest args &key descriptions &allow-other-keys)
(if descriptions
(apply #'make-description
(constructor-sym descr)
(reduce #'intersection
(mapcar #'(lambda (x) (ensure-list (textual-description x)))
(cons descr descriptions)))
args)
descr))
;;;
;;; Logisch, extern:
;;;
(defmethod make-and-description ((descr simple-conjunctive-description) &rest args)
(apply #'make-union-description descr args))
#|
;;; falsch! -> man braucht echte BOOLEAN DESCRIPTIONS HIER! DNF bestimmen etc.
(defmethod make-or-description ((descr simple-conjunctive-description) &rest descriptions)
(make-union-description descr descriptions))
|#
(defmethod make-and-description ((descr simple-disjunctive-description) &rest args)
(apply #'make-intersection-description descr args))
(defmethod make-or-description ((descr simple-disjunctive-description) &rest args)
(apply #'make-union-description descr args))
;;;
;;; Rasoning: Racer descriptions
;;;
(defmethod consistent-p ((description racer-node-description) &rest args)
(concept-is-consistent-p description))
(defmethod consistent-p ((description racer-edge-description) &rest args)
(role-is-consistent-p description))
(defmethod tautological-p ((description racer-node-description) &rest args)
(concept-is-tautological-p description))
(defmethod tautological-p ((description racer-edge-description) &rest args)
(role-is-tautological-p description))
;;;
;;;
;;;
(defmethod get-negated-description ((description racer-node-description))
(get-negated-concept description))
;;;
;;;
;;;
(defmethod implies-p ((descr1 racer-node-description) (descr2 racer-node-description) &rest args)
(apply #'concept-implies-p descr1 descr2 args))
(defmethod implies-p ((descr1 racer-edge-description) (descr2 racer-edge-description) &rest args)
(apply #'role-implies-p descr1 descr2 args))
;;;
;;;
;;;
(defmethod make-and-description ((descr racer-node-description) &rest args &key descriptions &allow-other-keys)
(apply #'make-description
(type-of descr)
`(and ,@(mapcar #'racer-concept (cons descr descriptions)))
args))
(defmethod make-or-description ((descr racer-node-description) &rest args &key descriptions &allow-other-keys)
(apply #'make-description
(type-of descr)
`(or ,@(mapcar #'racer-concept (cons descr descriptions)))
args))
;;;
;;; Added in 2021:
;;;
#|
(defmethod implies-p ((descr1 #<MIDELORA-MAP-NODE-DESCRIPTION: description) (descr2 description) &rest args)
(subclass-responsibility 'implies-p))
|#
| 23,125 | Common Lisp | .lisp | 556 | 35.442446 | 116 | 0.68132 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | d8b8edd62f2d23e0ec3fb4a1086fd226282dc5a5df5f1c73aebf44b1cf2de2e9 | 12,512 | [
-1
] |
12,513 | racer-substrate5.lisp | lambdamikel_DLMAPS/src/thematic-substrate/racer-substrate5.lisp | ;;; -*- Mode: Lisp; Syntax: Ansi-Common-Lisp; Package: THEMATIC-SUBSTRATE; Base: 10 -*-
(in-package :THEMATIC-SUBSTRATE)
;;;
;;; die Basis (auch fuer nRQL!) ist in common.lisp!
;;;
(defmethod info ((substrate racer-substrate) &key &allow-other-keys)
(format nil "Name: ~A, Type: ~A Nodes: ~A, Edges: ~A"
(name substrate)
(type-of substrate)
(no-of-nodes substrate)
(no-of-edges substrate)))
;;;
;;;
;;;
(defpersistentclass racer-abox-mirror-substrate (racer-substrate))
;;;
;;;
;;;
(defpersistentclass racer-substrate-object (substrate-object)
;;; stellt (optionale!) assoziation mit racer-objekten her
((racer-object :reader racer-object :initarg :racer-object :initform nil)
(racer-description :reader racer-description :initarg :racer-description :initform nil)))
(defpersistentclass racer-substrate-node (racer-substrate-object substrate-node))
(defpersistentclass racer-substrate-edge (racer-substrate-object substrate-edge))
;;;
;;;
;;;
(defpersistentclass racer-descriptions-substrate-object (substrate-object))
(defpersistentclass racer-descriptions-substrate-node (racer-descriptions-substrate-object substrate-node))
(defpersistentclass racer-descriptions-substrate-edge (racer-descriptions-substrate-object substrate-edge))
;;;
;;;
;;;
(defpersistentclass racer-abox-mirror-substrate-object (racer-substrate-object))
(defpersistentclass racer-abox-mirror-substrate-node (racer-abox-mirror-substrate-object racer-substrate-node))
(defpersistentclass racer-abox-mirror-substrate-edge (racer-abox-mirror-substrate-object racer-substrate-edge))
;;;
;;;
;;;
(defmethod get-standard-node-class ((substrate racer-substrate))
'racer-substrate-node)
(defmethod get-standard-edge-class ((substrate racer-substrate))
'racer-substrate-edge)
(defmethod get-standard-node-description-class ((substrate racer-substrate))
(call-next-method))
(defmethod get-standard-edge-description-class ((substrate racer-substrate))
(call-next-method))
;;; damit das "hybride racer-substrate" beliebig instantiert werden kann,
;;; ist die description-class für die Substrate-Objekte nicht festgelegt!
;;; in der ABox werden natürlich Racer-Beschreibungen generiert; beim
;;; Anlegen einer Knoten/Kanten-Beschreibung wird gesagt, ob die Beschreibung
;;; automatisch in eine Racer-Beschreibung konvertiert werden soll ("mirroring"),
;;; oder alternativ kann die :racer-description "von Hand" gesetzt werden, und
;;; dann ist die Substrate-Knoten/Kanten-Beschreibung unabhaengig von den Beschreibungen
;;; in der Racer-Abox
;;;
;;; Beim Racer-Descriptions-Substrate wird *keine* assoziierte ABox verwendet;
;;; daher werden, um Racer-Reasoning auszunutzen, einfach Racer-Konzepte/Rollen
;;; verwendet auf der Substrat-Ebene! Bestimmte Inkonsistenzen koennen natürlich
;;; nicht entdeckt werden, solange man nicht den Racer-Abox-Konsistenzcheck auf
;;; Racer-Descriptions-Substrate "reimplementiert".
;;;
(defmethod get-standard-node-class ((substrate racer-descriptions-substrate))
'racer-descriptions-substrate-node)
(defmethod get-standard-edge-class ((substrate racer-descriptions-substrate))
'racer-descriptions-substrate-edge)
(defmethod get-standard-node-description-class ((substrate racer-descriptions-substrate))
'racer-node-description)
(defmethod get-standard-edge-description-class ((substrate racer-descriptions-substrate))
'racer-edge-description)
;;;
;;;
;;;
(defmethod get-standard-node-class ((substrate racer-abox-mirror-substrate))
'racer-abox-mirror-substrate-node)
(defmethod get-standard-edge-class ((substrate racer-abox-mirror-substrate))
'racer-abox-mirror-substrate-edge)
(defmethod get-standard-node-description-class ((substrate racer-abox-mirror-substrate))
(call-next-method))
(defmethod get-standard-edge-description-class ((substrate racer-abox-mirror-substrate))
(call-next-method))
;;;
;;;
;;;
(defun thematic-object-p (object)
(and (typep object 'racer-substrate-object)
(racer-description object)))
(defun non-thematic-object-p (object)
(and (typep object 'substrate-object)
(not (thematic-object-p object))))
;;;
;;;
;;;
(defun non-thematic-node-p (node)
(and (typep node 'substrate-node)
(not (thematic-node-p node))))
(defun thematic-node-p (node)
(and (typep node 'racer-substrate-node)
(racer-description node)))
;;;
;;;
;;;
(defun non-thematic-edge-p (edge)
(and (typep edge 'substrate-edge)
(not (thematic-edge-p edge))))
(defun thematic-edge-p (edge)
(and (typep edge 'racer-substrate-edge)
(racer-description edge)))
;;;
;;;
;;;
(defmethod consistent-p ((obj racer-substrate) &key &allow-other-keys)
(and ;(abox-consistent-p (abox obj))
(call-next-method)))
;;;
;;; hier definiert, denn diese gibt es in nRQL nicht
;;;
(defmethod initialize-instance :after ((substrate racer-descriptions-substrate) &rest args
&key load-from-file &allow-other-keys)
(when load-from-file
(load load-from-file))
(apply #'set-tbox substrate args))
(defmethod initialize-instance :after ((substrate racer-abox-mirror-substrate) &rest args
&key &allow-other-keys)
(let* ((abox (abox substrate))
(nodes (all-individuals abox))
(node-description-class (get-standard-node-description-class substrate))
(edge-description-class (get-standard-edge-description-class substrate)))
(let ((hash (make-hash-table :size 10000)))
(dolist (assertion (all-concept-assertions abox))
(let ((node (first assertion))
(concept (second assertion)))
(if (gethash node hash)
(push concept (gethash node hash))
(setf (gethash node hash) (list concept)))))
(dolist (node nodes)
(let* ((concepts (gethash node hash))
(concept (make-node-description node-description-class
(or concepts :top))))
(create-node substrate node concept))))
(dolist (edge (all-role-assertions abox))
(let ((from (caar edge))
(to (cadar edge))
(role (make-edge-description edge-description-class (second edge))))
(unless (find-node substrate from)
(create-node substrate from (make-node-description node-description-class 'top)))
(unless (find-node substrate to)
(create-node substrate to (make-node-description node-description-class 'top)))
(create-edge substrate from to role)))))
;;;
;;;
;;;
(defmethod copy ((substrate racer-substrate) &rest args)
(declare (ignorable args))
(let ((copy (call-next-method)))
(with-slots (tbox abox) copy
(setf tbox (tbox substrate)
abox (abox substrate)))
copy))
(defmethod copy ((substrate racer-descriptions-substrate) &rest args)
(declare (ignorable args))
(let ((copy (call-next-method)))
(with-slots (tbox) copy
(setf tbox (tbox substrate)))
copy))
;;;
;;;
;;;
(defmethod delete-graph :after ((substrate racer-substrate) &rest args &key delete-abox-p &allow-other-keys)
(with-slots (abox) substrate
(when (and delete-abox-p abox)
(forget-abox abox))))
;;;
;;;
;;;
(defmethod initialize-instance :after ((node racer-substrate-node) &rest initargs
&key copy-p racer-description &allow-other-keys)
(unless copy-p
(with-slots (name in-graph racer-object) node
(with-slots (abox racer-package) in-graph
(when abox
(setf racer-object (convert-to-racer-individual-name name racer-package))
(if racer-description
(add-concept-assertion abox racer-object racer-description)
(add-concept-assertion abox racer-object 'racer:top)))))))
(defmethod delete-node :after ((substrate racer-substrate) (node racer-substrate-node) &key &allow-other-keys)
(when (and (thematic-node-p node)
(abox substrate))
(forget-concept-assertion
(abox substrate)
(racer-object node) (racer-description node))))
;;;
;;;
;;;
(defmethod initialize-instance :after ((object racer-substrate-edge) &rest initargs
&key copy-p racer-description &allow-other-keys)
(unless copy-p
(with-slots (in-graph from to racer-object) object
(with-slots (abox) in-graph
(setf racer-object (list (racer-object from) (racer-object to) racer-description))
(when racer-description
(add-role-assertion abox (racer-object from) (racer-object to) racer-description))))))
(defmethod delete-edge :after ((substrate racer-substrate) (edge racer-substrate-edge) &key &allow-other-keys)
(when (thematic-edge-p edge)
(forget-role-assertion (abox substrate)
(racer-object (from edge))
(racer-object (to edge))
(racer-description edge))))
;;;
;;; Wird bei der Objekterzeugung ":racer-description t" angeben, werden diese
;;; beiden Methoden verwendet, um die "description" in eine "gültige" (?)
;;; Racer-Beschreibung umzuwandeln. Sollte für Unterklassen entsprechend
;;; angepasst werden - je nach "description"-Unterklasse sollten entsprechende
;;; RACER-Umschreibungen zurückgegeben werden (wenn überhaupt möglich...)
;;;
(defmethod convert-to-racer-description ((descr node-description) &optional package)
(let ((descr (textual-description descr)))
(convert-to-racer-concept-expression (if (consp descr)
`(and ,@descr)
descr)
package)))
(defmethod convert-to-racer-description ((descr edge-description) &optional package)
(convert-to-racer-role-expression (textual-description descr) package))
;;;
;;; Per Default werden Knoten gespiegelt, Kanten nicht!!! s. "convert-to-racer-description-p"!
;;;
(defmethod create-node ((substrate racer-substrate) name (description node-description)
&rest args)
(apply #'make-node substrate :name name :description description args))
(defmethod make-node ((substrate racer-substrate)
&rest args
&key description racer-description (convert-to-racer-description-p t) &allow-other-keys)
(apply #'call-next-method substrate
:racer-description
(if (and (not racer-description)
convert-to-racer-description-p)
(convert-to-racer-description description (racer-package substrate))
racer-description)
args))
(defmethod create-edge ((substrate racer-substrate) (from substrate-node) (to substrate-node)
(description edge-description)
&rest args)
(apply #'make-edge substrate from to :description description args))
(defmethod make-edge ((substrate racer-substrate) (from substrate-node) (to substrate-node)
&rest args
&key description racer-description (convert-to-racer-description-p nil) &allow-other-keys)
(apply #'call-next-method substrate from to
:description description
:racer-description
(if (and (not racer-description)
convert-to-racer-description-p)
(convert-to-racer-description description (racer-package substrate))
racer-description)
args))
;;;
;;;
;;;
(defmethod copy-graph-item ((substrate racer-substrate) (object racer-substrate-object) &rest args)
(apply #'call-next-method
substrate object
:convert-to-racer-description-p nil
:racer-object (racer-object object)
:racer-description (racer-description object)
args))
;;;
;;;
;;;
(defmethod add-to-node ((substrate racer-substrate) (node substrate-node) (delta-description node-description)
&key &allow-other-keys)
(break "To be implemented!"))
(defmethod add-to-node ((substrate racer-descriptions-substrate) (node substrate-node) (delta-description node-description)
&key &allow-other-keys)
(break "To be implemented!"))
;;;
;;;
;;;
(defmethod get-associated-abox-individual ((substrate racer-substrate) (node substrate-node))
nil)
(defmethod get-associated-abox-individual ((substrate racer-substrate) (node racer-substrate-node))
(racer-object node))
#+:midelora
(defmethod get-associated-abox-individual ((substrate midelora-substrate) (node substrate-node))
node)
;;;
;;;
;;;
(defmethod get-associated-substrate-node ((substrate substrate) abox-ind)
;;;(find-node substrate abox-ind :error-p nil))
;;; wegen des Package-Problemes!!!
(loop as key being the hash-key of (node-table substrate)
as val being the hash-value of (node-table substrate)
when (and (symbolp key)
(string-equal (symbol-name key)
(symbol-name abox-ind)))
return val))
#+:midelora
(defmethod get-associated-substrate-node ((substrate midelora-substrate) (abox-ind substrate-node))
abox-ind)
;;;
;;;
;;;
(defmethod thematic-nodes ((substrate racer-substrate))
(get-nodes substrate :satisfying #'thematic-node-p))
(defmethod thematic-edges ((substrate racer-substrate))
(get-edges substrate :satisfying #'thematic-edge-p))
;;;
;;;
;;;
#|
(with-substrate (test :type 'racer-substrate
:delete-if-exists-p t
:error-p t
:new-tbox-p t
:new-abox-p t
:abox 'vdvgamma)
(setf *x* *cur-substrate*)
(node a (ncon (a b (all r (or (not d) (not c))))))
(node b (ncon (c d)))
(edge a b (econ r) :convert-to-racer-description-p t) ; wichtig, sonst wird keine ABox-Kante angelegt!
(visualize *x*))
(with-substrate (test :type 'racer-descriptions-substrate
:delete-if-exists-p t
:error-p t
:new-tbox-p t
:new-abox-p t
:abox 'gamma)
(setf *x* *cur-substrate*)
(node a (ncon (and a (all r (not b)))))
(node b (ncon (or b (all (inv r) (not a)))))
(edge a b (econ r) :convert-to-racer-description-p t) ; wichtig, sonst wird keine ABox-Kante angelegt!
(visualize *x*))
(with-substrate (family-mirror
:type 'racer-abox-mirror-substrate
:delete-if-exists-p t
;:racer-package 'racer-user
:load-from-file "/home/mwessel/lispworks/work/dlmaps/query/family-1-no-signature.racer")
(setf *x* *cur-substrate*))
(with-substrate (heflin
:type 'racer-abox-mirror-substrate
:delete-if-exists-p t
:racer-package 'thematic-substrate
:load-from-file "/home/mwessel/lispworks/work/dlmaps/query/heflin/heflin/university.lisp")
(setf *x* *cur-substrate*))
(with-substrate (heflin
:type 'racer-abox-mirror-substrate
:delete-if-exists-p t
:racer-package 'thematic-substrate
:load-from-file "/home/mwessel/lispworks/work/dlmaps/query/heflin/heflin/university0.lisp")
(setf *x* *cur-substrate*))
|#
| 15,418 | Common Lisp | .lisp | 350 | 36.862857 | 123 | 0.668923 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 49f757011fc5d202b709b249ab23f1d3965920e169d08a96018b108d24502120 | 12,513 | [
-1
] |
12,514 | rolebox-substrate6.lisp | lambdamikel_DLMAPS/src/thematic-substrate/rolebox-substrate6.lisp | ;;; -*- Mode: Lisp; Syntax: Ansi-Common-Lisp; Package: THEMATIC-SUBSTRATE; Base: 10 -*-
(in-package :THEMATIC-SUBSTRATE)
;;;
;;;
;;;
(defgeneric get-support (edge &key &allow-other-keys))
(defgeneric apply-rolebox-axioms (rolebox-substrate &key &allow-other-keys))
;;;
;;; Das Rolebox-Substrate bietet die Möglichkeit, ein Substrate
;;; mit einer Rolebox zu assoziieren. Da in der Rolebox Rollenaxiome,
;;; inverse und reflexive Rollen deklariert werden, verwaltet das
;;; Substrate automatisch die Inversen und Reflexiven.
;;;
(defpersistentclass rolebox-edge-description (simple-edge-description))
(defmethod implies-p ((descr1 rolebox-edge-description) (descr2 rolebox-edge-description) &rest args)
(subsetp (ensure-list (textual-description descr1))
(ensure-list (textual-description descr2))))
;;;
;;;
;;;
(defmethod eq-description-p ((description rolebox-edge-description))
(equal '(eq) (textual-description description)))
;;;
;;;
;;;
(defmethod copy ((description rolebox-edge-description) &rest args)
(make-edge-description (constructor-sym description) (textual-description description)))
;;;
;;;
;;;
(defpersistentclass rolebox-node-description (simple-node-description) )
(defmethod copy ((description rolebox-node-description) &rest args)
(make-edge-description (constructor-sym description) (textual-description description)))
;;;
;;;
;;;
(defpersistentclass rolebox-substrate (substrate)
((rbox :initarg :rbox :reader substrate-rbox :initform nil)))
(defmethod initialize-instance :after ((substrate rolebox-substrate) &rest initargs &key (rbox *cur-rbox*))
(setf (slot-value substrate 'rbox)
(find-rbox rbox)))
;;;
;;;
;;;
(defpersistentclass rolebox-substrate-node (substrate-node))
(defun rolebox-substrate-node-p (node)
(typep node 'rolebox-substrate-node))
;;;
;;;
(defpersistentclass rolebox-substrate-edge (substrate-edge)
((inverse-edge :reader inverse-edge :initform nil)
(triangles :reader triangles :initform nil)
(referenced-by :reader referenced-by :initform nil)))
(defun rolebox-substrate-edge-p (edge)
(typep edge 'rolebox-substrate-edge))
;;;
;;;
;;:
(defmethod establish-context-for ((substrate rolebox-substrate) continuation)
(let ((*cur-rbox*
(substrate-rbox substrate)))
(if (next-method-p)
(call-next-method)
(funcall continuation))))
(defmethod set-context-for progn ((substrate rolebox-substrate))
(setf *cur-rbox*
(substrate-rbox substrate)))
;;;
;;;
;;;
(defmethod get-standard-node-description-class ((substrate rolebox-substrate))
'rolebox-node-description)
(defmethod get-standard-edge-description-class ((substrate rolebox-substrate))
'rolebox-edge-description)
(defmethod get-standard-edge-class ((substrate rolebox-substrate))
'rolebox-substrate-edge)
(defmethod get-standard-node-class ((substrate rolebox-substrate))
'rolebox-substrate-node)
;;;
;;;
;;:
(defmethod create-node ((substrate rolebox-substrate) (name symbol) (description node-description)
&rest args)
(apply #'make-node substrate
:name name
:description description
args))
(defmethod make-node ((substrate rolebox-substrate)
&rest initargs
&key copy-p
(create-reflexive-edges-p t)
(edge-constructor #'(lambda (node ref-role)
(create-edge substrate
node node
(make-edge-description
(get-standard-edge-description-class substrate)
ref-role)
:create-inverse-p nil
:error-p nil)))
&allow-other-keys)
(let ((node (apply #'call-next-method substrate initargs)))
(when node
(unless copy-p
(with-slots (rbox) substrate
(when (and rbox create-reflexive-edges-p)
(dolist (ref-role (reflexive-roles rbox))
(funcall edge-constructor node ref-role))))))
node))
;;;
;;;
;;;
(defmethod create-edge ((substrate rolebox-substrate)
(from substrate-node) (to substrate-node)
(description rolebox-edge-description)
&rest args)
(apply #'make-edge substrate from to
:description description
args))
(defmethod make-edge ((substrate rolebox-substrate) (from rolebox-substrate-node) (to rolebox-substrate-node)
&rest args
&key
description
(create-inverse-p t)
copy-p
&allow-other-keys)
(let ((edge (apply #'call-next-method substrate from to args)))
(when (and (not copy-p)
edge
create-inverse-p)
(with-slots (rbox) substrate
(when rbox
(let* ((inv-description
(make-inverse-description rbox description)))
(when inv-description
(let* ((iedge (apply #'make-edge substrate to from
:description inv-description
:create-inverse-p nil
args)))
(with-slots (inverse-edge) iedge
(setf inverse-edge edge))
(with-slots (inverse-edge) edge
(setf inverse-edge iedge))))))))
edge))
;;;
;;;
;;;
(defmethod compute-triangle-index ((object rolebox-substrate-edge))
(with-slots (triangles in-graph from to) object
(loop-over-nodes (between in-graph)
(let ((from-between
(get-edges-between in-graph from between))
(between-to
(get-edges-between in-graph between to)))
(when (and from-between between-to)
(loop as fb in from-between do
(loop as bt in between-to do
(push (list fb bt) triangles)
(push object (slot-value fb 'referenced-by))
(push object (slot-value bt 'referenced-by))))))))
object)
(defmethod compute-triangle-index ((substrate rolebox-substrate))
(loop-over-edges (edge substrate)
(compute-triangle-index edge))
substrate)
(defmethod get-support ((edge rolebox-substrate-edge) &key &allow-other-keys)
(or (triangles edge)
(progn
(compute-triangle-index edge)
(triangles edge))))
;;;
;;;
;;;
(defmethod delete-edge ((substrate rolebox-substrate) (edge rolebox-substrate-edge)
&key (delete-inverse-p t) (error-p t) &allow-other-keys)
(call-next-method)
(dolist (referencing-edge (referenced-by edge))
(with-slots (triangles) referencing-edge
(setf triangles nil)))
(with-slots (from to inverse-edge) edge
(when (and inverse-edge delete-inverse-p)
(let ((inv-edge inverse-edge))
(setf inverse-edge nil)
(with-slots (inverse-edge) inv-edge ; verhindert Endlos-Schleife!
(setf inverse-edge nil))
(delete-edge substrate inv-edge :error-p error-p)))))
;;;
;;;
;;;
(defmethod copy ((substrate rolebox-substrate) &rest args
&key
(rbox (substrate-rbox substrate))
&allow-other-keys)
(let ((copy (apply #'call-next-method substrate :rbox rbox args)))
(when copy
(dolist (old-edge (get-edges substrate))
(when (inverse-edge old-edge)
(let ((new-edge (find-edge copy (id old-edge)))
(new-inv-edge (find-edge copy (id (inverse-edge old-edge)))))
(with-slots (inverse-edge) new-edge
(setf inverse-edge new-inv-edge))))))
copy))
;;;
;;;
;;;
(defmethod make-inverse-description ((rbox rolebox) (description rolebox-edge-description))
(let ((inv-role (inv-role rbox (textual-description description))))
(when inv-role
(make-edge-description (constructor-sym description) inv-role))))
(defmethod lookup ((box rolebox) (r rolebox-edge-description) (s rolebox-edge-description))
(lookup box (textual-description r) (textual-description s)))
(defmethod lookup ((box rolebox) (r rolebox-substrate-edge) (s rolebox-substrate-edge))
(lookup box (description r) (description s)))
;;;
;;;
;;;
(defmethod apply-rolebox-axioms ((substrate rolebox-substrate) &key
(edges (get-edges substrate))
(nodes (get-nodes substrate))
(edge-constructor
#'(lambda (from to comp &key support)
(declare (ignore support))
(create-edge substrate
from to
(make-edge-description
(get-standard-edge-description-class substrate)
comp))))
&allow-other-keys)
(let ((iter t)
(dummy-description
(make-edge-description (get-standard-edge-description-class substrate) 'dummy)))
(with-marked-objects (nodes)
(loop while iter do
(setf iter nil)
(dolist (r edges)
(let* ((from (from r))
(over (to r))
(s (outgoing over)))
(when (and (marked-p from)
(marked-p over))
(dolist (s s)
(when (rolebox-substrate-edge-p s)
(let ((to (to s)))
(when (marked-p to)
(let* ((comp
(lookup (substrate-rbox substrate) r s))
(comp
(if (consp comp)
(if (cdr comp)
comp
(first comp))
comp)))
(unless (eq (to r) (from s))
(error "Bad triangle found!"))
(when comp
(change-textual-description dummy-description comp)
(let ((edge (=>-edge-present-p substrate from to dummy-description)))
(unless edge
(funcall edge-constructor from to comp :support (list r s))
(setf iter t))))))))))))))
substrate))
;;;
;;;
;;;
(defmethod consistent-p ((substrate rolebox-substrate) &key
(nodes (get-nodes substrate))
(edges (get-edges substrate))
(check-node-labels-p t)
(check-edge-labels-p t)
aux-description-p
check-loops-p
check-inverses-p)
(let ((dummy-description
(make-edge-description (get-standard-edge-description-class substrate) 'dummy)))
;;; T, iff reflexive, inverse, and role composition frame conditions are EXPLICITLY satisfied!
(and (=> check-node-labels-p (every #'consistent-p (get-nodes substrate)))
(=> check-edge-labels-p (every #'consistent-p (get-edges substrate)) )
(with-marked-objects (nodes)
(with-marked-objects (edges nil)
(and
(=> check-loops-p
(every #'(lambda (ref-role)
(change-textual-description dummy-description ref-role)
(every #'(lambda (node)
(=>-edge-present-p substrate node node dummy-description))
nodes))
(reflexive-roles (substrate-rbox substrate))))
(=> check-inverses-p
(every #'(lambda (edge)
(let ((inv-descr (inv-role (substrate-rbox substrate)
(textual-description (description edge)))))
(=> inv-descr
(progn
(change-textual-description dummy-description inv-descr)
(=>-edge-present-p substrate (to edge) (from edge) dummy-description)))))
edges))
(dolist (r edges t)
(let* ((from (from r))
(over (to r))
(s (outgoing over)))
(dolist (s s)
(when (and (rolebox-substrate-edge-p s)
(marked-p s))
(let ((to (to s)))
(when (marked-p to)
(let ((comp (if aux-description-p
(lookup (substrate-rbox substrate)
(aux-description r)
(aux-description s))
(lookup (substrate-rbox substrate)
(description r)
(description s)))))
(unless (eq (to r) (from s))
(error "Bad triangle found!"))
(when comp
(change-textual-description dummy-description comp)
(unless (=>-edge-present-p substrate from to dummy-description)
(return-from consistent-p nil))))))))))))))))
(defmethod aux-description-consistent-p ((substrate rolebox-substrate) processed-edges)
(declare (ignore processed-edges))
(consistent-p substrate :aux-description-p t))
;;;
;;;
;;;
(defmethod enumerate-atomic-configurations ((substrate rolebox-substrate)
&rest args
&key
(edge-setter
#'(lambda (edge sym &key respect-inverses-p &allow-other-keys)
(change-textual-description (description edge) sym)
(when (and (inverse-edge edge) respect-inverses-p)
(change-textual-description
(description (inverse-edge edge))
(inv-role (substrate-rbox substrate) sym)))))
(respect-inverses-p t)
(edges
(if *non-determinism-p*
(reorder (get-underspecified-edges
substrate
:exclude-inverses-p respect-inverses-p))
(get-underspecified-edges
substrate
:exclude-inverses-p respect-inverses-p)))
(manager-fn #'(lambda (sel-edge edges processed-edges
&key respect-inverses-p &allow-other-keys)
(values (let ((edges (remove sel-edge edges)))
(if (and respect-inverses-p
(inverse-edge sel-edge))
(remove (inverse-edge sel-edge) edges)
edges))
(if (and respect-inverses-p
(inverse-edge sel-edge))
(cons sel-edge
(cons (inverse-edge sel-edge)
processed-edges))
(cons sel-edge
processed-edges)))))
(final-check-fn #'(lambda (substrate &rest args)
(apply #'consistent-p substrate args)))
&allow-other-keys)
(apply #'call-next-method substrate
:edge-setter edge-setter
:respect-inverses-p respect-inverses-p
:edges edges
:manager-fn manager-fn
:final-check-fn final-check-fn
args))
;;;
;;;
;;;
#|
(with-rbox (test-box :delete-if-exists-p t
:roles (r s t)
:reflexive-roles (t)
:inverse-roles ((r s) (s r))
:axioms
((r r s)
(r s s)))
(with-substrate (hello :type 'rolebox-substrate :delete-if-exists-p t)
(node a (ncon a))
(node b (ncon a))
(node c (ncon c))
(node d (ncon d))
(edge a b (econ r))
(edge b c (econ r))
(edge c d (econ r))
(visualize (list *cur-substrate*
(apply-rolebox-axioms (copy *cur-substrate*))))))
(with-rbox (test-box :delete-if-exists-p t
:roles (r s)
;:reflexive-roles (r)
:inverse-roles ((r s) (s r)))
(with-substrate (hello :type 'rolebox-substrate :delete-if-exists-p t)
(node a (ncon a-descr))
(node b (ncon b-descr))
(edge a b (econ (r s)))
(visualize (cons (copy *cur-substrate*)
(get-all-atomic-configurations (apply-rolebox-axioms *cur-substrate*))))))
(with-rbox (test-box :delete-if-exists-p t
:roles (r s t)
:inverse-roles ((s r))
:reflexive-roles (t)
:axioms
((r r (s r t))))
(with-substrate (hello :type 'rolebox-substrate :delete-if-exists-p t)
(node a (ncon a-descr))
(node b (ncon b-descr))
(node c (ncon c-descr))
(edge a b (econ r))
(edge b c (econ r))
(apply-rolebox-axioms *cur-substrate*)
(terpri)
(princ (consistent-p *cur-substrate*))
(visualize
(let ((copy (copy *cur-substrate*)))
(cons copy
(get-all-atomic-configurations (apply-rolebox-axioms *cur-substrate*)))))))
(with-rbox (rcc5-rolebox)
(with-substrate (hello :type 'rolebox-substrate :delete-if-exists-p t)
(setf *x* *cur-substrate*)
(node a (ncon a-descr))
(node b (ncon b-descr))
(node c (ncon c-descr))
(node d (ncon d-descr))
(edge a b (econ ppi))
(edge b c (econ dr))
(edge c d (econ po))
(princ (consistent-p *cur-substrate*))
(apply-rolebox-axioms *cur-substrate*)
(princ (consistent-p *cur-substrate*))
(let ((all
(cons (copy *cur-substrate*)
(get-all-atomic-configurations *cur-substrate*))))
(princ (mapcar #'consistent-p all))
(visualize (remove-if-not #'consistent-p all)))))
(with-rbox (test-box :delete-if-exists-p t
:roles (r s t)
:inverse-roles ((s r))
:reflexive-roles (t)
:axioms
((r r (s r t))))
(with-substrate (hello :type 'rolebox-substrate :delete-if-exists-p t)
(node a (ncon a-descr))
(node b (ncon b-descr))
(node c (ncon c-descr))
(node d (ncon c-descr))
(setf ab (edge a b (econ r)))
(setf bc (edge b c (econ r)))
(princ (consistent-p *cur-substrate*)) (terpri)
(princ (consistent-p *cur-substrate* :edges (list ab)))
(apply-rolebox-axioms *cur-substrate*)
(dolist (edge (get-edges-between *cur-substrate* 'd 'd))
(delete-edge *cur-substrate* edge))
(terpri) (princ "Consistent: ")
(princ (consistent-p *cur-substrate* :check-loops-p t))
(visualize *cur-substrate*)))
(with-rbox (rcc5-rolebox)
(with-substrate (hello :type 'rolebox-substrate :delete-if-exists-p t)
(setf a (node a (ncon a-descr)))
(setf b (node b (ncon b-descr)))
(setf c (node c (ncon c-descr)))
(node d (ncon c-descr))
(setf ab (edge a b (econ po)))
(setf bc (edge b c (econ po)))
(edge c d (econ po))
(apply-rolebox-axioms *cur-substrate* :edges (list ab bc) :nodes (list a b c))
(visualize *cur-substrate*)))
(with-rbox (rcc5-rolebox)
(with-substrate (hello :type 'rolebox-substrate :delete-if-exists-p t)
(setf a (node a (ncon a-descr)))
(setf b (node b (ncon b-descr)))
(setf c (node c (ncon c-descr)))
(edge a b (econ pp))
(edge b c (econ pp))
(edge a c (econ dr))
(visualize *cur-substrate*)
(princ (consistent-p *cur-substrate*))))
(with-substrate (hello :type 'rolebox-substrate :delete-if-exists-p t
:rbox 'rcc5-rolebox)
(setf a (node a (ncon a-descr)))
(setf b (node b (ncon b-descr)))
(setf c (node c (ncon c-descr)))
(edge a b (econ pp))
(edge b c (econ pp))
(edge a c (econ pp))
(visualize *cur-substrate*)
(princ (consistent-p *cur-substrate*)))
|#
| 22,748 | Common Lisp | .lisp | 487 | 29.667351 | 118 | 0.493821 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 5d5cfe02ae80a1066ddafbcf84136efef22a62f45f240ff52b46d1fcc4f2679a | 12,514 | [
-1
] |
12,515 | spatial-substrate.lisp | lambdamikel_DLMAPS/src/thematic-substrate/unfinished/spatial-substrate.lisp | ;;; -*- Mode: Lisp; Syntax: Ansi-Common-Lisp; Package: THEMATIC-SUBSTRATE; Base: 10 -*-
(in-package :THEMATIC-SUBSTRATE)
;;;
;;;
;;;
(defpersistentclass spatial-substrate (rolebox-substrate)
((consistency-relevant-edges :reader consistency-relevant-edges :initform nil)))
(defmethod create-substrate ((class (eql 'spatial-substrate))
&key name tbox abox rbox (real-class 'spatial-substrate))
(create-substrate 'rolebox-substrate :name name :abox abox :tbox tbox :rbox rbox :real-class 'spatial-substrate))
;;;
;;;
;;;
(defmethod simplify ((substrate spatial-substrate))
substrate)
(defmethod add-eq-loops ((substrate spatial-substrate))
(dolist (node (network-nodes substrate))
(create-edge substrate node node 'eq)))
(defmethod complete ((substrate spatial-substrate))
(add-eq-loops substrate)
;;;(add-inverse-edges substrate)
(add-missing-edges substrate))
(defmethod enumerate-atomic-configurations ((substrate spatial-substrate)
&key
how-many
(edges (consistency-relevant-edges substrate))
(sym-gen #'(lambda (edge processed-edges)
(description edge)))
(selector-fn #'(lambda (rem-edges processed-edges)
(first rem-edges)))
(manager-fn #'(lambda (sel-edge edges processed-edges)
(values (remove sel-edge
(remove (inverse-edge sel-edge)
edges))
(cons sel-edge (cons (inverse-edge sel-edge)
processed-edges)))))
(fn #'materialize)
(final-check-fn #'(lambda (x) (consistent-p x :force-p t)))
(construction-check-fn #'(lambda (x) t)))
(apply #'call-next-method
substrate
:edges edges
:how-many how-many
:sym-gen sym-gen
:selector-fn selector-fn
:manager-fn manager-fn
:fn fn
:final-check-fn final-check-fn
:construction-check-fn construction-check-fn
nil))
;;;
;;;
;;;
(defpersistentclass spatial-object (rolebox-substrate-node)
nil)
(defmethod create-node ((substrate spatial-substrate) name description &rest args &key (real-class 'spatial-object))
(apply #'call-next-method substrate name description :real-class real-class args))
(defpersistentclass spatial-relation (rolebox-substrate-edge)
((consistency-relevant-a-triangles :reader consistency-relevant-a-triangles :initform nil)))
(defmethod create-edge ((substrate spatial-substrate) from to description &rest args &key (error-p t) (real-class 'spatial-relation))
(if (get-edges-between substrate from to)
(when error-p (error "Edge (~A,~A) already exists in substrate ~A!"
from to substrate))
(apply #'call-next-method substrate from to description :real-class real-class :error-p error-p args)))
;;;
;;; Spatial-Relation-Methoden
;;;
(defmethod initialize-instance :after ((object spatial-relation) &rest initargs)
(with-slots (consistency-relevant-edges) (in-substrate object)
(when (consistency-relevant-p object)
(push object consistency-relevant-edges))))
(defmethod consistency-relevant-p ((edge spatial-relation))
(not (eq (from edge) (to edge))))
(defmethod delete-edge :after ((substrate spatial-substrate) (edge spatial-relation) &key &allow-other-keys)
(with-slots (inverse-edge) edge
(with-slots (consistency-relevant-edges) substrate
(setf consistency-relevant-edges
(delete edge consistency-relevant-edges))
(dolist (referencing-edge (referenced-by edge))
(when (typep referencing-edge 'spatial-relation)
(with-slots (consistency-relevant-a-triangles) referencing-edge
(setf consistency-relevant-a-triangles
(delete-if #'(lambda (tri) (member edge tri))
consistency-relevant-a-triangles))))))))
(defmethod get-support ((edge spatial-relation))
(with-slots (consistency-relevant-a-triangles in-substrate) edge
(with-slots (consistency-relevant-edges) in-substrate
(or consistency-relevant-a-triangles
(setf consistency-relevant-a-triangles
(remove-if-not #'(lambda (tri)
(and (consistency-relevant-p (first tri))
(consistency-relevant-p (first tri))))
(a-triangles edge)))))))
(defun compute-label-from-given-support (edge support)
(let* ((rbox (substrate-rbox (in-substrate edge)))
(role (mapcar #'(lambda (supp)
(let* ((r (current-label (first supp)))
(s (current-label (second supp)))
(res (lookup rbox r s)))
res))
(loop as tri in (consistency-relevant-a-triangles edge)
when (and (member (first tri)
support)
(member (second tri)))
collect tri))))
(if role
(reduce #'intersection role)
(full-disjunctive-role rbox))))
| 5,986 | Common Lisp | .lisp | 108 | 37.851852 | 133 | 0.547615 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | a5be23e65a0274287297f4d133cfd137e3663b5f60a1e35b938594c39c8344c0 | 12,515 | [
-1
] |
12,516 | languages.lisp | lambdamikel_DLMAPS/src/prover/languages.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
(defpersistentclass dl ()
((name :accessor name :initarg :name)))
(defmethod initialize-instance :after ((lang dl) &rest initargs)
(push lang *all-dls*))
;;;
;;;
;;;
(defpersistentclass needs-basic-abox-substrate ())
(defpersistentclass needs-rolebox-abox-substrate (needs-basic-abox-substrate))
(defpersistentclass needs-jepd-abox-substrate (needs-rolebox-abox-substrate))
;;;
;;; Hier werden nur Kombinationen bzw. Spezialisierungen definiert, die
;;; sinnvolle Spezialisierungen bzgl. des Proover-Codes ermoeglichen
;;; Idee: für die hier drei definierten "Top"-Klassen werden Proover implementiert;
;;; falls die Performanz unzureichend ist, koennen die get-code-Methoden des
;;; Provers entsp. spezialisiert werden (= effizienter gemacht fuer speziellere Sprachen)
;;; z.B. Blocking-Check aus fuer ALC, etc. Wichtig ist jedoch, dass der Top-Proover
;;; prinzipiell die mächtigste Sprache (also z.B. SHI-WICODIR) behandeln kann!
;;; Nur so werden die Code-Spezialisierungen optional. Daher ist die Vererbungshierarchie
;;; in "diese Richtung" angelegt
;;;
(defpersistentclass dl-with-disjunctive-aboxes (dl))
;;;
;;;
;;;
(defpersistentclass dl-with-role-hierarchies (dl)) ;;; alles meine DLs haben role hierarchies
(defpersistentclass dl-with-domain-and-range-restrictions-on-roles (dl))
(defpersistentclass dl-with-disjunctive-roles (dl))
(defpersistentclass dl-with-conjunctive-roles (dl))
(defpersistentclass dl-with-inverse-roles (dl)) ; also symmetric roles
(defpersistentclass dl-with-transitive-roles (dl))
(defpersistentclass dl-with-disjoint-roles (dl))
(defpersistentclass dl-with-rolebox (dl))
(defpersistentclass dl-with-jepd-property (dl-with-rolebox dl-with-disjoint-roles dl-with-inverse-roles))
;;;
;;;
;;;
(defpersistentclass boolean-dl (dl))
;;;
;;;
;;;
(defpersistentclass dl-with-somes (dl))
(defpersistentclass dl-with-features (dl))
(defpersistentclass dl-with-alls (dl))
;;;
;;;
;;;
(defpersistentclass alch-basis (boolean-dl dl-with-somes dl-with-alls
dl-with-domain-and-range-restrictions-on-roles
dl-with-role-hierarchies))
;;;
;;;
;;;
(defpersistentclass dl-with-number-restrictions (dl))
(defpersistentclass dl-with-unqualified-number-restrictions (dl-with-number-restrictions))
(defpersistentclass dl-with-qualified-number-restrictions (dl-with-number-restrictions))
;;;
;;;
;;;
(defpersistentclass dl-with-combined-some-all-rule (dl))
(defpersistentclass dl-with-blocking (dl))
(defpersistentclass dl-with-simple-blocking (dl-with-blocking))
(defpersistentclass dl-with-equal-blocking (dl-with-simple-blocking))
(defpersistentclass dl-with-subset-blocking (dl-with-simple-blocking))
(defpersistentclass dl-with-pairwise-blocking (dl-with-blocking))
(defpersistentclass dl-with-model-merging (dl))
;;;
;;; hier werden nur die Beweiser spezialisiert,
;;; fuer die Implementationen existieren!
;;;
(defpersistentclass super-dl (alch-basis
dl-with-unqualified-number-restrictions
dl-with-disjunctive-aboxes
dl-with-inverse-roles
dl-with-transitive-roles
dl-with-features
dl-with-pairwise-blocking
needs-basic-abox-substrate))
;;;
;;; Basis DLs
;;;
(defpersistentclass alch (alch-basis
dl-with-model-merging
dl-with-combined-some-all-rule
needs-basic-abox-substrate))
(defpersistentclass alchi (alch-basis
dl-with-inverse-roles
needs-basic-abox-substrate))
;;;
;;; DLs ohne inverse Rollen
;;;
(defpersistentclass alchf (alch
dl-with-features))
(defpersistentclass alchf-rplus (alchf
dl-with-transitive-roles
dl-with-subset-blocking))
(defpersistentclass alchn (alch
dl-with-unqualified-number-restrictions))
(defpersistentclass alchfn-rplus (alchf-rplus alchn))
;;;
;;; DLs mit inversen Rollen
;;;
(defpersistentclass alchi-rplus (alchi
dl-with-transitive-roles
dl-with-equal-blocking))
(defpersistentclass alchif (alchi
dl-with-features))
(defpersistentclass alchif-rplus (dl-with-pairwise-blocking
alchi-rplus alchif
))
(defpersistentclass alchifn-rplus (alchif-rplus
dl-with-unqualified-number-restrictions))
;;;
;;; Rolebox/JEPD Substrate DLs
;;;
(defpersistentclass alci-ra-minus (alch-basis
dl-with-disjunctive-aboxes
dl-with-rolebox
needs-rolebox-abox-substrate))
(defpersistentclass alci-ra-jepd (alci-ra-minus
dl-with-jepd-property
needs-jepd-abox-substrate))
(defpersistentclass alci-rcc (alci-ra-jepd))
;;;
;;;
;;;
(eval
`(progn
,@(mapcar #'(lambda (dl)
`(defconstant ,(intern (format nil "+~A+" dl))
(make-instance (quote ,dl)
:name (symbol-name ',dl))))
'(dl
super-dl
alch alchf alchn
alchf-rplus alchfn-rplus
alchi alchif
alchi-rplus alchif-rplus alchifn-rplus
;alchif-rplus
alci-ra-minus alci-ra-jepd alci-rcc))))
;;;
;;;
;;;
(defmethod make-language ((type symbol))
(or (loop as dl in *all-dls*
when (eq (type-of dl) type)
return dl)
(make-instance type)))
(defmethod make-language ((type dl))
type)
| 6,351 | Common Lisp | .lisp | 152 | 30.756579 | 105 | 0.628903 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 29fa33a137297ae1cf5e9c6928bfe5120c5701283048005e622c6638b699b87f | 12,516 | [
-1
] |
12,517 | core-models.lisp | lambdamikel_DLMAPS/src/prover/core-models.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(timed-defmethod delete-non-det-assertions ((abox abox))
(with-abox* (abox)
(let ((*reflexive-checks-p* nil)) ; wegen Error checking in delete-node etc.
(labels ((det-p (cp)
(and (not (cdr cp))
(or (not (first cp))
(zerop (first cp)))))
(deterministic-p (node-or-edge)
(every #'(lambda (constraint)
(if (consp constraint)
(let* ((node (first constraint))
(concept (second constraint))
(cp (get-choice-points concept :node node)))
(det-p cp))
(det-p (get-choice-points constraint))))
(created-by node-or-edge)))
(relevant-p (node)
(=> *store-instance-retrieval-model-p*
(or (= (id node) 1)
;;; nachfolger vom root node?
(some #'(lambda (in)
(= (id (from in)) 1))
(incoming node))))))
(loop-over-abox-nodes (node abox)
(if (or (and (not (old-p node))
(not (deterministic-p node)))
(not (relevant-p node)))
(delete-node abox node)
(progn
(dolist (slot '(choice-points
really-satisfiable-p
cache-satisfiable-p
;deterministically-expanded-p
realized-p))
(setf (slot-value node slot) nil))
(reset-label (description node)))))
(loop-over-abox-edges (edge abox)
(reset-label (description edge))
(when (and (not (old-p edge))
(not (deterministic-p edge)))
(delete-edge abox edge)))
(let ((history (get-history abox)))
(dolist (action history)
(when (action-det-action-p action)
(let* ((post (slot-value action 'post)))
(dolist (post post)
(let ((concept (second post))
(node (first post)))
(when (relevant-p node)
(pushnew concept (slot-value node 'told-concepts))
(if (or (is-all-concept-p concept)
(is-at-most-concept-p concept))
(add-to-unexpanded node concept)
(add-to-expanded node concept)))))))))
(with-slots (action-timestamp-counter current-action choice-point-counter) abox
(setf action-timestamp-counter 0
current-action nil
choice-point-counter 0))
abox))))
(timed-defmethod compute-core-model ((abox abox))
(with-abox (abox)
(loop-over-abox-nodes (node abox)
(when (or (and (old-p node)
;;; fuers instance retrieval model brauch ich nur den root node!
(not *store-instance-retrieval-model-p* ))
(= (id node) 1))
(setf (slot-value node 'core-model)
(make-model-from-node node))))
abox))
| 3,629 | Common Lisp | .lisp | 74 | 28.513514 | 87 | 0.444444 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | fdfe5d3fd26cf25de04856ee3306e43ac880a28484c7a565c4afaff422ff784a | 12,517 | [
-1
] |
12,518 | blocking2.lisp | lambdamikel_DLMAPS/src/prover/blocking2.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(defmacro hist-incoming (node)
`(let* ((id (id ,node))
(created-before
(remove-if-not #'(lambda (in)
(< (id (from in))
id))
(incoming ,node))))
(if (some #'old-p created-before)
nil
(first created-before))))
(defmethod blocking-blocked-p ((language dl-with-subset-blocking) (blocking abox-node) (blocked abox-node))
;;; Subset Blocking f. ALCHF-RPLUS
(loop-over-node-concepts (concept blocked)
(unless (on-tableau-p blocking concept)
(return-from blocking-blocked-p nil)))
t)
(defmethod blocking-blocked-p ((language alchi-rplus) (blocking abox-node) (blocked abox-node))
;;; Equal Blocking f. ALCHI-RPLUS
(loop-over-node-concepts (concept blocked)
(unless (on-tableau-p blocking concept)
(return-from blocking-blocked-p nil)))
(loop-over-node-concepts (concept blocking)
(unless (on-tableau-p blocked concept)
(return-from blocking-blocked-p nil)))
t)
(defmethod blocking-blocked-p ((language alchif-rplus) (blocking abox-node) (blocked abox-node))
; wird doppelt aufgerufen, pairwise blocking
(call-next-method))
(defmethod blocking-blocked-p ((language dl) (blocking abox-node) (blocked abox-node))
nil)
;;;
;;;
;;;
(defmethod blocking-or-blocking-predecessor ((abox abox) (blocking node))
(or (slot-value blocking 'blocking-for)
(let ((incoming (hist-incoming blocking)))
(and incoming
(blocking-or-blocking-predecessor abox (from incoming))))))
(defmacro loop-between-blocked-blocking ((var blocked blocking) &body body)
`(let ((,var ,blocked)
(in nil))
(loop
,@body
(when (eq ,var ,blocking)
(return))
(setf in (hist-incoming ,var))
(unless in (error "Node ~A is not a predecessor of ~A!" ,blocking ,blocked))
(setf ,var (from in)))))
;;;
;;;
;;;
(defmethod find-blocking-node ((abox abox) (blocked node))
(when (and (active-p blocked)
(not (old-p blocked))
(not (blocked-p blocked)))
(let ((incoming
(hist-incoming blocked))
(path (list blocked))
(blocking-node nil))
(loop while incoming do
(let ((blocking (from incoming)))
(push blocking path)
(setf incoming (hist-incoming blocking))
(when (blocking-blocked-p *language* blocking blocked)
(announce "Found blocked node ~A: blocked by: ~A" blocked blocking)
(register-blocking-blocked abox blocking blocked) ; deaktiviert den Knoten auch
(setf blocking-node blocking
incoming nil))))
blocking-node)))
(defrule block-nodes (dl-with-simple-blocking abox :args (blocked))
(when *blocking-enabled-p*
(if blocked
(find-blocking-node abox blocked)
(loop-over-leaf-nodes (blocked abox)
(find-blocking-node abox blocked))))
+insert-body-code+)
(defrule block-nodes (dl-with-pairwise-blocking abox :args (blocked))
(labels ((do-it (blocked)
(when (and (active-p blocked)
(not (old-p blocked))
(not (blocked-p blocked)))
(let* ((x blocked)
(incoming
(hist-incoming x)))
(when (and incoming
(not (deleted-p incoming)))
(let* ((role (role incoming))
(x1 (from incoming))
(incoming (hist-incoming x1))
(path (list x1 x)))
(when (and x x1 incoming
(not (deleted-p incoming)))
(loop while incoming do
(let* ((y (from incoming))
(blocking y))
(setf incoming
(hist-incoming y))
(push y path)
(when (and incoming
(not (deleted-p incoming)))
(let ((y1 (from incoming)))
(push y1 path)
(if (and (eq (role incoming) role)
(blocking-blocked-p *language* x y)
(blocking-blocked-p *language* x1 y1))
(progn
(announce "Found pairwise blocked node ~A: blocked by: ~A"
blocked blocking)
(register-blocking-blocked abox blocking blocked)
(setf incoming nil))
(setf incoming
(hist-incoming y1))))))))))))))
(when *blocking-enabled-p*
(if blocked
(do-it blocked)
(loop-over-leaf-nodes (blocked abox)
(do-it blocked)))))
+insert-body-code+)
| 5,821 | Common Lisp | .lisp | 123 | 28.788618 | 107 | 0.506182 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 1f949354f13dd70ed99d56766bc687f41d714b9068a17132e95e6acfaec9f661 | 12,518 | [
-1
] |
12,519 | process-test.lisp | lambdamikel_DLMAPS/src/prover/process-test.lisp |
(defvar *count* 0)
(defun test ()
(let ((*count* 0))
(mp:process-run-function "TEST"
nil
#'(lambda ()
(let ((*count* 'test))
(princ *count*)
(terpri)
(let ((*count* 'test2))
(test2))
(princ *count*)
(princ 'done)
(terpri)
(princ *count*) (terpri))))
*count*))
(defun test2 ()
(princ *count*)
(terpri)
(let ((*count* 'test3))
(test3))
(princ *count*)
(terpri))
(defun test3 ()
(princ *count*)
(terpri)
(setf *count* 0)
(loop as i from 1 to 100 do (incf *count*))
(princ *count*))
| 929 | Common Lisp | .lisp | 29 | 15.517241 | 62 | 0.335656 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 220a6a5e7360fba81ed3ea61c806411f8aef461ab5675f63254326f6a845ffe9 | 12,519 | [
-1
] |
12,520 | alchif-prover.lisp | lambdamikel_DLMAPS/src/prover/alchif-prover.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(define-prover ((abox-sat alchif abox))
(:main
(perform (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)
(restart-main)))
(:negative
(perform (some-expansion)
(:positive
(if clashes
(handle-clashes)
(restart-main)))
(:negative
(success))))))))))))
| 854 | Common Lisp | .lisp | 30 | 16.2 | 60 | 0.4324 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 6f7b6f2c5715e8046aaa6bd00b9458c183fb8c7e819532c5b854b5d2746dc7a4 | 12,520 | [
-1
] |
12,521 | abox9.lisp | lambdamikel_DLMAPS/src/prover/abox9.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(defpersistentclass abox (substrate)
((tbox :reader tbox :initarg :tbox :initform *cur-tbox*)
(abox-version :accessor abox-version :initform 0)
(prepared-p :reader prepared-p :initform nil)
(satisfiable :reader satisfiable :initform :not-tested)
;;;
;;;
;;;
(language :accessor language :initform nil :initarg :language)
(ready-for-retrieval :initform nil)
#+:use-membership-tables
(unexpanded-table :accessor unexpanded-table
:initform (when *create-membership-tables-p*
(make-weak-hash-table :size 10000 :rehash-size 10000 :test #'equalp)))
#+:use-membership-tables
(expanded-table :accessor expanded-table
:initform (when *create-membership-tables-p*
(make-weak-hash-table :size 10000 :rehash-size 10000 :test #'equalp)))
(action-timestamp-counter :accessor action-timestamp-counter :initform 0)
(current-action :accessor current-action :initform nil)
(choice-point-counter :accessor choice-point-counter :initform 0)
(cur-clash-node :accessor cur-clash-node :initform nil)))
(defmethod reset-abox ((abox abox))
(with-slots (node-table
edge-table
tbox
abox-version
prepared-p
satisfiable
language
ready-for-retrieval
unexpanded-table
expanded-table
action-timestamp-counter
current-action
choice-point-counter
cur-clash-node) abox
(setf satisfiable :not-tested
ready-for-retrieval nil
action-timestamp-counter 0
current-action nil
choice-point-counter 0
cur-clash-node nil)
(when node-table
(clrhash node-table))
(when edge-table
(clrhash edge-table))
abox))
(defparameter *use-avl-trees-for-abox1-p* nil)
(defpersistentclass abox1 (abox)
((node-table :initform nil)
(edge-table :initform nil)
(all-nodes :reader all-nodes :initform nil)
(all-edges :reader all-edges :initform nil)
;;;
;;; plus optionale (!) spezialisierte Listen / Indexstrukture
;;; ACHTUNG! DIESE MUESSEN VERWALTET WERDEN, INSBESONDERE AUCH
;;; BEIM ROLLBACK!!! AUFWENDIG!
;;; S. SET-STATE-VECTOR!
;;;
(old-nodes :initform nil)
(cache-sat-nodes :initform nil)
(deactivated-nodes :initform nil)
(leaf-nodes :initform nil)
(blocked-nodes :initform nil)
(active-nodes :initform nil)
#|
;; ; f. determ. expansion
(nodes-with-alls-nodes :initform nil) ; AVL
(nodes-not-det-expanded :initform nil) ;
|#
;;;
;;; plus optionale Heaps
;;;
;;; diese sind fuer get-oldes-node-.... -> abox-saturation
(nodes-not-or-expanded1 :initform nil)
(nodes-not-some-expanded1 :initform nil)
(nodes-not-feature-expanded1 :initform nil)
(nodes-not-at-least-expanded1 :initform nil)
;;;
;;;
;;;
;;; diese sind fuer trace strategy -> left-of-p !
(nodes-not-and-expanded :initform nil)
(nodes-not-atom-expanded :initform nil)
(nodes-not-or-expanded :initform nil)
(nodes-not-some-expanded :initform nil)
(nodes-not-feature-expanded :initform nil)
(nodes-not-at-least-expanded :initform nil)))
(defmethod reset-abox ((abox abox1))
(with-slots (all-nodes
all-edges
old-nodes
cache-sat-nodes
deactivated-nodes
leaf-nodes
blocked-nodes
active-nodes
nodes-not-and-expanded
nodes-not-atom-expanded
nodes-not-or-expanded
nodes-not-some-expanded
nodes-not-feature-expanded
nodes-not-at-least-expanded) abox
(setf all-nodes nil
all-edges nil
old-nodes nil
cache-sat-nodes nil
deactivated-nodes nil
leaf-nodes nil
blocked-nodes nil)
(dolist (slot '(active-nodes
nodes-not-and-expanded
nodes-not-atom-expanded
nodes-not-or-expanded
nodes-not-some-expanded
nodes-not-feature-expanded
nodes-not-at-least-expanded
nodes-not-or-expanded1
nodes-not-some-expanded1
nodes-not-feature-expanded1
nodes-not-at-least-expanded1))
(heap-clear (slot-value abox slot))))
(call-next-method))
;;;
;;;
;;;
(defmethod initialize-instance :after ((abox abox) &rest initargs)
(push abox *all-aboxes*)
(when (tbox abox)
(pushnew abox (used-by-aboxes (tbox abox)))))
;;;
;;;
;;;
(defpersistentclass abox-item (substrate-object)
((old-p :initarg :old-p :initform nil)
(active-p :reader active-p :initarg :active-p :initform nil)
(deleted-p :reader deleted-p :initform nil)
(choice-points :initform nil :initarg :choice-points) ; initargs für Copy-Funktionen!
(precondition-for-actions :initform nil :initarg :precondition-for-actions)
(postcondition-for-actions :initform nil :initarg :postcondition-for-actions)
(created-by :reader created-by
:initform nil
:initarg :created-by)))
(defmethod old-p ((item abox-item))
(slot-value item 'old-p))
;;;
;;;
;;;
(defun get-standard-abox-class ()
'abox1)
(defmethod get-standard-node-class ((abox abox))
'abox-node)
(defmethod get-standard-edge-class ((abox abox))
'abox-edge)
;;;
;;;
;;;
(defmethod get-standard-node-description-class ((abox abox))
'node-label)
(defmethod get-standard-edge-description-class ((abox abox))
'edge-label)
;;;
;;;
;;;
(defmethod unparse ((item symbol))
item)
;;;
;;;
;;;
(defmacro representative (node)
`(first (cluster-nodes ,node)))
(defmacro representative-p (node)
`(eq ,node (representative ,node)))
;;;
;;; Iteratoren und mengenbasierte Schnittstelle!
;;;
(defmacro loop-over-abox-nodes ((var abox &rest args) &body body)
`(abox-nodes-iterator ,abox
#'(lambda (,var)
,@body)
,@args))
(defmacro loop-over-abox-edges ((var abox &rest args) &body body)
`(abox-edges-iterator ,abox
#'(lambda (,var)
,@body)
,@args))
(defmacro loop-over-active-nodes ((var abox &rest args) &body body)
`(abox-active-nodes-iterator ,abox
#'(lambda (,var)
,@body)
,@args))
(defmacro loop-over-leaf-nodes ((var abox &rest args) &body body)
`(abox-leaf-nodes-iterator ,abox
#'(lambda (,var)
,@body)
,@args))
(defmacro loop-over-old-nodes ((var abox &rest args) &body body)
`(abox-old-nodes-iterator ,abox
#'(lambda (,var)
,@body)
,@args))
(defmacro loop-over-blocked-nodes ((var abox &rest args) &body body)
`(abox-blocked-nodes-iterator ,abox
#'(lambda (,var)
,@body)
,@args))
(defmacro loop-over-deactivated-nodes ((var abox &rest args) &body body)
`(abox-deactivated-nodes-iterator ,abox
#'(lambda (,var)
,@body)
,@args))
(defmacro loop-over-cache-sat-nodes ((var abox &rest args) &body body)
`(abox-cache-sat-nodes-iterator ,abox
#'(lambda (,var)
,@body)
,@args))
;;;
;;;
;;;
(timed-defmethod abox-nodes-iterator ((abox abox) fn &optional (consider-cluster-p t))
(maphash #'(lambda (key node)
(when (and (integerp key)
(not (deleted-p node))
(=> consider-cluster-p
(representative-p node)))
(funcall fn node)))
(node-table abox)))
(timed-defmethod abox-nodes-iterator ((abox abox1) fn &optional (consider-cluster-p t))
(if (not *use-avl-trees-for-abox1-p*)
(dolist (node (all-nodes abox))
(when (and (not (deleted-p node))
(=> consider-cluster-p
(representative-p node)))
(funcall fn node)))
(loop-over-avl-tree (node (all-nodes abox))
(when (and (not (deleted-p node))
(=> consider-cluster-p
(representative-p node)))
(funcall fn node)))))
;;;
;;;
;;:
(timed-defmethod abox-active-nodes-iterator ((abox abox) fn &optional (consider-cluster-p t))
(abox-nodes-iterator abox #'(lambda (node)
(when (active-p node)
(funcall fn node)))
consider-cluster-p))
(timed-defmethod abox-active-nodes-iterator ((abox abox1) fn &optional (consider-cluster-p t))
(if *maintain-active-nodes-p*
(loop-over-heap-items (node (slot-value abox 'active-nodes))
(when (=> consider-cluster-p
(representative-p node))
(funcall fn node)))
(call-next-method)))
;;;
;;;
;;;
(timed-defmethod abox-old-nodes-iterator ((abox abox) fn &optional (consider-cluster-p t))
(abox-nodes-iterator abox #'(lambda (node)
(when (old-p node)
(funcall fn node)))
consider-cluster-p))
(timed-defmethod abox-old-nodes-iterator ((abox abox1) fn &optional (consider-cluster-p t))
(if *maintain-old-nodes-p*
(dolist (node (slot-value abox 'old-nodes))
(when (=> consider-cluster-p
(representative-p node))
(funcall fn node)))
(call-next-method)))
;;;
;;;
;;;
(timed-defmethod abox-blocked-nodes-iterator ((abox abox) fn &optional (consider-cluster-p t))
(abox-nodes-iterator abox #'(lambda (node)
(when (blocked-p node)
(funcall fn node)))
consider-cluster-p))
(timed-defmethod abox-blocked-nodes-iterator ((abox abox1) fn &optional (consider-cluster-p t))
(if *maintain-blocked-nodes-p*
(dolist (node (slot-value abox 'blocked-nodes))
(when (=> consider-cluster-p
(representative-p node))
(funcall fn node)))
(call-next-method)))
;;;
;;;
;;;
(timed-defmethod abox-leaf-nodes-iterator ((abox abox) fn &optional (consider-cluster-p t))
(abox-active-nodes-iterator abox #'(lambda (node)
(when (every #'(lambda (out)
(not (active-p (to out))))
(outgoing node))
(funcall fn node)))
consider-cluster-p))
(timed-defmethod abox-leaf-nodes-iterator ((abox abox1) fn &optional (consider-cluster-p t))
(if *maintain-leaf-nodes-p*
(dolist (node (slot-value abox 'leaf-nodes))
(when (=> consider-cluster-p
(representative-p node))
(funcall fn node)))
(call-next-method)))
;;;
;;;
;;;
(timed-defmethod abox-deactivated-nodes-iterator ((abox abox) fn &optional (consider-cluster-p t))
(abox-nodes-iterator abox #'(lambda (node)
(unless (active-p node)
(funcall fn node)))
consider-cluster-p))
(timed-defmethod abox-deactivated-nodes-iterator ((abox abox1) fn &optional (consider-cluster-p t))
(if *maintain-deactivated-nodes-p*
(dolist (node (slot-value abox 'deactivated-nodes))
(when (=> consider-cluster-p
(representative-p node))
(funcall fn node)))
(call-next-method)))
;;;
;;;
;;;
(timed-defmethod abox-cache-sat-nodes-iterator ((abox abox) fn &optional (consider-cluster-p t))
(abox-nodes-iterator abox #'(lambda (node)
(when (cache-satisfiable-p node)
(funcall fn node)))
consider-cluster-p))
(timed-defmethod abox-cache-sat-nodes-iterator ((abox abox1) fn &optional (consider-cluster-p t))
(if *maintain-cache-sat-nodes-p*
(dolist (node (slot-value abox 'cache-sat-nodes))
(when (=> consider-cluster-p
(representative-p node))
(funcall fn node)))
(call-next-method)))
;;;
;;;
;;;
(timed-defmethod get-nodes ((abox abox) &rest args)
(declare (ignorable args))
(let ((nodes nil))
(loop-over-abox-nodes (node abox)
(push node nodes))
nodes))
(timed-defmethod get-edges ((abox abox) &rest args &key (satisfying #'yes))
(declare (ignorable args))
(let ((edges nil))
(loop-over-abox-edges (edge abox :satisfying satisfying)
(push edge edges))
edges))
(timed-defmethod get-active-nodes ((abox abox) &rest args)
(declare (ignorable args))
(let ((nodes nil))
(loop-over-active-nodes (node abox)
(push node nodes))
nodes))
(timed-defmethod get-old-nodes ((abox abox) &rest args)
(declare (ignorable args))
(let ((nodes nil))
(loop-over-old-nodes (node abox)
(push node nodes))
nodes))
(timed-defmethod get-blocked-nodes ((abox abox) &rest args)
(let ((nodes nil))
(loop-over-blocked-nodes (node abox)
(push node nodes))
nodes))
(timed-defmethod get-leaf-nodes ((abox abox) &rest args)
(let ((nodes nil))
(loop-over-leaf-nodes (node abox)
(push node nodes))
nodes))
(timed-defmethod get-deactivated-nodes ((abox abox) &rest args)
(let ((nodes nil))
(loop-over-deactivated-nodes (node abox)
(push node nodes))
nodes))
(timed-defmethod get-cache-sat-nodes ((abox abox) &rest args)
(let ((nodes nil))
(loop-over-cache-sat-nodes (node abox)
(push node nodes))
nodes))
;;;
;;;
(defmethod no-of-nodes ((abox abox) &rest args)
(length (get-nodes abox)))
(defmethod no-of-active-nodes ((abox abox) &rest args)
(length (get-active-nodes abox)))
(defmethod no-of-edges ((abox abox) &rest args)
(length (get-edges abox)))
;;;
;;;
;;;
(timed-defun get-youngest-node-satisfying (abox fn)
(let ((found nil))
(loop-over-active-nodes (node abox)
(when (and (or (not found)
(> (id node) (id found)))
(funcall fn node))
(setf found node)))
found))
(timed-defun get-youngest-node-satisfying1 (abox fn)
(let ((found nil))
(loop-over-active-nodes (node abox nil)
(when (and (or (not found)
(> (id node) (id found)))
(funcall fn node))
(setf found node)))
found))
(timed-defun get-oldest-node-satisfying (abox fn)
(let ((found nil))
(loop-over-active-nodes (node abox)
(when (and (or (not found)
(< (id node) (id found)))
(funcall fn node))
(setf found node)))
found))
(timed-defun get-oldest-node-satisfying1 (abox fn)
(let ((found nil))
(loop-over-active-nodes (node abox nil)
(when (and (or (not found)
(< (id node) (id found)))
(funcall fn node))
(setf found node)))
found))
(timed-defun get-oldest-old-then-youngest-satisfying (abox fn)
(or
(get-oldest-node-satisfying1 abox #'(lambda (x) (and (old-p x) (funcall fn x))))
(get-youngest-node-satisfying1 abox fn)))
;;;
;;;
;;;
(timed-defmethod get-oldest-node-with-unexpanded-or-concepts ((abox abox))
(get-oldest-node-satisfying abox #'has-unexpanded-or-concepts-p))
(timed-defmethod get-oldest-node-with-unexpanded-or-concepts ((abox abox1))
(if *maintain-unexpanded-or-concepts1-heap-p*
(heap-peek (slot-value abox 'nodes-not-or-expanded1))
(call-next-method)))
;;;
;;;
;;;
(timed-defmethod get-oldest-node-with-unexpanded-some-concepts ((abox abox))
(get-oldest-node-satisfying abox #'has-unexpanded-some-concepts-p))
(timed-defmethod get-oldest-node-with-unexpanded-some-concepts ((abox abox1))
(if *maintain-unexpanded-some-concepts1-heap-p*
(heap-peek (slot-value abox 'nodes-not-some-expanded1))
(call-next-method)))
;;;
;;;
;;;
(timed-defmethod get-oldest-node-with-unexpanded-attribute-exists-concepts ((abox abox))
(get-oldest-node-satisfying abox #'has-unexpanded-attribute-exists-concepts-p))
(timed-defmethod get-oldest-node-with-unexpanded-attribute-exists-concepts ((abox abox1))
(if *maintain-unexpanded-attribute-exists-concepts1-heap-p*
(heap-peek (slot-value abox 'nodes-not-feature-expanded1))
(call-next-method)))
;;;
;;;
;;;
(timed-defmethod get-oldest-node-with-unexpanded-at-least-concepts ((abox abox))
(get-oldest-node-satisfying abox #'has-unexpanded-at-least-concepts-p))
(timed-defmethod get-oldest-node-with-unexpanded-at-least-concepts ((abox abox1))
(if *maintain-unexpanded-at-least-concepts1-heap-p*
(heap-peek (slot-value abox 'nodes-not-at-least-expanded1))
(call-next-method)))
;;;
;;;
;;;
(timed-defmethod abox-edges-iterator ((abox abox) fn &key (satisfying #'yes))
(maphash #'(lambda (key edge)
(declare (ignorable edge))
(when (and (integerp key)
(not (deleted-p edge))
(funcall satisfying edge))
(funcall fn edge)))
(edge-table abox)))
(timed-defmethod abox-edges-iterator ((abox abox1) fn &key (satisfying #'yes))
(if (not *use-avl-trees-for-abox1-p*)
(dolist (edge (all-edges abox))
(when (and (not (deleted-p edge))
(funcall satisfying edge))
(funcall fn edge)))
(loop-over-avl-tree (edge (all-edges abox))
(when (and (not (deleted-p edge))
(funcall satisfying edge))
(funcall fn edge)))))
;;;
;;;
;;;
(defmethod establish-context-for ((abox abox) continuation)
(with-slots (tbox) abox
(let ((*cur-abox* abox)
#+:use-membership-tables
(*unexpanded-table* (unexpanded-table abox))
#+:use-membership-tables
(*expanded-table* (expanded-table abox)))
(setf tbox (find-tbox (or tbox *cur-tbox*) :error-p t))
(with-tbox* ( (tbox abox) )
(if (next-method-p)
(call-next-method)
(funcall continuation))))))
(defmethod set-context-for progn ((abox abox))
(with-slots (tbox) abox
(setf *cur-abox* abox)
#+:use-membership-tables
(setf *unexpanded-table* (unexpanded-table abox))
#+:use-membership-tables
(setf *expanded-table* (expanded-table abox))
(setf tbox (find-tbox (or tbox *cur-tbox*) :error-p t))
(in-tbox* (tbox abox))))
;;;
;;;
;;;
(defun current-abox ()
*cur-abox*)
(defun delete-abox (name &rest args)
(apply #'delete-substrate name args))
(defmethod delete-graph :after ((abox abox) &rest args)
;;; wird von delete-substrate aufgerufen
(setf *all-aboxes* (delete abox *all-aboxes*))
(setf *cur-abox* nil)
(when (tbox abox)
(setf (used-by-aboxes (tbox abox))
(delete abox (used-by-aboxes (tbox abox))))))
(defun find-abox (name &rest args)
(apply #'find-substrate name args))
(defun delete-all-aboxes ()
(delete-all-substrates :satisfying #'is-abox-p)
(in-abox default-abox))
(defun all-aboxes ()
(get-all-substrates :satisfying #'is-abox-p))
(defun associated-tbox (abox)
(tbox-name (tbox (find-abox abox :error-p t))))
(defun clone-abox (abox)
(copy-graph (find-abox abox :error-p t)))
;;;
;;;
;;;
(defmethod reset-sat-status ((abox abox))
(incf (abox-version abox))
(reset-cached-sat-result abox)
(setf (slot-value abox 'prepared-p) nil)
abox)
(defmethod reset-cached-sat-result ((abox abox))
(setf (slot-value abox 'satisfiable) :not-tested))
(defmethod reset-sat-status :after ((item abox-item))
(dolist (slot '(active-p
deleted-p
choice-points
precondition-for-actions
postcondition-for-actions))
(setf (slot-value item slot) nil)))
;;;
;;;
;;;
(defmethod get-language ((abox abox) &optional recompute-p)
(declare (ignorable recompute-p))
;;; durch das Parsen sind die Node-Assertions
;;; im concept-store gelandet!
(prepare abox +dl+)
(slot-value abox 'language))
(defmethod note-abox-has-changed ((abox abox))
(reset-sat-status abox))
(defmethod abox-realized-p ((abox abox))
(loop-over-abox-nodes (node abox)
(unless (realized-p node)
(return-from abox-realized-p nil)))
t)
;;;
;;;
;;;
#|
(defmethod copy ((abox abox) &rest args)
(let ((copy (apply #'call-next-method abox
:name (name abox)
;;; prevent building "Copy of copy of copy of..." names!
args)))
(with-slots (satisfiable language ready-for-retrieval tbox) abox
(setf (slot-value copy 'satisfiable) satisfiable
(slot-value copy 'language) language
(slot-value copy 'ready-for-retrieval) ready-for-retrieval
(slot-value copy 'tbox) tbox))
(loop-over-abox-nodes (node copy)
(setf (slot-value node 'cluster-nodes)
(mapcar #'(lambda (x)
(find-node copy (id x) :error-p t))
(cluster-nodes node))))
copy))
|#
| 22,294 | Common Lisp | .lisp | 591 | 28.360406 | 103 | 0.584034 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 38f2531ca072025fd4072e767181c31db4918f64711b63907337c0b5a1dcfe48 | 12,521 | [
-1
] |
12,522 | tester.lisp | lambdamikel_DLMAPS/src/prover/tester.lisp | ;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
(defun load-both (&optional (fn "test.kb") &key save-load-p (verify-p t) debug-p log-p)
(declare (ignorable debug-p log-p))
(reset-statistics)
(racer:delete-all-tboxes)
(delete-all-tboxes)
;(enable-racer-validation)
;(disable-racer-validation)
(in-tbox foobar :delete-if-exists-p t)
(let ((*package* (find-package :prover)))
(format t "Loading ~A into DLMAPS...~%" fn)
(load (format nil "dlmaps:prover;~A" fn)))
;(setf (language *cur-tbox*) (make-language 'alchf-rplus))
(when save-load-p
(format t "Saving ~A!~%" "dlmaps:prover;test.tbox")
(save-tbox *cur-tbox* "dlmaps:prover;test.tbox"))
(in-tbox foobar)
(when verify-p
(let ((*package* :racer-user))
(racer:in-tbox racer-user::foobar)
(format t "Loading ~A into RACER...~%" fn)
(if (not save-load-p)
(load (format nil "dlmaps:prover;~A" fn))
(load "dlmaps:prover;test.tbox")))
(racer::set-current-tbox 'racer-user::foobar)
(compare-taxonomies)
;(classify-cur-tbox debug-p log-p)
))
(defvar *stream*)
(defun enable-racer-validation ()
(setf *racer-validation-p* t
*logging-p* nil
*racer-tbox* 'racer-user::foobar))
(defun enable-logging ()
(setf *logging-p* t))
(defun disable-logging ()
(setf *logging-p* nil))
(defun disable-racer-validation ()
(setf *racer-validation-p* nil))
(defun classify-cur-tbox (&optional (debug-p *debug-p*) (logfile-p *logging-p*))
(reset-sat-status *cur-tbox*)
(let ((*debug-p* debug-p))
(racer:classify-tbox 'racer-user::foobar)
(with-open-file (stream "prover.log" :direction :output
:if-exists :supersede
:if-does-not-exist :create)
(let* ((*standard-output*
(if logfile-p
stream
*standard-output*))
(*print-pretty* t)
(*debug-io* *standard-output*)
(*error-output* *standard-output*)
(*trace-output* *standard-output*))
(classify *cur-tbox*
;:language +alchf+
:debug-p *debug-p*
:cache-models-p t
:use-cached-models-p t
:subtableau-caching-p t
:semantic-branching-p t
:delete-nodes-p nil
:use-unsat-cache-p t
:reuse-nodes-p nil
:non-determinism-p nil)))
;(visualize-dag (taxonomy *cur-tbox*))
))
(defun compare-taxonomies ()
(racer:classify-tbox)
(classify-cur-tbox nil nil)
(let* ((key #'(lambda (x)
(format nil "~A" x)))
(t1 (sort
(mapcar #'(lambda (x)
(list (sort (ensure-list (first x)) #'string-lessp :key key)
(sort (ensure-list (second x)) #'string-lessp :key key)
(sort (ensure-list (third x)) #'string-lessp :key key)))
(racer:taxonomy))
#'string-lessp
:key #'(lambda (x)
(format nil "~A" (caar x)))))
(t2 (sort
(mapcar #'(lambda (x)
(list (sort (ensure-list (first x)) #'string-lessp :key key)
(sort (ensure-list (second x)) #'string-lessp :key key)
(sort (ensure-list (third x)) #'string-lessp :key key)))
(taxonomy-list *cur-tbox*))
#'string-lessp
:key #'(lambda (x)
(format nil "~A" (caar x)))))
(okay t))
;(pprint t1) (terpri) (pprint t2) (terpri)
(mapc #'(lambda (a b)
(let ((a (read-from-string (format nil "~A" a)))
(b (read-from-string (format nil "~A" b))))
;; (format t "~% Racer: ~A~% DLMAPS: ~A~%" a b)
(unless (set-equal (first a) (first b) :test #'(lambda (x y) (set-equal (ensure-list x) (ensure-list y))))
(format t "*** BAD CONCEPT ORDER: ~A ~A~%" (first a) (first b)))
(unless (set-equal (second a) (second b) :test #'(lambda (x y) (set-equal (ensure-list x) (ensure-list y))))
(setf okay nil)
(format t "*** MISMATCH FOR PARENTS OF CONCEPT ~A
TOO MANY: ~A
TOO LESS: ~A~%~%"
(first a)
(set-difference (second b) (second a)
:test #'(lambda (x y) (set-equal (ensure-list x) (ensure-list y))))
(set-difference (second a) (second b)
:test #'(lambda (x y) (set-equal (ensure-list x) (ensure-list y))))))
(unless (set-equal (third a) (third b) :test #'(lambda (x y) (set-equal (ensure-list x) (ensure-list y))))
(setf okay nil)
(format t "*** MISMATCH FOR CHILDREN OF CONCEPT ~A
TOO MANY: ~A
TOO LESS: ~A~%~%"
(first a)
(set-difference (third b) (third a)
:test #'(lambda (x y) (set-equal (ensure-list x) (ensure-list y))))
(set-difference (third a) (third b)
:test #'(lambda (x y) (set-equal (ensure-list x) (ensure-list y))))))))
t1 t2)
(if okay
'taxonomies-are-identical
'error-taxonomies-are-different)))
;;;
(defun racer-subsumes (f g)
(let ((*package* (find-package :racer-user)))
(racer:concept-subsumes-p
(change-package-of-description f :racer-user)
(change-package-of-description g :racer-user)
'racer-user::foobar)))
(defun midelora-subsumes (f g &rest args)
(let ((*print-pretty* t))
(apply #'concept-subsumes-p f g
:debug-p t
args)))
| 6,081 | Common Lisp | .lisp | 135 | 31.903704 | 124 | 0.508835 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | f6c956d660d5dfc239acdbab81bc30ce3ab10c8b56c7ce2143b46ec58241c114 | 12,522 | [
-1
] |
12,523 | simple-kaon-test2.lisp | lambdamikel_DLMAPS/src/prover/simple-kaon-test2.lisp | (in-package cl-user)
(defun prepare ()
(ts::racer-answer-query '(?x) '(?x top)
:with-unique-name-assumption-p t))
(defun test1 (concept)
(set-nrql-mode 1)
(load "user-home:Desktop;KAON;dct_with_relations_3_5_10_10;test.racer")
;(time (classify-tbox))
(time (prepare))
(time (ts::racer-answer-query '(?x) `(?x ,concept)
:with-unique-name-assumption-p t)))
(defun test2 (concept)
(set-nrql-mode 6)
(load "user-home:Desktop;KAON;dct_with_relations_3_5_10_10;test.racer")
;(time (classify-tbox))
(time (prepare))
(time (ts::racer-answer-query '(?x) `(?x ,concept)
:with-unique-name-assumption-p t)))
(defun test3 (concept)
(set-nrql-mode 1)
(load "user-home:Desktop;KAON;dct_with_relations_5_5_5_5;test.racer")
(time (classify-tbox))
(time (prepare))
(time (ts::racer-answer-query '(?x) `(?x ,concept)
:with-unique-name-assumption-p t)))
(test2 'thing1) | 1,014 | Common Lisp | .lisp | 1 | 1,014 | 1,014 | 0.577909 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 6f919c7cd25ac47fac850df2199147f8e3e35223aeb5d1b3c11a3b551a982f07 | 12,523 | [
-1
] |
12,524 | db-abox.lisp | lambdamikel_DLMAPS/src/prover/db-abox.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;; CLSQL initilization
;;;
(setf clsql:*default-database-type* :mysql)
(defconstant +db-user+ "root")
(defconstant +db-passwd+ "root")
(clsql-sys::initialize-database-type)
;; (locally-enable-sql-reader-syntax)
(defparameter +string-marker+ 'string-marker-123)
(defparameter +symbol-marker+ 'symbol-marker-123)
;;;
;;;
;;;
(defpersistentclass db-abox (abox)
((db-name :initform nil)
(db-spec :initform nil)
(db-type :initform nil)
;;; verwenden, um wiederholte Datenbankabfragen zu vermeiden!
;;; noch nicht genutzt
(db-nodes-complete-p :accessor db-nodes-complete-p :initform nil)
(db-edges-complete-p :accessor db-edges-complete-p :initform nil)
(successors-complete-for :accessor successors-complete-for
:initform (make-hash-table :test #'equal))))
(defpersistentclass db-abox-node (abox-node)
((from-db-p :initform nil :accessor from-db-p :initarg :from-db-p)))
(defpersistentclass db-abox-edge (abox-edge)
((from-db-p :initform nil :accessor from-db-p :initarg :from-db-p)))
;;;
;;; Aux Functions
;;;
(defun decode-value (val)
;; (setf *x* val)
(labels ((do-it (val)
(if (stringp val)
val
(if (consp val)
(if (eq (first val) +symbol-marker+)
(if (second val)
(intern (format nil "~A" (third val))
(find-package (second val)))
(gensym (format nil "~A" (third val))))
(mapcar #'do-it val))
val))))
(let ((*package* (find-package :prover)))
(do-it (read-from-string val)))))
(defun encode-value (val)
;; (setf *y* val)
(if (stringp val)
(format nil "~S" val)
(if (listp val)
(format nil "~A"
(mapcar #'encode-value val))
(if (symbolp val)
(format nil "(~A ~A |~A|)"
+symbol-marker+
(if (symbol-package val)
(package-name (symbol-package val))
nil)
(symbol-name val))
(format nil "~A" val)))))
;;;
;;;
;;;
(defun convert-db-tuples (tuples)
(if (consp (car tuples))
(mapcar #'(lambda (tuple) (mapcar #'(lambda (x)
(decode-value x))
tuple))
tuples)
(mapcar #'decode-value tuples)))
(defun combine-labels (a b)
(encode-value
(remove-duplicates
(append (ensure-list a)
(ensure-list b))
:test #'set-equal)))
;;;
;;;
;;;
(defmacro with-db-connection ((db db-abox) &body body)
`(when (is-db-abox-p ,db-abox)
(with-slots (db-spec db-type) ,db-abox
(clsql:with-database (,db db-spec
:database-type db-type
:pool t
:make-default t)
(clsql:set-autocommit t :database ,db)
,@body))))
(defun all-dbs ()
(clsql:list-databases (list "localhost" "" +db-user+ +db-passwd+) :database-type :mysql))
(defun destroy-all-dbs ()
(dolist (db (clsql:list-databases
(list "localhost" "" +db-user+ +db-passwd+) :database-type :mysql))
(when (search "MIDELORA-DB-ABOX" db)
(destroy-db db))))
(defun destroy-db (db)
(clsql:destroy-database (list "localhost" db +db-user+ +db-passwd+) :database-type :mysql))
(defun all-db-nodes ()
(with-db-connection (db *cur-abox*)
(convert-db-tuples
(clsql::query "SELECT * FROM NODES"
:database db))))
(defun all-db-edges ()
(with-db-connection (db *cur-abox*)
(convert-db-tuples
(clsql::query "SELECT * FROM EDGES"
:database db))))
(defun delete-all-nodes ()
(mapc #'(lambda (x)
;; db-knoten werden nur geloescht, wenn :update-db-p t
(delete-node *cur-abox* x))
(get-nodes *cur-abox*)))
(defun delete-all-edges ()
(mapc #'(lambda (x)
;; db-knoten werden nur geloescht, wenn :update-db-p t
(delete-edge *cur-abox* x))
(get-edges *cur-abox*)))
;;;
;;;
;;;
;;;
(defmethod find-node ((abox db-abox) name &key error-p satisfying
(look-into-db-p t) &allow-other-keys)
(declare (ignorable satisfying))
(let ((node (call-next-method)))
(or node
(when look-into-db-p
(with-abox* (abox)
(let* ((name-label
(convert-db-tuples
(first
(with-db-connection (db abox)
(clsql::query
(format nil "SELECT name, label FROM NODES WHERE NAME = '~A'"
(encode-value name))
:database db)))))
(name (first name-label))
(label (second name-label)))
(when name
(let ((node (create-abox-node abox name
:type 'db-abox-node
:look-into-db-p nil
:update-db-p nil)))
(dolist (concept label)
(node-instance node concept :update-db-p nil))
node)))))
(when error-p
(error "Node ~A neither found in materialized ABox nor in DB!" name)))))
(defmethod get-edges-between ((abox db-abox) (from db-abox-node) (to db-abox-node) &rest args &key error-p
look-into-db-p &allow-other-keys)
(declare (ignorable args))
(let ((edge (call-next-method)))
(or edge
(let ((from1 (encode-value (name from)))
(to1 (encode-value (name to))))
(when look-into-db-p
(with-db-connection (db abox)
(with-abox* (abox)
(let ((label
(convert-db-tuples
(first
(clsql::query
(format nil "SELECT label FROM EDGES WHERE FROMNODE = '~A' AND TONODE = '~A'"
from1
to1)
:database db))))
(edges nil))
(dolist (label label)
(push (relate from to label
:type 'db-abox-edge
:from-db-p t)
edges))
edges)))))
(when error-p
(error "Edge ~A ~A neither found in materialized ABox nor in DB!" from to)))))
;;;
;;;
;;;
(defmethod initialize-instance :after ((abox db-abox) &rest args)
(declare (ignorable args))
(initialize-db abox))
(defmethod initialize-db ((abox db-abox))
(with-slots (db-spec db-type db-name name) abox
(setf db-type :mysql)
(setf db-spec
(list "localhost" (format nil "MIDELORA-DB-ABOX-~A"
name
)
+db-user+
+db-passwd+))
(setf db-name (clsql:database-name-from-spec db-spec db-type))
(cond ((member (second db-spec)
(all-dbs)
:test #'string-equal)
(format t "~%Database ~A already exists. Using existing DB.~%" name))
(t
(clsql:create-database db-spec :database-type db-type)
(with-db-connection (db abox)
(clsql:execute-command "CREATE TABLE NODES(NAME VARCHAR(255), LABEL BLOB, PRIMARY KEY(NAME))"
:database db)
(clsql:execute-command "CREATE TABLE EDGES(FROMNODE VARCHAR(255), TONODE VARCHAR(255), LABEL BLOB)"
:database db))))))
(defmethod delete-substrate :after ((substrate db-abox) &key &allow-other-keys)
(destroy-db (second (slot-value substrate 'db-spec))))
;;;
;;; Node construction
;;;
(defmethod create-node ((abox db-abox) (name-for-node symbol) (description node-label)
&rest args
&key
(update-db-p nil)
(old-p t) type
&allow-other-keys)
(if (and (eq type 'db-abox-node)
update-db-p)
(progn
(unless old-p
(error "DB ABox individuals must have OLD-P = T!"))
(let* ((node
(apply #'call-next-method
abox name-for-node description
:type 'db-abox-node
:look-into-db-p nil
args))
(av (list (list 'name (encode-value name-for-node))
(list 'label (encode-value nil)))))
(unless node
(error "Can't create node ~A!" name-for-node))
(setf (db-nodes-complete-p abox) nil)
(with-db-connection (db abox)
(clsql:insert-records :into 'nodes
:av-pairs av
:database db))
node))
(call-next-method)))
(defmethod delete-node :after ((abox db-abox) (node db-abox-node) &key update-db-p &allow-other-keys)
(when update-db-p
(with-db-connection (db abox)
(let ((name (encode-value (name node))))
(clsql:delete-records :from 'nodes
:database db
:where (clsql:sql-operation '= (clsql:sql-expression :attribute 'name) name))))))
(defmethod node-instance :after ((ind db-abox-node) (concept concept) &rest args &key (update-db-p t) &allow-other-keys)
(let ((abox (in-graph ind)))
(when update-db-p
(with-db-connection (db abox)
(let* ((label (mapcar #'unparse (told-concepts ind)))
(name (encode-value (name ind)))
(av (list (list 'label (encode-value label)))))
(with-db-connection (db abox)
(clsql:update-records 'nodes
:av-pairs av
:where (clsql:sql-operation '= (clsql:sql-expression :attribute 'name) name)
:database db)))))))
(defmethod node-forget :after ((ind db-abox-node) (concept concept) &rest args &key update-db-p &allow-other-keys)
(declare (ignorable args))
(when update-db-p
(let ((abox (in-graph ind)))
(with-db-connection (db abox)
(let* ((label (mapcar #'unparse (told-concepts ind)))
(name (encode-value (name ind)))
(av (list (list 'label (encode-value label)))))
(with-db-connection (db abox)
(clsql:update-records 'nodes
:av-pairs av
:where (clsql:sql-operation '= (clsql:sql-expression :attribute 'name) name)
:database db)))))))
;;;
;;;
;;;
(defmethod abox-nodes-iterator :after ((abox db-abox) fn &optional (consider-merged-class-p t))
(declare (ignorable consider-merged-class-p))
(unless (db-nodes-complete-p abox)
(dolist (tuple
(convert-db-tuples
(with-db-connection (db abox)
(clsql::query "SELECT * FROM NODES"
:database db))))
;;; hier werden nur die NAMEN der virtuellen Knoten ermittelt!
;;; -> evtl. materialisieren
(let ((node (first tuple)))
(unless (find-node abox node :look-into-db-p nil)
(let ((node (find-node abox node :look-into-db-p t)))
(funcall fn node)))))
(setf (db-nodes-complete-p abox) t)))
(timed-defmethod abox-edges-iterator :after ((abox db-abox) fn &key (satisfying #'yes))
(unless (db-edges-complete-p abox)
(dolist (tuple
(convert-db-tuples
(with-db-connection (db abox)
(clsql::query "SELECT * FROM EDGES"
:database db))))
(let* ((from (first tuple))
(to (second tuple))
(label (third tuple))
(edge (relate from to label
:type 'db-abox-edge
:from-db-p t)))
(when (funcall satisfying edge)
(funcall fn edge))))
(setf (db-edges-complete-p abox) t)))
;;;
;;; Edge construction
;;;
(defmethod create-edge ((abox db-abox)
(from db-abox-node) (to db-abox-node)
(description edge-label)
&rest args
&key
(update-db-p nil)
(old-p t)
type
&allow-other-keys)
(if (and (eq type 'db-abox-edge)
update-db-p)
(progn
(unless old-p
(error "DB ABox edges must have OLD-P = T!"))
(let* ((edge
(apply #'call-next-method
abox from to description
:type 'db-abox-edge
args))
(av (list (list 'fromnode (encode-value (name from)))
(list 'tonode (encode-value (name to)))
(list 'label (encode-value (unparse (textual-description description)))))))
(unless edge
(error "Can't create edge between ~A and ~A!" from to))
(setf (db-edges-complete-p abox) nil)
(with-db-connection (db abox)
(clsql:insert-records :into 'edges
:av-pairs av
:database db))
edge))
(call-next-method)))
(defmethod delete-edge :after ((abox db-abox) (edge db-abox-edge) &key update-db-p &allow-other-keys)
(when update-db-p
(with-db-connection (db abox)
(let ((from (encode-value (name (from edge))))
(to (encode-value (name (to edge))))
(label (encode-value (unparse (textual-description (description edge))))))
(princ label)
(when update-db-p
(with-db-connection (db abox)
(clsql-sys:delete-records :from 'edges
:database db
:where
(clsql:sql-operation
'and
(clsql:sql-operation '= (clsql:sql-expression :attribute 'fromnode) from)
(clsql:sql-operation '= (clsql:sql-expression :attribute 'tonode) to)
(clsql:sql-operation '= (clsql:sql-expression :attribute 'label) label)))))))))
;;;
;;;
;;;
(defmethod compute-virtual-successors ((abox db-abox) (node db-abox-node) &optional role)
(unless (gethash (list node role)
(successors-complete-for abox))
(with-db-connection (db abox)
(let ((succs
(convert-db-tuples
(clsql::query
(format nil "SELECT TONODE, LABEL FROM EDGES WHERE FROMNODE = '~A'"
(encode-value (name node)))
:database db)))
(pres
(convert-db-tuples
(clsql::query
(format nil "SELECT FROMNODE, LABEL FROM EDGES WHERE TONODE = '~A'"
(encode-value (name node)))
:database db)))
(inv-role (when role (get-inverse-role role))))
(setf (gethash (list node role)
(successors-complete-for abox)) t)
(nconc (delete nil
(mapcar #'(lambda (x)
(when (=> role (implies-p (parse-role (second x)) role))
(find-node abox (first x))))
succs))
(delete nil
(mapcar #'(lambda (x)
(when (=> inv-role (implies-p (parse-role (second x)) inv-role))
(find-node abox (first x))))
pres)))))))
(defmethod materialize-virtual-edge ((abox db-abox) (node db-abox-node) (succ db-abox-node) role)
(relate node succ role
:type 'db-abox-edge
:created-by t
:comment 'virtual-computed-midelora-rcc-edge
:old-p t
:materialized-virtual-p t))
(defmethod obvious-non-instance ((abox db-abox) node concept)
(cond ((is-bottom-concept-p concept)
t)
((is-top-concept-p concept)
nil)
((member concept (told-concepts node))
nil)
(t
(let* ((negated (negated-concept concept)))
(or (member negated (told-concepts node))
(obvious-instance abox node negated)
;;; erfordert das Retrieval-Konzeptmodell keine Nachfolger, dann
;;; ist der Test wieder anwenbar!
(some #'(lambda (ma)
(some #'(lambda (mb)
(and (not (or (node-model-successors mb)
(node-model-attributes mb)
(node-model-alls mb)
(node-model-at-mosts mb)))
(models-mergeable-p +alch+ ma mb)))
(cached-models negated)))
(ind-models node)))))))
#|
(progn
(delete-all-aboxes)
(in-abox test nil :type 'db-abox)
(princ (all-db-nodes))
(princ (all-db-edges))
(db-instance a a)
(db-related a b r)
(db-instance b b)
(del a)
(del b)
(princ (concept-instances (or (and a (some r b))
(and b (some (inv r) a)))))
)
|#
| 18,317 | Common Lisp | .lisp | 430 | 27.97907 | 120 | 0.495727 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 65204d30ee29a7a2655a415e64557383ae5071cc5932dbdf95509eaeca80ca18 | 12,524 | [
-1
] |
12,525 | meta-constraints.lisp | lambdamikel_DLMAPS/src/prover/meta-constraints.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(defmacro add-meta-constraints (node)
`(let ((node ,node))
(dolist (constraint *meta-constraints*)
(announce "Adding meta constraint ~A" constraint)
(unless (on-tableau-p node constraint)
(let ((added
(register-as-unexpanded constraint
:comment 'add-meta-constraint
:node node
:new-choice-point 0)))
(check-for-clash node added))))))
| 607 | Common Lisp | .lisp | 16 | 25.75 | 62 | 0.527241 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | de8a80ccb0ff405ec27d826b2ae389923488b78cf4a1d367808dc737a1edb21d | 12,525 | [
-1
] |
12,526 | models.lisp | lambdamikel_DLMAPS/src/prover/models.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(defstruct (node-model (:type list :constructor :auto))
all-expanded
atoms
successors
attributes
alls
at-mosts)
(defstruct (role-profile (:type list :constructor :auto))
role
counter
models)
(defmethod make-model-from-node ((node abox-node)
&key
(all-expanded nil all-expanded-p)
(atoms nil atoms-p)
(alls nil alls-p)
(attributes nil attributes-p)
(at-mosts nil at-mosts-p))
;(describe-object node t)
(when (or (blocked-p node)
(cache-satisfiable-p node))
(error "make model from node: ~A is blocked or cache satisfiable!" node))
(make-node-model
:all-expanded
(if all-expanded-p
all-expanded
(let ((concepts nil))
(loop-over-node-expanded-concepts (concept node)
(push concept concepts))
concepts))
:atoms
(if atoms-p
atoms
(let ((concepts nil))
(loop-over-node-expanded-atomic-concepts (concept node)
(push concept concepts))
concepts))
:alls
(if alls-p
alls
(let ((concepts nil))
(loop-over-node-all-concepts (concept node)
(push concept concepts))
concepts))
:attributes
(if attributes-p
attributes
(let ((concepts nil))
(loop-over-node-unexpanded-attribute-exists-concepts (concept node)
(push concept concepts))
concepts))
:at-mosts
(if at-mosts-p
at-mosts
(let* ((at-mosts nil))
(loop-over-node-unexpanded-at-most-concepts (concept node)
(push concept at-mosts))
(loop as role in (remove-duplicates (mapcar #'role at-mosts))
collect
(let ((min
(loop as at-most in at-mosts when (eq (role at-most) role)
minimize (n at-most))))
(make-role-profile :role role
:counter min
:models nil)))))
:successors
(let ((role-profiles nil))
(loop-over-role-successors (node nil) (succ edge)
(let* ((role (role edge))
(rp (assoc role role-profiles))
(others (remove-if-not #'(lambda (rp2)
(implies-p role (role-profile-role rp2)))
role-profiles))
(m (multiplicity edge)))
(unless (zerop m)
(unless rp
(push (make-role-profile :role role
:counter m
:models nil)
role-profiles))
(mapc #'(lambda (rp2)
(incf (role-profile-counter rp2) m))
others))))
(loop-over-role-predecessors (node nil) (succ edge)
(let* ((role (get-inverse-role (role edge)))
(rp (assoc role role-profiles))
(others (remove-if-not #'(lambda (rp2)
(implies-p role (role-profile-role rp2)))
role-profiles))
(m (inverse-multiplicity edge)))
(unless (zerop m)
(unless rp
(push (make-role-profile :role role
:counter m
:models nil)
role-profiles))
(mapc #'(lambda (rp2)
(incf (role-profile-counter rp2) m))
others))))
role-profiles)))
;;;
;;;
(defmethod models-mergeable-p ((language alch) a b)
(and (not (some #'(lambda (atom)
(let ((neg-atom (negated-concept atom)))
(find neg-atom (node-model-atoms b))))
(node-model-atoms a)))
;;;
;;; Some/Feature/At-least - All Interaction
;;;
(not (some #'(lambda (all)
(find-if #'(lambda (rp)
(implies-p (role-profile-role rp) (role all)))
(node-model-successors b)))
(node-model-alls a)))
(not (some #'(lambda (all)
(find-if #'(lambda (rp)
(implies-p (role-profile-role rp) (role all)))
(node-model-successors a)))
(node-model-alls b)))))
(defmethod models-mergeable-p ((language alchf) a b)
(and (models-mergeable-p +alch+ a b)
(not (some #'(lambda (rp-a)
(let ((r-a (role-profile-role rp-a)))
(find-if #'(lambda (rp-b)
(let ((r-b (role-profile-role rp-b)))
(has-common-parent-feature r-a r-b)))
(node-model-successors b))))
(node-model-successors a)))))
(defmethod models-mergeable-p ((language alchn) a b)
(and (models-mergeable-p +alch+ a b)
(not (possible-at-least-at-most-confict-p a b))))
(defun possible-at-least-at-most-confict-p (a b)
(let* ((at-most-roles
(delete-duplicates
(nconc (mapcar #'role-profile-role (node-model-at-mosts a))
(mapcar #'role-profile-role (node-model-at-mosts b)))))
(at-least-roles
(delete-duplicates
(nconc (mapcar #'role-profile-role (node-model-successors a))
(mapcar #'role-profile-role (node-model-successors b)))))
(at-most-profiles
(mapcar #'(lambda (role)
(make-role-profile :role role
:counter
(let ((a (find role (node-model-at-mosts a) :key #'role-profile-role))
(b (find role (node-model-at-mosts b) :key #'role-profile-role)))
(if a
(if b
(min (role-profile-counter a)
(role-profile-counter b))
(role-profile-counter a))
(if b
(role-profile-counter b)
(error "!"))))))
at-most-roles))
(at-least-profiles
(mapcar #'(lambda (role)
(make-role-profile :role role
:counter
(let ((a (find role (node-model-successors a) :key #'role-profile-role))
(b (find role (node-model-successors b) :key #'role-profile-role)))
(if a
(if b
(+ (role-profile-counter a)
(role-profile-counter b))
(role-profile-counter a))
(if b
(role-profile-counter b)
(error "!"))))))
at-least-roles)))
(find-if #'(lambda (at-most)
(let* ((at-least (find (role-profile-role at-most)
at-least-profiles
:key #'role-profile-role)))
(and at-least
(< (role-profile-counter at-most)
(role-profile-counter at-least)))))
at-most-profiles)))
(defun at-least-at-most-confict-p (a b)
(let* ((at-most-roles
(delete-duplicates
(nconc (mapcar #'role-profile-role (node-model-at-mosts a))
(mapcar #'role-profile-role (node-model-at-mosts b)))))
(at-least-roles
(delete-duplicates
(nconc (mapcar #'role-profile-role (node-model-successors a))
(mapcar #'role-profile-role (node-model-successors b)))))
(at-most-profiles
(mapcar #'(lambda (role)
(make-role-profile :role role
:counter
(let ((a (find role (node-model-at-mosts a) :key #'role-profile-role))
(b (find role (node-model-at-mosts b) :key #'role-profile-role)))
(if a
(if b
(min (role-profile-counter a)
(role-profile-counter b))
(role-profile-counter a))
(if b
(role-profile-counter b)
(error "!"))))))
at-most-roles))
(at-least-profiles
(mapcar #'(lambda (role)
(make-role-profile :role role
:counter
(let ((a (find role (node-model-successors a) :key #'role-profile-role))
(b (find role (node-model-successors b) :key #'role-profile-role)))
(if a
(if b
;;; MIN statt + -> wichtiger unterschied zu possible-at-least-at-most-conflict-p !
(min (role-profile-counter a)
(role-profile-counter b))
(role-profile-counter a))
(if b
(role-profile-counter b)
(error "!"))))))
at-least-roles)))
(find-if #'(lambda (at-most)
(let* ((at-least (find (role-profile-role at-most)
at-least-profiles
:key #'role-profile-role)))
(and at-least
(< (role-profile-counter at-most)
(role-profile-counter at-least)))))
at-most-profiles)))
;;;
;;;
;;;
(defmethod models-surely-not-mergeable-p ((language dl) a b)
(labels ((check-if-member (concepts)
(some #'(lambda (member-concept)
(let ((neg-concept (negated-concept member-concept)))
(or (find neg-concept
(node-model-all-expanded b))
(find neg-concept
(node-model-alls b)))))
concepts)))
(when (or (check-if-member (node-model-all-expanded a))
(check-if-member (node-model-alls a))
(at-least-at-most-confict-p a b))
;(princ "@")
t)))
;;;
;;; Subtableaux Caching und MM
;;;
(defun register-initial-concept-sat-cache-query ()
(incf *initial-concept-sat-cache-queries*))
(defun register-initial-concept-unsat-cache-query ()
(incf *initial-concept-unsat-cache-queries*))
(defun register-initial-concept-sat-cache-hit ()
(incf *initial-concept-sat-cache-hits*))
(defun register-initial-concept-unsat-cache-hit ()
(incf *initial-concept-unsat-cache-hits*))
(defun register-mm-query ()
(incf *mm-queries*))
(defun register-mm-success ()
(incf *mm-hits*))
(defun register-sat-cache-query ()
(incf *sat-cache-queries*))
(defun register-sat-cache-hit ()
(incf *sat-cache-hits*))
;;;
;;; aus Interface.lisp
;;;
(defun register-concept-mm-query ()
(incf *concept-mm-queries*))
(defun register-concept-mm-hit ()
(incf *concept-mm-hits*))
(defun register-concept-query ()
(incf *concept-queries*))
(defun register-true-concept-query ()
(incf *true-concept-queries*))
(defun register-subsumption-query ()
(incf *subsumes-queries*))
(defun register-true-subsumption-query ()
(incf *true-subsumes-queries*))
(defun register-subsumption-mm-hit ()
(incf *subsumes-mm-hits*))
(defun register-subsumption-ts-hit ()
(incf *subsumes-ts-hits*))
(defun register-abox-consistency-test ()
(incf *true-abox-consistency-tests*))
(defun register-abox-subsumption-test ()
(incf *true-abox-subsumption-tests*))
;;;
;;;
;;;
(defmethod models-of-concepts-mergeable-p ((language dl) list-of-concepts)
(let ((concepts nil))
(dolist (concept list-of-concepts)
(etypecase concept
(top-concept)
(bottom-concept
(return-from models-of-concepts-mergeable-p nil))
((or atomic-concept
some-concept
all-concept
at-least-concept
at-most-concept
attribute-exists-concept)
(if (cached-models concept)
(push concept concepts)
(return-from models-of-concepts-mergeable-p nil)))
(and-concept
(if (cached-models concept)
(push concept concepts)
(if (every #'cached-models (arguments concept))
(dolist (arg (arguments concept))
(push arg concepts))
(return-from models-of-concepts-mergeable-p nil))))
(or-concept
(if (cached-models concept)
(push concept concepts)
(let ((arg (find-if #'cached-models
(arguments concept))))
(if arg
(push arg concepts)
(return-from models-of-concepts-mergeable-p nil)))))))
(loop as ca on concepts do
(loop as cb in (rest ca) do
(let* ((ca (first ca))
(res
(some #'(lambda (ma)
(some #'(lambda (mb)
(models-mergeable-p language ma mb))
(cached-models cb)))
(cached-models ca))))
(unless res
(return-from models-of-concepts-mergeable-p nil)))))
t))
| 16,004 | Common Lisp | .lisp | 337 | 26.31454 | 133 | 0.424877 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 1ce656970ee6f4f863bec86728fd0cd28df393fdfc5c3dc0b24f4e9a733cd789 | 12,526 | [
-1
] |
12,527 | alchi-rplus-prover.lisp | lambdamikel_DLMAPS/src/prover/alchi-rplus-prover.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(define-prover ((abox-sat alchi-rplus abox))
(:main
(perform (deterministic-expansion)
(:body
(if clashes
(handle-clashes)
(perform (or-expansion)
(:positive
(if clashes
(handle-clashes)
(restart-main)))
(:negative
(perform (block-nodes)
(:body
(perform (some-expansion)
(:positive
(if clashes
(handle-clashes)
(restart-main)))
(:negative
(success))))))))))))
#|
(progn
(delete-all-tboxes)
(transitive rr)
(unless (sat? (and (some rr (some rr c)) (some s (all (inv s) (all rr (some rr d))))) :debug-p t :recompute-p t)
(error "Prover error!"))
(delete-all-tboxes)
(transitive p)
(def c (and (all (inv r) (all (inv p) (all (inv s) (Not a))))))
(let ((*print-pretty* t))
(when (sat? (and a (some s (and (some r top)
(some p top)
(all r c)
(all p (some r top))
(all p (all r c))
(all p (some p top)))))
:debug-p t :recompute-p t)
(break "Prover error!"))))
|#
| 1,473 | Common Lisp | .lisp | 45 | 20.133333 | 114 | 0.429793 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 7499af31788890bb068299416ab5f624f108d04cc8a7ad383d44f7ba688e87a6 | 12,527 | [
-1
] |
12,528 | alch-prover.lisp | lambdamikel_DLMAPS/src/prover/alch-prover.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(define-prover ((abox-sat alch abox))
(:init
(cond ((zerop (1- (no-of-nodes abox)))
(loop-over-abox-nodes (node abox)
(register-label-is-stable abox node))
(with-strategy (+strategy+)
(start-main)))
(t
(perform (initial-abox-saturation)
(:body
(with-strategy (+abox-saturation-strategy+)
(loop-over-abox-nodes (node abox)
(register-label-is-stable abox node))
(perform (model-merging)
(:body
(start-main)))))))))
(: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 (some-expansion)
(:positive
(if clashes
(handle-clashes)
(perform (model-merging :node new-node)
(:body
(next-round)))))
(:negative
(perform (make-models-for-old-nodes)
(:body
(success)))))))))))))
(:success
(completion-found)))
(define-prover ((abox-sat alch abox1))
;;; Beweiser mit Tiefensuch-Strategie (Trace Technique)!
(:init
(cond ((zerop (1- (no-of-nodes abox)))
(loop-over-abox-nodes (node abox)
(register-label-is-stable abox node))
(with-strategy (+trace-strategy+)
(start-main)))
(t
(perform (initial-abox-saturation)
(:body
(with-strategy (+trace-strategy+)
(loop-over-abox-nodes (node abox)
(register-label-is-stable abox node))
(perform (model-merging)
(:body
(start-main)))))))))
(:rollback
(let ((*maintain-active-nodes-p* t))
(rollback)))
(:main
(perform (focused-deterministic-expansion)
(:body
(if clashes
(handle-clashes)
(perform (or-expansion)
(:positive
(if clashes
(handle-clashes)
(restart-main)))
(:negative
(perform (some-expansion)
(:positive
(if clashes
(handle-clashes)
(perform (model-merging :node new-node)
(:body
(next-round)))))
(:negative
(perform (pop-active-nodes-heap)
(:positive
(next-round))
(:negative
(perform (make-models-for-old-nodes)
(:body (success)))))))))))))
(:success
(completion-found)))
#|
(progn
(with-abox (test :delete-if-exists-p t :language +alch+)
(ins a (and a
(or (all r (not c))
(all r (not b)))
(all r (or (not b) c))))
(ins b b)
(rel a b r)
(false! (abox-sat-p *cur-abox*
:language +alch+
:debug-p t))
(visualize *cur-abox*))
(progn
(delete-all-tboxes)
(delete-all-aboxes)
(subrole r s)
(domain r c)
(range r d)
(with-abox (test)
(rel a b r)
(ins a (or (not c) (all s (not d))))
(false! (abox-sat? test :debug-p t))))
(with-kb (test test :delete-if-exists-p t)
(defrole r :domain a :range b)
(rel i j r)
(true! (individual-instance? i a))
(true! (individual-instance? j b))
(true! (individual-instance? i (some r b)))
(true! (individual-instance? j (some (inv r) a)))
(true! (individual-instance? i (and a (all r b))))
(true! (individual-instance? i (and a (all r (and b (all (inv r) a)))))))
(with-kb (test test :delete-if-exists-p t)
(defrole r :domain a :range b)
(def x (some r top))
(def y (and a (some r b)))
(def xx (and (some r top)
(all r b)))
(true! (equivalent? x y))
(true! (equivalent? xx x))
(true! (equivalent? x xx))
(true! (equivalent? xx y)))
(with-kb (test test :delete-if-exists-p t)
(instance a (and d (all r c)))
(related a b (or r s))
(instance b (not c))
(instance b (all (inv s) (not d)))
(false! (abox-consistent-p *cur-abox*))))
|#
| 4,855 | Common Lisp | .lisp | 143 | 21.734266 | 84 | 0.4711 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 61cfa0570b48c77ad540def651d717eddda7138818ee4bf94d12d7d61ead64bc | 12,528 | [
-1
] |
12,529 | roles.lisp | lambdamikel_DLMAPS/src/prover/roles.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(defmethod get-all-roles ((tbox tbox))
(let ((roles nil))
(maphash #'(lambda (name role)
(declare (ignorable name))
(push role roles))
(slot-value (concept-store tbox) 'roles))
(remove-duplicates (sort roles #'< :key #'id))))
(defmethod get-all-transitive-roles ((tbox tbox))
(remove-if-not #'transitive-p (get-all-roles tbox)))
(defmethod get-all-features ((tbox tbox))
(remove-if-not #'feature-p (get-all-roles tbox)))
;;;
;;;
;;;
(defmethod define-role ((role-name symbol)
&key
symmetric
feature feature-p
inverse-feature inverse-feature-p
(inverse `(inv ,role-name))
parent
parents
inverse-parent
inverse-parents
transitive
transitive-p
(domain 'top)
(range 'top))
(with-concept-store (*cur-store*)
(let* ((*create-inverse-role-p* nil)
(role (or (find-role role-name)
(parse-role role-name)))
(inverse-role-name inverse)
(symmetric-p (or symmetric
(symmetric-role role)
(equal role-name inverse-role-name)))
(inverse-role (if symmetric-p
role
(or (find-role `(inv ,role-name))
(parse-role inverse-role-name))))
(symmetric-p (or symmetric-p
(symmetric-role inverse-role)))
(transitive-p (or transitive
transitive-p
(transitive-p role)
(transitive-p inverse-role)))
(domain (make-and-concept
(remove nil (list (when (role-domain role)
(role-domain role))
(when (role-range inverse-role)
(role-range inverse-role))
(parse-concept domain)))))
(range (make-and-concept
(remove nil (list (when (role-range role)
(role-range role))
(when (role-domain inverse-role)
(role-domain inverse-role))
(parse-concept range)))))
(feature-p (or feature-p
feature
(feature-p role)))
(inverse-feature-p (or inverse-feature-p
inverse-feature
(feature-p inverse-role)))
(parents (append (mapcar #'define-role
(append (ensure-list parent) (ensure-list parents)))
(superroles role)))
(inverse-parents (append (mapcar #'define-role
(append (ensure-list inverse-parent) (ensure-list inverse-parents)))
(superroles inverse-role))))
(register-inverses role inverse-role)
(register-name-for-role inverse-role inverse-role-name)
(register-name-for-role inverse-role `(inv ,role-name))
(unless (consp inverse-role-name)
(register-name-for-role role `(inv ,inverse-role-name)))
(when parents
(register-superroles role parents))
(when inverse-parents
(register-superroles inverse-role inverse-parents))
(when transitive-p
(register-transitive role))
(when symmetric-p
(register-symmetric role))
(when feature-p
(register-feature role))
(when inverse-feature-p
(register-feature inverse-role))
(when domain
(register-domain role domain))
(when range
(register-range role range))
(unless (parse-name role)
(setf (slot-value role 'parse-name) role-name))
(unless (parse-name inverse-role)
(setf (slot-value inverse-role 'parse-name) inverse-role))
role)))
(defmethod define-role (role-name &key &allow-other-keys)
(error "*** BAD ROLE NAME ~A GIVEN!" role-name))
(defmethod register-superroles ((role role) superroles)
(dolist (sr superroles)
(pushnew sr (slot-value role 'superroles)))
role)
(defmethod register-domain ((role role) (concept concept))
(setf (role-domain role) concept)
role)
(defmethod register-range ((role role) (concept concept))
(setf (role-range role) concept)
role)
(defmethod register-transitive ((role simple-role))
(setf (slot-value role 'transitive-p) t
(slot-value (slot-value role 'inverse-role)
'transitive-p) t)
role)
(defmethod register-symmetric ((role simple-role))
(setf (slot-value role 'symmetric-role) t)
role)
(defmethod register-feature ((role simple-role))
(setf (slot-value role 'feature-p) t)
role)
;;;
;;;
;;;
(defmethod prepare-roles ((tbox tbox))
(labels ((cyclic-p (role current)
(or (member role (superroles current))
(some #'(lambda (x)
(cyclic-p role x))
(superroles current))))
(get-all-superroles (role)
(remove-duplicates
(append (superroles role)
(reduce #'append
(mapcar #'get-all-superroles (superroles role)))))))
(with-slots (concept-store) tbox
(with-slots (roles all-store-roles) concept-store
(dolist (role all-store-roles)
(let* ((inv-role (get-inverse-role role))
(superroles
(remove-duplicates
(append (superroles role)
(mapcar #'get-inverse-role (superroles inv-role)))))
(inv-superroles
(mapcar #'get-inverse-role superroles)))
(setf (slot-value role 'superroles) superroles
(slot-value inv-role 'superroles) inv-superroles)
(dolist (sr superroles)
(pushnew role (slot-value sr 'subroles)))
(dolist (sr inv-superroles)
(pushnew inv-role
(slot-value sr 'subroles)))))
(dolist (role all-store-roles)
(when (is-simple-role-p role)
(when (cyclic-p role role)
(error "*** CYCLE IN ROLE HIERARCHY DETECTED FOR ~A!" role))
(let ((all-srs (get-all-superroles role)))
(setf (slot-value role 'all-superroles) all-srs)
(dolist (sr all-srs)
(pushnew role (slot-value sr 'all-subroles))))))
(dolist (role all-store-roles)
(when (is-simple-role-p role)
(let ((inv-role (get-inverse-role role)))
(register-domain role
(make-and-concept (remove nil
(remove-duplicates
(append
(cons (role-domain role)
(mapcar #'role-domain (all-superroles role)))
(when inv-role
(cons (role-range inv-role)
(mapcar #'role-range (all-superroles inv-role)))))))))
(register-range role
(make-and-concept (remove nil
(remove-duplicates
(append
(cons (role-range role)
(mapcar #'role-range (all-superroles role)))
(when inv-role
(cons (role-domain inv-role)
(mapcar #'role-domain (all-superroles inv-role))))))))))))
(let ((changed t))
;;; Fixpunkt, alle Domain/Range-Konzepte f. die komplexen Rollen berechnen
(loop while changed do
(setf changed nil)
(dolist (role all-store-roles)
(when (is-and-role-p role)
(when (and (not (role-domain role))
(every #'role-domain (arguments role)))
(setf changed t)
(register-domain role (make-and-concept (mapcar #'role-domain (arguments role)))))
(when (and (not (role-range role))
(every #'role-range (arguments role)))
(setf changed t)
(register-range role (make-and-concept (mapcar #'role-range (arguments role))))))
(when (is-or-role-p role)
(when (and (not (role-domain role))
(every #'role-domain (arguments role)))
(setf changed t)
(register-domain role (make-or-concept (mapcar #'role-domain (arguments role)))))
(when (and (not (role-range role))
(every #'role-range (arguments role)))
(setf changed t)
(register-range role (make-or-concept (mapcar #'role-range (arguments role))))))))))))
tbox)
;;;
;;;
;;;
(defun has-common-parent-feature (a b)
(and (feature-p a)
(feature-p b)
(some #'(lambda (a)
(and (feature-p a)
(some #'(lambda (b)
(and (feature-p b)
(eq a b)))
(cons b (all-superroles b)))))
(cons a (all-superroles a)))))
;;;
;;;
;;;
(defun create-and-role (roles &key feature-p)
(let ((roles (remove-duplicates roles)))
(if (cdr roles)
(make-instance 'and-role
:textual-description
`(and ,@(mapcar #'textual-description roles))
:feature-p feature-p
:constructor-sym 'reparse-role
:feature-p t
:arguments roles
:superroles roles
:all-superroles (reduce #'append
(mapcar #'all-superroles roles))
:concept-store *cur-store*
:tbox *cur-tbox*
:role-domain (make-and-concept (mapcar #'role-domain roles))
:role-range (make-and-concept (mapcar #'role-range roles)))
(first roles))))
;;;
;;;
;;;
(defmacro defrole (role &rest args)
`(define-role ',role
,@(mapcar #'(lambda (x)
`(quote ,x))
args)))
(defmacro deffeature (role &rest args)
`(define-role ',role :feature-p t
,@(mapcar #'(lambda (x)
`(quote ,x))
args)))
(defmacro subrole (role &rest superroles)
`(let ((role (parse-role ',role))
(superroles (mapcar #'parse-role ',superroles)))
(register-superroles role superroles)))
(defmacro domain (role concept)
`(let ((role (parse-role ',role))
(concept (parse-concept ',concept)))
(register-domain role concept)))
(defmacro range (role concept)
`(let ((role (parse-role ',role))
(concept (parse-concept ',concept)))
(register-range role concept)))
(defmacro transitive (role)
`(register-transitive (parse-role ',role)))
| 12,663 | Common Lisp | .lisp | 269 | 28.249071 | 124 | 0.46996 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 834c319433c7f57c04b44b7ed48ee3c6e54bac350d32db3be05caf75f3bd665e | 12,529 | [
-1
] |
12,530 | alchfn-rplus-prover.lisp | lambdamikel_DLMAPS/src/prover/alchfn-rplus-prover.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(define-prover ((abox-sat alchfn-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 (simple-at-most-merging)
(:positive
(restart-main))
(:negative
(perform (identify-stable-nodes)
(:body
(perform (model-merging)
(:body
(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)
(:body
(next-round)))))))
(:negative
(perform (simple-at-least-expansion)
(:positive
(if clashes
(handle-clashes)
(perform (block-nodes :blocked new-node)
(:body
(perform (model-merging)
(:body
(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)
;;; dieses Beispiel demonstriert, wie
;;; wichtig es ist, ERST die "oldest" OLD
;;; nodes zu expandieren; die "youngest" OLD
;;; zu präferieren führt wegen combined-some-all-rule
;;; zu falschem Ergebnis! das problem ist, dass
;;; bei youngest old first zunächst "c" und "b : some f c"
;;; gemerged werden; und dann erst "b" und "a : some f top".
;;; d.h., die transitive (all r (not c)) erreicht den
;;; gemergten Knoten "c" und "b : some f c" gar nicht!
;;; wird dagegen erst "b" und "a : some f top" gemerget,
;;; so hat der merge-Knoten schon (all r (not c)) im
;;; label, und das wird durchpropagiert, wenn dann
;;; das label für "b : (some f c)" erzeugt wird -> clash
(defrole f :parents (r g))
(transitive r)
(instance a (all r (not c)))
(related a b g)
(instance a (some f top))
(instance a (at-most 1 g))
(related b c g)
(instance b (some f c))
(instance b (at-most 1 g))
(false! (abox-sat? test))))
|#
| 3,764 | Common Lisp | .lisp | 91 | 23.043956 | 75 | 0.406087 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | d8a6b3ccc2fd9a003189128a4c78f3433b13f89aae06b9c68b34e23b3d69cbbc | 12,530 | [
-1
] |
12,531 | tbox9.lisp | lambdamikel_DLMAPS/src/prover/tbox9.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;; TBoxen
;;;
(defun mht ()
(make-hash-table :size 10000 :rehash-size 10000))
(defpersistentclass tbox ()
((name :accessor name :initform nil :initarg :name)
(tbox-version :accessor tbox-version :initform 0)
(prepared-p :reader prepared-p :initform nil)
(needs-blocking-p :reader needs-blocking-p :initform nil)
(rbox :accessor rbox :initform nil :initarg :rbox)
(used-by-aboxes :accessor used-by-aboxes :initform nil)
(orig-axioms-with-left-side :accessor orig-axioms-with-left-side :initform (mht))
(orig-axioms-with-right-side :accessor orig-axioms-with-right-side :initform (mht))
(new-axioms-with-left-side :accessor new-axioms-with-left-side :initform (mht))
(new-axioms-with-right-side :accessor new-axioms-with-right-side :initform (mht))
(equivalent-names :accessor equivalent-names :initform (mht))
(primitive-names :accessor primitive-names :initform nil)
(defined-names :accessor defined-names :initform nil)
(cyclic-names :accessor cyclic-names :initform nil)
(language :initform nil)
(in-definition-order-p :accessor in-definition-order-p :initform nil)
(told-subsumers-computed-p :accessor told-subsumers-computed-p :initform nil)
(satisfiable :reader satisfiable :initform :not-tested)
(meta-constraints :reader get-meta-constraints :initform nil)
(taxonomy :initform nil)
(axiom-counter :accessor axiom-counter :initform 0)
(concept-store :reader concept-store :initarg :concept-store)
(classification-order :accessor classification-order :initform nil)))
;;;
;;;
;;;
(defmethod get-all-atoms ((tbox tbox))
(all-atoms (concept-store tbox)))
(defmethod get-all-positive-atoms ((tbox tbox))
(positive-atoms (concept-store tbox)))
(defmethod get-all-negative-atoms ((tbox tbox))
(negative-atoms (concept-store tbox)))
;;;
;;;
;;;
(defmethod get-abox-type-for-tbox ((tbox tbox))
(let ((rbox (rbox tbox)))
(etypecase rbox
; (null 'abox)
(null (get-standard-abox-class))
(jepd-rolebox 'jepd-abox)
(rolebox 'rolebox-abox))))
(defmethod get-abox-type-for-tbox ((tbox null))
(get-standard-abox-class))
;;;
;;;
;;;
(defmethod tbox-classified-p ((tbox tbox))
(when (slot-value tbox 'taxonomy)
t))
;;;
;;;
;;;
(defpersistentclass taxonomy-node (dag-node)
((concept :accessor concept :initarg :concept :initform nil)
(definition :accessor definition :initarg :definition :initform nil)
(equivalents :accessor equivalents :initform nil)))
(defmethod print-object ((node taxonomy-node) stream)
(format stream "#<~A ~A>"
(type-of node)
(concept node)))
;;;
;;;
;;;
(defpersistentclass taxonomy (dag)
((tbox :reader tbox :initform nil :initarg :tbox)))
(defpersistentclass used-by-dag (dag))
(defmethod print-object ((taxonomy taxonomy) stream)
(format stream "#<~A ~A ~A>"
(type-of taxonomy)
(dag-name taxonomy)
(tbox taxonomy)))
;;;
;;;
;;;
(defpersistentclass axiom ()
((id :reader id :initarg :id)
(left :accessor left :initarg :left)
(right :accessor right :initarg :right)
(or-concept :accessor or-concept :initarg :or-concept)
(primitive-p :accessor primitive-p :initform nil :initarg :primitive-p)
(name-equivalence-axiom-p :accessor name-equivalence-axiom-p :initform nil :initarg
:name-equivalence-axiom-p)
(role-domain-axiom-p :accessor role-domain-axiom-p :initform nil :initarg :role-domain-axiom-p)
(role-range-axiom-p :accessor role-range-axiom-p :initform nil :initarg :role-range-axiom-p)
(marked-p :accessor marked-p :initform nil :initarg :marked-p)
(gci-p :accessor gci-p :initform nil :initarg :gci-p)))
(defmethod print-object ((axiom axiom) stream)
(if *print-pretty*
(if (primitive-p axiom)
(format stream "(~A ~A ~A)~%"
(if (gci-p axiom) 'implies 'def*)
(left axiom) (right axiom))
(format stream "(~A ~A ~A)~%"
(if (gci-p axiom) 'equivalent 'def)
(left axiom) (right axiom)))
(if (primitive-p axiom)
(format stream "#<~A: ~A => ~A>~%"
(if (gci-p axiom) 'GCI 'DEF*)
(left axiom) (right axiom))
(format stream "#<~A: ~A = ~A>~%"
(if (gci-p axiom) 'GCI 'DEF)
(left axiom) (right axiom)))))
(defmethod unparse ((axiom axiom))
(let ((*print-pretty* t))
(read-from-string
(format nil "|~A|" (print-object axiom nil)))))
;;;
;;;
;;;
(defmethod print-object ((tbox tbox) stream)
(if (prepared-p tbox)
(progn
(format stream "#<TBOX ~A, PREPARED, LANGUAGE ~A, " (name tbox) (get-language tbox))
(when (slot-value tbox 'taxonomy)
(format stream " CLASSIFIED,"))
(unless (eq (slot-value tbox 'satisfiable) :not-tested)
(format stream " SATISFIABLE: ~A," (slot-value tbox 'satisfiable)))
(format stream " ~A PCDs, ~A CDs, ~A GCIs, ~A MCs>"
(length (get-primitive-concept-definitions tbox))
(length (get-defined-concept-definitions tbox))
(length (get-gcis tbox))
(length (get-meta-constraints tbox))))
(progn
(format stream "#<TBOX ~A, ~A AXIOMS>"
(name tbox)
(length (get-original-axioms tbox))))))
;;;
;;;
;;;
(defun get-axioms-from (table)
(let ((res nil))
(maphash #'(lambda (key val)
(declare (ignore key))
;(princ key) (princ val)
(dolist (val val)
(push val res)))
table)
(sort (remove-duplicates res)
#'< :key #'id)))
;;;
;;;
;;;
(defmethod get-original-axioms ((tbox tbox))
(get-axioms-from (orig-axioms-with-left-side tbox)))
(defmethod get-new-axioms ((tbox tbox))
(get-axioms-from (new-axioms-with-left-side tbox)))
(defmethod get-axioms-with-left-side ((left concept) &key orig-p)
(gethash left
(if orig-p
(orig-axioms-with-left-side (tbox left))
(new-axioms-with-left-side (tbox left)))))
(defmethod get-axioms-with-right-side ((right concept) &key orig-p)
(gethash right
(if orig-p
(orig-axioms-with-right-side (tbox right))
(new-axioms-with-right-side (tbox right)))))
;;;
;;;
;;;
(defmethod get-axioms-containing-right-side ((right concept) &key orig-p)
(let* ((tbox (tbox right))
(axioms
(if orig-p (orig-axioms-with-left-side tbox) (new-axioms-with-left-side tbox)))
(found nil))
(maphash #'(lambda (key axioms)
(declare (ignorable key))
(dolist (axiom axioms)
(when (or (eq (right axiom) right)
(and (is-and-concept-p (right axiom))
(member right (arguments (right axiom)))))
(push axiom found))))
axioms)
found))
;;;
;;;
;;;
(defmethod get-axioms ((tbox tbox) &key orig-p)
(get-axioms-from
(if orig-p (orig-axioms-with-left-side tbox) (new-axioms-with-left-side tbox))))
(defmethod get-simple-axioms ((tbox tbox) &key orig-p)
(remove-if #'gci-p
(get-axioms-from
(if orig-p (orig-axioms-with-left-side tbox) (new-axioms-with-left-side tbox)))))
(defmethod get-gcis ((tbox tbox) &key orig-p)
(remove-if-not #'gci-p
(get-axioms-from
(if orig-p (orig-axioms-with-left-side tbox) (new-axioms-with-left-side tbox)))))
;;;
;;;
;;;
(defun sort-concepts (list)
(sort list #'< :key #'id))
;;;
;;;
;;;
(defmethod get-primitive-concept-definitions ((tbox tbox) &key orig-p)
(remove-if-not #'primitive-p (get-simple-axioms tbox :orig-p orig-p)))
(defmethod get-defined-concept-definitions ((tbox tbox) &key orig-p)
(remove-if #'primitive-p (get-simple-axioms tbox :orig-p orig-p)))
;;;
;;;
;;;
(defmethod get-simple-axiom-with-left-side ((name top-concept) &key &allow-other-keys)
nil)
(defmethod get-simple-axiom-with-left-side ((name bottom-concept) &key &allow-other-keys)
nil)
(defmethod get-simple-axiom-with-left-side ((name atomic-concept) &key orig-p)
(let ((defs (remove-if #'gci-p (get-axioms-with-left-side name :orig-p orig-p))))
(when (and defs (not (cdr defs)))
(values (right (first defs))
(first defs)))))
;;;
;;;
;;;
(defmethod get-simple-axioms-with-left-side ((name top-concept) &key &allow-other-keys)
nil)
(defmethod get-simple-axioms-with-left-side ((name bottom-concept) &key &allow-other-keys)
nil)
(defmethod get-simple-axioms-with-left-side ((name atomic-concept) &key orig-p)
(remove-if #'gci-p (get-axioms-with-left-side name :orig-p orig-p)))
;;;
;;;
;;;
(defmethod get-concept-definition ((name atomic-concept) &key orig-p)
(multiple-value-bind (right def)
(get-simple-axiom-with-left-side name :orig-p orig-p)
(when (and def (not (primitive-p def)))
(values right def))))
(defmethod get-primitive-concept-definition ((name atomic-concept) &key orig-p)
(multiple-value-bind (right def)
(get-simple-axiom-with-left-side name :orig-p orig-p)
(when (and def (primitive-p def))
(values right def))))
;;;
;;;
;;;
(defun ts-sort (atoms)
(topo-sort atoms
#'(lambda (x y)
(member x (told-subsumers y)))))
(defun def-order-sort (atoms)
(topo-sort atoms
#'(lambda (x y)
(member x (references-atoms y)))))
;;;
;;;
;;;
(defmethod compute-told-subsumers ((tbox tbox) &key orig-p)
(declare (ignorable orig-p))
(let ((axioms
(append (get-axioms tbox :orig-p orig-p )
;(get-axioms tbox :orig-p t)
))
(atoms (get-all-atoms tbox)))
(when *debug-p*
(terpri)
(format t "All positive atoms: ~A~%" atoms))
(labels ((compute-direct-told-subsumers ()
(dolist (axiom axioms)
(dolist (axiom (if (primitive-p axiom)
(list
(list (left axiom) (right axiom)))
(list
(list (left axiom) (right axiom))
(list (right axiom) (left axiom)))))
(dolist (axiom (list axiom
(list (get-negated-concept (second axiom))
(get-negated-concept (first axiom)))))
(let* ((left (first axiom))
(right (second axiom))
(left-atoms
(cond ((is-atomic-concept-p left) (list left))
((is-or-concept-p left)
(remove-if-not #'is-atomic-concept-p (arguments left)))))
(right-atoms
(cond ((is-atomic-concept-p right) (list right))
((is-and-concept-p right)
(remove-if-not #'is-atomic-concept-p (arguments right))))))
(dolist (left left-atoms)
(dolist (right right-atoms)
(dolist (left (cons left (get-equivalent-names left)))
(dolist (right (cons right (get-equivalent-names right)))
;;; es macht nur Sinn, told subsumers fuer positive Atome
;;; zu berechnen, denn nur diese werden ja in der
;;; Taxonomie gehalten
;(unless (negated-p left)
(pushnew right (told-subsumers left))
(when (negated-p right)
(pushnew (get-negated-concept left)
(told-subsumers (get-negated-concept right)))))))))))))
(compute-all-told-subsumers (name)
(if (marked-p name)
(told-subsumers name)
(progn
(dolist (atom (told-subsumers name))
(dolist (ts (compute-all-told-subsumers atom))
(pushnew ts (told-subsumers name))))
(setf (marked-p name) t)
(told-subsumers name)))))
(unmark-all-atoms tbox)
;;;
;;; direkte fuer alle berechnen
;;;
(compute-direct-told-subsumers)
(when *debug-p*
(dolist (name atoms)
(format t "Direct told subsumers of ~A: ~A~%" name
(told-subsumers name))))
;;;
;;; transitive Huelle fuer nicht zu Zyklen fuehrende berechnen
;;;
(labels ((leads-to-cycle-p (name path)
(or (member name path)
(some #'(lambda (x)
(leads-to-cycle-p x (cons name path)))
(told-subsumers name)))))
(let ((leads-to-cycle
(remove-if-not #'(lambda (x)
(leads-to-cycle-p x nil))
atoms)))
(when *debug-p*
(format t "Atoms that lead to a cyclic atom: ~A~%" leads-to-cycle))
(dolist (name (reverse
(ts-sort (set-difference atoms
leads-to-cycle))))
(compute-all-told-subsumers name)
(when *debug-p*
(format t "All told subsumers of ~A: ~A~%" name
(told-subsumers name))))
;;;
;;; Cluster bestimmen
;;;
(let ((clusters
(find-cluster (remove-if-not #'cyclic-p atoms)
;; das ist eine Obermenge!
;; hier fuehren ja auch C -> (some R D), D -> etc. zu Zyklen,
;; aber D ist kein Told Subsumer von C!
#'(lambda (x y)
(member y (told-subsumers x))))))
(dolist (cluster clusters)
(let ((all nil))
(dolist (name cluster)
(setf (ts-cyclic-p name) t)
(dolist (told (told-subsumers name))
(pushnew told all)
(dolist (told (told-subsumers told))
(pushnew told all))))
(dolist (name cluster)
(setf (told-subsumers name) all))
(when *debug-p*
(format t "All told subsumers of cluster ~A: ~A~%" cluster all)))))
;;;
;;; Told Subsumers fuer zu Cluster fuehrende setzen
;;;
(dolist (name leads-to-cycle)
(when (positive-p name)
(unless (ts-cyclic-p name) ; nicht selbst im Cluster, aber fuehr zum Cluster
(labels ((find-cluster-node (node)
(princ node)
(if (ts-cyclic-p node)
node
(find-if #'find-cluster-node
(told-subsumers node)))))
(let ((cluster-node (find-cluster-node name)))
(unless cluster-node
(break "Found no cluster node for ~A" name))
(setf (told-subsumers name)
(told-subsumers cluster-node))
(when *debug-p*
(format t "All told subsumers of ~A (leading to cluster ~A): ~A~%"
name cluster-node (told-subsumers name)))))))))
;;;
;;;
;;;
(unmark-all-atoms tbox)
(setf (slot-value tbox 'told-subsumers-computed-p) t)))))
;;;
;;;
;;;
(defmethod initialize-instance :after ((tbox tbox) &rest initargs &key dont-initialize-p)
(unless dont-initialize-p
(pushnew tbox *all-tboxes*)))
(defun make-tbox (name &rest args
&key (rbox *cur-rbox*) (delete-if-exists-p t) &allow-other-keys)
(when delete-if-exists-p t
(delete-tbox name :error-p nil :all-p t))
(let* ((store
(make-concept-store name))
(tbox
(apply #'make-instance 'tbox
:name name
:rbox rbox
:concept-store store
:allow-other-keys t
args)))
(setf (slot-value store 'tbox) tbox)
(let ((*cur-tbox* tbox))
(with-concept-store (store)
(make-top-concept)
(make-bottom-concept)))
tbox))
(defun find-tbox (name &key error-p)
(or
(if (typep name 'tbox)
name
(find name *all-tboxes* :key #'name
:test #'(lambda (x y)
(or (equal x y)
(and (Stringp x)
(stringp y)
(string-equal x y))))))
(when error-p
(error "Can't find TBox named ~A!" name))))
(defun delete-tbox (name &key all-p (error-p t))
(let ((found nil))
(loop
(let ((tbox (find-tbox name :error-p error-p)))
(when tbox
(setf found t))
(setf error-p nil)
(unless tbox
(when found
(in-tbox default-tbox)
(in-abox default-abox))
(return))
(setf *all-tboxes*
(delete tbox *all-tboxes*))
(dolist (abox (used-by-aboxes tbox))
(delete-abox abox))
(unless all-p
(in-tbox default-tbox)
(in-abox default-abox)
(return))))))
(defun delete-all-tboxes ()
(setf *all-tboxes* nil)
(in-tbox default-tbox)
(delete-all-aboxes)
*cur-tbox*)
(defun all-tboxes ()
*all-tboxes*)
(defun current-tbox ()
*cur-tbox*)
;;;
;;;
;;;
(defmethod make-axiom ((left concept) (right concept) &key (tbox *cur-tbox*)
primitive-p gci-p (orig-p t) marked-p
role-domain-axiom-p
role-range-axiom-p)
(unless tbox
(error "No TBox!"))
(if (eq left right)
(format t "~%*** WARNING: Bad axiom ~A -> ~A: equivalent to TOP! Axiom ignored.~%" left right)
(let* ((left (if (not primitive-p)
(if (is-atomic-concept-p left)
left
(if (is-atomic-concept-p right)
right
left))
left))
(right (first (remove left (list left right)))))
(note-tbox-modified tbox)
(let ((found (find-if #'(lambda (x)
(eq (right x) left))
(get-axioms-with-left-side right :orig-p orig-p))))
(when found
(setf (primitive-p found) nil))
(let ((axiom (or found
(make-instance 'axiom
:id (incf (axiom-counter tbox))
:gci-p gci-p
:primitive-p primitive-p
:marked-p marked-p
:left left :right right
:role-domain-axiom-p role-domain-axiom-p
:role-range-axiom-p role-range-axiom-p))))
(when orig-p
(if (gethash left (orig-axioms-with-left-side tbox))
(pushnew axiom (gethash left (orig-axioms-with-left-side tbox)))
(setf (gethash left (orig-axioms-with-left-side tbox))
(list axiom)))
(if (gethash right (orig-axioms-with-right-side tbox))
(pushnew axiom (gethash right (orig-axioms-with-right-side tbox)))
(setf (gethash right (orig-axioms-with-right-side tbox))
(list axiom))))
(unless orig-p
(if (gethash left (new-axioms-with-left-side tbox))
(pushnew axiom (gethash left (new-axioms-with-left-side tbox)))
(setf (gethash left (new-axioms-with-left-side tbox))
(list axiom)))
(if (gethash right (new-axioms-with-right-side tbox))
(pushnew axiom (gethash right (new-axioms-with-right-side tbox)))
(setf (gethash right (new-axioms-with-right-side tbox))
(list axiom))))
axiom)))))
(defmethod delete-axiom ((tbox tbox) (axiom axiom) &key (orig-p t))
(note-tbox-modified tbox)
(when orig-p
(setf (gethash (left axiom) (orig-axioms-with-left-side tbox))
(delete axiom (gethash (left axiom) (orig-axioms-with-left-side tbox))))
(setf (gethash (right axiom) (orig-axioms-with-right-side tbox))
(delete axiom (gethash (right axiom) (orig-axioms-with-right-side tbox)))))
(unless orig-p
(setf (gethash (left axiom) (new-axioms-with-left-side tbox))
(delete axiom (gethash (left axiom) (new-axioms-with-left-side tbox))))
(setf (gethash (right axiom) (new-axioms-with-right-side tbox))
(delete axiom (gethash (right axiom) (new-axioms-with-right-side tbox))))))
;;;
;;;
;;;
(defmethod unmark-all-atoms ((tbox tbox))
(dolist (atom (get-all-atoms tbox))
(setf (marked-p atom) nil)))
(defmethod compute-referenced-atoms ((concept atomic-concept) &key orig-p)
(labels ((do-it (name)
(dolist (name (cons name (get-equivalent-names name)))
(let ((axioms (get-axioms-with-left-side name :orig-p orig-p)))
(dolist (axiom axioms)
(dolist (name (get-all-atoms (right axiom)))
(when (and (positive-p name)
(not (marked-p name)))
(push name (references-atoms concept))
(setf (marked-p name) t)
(do-it name))))))))
(unmark-all-atoms (tbox concept))
(do-it concept)
(setf (references-atoms concept)
(remove-duplicates (references-atoms concept)))))
(defmethod compute-cross-references ((tbox tbox) &key orig-p)
(dolist (name (get-all-atoms tbox))
(compute-referenced-atoms name :orig-p orig-p)
(when (member name (references-atoms name))
(setf (cyclic-p name) t)
(setf (slot-value tbox 'needs-blocking-p) t)))
(unmark-all-atoms tbox))
;;;
;;;
;;;
(defmethod partition ((tbox tbox) &key (orig-p t) (allow-cyclic-primitive-definitions-p t))
(let* ((axioms
(if orig-p
(get-original-axioms tbox)
(get-new-axioms tbox)))
(left-sides
(sort-concepts
(remove-duplicates (mapcar #'left axioms))))
(new-axioms nil)
(name-equivalence-axioms nil))
;;;
;;; C -> D, C -> E => C -> D /\ E
;;;
(dolist (left-side left-sides)
(let* ((axioms (get-axioms-with-left-side left-side :orig-p orig-p))
(prim-axioms (remove-if-not #'primitive-p axioms))
(def-axioms (remove-if #'primitive-p axioms)))
(when prim-axioms
(let* ((axiom (first prim-axioms))
(rem-axioms (rest prim-axioms))
(right-sides
(mapcar #'right prim-axioms)))
(setf (right axiom)
(make-and-concept right-sides))
(push axiom new-axioms)
(dolist (axiom rem-axioms)
(delete-axiom tbox axiom :orig-p orig-p))))
(dolist (axiom def-axioms)
;;; (def C D)
(if (and (is-atomic-concept-p (left axiom))
(is-atomic-concept-p (right axiom))
(not (is-top-concept-p (left axiom)))
(not (is-top-concept-p (right axiom)))
(not (is-bottom-concept-p (left axiom)))
(not (is-bottom-concept-p (right axiom))))
;;; (def CN DN) ?
(push axiom name-equivalence-axioms)
(push axiom new-axioms)))))
;;;
;;; ab hier habe ich hoechstens ein Axiom der Form C -> D
;;; aber es koennen noch Axiome der Form C = E zusaetzlich
;;; vorhanden sein!
;;; Außerdem sind equivalente Namesdefinition (DEF CN DN)
;;; in name-equivalence-axioms!
;;;
(dolist (axiom new-axioms)
(setf (marked-p axiom) nil))
(let* ((new-axioms (reverse new-axioms)) ; wichtig!
(simple-axioms
(remove-if #'(lambda (axiom)
(or (not (is-atomic-concept-p (left axiom)))
(is-top-concept-p (left axiom))
(is-bottom-concept-p (right axiom))
(negative-p (left axiom))
(and (not (primitive-p axiom))
;; (def C TOP) ist GCI, aber
;; (def* C TOP) ist sogar redundant!
(is-top-concept-p (right axiom)))))
new-axioms))
(simple-axioms ; ordnung
(append (remove-if-not #'primitive-p simple-axioms)
(remove-if #'primitive-p simple-axioms)))
(sure-gci-axioms
(set-difference new-axioms simple-axioms))
(partitions nil))
(dolist (axiom sure-gci-axioms)
(setf (gci-p axiom) t))
(dolist (axiom simple-axioms)
(setf (gci-p axiom) nil))
(unmark-all-atoms tbox)
(labels ((cyclic-p (cur axiom &key (orig-p t) (consider-only-non-primitive-axioms-p t))
(cond ((eq (right cur) (left axiom))
t)
(t
(some #'(lambda (atom)
(let ((axioms (get-axioms-with-left-side atom :orig-p orig-p)))
(when axioms
(cond ((member axiom axioms)
t)
(t
(let ((axioms (remove-if #'(lambda (axiom)
(or (not (marked-p axiom))
(gci-p axiom)
(and consider-only-non-primitive-axioms-p
(primitive-p axiom))))
axioms)))
(when (cdr axioms)
(error "Error in TBox partioning procedure!"))
(when axioms
(cyclic-p (first axioms) axiom))))))))
(get-all-atoms (right cur))))))
(causes-cycle-p (axiom &rest args)
(apply #'cyclic-p axiom axiom args))
(do-it (u-axioms rem-axioms)
;;;
;;; da rem-axioms sortiert ist
;;; (erst die primitiven, dann
;;; die nicht-primitiven!)
;;; wird dolist immer zunaechst
;;; primitive finden
;;;
(let ((good-axiom
(loop while rem-axioms do
(let ((x (first rem-axioms)))
(if (primitive-p x)
;;; primitive-p
(if (or (marked-p x)
(gci-p x)
(and (marked-p (left x))
(not allow-cyclic-primitive-definitions-p))
(and (not allow-cyclic-primitive-definitions-p)
(causes-cycle-p x
:orig-p orig-p
:consider-only-non-primitive-axioms-p nil)))
(setf rem-axioms (delete x rem-axioms))
(return x))
;;; not primitive-p
(if (or (marked-p x)
(gci-p x)
(marked-p (left x))
(and (is-atomic-concept-p (right x))
(marked-p (right x)))
(causes-cycle-p x
:orig-p orig-p
:consider-only-non-primitive-axioms-p t))
(setf rem-axioms (delete x rem-axioms))
(return x))))
finally (return nil))))
(if (not good-axiom)
(push (reverse u-axioms) partitions)
(let ((name (left good-axiom)))
;(princ name) (terpri)
(setf (marked-p name) t)
(setf (marked-p good-axiom) t)
(do-it (cons good-axiom u-axioms)
(remove good-axiom rem-axioms)))))))
(do-it nil simple-axioms)
(setf partitions (sort partitions #'> :key #'length))
(let* ((u-part (first partitions))
(g-part (append (set-difference simple-axioms u-part)
;;; die nicht in u-part uebernommen
;;; simple-axioms muessen zusaetzlich
;;; als GCIs behandelt werden...
sure-gci-axioms)))
(loop as axiom in g-part do
(setf (gci-p axiom) t))
(loop as axiom in u-part do
(setf (gci-p axiom) nil))
(loop as axiom in name-equivalence-axioms do
(setf (name-equivalence-axiom-p axiom) t))
#|
(setf x u-part)
(setf y g-part)
(setf z name-equivalence-axioms)
|#
(when *debug-p*
(terpri)
(princ "U-Part : ") (princ (length u-part)) (terpri)
(princ "G-Part : ") (princ (length g-part)) (terpri)
(princ "E-Part : ") (princ (length name-equivalence-axioms)) (terpri)
;(break)
)
;;;
;;; primitive Atome markieren
;;;
(dolist (axiom u-part)
(when (primitive-p axiom)
(setf (primitive-p (left axiom)) t)))
(let ((change t))
(loop while change do
(setf change nil)
(dolist (axiom name-equivalence-axioms)
(cond ((and (primitive-p (left axiom))
(not (primitive-p (right axiom))))
(setf (primitive-p (right axiom)) t
change t))
((and (primitive-p (right axiom))
(not (primitive-p (left axiom))))
(setf (primitive-p (left axiom)) t
change t))))))
;;;
;;;
;;;
(values u-part g-part))))))
;;;
;;;
;;;
(defmethod positive-p ((atom atomic-concept))
(not (negated-p atom)))
(defmethod positive-p ((concept and/or-concept))
(every #'positive-p (arguments concept)))
(defmethod positive-p ((concept some/all-concept))
(positive-p (qualification concept)))
;;;
;;;
;;;
(defmethod negative-p ((concept concept))
(negated-p concept))
(defmethod negative-p ((concept and/or-concept))
(every #'negative-p (arguments concept)))
(defmethod negative-p ((concept some/all-concept))
(negative-p (qualification concept)))
;;;
;;;
;;;
(defmethod get-equivalent-names ((name atomic-concept))
(gethash name (equivalent-names (tbox name))))
(defmethod absorb-gcis ((tbox tbox))
(labels ((try-to-absorb (set)
(let ((loop t))
(loop while loop do
;(setf set (sort set #'< :key #'id))
(when *debug-p*
(format t "~%*** SET: ~A~%" set))
(setf loop nil)
;;;
;;; DL-Handbook s. 327
;;;
;;; (ii)
;;;
(let* ((found nil)
(w (find-if #'(lambda (w)
(and (is-atomic-concept-p w)
(positive-p w)
(multiple-value-bind (right def)
(get-simple-axiom-with-left-side w)
(declare (ignorable right))
(when (and def (primitive-p def))
(setf found def)
t))))
set)))
(when w
(let* ((right (right found))
(c
(make-and-concept
(list right
(make-not-concept
(make-and-concept (remove w set)))))))
(setf (slot-value found 'right) c)
(setf (gethash right (new-axioms-with-right-side tbox))
(delete found (gethash right (new-axioms-with-right-side tbox))))
(if (gethash c (new-axioms-with-right-side tbox))
(push found (gethash c (new-axioms-with-right-side tbox)))
(setf (gethash c (new-axioms-with-right-side tbox))
(list found))))
(when *debug-p*
(format t "~%*** ABSORBED ~A (~A) INTO ~A!" w set found))
(return-from try-to-absorb nil)))
;;;
;;; (iii)
;;;
(let* ((found nil)
(w (find-if #'(lambda (w)
(and (is-atomic-concept-p w)
(positive-p w)
(multiple-value-bind (right def)
(get-simple-axiom-with-left-side w)
(declare (ignore right))
(when (and def (not (primitive-p def)))
(setf found def)
t))))
set)))
(when w
(when *debug-p* (format t "*** (III)~%"))
(setf loop t)
(setf set (remove w set))
(push (right found) set)))
;;;
;;; (iv)
;;;
(unless loop
(let* ((found nil)
(w (find-if #'(lambda (w)
(and (is-atomic-concept-p w)
(negative-p w)
(multiple-value-bind (right def)
(get-simple-axiom-with-left-side
(get-negated-concept w))
(when (and def
(not (primitive-p def))
(is-or-concept-p right))
(setf found def)
t))))
set)))
(when w
(when *debug-p* (format t "*** (IV)~%"))
(setf loop t)
(setf set (remove w set))
(push (get-negated-concept (right found)) set))))
;;;
;;; (v)
;;;
(unless loop
(let ((inner-loop t))
(loop while inner-loop do ; AND's expandieren
(setf inner-loop nil)
(let ((and (find-if #'is-and-concept-p set)))
(when and
(when *debug-p* (format t "*** (V)~%"))
(setf inner-loop t)
(setf loop t)
(setf set (remove and set))
(setf set (append set (arguments and))))))))
;;;
;;; (vi)
;;;
(unless loop
(let ((or (find-if #'is-or-concept-p set))
(disjuncts-to-keep nil))
(when or
;(setf loop t)
(when *debug-p* (format t "*** (VI)~%"))
(dolist (arg (arguments or))
(let ((res (try-to-absorb (cons arg (remove or set)))))
;;; wurde ein Disjunkt absorbiert?
;;; -> OR ersetzen gegen übriggebliebene Diskunkte,
;;; die nicht absorbiert werden konnten
(when res
(push arg disjuncts-to-keep))))
(setf set
(if (not disjuncts-to-keep)
(remove or set)
(cons (make-or-concept disjuncts-to-keep)
(remove or set))))))))
(when *debug-p* (format t "*** RETURNING ~A~%!" set))
set)))
(with-slots (meta-constraints) tbox
(let* ((axioms
(get-original-axioms tbox))
(simple-axioms ; GCI-P: s. "partition-tbox"
(remove-if #'gci-p axioms))
(name-equivalence-axioms
(remove-if-not #'name-equivalence-axiom-p simple-axioms))
(simple-axioms
(remove-if #'name-equivalence-axiom-p simple-axioms))
(gcis
(remove-if-not #'gci-p axioms))
(simple-gcis
(remove-if-not #'(lambda (x)
(is-atomic-concept-p (left x)))
gcis))
(gcis (sort
(append simple-gcis
(set-difference gcis simple-gcis))
#'<
:key #'(lambda (x)
(id (left x)))))
(new-gcis nil)
(rem-names
(remove-if #'(lambda (x)
(or (is-top-concept-p x)
(is-bottom-concept-p x)
(get-simple-axioms-with-left-side x :orig-p t)))
(get-all-atoms tbox))))
(dolist (name rem-names)
;;; (def* AN TOP) f. undefiniertes AN
(make-axiom name
(make-top-concept)
:orig-p nil
:tbox tbox
:gci-p nil
:primitive-p t))
(dolist (axiom simple-axioms)
(make-axiom (left axiom) (right axiom)
:tbox tbox
:gci-p nil
:marked-p t
:primitive-p (primitive-p axiom)
:orig-p nil))
;;;
;;; GCI-Absorption
;;;
(dolist (gci gcis)
;; (format t "~% GCI: ~A~%" gci)
(let ((sets (if (primitive-p gci)
(list (list (get-negated-concept (right gci))
(left gci)))
(list (list (get-negated-concept (right gci))
(left gci))
(list (get-negated-concept (left gci))
(right gci))))))
(dolist (set sets)
(let ((res
(try-to-absorb set)))
;(unless res
; (format t "~% ABSORBED ~A!" set))
(when res
(when *debug-p*
(format t "~%*** Warning: Unable to absorb: ~A -> ~A~%" gci res)
;(break)
)
(push res new-gcis))))))
;;;
;;; Axiome der Art (def CN DN) CN, DN = Konzeptnamen (Atome)
;;;
;;; (princ name-equivalence-axioms) (break)
(dolist (axiom name-equivalence-axioms)
(let* ((left (left axiom))
(right (right axiom))
(names (cons left
(cons right
(append (get-equivalent-names left)
(get-equivalent-names right))))))
(dolist (name names)
(let ((names (remove name names)))
(when names
(setf (gethash name (equivalent-names (tbox name))) names)
(setf (gethash (get-negated-concept name)
(equivalent-names (tbox name)))
(mapcar #'get-negated-concept
(get-equivalent-names name))))))))
;;;
;;; Meta-Constraints erzeugen / GCIs
;;;
(when new-gcis
(setf (slot-value tbox 'needs-blocking-p) t)
(let ((meta-args
(arguments
(make-and-concept
;; wichtig wegen Normalisierung!!! (and (and ...)) !
(mapcar #'(lambda (new-gci)
(get-negated-concept
(make-and-concept new-gci)))
new-gcis))))
(rem-meta-args nil))
(dolist (meta-arg meta-args)
(cond ((is-all-concept-p meta-arg)
;;; top -> (all r c)
(when *debug-p*
(format t "Absorbing meta constraint conjunct ~A into role range of ~A (~A)~%"
meta-arg (role meta-arg) (qualification meta-arg)))
(register-range (role meta-arg) (qualification meta-arg)))
((and (is-or-concept-p meta-arg)
(find-if #'(lambda (x)
(and (is-all-concept-p x)
(is-bottom-concept-p (qualification x))))
(arguments meta-arg)))
;;; (or (all r bottom) (and c d)) = (some r top) -> (and c d)
(let* ((all (find-if #'(lambda (x)
(and (is-all-concept-p x)
(is-bottom-concept-p (qualification x))))
(arguments meta-arg)))
(rem (make-or-concept (remove all (arguments meta-arg)))))
(when *debug-p*
(format t "Absorbing meta constraint conjuncts ~A into role domain of ~A (~A)~%"
meta-arg (role all) rem))
(register-domain (role all) rem)))
(t (push meta-arg rem-meta-args))))
(when rem-meta-args
(setf (slot-value tbox 'meta-constraints)
;;; immer nur einer!
(list (make-and-concept rem-meta-args)))
(make-axiom (parse-concept 'top)
(first (slot-value tbox 'meta-constraints))
:tbox tbox
:gci-p t
:primitive-p t
:orig-p nil))))
;;;
;;; Axiome (defprimtconcept A TOP) loeschen
;;;
(dolist (axiom (get-axioms-with-right-side (make-top-concept) :orig-p nil))
(when (and (primitive-p axiom)
;;; notwendig, weil in das Axiom hineinabsorbiert
;;; worden sein kann!
(is-top-concept-p (right axiom)))
(delete-axiom tbox axiom :orig-p nil))))))
tbox)
;;;
;;;
;;;
(defmethod compute-classification-order ((tbox tbox))
;;;
;;; Classification Order / In Definition Order?
;;;
(let* ((atoms (get-all-positive-atoms tbox))
(non-cyclic-atoms
(remove-if #'cyclic-p atoms))
(cyclic-atoms
(remove-if-not #'cyclic-p atoms))
(ts-cyclic-cyclic-atoms
(remove-if-not #'ts-cyclic-p cyclic-atoms))
(rem-cyclic-atoms
(remove-if #'ts-cyclic-p cyclic-atoms))
(top (parse-concept 'top))
(bottom (parse-concept 'bottom)))
(unmark-all-atoms tbox)
(dolist (atom atoms)
(setf (marked-p atom) t))
;; (setf *x* (list non-cyclic-atoms cyclic-atoms ts-cyclic-cyclic-atoms))
;; (breaK)
(setf (classification-order tbox)
(cons top
(cons bottom
(delete top
(delete bottom
(append (def-order-sort non-cyclic-atoms)
(ts-sort rem-cyclic-atoms)
ts-cyclic-cyclic-atoms))))))
(unless cyclic-atoms
(setf (in-definition-order-p tbox) t))
;;;
;;;
;;;
tbox))
;;;
;;;
;;;
(defmethod prepare ((tbox tbox) (language dl))
;;; an dieser Stelle ist die Sprache der TBox
;;; noch nicht bekannt!!!
(unless (prepared-p tbox)
(setf (slot-value tbox 'language) nil
(slot-value tbox 'taxonomy) nil
(slot-value tbox 'satisfiable) :not-tested)
(reset-sat-status (concept-store tbox))
(dolist (abox (used-by-aboxes tbox))
(reset-sat-status abox))
(when *debug-p*
(terpri)
(princ "Preparing TBox...")
(terpri))
(clrhash (new-axioms-with-left-side tbox))
(clrhash (new-axioms-with-right-side tbox))
(when *debug-p*
(princ " Partitioning TBox -> "))
(partition tbox)
(when *debug-p*
(format t "Simple Axioms: ~A. GCIs: ~A.~%"
(length (get-simple-axioms tbox :orig-p t))
(length (get-gcis tbox :orig-p t)))
(princ " Performing GCI-Absorption -> "))
(absorb-gcis tbox)
(when *debug-p*
(format t "Simple Axioms: ~A. GCIs: ~A.~%"
(length (get-simple-axioms tbox))
(length (get-gcis tbox)))
(princ " Computing cross references -> "))
(compute-cross-references tbox)
(when *debug-p*
(princ " Preparing Roles -> "))
(prepare-roles tbox)
(when *debug-p*
(format t "Roles: ~A. Transitive Roles: ~A. Features: ~A~%"
(length (get-all-roles tbox))
(length (get-all-transitive-roles tbox))
(length (get-all-features tbox))))
(dolist (name (get-all-atoms tbox))
(when (cyclic-p name)
(push name (cyclic-names tbox)))
(let ((axioms (get-axioms-with-left-side name)))
(cond ((or (not axioms)
(and (not (cdr axioms))
(primitive-p (first axioms))))
(setf (primitive-p name) t)
(push name (primitive-names tbox)))
(t
(push name (defined-names tbox))))))
(when *debug-p*
(princ "DONE!") (terpri))
(when *debug-p*
(princ " Cyclical Concepts -> ")
(princ (cyclic-names tbox))
(terpri)
(princ " Blocking Needed? -> ")
(princ (needs-blocking-p tbox))
(terpri))
(when *compute-told-subsumers-p*
(when *debug-p*
(princ " Computing told subsumers -> "))
(unless (told-subsumers-computed-p tbox)
(compute-told-subsumers tbox)))
(when *debug-p*
(terpri)
(princ " Computing classification order -> "))
(compute-classification-order tbox)
(when *debug-p*
(princ "DONE!") (terpri)
(if (in-definition-order-p tbox)
(format t " TBox is in Definition Order.~%")
(format t " TBox is *NOT* in Definition Order.~%")))
;;;
;;;
;;;
(setf (slot-value tbox 'prepared-p) t)
;;; wichtig - muss VOR get-language gesetzt werden, sonst Endlosschleife!
(prepare (concept-store tbox) +dl+)
(get-language tbox)
(when *debug-p*
(princ " Computing language -> ")
(princ (slot-value tbox 'language))
(terpri)
(terpri))
;;;
;;;
;;;
tbox))
;;;
;;;
;;;
(defmethod taxonomy ((tbox tbox) &rest args &key recompute-p &allow-other-keys)
(prepare tbox +dl+)
(or (and (not recompute-p)
(slot-value tbox 'taxonomy))
(let ((taxonomy
(make-dag :type 'taxonomy
:tbox tbox
:name (format nil "Taxonomy of TBox ~A" (name tbox)))))
(setf (slot-value tbox 'taxonomy)
(apply #'classify taxonomy args))
(unmark-all-dag-nodes taxonomy)
(dolist (node (dag-nodes taxonomy))
(when (defined-concept-p (concept node))
(mark-dag-node node)))
taxonomy)))
(defmethod taxonomy ((tbox null) &rest args )
(error "Can't find TBox!"))
(defmethod taxonomy (tbox &rest args )
(apply #'taxonomy (find-tbox tbox) args))
;;;
;;;
;;;
(defmethod classify ((tbox tbox) &rest args )
(apply #'taxonomy tbox args))
(defmethod classify ((tbox symbol) &rest args )
(apply #'taxonomy tbox args))
;;;
;;;
;;;
(defmethod compute-used-by-dag ((tbox tbox) &key
(name #'original-description concept)
(definition
#'(lambda (concept)
(get-simple-axiom-with-left-side tbox concept)))
(root (make-top-concept))
(children
;; voreingestellt für used-by-Relation!
#'(lambda (concept)
(apply #'append
(mapcar #'(lambda (x)
(get-all-atoms (left x)))
(remove-if-not #'(lambda (axiom)
(member concept
(get-all-atoms (right axiom))))
(get-simple-axioms tbox)))))))
(let ((nodes nil)
(dag (make-dag :type 'used-by-dag
:name (format nil "Used-by-relationship of TBox ~A" (name tbox))
:tbox tbox)))
(labels ((expand (concept)
(or (find concept nodes :key #'concept)
(let ((children (funcall children concept))
(node (make-dag-node :type 'taxonomy-node
:concept concept
:name (funcall name concept)
:definition (funcall definition concept)
:concept concept)))
(push node nodes)
(let ((children
(mapcar #'expand children)))
(setf (dag-node-children node) children)
(dolist (child children)
(push node (dag-node-parents child)))
(insert-dag-node dag node))
node))))
(expand root)
dag)))
;;;
;;;
;;;
(defmethod classify ((taxonomy taxonomy) &rest args)
(let ((tbox (tbox taxonomy)))
(let ((time
(measure-time
(unless (apply #'tbox-sat-p tbox
;:debug-p t
args)
(format t "~%*** TBox ~A is incoherent!~%" tbox)
(return-from classify nil)))))
(format t "~%*** TIME NEEDED FOR TBOX COHERENCE CHECK: ~A SECONDS~%" time)
(show-statistics))
(format t "~%*** CLASSIFY CALLED WITH ARGUMENTS: ~A ~A~%" tbox args)
(let ((time
(measure-time
(let* ((concepts
(classification-order tbox))
(nodes (mapcar #'(lambda (atomic-concept)
(make-dag-node :type 'taxonomy-node
:name
(original-description atomic-concept)
:concept
atomic-concept
:definition
(get-simple-axiom-with-left-side atomic-concept)))
(if *non-determinism-p*
(progn
(setf (in-definition-order-p tbox) nil)
(reorder concepts))
concepts)))
(n (length nodes))
(count 0)
(pos 0)
(lastpos nil))
(setf *nodes* nodes)
(loop as i from 1 to 100 do (princ "-"))
(terpri)
(unmark-all-atoms tbox)
(dolist (node nodes)
(setf *node* node)
(apply #'classify-node node taxonomy args)
;;(princ "+")
(incf count)
(setf pos (floor (+ 0.5 (* 100 (/ count n)))))
(when (or (not lastpos)
(not (= pos lastpos)))
(loop as i from (or lastpos 0) to (1- pos) do (princ "*"))
(setf lastpos pos)))
(terpri)))))
(format t "~%*** TIME NEEDED FOR TBOX CLASSIFICATION: ~A SECONDS~%" time)
(show-statistics)))
taxonomy)
(defmethod classify-node ((node taxonomy-node) (taxonomy taxonomy) &rest args)
(setf *taxonomy* taxonomy)
(when *debug-p*
(terpri)
(princ ">>>>>>>>> Now classifying ")
(princ node) (terpri))
(let* ((tbox (tbox taxonomy))
(args (append (list :tbox tbox)
(list :rbox (rbox tbox))
(list :type (get-abox-type-for-tbox tbox))
(list :debug-p (or *debug-p*
(and *debug-p*
(=> *debug-node*
(eq (dag-node-name node) *debug-node*)))))
(append args
(list :language (get-language tbox)))))
(concept (concept node))
(parents (apply #'compute-node-parents node taxonomy args))
(children (progn
(setf (dag-node-parents node) parents)
#|
(pprint
(list node parents
;(in-definition-order-p tbox)
(not (get-meta-constraints tbox))
;(not (is-bottom-concept-p concept))
;(not (is-top-concept-p concept))
(is-atomic-concept-p concept)
(multiple-value-bind (def axiom)
(get-simple-axiom-with-left-side concept)
(declare (ignorable def))
(and axiom
(primitive-p axiom)
(every #'(lambda (x)
(=> (positive-p x)
(marked-p x)))
(told-subsumers (right axiom))))))) |#
;;; wichtig, die muessen hier schon gesetzt werden!
(let ((condition (and
(in-definition-order-p tbox)
(not (get-meta-constraints tbox))
(not (is-top-concept-p concept))
(not (is-bottom-concept-p concept))
(is-atomic-concept-p concept)
(multiple-value-bind (def axiom)
(get-simple-axiom-with-left-side concept)
(declare (ignorable def))
(or (and (not axiom)
(not (get-axioms-with-left-side concept)))
(and axiom
(primitive-p axiom)
(every #'(lambda (x)
(=> (positive-p x)
(marked-p x)))
(typecase (right axiom)
(atomic-concept (list (right axiom)))
(and-concept (remove-if-not #'is-atomic-concept-p
(arguments (right axiom))))))))))))
(if condition
(progn
(when *debug-p*
(format t "**** SKIPPING BOTTOM SEARCH PHASE FOR ~A!~%" node))
(let ((children
(or
(mapcar #'(lambda (x)
(find-node-for-concept1 taxonomy x))
(remove-if-not #'marked-p (get-equivalent-names concept)))
(list (find-node-for-concept1 taxonomy (parse-concept 'bottom))))))
children ))
(let ((children
(apply #'compute-node-children node taxonomy args))
(children2
(or
(mapcar #'(lambda (x)
(find-node-for-concept1 taxonomy x))
(remove-if-not #'marked-p (get-equivalent-names concept)))
(list (find-node-for-concept1 taxonomy (parse-concept 'bottom))))))
(when (and condition
(not (set-equal children children2)))
(break "Error: Bottom Search Phase skipped?! ~A ~A ~A" node children children2))
children))))))
(if (and (set-equal parents children)
parents
(not (cdr parents))
(not (cdr children)))
(let ((equi-node (car parents)))
(unless (eq equi-node node)
(when *debug-p* (format t "**** FOUND EQUIVALENT NODE FOR ~A: ~A!~%" node (car parents)))
(setf (slot-value equi-node 'equivalents)
(cons node (slot-value equi-node 'equivalents)))))
(progn
(when *debug-p*
(format t "**** PARENTS OF ~A: ~A!~%" node parents)
(format t "**** CHILDREN OF ~A: ~A!~%" node children))
(setf (dag-node-parents node) parents
(dag-node-children node) children)
(setf (marked-p (concept node)) t)
(insert-dag-node taxonomy node)))))
;;;
;;;
;;;
(defmethod subsumes1-p ((a concept) (b concept) &rest args)
(let ((res
(if (and *logging-p*
(=> *debug-node*
(eq (dag-node-name *node*)
*debug-node*)))
(progn
(apply #'subsumes-p a b
:debug-p t args))
(apply #'subsumes-p a b args))))
(when *racer-validation-p*
(let ((*print-pretty* t))
(unless (eq (racer-user::concept-subsumes-p
(let ((*package* (find-package :racer-user)))
(read-from-string (format nil "~A"
a)))
(let ((*package* (find-package :racer-user)))
(read-from-string (format nil "~A"
b)))
*racer-tbox*)
res)
(with-logging
(progn
(trace subsumes-p)
(trace sat-p)
(trace abox-sat-p)
(trace consistent-p)
(trace already-known-to-be-satisfiable-p)
(trace already-known-to-be-inconsistent-p)
(trace prover-init)
(trace prover-main)
(format t "~%~%!!!!!!!!!!!!!!!! ERROR !!!!!!!!!!!!!!!!!!!!!!~%~%")
(apply #'subsumes-p a b :debug-p t :recompute-p t args)
(format t "~%~%!!!!!!!!!!!!!!!! ERROR !!!!!!!!!!!!!!!!!!!!!!~%~%")
(force-output *standard-output*)))
(error "Found mismatch for (subsumes? ~A ~A): Racer: ~A, Prover: ~A"
a b
(not res) res))))
(when *debug-p*
(if res
(format t "~A SUBSUMES ~A~%" a b)
(format t "~A DOES NOT SUBSUME ~A~%" a b)))
res))
;;;
;;;
;;;
(defmethod get-told-non-subsumers ((concept concept))
(mapcar #'get-negated-concept
(remove-if-not #'negated-p
(told-subsumers concept))))
;;;
;;;
;;;
(defmethod compute-node-parents ((node taxonomy-node) (taxonomy taxonomy) &rest args)
(labels ((mark-all-descendants (node)
(unless (eq (dag-node-marked-p node) 'no)
(mark-dag-node node 'no)
(mapc #'mark-all-descendants (dag-node-children node))))
(mark-all-ancestors (node)
(unless (eq (dag-node-marked-p node) 'yes)
(mark-dag-node node 'yes)
(mapc #'mark-all-ancestors (dag-node-parents node))))
(do-it (nodes)
(loop while nodes do
;(princ (length nodes))
;(terpri)
(let ((current (pop nodes)))
(unless (eq (dag-node-marked-p current) 'no)
(cond ((or (eq (dag-node-marked-p current) 'yes)
(apply #'subsumes1-p (concept current) (concept node) args))
(mark-all-ancestors current)
(setf nodes (nconc nodes (copy-list (dag-node-children current)))))
(t (mark-all-descendants current))))))))
(cond ((is-top-concept-p (concept node)) nil)
((is-bottom-concept-p (concept node))
(list (find-node-for-concept1 taxonomy (parse-concept 'top))))
(t
(unmark-all-dag-nodes taxonomy)
(mapc #'mark-all-descendants
(remove nil
(mapcar #'(lambda (x)
(find-node-for-concept1 taxonomy x))
(get-told-non-subsumers (concept node)))))
(mapc #'mark-all-ancestors
(remove nil
(mapcar #'(lambda (x)
(let ((node1
(find-node-for-concept1 taxonomy x)))
(when (and *debug-p* (not node1))
(format t "*** WARNING: CAN'T FIND TOLD SUBSUMER ~A OF ~A!~%" x (concept node)))
(when (and (in-definition-order-p (tbox taxonomy)) (not node1))
;;; nur dann ist das ein Fehler!
(error "This TBox is not in definition order!"))
node1))
(remove-if-not #'positive-p
(told-subsumers (concept node))))))
(do-it (list (find-node-for-concept1 taxonomy (parse-concept 'top))))
(remove-if #'(lambda (q)
(or (not (eq (dag-node-marked-p q) 'yes))
(some #'(lambda (child)
(eq (dag-node-marked-p child) 'yes))
(dag-node-children q))))
(dag-nodes taxonomy))))))
(defmethod compute-node-children ((node taxonomy-node) (taxonomy taxonomy) &rest args)
(labels ((mark-all-ancestors (node)
(unless (eq (dag-node-marked-p node) 'no)
(mark-dag-node node 'no)
(mapc #'mark-all-ancestors (dag-node-parents node))))
(mark-all-descendants (node)
(unless (eq (dag-node-marked-p node) 'yes)
(mark-dag-node node 'yes)
(mapc #'mark-all-descendants (dag-node-children node))))
(mark-descendants-with (node val)
(unless (member val (dag-node-marked-p node))
(push val (dag-node-marked-p node))
(mapc #'(lambda (child)
(mark-descendants-with child val))
(dag-node-children node))))
(do-it (nodes)
(loop while nodes do
(let ((current (pop nodes)))
(when (eq (dag-node-marked-p current) 'candidate)
(cond ((or (eq (dag-node-marked-p current) 'yes)
(apply #'subsumes1-p (concept node) (concept current) args))
(mark-all-descendants current)
(setf nodes (nconc nodes (copy-list (dag-node-parents current)))))
(t
(mark-all-ancestors current))))))))
(cond ((is-top-concept-p (concept node))
;(list (find-node-for-concept1 taxonomy (parse-concept 'top)))
; gibt es noch nicht!
nil)
((is-bottom-concept-p (concept node)) nil)
(t
(dolist (node (dag-nodes taxonomy))
(mark-dag-node node '()))
(let* ((parents (dag-node-parents node))
(n (length parents))
(bottom (find-node-for-concept1 taxonomy (parse-concept 'bottom))))
(dolist (parent parents)
(mark-descendants-with parent parent))
(dolist (node (dag-nodes taxonomy))
(if (= n (length (dag-node-marked-p node)))
(mark-dag-node node 'candidate)
(mark-dag-node node 'no)))
;; (format t "Candidates for ~A: ~A" node candidates)
;; (terpri)
(do-it (list bottom))
#|
(format t "Adter do-it: ~A"
(mapcar #'(lambda (x)
(list x
(dag-node-marked-p x)))
(dag-nodes taxonomy)))
(terpri)
|#
(remove-if #'(lambda (q)
(or
(not (eq (dag-node-marked-p q) 'yes))
(some #'(lambda (parent)
(eq (dag-node-marked-p parent) 'yes))
(dag-node-parents q))))
(dag-nodes taxonomy)))))))
#|
(defmethod compute-node-parents ((node taxonomy-node) (taxonomy taxonomy) &rest args)
(labels ((mark-all-descendants (node)
(unless (eq (dag-node-marked-p node) 'no)
(mark-dag-node node 'no)
(mapc #'mark-all-descendants (dag-node-children node))))
(mark-all-ancestors (node)
(unless (eq (dag-node-marked-p node) 'yes)
(mark-dag-node node 'yes)
(mapc #'mark-all-ancestors (dag-node-parents node))))
(do-it (current)
(unless (eq (dag-node-marked-p current) 'no)
(cond ((or (when (eq (dag-node-marked-p current) 'yes)
;;;
t)
(apply #'subsumes1-p (concept current) (concept node) args))
(mark-all-ancestors current)
(dolist (child (dag-node-children current))
(do-it child)))
(t
(mark-all-descendants current))))))
(cond ((is-top-concept-p (concept node)) nil)
((is-bottom-concept-p (concept node))
(list (find-node-for-concept1 taxonomy (parse-concept 'top))))
(t
(unmark-all-dag-nodes taxonomy)
(mapc #'mark-all-ancestors
(remove nil
(mapcar #'(lambda (x)
(let ((node1
(find-node-for-concept1 taxonomy x)))
(when (and *debug-p* (not node1))
(format t "*** WARNING: CAN'T FIND TOLD SUBSUMER ~A OF ~A!~%" x (concept node)))
(when (and (in-definition-order-p (tbox taxonomy)) (not node1))
;;; nur dann ist das ein Fehler!
(error "This TBox is not in definition order!"))
node1))
(remove-if-not #'positive-p
(told-subsumers (concept node))))))
(do-it (find-node-for-concept1 taxonomy (parse-concept 'top)))
(remove-if #'(lambda (q)
(or (not (eq (dag-node-marked-p q) 'yes))
(some #'(lambda (child)
(eq (dag-node-marked-p child) 'yes))
(dag-node-children q))))
(dag-nodes taxonomy))))))
(defmethod compute-node-children ((node taxonomy-node) (taxonomy taxonomy) &rest args)
(labels ((mark-all-ancestors (node)
(unless (eq (dag-node-marked-p node) 'no)
(mark-dag-node node 'no)
(mapc #'mark-all-ancestors (dag-node-parents node))))
(mark-all-descendants (node)
(unless (eq (dag-node-marked-p node) 'yes)
(mark-dag-node node 'yes)
(mapc #'mark-all-descendants (dag-node-children node))))
(mark-descendants-with (node val)
(unless (member val (dag-node-marked-p node))
(push val (dag-node-marked-p node))
(mapc #'(lambda (child)
(mark-descendants-with child val))
(dag-node-children node))))
(do-it (current)
(unless (eq (dag-node-marked-p current) 'no)
(when (eq (dag-node-marked-p current) 'candidate)
(cond ((or (eq (dag-node-marked-p current) 'yes)
(apply #'subsumes1-p (concept node) (concept current) args))
(mark-all-descendants current)
(dolist (parent (dag-node-parents current))
(do-it parent)))
(t
(mark-all-ancestors current)))))))
(cond ((is-top-concept-p (concept node))
;(list (find-node-for-concept1 taxonomy (parse-concept 'top)))
; gibt es noch nicht!
nil)
((is-bottom-concept-p (concept node))
nil)
(t
(dolist (node (dag-nodes taxonomy))
(mark-dag-node node '()))
(let* ((parents (dag-node-parents node))
(n (length parents))
(bottom (find-node-for-concept1 taxonomy (parse-concept 'bottom))))
(dolist (parent parents)
(mark-descendants-with parent parent))
(dolist (node (dag-nodes taxonomy))
(if (= n (length (dag-node-marked-p node)))
(mark-dag-node node 'candidate)
(mark-dag-node node 'no)))
(do-it bottom)
(remove-if #'(lambda (q)
(or
(not (eq (dag-node-marked-p q) 'yes))
(some #'(lambda (parent)
(eq (dag-node-marked-p parent) 'yes))
(dag-node-parents q))))
(dag-nodes taxonomy)))))))
|#
;;;
;;; Interface
;;;
(defmethod node-representation ((node taxonomy-node))
(unparse
(cons (concept node)
(mapcar #'concept
(equivalents node)))))
;;;
;;;
;;;
(defmethod parents ((concept concept))
(let ((node (find-node-for-concept concept)))
(when node
(mapcar #'node-representation
(dag-node-parents node)))))
(defmethod parents ((concept symbol))
(parents (parse-concept concept)))
(defmethod children ((concept concept))
(let ((node (find-node-for-concept concept)))
(when node
(mapcar #'node-representation
(dag-node-children node)))))
(defmethod children ((concept symbol))
(children (parse-concept concept)))
(defmethod ancestors ((concept concept))
(let ((node (find-node-for-concept concept)))
(when node
(mapcar #'node-representation
(dag-node-ancestors node)))))
(defmethod ancestors ((concept symbol))
(ancestors (parse-concept concept)))
(defmethod descendants ((concept concept))
(let ((node (find-node-for-concept concept)))
(when node
(mapcar #'node-representation
(dag-node-descendants node)))))
(defmethod descendants ((concept symbol))
(descendants (parse-concept concept)))
(defmethod equivalents ((concept concept))
(let ((node (find-node-for-concept concept)))
(when node
(node-representation node))))
(defmethod synonyms ((concept concept))
(equivalents concept))
(defmethod equivalents ((concept symbol))
(equivalents (parse-concept concept)))
(defmethod synonyms ((concept symbol))
(synonyms (parse-concept concept)))
;;;
;;;
;;;
(defmethod find-node-for-concept1 ((taxonomy taxonomy) (concept atomic-concept))
(or (find concept (dag-nodes taxonomy) :key #'concept)
(loop as node in (dag-nodes taxonomy)
when (member concept (equivalents node) :key #'concept)
return node)))
(defun find-node-for-concept (concept)
(find-node-for-concept1 (taxonomy (tbox concept)) concept))
;;;
;;;
;;;
(defmethod primitive-concept-p ((concept concept))
nil)
(defmethod primitive-concept-p ((concept atomic-concept))
(prepare (tbox concept) +dl+)
(get-primitive-concept-definition concept))
(defmethod defined-concept-p ((concept concept))
nil)
(defmethod defined-concept-p ((concept atomic-concept))
(prepare (tbox concept) +dl+)
(get-concept-definition concept))
;;;
;;;
;;;
(defmethod primitive-concept-p (concept)
(primitive-concept-p (parse-concept concept)))
(defmethod defined-concept-p (concept)
(defined-concept-p (parse-concept concept)))
(defun get-primitive-concepts (tbox)
(prepare tbox +dl+)
(primitive-names (find-tbox tbox :error-p t)))
(defun get-defined-concepts (tbox)
(prepare tbox +dl+)
(defined-names (find-tbox tbox :error-p t)))
;;;
;;;
;;;
(defmethod note-tbox-modified ((tbox tbox))
(reset-sat-status tbox))
;;;
;;;
;;;
(defmethod reset-sat-status ((tbox tbox))
(incf (tbox-version tbox))
(setf (slot-value tbox 'prepared-p) nil)
tbox)
(defmethod reset-sat-status ((tbox symbol))
(reset-sat-status (find-tbox tbox :error-p t)))
;;;
;;;
;;;
(defun forget-tbox (tbox)
(delete-tbox tbox))
(defun tbox-name (tbox)
(name (find-tbox tbox :error-p t)))
;;;
;;;
;;;
(defmacro def* (left &optional (right 'top))
(let ((cleft
(with-disabled-concept-store
(parse-concept left))))
(if (not (and (is-atomic-concept-p cleft)
(not (negated-p cleft))))
(error "Syntax error! ~A must be a concept name!" left)
`(let ((*old-concept-p* t))
(make-axiom (parse-concept ',left)
(parse-concept ',right)
:primitive-p t)))))
(defmacro def (left right)
(let ((cleft
(with-disabled-concept-store
(parse-concept left))))
(if (not (and (is-atomic-concept-p cleft)
(not (negated-p cleft))))
(error "Syntax error! ~A must be a concept name!" left)
`(let ((*old-concept-p* t))
(make-axiom (parse-concept ',left)
(parse-concept ',right))))))
;;;
;;;
;;;
(defmacro impl (left right)
`(let ((*old-concept-p* t))
(make-axiom (parse-concept ',left) (parse-concept ',right) :primitive-p t)))
(defmacro equi (left right)
`(let ((*old-concept-p* t))
(make-axiom (parse-concept ',left) (parse-concept ',right))))
;;;
;;;
;;;
(defmethod taxonomy-list ((tbox tbox))
(let* ((taxonomy (taxonomy tbox))
(nodes
(sort (dag-nodes taxonomy)
#'<
:key (lambda (x) (id (concept x))))))
(tree-map #'(lambda (x)
(when x
(name (concept x))))
(mapcar #'(lambda (node)
(list (if (equivalents node)
(cons node (equivalents node))
node)
(mapcar #'(lambda (x)
(if (equivalents x)
(cons x (equivalents x))
x))
(dag-node-parents node))
(mapcar #'(lambda (x)
(if (equivalents x)
(cons x (equivalents x))
x))
(dag-node-children node))))
nodes))))
;;;
;;;
;;;
(defmethod tbox-sat-p :around ((tbox tbox) &rest args)
(declare (ignorable args))
(if (eq (slot-value tbox 'satisfiable) :not-tested)
(setf (slot-value tbox 'satisfiable)
(call-next-method))
(slot-value tbox 'satisfiable)))
(defmethod tbox-sat-p ((tbox tbox) &rest args)
(prepare tbox +dl+)
(let* ((args (append (list :tbox tbox)
(list :rbox (rbox tbox))
(list :type (get-abox-type-for-tbox tbox))
(append args
(list :language (get-language tbox)))))
(lastpos nil)
(count 0)
(pos nil)
(concepts (classification-order tbox))
(unsat nil)
(n (length concepts)))
(format t "~%*** TBOX-SAT-P CALLED WITH ARGUMENTS: ~A ~A~%" tbox args)
(terpri)
(loop as i from 1 to 100 do (princ "-"))
(terpri)
(dolist (concept concepts)
(setf *concept* concept)
(incf count)
(setf pos (round (+ 0.5 (* 100 (/ count n)))))
(let ((char (if (apply #'sat-p concept
:debug-p
(or *debug-p*
(and *logging-p*
(=> *debug-concept*
(eq concept (parse-concept *debug-concept*)))))
args)
"+"
(progn
(push concept unsat)
"-"))))
(when (or (not lastpos)
(not (= pos lastpos)))
(loop as i from (or lastpos 0) to (1- pos) do (princ char))
(setf lastpos pos))))
(terpri)
(let ((unsat (remove-if #'is-bottom-concept-p unsat)))
(if unsat
(progn
(format t "~%*** WARNING: TBOX ~A IS INCOHERENT, UNSATISFIABLE CONCEPTS: ~A~%" tbox unsat)
nil)
t))))
(defmethod tbox-sat-p (tbox &rest args)
(apply #'tbox-sat-p
(find-tbox tbox :error-p t)
args))
;;;
;;; Eigene Macros
;;;
(defmacro tbox-sat? (abox &rest args)
`(tbox-sat-p (quote ,abox) ,@args))
(defmacro tbox-sat*? (abox &rest args)
`(tbox-sat-p ,abox ,@args))
;;;
;;;
;;;
(defmethod get-language ((tbox tbox) &optional recompute-p)
(declare (ignorable recompute-p))
(unless (prepared-p tbox)
(prepare tbox +dl+))
(setf (slot-value tbox 'language)
(if (needs-blocking-p tbox)
+alchf-rplus+
(typecase (rbox tbox)
(jepd-rolebox
(if (member (rbox tbox)
(list +rcc1-rolebox+
+rcc2-rolebox+
+rcc3-rolebox+
+rcc5-rolebox+
+rcc8-rolebox+))
+alci-rcc+
+alci-ra-jepd+))
(rolebox
+alci-ra-minus+)
(otherwise
(get-language (concept-store tbox)))))))
;;;
;;;
;;;
(in-tbox default-tbox)
(in-abox default-abox)
#|
(defun test ()
(delete-all-tboxes)
(def* a d1)
(implies (or a (some r c)) d2)
(prepare *cur-tbox* +alch+)
(princ (get-simple-axioms *cur-tbox*))
(terpri)
(princ (get-meta-constraints *cur-tbox*))
)
(defun test ()
(delete-all-tboxes)
(implies (and geometric-figure (some angles three))
(some sides three))
(implies geometric-figure figure)
(prepare *cur-tbox* +alch+)
(princ (get-simple-axioms *cur-tbox*))
(terpri)
(princ (get-meta-constraints *cur-tbox*))
)
(defun test ()
(delete-all-tboxes)
(def* top d)
(def* a d1)
(def* a d2)
(prepare *cur-tbox* +alch+)
(princ (get-simple-axioms *cur-tbox*))
(terpri)
(princ (get-meta-constraints *cur-tbox*))
)
(defun test ()
(delete-all-tboxes)
(def* top d)
(def* a (and b (some r a)))
(def* a x)
(prepare *cur-tbox* +alch+)
(princ (get-simple-axioms *cur-tbox*))
(terpri)
(princ (get-meta-constraints *cur-tbox*))
)
(defun test ()
(delete-all-tboxes)
(def* a b)
(def* a c)
(def a xx)
;(def* c c)
(setf *debug-p* t)
(prepare *cur-tbox* +alch+ )
(princ (get-simple-axioms *cur-tbox*))
(terpri)
(princ (get-meta-constraints *cur-tbox*))
)
|#
| 88,544 | Common Lisp | .lisp | 1,941 | 27.409067 | 123 | 0.454082 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 5e979dc070ae3b233ef69b9cc593e8548f8e137c6696b5c54166af2d323f9fe4 | 12,531 | [
-1
] |
12,532 | deterministic-expansion3.lisp | lambdamikel_DLMAPS/src/prover/deterministic-expansion3.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(defmacro with-clash-handler (&rest body)
`(let ((clashes nil))
,@body))
(defmacro check-for-clash (node concepts &optional handle-clash)
`(dolist (concept (ensure-list ,concepts))
(cond ((already-known-to-be-inconsistent-p concept)
(register-clash ,node concept)
(when ,handle-clash
(handle-clashes)))
((on-tableau-p ,node (get-negated-concept concept))
(register-clash ,node concept)
(when ,handle-clash
(handle-clashes))))))
(defmacro handle-clash (node concept culprits choice-points)
`(progn
(setf ,choice-points (sort-choice-points ,choice-points))
;; (announce1 "CLASH FOR ~A AT ~A DUE TO ~A" concept node culprits)
(when *debug-p*
(announce "CLASH FOR ~A AT ~A DUE TO ~A" ,concept ,node ,culprits)
(describe-object ,node t)
(terpri)
(announce "Returning Choice Points: ~A" ,choice-points))
;;; jedes "perform"-Macro setzt einen Prover-Block auf!
(setf (cur-clash-node *cur-abox*) ,node)
(return-from prover (values nil ,choice-points))))
(defmacro register-clash (node concept)
`(progn
(when *debug-p*
(announce "REGISTER CLASH FOR ~A AT ~A" ,concept ,node)
(describe-object ,node t)
(terpri))
(let ((culprits
(if (already-known-to-be-inconsistent-p ,concept)
(list ,concept)
(get-clash-culprits ,node ,concept)))
(choice-points nil))
(dolist (culprit culprits)
(dolist (point (get-choice-points culprit :node ,node))
(push point choice-points)))
(push (list (maximum choice-points)
,node
,concept
culprits
choice-points)
clashes))))
(defmacro handle-clashes ()
`(when clashes
(let ((best-clash nil))
(loop as clash in clashes
as max-choice-point = (first clash)
do
(when (or (not best-clash)
(> max-choice-point
(first best-clash)))
(setf best-clash clash)))
(announce "Clashes found: ~A. Handling: ~A" clashes best-clash)
(handle-clash (second best-clash)
(third best-clash)
(fourth best-clash)
(fifth best-clash)))))
;;;
;;;
;;;
(defrule look-for-atoms (dl abox :args (node node-changed-p))
(loop-over-node-unexpanded-atomic-concepts (atomic-concept node)
(unless clashes
(unless (expanded-p node atomic-concept)
(announce "Found UNEXPANDED ATOM ~A : ~A" node atomic-concept)
(if (is-bottom-concept-p atomic-concept)
(register-clash node atomic-concept)
(progn
(register-as-expanded atomic-concept
:comment 'expand-atom-no-preconditions
:node node)
(when *cur-tbox*
(let* ((equivalent-names
(gethash (if (negated-p atomic-concept)
(get-negated-concept atomic-concept)
atomic-concept)
(equivalent-names *cur-tbox*)))
(equivalent-names
(if (negated-p atomic-concept)
(mapcar #'get-negated-concept equivalent-names)
equivalent-names)))
(dolist (def equivalent-names)
(unless (on-tableau-p node def)
(announce "Node ~A: Adding equivalent name for ~A : ~A"
node atomic-concept def)
(setf node-changed-p t)
(let ((added
(register-as-unexpanded def
:comment 'add-equivalent-name
:node node
:depends-on (list (list node atomic-concept)))))
(check-for-clash node added)))))
;;; TBox7
(multiple-value-bind (def axiom)
(get-simple-axiom-with-left-side
(if (negated-p atomic-concept)
(get-negated-concept atomic-concept)
atomic-concept))
(let ((def (when def
(if (negated-p atomic-concept)
(unless (primitive-p axiom)
(get-negated-concept def))
def))))
(when def
(unless (on-tableau-p node def)
(announce "Node ~A: Adding concept definition of ~A : ~A"
node atomic-concept def)
(setf node-changed-p t)
(let ((added
(register-as-unexpanded def
:comment 'add-concept-definition-of-atom
:node node
:depends-on (list (list node atomic-concept)))))
(check-for-clash node added))))))
;;; zur Maximierung der abgeleiteten Info:
;;; aus A -> B für "not B" auch "not A" folgern!
;;; wird durch obiges lazy Unfolding nicht abgeleitet! Zusatzregel:
(when (and *compute-core-model-p*
;;; fuer das Instance Retrieval Model nur fuer root node?
(=> *store-instance-retrieval-model-p*
t ; (root-p node)
))
(when (tbox-classified-p *cur-tbox*)
(let ((parents (ancestors atomic-concept)))
(dolist (parent parents)
(dolist (parent parent) ; equivalence classes
(let ((def (parse-concept parent)))
(when def
(unless (on-tableau-p node def)
(announce "Node ~A: Adding taxonomy implied concept definition of ~A : ~A"
node atomic-concept def)
(setf node-changed-p t)
(let ((added
(register-as-unexpanded def
:comment 'add-concept-definition-of-atom
:node node
:depends-on (list (list node atomic-concept)))))
(check-for-clash node added)))))))))
(dolist (axiom (get-axioms-containing-right-side
(get-negated-concept atomic-concept)))
(let ((def (get-negated-concept (left axiom))))
(when def
(unless (on-tableau-p node def)
(announce "Node ~A: Adding concept definition of ~A : ~A"
node atomic-concept def)
(setf node-changed-p t)
(let ((added
(register-as-unexpanded def
:comment 'add-concept-definition-of-atom
:node node
:depends-on (list (list node atomic-concept)))))
(check-for-clash node added)))))))
#|
;;; ab TBox8
(let ((axioms
(get-simple-axioms-with-left-side atomic-concept)))
(dolist (axiom axioms)
(let ((def (right axiom)))
(unless (on-tableau-p node def)
(announce "Node ~A: Adding concept definition of ~A : ~A"
node atomic-concept def)
(setf node-changed-p t)
(let ((added
(register-as-unexpanded def
:comment 'add-concept-definition-of-atom
:node node
:depends-on (list (list node atomic-concept)))))
(check-for-clash node added))))))
|#
))))))
(incf *time-spend-in-look-for-atoms*
(- (get-internal-run-time) *start-time*)))
(defrule look-for-ands (dl abox :args (node node-changed-p))
(loop-over-node-unexpanded-and-concepts (and-concept node)
(unless clashes
(unless (expanded-p node and-concept)
(announce "Found UNEXPANDED AND ~A : ~A" node and-concept)
(register-as-expanded and-concept
:comment 'expand-and-put-to-expanded
:node node)
(dolist (arg (arguments and-concept))
(unless clashes
(unless (on-tableau-p node arg)
(setf node-changed-p t)
(let ((added
(register-as-unexpanded arg
:comment 'expand-and-put-arguments-to-unexpanded
:node node
:depends-on (list (list node and-concept)))))
(check-for-clash node added))))))))
(incf *time-spend-in-look-for-ands*
(- (get-internal-run-time) *start-time*)))
(defrule look-for-ors (dl abox :args (node node-changed-p))
(loop-over-node-unexpanded-or-concepts (or-concept node)
(unless clashes
(unless (expanded-p node or-concept)
(let* ((unknowns 0)
(disjunct nil)
(val
(dolist (arg (arguments or-concept) nil)
(cond ((on-tableau-p node arg)
(setf disjunct arg)
(return 'true))
((not (on-tableau-p node (get-negated-concept arg)))
(setf disjunct arg)
(incf unknowns)))))
(val
(or val
(if (zerop unknowns)
'false
(if (= 1 unknowns)
(values 'deterministic disjunct)
'unknown)))))
(case val
(true
(announce "Found TRUE OR ~A : ~A (FOUND TRUE (SUB)ARGUMENT ON TABLEAU) : ~A, ~A"
node or-concept disjunct (get-choice-points disjunct :node node))
(register-as-expanded or-concept
:comment 'expand-or-found-true-or-argument
:node node
:depends-on (list (list node disjunct))))
(false
(announce "Found FALSE OR ~A : ~A (ALL NEGATED ARGUMENTS ON TABLEAU)"
node or-concept)
(register-clash node or-concept))
(deterministic
(announce "Found DETERMINISTIC OR ~A : ~A. Disjunct: ~A"
node or-concept disjunct)
(setf node-changed-p t)
(let ((added
(register-as-unexpanded disjunct
:comment 'put-to-unexpanded-found-deterministic-or
:node node
:depends-on (cons (list node or-concept)
(mapcar #'(lambda (false-disjunct)
(list node (get-negated-concept false-disjunct)))
(remove disjunct (arguments or-concept)))))))
(check-for-clash node added))
(unless clashes
(register-as-expanded or-concept
:comment 'put-to-expanded-found-deterministic-or
:node node
:depends-on (list (list node disjunct))))))))))
(incf *time-spend-in-look-for-ors*
(- (get-internal-run-time) *start-time*)))
(defrule look-for-somes (dl abox :args (node node-changed-p))
(loop-over-node-unexpanded-some-concepts (some-concept node)
(unless clashes
(unless (expanded-p node some-concept)
(let ((qual (qualification some-concept))
(role (role some-concept)))
(loop-over-role-successors (node role) (succ edge)
(when (on-tableau-p succ qual)
(setf node-changed-p t)
(announce "Found satisfied SOME ~A : ~A, satisfied by node ~A"
node some-concept succ)
(register-as-expanded some-concept
:comment 'found-satisfied-some
:node node
:depends-on (list (list succ qual) edge))
(return-from loop)))))))
(incf *time-spend-in-look-for-somes*
(- (get-internal-run-time) *start-time*)))
(defrule look-for-at-leasts (dl abox :args (node node-changed-p))
(loop-over-node-unexpanded-at-least-concepts (at-least-concept node)
(unless clashes
(unless (expanded-p node at-least-concept)
(let ((succs nil)
(m 0)
(n (n at-least-concept))
(qual (qualification at-least-concept))
(role (role at-least-concept)))
(loop-over-role-successors (node role) (succ edge)
(when (on-tableau-p succ qual)
(push succ succs)
(incf m (multiplicity edge))
(when (>= m n)
(return-from loop))))
(when (>= m n)
(setf node-changed-p t)
(announce "Found satisfied AT-LEAST ~A : ~A, satisfied by nodes ~A"
node at-least-concept succs)
(register-as-expanded at-least-concept
:comment 'found-satisfied-at-least
:node node
:depends-on (reduce #'append (mapcar #'created-by succs))))))))
(incf *time-spend-in-look-for-at-leasts*
(- (get-internal-run-time) *start-time*)))
(defrule look-for-alls (dl abox :args (node node-changed-p succs))
(loop-over-node-UNEXPANDED-all-concepts (all-concept node)
(unless clashes
(register-as-expanded all-concept
:comment 'expand-all-no-preconditions
:node node)
;; (unless (expanded-p node all-concept)
(let ((qual (qualification all-concept))
(role (role all-concept))
(added nil))
(loop-over-role-successors (node role) (succ edge)
(unless (on-tableau-p succ qual)
(unless clashes
(announce "Found applicable ALL ~A : ~A -> ~A : ~A OVER ~A"
node all-concept succ qual edge)
(setf node-changed-p t
added t)
(let ((added
(register-as-unexpanded qual
:comment 'found-applicable-all
:node succ
:depends-on
(list (list node all-concept) edge))))
(check-for-clash succ added))))
(unless clashes
(when (and *propagation-of-transitive-all-concepts-p*
(transitive-p all-concept))
(unless (on-tableau-p succ all-concept)
(announce "Found applicable transitive ALL ~A : ~A -> ~A : ~A OVER ~A"
node all-concept succ qual edge)
(setf node-changed-p t
added t)
(let ((added
(register-as-unexpanded all-concept
:comment 'found-applicable-transitive-all
:node succ
:depends-on
(list (list node all-concept) edge))))
(check-for-clash succ added)))))
(when added
(push succ succs))))))
(incf *time-spend-in-look-for-alls*
(- (get-internal-run-time) *start-time*)))
;;;
;;;
;;;
#|
(defrule deterministic-expansion (dl abox)
(with-clash-handler
(let ((any-node-has-changed-p t))
(loop while any-node-has-changed-p do
(announce "Any node has changed, new round!")
(setf any-node-has-changed-p nil)
(loop-over-active-nodes (node abox)
(announce "Now considering node ~A" node)
(unless clashes
(when (active-p node)
(let ((node-changed-p t)
(node-has-changed-p nil))
(unless (deterministically-expanded-p node)
(loop while node-changed-p do
(setf node-changed-p nil)
(unless clashes (perform! (look-for-atoms :node node :node-changed-p node-changed-p)))
(unless clashes (perform! (look-for-ands :node node :node-changed-p node-changed-p)))
(unless clashes (perform! (look-for-ors :node node :node-changed-p node-changed-p)))
(unless clashes (perform! (look-for-somes :node node :node-changed-p node-changed-p)))
(unless clashes (perform! (look-for-at-leasts :node node :node-changed-p node-changed-p)))
(when node-changed-p
(announce "Node ~A has changed!" node)
(setf any-node-has-changed-p t)
(setf node-has-changed-p t)))
(when (and (not node-has-changed-p)
(not clashes))
(register-deterministically-expanded abox node)))))
(when (and (not *combined-some-all-rule-p*)
(not clashes)
(or *dynamic-blocking-p*
(active-p node)))
(perform! (look-for-alls :node node :node-changed-p any-node-has-changed-p)))))))
+insert-body-code+))
|#
(defrule deterministic-expansion (dl abox)
(with-clash-handler
(block main-loop
(let ((nodes (get-active-nodes abox)))
(loop while nodes do
(let ((all-nodes nil))
(dolist (node nodes)
(unless (deterministically-expanded-p node)
(announce "Now considering node ~A" node)
(let ((node-changed-p t))
(loop while node-changed-p do
(setf node-changed-p nil)
(perform! (look-for-atoms :node node :node-changed-p node-changed-p))
(when clashes (return-from main-loop))
(perform! (look-for-ands :node node :node-changed-p node-changed-p))
(when clashes (return-from main-loop))
(perform! (look-for-ors :node node :node-changed-p node-changed-p))
(when clashes (return-from main-loop))
(perform! (look-for-somes :node node :node-changed-p node-changed-p))
(when clashes (return-from main-loop))
(perform! (look-for-at-leasts :node node :node-changed-p node-changed-p))
(when clashes (return-from main-loop)))
(when (has-unexpanded-all-concepts-p node)
(push node all-nodes))
(register-deterministically-expanded abox node))))
(setf nodes nil)
(unless *combined-some-all-rule-p*
(let ((node-changed-p nil))
;;; durch Anwendung von look-for-alls wird der
;;; Knoten, der die Qualifikation aus dem All erhalten hat,
;;; wieder aktiv und determinsitically-expanded wird
;;; aufgehoben. Das All kann nun also expandiert gekennzeichnet
;;; werden! Die SOME-Regel betrachtet dann beim Erzeugen von
;;; NAchfolgern eben auch EXPANDIERTE (und nicht nur unexpandierte)
;;; ALL-Konzepte auf dem Label
(declare (ignorable node-changed-p))
(if *dynamic-blocking-p*
(loop-over-abox-nodes (node abox)
(perform! (look-for-alls :node node
:node-changed-p node-changed-p
:succs nodes))
(when clashes (return-from main-loop)))
(dolist (node all-nodes)
(perform! (look-for-alls :node node
:node-changed-p node-changed-p
:succs nodes))
(when clashes (return-from main-loop))))))))))
+insert-body-code+))
;;;
;;;
;;;
(defrule deterministic-expansion (dl-with-combined-some-all-rule abox)
(with-clash-handler
(loop-over-active-nodes (node abox)
(when (and (active-p node)
(not (deterministically-expanded-p node)))
(let ((node-changed-p t))
(loop while node-changed-p do
(setf node-changed-p nil)
(unless clashes (perform! (look-for-atoms :node node :node-changed-p node-changed-p)))
(unless clashes (perform! (look-for-ands :node node :node-changed-p node-changed-p)))
(unless clashes (perform! (look-for-ors :node node :node-changed-p node-changed-p)))
(unless clashes (perform! (look-for-somes :node node :node-changed-p node-changed-p)))
(unless clashes (perform! (look-for-at-leasts :node node :node-changed-p node-changed-p))))
(unless clashes
(register-deterministically-expanded abox node)))))
+insert-body-code+))
(defrule focused-deterministic-expansion (dl-with-combined-some-all-rule abox1)
(with-clash-handler
(let ((rule-was-applicable-p t))
(let ((node (select-det-node abox *strategy* language)))
(when node
(loop while rule-was-applicable-p do
(setf rule-was-applicable-p nil)
(unless clashes
(perform! (look-for-atoms :node node :node-changed-p rule-was-applicable-p)))
(unless clashes
(perform! (look-for-ands :node node :node-changed-p rule-was-applicable-p)))
(unless clashes
(perform! (look-for-ors :node node :node-changed-p rule-was-applicable-p)))
(unless clashes
(perform! (look-for-somes :node node :node-changed-p rule-was-applicable-p)))
(unless clashes
(perform! (look-for-at-leasts :node node :node-changed-p rule-was-applicable-p))))
(unless clashes
(register-deterministically-expanded abox node))))
+insert-body-code+)))
| 28,535 | Common Lisp | .lisp | 464 | 32.241379 | 139 | 0.441061 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | af8c3023ab2f34be2083353439bf10eaa9a32366d79f0c56e637a24b61c25305 | 12,532 | [
-1
] |
12,533 | statistics.lisp | lambdamikel_DLMAPS/src/prover/statistics.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(defconstant +specials+
'(*
*TIME-SPEND-IN-GET-NODES*
*TIME-SPEND-IN-GET-CACHE-SAT-NODES*
*TIME-SPEND-IN-GET-OLD-NODES*
*TIME-SPEND-IN-GET-LEAF-NODES*
*TIME-SPEND-IN-GET-DEACTIVATED-NODES*
*TIME-SPEND-IN-GET-BLOCKED-NODES*
*TIME-SPEND-IN-GET-ACTIVE-NODES*
*TIME-SPEND-IN-ABOX-NODES-ITERATOR*
*TIME-SPEND-IN-ABOX-ACTIVE-NODES-ITERATOR*
*TIME-SPEND-IN-ABOX-OLD-NODES-ITERATOR*
*TIME-SPEND-IN-ABOX-LEAF-NODES-ITERATOR*
*TIME-SPEND-IN-ABOX-CACHE-SAT-NODES-ITERATOR*
*TIME-SPEND-IN-ABOX-BLOCKED-NODES-ITERATOR*
*TIME-SPEND-IN-ABOX-DEACTIVATED-NODES-ITERATOR*
*TIME-SPEND-IN-GET-OLDEST-NODE-WITH-UNEXPANDED-ATTRIBUTE-EXISTS-CONCEPTS*
*TIME-SPEND-IN-GET-OLDEST-NODE-WITH-UNEXPANDED-SOME-CONCEPTS*
*TIME-SPEND-IN-GET-OLDEST-NODE-WITH-UNEXPANDED-OR-CONCEPTS*
*TIME-SPEND-IN-GET-OLDEST-NODE-WITH-UNEXPANDED-AT-LEAST-CONCEPTS*
*TIME-SPEND-IN-ABOX-EDGES-ITERATOR*
*TIME-SPEND-IN-GET-EDGES*
*
*TIME-SPEND-IN-MAKE-CREATE-ACTION*
*TIME-SPEND-IN-MAKE-PUT-TO-UNEXPANDED-ACTION*
*TIME-SPEND-IN-MAKE-MOVE-FROM-UNEXPANDED-TO-EXPANDED*
*TIME-SPEND-IN-MAKE-REGISTER-ADDITIONAL-DEPENDENCIES*
*TIME-SPEND-IN-MAKE-CHANGE-STATE-ACTION*
*
*TIME-SPEND-IN-UNDO*
*TIME-SPEND-IN-UNDO-CREATE-EDGE-ACTION*
*TIME-SPEND-IN-UNDO-CREATE-NODE-ACTION*
*TIME-SPEND-IN-UNDO-CHANGE-STATE-ACTION*
*TIME-SPEND-IN-undo-PUT-TO-UNEXPANDED-ACTION*
*TIME-SPEND-IN-undo-MOVE-FROM-UNEXPANDED-TO-EXPANDED-ACTION*
*TIME-SPEND-IN-undo-REGISTER-ADDITIONAL-DEPENDENCIES-ACTION*
*
*TIME-SPEND-IN-REGISTER-CHOICE-POINTS-FOR*
*TIME-SPEND-IN-ADD-A-CHOICE-POINT*
*TIME-SPEND-IN-SET-CHOICE-POINTS*
*TIME-SPEND-IN-GET-CHOICE-POINTS*
*TIME-SPEND-IN-DELETE-CHOICE-POINTS*
*TIME-SPEND-IN-ADD-CHOICE-POINTS-FOR-EDGES*
*
*TIME-SPEND-IN-REGISTER-BLOCKING-BLOCKED*
*TIME-SPEND-IN-UNREGISTER-BLOCKING-BLOCKED*
*TIME-SPEND-IN-ADJUST-BLOCKING-DEPENDENCIES*
*
*TIME-SPEND-IN-ADD-TO-UNEXPANDED*
*TIME-SPEND-IN-ADD-TO-EXPANDED*
*TIME-SPEND-IN-DELETE-FROM-UNEXPANDED*
*TIME-SPEND-IN-DELETE-FROM-EXPANDED*
*
*TIME-SPEND-IN-REGISTER-AS-UNEXPANDED*
*TIME-SPEND-IN-MOVE-FROM-UNEXPANDED-TO-EXPANDED*
*TIME-SPEND-IN-PUT-FROM-EXPANDED-TO-UNEXPANDED*
*
*TIME-SPEND-IN-DELETE-NODE*
*TIME-SPEND-IN-DELETE-EDGE*
*
*TIME-SPEND-IN-REGISTER-ALREADY-KNOWN-TO-BE-SATISFIABLE*
*TIME-SPEND-IN-REGISTER-LABEL-IS-STABLE*
*TIME-SPEND-IN-REGISTER-ADDITIONAL-DEPENDENCIES*
*TIME-SPEND-IN-REGISTER-DETERMINISTICALLY-EXPANDED*
*TIME-SPEND-IN-REGISTER-ALREADY-KNOWN-TO-BE-INCONSISTENT*
*TIME-SPEND-IN-REGISTER-CHOICE-POINTS*
*TIME-SPEND-IN-REGISTER-CACHE-SATISFIABLE*
*TIME-SPEND-IN-UNREGISTER-DETERMINISTICALLY-EXPANDED*
*
*TIME-SPEND-IN-DELETE-NODE*
*TIME-SPEND-IN-MARK-DELETED*
*TIME-SPEND-IN-UNMARK-DELETED*
*TIME-SPEND-IN-ACTIVATE-NODE*
*TIME-SPEND-IN-DEACTIVATE-NODE*
*TIME-SPEND-IN-PUT-FROM-UNEXPANDED-TO-EXPANDED*
*TIME-SPEND-IN-REGISTER-AS-EXPANDED*
*TIME-SPEND-IN-IS-SUCCESSOR-P*
*TIME-SPEND-IN-ADJUST-INDEX-STRUCTURES*
*
*TIME-SPEND-IN-DELETE-FROM-ALL-HEAPS*
*TIME-SPEND-IN-DELETE-FROM-HEAPS*
*TIME-SPEND-IN-ADD-TO-HEAPS*
*
*TIME-SPEND-IN-GET-YOUNGEST-NODE-SATISFYING*
*TIME-SPEND-IN-GET-YOUNGEST-NODE-SATISFYING1*
*TIME-SPEND-IN-GET-OLDEST-NODE-SATISFYING*
*TIME-SPEND-IN-GET-OLDEST-NODE-SATISFYING1*
*TIME-SPEND-IN-GET-OLDEST-OLD-THEN-YOUNGEST-SATISFYING*
*
*TIME-SPEND-IN-ABOX-ENUMERATION*
*TIME-SPEND-IN-INITIAL-ABOX-SATURATION*
*TIME-SPEND-IN-ROLEBOX-APPLICATION*
*TIME-SPEND-IN-ABOX-COMPLETION*
*
*TIME-SPEND-IN-IDENTIFY-STABLE-NODES*
*TIME-SPEND-IN-MODEL-MERGING*
*TIME-SPEND-IN-MAKE-MODELS-FOR-NODES*
*TIME-SPEND-IN-MAKE-MODELS-FOR-OLD-NODES*
*
*TIME-SPEND-IN-DELETE-NON-DET-ASSERTIONS*
*TIME-SPEND-IN-COMPUTE-CORE-MODEL*
*
*TIME-SPEND-IN-BLOCK-NODES*
*TIME-SPEND-IN-POP-ACTIVE-NODES-HEAP*
*
*TIME-SPEND-IN-DETERMINISTIC-EXPANSION*
*TIME-SPEND-IN-SELECT-DET-NODE*
*TIME-SPEND-IN-FOCUSED-DETERMINISTIC-EXPANSION*
*TIME-SPEND-IN-LOOK-FOR-ATOMS*
*TIME-SPEND-IN-LOOK-FOR-ANDS*
*TIME-SPEND-IN-LOOK-FOR-ORS*
*TIME-SPEND-IN-LOOK-FOR-SOMES*
*TIME-SPEND-IN-LOOK-FOR-AT-LEASTS*
*TIME-SPEND-IN-LOOK-FOR-ALLS*
*
*TIME-SPEND-IN-SELECT-OR-CONCEPT*
*TIME-SPEND-IN-SELECT-OR-CONCEPT1*
*TIME-SPEND-IN-SELECT-OPEN-DISJUNCT*
*TIME-SPEND-IN-SELECT-OPEN-DISJUNCT1*
*TIME-SPEND-IN-OR-EXPANSION*
*
*TIME-SPEND-IN-SELECT-SOME-CONCEPT*
*TIME-SPEND-IN-SELECT-SOME-CONCEPT1*
*TIME-SPEND-IN-SOME-EXPANSION*
*TIME-SPEND-IN-COMPUTE-NEW-SOME-SUCCESSOR-LABEL*
*
*TIME-SPEND-IN-SELECT-ATTRIBUTE-EXISTS-CONCEPTS*
*TIME-SPEND-IN-SELECT-ATTRIBUTE-EXISTS-CONCEPTS1*
*TIME-SPEND-IN-FEATURE-EXPANSION*
*TIME-SPEND-IN-COMPUTE-NEW-FEATURE-SUCCESSOR-LABEL*
*
*TIME-SPEND-IN-SELECT-AT-LEAST-CONCEPT*
*TIME-SPEND-IN-SELECT-AT-LEAST-CONCEPT1*
*TIME-SPEND-IN-SIMPLE-AT-LEAST-EXPANSION*
*
*TIME-SPEND-IN-SELECT-VIOLATED-AT-MOST-CONCEPT*
*TIME-SPEND-IN-SIMPLE-AT-MOST-MERGING*
*
*TIME-SPEND-IN-PROVER-INIT-ABOX-SAT-ALCH*
*TIME-SPEND-IN-PROVER-INIT-ABOX-SAT-ALCHF*
*TIME-SPEND-IN-PROVER-INIT-ABOX-SAT-ALCHF-RPLUS*
*TIME-SPEND-IN-PROVER-INIT-ABOX-SAT-ALCHI*
*TIME-SPEND-IN-PROVER-INIT-ABOX-SAT-ALCHN*
*TIME-SPEND-IN-PROVER-INIT-BEFORE-MAIN-ABOX-SAT-ALCH*
*TIME-SPEND-IN-PROVER-INIT-BEFORE-MAIN-ABOX-SAT-ALCHF*
*TIME-SPEND-IN-PROVER-INIT-BEFORE-MAIN-ABOX-SAT-ALCHF-RPLUS*
*TIME-SPEND-IN-PROVER-INIT-BEFORE-MAIN-ABOX-SAT-ALCHI*
*TIME-SPEND-IN-PROVER-INIT-BEFORE-MAIN-ABOX-SAT-ALCHN*
*TIME-SPEND-IN-PROVER-MAIN-ABOX-SAT-ALCH*
*TIME-SPEND-IN-PROVER-MAIN-ABOX-SAT-ALCHF*
*TIME-SPEND-IN-PROVER-MAIN-ABOX-SAT-ALCHF-RPLUS*
*TIME-SPEND-IN-PROVER-MAIN-ABOX-SAT-ALCHI*
*TIME-SPEND-IN-PROVER-MAIN-ABOX-SAT-ALCHN*
*
*TIME-SPEND-IN-PROVER-INIT-ABOX-SAT-ALCI-RA-JEPD*
*TIME-SPEND-IN-PROVER-INIT-ABOX-SAT-ALCI-RA-MINUS*
*TIME-SPEND-IN-PROVER-INIT-CONCEPT-INSTANCES-DL*
*TIME-SPEND-IN-PROVER-INIT-INDIVIDUAL-INSTANCE-P-DL*
*TIME-SPEND-IN-PROVER-MAIN-ABOX-SAT-ALCI-RA-JEPD*
*TIME-SPEND-IN-PROVER-MAIN-ABOX-SAT-ALCI-RA-MINUS*
*
*TIME-SPEND-IN-INDIVIDUAL-INSTANCE-REGISTER-TOLD-CONCEPTS*
*TIME-SPEND-IN-INDIVIDUAL-INSTANCE-INIT-ABOX*
*TIME-SPEND-IN-INDIVIDUAL-INSTANCE-ABOX-SAT*
*TIME-SPEND-IN-INDIVIDUAL-INSTANCE-ROLLBACK*
*TIME-SPEND-IN-INDIVIDUAL-INSTANCE-ROLLBACK2*
*TIME-SPEND-IN-GLOBAL-ROLLBACK*
*))
(defun reset-statistics ()
(setf *initial-concept-sat-cache-hits* 0)
(setf *initial-concept-unsat-cache-hits* 0)
(setf *initial-concept-sat-cache-queries* 0)
(setf *initial-concept-unsat-cache-queries* 0)
(setf *individual-instance-proofs* 0
*obvious-instance-hits* 0
*obvious-non-instance-hits* 0
*all-instance-tests* 0)
(setf *true-abox-consistency-tests* 0)
(setf *true-abox-subsumption-tests* 0)
(setf *mm-queries* 0)
(setf *mm-hits* 0)
(setf *concept-queries* 0)
(setf *true-concept-queries* 0)
(setf *concept-mm-queries* 0)
(setf *concept-mm-hits* 0)
(setf *subsumes-queries* 0)
(setf *true-subsumes-queries* 0)
(setf *subsumes-mm-hits* 0)
(setf *subsumes-ts-hits* 0)
(setf *blocked-nodes* 0)
(setf *created-nodes* 0)
(setf *no-of-undos* 0
*time-spend-in-undo* 0
*time-for-node-creation* 0
*time-for-edge-creation* 0
*sat-cache-hits* 0
*sat-cache-queries* 0)
(dolist (var +specials+)
(unless (eq var '*)
(setf (symbol-value var) 0))))
(defun show-statistics ()
;(describe-object *abox* t)
(format t "~%*** Node: ~A, Concept : ~A ~%" *node* *concept*)
(format t "~%*** Nodes: ~A Active: ~A Edges: ~A ~%"
(length (get-nodes *abox*))
(length (get-active-nodes *abox*))
(length (get-edges *abox*)))
(format t "~%----------------------------------------------")
(format t "~%*** ~7,D UNDOS IN ~7,D SECONDS, AVERAGE : ~20,10F"
*no-of-undos*
(float (/ *time-spend-in-undo* internal-time-units-per-second))
(float (/ (/ *time-spend-in-undo* internal-time-units-per-second)
(max *no-of-undos* 1))))
(format t "~%*** Time For Node Creation : ~10,D"
(float (/ *time-for-node-creation* internal-time-units-per-second)))
(format t "~%*** Time For Edge Creation : ~10,D"
(float (/ *time-for-edge-creation* internal-time-units-per-second)))
(format t "~%*** Blocked vs. Created Nodes : ~10,D of ~10,D / ~10,4F"
*blocked-nodes*
*created-nodes*
(float (/ *blocked-nodes* (max 1 *created-nodes*))))
;;;
;;; Interface (Konzept, Subsumption)
;;;
(format t "~%----------------------------------------------")
(format t "~%*** CONCEPT STATISTICS")
(format t "~%*** Concept Sat Cache Performance : ~10,D of ~10,D / ~10,4F"
(- *concept-queries* *true-concept-queries*) *concept-queries*
(float (/ (- *concept-queries* *true-concept-queries*) (max 1 *concept-queries*))))
(format t "~%*** AND Concept Sat Cache MM Performance : ~10,D of ~10,D / ~10,4F"
*concept-mm-hits* *concept-mm-queries*
(float (/ *concept-mm-hits* (max 1 *concept-mm-queries*))))
(format t "~%----------------------------------------------")
(format t "~%*** SUBSUMPTION STATISTICS")
(format t "~%*** True vs. All Subsumption Tests : ~10,D of ~10,D / ~10,4F"
*true-subsumes-queries*
*subsumes-queries*
(float (/ *true-subsumes-queries* (max 1 *subsumes-queries*))))
(format t "~%*** Told Subsumers Subsumptions Hits : ~10,D of ~10,D / ~10,4F"
*subsumes-ts-hits*
*subsumes-queries*
(float (/ *subsumes-ts-hits* (max 1 *subsumes-queries*))))
(format t "~%*** MM Performance of Rem. Subs. Tests : ~10,D of ~10,D / ~10,4F"
*subsumes-mm-hits*
*true-subsumes-queries*
(float (/ *subsumes-mm-hits* (max 1 *true-subsumes-queries*))))
(format t "~%*** True ABox Subsumption Tests : ~10,D"
*true-abox-subsumption-tests*)
;;;
;;; ABox (Subtableaux, Model-Merging)
;;;
(format t "~%----------------------------------------------")
(format t "~%*** ABOX STATISTICS")
(format t "~%*** True ABox Consistency Tests : ~10,D"
*true-abox-consistency-tests*)
(format t "~%*** Total Unsat Cache Performance : ~10,D of ~10,D / ~10,4F"
*initial-concept-unsat-cache-hits*
*initial-concept-unsat-cache-queries*
(float (/ *initial-concept-unsat-cache-hits* (max 1 *initial-concept-unsat-cache-queries*))))
(format t "~%*** Total Sat Cache Performance : ~10,D of ~10,D / ~10,4F"
*sat-cache-hits*
*sat-cache-queries*
(float (/ *sat-cache-hits* (max 1 *sat-cache-queries*))))
(format t "~% Initial Concept Sat Cache Performance : ~10,D of ~10,D / ~10,4F"
*initial-concept-sat-cache-hits*
*initial-concept-sat-cache-queries*
(float (/ *initial-concept-sat-cache-hits* (max 1 *initial-concept-sat-cache-queries*))))
(format t "~% Initial Concept MM Test Performance : ~10,D of ~10,D / ~10,4F"
*mm-hits*
*mm-queries*
(float (/ *mm-hits* (max 1 *mm-queries*))))
(format t "~%----------------------------------------------")
(format t "~%*** INSTANCE STATISTICS")
(format t "~%*** All Instance Tests : ~10,D" *all-instance-tests*)
(format t "~%*** Obvious Instance Hits : ~10,D / ~10,4F"
*obvious-instance-hits*
(/ *obvious-instance-hits* (max 1 *all-instance-tests*)))
(format t "~%*** Obvious Non Instance Hits : ~10,D / ~10,4F"
*obvious-non-instance-hits*
(/ *obvious-non-instance-hits* (max 1 *all-instance-tests*)))
(format t "~%*** True Instance Proofs : ~10,D / ~10,4F"
*individual-instance-proofs*
(/ *individual-instance-proofs* (max 1 *all-instance-tests*)))
(format t "~%*** PROFILER STATISTICS")
;;;
;;;
;;;
(dolist (var +specials+)
(if (eq var '*)
(format t "~%-------------------------------------------------------------------------------")
(format t "~%*** ~80,A : ~10,4F "
var (float (/ (symbol-value var) internal-time-units-per-second)))))
(terpri))
(reset-statistics)
| 13,198 | Common Lisp | .lisp | 299 | 37.130435 | 103 | 0.623678 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | ccda0a926654614de94a4e29f1f79c41ebdb2864312c58712c98404f641a21af | 12,533 | [
-1
] |
12,534 | abox-nodes.lisp | lambdamikel_DLMAPS/src/prover/abox-nodes.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(defpersistentclass abox-node (substrate-node abox-item)
((avl-key :initform (incf *avl-key-counter*) :reader avl-key)
(address :reader address :initform '(0))
(rev-address :reader rev-address :initform '(0))
(succ-counter :reader succ-counter :initform 0)
(initial-concept :reader initial-concept :initform nil :initarg :initial-concept)
(told-concepts :reader told-concepts :initform nil :initarg :told-concepts)
(cluster-nodes :reader cluster-nodes :initform nil :initarg :cluster-nodes)
;; wird momentan nicht benutzt (s. merging2.lisp; auskommentiert)
(core-model :reader core-model :initform nil) ; entailed information (true in ALL models!)
(ind-models :reader ind-models :initform nil) ; model information (true in THIS model!); evtl. mehrere
;;;
;;; Die (anhand des Knotenlabels) abgeleiteten Attribute (zur Effizienzsteigerung)
;;; werden stets fuer den Stellvertreter gesetzt, da die Iteratoren nur den
;;; Stellvertreter als Knoten zuruckliefern, dessen Label ist aber die Ver-
;;; einigung der Knoten des Clusters!
;;;
;;; Diese Markierungsattribute werden von den Tabregeln gesetzt.
;;;
(deterministically-expanded-p :accessor deterministically-expanded-p :initform nil)
(checked-p :accessor checked-p :initform nil)
(really-satisfiable-p :accessor really-satisfiable-p :initform nil)
(cache-satisfiable-p :accessor cache-satisfiable-p :initform nil)
(realized-p :accessor realized-p :initform nil)
;; noch nicht verwendet
(stable-p :accessor stable-p :initform nil :initarg :stable-p)
;;; determinsitically-expanded-p iff BCP etc. abgeschlossen
;;;
;;; (private) Verwaltungsinfo; nur ueber Kernel bzw. "komplexe" Methoden zugreifbar
;;; (um konsistente Verwaltung sicherzustellen!)
;;;
(blocked-by :initform nil :initarg :blocked-by)
(blocking-for :initform nil :initarg :blocking-for)))
;;;
;;;
;;;
(defmethod root-or-old-p ((node abox-node))
(or (old-p node)
(root-p node)))
(defmethod root-p ((node abox-node))
(= (id node) 1))
;;;
;;;
;;;
#|
(defmethod left-of-p ((a abox-node) (b abox-node))
(if (old-p a)
(if (old-p b)
(< (id a) (id b))
t)
(if (old-p b)
nil
(let ((aa (rev-address a))
(ba (rev-address b)))
(some #'(lambda (a b)
(< a b))
aa ba)))))
|#
(defmethod left-of-p ((a abox-node) (b abox-node))
(if (old-p a)
(if (old-p b)
(< (id a) (id b))
t)
(if (old-p b)
nil
(> (id a) (id b)))))
(defmethod older-p ((a abox-node) (b abox-node))
(< (id a) (id b)))
;;;
;;;
;;;
(defmethod copy-node ((abox abox) (node abox-node) &rest args)
(declare (ignorable args))
(let ((copy (call-next-method))
(state (get-state-vector node)))
(set-state-vector copy state nil)
(dolist (slot '(old-p
active-p
deleted-p
address
rev-address
succ-counter
choice-points
;;; mit denen kann man zwar nicht weiterrechnen (da Referenzen auf
;;; alte Objekte enthalten!), aber gut fuer Inspektionszwecke!
precondition-for-actions
postcondition-for-actions
created-by
;;;
initial-concept
told-concepts
cluster-nodes
core-model
ind-models
deterministically-expanded-p
checked-p
really-satisfiable-p
cache-satisfiable-p
realized-p
stable-p
blocked-by
blocking-for))
(setf (slot-value copy slot) (copy-tree (slot-value node slot))))
copy))
;;;
;;;
;;;
(defmethod unparse ((item abox-node))
(name item))
(defmethod get-abox ((node abox-node))
(in-graph node))
(defmethod reset-sat-status ((node abox-node))
(dolist (slot '(initial-concept
choice-points
core-model
ind-models
really-satisfiable-p
cache-satisfiable-p
realized-p
stable-p
blocked-by
blocking-for))
(setf (slot-value node slot) nil))
(reset-label (description node))
(reset-sat-status (in-graph node)))
;;;
;;; Macros fuer Label-Verwaltung
;;;
(defmacro loop-over-node-slot ((var node slot) &rest body)
#+:use-avl-trees-for-labels
`(loop-over-avl-tree (,var (slot-value (description ,node) ',slot))
,@body)
#-:use-avl-trees-for-labels
`(dolist (,var (slot-value (description ,node) ',slot))
,@body))
;;;
;;;
;;;
(defmacro loop-over-cluster-nodes ((var node &optional (consider-cluster-p t)) &body body)
(if consider-cluster-p
`(dolist (,var (cluster-nodes ,node))
,@body)
`(let ((,var ,node))
,@body)))
(defmacro loop-over-node-unexpanded-atomic-concepts ((var node &optional (consider-cluster-p t)) &rest body)
`(loop-over-cluster-nodes (equi ,node ,consider-cluster-p)
(loop-over-node-slot (,var equi unexpanded-atomic-concepts) ,@body)))
(defmacro loop-over-node-unexpanded-some-concepts ((var node &optional (consider-cluster-p t)) &rest body)
`(loop-over-cluster-nodes (equi ,node ,consider-cluster-p)
(loop-over-node-slot (,var equi unexpanded-some-concepts) ,@body)))
(defmacro loop-over-node-unexpanded-attribute-exists-concepts ((var node &optional (consider-cluster-p t)) &rest body)
`(loop-over-cluster-nodes (equi ,node ,consider-cluster-p)
(loop-over-node-slot (,var equi unexpanded-attribute-exists-concepts) ,@body)))
(defmacro loop-over-node-unexpanded-at-least-concepts ((var node &optional (consider-cluster-p t)) &rest body)
`(loop-over-cluster-nodes (equi ,node ,consider-cluster-p)
(loop-over-node-slot (,var equi unexpanded-at-least-concepts) ,@body)))
(defmacro loop-over-node-unexpanded-at-most-concepts ((var node &optional (consider-cluster-p t)) &rest body)
`(loop-over-cluster-nodes (equi ,node ,consider-cluster-p)
(loop-over-node-slot (,var equi unexpanded-at-most-concepts) ,@body)))
(defmacro loop-over-node-unexpanded-all-concepts ((var node &optional (consider-cluster-p t)) &rest body)
`(loop-over-cluster-nodes (equi ,node ,consider-cluster-p)
(loop-over-node-slot (,var equi unexpanded-all-concepts) ,@body)))
(defmacro loop-over-node-unexpanded-and-concepts ((var node &optional (consider-cluster-p t)) &rest body)
`(loop-over-cluster-nodes (equi ,node ,consider-cluster-p)
(loop-over-node-slot (,var equi unexpanded-and-concepts) ,@body)))
(defmacro loop-over-node-unexpanded-or-concepts ((var node &optional (consider-cluster-p t)) &rest body)
`(loop-over-cluster-nodes (equi ,node ,consider-cluster-p)
(loop-over-node-slot (,var equi unexpanded-or-concepts) ,@body)))
;;;
;;;
;;;
(defmacro loop-over-node-unexpanded-concepts ((var node &optional (consider-cluster-p t)) &rest body)
(let ((label (gensym)))
`(labels ((,label (,var ,node)
(declare (ignorable ,var ,node))
,@body))
(loop-over-cluster-nodes (equi ,node ,consider-cluster-p)
(loop-over-node-slot (,var equi unexpanded-atomic-concepts) (,label ,var ,node))
(loop-over-node-slot (,var equi unexpanded-and-concepts) (,label ,var ,node))
(loop-over-node-slot (,var equi unexpanded-or-concepts) (,label ,var ,node))
(loop-over-node-slot (,var equi unexpanded-all-concepts) (,label ,var ,node))
(loop-over-node-slot (,var equi unexpanded-some-concepts) (,label ,var ,node))
(loop-over-node-slot (,var equi unexpanded-attribute-exists-concepts) (,label ,var ,node))
(loop-over-node-slot (,var equi unexpanded-at-least-concepts) (,label ,var ,node))
(loop-over-node-slot (,var equi unexpanded-at-most-concepts) (,label ,var ,node))))))
;;;
;;;
;;;
(defmacro loop-over-node-expanded-atomic-concepts ((var node &optional (consider-cluster-p t)) &rest body)
`(loop-over-cluster-nodes (equi ,node ,consider-cluster-p)
(loop-over-node-slot (,var equi expanded-atomic-concepts) ,@body)))
(defmacro loop-over-node-expanded-some-concepts ((var node &optional (consider-cluster-p t)) &rest body)
`(loop-over-cluster-nodes (equi ,node ,consider-cluster-p)
(loop-over-node-slot (,var equi expanded-some-concepts) ,@body)))
(defmacro loop-over-node-expanded-attribute-exists-concepts ((var node &optional (consider-cluster-p t)) &rest body)
`(loop-over-cluster-nodes (equi ,node ,consider-cluster-p)
(loop-over-node-slot (,var equi expanded-attribute-exists-concepts) ,@body)))
(defmacro loop-over-node-expanded-at-least-concepts ((var node &optional (consider-cluster-p t)) &rest body)
`(loop-over-cluster-nodes (equi ,node ,consider-cluster-p)
(loop-over-node-slot (,var equi expanded-at-least-concepts) ,@body)))
(defmacro loop-over-node-expanded-at-most-concepts ((var node &optional (consider-cluster-p t)) &rest body)
`(loop-over-cluster-nodes (equi ,node ,consider-cluster-p)
(loop-over-node-slot (,var equi expanded-at-most-concepts) ,@body)))
(defmacro loop-over-node-expanded-all-concepts ((var node &optional (consider-cluster-p t)) &rest body)
`(loop-over-cluster-nodes (equi ,node ,consider-cluster-p)
(loop-over-node-slot (,var equi expanded-all-concepts) ,@body)))
(defmacro loop-over-node-expanded-and-concepts ((var node &optional (consider-cluster-p t)) &rest body)
`(loop-over-cluster-nodes (equi ,node ,consider-cluster-p)
(loop-over-node-slot (,var equi expanded-and-concepts) ,@body)))
(defmacro loop-over-node-expanded-or-concepts ((var node &optional (consider-cluster-p t)) &rest body)
`(loop-over-cluster-nodes (equi ,node ,consider-cluster-p)
(loop-over-node-slot (,var equi expanded-or-concepts) ,@body)))
(defmacro loop-over-node-expanded-concepts ((var node &optional (consider-cluster-p t)) &rest body)
(let ((label (gensym)))
`(labels ((,label (,var ,node)
(declare (ignorable ,var ,node))
,@body))
(loop-over-cluster-nodes (equi ,node ,consider-cluster-p)
(loop-over-node-slot (,var equi expanded-atomic-concepts) (,label ,var ,node))
(loop-over-node-slot (,var equi expanded-and-concepts) (,label ,var ,node))
(loop-over-node-slot (,var equi expanded-or-concepts) (,label ,var ,node))
(loop-over-node-slot (,var equi expanded-all-concepts) (,label ,var ,node))
(loop-over-node-slot (,var equi expanded-some-concepts) (,label ,var ,node))
(loop-over-node-slot (,var equi expanded-attribute-exists-concepts) (,label ,var ,node))
(loop-over-node-slot (,var equi expanded-at-least-concepts) (,label ,var ,node))
(loop-over-node-slot (,var equi expanded-at-most-concepts) (,label ,var ,node))))))
;;;
;;;
;;;
(defmacro loop-over-node-concepts ((var node &optional (consider-cluster-p t)) &rest body)
(let ((label (gensym)))
`(labels ((,label (,var ,node)
(declare (ignorable ,var ,node))
,@body))
(loop-over-node-unexpanded-concepts (,var ,node ,consider-cluster-p) (,label ,var ,node))
(loop-over-node-expanded-concepts (,var ,node ,consider-cluster-p) (,label ,var ,node)))))
(defmacro loop-over-node-all-concepts ((var node &optional (consider-cluster-p t)) &rest body)
(let ((label (gensym)))
`(labels ((,label (,var ,node)
(declare (ignorable ,var ,node))
,@body))
(loop-over-node-unexpanded-all-concepts (,var ,node ,consider-cluster-p) (,label ,var ,node))
(loop-over-node-expanded-all-concepts (,var ,node ,consider-cluster-p) (,label ,var ,node)))))
;;;
;;;
;;;
(defmacro every-unexpanded-concept-satisfies (node predicate &optional (consider-cluster-p t))
(let ((blockname (gensym)))
`(block ,blockname
(progn
(loop-over-node-unexpanded-concepts (x ,node ,consider-cluster-p)
(unless (,predicate x)
(return-from ,blockname nil)))
t))))
(defmacro some-unexpanded-concept-satisfies (node predicate &optional (consider-cluster-p))
(let ((blockname (gensym)))
`(block ,blockname
(progn
(loop-over-node-unexpanded-concepts (x ,node ,consider-cluster-p)
(when (,predicate x)
(return-from ,blockname t)))
nil))))
;;;
;;;
;;;
(defmethod has-unexpanded-concepts-p ((node abox-node) &optional (consider-cluster-p t))
(some #'(lambda (node)
(has-unexpanded-concepts-p (description node)))
(if consider-cluster-p
(cluster-nodes node)
(list node))))
(defmethod has-expanded-concepts-p ((node abox-node) &optional (consider-cluster-p t))
(some #'(lambda (node)
(has-expanded-concepts-p (description node)))
(if consider-cluster-p
(cluster-nodes node)
(list node))))
(defmethod has-unexpanded-some-concepts-p ((node abox-node) &optional (consider-cluster-p t))
(some #'(lambda (node)
(has-unexpanded-some-concepts-p (description node)))
(if consider-cluster-p
(cluster-nodes node)
(list node))))
(defmethod has-unexpanded-all-concepts-p ((node abox-node) &optional (consider-cluster-p t))
(some #'(lambda (node)
(has-unexpanded-all-concepts-p (description node)))
(if consider-cluster-p
(cluster-nodes node)
(list node))))
(defmethod has-unexpanded-and-concepts-p ((node abox-node) &optional (consider-cluster-p t))
(some #'(lambda (node)
(has-unexpanded-and-concepts-p (description node)))
(if consider-cluster-p
(cluster-nodes node)
(list node))))
(defmethod has-unexpanded-atomic-concepts-p ((node abox-node) &optional (consider-cluster-p t))
(some #'(lambda (node)
(has-unexpanded-atomic-concepts-p (description node)))
(if consider-cluster-p
(cluster-nodes node)
(list node))))
(defmethod has-unexpanded-or-concepts-p ((node abox-node) &optional (consider-cluster-p t))
(some #'(lambda (node)
(has-unexpanded-or-concepts-p (description node)))
(if consider-cluster-p
(cluster-nodes node)
(list node))))
(defmethod has-unexpanded-attribute-exists-concepts-p ((node abox-node) &optional (consider-cluster-p t))
(some #'(lambda (node)
(has-unexpanded-attribute-exists-concepts-p (description node)))
(if consider-cluster-p
(cluster-nodes node)
(list node))))
(defmethod has-unexpanded-at-least-concepts-p ((node abox-node) &optional (consider-cluster-p t))
(some #'(lambda (node)
(has-unexpanded-at-least-concepts-p (description node)))
(if consider-cluster-p
(cluster-nodes node)
(list node))))
(defmethod has-unexpanded-at-most-concepts-p ((node abox-node) &optional (consider-cluster-p t))
(some #'(lambda (node)
(has-unexpanded-at-most-concepts-p (description node)))
(if consider-cluster-p
(cluster-nodes node)
(list node))))
;;;
;;;
;;;
(defmethod has-unexpanded-generating-concepts-p ((node abox-node) &rest args)
(or (apply #'has-unexpanded-some-concepts-p node args)
(apply #'has-unexpanded-attribute-exists-concepts-p node args)
(apply #'has-unexpanded-at-least-concepts-p node args)))
;;;
;;;
;;;
(defmacro on-tableau-p (node concept &optional (consider-cluster-p t))
`(some #'(lambda (equi)
(or (concept-member (description equi) ,concept expanded)
(concept-member (description equi) ,concept unexpanded)))
,(if consider-cluster-p
`(cluster-nodes ,node)
`(list ,node))))
(defmacro expanded-p (node concept &optional (consider-cluster-p t))
`(some #'(lambda (equi)
(concept-member (description equi) ,concept expanded))
,(if consider-cluster-p
`(cluster-nodes ,node)
`(list ,node))))
(defmacro unexpanded-p (node concept &optional (consider-cluster-p t))
`(some #'(lambda (equi)
(concept-member (description equi) ,concept unexpanded))
,(if consider-cluster-p
`(cluster-nodes ,node)
`(list ,node))))
;;;
;;;
;;;
(defmethod complete-p ((node abox-node) &optional (consider-cluster-p t))
(every #'(lambda (node) (complete-p (description node)))
(if consider-cluster-p
(cluster-nodes node)
(list node))))
;;;
;;;
;;;
(defmethod already-known-to-be-inconsistent-p ((abox-node abox-node))
(when (initial-concept abox-node)
(already-known-to-be-inconsistent-p (initial-concept abox-node))))
(defmethod already-known-to-be-tautological-p ((abox-node abox-node))
(when (initial-concept abox-node)
(already-known-to-be-tautological-p (initial-concept abox-node))))
(defmethod already-known-to-be-satisfiable-p ((abox-node abox-node))
(when (initial-concept abox-node)
(already-known-to-be-satisfiable-p (initial-concept abox-node))))
;;;
;;;
;;;
(defmethod compute-virtual-successors ((abox abox) (node abox-node) &optional role)
(declare (ignorable role))
nil)
(defmethod materialize-virtual-edge ((abox abox) (node abox-node) (succ abox-node) role)
(declare (ignorable role))
nil)
| 18,644 | Common Lisp | .lisp | 388 | 38.574742 | 122 | 0.614208 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 97c805d51bbc54d8876e26c638b980b65a68737908ad27fa9a6069bb89222110 | 12,534 | [
-1
] |
12,535 | krss.lisp | lambdamikel_DLMAPS/src/prover/krss.lisp | ;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;; hier sind auch einige Funktionen nach Racer benannt!
;;;
(defmacro implies (left right)
`(progn
;(impl (not ,right) (not ,left))
(impl ,left ,right)))
(defmacro equivalent (left right)
`(equi ,left ,right))
(defmacro disjoint (&rest concepts)
(unless (cdr concepts)
(error "DISJOINT needs at least 2 concepts!"))
`(progn
,@(mapcar #'(lambda (concept)
`(impl ,concept
(and ,@(mapcar #'(lambda (x)
`(not ,x))
(remove concept concepts)))))
concepts)))
;;;
;;;
;;;
(defmacro define-primitive-concept (left &optional (right 'top))
`(def* ,left ,right))
(defmacro defprimconcept (left &optional (right 'top))
`(define-primitive-concept ,left ,right))
(defmacro define-concept (left &optional right)
(if right
`(def ,left ,right)
`(def* ,left)))
(defmacro defconcept (left &optional right)
`(define-concept ,left ,right))
;;;
;;;
;;;
(defmacro primitive-concept? (concept)
`(primitive-concept-p ',concept))
(defmacro defined-concept? (concept)
`(defined-concept-p ',concept))
;;;
;;;
;;;
(defmacro define-primitive-role (role &rest args)
`(defrole ,role ,@args))
(defmacro define-primitive-attribute (role &rest args)
`(deffeature ,role ,@args))
;;;
;;;
;;;
(defmacro instance (name def &optional abox &rest args)
`(with-abox* ((or ',abox *cur-abox*))
(ins ,name ,def ,@args)))
(defmacro db-instance (name def &optional abox &rest args)
`(with-abox* ((or ',abox *cur-abox*))
(ins ,name ,def
:update-db-p t
:type 'db-abox-node ,@args)))
(defmacro forget (name def &optional abox &rest args)
`(with-abox* ((or ',abox *cur-abox*))
(for ,name ,def ,@args)))
(defmacro db-forget (name def &optional abox &rest args)
`(with-abox* ((or ',abox *cur-abox*))
(for ,name ,def
:update-db-p t ,@args)))
(defmacro related (a b role &optional abox &rest args)
`(with-abox* ((or ',abox *cur-abox*))
(rel ,a ,b ,role ,@args)))
(defmacro db-related (a b role &optional abox &rest args)
`(with-abox* ((or ',abox *cur-abox*))
(rel ,a ,b ,role
:type 'db-abox-edge
:node-type 'db-abox-node
:update-db-p t
,@args)))
(defmacro unrelated (a b role &optional abox &rest args)
`(with-abox* ((or ',abox *cur-abox*))
(unrel ,a ,b ,role ,@args)))
(defmacro db-unrelated (a b role &optional abox &rest args)
`(with-abox* ((or ',abox *cur-abox*))
(unrel ,a ,b ,role
:look-into-db-p nil
:update-db-p t
,@args)))
;;;
;;;
;;;
(defmacro db-del (name &rest args)
`(delete-node *cur-abox* ',name
:look-into-db-p t
:update-db-p t
,@args))
;;;
;;;
;;;
(defun add-concept-assertion (abox ind concept)
(with-abox* (abox :delete-if-exists-p nil)
(node-instance ind concept)))
(defun forget-concept-assertion (abox ind concept)
(with-abox* (abox :delete-if-exists-p nil)
(node-forget ind concept)))
(defun add-role-assertion (abox from to role)
(with-abox* (abox :delete-if-exists-p nil)
(relate from to role)))
(defun forget-role-assertion (abox from to role)
(with-abox* (abox :delete-if-exists-p nil)
(unrelate from to role)))
;;;
;;;
;;;
(defun init-abox (&optional (abox (name *cur-abox*)))
(in-abox* abox :delete-if-exists-p t))
(defun init-tbox (&optional (tbox (name *cur-tbox*)))
(in-tbox* tbox :delete-if-exists-p t))
;;;
;;;
;;;
(defun set-current-abox (&optional (abox (name *cur-abox*)))
(in-abox* abox :delete-if-exists-p nil))
(defun set-current-tbox (&optional (tbox (name *cur-tbox*)))
(in-tbox* tbox :delete-if-exists-p nil))
;;;
;;;
;;;
(defun tbox-coherent-p (&optional (tbox *cur-tbox*) &rest args)
(apply #'tbox-sat-p tbox args))
(defun classify-tbox (&optional (tbox *cur-tbox*) &rest args)
(apply #'classify tbox args))
;;;
;;;
;;;
(defun concept-satisfiable-p (concept &rest args)
(apply #'sat-p concept args))
(defun concept-subsumes-p (concept1 concept2 &rest args)
(apply #'subsumes-p concept1 concept2 args))
(defmethod concept-disjoint-p (concept1 concept2 &rest args &key tbox &allow-other-keys)
(let ((*cur-store* (if tbox
(concept-store (find-tbox tbox :error-p t))
(concept-store *cur-tbox*))))
(apply #'concept-disjoint-p
(parse-concept concept1)
(parse-concept concept2) args)))
(defmethod concept-disjoint-p ((concept1 concept) (concept2 concept) &rest args)
(not (apply #'sat-p
(make-and-concept (list concept1 concept2)) args)))
(defun concept-equivalent-p (concept1 concept2 &rest args)
(apply #'equivalent-p concept1 concept2 args))
;;;
;;;
;;;
(defmacro concept-satisfiable? (expr &rest args)
`(concept-satisfiable-p (quote ,expr) ,@args))
(defmacro concept-subsumes? (concept1 concept2 &rest args)
`(concept-subsumes-p ',concept1 ',concept2 ,@args))
(defmacro concept-equivalent? (concept1 concept2 &rest args)
`(concept-equivalent-p ',concept1 ',concept2 ,@args))
(defmacro concept-disjoint? (concept1 concept2 &rest args)
`(concept-disjoint-p ',concept1 ',concept2 ,@args))
;;;
;;;
;;;
(defmacro abox-consistent? (&optional abox &rest args)
`(abox-consistent-p (or ',abox *cur-abox*) ,@args))
(defmacro tbox-coherent? (&optional tbox &rest args)
`(tbox-coherent-p (or ',tbox *cur-tbox*) ,@args))
;;;
;;;
;;;
(defmacro tbox-classified? (&optional tbox)
`(tbox-classified-p (find-tbox (or ',tbox *cur-tbox*) :error-p t)))
(defmacro abox-realized? (&optional abox)
`(abox-realized-p (find-abox (or ',abox *cur-abox*) :error-p t)))
;;;
;;;
;;;
(defun all-atomic-concepts (&optional (tbox *cur-tbox*))
(let ((tax (taxonomy (find-tbox tbox :error-p t))))
(mapcar #'node-representation (dag-nodes tax))))
;;;
;;;
;;;
(defun get-concept-parents (concept &optional (tbox *cur-tbox*))
(with-tbox* (tbox)
(parents (parse-concept concept))))
(defun atomic-concept-parents (&rest args)
(apply #'get-concept-parents args))
(defun get-concept-children (concept &optional (tbox *cur-tbox*))
(with-tbox* (tbox)
(children (parse-concept concept))))
(defun atomic-concept-children (&rest args)
(apply #'get-concept-children args))
(defun get-concept-equivalents (concept &optional (tbox *cur-tbox*))
(with-tbox* (tbox)
(equivalents (parse-concept concept))))
(defun atomic-concept-synonyms (&rest args)
(apply #'get-concept-equivalents args))
(defun get-concept-ancestors (concept &optional (tbox *cur-tbox*))
(with-tbox* (tbox)
(ancestors (parse-concept concept))))
(defun atomic-concept-ancestors (&rest args)
(apply #'get-concept-ancestors args))
(defun get-concept-descendants (concept &optional (tbox *cur-tbox*))
(with-tbox* (tbox)
(descendants (parse-concept concept))))
(defun atomic-concept-descendants (&rest args)
(apply #'get-concept-descendants args))
;;;
;;;
;;;
(defmacro concept-parents (concept &optional tbox)
`(get-concept-parents ',concept (or ',tbox *cur-tbox*)))
(defmacro concept-children (concept &optional tbox)
`(get-concept-children ',concept (or ',tbox *cur-tbox*)))
(defmacro concept-equivalents (concept &optional tbox)
`(get-concept-equivalents ',concept (or ',tbox *cur-tbox*)))
(defmacro concept-ancestors (concept &optional tbox)
`(get-concept-ancestors ',concept (or ',tbox *cur-tbox*)))
(defmacro concept-descendants (concept &optional tbox)
`(get-concept-descendants ',concept (or ',tbox *cur-tbox*)))
;;;
;;;
;;;
(defun get-roles (&optional (tbox *cur-tbox*))
(unparse (get-all-roles (find-tbox tbox :error-p t))))
(defun all-roles (&rest args)
(apply #'get-roles args))
(defun get-transitive-roles (&optional (tbox *cur-tbox*))
(unparse (get-all-transitive-roles (find-tbox tbox :error-p t))))
(defun all-transitive-roles (&rest args)
(apply #'get-transitive-roles args))
(defun get-features (&optional (tbox *cur-tbox*))
(unparse (get-all-features (find-tbox tbox :error-p t))))
(defun all-features (&rest args)
(apply #'get-features args))
;;;
;;;
;;;
(defmacro roles (&optional tbox)
`(get-roles (or ',tbox *cur-tbox*)))
(defmacro transitive-roles (&optional tbox)
`(get-transitive-roles (or ',tbox *cur-tbox*)))
(defmacro features (&optional tbox)
`(get-features (or ',tbox *cur-tbox*)))
;;;
;;;
;;;
(defun get-role-parents (role &optional (tbox *cur-tbox*))
(with-concept-store ((concept-store (find-tbox tbox :error-p t)))
(unparse (superroles (parse-role role)))))
(defun atomic-role-parents (&rest args)
(apply #'get-role-parents args))
(defun get-role-children (role &optional (tbox *cur-tbox*))
(with-concept-store ((concept-store (find-tbox tbox :error-p t)))
(unparse (subroles (parse-role role)))))
(defun atomic-role-children (&rest args)
(apply #'get-role-children args))
(defun get-role-ancestors (role &optional (tbox *cur-tbox*))
(with-concept-store ((concept-store (find-tbox tbox :error-p t)))
(unparse (all-superroles (parse-role role)))))
(defun atomic-role-ancestors (&rest args)
(apply #'get-role-ancestors args))
(defun get-role-descendants (role &optional (tbox *cur-tbox*))
(with-concept-store ((concept-store (find-tbox tbox :error-p t)))
(unparse (all-subroles (parse-role role)))))
(defun atomic-role-descendants (&rest args)
(apply #'get-role-descendants args))
;;;
;;;
;;;
(defun atomic-role-inverse (role &optional (tbox *cur-tbox*))
(with-concept-store ((concept-store (find-tbox tbox :error-p t)))
(unparse (get-inverse-role (parse-role role)))))
;;;
;;;
;;;
(defmacro role-parents (role &optional tbox)
`(get-role-parents ',role (or ',tbox *cur-tbox*)))
(defmacro role-children (role &optional tbox)
`(get-role-children ',role (or ',tbox *cur-tbox*)))
(defmacro role-ancestors (role &optional tbox)
`(get-role-ancestors ',role (or ',tbox *cur-tbox*)))
(defmacro role-descendants (role &optional tbox)
`(get-role-descendants ',role (or ',tbox *cur-tbox*)))
;;;
;;;
;;;
(defun role-subsumes-p (r1 r2 &optional (tbox *cur-tbox*))
(with-concept-store ((concept-store
(find-tbox tbox :error-p t)))
(when (member (parse-role r2) (all-subroles (parse-role r1)))
t)))
(defmacro role-subsumes? (r1 r2 &optional tbox)
`(role-subsumes-p ',r1 ',r2 (or ',tbox *cur-tbox*)))
;;;
;;;
;;;
(defun get-concept-assertions (&optional (abox *cur-abox*))
(let ((assertions nil)
(abox (find-abox abox :error-p t)))
(loop-over-abox-nodes (node abox)
(when (old-p node)
(dolist (concept (get-concept-assertions-for-individual node abox))
(push concept assertions))))
assertions))
(defmacro concept-assertions (&optional abox)
`(get-concept-assertions (or ',abox *cur-abox*)))
(defun all-concept-assertions (&rest args)
(apply #'get-concept-assertions args))
;;;
;;;
;;;
(defun get-concept-assertions-for-individual (ind &optional (abox *cur-abox*))
(let ((name (unparse ind)))
(mapcar #'(lambda (x)
(list name x))
(unparse
(told-concepts (find-node
(find-abox abox :error-p t)
ind
:error-p t))))))
(defmacro concept-assertions-for-individual (ind &optional abox)
`(get-concept-assertions-for-individual ',ind (or ',abox *cur-abox*)))
(defun all-concept-assertions-for-individual (&rest args)
(apply #'get-concept-assertions-for-individual args))
;;;
;;;
;;;
(defun individual-p (ind &optional (abox *cur-abox*))
(unparse
(find-node (find-abox abox :error-p t)
ind
:error-p nil)))
(defmacro individual? (ind &optional abox)
`(individual-p ',ind (or ',abox *cur-abox*)))
;;;
;;;
;;;
(defun abox-consistent-p (&optional (abox *cur-abox*) &rest args)
(apply #'abox-sat-p abox args))
;;;
;;;
;;;
(defun individual-instance-p (ind concept &optional (abox *cur-abox*) &rest args)
(apply #'instance-p abox ind concept args))
(defmacro individual-instance? (ind concept &optional abox &rest args)
`(individual-instance-p ',ind ',concept (or ',abox *cur-abox*) ,@args))
;;;
;;;
;;;
(defun get-concept-instances (concept &optional (abox *cur-abox*) &rest args)
(unparse (apply #'retrieve-concept-instances abox concept args)))
(defmacro concept-instances (concept &optional abox &rest args)
`(get-concept-instances ',concept (or ',abox *cur-abox*) ,@args))
;;;
;;;
;;;
(defun get-role-assertions (&optional (abox *cur-abox*))
(let ((assertions nil)
(abox (find-abox abox :error-p t)))
(loop-over-abox-edges (edge abox)
(when (old-p edge)
(push (unparse
(list (list (from edge)
(to edge))
(role edge)))
assertions)))
assertions))
(defmacro role-assertions (&optional abox)
`(get-role-assertions (or ',abox *cur-abox*)))
(defun all-role-assertions (&rest args)
(apply #'get-role-assertions args))
;;;
;;;
;;;
(defun get-all-role-assertions-for-individual-in-domain (ind &optional
(abox *cur-abox*)
role)
(let* ((abox (find-abox abox :error-p t))
(node (find-node abox ind :error-p t))
(assertions nil))
(with-abox* (abox)
(let ((role (and role (parse-role role))))
(dolist (out (outgoing node))
(when (and (old-p out)
(old-p (to out))
(=> role
(eq (role out)
role)))
(push (unparse
(list (list node
(to out))
(role out)))
assertions)))))
assertions))
(defun all-role-assertions-for-individual-in-domain (&rest args)
(apply #'get-all-role-assertions-for-individual-in-domain args))
(defun get-all-role-assertions-for-individual-in-range (ind &optional
(abox *cur-abox*)
role)
(let* ((abox (find-abox abox :error-p t))
(node (find-node abox ind :error-p t))
(assertions nil))
(with-abox* (abox)
(let ((role (and role (parse-role role))))
(dolist (out (incoming node))
(when (and (old-p out)
(old-p (from out))
(=> role
(eq (role out)
role)))
(push (unparse
(list (list (from out)
node)
(role out)))
assertions)))))
assertions))
(defun all-role-assertions-for-individual-in-range (&rest args)
(apply #'get-all-role-assertions-for-individual-in-range args))
;;;
;;;
;;;
(defun get-individual-fillers (ind role &optional (abox *cur-abox*) &rest args)
(unparse (apply #'retrieve-role-fillers abox ind role args)))
(defmacro individual-fillers (ind role &optional abox &rest args)
`(get-individual-fillers ',ind ',role (or ',abox *cur-abox*) ,@args))
;;;
;;;
;;;
(defun individuals-related-p (a b role &optional (abox *cur-abox*) &rest args)
(apply #'related-p abox a b role args))
(defmacro individuals-related? (a b role &optional abox &rest args)
`(individuals-related-p ',a ',b ',role (or ',abox *cur-abox*) ,@args))
;;;
;;;
;;;
(defun get-abox-language (&optional (abox *cur-abox*))
(name (get-language (find-abox abox :error-p t))))
;;;
;;;
;;;
(defun all-individuals (&optional (abox *cur-abox*))
(let ((abox (find-abox abox :error-p t)))
(unparse
(remove-if-not #'old-p (get-nodes abox)))))
;;;
;;;
;;;
(defun get-tbox-version (tbox)
(tbox-version tbox))
(defun get-abox-version (abox)
(abox-version abox))
(defun full-reset ()
(reset-statistics)
(delete-all-aboxes)
(delete-all-tboxes))
;;;
;;; Dummies:
;;;
(defmacro DEFINE-DATATYPE-PROPERTY (&rest args)
(declare (ignorable args))
t)
| 16,678 | Common Lisp | .lisp | 462 | 29.943723 | 89 | 0.612341 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 551fc5e940e9461e54cfb49026b6cbc98d59ab4cb62e44bd55abaab49cb16d31 | 12,535 | [
-1
] |
12,536 | kaon-kb.lisp | lambdamikel_DLMAPS/src/prover/kaon-kb.lisp | (in-package :prover)
(in-knowledge-base example-t-box example-a-box)
(implies (or (some prop7 thing0) thing34) thing3)
(implies (or thing140 (some prop6 thing0)) thing14)
(implies (or thing142 (some prop8 thing0)) thing14)
(implies (or thing320 (some prop6 thing0)) thing32)
(implies (or (some prop3 thing0) thing034) thing03)
(implies (or thing04 (some prop4 thing0)) thing0)
(implies (or (some prop3 thing0) thing412) thing41)
(implies (or thing232 (some prop3 thing0)) thing23)
(implies (or (some prop0 thing0) thing243) thing24)
(implies (or thing100 (some prop2 thing0)) thing10)
(implies (or (some prop7 thing0) thing010) thing01)
(implies (or (some prop9 thing0) thing440) thing44)
(implies (or (some prop9 thing0) thing012) thing01)
(implies (or thing043 (some prop8 thing0)) thing04)
(implies (or (some prop2 thing0) thing20) thing2)
(implies (or (some prop7 thing0) thing11) thing1)
(implies (or (some prop6 thing0) thing122) thing12)
(implies (or thing43 (some prop2 thing0)) thing4)
(implies (or thing324 (some prop0 thing0)) thing32)
(implies (or thing414 (some prop5 thing0)) thing41)
(implies (or thing442 (some prop1 thing0)) thing44)
(implies (or (some prop1 thing0) thing2) *top*)
(implies (or (some prop7 thing0) thing222) thing22)
(implies (or (some prop5 thing0) thing103) thing10)
(implies (or thing333 (some prop5 thing0)) thing33)
(implies (or (some prop6 thing0) thing24) thing2)
(implies (or (some prop5 thing0) thing14) thing1)
(implies (or thing302 (some prop6 thing0)) thing30)
(implies (or thing001 (some prop2 thing0)) thing00)
(implies (or (some prop1 thing0) thing212) thing21)
(implies (or (some prop1 thing0) thing014) thing01)
(implies (or thing032 (some prop1 thing0)) thing03)
(implies (or (some prop1 thing0) thing410) thing41)
(implies (or thing441 (some prop0 thing0)) thing44)
(implies (or (some prop9 thing0) thing404) thing40)
(implies (or (some prop6 thing0) thing01) thing0)
(implies (or thing121 (some prop5 thing0)) thing12)
(implies (or thing0) *top*)
(implies (or (some prop4 thing0) thing40) thing4)
(implies (or (some prop0 thing0) thing013) thing01)
(implies (or thing310 (some prop0 thing0)) thing31)
(implies (or (some prop0 thing0) thing41) thing4)
(implies (or (some prop3 thing0) thing30) thing3)
(implies (or thing220 (some prop5 thing0)) thing22)
(implies (or (some prop6 thing0) thing433) thing43)
(implies (or (some prop6 thing0) thing023) thing02)
(implies (or (some prop5 thing0) thing301) thing30)
(implies (or (some prop2 thing0) thing330) thing33)
(implies (or (some prop8 thing0) thing110) thing11)
(implies (or thing000 (some prop1 thing0)) thing00)
(implies (or thing002 (some prop3 thing0)) thing00)
(implies (or (some prop4 thing0) thing003) thing00)
(implies (or thing342 (some prop0 thing0)) thing34)
(implies (or (some prop1 thing0) thing343) thing34)
(implies (or thing424 (some prop1 thing0)) thing42)
(implies (or (some prop1 thing0) thing10) thing1)
(implies (or thing02 (some prop2 thing0)) thing0)
(implies (or thing141 (some prop7 thing0)) thing14)
(implies (or (some prop2 thing0) thing132) thing13)
(implies (or (some prop8 thing0) thing241) thing24)
(implies (or (some prop0 thing0) thing23) thing2)
(implies (or (some prop9 thing0) thing224) thing22)
(implies (or (some prop5 thing0) thing32) thing3)
(implies (or (some prop1 thing0) thing33) thing3)
(implies (or (some prop3 thing0) thing444) thing44)
(implies (or thing234 (some prop5 thing0)) thing23)
(implies (or (some prop9 thing0) thing111) thing11)
(implies (or (some prop5 thing0) thing004) thing00)
(implies (or (some prop7 thing0) thing420) thing42)
(implies (or thing011 (some prop8 thing0)) thing01)
(implies (or thing204 (some prop7 thing0)) thing20)
(implies (or (some prop7 thing0) thing321) thing32)
(implies (or (some prop8 thing0) thing322) thing32)
(implies (or thing021 (some prop4 thing0)) thing02)
(implies (or (some prop3 thing0) thing214) thing21)
(implies (or thing400 (some prop5 thing0)) thing40)
(implies (or (some prop7 thing0) thing402) thing40)
(implies (or thing313 (some prop3 thing0)) thing31)
(implies (or (some prop9 thing0) thing341) thing34)
(implies (or thing244 (some prop1 thing0)) thing24)
(implies (or thing120 (some prop4 thing0)) thing12)
(implies (or thing240 (some prop7 thing0)) thing24)
(implies (or (some prop4 thing0) thing413) thing41)
(implies (or (some prop7 thing0) thing042) thing04)
(implies (or thing44 (some prop8 thing0)) thing4)
(implies (or thing233 (some prop4 thing0)) thing23)
(implies (or (some prop0 thing0) thing112) thing11)
(implies (or (some prop2 thing0) thing344) thing34)
(implies (or (some prop0 thing0) thing144) thing14)
(implies (or thing114 (some prop2 thing0)) thing11)
(implies (or (some prop4 thing0) thing431) thing43)
(implies (or thing4 (some prop3 thing0)) *top*)
(implies (or (some prop0 thing0) thing1) *top*)
(implies (or (some prop4 thing0) thing134) thing13)
(implies (or thing041 (some prop6 thing0)) thing04)
(implies (or (some prop3 thing0) thing133) thing13)
(implies (or (some prop0 thing0) thing00) thing0)
(implies (or (some prop2 thing0) thing411) thing41)
(implies (or thing022 (some prop5 thing0)) thing02)
(implies (or (some prop6 thing0) thing104) thing10)
(implies (or (some prop9 thing0) thing31) thing3)
(implies (or thing031 (some prop0 thing0)) thing03)
(implies (or thing434 (some prop7 thing0)) thing43)
(implies (or thing242 (some prop9 thing0)) thing24)
(implies (or thing223 (some prop8 thing0)) thing22)
(implies (or (some prop2 thing0) thing033) thing03)
(implies (or (some prop0 thing0) thing423) thing42)
(implies (or (some prop6 thing0) thing334) thing33)
(implies (or (some prop9 thing0) thing13) thing1)
(implies (or thing432 (some prop5 thing0)) thing43)
(implies (or thing102 (some prop4 thing0)) thing10)
(implies (or (some prop8 thing0) thing340) thing34)
(implies (or (some prop7 thing0) thing024) thing02)
(implies (or (some prop8 thing0) thing124) thing12)
(implies (or (some prop9 thing0) thing044) thing04)
(implies (or (some prop9 thing0) thing323) thing32)
(implies (or thing101 (some prop3 thing0)) thing10)
(implies (or (some prop8 thing0) thing03) thing0)
(implies (or (some prop3 thing0) thing12) thing1)
(implies (or (some prop1 thing0) thing131) thing13)
(implies (or thing421 (some prop8 thing0)) thing42)
(implies (or thing130 (some prop0 thing0)) thing13)
(implies (or thing311 (some prop1 thing0)) thing31)
(implies (or (some prop3 thing0) thing331) thing33)
(implies (or thing22 (some prop4 thing0)) thing2)
(implies (or thing213 (some prop2 thing0)) thing21)
(implies (or (some prop6 thing0) thing221) thing22)
(implies (or thing020 (some prop3 thing0)) thing02)
(implies (or (some prop5 thing0) thing202) thing20)
(implies (or thing21 (some prop8 thing0)) thing2)
(implies (or (some prop9 thing0) thing143) thing14)
(implies (or (some prop0 thing0) thing211) thing21)
(implies (or thing123 (some prop7 thing0)) thing12)
(implies (or thing42 (some prop6 thing0)) thing4)
(implies (or thing303 (some prop7 thing0)) thing30)
(implies (or (some prop2 thing0) thing312) thing31)
(implies (or thing332 (some prop4 thing0)) thing33)
(implies (or thing403 (some prop8 thing0)) thing40)
(implies (or thing300 (some prop4 thing0)) thing30)
(implies (or thing210 (some prop9 thing0)) thing21)
(implies (or thing430 (some prop3 thing0)) thing43)
(implies (or (some prop1 thing0) thing230) thing23)
(implies (or thing113 (some prop1 thing0)) thing11)
(implies (or thing314 (some prop4 thing0)) thing31)
(implies (or (some prop9 thing0) thing030) thing03)
(implies (or (some prop6 thing0) thing203) thing20)
(implies (or thing040 (some prop5 thing0)) thing04)
(implies (or thing443 (some prop2 thing0)) thing44)
(implies (or thing231 (some prop2 thing0)) thing23)
(implies (or (some prop6 thing0) thing401) thing40)
(implies (or thing200 (some prop3 thing0)) thing20)
(implies (or (some prop4 thing0) thing201) thing20)
(implies (or thing3 (some prop2 thing0)) *top*)
(implies (or (some prop8 thing0) thing304) thing30)
(implies (or (some prop9 thing0) thing422) thing42)
(instance thing103_8 thing103)
(related thing103_8 thing103_9 prop9)
(instance thing121_6 thing121)
(related thing121_6 thing121_7 prop7)
(instance thing113_3 thing113)
(related thing113_3 thing113_4 prop4)
(instance thing330_6 thing330)
(related thing330_6 thing330_7 prop7)
(instance thing241_8 thing241)
(related thing241_8 thing241_9 prop9)
(instance thing310_7 thing310)
(related thing310_7 thing310_8 prop8)
(instance thing233_8 thing233)
(related thing233_8 thing233_9 prop9)
(instance thing342_0 thing342)
(related thing342_0 thing342_1 prop1)
(instance thing4_6 thing4)
(related thing4_6 thing4_7 prop7)
(instance thing230_5 thing230)
(related thing230_5 thing230_6 prop6)
(instance thing412_8 thing412)
(related thing412_8 thing412_9 prop9)
(instance thing400_9 thing400)
(related thing400_9 thing401_0 prop0)
(instance thing020_9 thing020)
(related thing020_9 thing021_0 prop0)
(instance thing004_0 thing004)
(related thing004_0 thing004_1 prop1)
(instance thing033_5 thing033)
(related thing033_5 thing033_6 prop6)
(instance thing231_5 thing231)
(related thing231_5 thing231_6 prop6)
(instance thing233_4 thing233)
(related thing233_4 thing233_5 prop5)
(instance thing420_1 thing420)
(related thing420_1 thing420_2 prop2)
(instance thing444_7 thing444)
(related thing444_7 thing444_8 prop8)
(instance thing324_3 thing324)
(related thing324_3 thing324_4 prop4)
(instance thing2_5 thing2)
(related thing2_5 thing2_6 prop6)
(instance thing004_8 thing004)
(related thing004_8 thing004_9 prop9)
(instance thing342_7 thing342)
(related thing342_7 thing342_8 prop8)
(instance thing24_6 thing24)
(related thing24_6 thing24_7 prop7)
(instance thing132_5 thing132)
(related thing132_5 thing132_6 prop6)
(instance thing310_2 thing310)
(related thing310_2 thing310_3 prop3)
(instance thing21_6 thing21)
(related thing21_6 thing21_7 prop7)
(instance thing400_2 thing400)
(related thing400_2 thing400_3 prop3)
(instance thing002_3 thing002)
(related thing002_3 thing002_4 prop4)
(instance thing210_7 thing210)
(related thing210_7 thing210_8 prop8)
(instance thing00_1 thing00)
(related thing00_1 thing00_2 prop2)
(instance thing43_8 thing43)
(related thing43_8 thing43_9 prop9)
(instance thing13_1 thing13)
(related thing13_1 thing13_2 prop2)
(instance thing340_7 thing340)
(related thing340_7 thing340_8 prop8)
(instance thing4_8 thing4)
(related thing4_8 thing4_9 prop9)
(instance thing410_9 thing410)
(related thing410_9 thing411_0 prop0)
(instance thing14_5 thing14)
(related thing14_5 thing14_6 prop6)
(instance thing000_6 thing000)
(related thing000_6 thing000_7 prop7)
(instance thing201_8 thing201)
(related thing201_8 thing201_9 prop9)
(instance thing333_8 thing333)
(related thing333_8 thing333_9 prop9)
(instance thing012_8 thing012)
(related thing012_8 thing012_9 prop9)
(instance thing120_7 thing120)
(related thing120_7 thing120_8 prop8)
(instance thing222_6 thing222)
(related thing222_6 thing222_7 prop7)
(instance thing412_1 thing412)
(related thing412_1 thing412_2 prop2)
(instance thing010_6 thing010)
(related thing010_6 thing010_7 prop7)
(instance thing434_6 thing434)
(related thing434_6 thing434_7 prop7)
(instance thing104_1 thing104)
(related thing104_1 thing104_2 prop2)
(instance thing230_9 thing230)
(related thing230_9 thing231_0 prop0)
(instance thing034_5 thing034)
(related thing034_5 thing034_6 prop6)
(instance thing414_6 thing414)
(related thing414_6 thing414_7 prop7)
(instance thing312_6 thing312)
(related thing312_6 thing312_7 prop7)
(instance thing201_0 thing201)
(related thing201_0 thing201_1 prop1)
(instance thing304_7 thing304)
(related thing304_7 thing304_8 prop8)
(instance thing034_2 thing034)
(related thing034_2 thing034_3 prop3)
(instance thing211_6 thing211)
(related thing211_6 thing211_7 prop7)
(instance thing113_4 thing113)
(related thing113_4 thing113_5 prop5)
(instance thing424_3 thing424)
(related thing424_3 thing424_4 prop4)
(instance thing200_3 thing200)
(related thing200_3 thing200_4 prop4)
(instance thing121_2 thing121)
(related thing121_2 thing121_3 prop3)
(instance thing23_1 thing23)
(related thing23_1 thing23_2 prop2)
(instance thing010_9 thing010)
(related thing010_9 thing011_0 prop0)
(instance thing142_5 thing142)
(related thing142_5 thing142_6 prop6)
(instance thing120_3 thing120)
(related thing120_3 thing120_4 prop4)
(instance thing303_5 thing303)
(related thing303_5 thing303_6 prop6)
(instance thing233_0 thing233)
(related thing233_0 thing233_1 prop1)
(instance thing333_0 thing333)
(related thing333_0 thing333_1 prop1)
(instance thing333_7 thing333)
(related thing333_7 thing333_8 prop8)
(instance thing401_3 thing401)
(related thing401_3 thing401_4 prop4)
(instance thing412_2 thing412)
(related thing412_2 thing412_3 prop3)
(instance thing003_9 thing003)
(related thing003_9 thing004_0 prop0)
(instance thing012_6 thing012)
(related thing012_6 thing012_7 prop7)
(instance thing221_6 thing221)
(related thing221_6 thing221_7 prop7)
(instance thing111_2 thing111)
(related thing111_2 thing111_3 prop3)
(instance thing403_7 thing403)
(related thing403_7 thing403_8 prop8)
(instance thing10_2 thing10)
(related thing10_2 thing10_3 prop3)
(instance thing410_3 thing410)
(related thing410_3 thing410_4 prop4)
(instance thing132_8 thing132)
(related thing132_8 thing132_9 prop9)
(instance thing302_5 thing302)
(related thing302_5 thing302_6 prop6)
(instance thing404_9 thing404)
(related thing404_9 thing41_0 prop0)
(instance thing443_1 thing443)
(related thing443_1 thing443_2 prop2)
(instance thing124_7 thing124)
(related thing124_7 thing124_8 prop8)
(instance thing120_2 thing120)
(related thing120_2 thing120_3 prop3)
(instance thing321_0 thing321)
(related thing321_0 thing321_1 prop1)
(instance thing013_9 thing013)
(related thing013_9 thing014_0 prop0)
(instance thing342_3 thing342)
(related thing342_3 thing342_4 prop4)
(instance thing002_9 thing002)
(related thing002_9 thing003_0 prop0)
(instance thing304_5 thing304)
(related thing304_5 thing304_6 prop6)
(instance thing211_4 thing211)
(related thing211_4 thing211_5 prop5)
(instance thing101_7 thing101)
(related thing101_7 thing101_8 prop8)
(instance thing32_3 thing32)
(related thing32_3 thing32_4 prop4)
(instance thing324_0 thing324)
(related thing324_0 thing324_1 prop1)
(instance thing302_3 thing302)
(related thing302_3 thing302_4 prop4)
(instance thing2_7 thing2)
(related thing2_7 thing2_8 prop8)
(instance thing3_6 thing3)
(related thing3_6 thing3_7 prop7)
(instance thing004_1 thing004)
(related thing004_1 thing004_2 prop2)
(instance thing34_4 thing34)
(related thing34_4 thing34_5 prop5)
(instance thing411_9 thing411)
(related thing411_9 thing412_0 prop0)
(instance thing03_0 thing03)
(related thing03_0 thing03_1 prop1)
(instance thing244_9 thing244)
(related thing244_9 thing3_0 prop0)
(instance thing343_8 thing343)
(related thing343_8 thing343_9 prop9)
(instance thing300_3 thing300)
(related thing300_3 thing300_4 prop4)
(instance thing401_1 thing401)
(related thing401_1 thing401_2 prop2)
(instance thing201_7 thing201)
(related thing201_7 thing201_8 prop8)
(instance thing430_7 thing430)
(related thing430_7 thing430_8 prop8)
(instance thing102_1 thing102)
(related thing102_1 thing102_2 prop2)
(instance thing020_7 thing020)
(related thing020_7 thing020_8 prop8)
(instance thing324_8 thing324)
(related thing324_8 thing324_9 prop9)
(instance thing133_6 thing133)
(related thing133_6 thing133_7 prop7)
(instance thing443_8 thing443)
(related thing443_8 thing443_9 prop9)
(instance thing44_1 thing44)
(related thing44_1 thing44_2 prop2)
(instance thing334_4 thing334)
(related thing334_4 thing334_5 prop5)
(instance thing204_2 thing204)
(related thing204_2 thing204_3 prop3)
(instance thing002_4 thing002)
(related thing002_4 thing002_5 prop5)
(instance thing23_2 thing23)
(related thing23_2 thing23_3 prop3)
(instance thing403_4 thing403)
(related thing403_4 thing403_5 prop5)
(instance thing242_0 thing242)
(related thing242_0 thing242_1 prop1)
(instance thing311_6 thing311)
(related thing311_6 thing311_7 prop7)
(instance thing030_6 thing030)
(related thing030_6 thing030_7 prop7)
(instance thing100_0 thing100)
(related thing100_0 thing100_1 prop1)
(instance thing004_9 thing004)
(related thing004_9 thing01_0 prop0)
(instance thing440_8 thing440)
(related thing440_8 thing440_9 prop9)
(instance thing13_0 thing13)
(related thing13_0 thing13_1 prop1)
(instance thing24_8 thing24)
(related thing24_8 thing24_9 prop9)
(instance thing044_6 thing044)
(related thing044_6 thing044_7 prop7)
(instance thing213_6 thing213)
(related thing213_6 thing213_7 prop7)
(instance thing401_7 thing401)
(related thing401_7 thing401_8 prop8)
(instance thing23_9 thing23)
(related thing23_9 thing230_0 prop0)
(instance thing43_2 thing43)
(related thing43_2 thing43_3 prop3)
(instance thing000_9 thing000)
(related thing000_9 thing001_0 prop0)
(instance thing401_4 thing401)
(related thing401_4 thing401_5 prop5)
(instance thing314_3 thing314)
(related thing314_3 thing314_4 prop4)
(instance thing134_3 thing134)
(related thing134_3 thing134_4 prop4)
(instance thing420_5 thing420)
(related thing420_5 thing420_6 prop6)
(instance thing431_0 thing431)
(related thing431_0 thing431_1 prop1)
(instance thing441_3 thing441)
(related thing441_3 thing441_4 prop4)
(instance thing104_9 thing104)
(related thing104_9 thing11_0 prop0)
(instance thing222_3 thing222)
(related thing222_3 thing222_4 prop4)
(instance thing333_1 thing333)
(related thing333_1 thing333_2 prop2)
(instance thing333_6 thing333)
(related thing333_6 thing333_7 prop7)
(instance thing003_1 thing003)
(related thing003_1 thing003_2 prop2)
(instance thing133_2 thing133)
(related thing133_2 thing133_3 prop3)
(instance thing223_1 thing223)
(related thing223_1 thing223_2 prop2)
(instance thing233_1 thing233)
(related thing233_1 thing233_2 prop2)
(instance thing143_4 thing143)
(related thing143_4 thing143_5 prop5)
(instance thing111_1 thing111)
(related thing111_1 thing111_2 prop2)
(instance thing120_0 thing120)
(related thing120_0 thing120_1 prop1)
(instance thing234_8 thing234)
(related thing234_8 thing234_9 prop9)
(instance thing110_5 thing110)
(related thing110_5 thing110_6 prop6)
(instance thing140_9 thing140)
(related thing140_9 thing141_0 prop0)
(instance thing33_8 thing33)
(related thing33_8 thing33_9 prop9)
(instance thing03_4 thing03)
(related thing03_4 thing03_5 prop5)
(instance thing12_5 thing12)
(related thing12_5 thing12_6 prop6)
(instance thing001_2 thing001)
(related thing001_2 thing001_3 prop3)
(instance thing212_5 thing212)
(related thing212_5 thing212_6 prop6)
(instance thing214_8 thing214)
(related thing214_8 thing214_9 prop9)
(instance thing403_6 thing403)
(related thing403_6 thing403_7 prop7)
(instance thing441_7 thing441)
(related thing441_7 thing441_8 prop8)
(instance thing300_7 thing300)
(related thing300_7 thing300_8 prop8)
(instance thing413_4 thing413)
(related thing413_4 thing413_5 prop5)
(instance thing210_4 thing210)
(related thing210_4 thing210_5 prop5)
(instance thing241_0 thing241)
(related thing241_0 thing241_1 prop1)
(instance thing302_7 thing302)
(related thing302_7 thing302_8 prop8)
(instance thing423_1 thing423)
(related thing423_1 thing423_2 prop2)
(instance thing001_1 thing001)
(related thing001_1 thing001_2 prop2)
(instance thing4_0 thing4)
(related thing4_0 thing4_1 prop1)
(instance thing104_6 thing104)
(related thing104_6 thing104_7 prop7)
(instance thing430_2 thing430)
(related thing430_2 thing430_3 prop3)
(instance thing324_5 thing324)
(related thing324_5 thing324_6 prop6)
(instance thing431_8 thing431)
(related thing431_8 thing431_9 prop9)
(instance thing043_3 thing043)
(related thing043_3 thing043_4 prop4)
(instance thing224_2 thing224)
(related thing224_2 thing224_3 prop3)
(instance thing420_0 thing420)
(related thing420_0 thing420_1 prop1)
(instance thing221_7 thing221)
(related thing221_7 thing221_8 prop8)
(instance thing231_8 thing231)
(related thing231_8 thing231_9 prop9)
(instance thing304_1 thing304)
(related thing304_1 thing304_2 prop2)
(instance thing034_1 thing034)
(related thing034_1 thing034_2 prop2)
(instance thing401_6 thing401)
(related thing401_6 thing401_7 prop7)
(instance thing214_1 thing214)
(related thing214_1 thing214_2 prop2)
(instance thing241_5 thing241)
(related thing241_5 thing241_6 prop6)
(instance thing204_8 thing204)
(related thing204_8 thing204_9 prop9)
(instance thing221_9 thing221)
(related thing221_9 thing222_0 prop0)
(instance thing334_1 thing334)
(related thing334_1 thing334_2 prop2)
(instance thing102_0 thing102)
(related thing102_0 thing102_1 prop1)
(instance thing224_3 thing224)
(related thing224_3 thing224_4 prop4)
(instance thing242_6 thing242)
(related thing242_6 thing242_7 prop7)
(instance thing422_0 thing422)
(related thing422_0 thing422_1 prop1)
(instance thing320_0 thing320)
(related thing320_0 thing320_1 prop1)
(instance thing224_4 thing224)
(related thing224_4 thing224_5 prop5)
(instance thing132_3 thing132)
(related thing132_3 thing132_4 prop4)
(instance thing013_3 thing013)
(related thing013_3 thing013_4 prop4)
(instance thing1_7 thing1)
(related thing1_7 thing1_8 prop8)
(instance thing131_7 thing131)
(related thing131_7 thing131_8 prop8)
(instance thing04_0 thing04)
(related thing04_0 thing04_1 prop1)
(instance thing433_8 thing433)
(related thing433_8 thing433_9 prop9)
(instance thing130_2 thing130)
(related thing130_2 thing130_3 prop3)
(instance thing3_1 thing3)
(related thing3_1 thing3_2 prop2)
(instance thing43_9 thing43)
(related thing43_9 thing430_0 prop0)
(instance thing223_6 thing223)
(related thing223_6 thing223_7 prop7)
(instance thing434_9 thing434)
(related thing434_9 thing44_0 prop0)
(instance thing331_0 thing331)
(related thing331_0 thing331_1 prop1)
(instance thing003_3 thing003)
(related thing003_3 thing003_4 prop4)
(instance thing102_8 thing102)
(related thing102_8 thing102_9 prop9)
(instance thing202_0 thing202)
(related thing202_0 thing202_1 prop1)
(instance thing13_8 thing13)
(related thing13_8 thing13_9 prop9)
(instance thing200_6 thing200)
(related thing200_6 thing200_7 prop7)
(instance thing221_1 thing221)
(related thing221_1 thing221_2 prop2)
(instance thing13_5 thing13)
(related thing13_5 thing13_6 prop6)
(instance thing32_2 thing32)
(related thing32_2 thing32_3 prop3)
(instance thing412_9 thing412)
(related thing412_9 thing413_0 prop0)
(instance thing2_1 thing2)
(related thing2_1 thing2_2 prop2)
(instance thing31_6 thing31)
(related thing31_6 thing31_7 prop7)
(instance thing032_9 thing032)
(related thing032_9 thing033_0 prop0)
(instance thing240_2 thing240)
(related thing240_2 thing240_3 prop3)
(instance thing404_7 thing404)
(related thing404_7 thing404_8 prop8)
(instance thing410_1 thing410)
(related thing410_1 thing410_2 prop2)
(instance thing202_1 thing202)
(related thing202_1 thing202_2 prop2)
(instance thing010_7 thing010)
(related thing010_7 thing010_8 prop8)
(instance thing020_1 thing020)
(related thing020_1 thing020_2 prop2)
(instance thing412_3 thing412)
(related thing412_3 thing412_4 prop4)
(instance thing411_0 thing411)
(related thing411_0 thing411_1 prop1)
(instance thing113_7 thing113)
(related thing113_7 thing113_8 prop8)
(instance thing123_2 thing123)
(related thing123_2 thing123_3 prop3)
(instance thing3_9 thing3)
(related thing3_9 thing30_0 prop0)
(instance thing32_7 thing32)
(related thing32_7 thing32_8 prop8)
(instance thing231_6 thing231)
(related thing231_6 thing231_7 prop7)
(instance thing331_5 thing331)
(related thing331_5 thing331_6 prop6)
(instance thing142_2 thing142)
(related thing142_2 thing142_3 prop3)
(instance thing344_1 thing344)
(related thing344_1 thing344_2 prop2)
(instance thing133_1 thing133)
(related thing133_1 thing133_2 prop2)
(instance thing041_6 thing041)
(related thing041_6 thing041_7 prop7)
(instance thing344_4 thing344)
(related thing344_4 thing344_5 prop5)
(instance thing244_5 thing244)
(related thing244_5 thing244_6 prop6)
(instance thing341_1 thing341)
(related thing341_1 thing341_2 prop2)
(instance thing31_3 thing31)
(related thing31_3 thing31_4 prop4)
(instance thing330_8 thing330)
(related thing330_8 thing330_9 prop9)
(instance thing333_9 thing333)
(related thing333_9 thing334_0 prop0)
(instance thing120_5 thing120)
(related thing120_5 thing120_6 prop6)
(instance thing344_6 thing344)
(related thing344_6 thing344_7 prop7)
(instance thing100_4 thing100)
(related thing100_4 thing100_5 prop5)
(instance thing42_7 thing42)
(related thing42_7 thing42_8 prop8)
(instance thing332_2 thing332)
(related thing332_2 thing332_3 prop3)
(instance thing230_7 thing230)
(related thing230_7 thing230_8 prop8)
(instance thing034_0 thing034)
(related thing034_0 thing034_1 prop1)
(instance thing134_6 thing134)
(related thing134_6 thing134_7 prop7)
(instance thing332_9 thing332)
(related thing332_9 thing333_0 prop0)
(instance thing231_9 thing231)
(related thing231_9 thing232_0 prop0)
(instance thing212_4 thing212)
(related thing212_4 thing212_5 prop5)
(instance thing320_7 thing320)
(related thing320_7 thing320_8 prop8)
(instance thing301_8 thing301)
(related thing301_8 thing301_9 prop9)
(instance thing34_9 thing34)
(related thing34_9 thing340_0 prop0)
(instance thing214_6 thing214)
(related thing214_6 thing214_7 prop7)
(instance thing242_8 thing242)
(related thing242_8 thing242_9 prop9)
(instance thing21_9 thing21)
(related thing21_9 thing210_0 prop0)
(instance thing441_5 thing441)
(related thing441_5 thing441_6 prop6)
(instance thing42_2 thing42)
(related thing42_2 thing42_3 prop3)
(instance thing111_7 thing111)
(related thing111_7 thing111_8 prop8)
(instance thing330_3 thing330)
(related thing330_3 thing330_4 prop4)
(instance thing340_8 thing340)
(related thing340_8 thing340_9 prop9)
(instance thing122_9 thing122)
(related thing122_9 thing123_0 prop0)
(instance thing331_7 thing331)
(related thing331_7 thing331_8 prop8)
(instance thing410_8 thing410)
(related thing410_8 thing410_9 prop9)
(instance thing01_0 thing01)
(related thing01_0 thing01_1 prop1)
(instance thing143_5 thing143)
(related thing143_5 thing143_6 prop6)
(instance thing240_3 thing240)
(related thing240_3 thing240_4 prop4)
(instance thing342_4 thing342)
(related thing342_4 thing342_5 prop5)
(instance thing002_6 thing002)
(related thing002_6 thing002_7 prop7)
(instance thing423_2 thing423)
(related thing423_2 thing423_3 prop3)
(instance thing323_4 thing323)
(related thing323_4 thing323_5 prop5)
(instance thing342_9 thing342)
(related thing342_9 thing343_0 prop0)
(instance thing242_5 thing242)
(related thing242_5 thing242_6 prop6)
(instance thing343_2 thing343)
(related thing343_2 thing343_3 prop3)
(instance thing440_3 thing440)
(related thing440_3 thing440_4 prop4)
(instance thing243_1 thing243)
(related thing243_1 thing243_2 prop2)
(instance thing411_6 thing411)
(related thing411_6 thing411_7 prop7)
(instance thing142_7 thing142)
(related thing142_7 thing142_8 prop8)
(instance thing111_9 thing111)
(related thing111_9 thing112_0 prop0)
(instance thing10_1 thing10)
(related thing10_1 thing10_2 prop2)
(instance thing042_7 thing042)
(related thing042_7 thing042_8 prop8)
(instance thing144_4 thing144)
(related thing144_4 thing144_5 prop5)
(instance thing21_2 thing21)
(related thing21_2 thing21_3 prop3)
(instance thing330_0 thing330)
(related thing330_0 thing330_1 prop1)
(instance thing20_5 thing20)
(related thing20_5 thing20_6 prop6)
(instance thing110_9 thing110)
(related thing110_9 thing111_0 prop0)
(instance thing413_9 thing413)
(related thing413_9 thing414_0 prop0)
(instance thing310_4 thing310)
(related thing310_4 thing310_5 prop5)
(instance thing041_4 thing041)
(related thing041_4 thing041_5 prop5)
(instance thing122_8 thing122)
(related thing122_8 thing122_9 prop9)
(instance thing031_3 thing031)
(related thing031_3 thing031_4 prop4)
(instance thing04_4 thing04)
(related thing04_4 thing04_5 prop5)
(instance thing101_0 thing101)
(related thing101_0 thing101_1 prop1)
(instance thing102_5 thing102)
(related thing102_5 thing102_6 prop6)
(instance thing433_9 thing433)
(related thing433_9 thing434_0 prop0)
(instance thing124_8 thing124)
(related thing124_8 thing124_9 prop9)
(instance thing242_2 thing242)
(related thing242_2 thing242_3 prop3)
(instance thing134_0 thing134)
(related thing134_0 thing134_1 prop1)
(instance thing3_0 thing3)
(related thing3_0 thing3_1 prop1)
(instance thing242_9 thing242)
(related thing242_9 thing243_0 prop0)
(instance thing014_8 thing014)
(related thing014_8 thing014_9 prop9)
(instance thing42_6 thing42)
(related thing42_6 thing42_7 prop7)
(instance thing0_1 thing0)
(related thing0_1 thing0_2 prop2)
(instance thing011_1 thing011)
(related thing011_1 thing011_2 prop2)
(instance thing223_9 thing223)
(related thing223_9 thing224_0 prop0)
(instance thing042_3 thing042)
(related thing042_3 thing042_4 prop4)
(instance thing430_9 thing430)
(related thing430_9 thing431_0 prop0)
(instance thing13_3 thing13)
(related thing13_3 thing13_4 prop4)
(instance thing23_7 thing23)
(related thing23_7 thing23_8 prop8)
(instance thing214_3 thing214)
(related thing214_3 thing214_4 prop4)
(instance thing142_1 thing142)
(related thing142_1 thing142_2 prop2)
(instance thing034_7 thing034)
(related thing034_7 thing034_8 prop8)
(instance thing302_1 thing302)
(related thing302_1 thing302_2 prop2)
(instance thing00_4 thing00)
(related thing00_4 thing00_5 prop5)
(instance thing110_3 thing110)
(related thing110_3 thing110_4 prop4)
(instance thing401_0 thing401)
(related thing401_0 thing401_1 prop1)
(instance thing320_9 thing320)
(related thing320_9 thing321_0 prop0)
(instance thing101_1 thing101)
(related thing101_1 thing101_2 prop2)
(instance thing112_4 thing112)
(related thing112_4 thing112_5 prop5)
(instance thing100_7 thing100)
(related thing100_7 thing100_8 prop8)
(instance thing0_4 thing0)
(related thing0_4 thing0_5 prop5)
(instance thing042_1 thing042)
(related thing042_1 thing042_2 prop2)
(instance thing02_8 thing02)
(related thing02_8 thing02_9 prop9)
(instance thing340_9 thing340)
(related thing340_9 thing341_0 prop0)
(instance thing423_8 thing423)
(related thing423_8 thing423_9 prop9)
(instance thing044_5 thing044)
(related thing044_5 thing044_6 prop6)
(instance thing41_5 thing41)
(related thing41_5 thing41_6 prop6)
(instance thing231_2 thing231)
(related thing231_2 thing231_3 prop3)
(instance thing443_3 thing443)
(related thing443_3 thing443_4 prop4)
(instance thing41_7 thing41)
(related thing41_7 thing41_8 prop8)
(instance thing301_1 thing301)
(related thing301_1 thing301_2 prop2)
(instance thing303_9 thing303)
(related thing303_9 thing304_0 prop0)
(instance thing021_2 thing021)
(related thing021_2 thing021_3 prop3)
(instance thing143_3 thing143)
(related thing143_3 thing143_4 prop4)
(instance thing302_4 thing302)
(related thing302_4 thing302_5 prop5)
(instance thing130_4 thing130)
(related thing130_4 thing130_5 prop5)
(instance thing231_1 thing231)
(related thing231_1 thing231_2 prop2)
(instance thing313_3 thing313)
(related thing313_3 thing313_4 prop4)
(instance thing311_2 thing311)
(related thing311_2 thing311_3 prop3)
(instance thing314_1 thing314)
(related thing314_1 thing314_2 prop2)
(instance thing323_0 thing323)
(related thing323_0 thing323_1 prop1)
(instance thing441_4 thing441)
(related thing441_4 thing441_5 prop5)
(instance thing333_4 thing333)
(related thing333_4 thing333_5 prop5)
(instance thing243_8 thing243)
(related thing243_8 thing243_9 prop9)
(instance thing334_9 thing334)
(related thing334_9 thing34_0 prop0)
(instance thing332_6 thing332)
(related thing332_6 thing332_7 prop7)
(instance thing443_2 thing443)
(related thing443_2 thing443_3 prop3)
(instance thing021_1 thing021)
(related thing021_1 thing021_2 prop2)
(instance thing302_0 thing302)
(related thing302_0 thing302_1 prop1)
(instance thing410_7 thing410)
(related thing410_7 thing410_8 prop8)
(instance thing434_0 thing434)
(related thing434_0 thing434_1 prop1)
(instance thing232_8 thing232)
(related thing232_8 thing232_9 prop9)
(instance thing402_6 thing402)
(related thing402_6 thing402_7 prop7)
(instance thing320_3 thing320)
(related thing320_3 thing320_4 prop4)
(instance thing102_6 thing102)
(related thing102_6 thing102_7 prop7)
(instance thing02_3 thing02)
(related thing02_3 thing02_4 prop4)
(instance thing320_4 thing320)
(related thing320_4 thing320_5 prop5)
(instance thing322_3 thing322)
(related thing322_3 thing322_4 prop4)
(instance thing241_1 thing241)
(related thing241_1 thing241_2 prop2)
(instance thing031_7 thing031)
(related thing031_7 thing031_8 prop8)
(instance thing004_2 thing004)
(related thing004_2 thing004_3 prop3)
(instance thing411_4 thing411)
(related thing411_4 thing411_5 prop5)
(instance thing233_9 thing233)
(related thing233_9 thing234_0 prop0)
(instance thing032_1 thing032)
(related thing032_1 thing032_2 prop2)
(instance thing034_4 thing034)
(related thing034_4 thing034_5 prop5)
(instance thing310_0 thing310)
(related thing310_0 thing310_1 prop1)
(instance thing4_1 thing4)
(related thing4_1 thing4_2 prop2)
(instance thing40_2 thing40)
(related thing40_2 thing40_3 prop3)
(instance thing43_7 thing43)
(related thing43_7 thing43_8 prop8)
(instance thing300_9 thing300)
(related thing300_9 thing301_0 prop0)
(instance thing322_5 thing322)
(related thing322_5 thing322_6 prop6)
(instance thing32_8 thing32)
(related thing32_8 thing32_9 prop9)
(instance thing422_7 thing422)
(related thing422_7 thing422_8 prop8)
(instance thing231_0 thing231)
(related thing231_0 thing231_1 prop1)
(instance thing444_1 thing444)
(related thing444_1 thing444_2 prop2)
(instance thing233_5 thing233)
(related thing233_5 thing233_6 prop6)
(instance thing312_3 thing312)
(related thing312_3 thing312_4 prop4)
(instance thing440_9 thing440)
(related thing440_9 thing441_0 prop0)
(instance thing442_7 thing442)
(related thing442_7 thing442_8 prop8)
(instance thing123_3 thing123)
(related thing123_3 thing123_4 prop4)
(instance thing432_9 thing432)
(related thing432_9 thing433_0 prop0)
(instance thing43_1 thing43)
(related thing43_1 thing43_2 prop2)
(instance thing12_1 thing12)
(related thing12_1 thing12_2 prop2)
(instance thing422_3 thing422)
(related thing422_3 thing422_4 prop4)
(instance thing130_0 thing130)
(related thing130_0 thing130_1 prop1)
(instance thing444_6 thing444)
(related thing444_6 thing444_7 prop7)
(instance thing033_8 thing033)
(related thing033_8 thing033_9 prop9)
(instance thing014_3 thing014)
(related thing014_3 thing014_4 prop4)
(instance thing210_0 thing210)
(related thing210_0 thing210_1 prop1)
(instance thing033_3 thing033)
(related thing033_3 thing033_4 prop4)
(instance thing444_0 thing444)
(related thing444_0 thing444_1 prop1)
(instance thing02_4 thing02)
(related thing02_4 thing02_5 prop5)
(instance thing121_9 thing121)
(related thing121_9 thing122_0 prop0)
(instance thing013_1 thing013)
(related thing013_1 thing013_2 prop2)
(instance thing04_3 thing04)
(related thing04_3 thing04_4 prop4)
(instance thing122_4 thing122)
(related thing122_4 thing122_5 prop5)
(instance thing01_1 thing01)
(related thing01_1 thing01_2 prop2)
(instance thing303_0 thing303)
(related thing303_0 thing303_1 prop1)
(instance thing423_9 thing423)
(related thing423_9 thing424_0 prop0)
(instance thing000_8 thing000)
(related thing000_8 thing000_9 prop9)
(instance thing434_7 thing434)
(related thing434_7 thing434_8 prop8)
(instance thing33_6 thing33)
(related thing33_6 thing33_7 prop7)
(instance thing323_2 thing323)
(related thing323_2 thing323_3 prop3)
(instance thing012_4 thing012)
(related thing012_4 thing012_5 prop5)
(instance thing11_0 thing11)
(related thing11_0 thing11_1 prop1)
(instance thing01_8 thing01)
(related thing01_8 thing01_9 prop9)
(instance thing21_0 thing21)
(related thing21_0 thing21_1 prop1)
(instance thing124_3 thing124)
(related thing124_3 thing124_4 prop4)
(instance thing430_3 thing430)
(related thing430_3 thing430_4 prop4)
(instance thing20_4 thing20)
(related thing20_4 thing20_5 prop5)
(instance thing131_5 thing131)
(related thing131_5 thing131_6 prop6)
(instance thing422_2 thing422)
(related thing422_2 thing422_3 prop3)
(instance thing24_9 thing24)
(related thing24_9 thing240_0 prop0)
(instance thing200_9 thing200)
(related thing200_9 thing201_0 prop0)
(instance thing312_7 thing312)
(related thing312_7 thing312_8 prop8)
(instance thing112_3 thing112)
(related thing112_3 thing112_4 prop4)
(instance thing144_1 thing144)
(related thing144_1 thing144_2 prop2)
(instance thing04_2 thing04)
(related thing04_2 thing04_3 prop3)
(instance thing402_0 thing402)
(related thing402_0 thing402_1 prop1)
(instance thing330_5 thing330)
(related thing330_5 thing330_6 prop6)
(instance thing441_8 thing441)
(related thing441_8 thing441_9 prop9)
(instance thing200_5 thing200)
(related thing200_5 thing200_6 prop6)
(instance thing143_7 thing143)
(related thing143_7 thing143_8 prop8)
(instance thing101_3 thing101)
(related thing101_3 thing101_4 prop4)
(instance thing240_5 thing240)
(related thing240_5 thing240_6 prop6)
(instance thing44_9 thing44)
(related thing44_9 thing440_0 prop0)
(instance thing441_1 thing441)
(related thing441_1 thing441_2 prop2)
(instance thing030_3 thing030)
(related thing030_3 thing030_4 prop4)
(instance thing314_6 thing314)
(related thing314_6 thing314_7 prop7)
(instance thing024_8 thing024)
(related thing024_8 thing024_9 prop9)
(instance thing44_2 thing44)
(related thing44_2 thing44_3 prop3)
(instance thing311_3 thing311)
(related thing311_3 thing311_4 prop4)
(instance thing224_1 thing224)
(related thing224_1 thing224_2 prop2)
(instance thing22_5 thing22)
(related thing22_5 thing22_6 prop6)
(instance thing232_9 thing232)
(related thing232_9 thing233_0 prop0)
(instance thing343_9 thing343)
(related thing343_9 thing344_0 prop0)
(instance thing223_5 thing223)
(related thing223_5 thing223_6 prop6)
(instance thing124_1 thing124)
(related thing124_1 thing124_2 prop2)
(instance thing143_2 thing143)
(related thing143_2 thing143_3 prop3)
(instance thing10_3 thing10)
(related thing10_3 thing10_4 prop4)
(instance thing402_7 thing402)
(related thing402_7 thing402_8 prop8)
(instance thing104_3 thing104)
(related thing104_3 thing104_4 prop4)
(instance thing202_3 thing202)
(related thing202_3 thing202_4 prop4)
(instance thing420_6 thing420)
(related thing420_6 thing420_7 prop7)
(instance thing34_0 thing34)
(related thing34_0 thing34_1 prop1)
(instance thing413_8 thing413)
(related thing413_8 thing413_9 prop9)
(instance thing101_4 thing101)
(related thing101_4 thing101_5 prop5)
(instance thing104_5 thing104)
(related thing104_5 thing104_6 prop6)
(instance thing212_3 thing212)
(related thing212_3 thing212_4 prop4)
(instance thing404_8 thing404)
(related thing404_8 thing404_9 prop9)
(instance thing243_3 thing243)
(related thing243_3 thing243_4 prop4)
(instance thing140_0 thing140)
(related thing140_0 thing140_1 prop1)
(instance thing41_4 thing41)
(related thing41_4 thing41_5 prop5)
(instance thing001_3 thing001)
(related thing001_3 thing001_4 prop4)
(instance thing144_9 thing144)
(related thing144_9 thing2_0 prop0)
(instance thing413_6 thing413)
(related thing413_6 thing413_7 prop7)
(instance thing034_9 thing034)
(related thing034_9 thing04_0 prop0)
(instance thing031_9 thing031)
(related thing031_9 thing032_0 prop0)
(instance thing314_7 thing314)
(related thing314_7 thing314_8 prop8)
(instance thing40_3 thing40)
(related thing40_3 thing40_4 prop4)
(instance thing020_5 thing020)
(related thing020_5 thing020_6 prop6)
(instance thing114_6 thing114)
(related thing114_6 thing114_7 prop7)
(instance thing334_6 thing334)
(related thing334_6 thing334_7 prop7)
(instance thing201_4 thing201)
(related thing201_4 thing201_5 prop5)
(instance thing034_6 thing034)
(related thing034_6 thing034_7 prop7)
(instance thing032_2 thing032)
(related thing032_2 thing032_3 prop3)
(instance thing301_4 thing301)
(related thing301_4 thing301_5 prop5)
(instance thing101_6 thing101)
(related thing101_6 thing101_7 prop7)
(instance thing411_1 thing411)
(related thing411_1 thing411_2 prop2)
(instance thing11_7 thing11)
(related thing11_7 thing11_8 prop8)
(instance thing1_6 thing1)
(related thing1_6 thing1_7 prop7)
(instance thing134_8 thing134)
(related thing134_8 thing134_9 prop9)
(instance thing310_1 thing310)
(related thing310_1 thing310_2 prop2)
(instance thing322_6 thing322)
(related thing322_6 thing322_7 prop7)
(instance thing334_8 thing334)
(related thing334_8 thing334_9 prop9)
(instance thing123_0 thing123)
(related thing123_0 thing123_1 prop1)
(instance thing203_3 thing203)
(related thing203_3 thing203_4 prop4)
(instance thing021_7 thing021)
(related thing021_7 thing021_8 prop8)
(instance thing244_1 thing244)
(related thing244_1 thing244_2 prop2)
(instance thing414_5 thing414)
(related thing414_5 thing414_6 prop6)
(instance thing334_2 thing334)
(related thing334_2 thing334_3 prop3)
(instance thing233_2 thing233)
(related thing233_2 thing233_3 prop3)
(instance thing323_3 thing323)
(related thing323_3 thing323_4 prop4)
(instance thing223_8 thing223)
(related thing223_8 thing223_9 prop9)
(instance thing110_6 thing110)
(related thing110_6 thing110_7 prop7)
(instance thing224_7 thing224)
(related thing224_7 thing224_8 prop8)
(instance thing204_1 thing204)
(related thing204_1 thing204_2 prop2)
(instance thing132_7 thing132)
(related thing132_7 thing132_8 prop8)
(instance thing013_8 thing013)
(related thing013_8 thing013_9 prop9)
(instance thing42_1 thing42)
(related thing42_1 thing42_2 prop2)
(instance thing002_0 thing002)
(related thing002_0 thing002_1 prop1)
(instance thing240_6 thing240)
(related thing240_6 thing240_7 prop7)
(instance thing443_6 thing443)
(related thing443_6 thing443_7 prop7)
(instance thing224_6 thing224)
(related thing224_6 thing224_7 prop7)
(instance thing1_4 thing1)
(related thing1_4 thing1_5 prop5)
(instance thing310_8 thing310)
(related thing310_8 thing310_9 prop9)
(instance thing000_4 thing000)
(related thing000_4 thing000_5 prop5)
(instance thing312_0 thing312)
(related thing312_0 thing312_1 prop1)
(instance thing414_2 thing414)
(related thing414_2 thing414_3 prop3)
(instance thing244_0 thing244)
(related thing244_0 thing244_1 prop1)
(instance thing424_0 thing424)
(related thing424_0 thing424_1 prop1)
(instance thing0_0 thing0)
(related thing0_0 thing0_1 prop1)
(instance thing431_9 thing431)
(related thing431_9 thing432_0 prop0)
(instance thing243_0 thing243)
(related thing243_0 thing243_1 prop1)
(instance thing043_1 thing043)
(related thing043_1 thing043_2 prop2)
(instance thing302_6 thing302)
(related thing302_6 thing302_7 prop7)
(instance thing432_3 thing432)
(related thing432_3 thing432_4 prop4)
(instance thing024_2 thing024)
(related thing024_2 thing024_3 prop3)
(instance thing343_4 thing343)
(related thing343_4 thing343_5 prop5)
(instance thing443_9 thing443)
(related thing443_9 thing444_0 prop0)
(instance thing204_0 thing204)
(related thing204_0 thing204_1 prop1)
(instance thing240_7 thing240)
(related thing240_7 thing240_8 prop8)
(instance thing230_3 thing230)
(related thing230_3 thing230_4 prop4)
(instance thing31_5 thing31)
(related thing31_5 thing31_6 prop6)
(instance thing303_7 thing303)
(related thing303_7 thing303_8 prop8)
(instance thing433_4 thing433)
(related thing433_4 thing433_5 prop5)
(instance thing140_5 thing140)
(related thing140_5 thing140_6 prop6)
(instance thing421_5 thing421)
(related thing421_5 thing421_6 prop6)
(instance thing403_0 thing403)
(related thing403_0 thing403_1 prop1)
(instance thing424_1 thing424)
(related thing424_1 thing424_2 prop2)
(instance thing244_2 thing244)
(related thing244_2 thing244_3 prop3)
(instance thing311_8 thing311)
(related thing311_8 thing311_9 prop9)
(instance thing300_1 thing300)
(related thing300_1 thing300_2 prop2)
(instance thing40_9 thing40)
(related thing40_9 thing400_0 prop0)
(instance thing121_8 thing121)
(related thing121_8 thing121_9 prop9)
(instance thing114_2 thing114)
(related thing114_2 thing114_3 prop3)
(instance thing342_6 thing342)
(related thing342_6 thing342_7 prop7)
(instance thing142_3 thing142)
(related thing142_3 thing142_4 prop4)
(instance thing321_3 thing321)
(related thing321_3 thing321_4 prop4)
(instance thing023_1 thing023)
(related thing023_1 thing023_2 prop2)
(instance thing433_1 thing433)
(related thing433_1 thing433_2 prop2)
(instance thing002_2 thing002)
(related thing002_2 thing002_3 prop3)
(instance thing424_6 thing424)
(related thing424_6 thing424_7 prop7)
(instance thing232_3 thing232)
(related thing232_3 thing232_4 prop4)
(instance thing220_8 thing220)
(related thing220_8 thing220_9 prop9)
(instance thing341_7 thing341)
(related thing341_7 thing341_8 prop8)
(instance thing03_8 thing03)
(related thing03_8 thing03_9 prop9)
(instance thing411_8 thing411)
(related thing411_8 thing411_9 prop9)
(instance thing24_1 thing24)
(related thing24_1 thing24_2 prop2)
(instance thing030_1 thing030)
(related thing030_1 thing030_2 prop2)
(instance thing141_8 thing141)
(related thing141_8 thing141_9 prop9)
(instance thing332_3 thing332)
(related thing332_3 thing332_4 prop4)
(instance thing223_7 thing223)
(related thing223_7 thing223_8 prop8)
(instance thing021_3 thing021)
(related thing021_3 thing021_4 prop4)
(instance thing304_9 thing304)
(related thing304_9 thing31_0 prop0)
(instance thing221_8 thing221)
(related thing221_8 thing221_9 prop9)
(instance thing420_2 thing420)
(related thing420_2 thing420_3 prop3)
(instance thing434_8 thing434)
(related thing434_8 thing434_9 prop9)
(instance thing141_4 thing141)
(related thing141_4 thing141_5 prop5)
(instance thing133_8 thing133)
(related thing133_8 thing133_9 prop9)
(instance thing033_1 thing033)
(related thing033_1 thing033_2 prop2)
(instance thing423_3 thing423)
(related thing423_3 thing423_4 prop4)
(instance thing13_2 thing13)
(related thing13_2 thing13_3 prop3)
(instance thing3_4 thing3)
(related thing3_4 thing3_5 prop5)
(instance thing32_6 thing32)
(related thing32_6 thing32_7 prop7)
(instance thing131_0 thing131)
(related thing131_0 thing131_1 prop1)
(instance thing010_2 thing010)
(related thing010_2 thing010_3 prop3)
(instance thing41_9 thing41)
(related thing41_9 thing410_0 prop0)
(instance thing410_0 thing410)
(related thing410_0 thing410_1 prop1)
(instance thing0_5 thing0)
(related thing0_5 thing0_6 prop6)
(instance thing402_3 thing402)
(related thing402_3 thing402_4 prop4)
(instance thing244_6 thing244)
(related thing244_6 thing244_7 prop7)
(instance thing20_6 thing20)
(related thing20_6 thing20_7 prop7)
(instance thing14_1 thing14)
(related thing14_1 thing14_2 prop2)
(instance thing034_3 thing034)
(related thing034_3 thing034_4 prop4)
(instance thing134_9 thing134)
(related thing134_9 thing14_0 prop0)
(instance thing04_7 thing04)
(related thing04_7 thing04_8 prop8)
(instance thing304_8 thing304)
(related thing304_8 thing304_9 prop9)
(instance thing022_0 thing022)
(related thing022_0 thing022_1 prop1)
(instance thing3_8 thing3)
(related thing3_8 thing3_9 prop9)
(instance thing134_2 thing134)
(related thing134_2 thing134_3 prop3)
(instance thing222_9 thing222)
(related thing222_9 thing223_0 prop0)
(instance thing332_4 thing332)
(related thing332_4 thing332_5 prop5)
(instance thing13_9 thing13)
(related thing13_9 thing130_0 prop0)
(instance thing103_6 thing103)
(related thing103_6 thing103_7 prop7)
(instance thing01_9 thing01)
(related thing01_9 thing010_0 prop0)
(instance thing410_4 thing410)
(related thing410_4 thing410_5 prop5)
(instance thing424_5 thing424)
(related thing424_5 thing424_6 prop6)
(instance thing232_2 thing232)
(related thing232_2 thing232_3 prop3)
(instance thing34_6 thing34)
(related thing34_6 thing34_7 prop7)
(instance thing231_7 thing231)
(related thing231_7 thing231_8 prop8)
(instance thing411_7 thing411)
(related thing411_7 thing411_8 prop8)
(instance thing312_8 thing312)
(related thing312_8 thing312_9 prop9)
(instance thing300_8 thing300)
(related thing300_8 thing300_9 prop9)
(instance thing200_8 thing200)
(related thing200_8 thing200_9 prop9)
(instance thing030_2 thing030)
(related thing030_2 thing030_3 prop3)
(instance thing14_7 thing14)
(related thing14_7 thing14_8 prop8)
(instance thing43_0 thing43)
(related thing43_0 thing43_1 prop1)
(instance thing121_0 thing121)
(related thing121_0 thing121_1 prop1)
(instance thing442_1 thing442)
(related thing442_1 thing442_2 prop2)
(instance thing222_1 thing222)
(related thing222_1 thing222_2 prop2)
(instance thing000_0 thing000)
(related thing000_0 thing000_1 prop1)
(instance thing014_2 thing014)
(related thing014_2 thing014_3 prop3)
(instance thing40_7 thing40)
(related thing40_7 thing40_8 prop8)
(instance thing110_2 thing110)
(related thing110_2 thing110_3 prop3)
(instance thing41_0 thing41)
(related thing41_0 thing41_1 prop1)
(instance thing30_7 thing30)
(related thing30_7 thing30_8 prop8)
(instance thing214_7 thing214)
(related thing214_7 thing214_8 prop8)
(instance thing144_6 thing144)
(related thing144_6 thing144_7 prop7)
(instance thing441_6 thing441)
(related thing441_6 thing441_7 prop7)
(instance thing22_3 thing22)
(related thing22_3 thing22_4 prop4)
(instance thing243_4 thing243)
(related thing243_4 thing243_5 prop5)
(instance thing1_8 thing1)
(related thing1_8 thing1_9 prop9)
(instance thing321_8 thing321)
(related thing321_8 thing321_9 prop9)
(instance thing40_1 thing40)
(related thing40_1 thing40_2 prop2)
(instance thing314_8 thing314)
(related thing314_8 thing314_9 prop9)
(instance thing223_0 thing223)
(related thing223_0 thing223_1 prop1)
(instance thing303_6 thing303)
(related thing303_6 thing303_7 prop7)
(instance thing112_7 thing112)
(related thing112_7 thing112_8 prop8)
(instance thing122_5 thing122)
(related thing122_5 thing122_6 prop6)
(instance thing224_0 thing224)
(related thing224_0 thing224_1 prop1)
(instance thing043_9 thing043)
(related thing043_9 thing044_0 prop0)
(instance thing000_2 thing000)
(related thing000_2 thing000_3 prop3)
(instance thing23_5 thing23)
(related thing23_5 thing23_6 prop6)
(instance thing321_7 thing321)
(related thing321_7 thing321_8 prop8)
(instance thing214_5 thing214)
(related thing214_5 thing214_6 prop6)
(instance thing031_0 thing031)
(related thing031_0 thing031_1 prop1)
(instance thing210_8 thing210)
(related thing210_8 thing210_9 prop9)
(instance thing30_0 thing30)
(related thing30_0 thing30_1 prop1)
(instance thing122_1 thing122)
(related thing122_1 thing122_2 prop2)
(instance thing434_1 thing434)
(related thing434_1 thing434_2 prop2)
(instance thing131_1 thing131)
(related thing131_1 thing131_2 prop2)
(instance thing102_7 thing102)
(related thing102_7 thing102_8 prop8)
(instance thing121_7 thing121)
(related thing121_7 thing121_8 prop8)
(instance thing03_5 thing03)
(related thing03_5 thing03_6 prop6)
(instance thing130_8 thing130)
(related thing130_8 thing130_9 prop9)
(instance thing2_3 thing2)
(related thing2_3 thing2_4 prop4)
(instance thing102_4 thing102)
(related thing102_4 thing102_5 prop5)
(instance thing221_4 thing221)
(related thing221_4 thing221_5 prop5)
(instance thing334_7 thing334)
(related thing334_7 thing334_8 prop8)
(instance thing011_0 thing011)
(related thing011_0 thing011_1 prop1)
(instance thing24_3 thing24)
(related thing24_3 thing24_4 prop4)
(instance thing220_3 thing220)
(related thing220_3 thing220_4 prop4)
(instance thing403_2 thing403)
(related thing403_2 thing403_3 prop3)
(instance thing000_5 thing000)
(related thing000_5 thing000_6 prop6)
(instance thing423_0 thing423)
(related thing423_0 thing423_1 prop1)
(instance thing312_9 thing312)
(related thing312_9 thing313_0 prop0)
(instance thing144_7 thing144)
(related thing144_7 thing144_8 prop8)
(instance thing421_4 thing421)
(related thing421_4 thing421_5 prop5)
(instance thing32_1 thing32)
(related thing32_1 thing32_2 prop2)
(instance thing243_5 thing243)
(related thing243_5 thing243_6 prop6)
(instance thing00_2 thing00)
(related thing00_2 thing00_3 prop3)
(instance thing341_8 thing341)
(related thing341_8 thing341_9 prop9)
(instance thing110_1 thing110)
(related thing110_1 thing110_2 prop2)
(instance thing014_1 thing014)
(related thing014_1 thing014_2 prop2)
(instance thing321_4 thing321)
(related thing321_4 thing321_5 prop5)
(instance thing431_1 thing431)
(related thing431_1 thing431_2 prop2)
(instance thing431_3 thing431)
(related thing431_3 thing431_4 prop4)
(instance thing140_8 thing140)
(related thing140_8 thing140_9 prop9)
(instance thing204_3 thing204)
(related thing204_3 thing204_4 prop4)
(instance thing002_7 thing002)
(related thing002_7 thing002_8 prop8)
(instance thing433_0 thing433)
(related thing433_0 thing433_1 prop1)
(instance thing22_6 thing22)
(related thing22_6 thing22_7 prop7)
(instance thing140_2 thing140)
(related thing140_2 thing140_3 prop3)
(instance thing022_8 thing022)
(related thing022_8 thing022_9 prop9)
(instance thing23_8 thing23)
(related thing23_8 thing23_9 prop9)
(instance thing332_0 thing332)
(related thing332_0 thing332_1 prop1)
(instance thing12_4 thing12)
(related thing12_4 thing12_5 prop5)
(instance thing003_2 thing003)
(related thing003_2 thing003_3 prop3)
(instance thing141_3 thing141)
(related thing141_3 thing141_4 prop4)
(instance thing022_5 thing022)
(related thing022_5 thing022_6 prop6)
(instance thing030_7 thing030)
(related thing030_7 thing030_8 prop8)
(instance thing244_7 thing244)
(related thing244_7 thing244_8 prop8)
(instance thing240_9 thing240)
(related thing240_9 thing241_0 prop0)
(instance thing203_2 thing203)
(related thing203_2 thing203_3 prop3)
(instance thing432_7 thing432)
(related thing432_7 thing432_8 prop8)
(instance thing122_6 thing122)
(related thing122_6 thing122_7 prop7)
(instance thing000_1 thing000)
(related thing000_1 thing000_2 prop2)
(instance thing403_5 thing403)
(related thing403_5 thing403_6 prop6)
(instance thing241_2 thing241)
(related thing241_2 thing241_3 prop3)
(instance thing33_5 thing33)
(related thing33_5 thing33_6 prop6)
(instance thing433_2 thing433)
(related thing433_2 thing433_3 prop3)
(instance thing33_9 thing33)
(related thing33_9 thing330_0 prop0)
(instance thing304_0 thing304)
(related thing304_0 thing304_1 prop1)
(instance thing220_2 thing220)
(related thing220_2 thing220_3 prop3)
(instance thing022_1 thing022)
(related thing022_1 thing022_2 prop2)
(instance thing420_7 thing420)
(related thing420_7 thing420_8 prop8)
(instance thing32_5 thing32)
(related thing32_5 thing32_6 prop6)
(instance thing232_1 thing232)
(related thing232_1 thing232_2 prop2)
(instance thing320_6 thing320)
(related thing320_6 thing320_7 prop7)
(instance thing014_5 thing014)
(related thing014_5 thing014_6 prop6)
(instance thing03_2 thing03)
(related thing03_2 thing03_3 prop3)
(instance thing134_1 thing134)
(related thing134_1 thing134_2 prop2)
(instance thing040_6 thing040)
(related thing040_6 thing040_7 prop7)
(instance thing412_6 thing412)
(related thing412_6 thing412_7 prop7)
(instance thing321_5 thing321)
(related thing321_5 thing321_6 prop6)
(instance thing133_9 thing133)
(related thing133_9 thing134_0 prop0)
(instance thing22_0 thing22)
(related thing22_0 thing22_1 prop1)
(instance thing443_5 thing443)
(related thing443_5 thing443_6 prop6)
(instance thing114_1 thing114)
(related thing114_1 thing114_2 prop2)
(instance thing004_6 thing004)
(related thing004_6 thing004_7 prop7)
(instance thing044_7 thing044)
(related thing044_7 thing044_8 prop8)
(instance thing003_6 thing003)
(related thing003_6 thing003_7 prop7)
(instance thing220_4 thing220)
(related thing220_4 thing220_5 prop5)
(instance thing343_6 thing343)
(related thing343_6 thing343_7 prop7)
(instance thing132_1 thing132)
(related thing132_1 thing132_2 prop2)
(instance thing203_5 thing203)
(related thing203_5 thing203_6 prop6)
(instance thing013_5 thing013)
(related thing013_5 thing013_6 prop6)
(instance thing334_5 thing334)
(related thing334_5 thing334_6 prop6)
(instance thing223_2 thing223)
(related thing223_2 thing223_3 prop3)
(instance thing120_9 thing120)
(related thing120_9 thing121_0 prop0)
(instance thing023_2 thing023)
(related thing023_2 thing023_3 prop3)
(instance thing230_0 thing230)
(related thing230_0 thing230_1 prop1)
(instance thing12_0 thing12)
(related thing12_0 thing12_1 prop1)
(instance thing311_1 thing311)
(related thing311_1 thing311_2 prop2)
(instance thing21_7 thing21)
(related thing21_7 thing21_8 prop8)
(instance thing214_9 thing214)
(related thing214_9 thing22_0 prop0)
(instance thing41_3 thing41)
(related thing41_3 thing41_4 prop4)
(instance thing442_9 thing442)
(related thing442_9 thing443_0 prop0)
(instance thing233_3 thing233)
(related thing233_3 thing233_4 prop4)
(instance thing234_1 thing234)
(related thing234_1 thing234_2 prop2)
(instance thing104_8 thing104)
(related thing104_8 thing104_9 prop9)
(instance thing33_7 thing33)
(related thing33_7 thing33_8 prop8)
(instance thing413_7 thing413)
(related thing413_7 thing413_8 prop8)
(instance thing404_1 thing404)
(related thing404_1 thing404_2 prop2)
(instance thing42_5 thing42)
(related thing42_5 thing42_6 prop6)
(instance thing13_6 thing13)
(related thing13_6 thing13_7 prop7)
(instance thing014_7 thing014)
(related thing014_7 thing014_8 prop8)
(instance thing431_5 thing431)
(related thing431_5 thing431_6 prop6)
(instance thing210_1 thing210)
(related thing210_1 thing210_2 prop2)
(instance thing221_0 thing221)
(related thing221_0 thing221_1 prop1)
(instance thing124_0 thing124)
(related thing124_0 thing124_1 prop1)
(instance thing403_1 thing403)
(related thing403_1 thing403_2 prop2)
(instance thing031_6 thing031)
(related thing031_6 thing031_7 prop7)
(instance thing234_7 thing234)
(related thing234_7 thing234_8 prop8)
(instance thing201_3 thing201)
(related thing201_3 thing201_4 prop4)
(instance thing211_7 thing211)
(related thing211_7 thing211_8 prop8)
(instance thing434_4 thing434)
(related thing434_4 thing434_5 prop5)
(instance thing432_6 thing432)
(related thing432_6 thing432_7 prop7)
(instance thing012_1 thing012)
(related thing012_1 thing012_2 prop2)
(instance thing023_5 thing023)
(related thing023_5 thing023_6 prop6)
(instance thing043_6 thing043)
(related thing043_6 thing043_7 prop7)
(instance thing10_0 thing10)
(related thing10_0 thing10_1 prop1)
(instance thing111_8 thing111)
(related thing111_8 thing111_9 prop9)
(instance thing311_7 thing311)
(related thing311_7 thing311_8 prop8)
(instance thing0_8 thing0)
(related thing0_8 thing0_9 prop9)
(instance thing402_1 thing402)
(related thing402_1 thing402_2 prop2)
(instance thing341_0 thing341)
(related thing341_0 thing341_1 prop1)
(instance thing011_9 thing011)
(related thing011_9 thing012_0 prop0)
(instance thing031_1 thing031)
(related thing031_1 thing031_2 prop2)
(instance thing023_6 thing023)
(related thing023_6 thing023_7 prop7)
(instance thing234_2 thing234)
(related thing234_2 thing234_3 prop3)
(instance thing442_8 thing442)
(related thing442_8 thing442_9 prop9)
(instance thing024_3 thing024)
(related thing024_3 thing024_4 prop4)
(instance thing221_3 thing221)
(related thing221_3 thing221_4 prop4)
(instance thing243_7 thing243)
(related thing243_7 thing243_8 prop8)
(instance thing400_4 thing400)
(related thing400_4 thing400_5 prop5)
(instance thing202_2 thing202)
(related thing202_2 thing202_3 prop3)
(instance thing140_6 thing140)
(related thing140_6 thing140_7 prop7)
(instance thing413_5 thing413)
(related thing413_5 thing413_6 prop6)
(instance thing21_1 thing21)
(related thing21_1 thing21_2 prop2)
(instance thing211_8 thing211)
(related thing211_8 thing211_9 prop9)
(instance thing333_5 thing333)
(related thing333_5 thing333_6 prop6)
(instance thing130_9 thing130)
(related thing130_9 thing131_0 prop0)
(instance thing424_8 thing424)
(related thing424_8 thing424_9 prop9)
(instance thing4_4 thing4)
(related thing4_4 thing4_5 prop5)
(instance thing430_8 thing430)
(related thing430_8 thing430_9 prop9)
(instance thing34_5 thing34)
(related thing34_5 thing34_6 prop6)
(instance thing044_1 thing044)
(related thing044_1 thing044_2 prop2)
(instance thing142_0 thing142)
(related thing142_0 thing142_1 prop1)
(instance thing330_1 thing330)
(related thing330_1 thing330_2 prop2)
(instance thing402_2 thing402)
(related thing402_2 thing402_3 prop3)
(instance thing001_9 thing001)
(related thing001_9 thing002_0 prop0)
(instance thing020_6 thing020)
(related thing020_6 thing020_7 prop7)
(instance thing01_3 thing01)
(related thing01_3 thing01_4 prop4)
(instance thing322_0 thing322)
(related thing322_0 thing322_1 prop1)
(instance thing040_5 thing040)
(related thing040_5 thing040_6 prop6)
(instance thing310_9 thing310)
(related thing310_9 thing311_0 prop0)
(instance thing324_6 thing324)
(related thing324_6 thing324_7 prop7)
(instance thing100_5 thing100)
(related thing100_5 thing100_6 prop6)
(instance thing301_0 thing301)
(related thing301_0 thing301_1 prop1)
(instance thing31_9 thing31)
(related thing31_9 thing310_0 prop0)
(instance thing322_4 thing322)
(related thing322_4 thing322_5 prop5)
(instance thing1_3 thing1)
(related thing1_3 thing1_4 prop4)
(instance thing34_2 thing34)
(related thing34_2 thing34_3 prop3)
(instance thing44_7 thing44)
(related thing44_7 thing44_8 prop8)
(instance thing200_1 thing200)
(related thing200_1 thing200_2 prop2)
(instance thing104_7 thing104)
(related thing104_7 thing104_8 prop8)
(instance thing131_2 thing131)
(related thing131_2 thing131_3 prop3)
(instance thing322_9 thing322)
(related thing322_9 thing323_0 prop0)
(instance thing121_3 thing121)
(related thing121_3 thing121_4 prop4)
(instance thing33_0 thing33)
(related thing33_0 thing33_1 prop1)
(instance thing141_0 thing141)
(related thing141_0 thing141_1 prop1)
(instance thing202_4 thing202)
(related thing202_4 thing202_5 prop5)
(instance thing344_3 thing344)
(related thing344_3 thing344_4 prop4)
(instance thing21_5 thing21)
(related thing21_5 thing21_6 prop6)
(instance thing244_8 thing244)
(related thing244_8 thing244_9 prop9)
(instance thing31_8 thing31)
(related thing31_8 thing31_9 prop9)
(instance thing042_5 thing042)
(related thing042_5 thing042_6 prop6)
(instance thing223_4 thing223)
(related thing223_4 thing223_5 prop5)
(instance thing203_6 thing203)
(related thing203_6 thing203_7 prop7)
(instance thing31_1 thing31)
(related thing31_1 thing31_2 prop2)
(instance thing432_5 thing432)
(related thing432_5 thing432_6 prop6)
(instance thing41_2 thing41)
(related thing41_2 thing41_3 prop3)
(instance thing312_4 thing312)
(related thing312_4 thing312_5 prop5)
(instance thing144_8 thing144)
(related thing144_8 thing144_9 prop9)
(instance thing013_4 thing013)
(related thing013_4 thing013_5 prop5)
(instance thing14_8 thing14)
(related thing14_8 thing14_9 prop9)
(instance thing201_9 thing201)
(related thing201_9 thing202_0 prop0)
(instance thing420_8 thing420)
(related thing420_8 thing420_9 prop9)
(instance thing001_8 thing001)
(related thing001_8 thing001_9 prop9)
(instance thing042_4 thing042)
(related thing042_4 thing042_5 prop5)
(instance thing341_6 thing341)
(related thing341_6 thing341_7 prop7)
(instance thing144_3 thing144)
(related thing144_3 thing144_4 prop4)
(instance thing14_6 thing14)
(related thing14_6 thing14_7 prop7)
(instance thing011_4 thing011)
(related thing011_4 thing011_5 prop5)
(instance thing020_4 thing020)
(related thing020_4 thing020_5 prop5)
(instance thing203_1 thing203)
(related thing203_1 thing203_2 prop2)
(instance thing103_9 thing103)
(related thing103_9 thing104_0 prop0)
(instance thing40_4 thing40)
(related thing40_4 thing40_5 prop5)
(instance thing023_8 thing023)
(related thing023_8 thing023_9 prop9)
(instance thing444_9 thing444)
(instance thing213_9 thing213)
(related thing213_9 thing214_0 prop0)
(instance thing003_0 thing003)
(related thing003_0 thing003_1 prop1)
(instance thing033_0 thing033)
(related thing033_0 thing033_1 prop1)
(instance thing23_0 thing23)
(related thing23_0 thing23_1 prop1)
(instance thing003_8 thing003)
(related thing003_8 thing003_9 prop9)
(instance thing213_1 thing213)
(related thing213_1 thing213_2 prop2)
(instance thing032_0 thing032)
(related thing032_0 thing032_1 prop1)
(instance thing120_4 thing120)
(related thing120_4 thing120_5 prop5)
(instance thing224_8 thing224)
(related thing224_8 thing224_9 prop9)
(instance thing33_4 thing33)
(related thing33_4 thing33_5 prop5)
(instance thing12_9 thing12)
(related thing12_9 thing120_0 prop0)
(instance thing140_3 thing140)
(related thing140_3 thing140_4 prop4)
(instance thing413_3 thing413)
(related thing413_3 thing413_4 prop4)
(instance thing311_4 thing311)
(related thing311_4 thing311_5 prop5)
(instance thing011_2 thing011)
(related thing011_2 thing011_3 prop3)
(instance thing421_6 thing421)
(related thing421_6 thing421_7 prop7)
(instance thing033_6 thing033)
(related thing033_6 thing033_7 prop7)
(instance thing304_2 thing304)
(related thing304_2 thing304_3 prop3)
(instance thing40_8 thing40)
(related thing40_8 thing40_9 prop9)
(instance thing014_6 thing014)
(related thing014_6 thing014_7 prop7)
(instance thing20_9 thing20)
(related thing20_9 thing200_0 prop0)
(instance thing040_1 thing040)
(related thing040_1 thing040_2 prop2)
(instance thing213_7 thing213)
(related thing213_7 thing213_8 prop8)
(instance thing411_3 thing411)
(related thing411_3 thing411_4 prop4)
(instance thing04_9 thing04)
(related thing04_9 thing040_0 prop0)
(instance thing113_0 thing113)
(related thing113_0 thing113_1 prop1)
(instance thing41_8 thing41)
(related thing41_8 thing41_9 prop9)
(instance thing224_9 thing224)
(related thing224_9 thing23_0 prop0)
(instance thing33_1 thing33)
(related thing33_1 thing33_2 prop2)
(instance thing110_7 thing110)
(related thing110_7 thing110_8 prop8)
(instance thing011_3 thing011)
(related thing011_3 thing011_4 prop4)
(instance thing12_8 thing12)
(related thing12_8 thing12_9 prop9)
(instance thing042_0 thing042)
(related thing042_0 thing042_1 prop1)
(instance thing430_0 thing430)
(related thing430_0 thing430_1 prop1)
(instance thing043_5 thing043)
(related thing043_5 thing043_6 prop6)
(instance thing422_9 thing422)
(related thing422_9 thing423_0 prop0)
(instance thing442_6 thing442)
(related thing442_6 thing442_7 prop7)
(instance thing323_5 thing323)
(related thing323_5 thing323_6 prop6)
(instance thing241_7 thing241)
(related thing241_7 thing241_8 prop8)
(instance thing332_8 thing332)
(related thing332_8 thing332_9 prop9)
(instance thing200_4 thing200)
(related thing200_4 thing200_5 prop5)
(instance thing002_8 thing002)
(related thing002_8 thing002_9 prop9)
(instance thing10_5 thing10)
(related thing10_5 thing10_6 prop6)
(instance thing133_3 thing133)
(related thing133_3 thing133_4 prop4)
(instance thing4_2 thing4)
(related thing4_2 thing4_3 prop3)
(instance thing441_9 thing441)
(related thing441_9 thing442_0 prop0)
(instance thing310_6 thing310)
(related thing310_6 thing310_7 prop7)
(instance thing041_8 thing041)
(related thing041_8 thing041_9 prop9)
(instance thing124_2 thing124)
(related thing124_2 thing124_3 prop3)
(instance thing013_2 thing013)
(related thing013_2 thing013_3 prop3)
(instance thing410_5 thing410)
(related thing410_5 thing410_6 prop6)
(instance thing021_4 thing021)
(related thing021_4 thing021_5 prop5)
(instance thing420_4 thing420)
(related thing420_4 thing420_5 prop5)
(instance thing131_3 thing131)
(related thing131_3 thing131_4 prop4)
(instance thing314_9 thing314)
(related thing314_9 thing32_0 prop0)
(instance thing240_8 thing240)
(related thing240_8 thing240_9 prop9)
(instance thing00_5 thing00)
(related thing00_5 thing00_6 prop6)
(instance thing233_7 thing233)
(related thing233_7 thing233_8 prop8)
(instance thing342_1 thing342)
(related thing342_1 thing342_2 prop2)
(instance thing012_7 thing012)
(related thing012_7 thing012_8 prop8)
(instance thing204_6 thing204)
(related thing204_6 thing204_7 prop7)
(instance thing400_6 thing400)
(related thing400_6 thing400_7 prop7)
(instance thing204_7 thing204)
(related thing204_7 thing204_8 prop8)
(instance thing134_7 thing134)
(related thing134_7 thing134_8 prop8)
(instance thing211_0 thing211)
(related thing211_0 thing211_1 prop1)
(instance thing22_7 thing22)
(related thing22_7 thing22_8 prop8)
(instance thing214_2 thing214)
(related thing214_2 thing214_3 prop3)
(instance thing330_4 thing330)
(related thing330_4 thing330_5 prop5)
(instance thing023_3 thing023)
(related thing023_3 thing023_4 prop4)
(instance thing343_1 thing343)
(related thing343_1 thing343_2 prop2)
(instance thing102_2 thing102)
(related thing102_2 thing102_3 prop3)
(instance thing203_8 thing203)
(related thing203_8 thing203_9 prop9)
(instance thing304_4 thing304)
(related thing304_4 thing304_5 prop5)
(instance thing220_7 thing220)
(related thing220_7 thing220_8 prop8)
(instance thing113_8 thing113)
(related thing113_8 thing113_9 prop9)
(instance thing340_3 thing340)
(related thing340_3 thing340_4 prop4)
(instance thing011_6 thing011)
(related thing011_6 thing011_7 prop7)
(instance thing421_7 thing421)
(related thing421_7 thing421_8 prop8)
(instance thing333_2 thing333)
(related thing333_2 thing333_3 prop3)
(instance thing344_2 thing344)
(related thing344_2 thing344_3 prop3)
(instance thing303_3 thing303)
(related thing303_3 thing303_4 prop4)
(instance thing020_3 thing020)
(related thing020_3 thing020_4 prop4)
(instance thing313_6 thing313)
(related thing313_6 thing313_7 prop7)
(instance thing100_2 thing100)
(related thing100_2 thing100_3 prop3)
(instance thing202_9 thing202)
(related thing202_9 thing203_0 prop0)
(instance thing30_1 thing30)
(related thing30_1 thing30_2 prop2)
(instance thing31_7 thing31)
(related thing31_7 thing31_8 prop8)
(instance thing2_2 thing2)
(related thing2_2 thing2_3 prop3)
(instance thing124_4 thing124)
(related thing124_4 thing124_5 prop5)
(instance thing134_5 thing134)
(related thing134_5 thing134_6 prop6)
(instance thing213_2 thing213)
(related thing213_2 thing213_3 prop3)
(instance thing341_4 thing341)
(related thing341_4 thing341_5 prop5)
(instance thing002_1 thing002)
(related thing002_1 thing002_2 prop2)
(instance thing234_3 thing234)
(related thing234_3 thing234_4 prop4)
(instance thing440_0 thing440)
(related thing440_0 thing440_1 prop1)
(instance thing2_4 thing2)
(related thing2_4 thing2_5 prop5)
(instance thing004_5 thing004)
(related thing004_5 thing004_6 prop6)
(instance thing10_6 thing10)
(related thing10_6 thing10_7 prop7)
(instance thing031_4 thing031)
(related thing031_4 thing031_5 prop5)
(instance thing132_0 thing132)
(related thing132_0 thing132_1 prop1)
(instance thing130_6 thing130)
(related thing130_6 thing130_7 prop7)
(instance thing003_5 thing003)
(related thing003_5 thing003_6 prop6)
(instance thing403_9 thing403)
(related thing403_9 thing404_0 prop0)
(instance thing40_5 thing40)
(related thing40_5 thing40_6 prop6)
(instance thing203_4 thing203)
(related thing203_4 thing203_5 prop5)
(instance thing33_2 thing33)
(related thing33_2 thing33_3 prop3)
(instance thing013_7 thing013)
(related thing013_7 thing013_8 prop8)
(instance thing011_7 thing011)
(related thing011_7 thing011_8 prop8)
(instance thing001_6 thing001)
(related thing001_6 thing001_7 prop7)
(instance thing100_6 thing100)
(related thing100_6 thing100_7 prop7)
(instance thing413_0 thing413)
(related thing413_0 thing413_1 prop1)
(instance thing343_0 thing343)
(related thing343_0 thing343_1 prop1)
(instance thing2_0 thing2)
(related thing2_0 thing2_1 prop1)
(instance thing422_5 thing422)
(related thing422_5 thing422_6 prop6)
(instance thing201_5 thing201)
(related thing201_5 thing201_6 prop6)
(instance thing02_2 thing02)
(related thing02_2 thing02_3 prop3)
(instance thing321_2 thing321)
(related thing321_2 thing321_3 prop3)
(instance thing211_3 thing211)
(related thing211_3 thing211_4 prop4)
(instance thing103_0 thing103)
(related thing103_0 thing103_1 prop1)
(instance thing434_2 thing434)
(related thing434_2 thing434_3 prop3)
(instance thing320_5 thing320)
(related thing320_5 thing320_6 prop6)
(instance thing44_0 thing44)
(related thing44_0 thing44_1 prop1)
(instance thing30_9 thing30)
(related thing30_9 thing300_0 prop0)
(instance thing344_9 thing344)
(related thing344_9 thing4_0 prop0)
(instance thing243_2 thing243)
(related thing243_2 thing243_3 prop3)
(instance thing324_1 thing324)
(related thing324_1 thing324_2 prop2)
(instance thing300_0 thing300)
(related thing300_0 thing300_1 prop1)
(instance thing442_5 thing442)
(related thing442_5 thing442_6 prop6)
(instance thing022_3 thing022)
(related thing022_3 thing022_4 prop4)
(instance thing111_0 thing111)
(related thing111_0 thing111_1 prop1)
(instance thing212_7 thing212)
(related thing212_7 thing212_8 prop8)
(instance thing430_4 thing430)
(related thing430_4 thing430_5 prop5)
(instance thing123_8 thing123)
(related thing123_8 thing123_9 prop9)
(instance thing341_3 thing341)
(related thing341_3 thing341_4 prop4)
(instance thing044_8 thing044)
(related thing044_8 thing044_9 prop9)
(instance thing222_7 thing222)
(related thing222_7 thing222_8 prop8)
(instance thing143_9 thing143)
(related thing143_9 thing144_0 prop0)
(instance thing403_8 thing403)
(related thing403_8 thing403_9 prop9)
(instance thing222_0 thing222)
(related thing222_0 thing222_1 prop1)
(instance thing424_9 thing424)
(related thing424_9 thing43_0 prop0)
(instance thing411_5 thing411)
(related thing411_5 thing411_6 prop6)
(instance thing30_8 thing30)
(related thing30_8 thing30_9 prop9)
(instance thing444_4 thing444)
(related thing444_4 thing444_5 prop5)
(instance thing242_3 thing242)
(related thing242_3 thing242_4 prop4)
(instance thing441_0 thing441)
(related thing441_0 thing441_1 prop1)
(instance thing431_2 thing431)
(related thing431_2 thing431_3 prop3)
(instance thing033_7 thing033)
(related thing033_7 thing033_8 prop8)
(instance thing030_9 thing030)
(related thing030_9 thing031_0 prop0)
(instance thing314_5 thing314)
(related thing314_5 thing314_6 prop6)
(instance thing00_6 thing00)
(related thing00_6 thing00_7 prop7)
(instance thing401_8 thing401)
(related thing401_8 thing401_9 prop9)
(instance thing013_6 thing013)
(related thing013_6 thing013_7 prop7)
(instance thing042_6 thing042)
(related thing042_6 thing042_7 prop7)
(instance thing204_9 thing204)
(related thing204_9 thing21_0 prop0)
(instance thing004_3 thing004)
(related thing004_3 thing004_4 prop4)
(instance thing024_7 thing024)
(related thing024_7 thing024_8 prop8)
(instance thing10_4 thing10)
(related thing10_4 thing10_5 prop5)
(instance thing1_0 thing1)
(related thing1_0 thing1_1 prop1)
(instance thing44_4 thing44)
(related thing44_4 thing44_5 prop5)
(instance thing322_2 thing322)
(related thing322_2 thing322_3 prop3)
(instance thing103_5 thing103)
(related thing103_5 thing103_6 prop6)
(instance thing141_7 thing141)
(related thing141_7 thing141_8 prop8)
(instance thing0_2 thing0)
(related thing0_2 thing0_3 prop3)
(instance thing034_8 thing034)
(related thing034_8 thing034_9 prop9)
(instance thing42_9 thing42)
(related thing42_9 thing420_0 prop0)
(instance thing244_3 thing244)
(related thing244_3 thing244_4 prop4)
(instance thing303_2 thing303)
(related thing303_2 thing303_3 prop3)
(instance thing321_6 thing321)
(related thing321_6 thing321_7 prop7)
(instance thing34_3 thing34)
(related thing34_3 thing34_4 prop4)
(instance thing133_0 thing133)
(related thing133_0 thing133_1 prop1)
(instance thing323_1 thing323)
(related thing323_1 thing323_2 prop2)
(instance thing404_5 thing404)
(related thing404_5 thing404_6 prop6)
(instance thing02_6 thing02)
(related thing02_6 thing02_7 prop7)
(instance thing442_3 thing442)
(related thing442_3 thing442_4 prop4)
(instance thing113_9 thing113)
(related thing113_9 thing114_0 prop0)
(instance thing022_7 thing022)
(related thing022_7 thing022_8 prop8)
(instance thing024_9 thing024)
(related thing024_9 thing03_0 prop0)
(instance thing124_9 thing124)
(related thing124_9 thing13_0 prop0)
(instance thing023_9 thing023)
(related thing023_9 thing024_0 prop0)
(instance thing141_2 thing141)
(related thing141_2 thing141_3 prop3)
(instance thing212_6 thing212)
(related thing212_6 thing212_7 prop7)
(instance thing201_2 thing201)
(related thing201_2 thing201_3 prop3)
(instance thing0_9 thing0)
(related thing0_9 thing00_0 prop0)
(instance thing040_2 thing040)
(related thing040_2 thing040_3 prop3)
(instance thing041_9 thing041)
(related thing041_9 thing042_0 prop0)
(instance thing244_4 thing244)
(related thing244_4 thing244_5 prop5)
(instance thing221_2 thing221)
(related thing221_2 thing221_3 prop3)
(instance thing012_9 thing012)
(related thing012_9 thing013_0 prop0)
(instance thing234_6 thing234)
(related thing234_6 thing234_7 prop7)
(instance thing330_9 thing330)
(related thing330_9 thing331_0 prop0)
(instance thing222_5 thing222)
(related thing222_5 thing222_6 prop6)
(instance thing400_5 thing400)
(related thing400_5 thing400_6 prop6)
(instance thing443_7 thing443)
(related thing443_7 thing443_8 prop8)
(instance thing43_4 thing43)
(related thing43_4 thing43_5 prop5)
(instance thing042_9 thing042)
(related thing042_9 thing043_0 prop0)
(instance thing03_6 thing03)
(related thing03_6 thing03_7 prop7)
(instance thing21_4 thing21)
(related thing21_4 thing21_5 prop5)
(instance thing322_8 thing322)
(related thing322_8 thing322_9 prop9)
(instance thing021_5 thing021)
(related thing021_5 thing021_6 prop6)
(instance thing323_7 thing323)
(related thing323_7 thing323_8 prop8)
(instance thing414_4 thing414)
(related thing414_4 thing414_5 prop5)
(instance thing041_3 thing041)
(related thing041_3 thing041_4 prop4)
(instance thing440_5 thing440)
(related thing440_5 thing440_6 prop6)
(instance thing341_9 thing341)
(related thing341_9 thing342_0 prop0)
(instance thing213_3 thing213)
(related thing213_3 thing213_4 prop4)
(instance thing44_8 thing44)
(related thing44_8 thing44_9 prop9)
(instance thing304_6 thing304)
(related thing304_6 thing304_7 prop7)
(instance thing123_5 thing123)
(related thing123_5 thing123_6 prop6)
(instance thing344_5 thing344)
(related thing344_5 thing344_6 prop6)
(instance thing30_6 thing30)
(related thing30_6 thing30_7 prop7)
(instance thing000_3 thing000)
(related thing000_3 thing000_4 prop4)
(instance thing401_9 thing401)
(related thing401_9 thing402_0 prop0)
(instance thing331_3 thing331)
(related thing331_3 thing331_4 prop4)
(instance thing313_4 thing313)
(related thing313_4 thing313_5 prop5)
(instance thing220_1 thing220)
(related thing220_1 thing220_2 prop2)
(instance thing03_3 thing03)
(related thing03_3 thing03_4 prop4)
(instance thing44_3 thing44)
(related thing44_3 thing44_4 prop4)
(instance thing231_3 thing231)
(related thing231_3 thing231_4 prop4)
(instance thing123_9 thing123)
(related thing123_9 thing124_0 prop0)
(instance thing124_5 thing124)
(related thing124_5 thing124_6 prop6)
(instance thing34_8 thing34)
(related thing34_8 thing34_9 prop9)
(instance thing204_4 thing204)
(related thing204_4 thing204_5 prop5)
(instance thing433_6 thing433)
(related thing433_6 thing433_7 prop7)
(instance thing12_7 thing12)
(related thing12_7 thing12_8 prop8)
(instance thing110_4 thing110)
(related thing110_4 thing110_5 prop5)
(instance thing22_4 thing22)
(related thing22_4 thing22_5 prop5)
(instance thing132_4 thing132)
(related thing132_4 thing132_5 prop5)
(instance thing430_1 thing430)
(related thing430_1 thing430_2 prop2)
(instance thing303_4 thing303)
(related thing303_4 thing303_5 prop5)
(instance thing124_6 thing124)
(related thing124_6 thing124_7 prop7)
(instance thing43_5 thing43)
(related thing43_5 thing43_6 prop6)
(instance thing240_1 thing240)
(related thing240_1 thing240_2 prop2)
(instance thing433_5 thing433)
(related thing433_5 thing433_6 prop6)
(instance thing11_3 thing11)
(related thing11_3 thing11_4 prop4)
(instance thing041_0 thing041)
(related thing041_0 thing041_1 prop1)
(instance thing442_2 thing442)
(related thing442_2 thing442_3 prop3)
(instance thing310_5 thing310)
(related thing310_5 thing310_6 prop6)
(instance thing131_9 thing131)
(related thing131_9 thing132_0 prop0)
(instance thing223_3 thing223)
(related thing223_3 thing223_4 prop4)
(instance thing242_1 thing242)
(related thing242_1 thing242_2 prop2)
(instance thing334_3 thing334)
(related thing334_3 thing334_4 prop4)
(instance thing014_4 thing014)
(related thing014_4 thing014_5 prop5)
(instance thing04_6 thing04)
(related thing04_6 thing04_7 prop7)
(instance thing144_5 thing144)
(related thing144_5 thing144_6 prop6)
(instance thing400_1 thing400)
(related thing400_1 thing400_2 prop2)
(instance thing043_0 thing043)
(related thing043_0 thing043_1 prop1)
(instance thing400_3 thing400)
(related thing400_3 thing400_4 prop4)
(instance thing301_3 thing301)
(related thing301_3 thing301_4 prop4)
(instance thing220_5 thing220)
(related thing220_5 thing220_6 prop6)
(instance thing300_4 thing300)
(related thing300_4 thing300_5 prop5)
(instance thing414_0 thing414)
(related thing414_0 thing414_1 prop1)
(instance thing331_4 thing331)
(related thing331_4 thing331_5 prop5)
(instance thing024_6 thing024)
(related thing024_6 thing024_7 prop7)
(instance thing31_2 thing31)
(related thing31_2 thing31_3 prop3)
(instance thing24_5 thing24)
(related thing24_5 thing24_6 prop6)
(instance thing344_0 thing344)
(related thing344_0 thing344_1 prop1)
(instance thing343_7 thing343)
(related thing343_7 thing343_8 prop8)
(instance thing444_2 thing444)
(related thing444_2 thing444_3 prop3)
(instance thing202_7 thing202)
(related thing202_7 thing202_8 prop8)
(instance thing3_2 thing3)
(related thing3_2 thing3_3 prop3)
(instance thing410_6 thing410)
(related thing410_6 thing410_7 prop7)
(instance thing30_5 thing30)
(related thing30_5 thing30_6 prop6)
(instance thing0_3 thing0)
(related thing0_3 thing0_4 prop4)
(instance thing421_8 thing421)
(related thing421_8 thing421_9 prop9)
(instance thing314_4 thing314)
(related thing314_4 thing314_5 prop5)
(instance thing143_6 thing143)
(related thing143_6 thing143_7 prop7)
(instance thing231_4 thing231)
(related thing231_4 thing231_5 prop5)
(instance thing432_1 thing432)
(related thing432_1 thing432_2 prop2)
(instance thing041_7 thing041)
(related thing041_7 thing041_8 prop8)
(instance thing044_3 thing044)
(related thing044_3 thing044_4 prop4)
(instance thing043_4 thing043)
(related thing043_4 thing043_5 prop5)
(instance thing310_3 thing310)
(related thing310_3 thing310_4 prop4)
(instance thing200_2 thing200)
(related thing200_2 thing200_3 prop3)
(instance thing021_9 thing021)
(related thing021_9 thing022_0 prop0)
(instance thing34_7 thing34)
(related thing34_7 thing34_8 prop8)
(instance thing111_5 thing111)
(related thing111_5 thing111_6 prop6)
(instance thing240_4 thing240)
(related thing240_4 thing240_5 prop5)
(instance thing024_4 thing024)
(related thing024_4 thing024_5 prop5)
(instance thing01_6 thing01)
(related thing01_6 thing01_7 prop7)
(instance thing112_0 thing112)
(related thing112_0 thing112_1 prop1)
(instance thing313_8 thing313)
(related thing313_8 thing313_9 prop9)
(instance thing032_5 thing032)
(related thing032_5 thing032_6 prop6)
(instance thing140_4 thing140)
(related thing140_4 thing140_5 prop5)
(instance thing420_3 thing420)
(related thing420_3 thing420_4 prop4)
(instance thing101_2 thing101)
(related thing101_2 thing101_3 prop3)
(instance thing100_9 thing100)
(related thing100_9 thing101_0 prop0)
(instance thing300_5 thing300)
(related thing300_5 thing300_6 prop6)
(instance thing141_5 thing141)
(related thing141_5 thing141_6 prop6)
(instance thing033_9 thing033)
(related thing033_9 thing034_0 prop0)
(instance thing234_5 thing234)
(related thing234_5 thing234_6 prop6)
(instance thing010_3 thing010)
(related thing010_3 thing010_4 prop4)
(instance thing234_9 thing234)
(related thing234_9 thing24_0 prop0)
(instance thing130_7 thing130)
(related thing130_7 thing130_8 prop8)
(instance thing120_8 thing120)
(related thing120_8 thing120_9 prop9)
(instance thing421_0 thing421)
(related thing421_0 thing421_1 prop1)
(instance thing100_3 thing100)
(related thing100_3 thing100_4 prop4)
(instance thing114_3 thing114)
(related thing114_3 thing114_4 prop4)
(instance thing3_5 thing3)
(related thing3_5 thing3_6 prop6)
(instance thing311_0 thing311)
(related thing311_0 thing311_1 prop1)
(instance thing3_3 thing3)
(related thing3_3 thing3_4 prop4)
(instance thing032_3 thing032)
(related thing032_3 thing032_4 prop4)
(instance thing42_3 thing42)
(related thing42_3 thing42_4 prop4)
(instance thing103_2 thing103)
(related thing103_2 thing103_3 prop3)
(instance thing401_2 thing401)
(related thing401_2 thing401_3 prop3)
(instance thing230_6 thing230)
(related thing230_6 thing230_7 prop7)
(instance thing332_1 thing332)
(related thing332_1 thing332_2 prop2)
(instance thing012_5 thing012)
(related thing012_5 thing012_6 prop6)
(instance thing040_9 thing040)
(related thing040_9 thing041_0 prop0)
(instance thing212_0 thing212)
(related thing212_0 thing212_1 prop1)
(instance thing211_2 thing211)
(related thing211_2 thing211_3 prop3)
(instance thing142_4 thing142)
(related thing142_4 thing142_5 prop5)
(instance thing342_5 thing342)
(related thing342_5 thing342_6 prop6)
(instance thing402_8 thing402)
(related thing402_8 thing402_9 prop9)
(instance thing424_4 thing424)
(related thing424_4 thing424_5 prop5)
(instance thing011_8 thing011)
(related thing011_8 thing011_9 prop9)
(instance thing214_0 thing214)
(related thing214_0 thing214_1 prop1)
(instance thing100_1 thing100)
(related thing100_1 thing100_2 prop2)
(instance thing14_4 thing14)
(related thing14_4 thing14_5 prop5)
(instance thing323_8 thing323)
(related thing323_8 thing323_9 prop9)
(instance thing144_2 thing144)
(related thing144_2 thing144_3 prop3)
(instance thing324_4 thing324)
(related thing324_4 thing324_5 prop5)
(instance thing40_6 thing40)
(related thing40_6 thing40_7 prop7)
(instance thing022_9 thing022)
(related thing022_9 thing023_0 prop0)
(instance thing114_0 thing114)
(related thing114_0 thing114_1 prop1)
(instance thing313_7 thing313)
(related thing313_7 thing313_8 prop8)
(instance thing403_3 thing403)
(related thing403_3 thing403_4 prop4)
(instance thing324_2 thing324)
(related thing324_2 thing324_3 prop3)
(instance thing240_0 thing240)
(related thing240_0 thing240_1 prop1)
(instance thing232_6 thing232)
(related thing232_6 thing232_7 prop7)
(instance thing021_8 thing021)
(related thing021_8 thing021_9 prop9)
(instance thing334_0 thing334)
(related thing334_0 thing334_1 prop1)
(instance thing431_6 thing431)
(related thing431_6 thing431_7 prop7)
(instance thing143_0 thing143)
(related thing143_0 thing143_1 prop1)
(instance thing323_9 thing323)
(related thing323_9 thing324_0 prop0)
(instance thing020_2 thing020)
(related thing020_2 thing020_3 prop3)
(instance thing131_8 thing131)
(related thing131_8 thing131_9 prop9)
(instance thing143_1 thing143)
(related thing143_1 thing143_2 prop2)
(instance thing030_5 thing030)
(related thing030_5 thing030_6 prop6)
(instance thing01_7 thing01)
(related thing01_7 thing01_8 prop8)
(instance thing014_0 thing014)
(related thing014_0 thing014_1 prop1)
(instance thing410_2 thing410)
(related thing410_2 thing410_3 prop3)
(instance thing333_3 thing333)
(related thing333_3 thing333_4 prop4)
(instance thing320_8 thing320)
(related thing320_8 thing320_9 prop9)
(instance thing202_8 thing202)
(related thing202_8 thing202_9 prop9)
(instance thing412_5 thing412)
(related thing412_5 thing412_6 prop6)
(instance thing31_4 thing31)
(related thing31_4 thing31_5 prop5)
(instance thing421_1 thing421)
(related thing421_1 thing421_2 prop2)
(instance thing121_4 thing121)
(related thing121_4 thing121_5 prop5)
(instance thing203_0 thing203)
(related thing203_0 thing203_1 prop1)
(instance thing232_0 thing232)
(related thing232_0 thing232_1 prop1)
(instance thing421_2 thing421)
(related thing421_2 thing421_3 prop3)
(instance thing121_1 thing121)
(related thing121_1 thing121_2 prop2)
(instance thing13_4 thing13)
(related thing13_4 thing13_5 prop5)
(instance thing413_1 thing413)
(related thing413_1 thing413_2 prop2)
(instance thing230_4 thing230)
(related thing230_4 thing230_5 prop5)
(instance thing300_6 thing300)
(related thing300_6 thing300_7 prop7)
(instance thing130_5 thing130)
(related thing130_5 thing130_6 prop6)
(instance thing331_6 thing331)
(related thing331_6 thing331_7 prop7)
(instance thing213_5 thing213)
(related thing213_5 thing213_6 prop6)
(instance thing111_4 thing111)
(related thing111_4 thing111_5 prop5)
(instance thing330_7 thing330)
(related thing330_7 thing330_8 prop8)
(instance thing432_8 thing432)
(related thing432_8 thing432_9 prop9)
(instance thing442_0 thing442)
(related thing442_0 thing442_1 prop1)
(instance thing340_5 thing340)
(related thing340_5 thing340_6 prop6)
(instance thing41_1 thing41)
(related thing41_1 thing41_2 prop2)
(instance thing432_2 thing432)
(related thing432_2 thing432_3 prop3)
(instance thing144_0 thing144)
(related thing144_0 thing144_1 prop1)
(instance thing404_6 thing404)
(related thing404_6 thing404_7 prop7)
(instance thing440_1 thing440)
(related thing440_1 thing440_2 prop2)
(instance thing421_9 thing421)
(related thing421_9 thing422_0 prop0)
(instance thing122_2 thing122)
(related thing122_2 thing122_3 prop3)
(instance thing413_2 thing413)
(related thing413_2 thing413_3 prop3)
(instance thing021_6 thing021)
(related thing021_6 thing021_7 prop7)
(instance thing20_7 thing20)
(related thing20_7 thing20_8 prop8)
(instance thing104_0 thing104)
(related thing104_0 thing104_1 prop1)
(instance thing010_8 thing010)
(related thing010_8 thing010_9 prop9)
(instance thing133_4 thing133)
(related thing133_4 thing133_5 prop5)
(instance thing042_8 thing042)
(related thing042_8 thing042_9 prop9)
(instance thing424_2 thing424)
(related thing424_2 thing424_3 prop3)
(instance thing4_7 thing4)
(related thing4_7 thing4_8 prop8)
(instance thing42_8 thing42)
(related thing42_8 thing42_9 prop9)
(instance thing444_3 thing444)
(related thing444_3 thing444_4 prop4)
(instance thing242_4 thing242)
(related thing242_4 thing242_5 prop5)
(instance thing132_2 thing132)
(related thing132_2 thing132_3 prop3)
(instance thing041_5 thing041)
(related thing041_5 thing041_6 prop6)
(instance thing243_9 thing243)
(related thing243_9 thing244_0 prop0)
(instance thing33_3 thing33)
(related thing33_3 thing33_4 prop4)
(instance thing332_7 thing332)
(related thing332_7 thing332_8 prop8)
(instance thing211_9 thing211)
(related thing211_9 thing212_0 prop0)
(instance thing010_5 thing010)
(related thing010_5 thing010_6 prop6)
(instance thing004_7 thing004)
(related thing004_7 thing004_8 prop8)
(instance thing044_4 thing044)
(related thing044_4 thing044_5 prop5)
(instance thing000_7 thing000)
(related thing000_7 thing000_8 prop8)
(instance thing20_3 thing20)
(related thing20_3 thing20_4 prop4)
(instance thing141_1 thing141)
(related thing141_1 thing141_2 prop2)
(instance thing414_1 thing414)
(related thing414_1 thing414_2 prop2)
(instance thing13_7 thing13)
(related thing13_7 thing13_8 prop8)
(instance thing113_5 thing113)
(related thing113_5 thing113_6 prop6)
(instance thing430_5 thing430)
(related thing430_5 thing430_6 prop6)
(instance thing31_0 thing31)
(related thing31_0 thing31_1 prop1)
(instance thing14_2 thing14)
(related thing14_2 thing14_3 prop3)
(instance thing200_7 thing200)
(related thing200_7 thing200_8 prop8)
(instance thing003_4 thing003)
(related thing003_4 thing003_5 prop5)
(instance thing22_2 thing22)
(related thing22_2 thing22_3 prop3)
(instance thing412_4 thing412)
(related thing412_4 thing412_5 prop5)
(instance thing242_7 thing242)
(related thing242_7 thing242_8 prop8)
(instance thing04_5 thing04)
(related thing04_5 thing04_6 prop6)
(instance thing142_6 thing142)
(related thing142_6 thing142_7 prop7)
(instance thing220_9 thing220)
(related thing220_9 thing221_0 prop0)
(instance thing232_7 thing232)
(related thing232_7 thing232_8 prop8)
(instance thing303_8 thing303)
(related thing303_8 thing303_9 prop9)
(instance thing300_2 thing300)
(related thing300_2 thing300_3 prop3)
(instance thing114_9 thing114)
(related thing114_9 thing12_0 prop0)
(instance thing020_0 thing020)
(related thing020_0 thing020_1 prop1)
(instance thing302_9 thing302)
(related thing302_9 thing303_0 prop0)
(instance thing412_0 thing412)
(related thing412_0 thing412_1 prop1)
(instance thing013_0 thing013)
(related thing013_0 thing013_1 prop1)
(instance thing042_2 thing042)
(related thing042_2 thing042_3 prop3)
(instance thing331_8 thing331)
(related thing331_8 thing331_9 prop9)
(instance thing001_5 thing001)
(related thing001_5 thing001_6 prop6)
(instance thing212_9 thing212)
(related thing212_9 thing213_0 prop0)
(instance thing142_8 thing142)
(related thing142_8 thing142_9 prop9)
(instance thing104_4 thing104)
(related thing104_4 thing104_5 prop5)
(instance thing114_7 thing114)
(related thing114_7 thing114_8 prop8)
(instance thing401_5 thing401)
(related thing401_5 thing401_6 prop6)
(instance thing003_7 thing003)
(related thing003_7 thing003_8 prop8)
(instance thing032_8 thing032)
(related thing032_8 thing032_9 prop9)
(instance thing212_8 thing212)
(related thing212_8 thing212_9 prop9)
(instance thing114_5 thing114)
(related thing114_5 thing114_6 prop6)
(instance thing440_4 thing440)
(related thing440_4 thing440_5 prop5)
(instance thing010_4 thing010)
(related thing010_4 thing010_5 prop5)
(instance thing34_1 thing34)
(related thing34_1 thing34_2 prop2)
(instance thing234_4 thing234)
(related thing234_4 thing234_5 prop5)
(instance thing14_3 thing14)
(related thing14_3 thing14_4 prop4)
(instance thing24_2 thing24)
(related thing24_2 thing24_3 prop3)
(instance thing20_1 thing20)
(related thing20_1 thing20_2 prop2)
(instance thing422_8 thing422)
(related thing422_8 thing422_9 prop9)
(instance thing030_4 thing030)
(related thing030_4 thing030_5 prop5)
(instance thing402_9 thing402)
(related thing402_9 thing403_0 prop0)
(instance thing313_5 thing313)
(related thing313_5 thing313_6 prop6)
(instance thing00_7 thing00)
(related thing00_7 thing00_8 prop8)
(instance thing024_0 thing024)
(related thing024_0 thing024_1 prop1)
(instance thing111_6 thing111)
(related thing111_6 thing111_7 prop7)
(instance thing2_8 thing2)
(related thing2_8 thing2_9 prop9)
(instance thing44_5 thing44)
(related thing44_5 thing44_6 prop6)
(instance thing140_1 thing140)
(related thing140_1 thing140_2 prop2)
(instance thing210_5 thing210)
(related thing210_5 thing210_6 prop6)
(instance thing443_4 thing443)
(related thing443_4 thing443_5 prop5)
(instance thing122_0 thing122)
(related thing122_0 thing122_1 prop1)
(instance thing130_3 thing130)
(related thing130_3 thing130_4 prop4)
(instance thing111_3 thing111)
(related thing111_3 thing111_4 prop4)
(instance thing1_2 thing1)
(related thing1_2 thing1_3 prop3)
(instance thing022_4 thing022)
(related thing022_4 thing022_5 prop5)
(instance thing104_2 thing104)
(related thing104_2 thing104_3 prop3)
(instance thing020_8 thing020)
(related thing020_8 thing020_9 prop9)
(instance thing400_0 thing400)
(related thing400_0 thing400_1 prop1)
(instance thing001_7 thing001)
(related thing001_7 thing001_8 prop8)
(instance thing423_6 thing423)
(related thing423_6 thing423_7 prop7)
(instance thing230_1 thing230)
(related thing230_1 thing230_2 prop2)
(instance thing440_7 thing440)
(related thing440_7 thing440_8 prop8)
(instance thing431_4 thing431)
(related thing431_4 thing431_5 prop5)
(instance thing103_4 thing103)
(related thing103_4 thing103_5 prop5)
(instance thing444_5 thing444)
(related thing444_5 thing444_6 prop6)
(instance thing032_6 thing032)
(related thing032_6 thing032_7 prop7)
(instance thing10_8 thing10)
(related thing10_8 thing10_9 prop9)
(instance thing321_1 thing321)
(related thing321_1 thing321_2 prop2)
(instance thing224_5 thing224)
(related thing224_5 thing224_6 prop6)
(instance thing113_2 thing113)
(related thing113_2 thing113_3 prop3)
(instance thing222_2 thing222)
(related thing222_2 thing222_3 prop3)
(instance thing434_3 thing434)
(related thing434_3 thing434_4 prop4)
(instance thing20_0 thing20)
(related thing20_0 thing20_1 prop1)
(instance thing411_2 thing411)
(related thing411_2 thing411_3 prop3)
(instance thing004_4 thing004)
(related thing004_4 thing004_5 prop5)
(instance thing001_0 thing001)
(related thing001_0 thing001_1 prop1)
(instance thing112_2 thing112)
(related thing112_2 thing112_3 prop3)
(instance thing030_8 thing030)
(related thing030_8 thing030_9 prop9)
(instance thing114_4 thing114)
(related thing114_4 thing114_5 prop5)
(instance thing324_7 thing324)
(related thing324_7 thing324_8 prop8)
(instance thing142_9 thing142)
(related thing142_9 thing143_0 prop0)
(instance thing404_2 thing404)
(related thing404_2 thing404_3 prop3)
(instance thing012_3 thing012)
(related thing012_3 thing012_4 prop4)
(instance thing2_6 thing2)
(related thing2_6 thing2_7 prop7)
(instance thing044_2 thing044)
(related thing044_2 thing044_3 prop3)
(instance thing031_8 thing031)
(related thing031_8 thing031_9 prop9)
(instance thing041_2 thing041)
(related thing041_2 thing041_3 prop3)
(instance thing043_2 thing043)
(related thing043_2 thing043_3 prop3)
(instance thing312_5 thing312)
(related thing312_5 thing312_6 prop6)
(instance thing001_4 thing001)
(related thing001_4 thing001_5 prop5)
(instance thing42_0 thing42)
(related thing42_0 thing42_1 prop1)
(instance thing022_6 thing022)
(related thing022_6 thing022_7 prop7)
(instance thing00_8 thing00)
(related thing00_8 thing00_9 prop9)
(instance thing040_7 thing040)
(related thing040_7 thing040_8 prop8)
(instance thing014_9 thing014)
(related thing014_9 thing02_0 prop0)
(instance thing430_6 thing430)
(related thing430_6 thing430_7 prop7)
(instance thing213_0 thing213)
(related thing213_0 thing213_1 prop1)
(instance thing112_5 thing112)
(related thing112_5 thing112_6 prop6)
(instance thing301_2 thing301)
(related thing301_2 thing301_3 prop3)
(instance thing123_7 thing123)
(related thing123_7 thing123_8 prop8)
(instance thing121_5 thing121)
(related thing121_5 thing121_6 prop6)
(instance thing44_6 thing44)
(related thing44_6 thing44_7 prop7)
(instance thing22_8 thing22)
(related thing22_8 thing22_9 prop9)
(instance thing422_4 thing422)
(related thing422_4 thing422_5 prop5)
(instance thing122_7 thing122)
(related thing122_7 thing122_8 prop8)
(instance thing414_8 thing414)
(related thing414_8 thing414_9 prop9)
(instance thing03_1 thing03)
(related thing03_1 thing03_2 prop2)
(instance thing404_0 thing404)
(related thing404_0 thing404_1 prop1)
(instance thing210_2 thing210)
(related thing210_2 thing210_3 prop3)
(instance thing4_9 thing4)
(related thing4_9 thing40_0 prop0)
(instance thing23_3 thing23)
(related thing23_3 thing23_4 prop4)
(instance thing32_4 thing32)
(related thing32_4 thing32_5 prop5)
(instance thing201_1 thing201)
(related thing201_1 thing201_2 prop2)
(instance thing040_4 thing040)
(related thing040_4 thing040_5 prop5)
(instance thing024_1 thing024)
(related thing024_1 thing024_2 prop2)
(instance thing021_0 thing021)
(related thing021_0 thing021_1 prop1)
(instance thing222_8 thing222)
(related thing222_8 thing222_9 prop9)
(instance thing21_8 thing21)
(related thing21_8 thing21_9 prop9)
(instance thing320_2 thing320)
(related thing320_2 thing320_3 prop3)
(instance thing311_5 thing311)
(related thing311_5 thing311_6 prop6)
(instance thing313_2 thing313)
(related thing313_2 thing313_3 prop3)
(instance thing123_6 thing123)
(related thing123_6 thing123_7 prop7)
(instance thing203_9 thing203)
(related thing203_9 thing204_0 prop0)
(instance thing212_1 thing212)
(related thing212_1 thing212_2 prop2)
(instance thing414_3 thing414)
(related thing414_3 thing414_4 prop4)
(instance thing214_4 thing214)
(related thing214_4 thing214_5 prop5)
(instance thing044_0 thing044)
(related thing044_0 thing044_1 prop1)
(instance thing040_3 thing040)
(related thing040_3 thing040_4 prop4)
(instance thing112_1 thing112)
(related thing112_1 thing112_2 prop2)
(instance thing433_7 thing433)
(related thing433_7 thing433_8 prop8)
(instance thing024_5 thing024)
(related thing024_5 thing024_6 prop6)
(instance thing03_9 thing03)
(related thing03_9 thing030_0 prop0)
(instance thing330_2 thing330)
(related thing330_2 thing330_3 prop3)
(instance thing232_4 thing232)
(related thing232_4 thing232_5 prop5)
(instance thing313_0 thing313)
(related thing313_0 thing313_1 prop1)
(instance thing443_0 thing443)
(related thing443_0 thing443_1 prop1)
(instance thing233_6 thing233)
(related thing233_6 thing233_7 prop7)
(instance thing431_7 thing431)
(related thing431_7 thing431_8 prop8)
(instance thing1_9 thing1)
(related thing1_9 thing10_0 prop0)
(instance thing324_9 thing324)
(related thing324_9 thing33_0 prop0)
(instance thing133_5 thing133)
(related thing133_5 thing133_6 prop6)
(instance thing022_2 thing022)
(related thing022_2 thing022_3 prop3)
(instance thing321_9 thing321)
(related thing321_9 thing322_0 prop0)
(instance thing213_4 thing213)
(related thing213_4 thing213_5 prop5)
(instance thing101_9 thing101)
(related thing101_9 thing102_0 prop0)
(instance thing032_7 thing032)
(related thing032_7 thing032_8 prop8)
(instance thing203_7 thing203)
(related thing203_7 thing203_8 prop8)
(instance thing123_4 thing123)
(related thing123_4 thing123_5 prop5)
(instance thing02_0 thing02)
(related thing02_0 thing02_1 prop1)
(instance thing010_1 thing010)
(related thing010_1 thing010_2 prop2)
(instance thing0_6 thing0)
(related thing0_6 thing0_7 prop7)
(instance thing341_2 thing341)
(related thing341_2 thing341_3 prop3)
(instance thing0_7 thing0)
(related thing0_7 thing0_8 prop8)
(instance thing12_6 thing12)
(related thing12_6 thing12_7 prop7)
(instance thing143_8 thing143)
(related thing143_8 thing143_9 prop9)
(instance thing033_4 thing033)
(related thing033_4 thing033_5 prop5)
(instance thing211_1 thing211)
(related thing211_1 thing211_2 prop2)
(instance thing432_4 thing432)
(related thing432_4 thing432_5 prop5)
(instance thing23_4 thing23)
(related thing23_4 thing23_5 prop5)
(instance thing11_5 thing11)
(related thing11_5 thing11_6 prop6)
(instance thing134_4 thing134)
(related thing134_4 thing134_5 prop5)
(instance thing222_4 thing222)
(related thing222_4 thing222_5 prop5)
(instance thing011_5 thing011)
(related thing011_5 thing011_6 prop6)
(instance thing023_7 thing023)
(related thing023_7 thing023_8 prop8)
(instance thing131_4 thing131)
(related thing131_4 thing131_5 prop5)
(instance thing232_5 thing232)
(related thing232_5 thing232_6 prop6)
(instance thing241_4 thing241)
(related thing241_4 thing241_5 prop5)
(instance thing112_9 thing112)
(related thing112_9 thing113_0 prop0)
(instance thing012_2 thing012)
(related thing012_2 thing012_3 prop3)
(instance thing032_4 thing032)
(related thing032_4 thing032_5 prop5)
(instance thing340_2 thing340)
(related thing340_2 thing340_3 prop3)
(instance thing230_8 thing230)
(related thing230_8 thing230_9 prop9)
(instance thing301_6 thing301)
(related thing301_6 thing301_7 prop7)
(instance thing421_3 thing421)
(related thing421_3 thing421_4 prop4)
(instance thing23_6 thing23)
(related thing23_6 thing23_7 prop7)
(instance thing00_3 thing00)
(related thing00_3 thing00_4 prop4)
(instance thing202_5 thing202)
(related thing202_5 thing202_6 prop6)
(instance thing302_8 thing302)
(related thing302_8 thing302_9 prop9)
(instance thing112_8 thing112)
(related thing112_8 thing112_9 prop9)
(instance thing033_2 thing033)
(related thing033_2 thing033_3 prop3)
(instance thing320_1 thing320)
(related thing320_1 thing320_2 prop2)
(instance thing132_9 thing132)
(related thing132_9 thing133_0 prop0)
(instance thing1_1 thing1)
(related thing1_1 thing1_2 prop2)
(instance thing340_4 thing340)
(related thing340_4 thing340_5 prop5)
(instance thing140_7 thing140)
(related thing140_7 thing140_8 prop8)
(instance thing122_3 thing122)
(related thing122_3 thing122_4 prop4)
(instance thing441_2 thing441)
(related thing441_2 thing441_3 prop3)
(instance thing42_4 thing42)
(related thing42_4 thing42_5 prop5)
(instance thing11_6 thing11)
(related thing11_6 thing11_7 prop7)
(instance thing43_6 thing43)
(related thing43_6 thing43_7 prop7)
(instance thing301_7 thing301)
(related thing301_7 thing301_8 prop8)
(instance thing404_4 thing404)
(related thing404_4 thing404_5 prop5)
(instance thing141_6 thing141)
(related thing141_6 thing141_7 prop7)
(instance thing043_8 thing043)
(related thing043_8 thing043_9 prop9)
(instance thing133_7 thing133)
(related thing133_7 thing133_8 prop8)
(instance thing404_3 thing404)
(related thing404_3 thing404_4 prop4)
(instance thing11_8 thing11)
(related thing11_8 thing11_9 prop9)
(instance thing423_7 thing423)
(related thing423_7 thing423_8 prop8)
(instance thing423_5 thing423)
(related thing423_5 thing423_6 prop6)
(instance thing10_9 thing10)
(related thing10_9 thing100_0 prop0)
(instance thing400_8 thing400)
(related thing400_8 thing400_9 prop9)
(instance thing2_9 thing2)
(related thing2_9 thing20_0 prop0)
(instance thing113_1 thing113)
(related thing113_1 thing113_2 prop2)
(instance thing43_3 thing43)
(related thing43_3 thing43_4 prop4)
(instance thing234_0 thing234)
(related thing234_0 thing234_1 prop1)
(instance thing230_2 thing230)
(related thing230_2 thing230_3 prop3)
(instance thing04_8 thing04)
(related thing04_8 thing04_9 prop9)
(instance thing24_0 thing24)
(related thing24_0 thing24_1 prop1)
(instance thing204_5 thing204)
(related thing204_5 thing204_6 prop6)
(instance thing031_5 thing031)
(related thing031_5 thing031_6 prop6)
(instance thing00_9 thing00)
(related thing00_9 thing000_0 prop0)
(instance thing444_8 thing444)
(related thing444_8 thing444_9 prop9)
(instance thing313_1 thing313)
(related thing313_1 thing313_2 prop2)
(instance thing103_3 thing103)
(related thing103_3 thing103_4 prop4)
(instance thing21_3 thing21)
(related thing21_3 thing21_4 prop4)
(instance thing120_1 thing120)
(related thing120_1 thing120_2 prop2)
(instance thing10_7 thing10)
(related thing10_7 thing10_8 prop8)
(instance thing414_7 thing414)
(related thing414_7 thing414_8 prop8)
(instance thing313_9 thing313)
(related thing313_9 thing314_0 prop0)
(instance thing414_9 thing414)
(related thing414_9 thing42_0 prop0)
(instance thing301_5 thing301)
(related thing301_5 thing301_6 prop6)
(instance thing4_3 thing4)
(related thing4_3 thing4_4 prop4)
(instance thing01_2 thing01)
(related thing01_2 thing01_3 prop3)
(instance thing130_1 thing130)
(related thing130_1 thing130_2 prop2)
(instance thing210_6 thing210)
(related thing210_6 thing210_7 prop7)
(instance thing423_4 thing423)
(related thing423_4 thing423_5 prop5)
(instance thing201_6 thing201)
(related thing201_6 thing201_7 prop7)
(instance thing30_3 thing30)
(related thing30_3 thing30_4 prop4)
(instance thing220_6 thing220)
(related thing220_6 thing220_7 prop7)
(instance thing043_7 thing043)
(related thing043_7 thing043_8 prop8)
(instance thing342_8 thing342)
(related thing342_8 thing342_9 prop9)
(instance thing20_8 thing20)
(related thing20_8 thing20_9 prop9)
(instance thing4_5 thing4)
(related thing4_5 thing4_6 prop6)
(instance thing040_8 thing040)
(related thing040_8 thing040_9 prop9)
(instance thing12_2 thing12)
(related thing12_2 thing12_3 prop3)
(instance thing24_7 thing24)
(related thing24_7 thing24_8 prop8)
(instance thing440_6 thing440)
(related thing440_6 thing440_7 prop7)
(instance thing433_3 thing433)
(related thing433_3 thing433_4 prop4)
(instance thing32_0 thing32)
(related thing32_0 thing32_1 prop1)
(instance thing303_1 thing303)
(related thing303_1 thing303_2 prop2)
(instance thing141_9 thing141)
(related thing141_9 thing142_0 prop0)
(instance thing442_4 thing442)
(related thing442_4 thing442_5 prop5)
(instance thing302_2 thing302)
(related thing302_2 thing302_3 prop3)
(instance thing312_1 thing312)
(related thing312_1 thing312_2 prop2)
(instance thing344_8 thing344)
(related thing344_8 thing344_9 prop9)
(instance thing02_7 thing02)
(related thing02_7 thing02_8 prop8)
(instance thing123_1 thing123)
(related thing123_1 thing123_2 prop2)
(instance thing002_5 thing002)
(related thing002_5 thing002_6 prop6)
(instance thing340_1 thing340)
(related thing340_1 thing340_2 prop2)
(instance thing11_4 thing11)
(related thing11_4 thing11_5 prop5)
(instance thing113_6 thing113)
(related thing113_6 thing113_7 prop7)
(instance thing243_6 thing243)
(related thing243_6 thing243_7 prop7)
(instance thing332_5 thing332)
(related thing332_5 thing332_6 prop6)
(instance thing110_0 thing110)
(related thing110_0 thing110_1 prop1)
(instance thing02_5 thing02)
(related thing02_5 thing02_6 prop6)
(instance thing440_2 thing440)
(related thing440_2 thing440_3 prop3)
(instance thing40_0 thing40)
(related thing40_0 thing40_1 prop1)
(instance thing331_9 thing331)
(related thing331_9 thing332_0 prop0)
(instance thing322_7 thing322)
(related thing322_7 thing322_8 prop8)
(instance thing241_3 thing241)
(related thing241_3 thing241_4 prop4)
(instance thing241_6 thing241)
(related thing241_6 thing241_7 prop7)
(instance thing314_0 thing314)
(related thing314_0 thing314_1 prop1)
(instance thing412_7 thing412)
(related thing412_7 thing412_8 prop8)
(instance thing102_9 thing102)
(related thing102_9 thing103_0 prop0)
(instance thing311_9 thing311)
(related thing311_9 thing312_0 prop0)
(instance thing24_4 thing24)
(related thing24_4 thing24_5 prop5)
(instance thing202_6 thing202)
(related thing202_6 thing202_7 prop7)
(instance thing340_0 thing340)
(related thing340_0 thing340_1 prop1)
(instance thing323_6 thing323)
(related thing323_6 thing323_7 prop7)
(instance thing20_2 thing20)
(related thing20_2 thing20_3 prop3)
(instance thing343_5 thing343)
(related thing343_5 thing343_6 prop6)
(instance thing03_7 thing03)
(related thing03_7 thing03_8 prop8)
(instance thing14_9 thing14)
(related thing14_9 thing140_0 prop0)
(instance thing432_0 thing432)
(related thing432_0 thing432_1 prop1)
(instance thing110_8 thing110)
(related thing110_8 thing110_9 prop9)
(instance thing343_3 thing343)
(related thing343_3 thing343_4 prop4)
(instance thing14_0 thing14)
(related thing14_0 thing14_1 prop1)
(instance thing422_1 thing422)
(related thing422_1 thing422_2 prop2)
(instance thing434_5 thing434)
(related thing434_5 thing434_6 prop6)
(instance thing1_5 thing1)
(related thing1_5 thing1_6 prop6)
(instance thing041_1 thing041)
(related thing041_1 thing041_2 prop2)
(instance thing01_5 thing01)
(related thing01_5 thing01_6 prop6)
(instance thing210_9 thing210)
(related thing210_9 thing211_0 prop0)
(instance thing344_7 thing344)
(related thing344_7 thing344_8 prop8)
(instance thing211_5 thing211)
(related thing211_5 thing211_6 prop6)
(instance thing221_5 thing221)
(related thing221_5 thing221_6 prop6)
(instance thing342_2 thing342)
(related thing342_2 thing342_3 prop3)
(instance thing030_0 thing030)
(related thing030_0 thing030_1 prop1)
(instance thing22_1 thing22)
(related thing22_1 thing22_2 prop2)
(instance thing101_8 thing101)
(related thing101_8 thing101_9 prop9)
(instance thing11_1 thing11)
(related thing11_1 thing11_2 prop2)
(instance thing031_2 thing031)
(related thing031_2 thing031_3 prop3)
(instance thing341_5 thing341)
(related thing341_5 thing341_6 prop6)
(instance thing00_0 thing00)
(related thing00_0 thing00_1 prop1)
(instance thing220_0 thing220)
(related thing220_0 thing220_1 prop1)
(instance thing023_4 thing023)
(related thing023_4 thing023_5 prop5)
(instance thing212_2 thing212)
(related thing212_2 thing212_3 prop3)
(instance thing30_2 thing30)
(related thing30_2 thing30_3 prop3)
(instance thing132_6 thing132)
(related thing132_6 thing132_7 prop7)
(instance thing112_6 thing112)
(related thing112_6 thing112_7 prop7)
(instance thing41_6 thing41)
(related thing41_6 thing41_7 prop7)
(instance thing103_7 thing103)
(related thing103_7 thing103_8 prop8)
(instance thing100_8 thing100)
(related thing100_8 thing100_9 prop9)
(instance thing02_9 thing02)
(related thing02_9 thing020_0 prop0)
(instance thing023_0 thing023)
(related thing023_0 thing023_1 prop1)
(instance thing30_4 thing30)
(related thing30_4 thing30_5 prop5)
(instance thing424_7 thing424)
(related thing424_7 thing424_8 prop8)
(instance thing400_7 thing400)
(related thing400_7 thing400_8 prop8)
(instance thing102_3 thing102)
(related thing102_3 thing102_4 prop4)
(instance thing04_1 thing04)
(related thing04_1 thing04_2 prop2)
(instance thing402_5 thing402)
(related thing402_5 thing402_6 prop6)
(instance thing3_7 thing3)
(related thing3_7 thing3_8 prop8)
(instance thing12_3 thing12)
(related thing12_3 thing12_4 prop4)
(instance thing101_5 thing101)
(related thing101_5 thing101_6 prop6)
(instance thing11_2 thing11)
(related thing11_2 thing11_3 prop3)
(instance thing32_9 thing32)
(related thing32_9 thing320_0 prop0)
(instance thing012_0 thing012)
(related thing012_0 thing012_1 prop1)
(instance thing210_3 thing210)
(related thing210_3 thing210_4 prop4)
(instance thing213_8 thing213)
(related thing213_8 thing213_9 prop9)
(instance thing22_9 thing22)
(related thing22_9 thing220_0 prop0)
(instance thing120_6 thing120)
(related thing120_6 thing120_7 prop7)
(instance thing304_3 thing304)
(related thing304_3 thing304_4 prop4)
(instance thing301_9 thing301)
(related thing301_9 thing302_0 prop0)
(instance thing241_9 thing241)
(related thing241_9 thing242_0 prop0)
(instance thing114_8 thing114)
(related thing114_8 thing114_9 prop9)
(instance thing422_6 thing422)
(related thing422_6 thing422_7 prop7)
(instance thing040_0 thing040)
(related thing040_0 thing040_1 prop1)
(instance thing322_1 thing322)
(related thing322_1 thing322_2 prop2)
(instance thing11_9 thing11)
(related thing11_9 thing110_0 prop0)
(instance thing402_4 thing402)
(related thing402_4 thing402_5 prop5)
(instance thing200_0 thing200)
(related thing200_0 thing200_1 prop1)
(instance thing044_9 thing044)
(related thing044_9 thing1_0 prop0)
(instance thing331_2 thing331)
(related thing331_2 thing331_3 prop3)
(instance thing103_1 thing103)
(related thing103_1 thing103_2 prop2)
(instance thing02_1 thing02)
(related thing02_1 thing02_2 prop2)
(instance thing01_4 thing01)
(related thing01_4 thing01_5 prop5)
(instance thing314_2 thing314)
(related thing314_2 thing314_3 prop3)
(instance thing420_9 thing420)
(related thing420_9 thing421_0 prop0)
(instance thing131_6 thing131)
(related thing131_6 thing131_7 prop7)
(instance thing340_6 thing340)
(related thing340_6 thing340_7 prop7)
(instance thing010_0 thing010)
(related thing010_0 thing010_1 prop1)
(instance thing331_1 thing331)
(related thing331_1 thing331_2 prop2)
(instance thing312_2 thing312)
(related thing312_2 thing312_3 prop3)
| 113,559 | Common Lisp | .lisp | 1 | 113,558 | 113,559 | 0.79099 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 90e1c8c1949fcc63a274e43f7052d3b0a82b387cf62e2d87005023e5e0220c88 | 12,536 | [
-1
] |
12,537 | abstractions.lisp | lambdamikel_DLMAPS/src/prover/abstractions.lisp | ;; -*- 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))
| 41,428 | Common Lisp | .lisp | 668 | 29.769461 | 149 | 0.364159 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 52bb2a94fa7083213812d89a61745f6d499ab1d4eddda1ebb8cb9d08ee34eeab | 12,537 | [
-1
] |
12,538 | bug.lisp | lambdamikel_DLMAPS/src/prover/bug.lisp | (define-primitive-role r1)
(define-primitive-role r2)
(define-primitive-role r3)
(define-primitive-role r4)
(define-primitive-role r5)
(define-primitive-role r6)
(define-primitive-role r7)
(define-primitive-role r8)
(define-primitive-role r9)
(define-primitive-role r10)
(define-primitive-concept c0 TOP)
(define-primitive-concept c1
(and (all r3 c0)
(at-least 1 r8)
(at-most 8 r2)))
(define-primitive-concept c2 TOP)
(define-primitive-concept c3
(and (at-least 5 r9)))
(define-concept c4
(and c2
(at-least 2 r8)))
(define-primitive-concept c5
(and c3
(at-least 4 r10)
(at-most 6 r2)))
(define-primitive-concept c6
(and c2
(at-most 5 r6)))
(define-concept c7
(and c3
(at-least 2 r7)
(at-most 9 r10)))
(define-primitive-concept c8
(and c3
(all r8 c0)
(at-most 6 r8)))
(define-concept c9
(and c2 c1
(all r8 c2)
(at-most 5 r2)))
(define-primitive-concept c10
(and c3
(all r1 c0)
(at-most 5 r7)))
(define-primitive-concept c11
(and c3
(all r3 c1)
(at-least 4 r5)
(at-most 6 r9)))
(define-primitive-concept c12
(and c1
(all r8 c0)
(at-least 2 r3)))
(define-primitive-concept c13
(and c10
(all r8 c5)
(at-most 5 r4)))
(define-primitive-concept c14
(and c6 c5
(all r1 c3)))
(define-primitive-concept c15
(and c11 c12
(all r1 c0)
(at-least 4 r2)))
(define-primitive-concept c16
(and c12 c8
(all r7 c10) (all r9 c1)
(at-least 4 r3)
(at-most 5 r2)))
(define-primitive-concept c17
(and c4 c8
(all r6 c9) (all r4 c4)
(at-least 4 r6)))
(define-primitive-concept c18
(and c10
(all r2 c6)
(at-least 3 r2)))
(define-primitive-concept c19
(and c6
(all r4 c8)
(at-least 2 r9)))
(define-primitive-concept c20
(and c3 c10
(at-least 1 r8)
(at-most 7 r10)))
(define-primitive-concept c21
(and c5 c10
(all r8 c2)
(at-least 1 r10)))
(define-primitive-concept c22
(and c7 c4
(all r4 c5)))
(define-concept c23
(and c12
(all r5 c8)))
(define-concept c24
(and c8
(all r6 c0)))
(define-primitive-concept c25
(and c5 c12
(all r5 c7) (all r4 c4)
(at-least 5 r8)))
(define-primitive-concept c26
(and c8
(all r3 c8)
(at-most 5 r3)))
(define-primitive-concept c27
(and c11
(all r8 c4)
(at-least 5 r6)))
(define-primitive-concept c28
(and c11
(all r6 c1)))
(define-concept c29
(and c7 c11
(all r8 c8) (all r1 c5)
(at-least 4 r5)
(at-most 8 r10)))
(define-primitive-concept c30
(and c12
(at-least 5 r5)
(at-most 5 r2)))
(define-primitive-concept c31
(and c5 c11
(all r1 c5) (all r7 c5)
(at-least 4 r3)
(at-most 7 r10)))
(define-primitive-concept c32
(and c2 c10
(all r1 c0) (all r10 c12)
(at-least 4 r8)
(at-most 8 r9)))
(define-primitive-concept c33
(and c7
(all r8 c6) (all r3 c3)
(at-least 2 r2)
(at-most 7 r1)))
(define-concept c34
(and c6
(at-least 4 r6)
(at-most 9 r10)))
(define-primitive-concept c35
(and c8
(at-least 1 r8)))
(define-primitive-concept c36
(and c9
(all r6 c2)
(at-least 3 r3)))
(define-concept c37
(and c12
(all r6 c0)
(at-most 6 r3)))
(define-primitive-concept c38
(and c11
(all r7 c8) (all r3 c7)))
(define-concept c39
(and c11
(all r9 c12)
(at-least 3 r7)))
(define-primitive-concept c40
(and c38
(all r6 c14)))
(define-primitive-concept c41
(and c13
(all r6 c2)
(at-most 9 r8)))
(define-primitive-concept c42
(and c14
(all r6 c19) (all r9 c15)
(at-most 7 r1)))
(define-primitive-concept c43
(and c28
(all r1 c17)
(at-least 2 r8)
(at-most 9 r5)))
(define-primitive-concept c44
(and c35
(all r5 c35)
(at-least 1 r5)))
(define-primitive-concept c45
(and c15
(all r6 c3)
(at-most 8 r5)))
(define-primitive-concept c46
(and c3 c28
(at-most 7 r3)))
(define-primitive-concept c47
(and c29 c23))
(define-primitive-concept c48
(and c27
(at-least 5 r9)))
(define-primitive-concept c49
(and c18
(all r9 c38)
(at-most 8 r4)))
(define-primitive-concept c50
(and c19
(at-least 1 r2)))
(define-primitive-concept c51
(and c22
(at-least 5 r10)))
(define-primitive-concept c52
(and c33 c32
(at-most 5 r5)))
(define-primitive-concept c53
(and c6 c23
(at-least 2 r2)
(at-most 5 r6)))
(define-primitive-concept c54
(and c39 c23
(all r8 c8)))
(define-concept c55
(and c7 c24
(at-least 1 r2)
(at-most 9 r1)))
(define-primitive-concept c56
(and c39
(all r5 c17)
(at-most 8 r8)))
(define-primitive-concept c57
(and c25 c36
(all r1 c28)
(at-least 2 r2)
(at-most 8 r10)))
(define-primitive-concept c58
(and c29 c34
(at-most 8 r4)))
(define-concept c59
(and c35
(all r2 c34)))
(define-primitive-concept c60
(and c32 c34
(all r6 c3) (all r10 c32)
(at-most 9 r8)))
(define-concept c61
(and c32
(all r9 c5)))
(define-primitive-concept c62
(and c23 c35
(at-least 1 r10)))
(define-concept c63
(and c22
(all r1 c38)
(at-least 5 r2)
(at-most 8 r8)))
(define-primitive-concept c64
(and c33 c39
(all r1 c28)
(at-least 5 r1)
(at-most 5 r6)))
(define-primitive-concept c65
(and c38
(all r3 c25)
(at-least 5 r7)
(at-most 8 r5)))
(define-primitive-concept c66
(and c26
(all r8 c22)
(at-most 6 r1)))
(define-primitive-concept c67
(and c23
(at-most 6 r4)))
(define-primitive-concept c68
(and c16 c15
(all r7 c14) (all r1 c39)))
(define-primitive-concept c69
(and c34
(all r8 c2) (all r4 c27)
(at-least 3 r4)))
(define-concept c70
(and c23
(at-most 6 r3)))
(define-primitive-concept c71
(and c15 c29
(at-most 8 r8)))
(define-primitive-concept c72
(and c7 c17
(all r4 c34)
(at-most 5 r7)))
(define-primitive-concept c73
(and c17
(all r9 c12) (all r4 c0)
(at-most 9 r9)))
(define-primitive-concept c74
(and c5 c34
(all r7 c7)
(at-least 1 r1)))
(define-primitive-concept c75
(and c35
(at-least 1 r4)))
(define-primitive-concept c76
(and c32
(all r7 c29) (all r9 c26)
(at-least 2 r5)))
(define-primitive-concept c77
(and c30 c17
(at-least 3 r5)))
(define-primitive-concept c78
(and c21
(at-least 5 r1)))
(define-primitive-concept c79
(and c18 c22
(all r7 c13) (all r2 c28)
(at-least 1 r8)))
(define-primitive-concept c80
(and c27 c22
(all r3 c27)
(at-most 7 r6)))
(define-concept c81
(and c23 c29
(all r3 c1)
(at-least 2 r10)))
(define-concept c82
(and c22 c39
(all r7 c6)
(at-least 2 r1)))
(define-primitive-concept c83
(and c18))
(define-concept c84
(and c3 c27
(at-least 2 r6)))
(define-primitive-concept c85
(and c21))
(define-concept c86
(and c39
(at-least 3 r5)
(at-most 7 r2)))
(define-primitive-concept c87
(and c11 c32
(all r3 c23) (all r8 c19)))
(define-primitive-concept c88
(and c27
(all r8 c9)
(at-least 3 r9)))
(define-primitive-concept c89
(and c37 c36
(at-least 5 r9)
(at-most 5 r6)))
(define-concept c90
(and c18
(at-most 9 r2)))
(define-concept c91
(and c38 c16
(all r3 c14) (all r2 c12)))
(define-primitive-concept c92
(and c31
(at-least 4 r2)))
(define-primitive-concept c93
(and c26
(all r4 c20)
(at-least 3 r8)))
(define-primitive-concept c94
(and c14
(at-least 4 r9)))
(define-primitive-concept c95
(and c15 c33
(at-least 5 r6)
(at-most 5 r4)))
(define-primitive-concept c96
(and c3 c36
(all r8 c21)
(at-most 5 r4)))
(define-primitive-concept c97
(and c20 c23
(all r6 c2)
(at-least 5 r10)))
(define-primitive-concept c98
(and c30 c15
(at-most 5 r2)))
(define-primitive-concept c99
(and c19
(all r3 c19)))
(define-concept c100
(and c26
(all r6 c10)
(at-most 6 r5)))
(define-concept c101
(and c13
(all r5 c14) (all r7 c20)
(at-least 1 r3)
(at-most 9 r10)))
(define-concept c102
(and c24 c13
(at-most 7 r8)))
(define-concept c103
(and c35
(at-least 5 r9)
(at-most 8 r5)))
(define-primitive-concept c104
(and c12 c27
(all r4 c30) (all r9 c17)
(at-least 1 r1)
(at-most 8 r7)))
(define-primitive-concept c105
(and c31
(all r1 c17)
(at-least 1 r7)))
| 9,321 | Common Lisp | .lisp | 397 | 17.413098 | 36 | 0.569155 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | fed3ee82765b449e6cf6ba92dbdfce5cb644ac25762639d9ee7df3c5e76430ab | 12,538 | [
-1
] |
12,539 | wine-food.lisp | lambdamikel_DLMAPS/src/prover/wine-food.lisp |
(IN-TBOX |/home/mi.wessel/Racer/examples/examples/wine-food/wine.owl| :SIZE 200 :ROLE-SIZE 30)
(DEFINE-DATATYPE-PROPERTY |http://www.w3.org/2000/01/rdf-schema#comment| :RANGE STRING)
(DEFINE-DATATYPE-PROPERTY |http://www.w3.org/2002/07/owl#comment| :RANGE STRING)
(DEFINE-DATATYPE-PROPERTY |http://www.w3.org/2000/01/rdf-schema#seeAlso| :RANGE STRING)
(DEFINE-DATATYPE-PROPERTY |http://www.w3.org/2002/07/owl#seeAlso| :RANGE STRING)
(DEFINE-DATATYPE-PROPERTY |http://www.w3.org/2000/01/rdf-schema#isDefinedBy| :RANGE STRING)
(DEFINE-DATATYPE-PROPERTY |http://www.w3.org/2002/07/owl#isDefinedBy| :RANGE STRING)
(DEFINE-DATATYPE-PROPERTY |http://www.w3.org/2000/01/rdf-schema#label| :RANGE STRING)
(DEFINE-DATATYPE-PROPERTY |http://www.w3.org/2002/07/owl#label| :RANGE STRING)
(DEFINE-DATATYPE-PROPERTY |http://www.w3.org/2002/07/owl#versionInfo| :RANGE STRING)
(DEFINE-PRIMITIVE-ROLE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#madeFromFruit| :DOMAIN |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#ConsumableThing| :RANGE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Fruit|)
(DEFINE-PRIMITIVE-ROLE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| :DOMAIN |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse| :RANGE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PotableLiquid|)
(DEFINE-PRIMITIVE-ROLE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#course| :DOMAIN |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Meal| :RANGE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|)
(DEFINE-PRIMITIVE-ATTRIBUTE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| :PARENTS |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasWineDescriptor| :DOMAIN |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine| :RANGE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineColor|)
(DEFINE-PRIMITIVE-ATTRIBUTE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| :PARENTS |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasWineDescriptor| :RANGE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineBody|)
(DEFINE-PRIMITIVE-ATTRIBUTE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| :PARENTS |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasWineDescriptor| :RANGE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineFlavor|)
(DEFINE-PRIMITIVE-ATTRIBUTE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| :PARENTS |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasWineDescriptor| :RANGE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineSugar|)
(DEFINE-PRIMITIVE-ROLE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| :DOMAIN |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse| :RANGE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#EdibleThing|)
(DEFINE-PRIMITIVE-ROLE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| :PARENTS |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#madeFromFruit| :INVERSE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeIntoWine| :DOMAIN |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine| :RANGE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineGrape|)
(DEFINE-PRIMITIVE-ROLE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| :TRANSITIVE T :DOMAIN TOP :RANGE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Region|)
(DEFINE-PRIMITIVE-ROLE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#adjacentRegion| :INVERSE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#adjacentRegion| :DOMAIN |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Region| :RANGE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Region|)
(DEFINE-DATATYPE-PROPERTY |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#yearValue| :RANGE CARDINAL)
(DEFINE-PRIMITIVE-ATTRIBUTE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasVintageYear| :DOMAIN |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Vintage| :RANGE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#VintageYear|)
(DEFINE-PRIMITIVE-ROLE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeIntoWine| :PARENTS #:|http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#madeFromFruit-INV-50310| :INVERSE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| :DOMAIN |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineGrape| :RANGE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|)
(DEFINE-PRIMITIVE-ROLE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasWineDescriptor| :DOMAIN |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine| :RANGE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineDescriptor|)
(DEFINE-PRIMITIVE-ATTRIBUTE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasMaker| :INVERSE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#producesWine|)
(DEFINE-PRIMITIVE-ROLE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#producesWine| :INVERSE |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasMaker|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Winery| *TOP*)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#ConsumableThing| *TOP*)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#VintageYear| *TOP*)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Region| *TOP*)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#LoireRegion|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#BourgogneRegion|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#BordeauxRegion|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#ZinfandelGrape|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#ToursRegion|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#RieslingGrape|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#StEmilionRegion|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SemillonGrape|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SauvignonBlancGrape|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SancerreRegion|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PinotNoirGrape|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PinotBlancGrape|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PetiteSyrahGrape|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PauillacRegion|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#MedocRegion|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#MuscadetRegion|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#MeursaultRegion|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#MerlotGrape|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CabernetSauvignonGrape|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CabernetFrancGrape|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#MalbecGrape|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PetiteVerdotGrape|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#MargauxRegion|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#ItalianRegion|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#GermanyRegion|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#GamayGrape|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#FrenchRegion|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CotesDOrRegion|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CheninBlancGrape|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#ChardonnayGrape|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CaliforniaRegion|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#TexasRegion|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#BeaujolaisRegion|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#AnjouRegion|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#USRegion|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#AlsaceRegion|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Red|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Full|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Strong|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Dry|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Medium|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Moderate|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#White|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Light|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Delicate|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Sweet|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#OffDry|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Juice| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#madeFromFruit| *TOP*) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PotableLiquid|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#EarlyHarvest| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Dry| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#OffDry|)) (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#LateHarvest|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#EatingGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Grape|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SauterneRegion|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Sauternes| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Medium|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SauterneRegion|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#White|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#LateHarvest| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Bordeaux|))
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PortugalRegion|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Port| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PortugalRegion|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Strong|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Full|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Sweet|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#RedWine|))
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#ChiantiRegion|)
(DEFINE-PRIMITIVE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SangioveseGrape|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Chianti| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SangioveseGrape|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#ChiantiRegion|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Moderate|) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Medium| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Light|)) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Red|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Dry|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#ItalianWine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Red| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineColor|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineColor| (AND (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Red| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Rose| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#White|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineDescriptor|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Rose| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineColor|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#White| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineColor|)
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineDescriptor| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineTaste| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineColor|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineTaste| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineDescriptor|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Full| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineBody|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineBody| (AND (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Full| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Medium| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Light|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineTaste|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Medium| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineBody|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Light| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineBody|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Strong| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineFlavor|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineFlavor| (AND (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Strong| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Moderate| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Delicate|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineTaste|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Moderate| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineFlavor|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Delicate| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineFlavor|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Dry| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineSugar|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineSugar| (AND (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Dry| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#OffDry| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Sweet|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineTaste|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#OffDry| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineSugar|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Sweet| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineSugar|)
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonConsumableThing| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#ConsumableThing|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Vintage| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasVintageYear| *TOP*))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonSweetFruitCourse| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#OffDry|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Delicate|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonSweetFruit|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse| (AND (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#SpicyRedMeat|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#SpicyRedMeatCourse|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#RedMeat|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#RedMeatCourse|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Seafood|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#SeafoodCourse|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Shellfish|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#ShellfishCourse|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#BlandFish|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#BlandFishCourse|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#CheeseNutsDessert|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#CheeseNutsDessertCourse|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#DarkMeatFowl|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#DarkMeatFowlCourse|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#SweetDessert|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#SweetDessertCourse|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Dessert|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#DessertCourse|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Fish|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#FishCourse|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Fruit|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#FruitCourse|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#LightMeatFowl|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#LightMeatFowlCourse|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonBlandFish|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonBlandFishCourse|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonOysterShellfish|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonOysterShellfishCourse|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonRedMeat|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonRedMeatCourse|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonSpicyRedMeat|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonSpicyRedMeatCourse|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#SweetFruit|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#SweetFruitCourse|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonSweetFruit|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonSweetFruitCourse|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#OtherTomatoBasedFood|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#OtherTomatoBasedFoodCourse|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#OysterShellfish|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#OysterShellfishCourse|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithHeavyCreamSauce|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithHeavyCreamCourse|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithLightCreamSauce|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithLightCreamCourse|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithNonSpicyRedSauce|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithNonSpicyRedSauceCourse|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithSpicyRedSauce|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithSpicyRedSauceCourse|) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Wine|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| *TOP*) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| *TOP*) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#ConsumableThing|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#EdibleThing| (AND (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#ConsumableThing|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Meal| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#course| *TOP*) (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#EdibleThing|) (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#ConsumableThing|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PotableLiquid| (AND (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Meal|) (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#EdibleThing|) (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#ConsumableThing|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonSweetFruit| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#EdibleThing|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#SweetFruit| (AND (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonSweetFruit|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#EdibleThing|))
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Fruit| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#SweetFruit| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonSweetFruit|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Pasta| (AND |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#EdibleThing| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Fruit|)))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithWhiteSauce| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Pasta|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithLightCreamSauce| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithWhiteSauce|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithHeavyCreamSauce| (AND (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithLightCreamSauce|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithWhiteSauce|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithRedSauce| (AND (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithWhiteSauce|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Pasta|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithSpicyRedSauce| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithRedSauce|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithNonSpicyRedSauce| (AND |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithRedSauce| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithSpicyRedSauce|)))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#OtherTomatoBasedFood| (AND (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Pasta|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#EdibleThing| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Fruit|)))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Meat| (AND (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#OtherTomatoBasedFood|) (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Pasta|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#EdibleThing| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Fruit|)))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonRedMeat| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Meat|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#RedMeat| (AND |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Meat| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonRedMeat|)))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonSpicyRedMeat| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#RedMeat|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#SpicyRedMeat| (AND |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#RedMeat| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonSpicyRedMeat|)))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Grape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#SweetFruit|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WineGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Grape|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Beaujolais| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Light|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Delicate|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#BeaujolaisRegion|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#GamayGrape|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Red|) (AT-MOST 1 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Dry|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Wine| (AND (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Red|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#RedWine|) (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#BordeauxRegion|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Bordeaux|) (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#LoireRegion|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Loire|) (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#BeaujolaisRegion|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Beaujolais|) (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#BourgogneRegion|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Burgundy|) (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CabernetFrancGrape|)) (AT-LEAST 2 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CabernetFranc|) (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CabernetSauvignonGrape|)) (AT-LEAST 2 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CabernetSauvignon|) (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#ChardonnayGrape|)) (AT-LEAST 2 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Chardonnay|) (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CheninBlancGrape|)) (AT-LEAST 2 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CheninBlanc|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| (AND (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PetiteVerdotGrape|) (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#MalbecGrape|) (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CabernetFrancGrape|) (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CabernetSauvignonGrape|) (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#MerlotGrape|))) (AT-MOST 1 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Meritage|) (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#MerlotGrape|)) (AT-LEAST 2 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Merlot|) (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PetiteSyrahGrape|)) (AT-LEAST 2 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PetiteSyrah|) (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PinotBlancGrape|)) (AT-LEAST 2 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PinotBlanc|) (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PinotNoirGrape|)) (AT-LEAST 2 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PinotNoir|) (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#RieslingGrape|)) (AT-LEAST 2 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Riesling|) (OR (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| (AND (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SauvignonBlancGrape|) (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SemillonGrape|))) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SemillonOrSauvignonBlanc|) (OR (AT-LEAST 2 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#ZinfandelGrape|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Zinfandel|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Region|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| *TOP*) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| *TOP*) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| *TOP*) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| *TOP*) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| *TOP*) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasMaker| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Winery|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasMaker| *TOP*) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PotableLiquid|))
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Wine|)
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#AlsatianWine| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#AlsaceRegion|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#AmericanWine| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#USRegion|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CabernetFranc| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Moderate|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Medium|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CabernetFrancGrape|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Red|) (AT-MOST 1 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Dry|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CabernetSauvignon| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Strong| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Moderate|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Full| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Medium|)) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CabernetSauvignonGrape|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Red|) (AT-MOST 1 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Dry|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#TexasWine| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#TexasRegion|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CaliforniaWine| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CaliforniaRegion|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Chardonnay| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Strong| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Moderate|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Full| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Medium|)) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#ChardonnayGrape|) (AT-MOST 1 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#White|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CheninBlanc| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Moderate|) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Full| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Medium|)) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CheninBlancGrape|) (AT-MOST 1 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Dry| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#OffDry|)) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#White|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#TableWine| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Dry|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#DryWine| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#TableWine|)
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#FrenchWine| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#FrenchRegion|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#FullBodiedWine| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Full|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Gamay| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#GamayGrape|) (AT-MOST 1 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#GermanWine| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#GermanyRegion|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#ItalianWine| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#ItalianRegion|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#LateHarvest| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Strong| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Moderate|)) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Sweet|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#DessertWine| (AND (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#White|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#IceWine| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#LateHarvest|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#OffDry| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Sweet|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#IceWine| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Strong| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Moderate|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Full| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Medium|)) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#White|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#DessertWine| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#LateHarvest|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Meritage| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PetiteVerdotGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#MalbecGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CabernetFrancGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CabernetSauvignonGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#MerlotGrape|)) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Red|) (AT-LEAST 2 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Merlot| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Medium| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Light|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Moderate| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Delicate|)) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#MerlotGrape|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Red|) (AT-MOST 1 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Dry|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PetiteSyrah| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Strong| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Moderate|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Full| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Medium|)) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PetiteSyrahGrape|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Red|) (AT-MOST 1 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Dry|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PinotBlanc| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PinotBlancGrape|) (AT-MOST 1 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#White|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PinotNoir| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PinotNoirGrape|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Red|) (AT-MOST 1 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#RoseWine| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Rose|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SemillonOrSauvignonBlanc| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Full| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Medium|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SauvignonBlancGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SemillonGrape|)) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#White|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Semillon| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SemillonGrape|) (AT-MOST 1 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SemillonOrSauvignonBlanc|))
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SauvignonBlanc| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SauvignonBlancGrape|) (AT-MOST 1 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SemillonOrSauvignonBlanc|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SweetRiesling| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Strong| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Moderate|)) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Full|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Sweet|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#DessertWine| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Riesling|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Riesling| (AND (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Dry|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#DryRiesling|) (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Sweet|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SweetRiesling|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#RieslingGrape|) (AT-MOST 1 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#White|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#DryRiesling| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Medium| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Light|)) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Delicate|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Dry|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#White|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Riesling|))
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SweetWine| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Sweet|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Zinfandel| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Strong| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Moderate|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Full| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Medium|)) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Red|) (AT-MOST 1 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#ZinfandelGrape|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Dry|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#TableWine| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Dry|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#DryRedWine| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Red|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#TableWine|))
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#RedTableWine| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#DryRedWine|)
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#DryWhiteWine| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#White|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#TableWine|))
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WhiteTableWine| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#DryWhiteWine|)
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WhiteWine| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#White|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WhiteNonSweetWine| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Dry| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#OffDry|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WhiteWine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Loire| (AND (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#AnjouRegion|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Anjou|) (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#MuscadetRegion|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Muscadet|) (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SancerreRegion|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Sancerre|) (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#ToursRegion|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Tours|) (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WhiteLoire| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WhiteWine|)) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#LoireRegion|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WhiteLoire| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CheninBlancGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PinotBlancGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SauvignonBlancGrape|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Loire| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WhiteWine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Tours| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CheninBlancGrape|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#ToursRegion|) (AT-MOST 1 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Loire|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Sancerre| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Delicate|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#OffDry|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Medium|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SancerreRegion|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SauvignonBlancGrape|) (AT-MOST 1 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Loire|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Muscadet| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Light|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Delicate|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#MuscadetRegion|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PinotBlancGrape|) (AT-MOST 1 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Dry|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Loire|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Anjou| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Light|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Delicate|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#OffDry|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#AnjouRegion|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Rose|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Loire|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Bordeaux| (AND (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#MedocRegion|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Medoc|) (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#StEmilionRegion|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#StEmilion|) (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WhiteBordeaux| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WhiteWine|)) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#BordeauxRegion|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WhiteBordeaux| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SauvignonBlancGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SemillonGrape|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Bordeaux| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WhiteWine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#StEmilion| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Strong|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CabernetSauvignonGrape|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Red|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#StEmilionRegion|) (AT-MOST 1 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Bordeaux|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#RedBordeaux| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CabernetSauvignonGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#MerlotGrape|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#RedWine| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Bordeaux|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#RedWine| (AND (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#RedBordeaux| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Bordeaux|)) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Red|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#RedBurgundy| (AND (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CotesDOrRegion|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CotesDOr|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PinotNoirGrape|) (AT-MOST 1 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#RedWine| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Burgundy|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Burgundy| (AND (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#RedBurgundy| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#RedWine|)) (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WhiteBurgundy| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WhiteWine|)) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#BourgogneRegion|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Dry|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WhiteBurgundy| (AND (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#MeursaultRegion|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Meursault|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#ChardonnayGrape|) (AT-MOST 1 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Burgundy| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WhiteWine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Meursault| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Full|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#MeursaultRegion|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WhiteBurgundy|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CotesDOr| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Moderate|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CotesDOrRegion|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#RedBurgundy|))
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#DryRedWine| (AND |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#DryWine| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#RedWine|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Medoc| (AND (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#MargauxRegion|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Margaux|) (OR (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PauillacRegion|)) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Pauillac|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#MedocRegion|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Red|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Dry|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Bordeaux|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Pauillac| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Strong|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CabernetSauvignonGrape|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Full|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#PauillacRegion|) (AT-MOST 1 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Medoc|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Margaux| (AND (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Delicate|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#MargauxRegion|) (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#MerlotGrape|) (AT-MOST 1 |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#madeFromGrape|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Medoc|))
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#DryWhiteWine| (AND |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#DryWine| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#WhiteWine|))
(DEFINE-CONCEPT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Wine| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Wine|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Fowl| (AND (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Meat|) (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#OtherTomatoBasedFood|) (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Pasta|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#EdibleThing| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Fruit|)))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#LightMeatFowl| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Fowl|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#DarkMeatFowl| (AND |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Fowl| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#LightMeatFowl|)))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Dessert| (AND (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Fowl|) (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Meat|) (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#OtherTomatoBasedFood|) (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Pasta|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#EdibleThing| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Fruit|)))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#SweetDessert| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Dessert|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#CheeseNutsDessert| (AND (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#SweetDessert|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Dessert|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Seafood| (AND (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Dessert|) (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Fowl|) (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Meat|) (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#OtherTomatoBasedFood|) (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Pasta|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#EdibleThing| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Fruit|)))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Fish| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Seafood|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonBlandFish| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Fish|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#BlandFish| (AND |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Fish| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonBlandFish|)))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Shellfish| (AND |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Seafood| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Fish|)))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#OysterShellfish| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Shellfish|)
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonOysterShellfish| (AND |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Shellfish| (NOT |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#OysterShellfish|)))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithSpicyRedSauceCourse| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Dry|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Strong|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Full|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Red|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithSpicyRedSauce|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithNonSpicyRedSauceCourse| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Moderate|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Medium|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Dry|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Red|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithNonSpicyRedSauce|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithLightCreamCourse| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Delicate|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Light|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#White|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Dry|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithLightCreamSauce|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithHeavyCreamCourse| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#White|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Moderate|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Medium|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Dry|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#PastaWithHeavyCreamSauce|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#OysterShellfishCourse| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Sweet|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#OysterShellfish|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#OtherTomatoBasedFoodCourse| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Moderate|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Medium|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Dry|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Red|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#OtherTomatoBasedFood|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#SweetFruitCourse| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Sweet|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Moderate|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#SweetFruit|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonSpicyRedMeatCourse| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Moderate| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Strong|))) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Medium|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Dry|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Red|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonSpicyRedMeat|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonRedMeatCourse| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#White|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Medium|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Dry|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Strong|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonRedMeat|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonOysterShellfishCourse| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Dry|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonOysterShellfish|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonBlandFishCourse| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Moderate|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#NonBlandFish|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#LightMeatFowlCourse| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#White|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Moderate|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Medium|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Dry|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#LightMeatFowl|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#FruitCourse| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#White|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Medium|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Fruit|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#FishCourse| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Medium|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Dry|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Fish|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#DessertCourse| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Sweet|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Strong|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Full|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Dessert|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#SweetDessertCourse| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#White|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#SweetDessert|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#DarkMeatFowlCourse| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Delicate|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Light|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Dry|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Red|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#DarkMeatFowl|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#CheeseNutsDessertCourse| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Red|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#CheeseNutsDessert|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#BlandFishCourse| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Delicate|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#BlandFish|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#ShellfishCourse| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| (OR |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Moderate| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Strong|))) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Full|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Shellfish|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#SeafoodCourse| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#White|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Seafood|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#RedMeatCourse| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Red|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#RedMeat|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|))
(IMPLIES |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#SpicyRedMeatCourse| (AND (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasFlavor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Moderate|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasSugar| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Dry|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasBody| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Full|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasDrink| (SOME |http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#hasColor| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#Red|)) (ALL |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#hasFood| |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#SpicyRedMeat|) |http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#MealCourse|)) | 91,205 | Common Lisp | .lisp | 231 | 392.82684 | 5,946 | 0.744454 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 2a6717efee9603794f36fac1d1fab2ffe16c133c5aaae75d218ec3288dabb433 | 12,539 | [
-1
] |
12,540 | abox-enumeration.lisp | lambdamikel_DLMAPS/src/prover/abox-enumeration.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(defrule abox-enumeration (dl abox)
(let* ((sat nil)
(collected-dependencies nil)
(count 0)
(underspecified-edges (edge-gen abox))
(underspecified-edges-and-inverses
(remove nil (append underspecified-edges
(mapcar #'inverse-edge underspecified-edges ))))
(clash-p nil)
(successfully-repaired-p nil)
(end-loop-p nil)
(choice-points nil)
(memorized-action (get-current-action)))
(if (not underspecified-edges)
+insert-body-code+
(let ((abox (first-completion abox)))
(unless abox
(error "No completion! How do I handle this?"))
(loop
(incf count)
(announce "Performing ABOX ENUMERATION OF ~A ON LEVEL ~A, ALTERNATIVE NO. ~A.~%DISJUNCTIVE EDGES: ~A~%CHOICE-POINTS OF DISJUNCTIVE EDGES: ~A~%"
abox level count underspecified-edges
choice-points)
(when *debug-p*
(format t "~%~%Underspecified Edges:~%")
(dolist (edge underspecified-edges)
(describe-object edge t)
(terpri))
(format t "~%~%Edges and Inverses:~%")
(dolist (edge underspecified-edges)
(describe-object edge t)
(terpri)
(when (inverse-edge edge)
(describe-object (inverse-edge edge) t)
(terpri) (Terpri)))
(terpri))
(if (or end-loop-p
(and sat (not *compute-all-completions-p*)))
(progn
;;; Vorherigen Enumeration Context herstellen!
(announce "*** EXITING LEVEL ~A" level)
(pop-description-stack abox)
(return-from prover
(if sat
t
(values sat (set-difference collected-dependencies choice-points)))))
(progn
(when (zerop (1- count))
(setf choice-points
;; der neue Choicepoint wird automatisch auch f.d. Inverse registriert!
(add-choice-points-for-edges abox underspecified-edges)))
(announce "*** CHOICE POINTS OF DISJUNCTIVE EDGES: ~A~%ACTUAL CHOICE POINTS OF DISJ.EDGES: ~A"
choice-points
(mapcar #'get-choice-points underspecified-edges-and-inverses))
(multiple-value-bind (sub-sat deps)
(if clash-p
(if successfully-repaired-p
(progn
(announce "*** SUCCESSFULLY REPARIED CONSTRAINT SYSTEM ON LEVEL ~A!" level)
(setf clash-p nil)
+insert-after-successful-clash-repair-code+
)
(progn
;;; hier habe ich keine andere Wahl!
;;; da "local" nicht reparier werden kann,
;;; müssen alle Constraints die von den
;;; Kanten abhängen zurückgenommen werden
(announce "*** LOCAL REPAIR OF CONSTRAINT SYSTEM ON LEVEL ~A FAILED!" level)
(pop-description-stack abox)
#+:use-dependency-directed-backtracking
(progn
(break "DEPENDENCY DIRECTED BACKTRACKING NOT FULLY UNDERSTOOD YET!")
(dolist (edge underspecified-edges-and-inverses)
(rollback-all-depending-on abox edge)))
#-:use-dependency-directed-backtracking
(let ((*use-unsat-cache-p* nil)) ; wichtig!
;;; simple backjumping
(rollback-to abox memorized-action))
(return-from prover
(if sat
t
(values nil (set-difference collected-dependencies choice-points))))))
+insert-body-code+ )
(when *debug-p*
(announce "*** RETURNED TO ABOX ENUMERATION ON LEVEL ~A -> SUB-SAT: ~A, RETURNED CHOICE POINTS: ~A~%CHOICE POINTS OF DISJUNCTIVE EDGES: ~A~%ACTUAL CHOICE POINTS OF DISJ.EDGES: ~A" level sub-sat
deps
choice-points (mapcar #'get-choice-points underspecified-edges-and-inverses))
(when *debug-p*
(format t "~%~%Underspecified Edges:~%")
(dolist (edge underspecified-edges)
(describe-object edge t)
(terpri))
(format t "~%~%Edges and Inverses:~%")
(dolist (edge underspecified-edges)
(describe-object edge t)
(terpri)
(when (inverse-edge edge)
(describe-object (inverse-edge edge) t)
(terpri) (Terpri)))
(terpri)))
(setf sat (or sub-sat sat)
clash-p nil)
(if *compute-all-completions-p*
(progn
#+:use-dependency-directed-backtracking
(progn
(break "DEPENDENCY DIRECTED BACKTRACKING NOT FULLY UNDERSTOOD YET!")
(dolist (edge underspecified-edges-and-inverses)
(rollback-all-depending-on abox edge)))
#-:use-dependency-directed-backtracking
(let ((*use-unsat-cache-p* nil))
;;; simple backjumping
(rollback-to abox memorized-action))
(let ((next-abox
(when (has-next-configuration-p abox)
(next-completion abox))))
(setf abox (or next-abox abox))
(unless next-abox
(announce "*** NO NEXT COMPLETION ON LEVEL ~A" level))
(unless next-abox
(setf end-loop-p t))))
(unless sub-sat
(setf clash-p t)
(when (and deps choice-points
(> (maximum deps)
(maximum choice-points)))
(error "*** Error in dependency management!"))
(setf collected-dependencies
(append deps collected-dependencies))
;;; kanten identifizieren, die für den clash verantwortlich sind!
(let ((deps (intersection deps choice-points)))
(setf deps (mapcar #'(lambda (choice-point)
(remove-if-not #'(lambda (edge)
(member choice-point
(get-choice-points edge)))
underspecified-edges-and-inverses))
(sort-choice-points deps)))
;; (setf *x* abox)
(announce "++++ POSSIBLE RESTART EDGES: ~A" deps)
(let ((restart-points
(block here
(loop as dep in deps
do
(loop as restart-from in dep
when (has-next-configuration-p abox :restart-from restart-from)
do (return-from here
(list dep restart-from)))))))
(announce "++++ REMAINING RESTART EDGES: ~A" restart-points)
;;; (break "~A" restart-points)
(cond (restart-points
(announce "*** REPAIRING CONSTRAINT SYSTEM ON LEVEL ~A FROM ~A!" level restart-points)
#+:use-dependency-directed-backtracking
(progn
(break "DEPENDENCY DIRECTED BACKTRACKING NOT FULLY UNDERSTOOD YET!")
(dolist (dep (first restart-points))
(rollback-all-depending-on abox dep)))
#-:use-dependency-directed-backtracking
(progn
(rollback-to abox memorized-action))
(announce "*** Stack: ~A~%*** Description Stack: ~A"
(slot-value abox 'thematic-substrate::stack)
(slot-value abox 'thematic-substrate::description-stack))
(let ((next-abox
(next-completion abox :restart-from (second restart-points))))
(setf abox (or next-abox abox))
(setf successfully-repaired-p
(when next-abox t))))
(t
(setf successfully-repaired-p nil)
(announce "*** UNABLED TO RESTART FROM ~A~%*** Stack: ~A~%*** Description Stack: ~A!" restart-points
(slot-value abox 'thematic-substrate::stack)
(slot-value abox 'thematic-substrate::description-stack))))))))))))))))
;;;
;;; Der folgende Code wird benötigt, um Rollen-Disjunktionen
;;; in der ABOX aufzulösen
;;;
(defmethod edge-setter ((edge abox-edge) (role simple-role) &key remaining &allow-other-keys)
(declare (ignore remaining))
(change-textual-description (description edge) role)
edge)
(defmethod edge-gen ((abox abox) &key &allow-other-keys)
(get-underspecified-edges abox :exclude-inverses-p t))
(defmethod sym-gen ((edge abox-edge) processed-edges &key &allow-other-keys)
(declare (ignorable processed-edges))
(let ((role (textual-description (aux-description edge))))
(copy-list (arguments role)))) ;;; WICHTIG !! COPY-LIST !!!
(defun selector-fn (rem-edges processed-edges &key &allow-other-keys)
(declare (ignore processed-edges))
(first rem-edges))
(defmethod manager-fn ((sel-edge abox-edge) edges processed-edges &key &allow-other-keys)
(values (remove sel-edge edges)
(cons sel-edge processed-edges)))
;;;
;;;
;;;
(defmethod role-consistent-p ((abox abox) &rest args)
(declare (ignore args))
t)
(defmethod enumerate-atomic-configurations ((abox abox)
&rest args
&key
(edge-setter #'edge-setter)
(respect-inverses-p t)
(sym-gen #'sym-gen)
(selector-fn #'selector-fn)
(edge-gen #'edge-gen)
(manager-fn #'manager-fn)
(final-check-fn #'role-consistent-p)
(fn #'(lambda (abox &rest args)
(declare (ignore args)) abox))
&allow-other-keys)
(apply #'call-next-method abox
:save-node-labels-p nil
:save-edge-labels-p t
:edge-setter edge-setter
:respect-inverses-p respect-inverses-p
:edges (funcall edge-gen abox)
:manager-fn manager-fn
:final-check-fn final-check-fn
:selector-fn selector-fn
:sym-gen sym-gen
:fn fn
args))
;;;
;;;
;;;
(defmethod first-completion ((abox abox) &key &allow-other-keys)
(enumerate-atomic-configurations abox :reset-p t))
(defmethod next-completion ((abox abox) &key restart-from)
(enumerate-atomic-configurations abox :restart-from restart-from))
| 13,699 | Common Lisp | .lisp | 235 | 32.097872 | 211 | 0.467825 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 65fa9095631cf56ef880bd68dd816febcbd1ddeeac9f7bc2bd9cd42269c2a5a4 | 12,540 | [
-1
] |
12,541 | node-label2.lisp | lambdamikel_DLMAPS/src/prover/node-label2.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(defpersistentclass node-label (node-description)
((textual-description :initform "Node-Label")
(of-node :reader of-node :initarg :of-node)
(unexpanded-atomic-concepts :initform nil :initarg :unexpanded-atomic-concepts)
(unexpanded-all-concepts :initform nil :initarg :unexpanded-all-concepts)
(unexpanded-and-concepts :initform nil :initarg :unexpanded-and-concepts)
(unexpanded-or-concepts :initform nil :initarg :unexpanded-or-concepts)
(unexpanded-some-concepts :initform nil :initarg :unexpanded-some-concepts)
(unexpanded-attribute-exists-concepts :initform nil :initarg :unexpanded-attribute-exists-concepts)
(unexpanded-at-least-concepts :initform nil :initarg :unexpanded-at-least-concepts)
(unexpanded-at-most-concepts :initform nil :initarg :unexpanded-at-most-concepts)
(expanded-atomic-concepts :initform nil :initarg :expanded-atomic-concepts)
(expanded-all-concepts :initform nil :initarg :expanded-all-concepts)
(expanded-and-concepts :initform nil :initarg :expanded-and-concepts)
(expanded-or-concepts :initform nil :initarg :expanded-or-concepts)
(expanded-some-concepts :initform nil :initarg :expanded-some-concepts)
(expanded-attribute-exists-concepts :initform nil :initarg :expanded-attribute-exists-concepts)
(expanded-at-least-concepts :initform nil :initarg :expanded-at-least-concepts)
(expanded-at-most-concepts :initform nil :initarg :expanded-at-most-concepts)))
(defmethod copy ((label node-label) &rest args)
(declare (ignorable args))
(let ((copy
(make-node-description 'node-label
(textual-description label)
:type
(type-of label))))
(with-slots (of-node) copy
(setf of-node
(find-node copy (of-node label) :error-p t)))
(dolist (slot '(unexpanded-atomic-concepts
unexpanded-all-concepts
unexpanded-and-concepts
unexpanded-or-concepts
unexpanded-some-concepts
unexpanded-attribute-exists-concepts
unexpanded-at-least-concepts
unexpanded-at-most-concepts
expanded-atomic-concepts
expanded-all-concepts
expanded-and-concepts
expanded-or-concepts
expanded-some-concepts
expanded-attribute-exists-concepts
expanded-at-least-concepts
expanded-at-most-concepts))
(setf (slot-value copy slot)
#+:use-avl-trees-for-labels
(copy-tree (slot-value label slot))
#-:use-avl-trees-for-labels
(copy-list (slot-value label slot))))
label))
;;;
;;;
;;;
(defmethod reset-label ((node-label node-label))
(with-slots (expanded-atomic-concepts
expanded-some-concepts
expanded-attribute-exists-concepts
expanded-at-least-concepts
expanded-at-most-concepts
expanded-all-concepts
expanded-and-concepts
expanded-or-concepts
unexpanded-atomic-concepts
unexpanded-some-concepts
unexpanded-attribute-exists-concepts
unexpanded-at-least-concepts
unexpanded-at-most-concepts
unexpanded-all-concepts
unexpanded-and-concepts
unexpanded-or-concepts) node-label
#+:use-membership-tables
(dolist (slot '(expanded-atomic-concepts
expanded-some-concepts
expanded-attribute-exists-concepts
expanded-at-least-concepts
expanded-at-most-concepts
expanded-all-concepts
expanded-and-concepts
expanded-or-concepts))
(dolist (concept (slot-value node-label slot))
(remhash (list concept node-label) *expanded-table*)))
#+:use-membership-tables
(dolist (slot '(unexpanded-atomic-concepts
unexpanded-some-concepts
unexpanded-attribute-exists-concepts
unexpanded-at-least-concepts
unexpanded-at-most-concepts
unexpanded-all-concepts
unexpanded-and-concepts
unexpanded-or-concepts))
(dolist (concept (slot-value node-label slot))
(remhash (list concept node-label) *unexpanded-table*)))
(setf expanded-atomic-concepts nil
expanded-some-concepts nil
expanded-attribute-exists-concepts nil
expanded-at-least-concepts nil
expanded-at-most-concepts nil
expanded-all-concepts nil
expanded-and-concepts nil
expanded-or-concepts nil
unexpanded-atomic-concepts nil
unexpanded-some-concepts nil
unexpanded-attribute-exists-concepts nil
unexpanded-at-least-concepts nil
unexpanded-at-most-concepts nil
unexpanded-all-concepts nil
unexpanded-and-concepts nil
unexpanded-or-concepts nil)))
;;;
;;;
;;;
(defmacro get-slot-for (concept slot-type)
(ecase slot-type
(expanded
`(etypecase ,concept
(atomic-concept 'expanded-atomic-concepts)
(and-concept 'expanded-and-concepts)
(or-concept 'expanded-or-concepts)
(attribute-exists-concept 'expanded-attribute-exists-concepts)
(some-concept 'expanded-some-concepts)
(all-concept 'expanded-all-concepts)
(at-least-concept 'expanded-at-least-concepts)
(at-most-concept 'expanded-at-most-concepts)))
(unexpanded
`(etypecase ,concept
(atomic-concept 'unexpanded-atomic-concepts)
(and-concept 'unexpanded-and-concepts)
(or-concept 'unexpanded-or-concepts)
(attribute-exists-concept 'unexpanded-attribute-exists-concepts)
(some-concept 'unexpanded-some-concepts)
(all-concept 'unexpanded-all-concepts)
(at-least-concept 'unexpanded-at-least-concepts)
(at-most-concept 'unexpanded-at-most-concepts)))))
;;;
;;;
;;;
#-:use-membership-tables
(defmacro concept-member (label concept slot)
`(let ((slot (get-slot-for ,concept ,slot)))
#+:use-avl-trees-for-labels
(find-in-avl-tree ,concept (slot-value ,label slot) :key #'id)
#-:use-avl-trees-for-labels
(member ,concept (slot-value ,label slot))))
#+:use-membership-tables
(defmacro concept-member (label concept slot)
`(ecase ',slot
(expanded
(gethash (list ,concept ,label) *expanded-table*))
(unexpanded
(gethash (list ,concept ,label) *unexpanded-table*))))
;;;
;;;
;;;
(defmethod make-node-description ((class (eql 'node-label)) descr &rest args &key type &allow-other-keys)
(apply #'make-instance (or type class)
:textual-description descr
:constructor-sym 'node-label
:allow-other-keys t
args))
;;;
;;;
;;;
(defmethod has-unexpanded-concepts-p ((label node-label) &optional (consider-cluster-p t))
(declare (ignorable consider-cluster-p))
(some #'(lambda (slot)
(slot-value label slot))
'(unexpanded-atomic-concepts
unexpanded-some-concepts
unexpanded-all-concepts
unexpanded-and-concepts
unexpanded-or-concepts
unexpanded-attribute-exists-concepts
unexpanded-at-least-concepts
unexpanded-at-most-concepts)))
(defmethod has-expanded-concepts-p ((label node-label) &optional (consider-cluster-p t))
(declare (ignorable consider-cluster-p))
(some #'(lambda (slot)
(slot-value label slot))
'(expanded-atomic-concepts
expanded-some-concepts
expanded-all-concepts
expanded-and-concepts
expanded-or-concepts
expanded-attribute-exists-concepts
expanded-at-least-concepts
expanded-at-most-concepts)))
;;;
;;;
;;;
(defmethod has-unexpanded-and-concepts-p ((label node-label) &optional (consider-cluster-p t))
(declare (ignorable consider-cluster-p))
(slot-value label 'unexpanded-and-concepts))
(defmethod has-unexpanded-atomic-concepts-p ((label node-label) &optional (consider-cluster-p t))
(declare (ignorable consider-cluster-p))
(slot-value label 'unexpanded-atomic-concepts))
(defmethod has-unexpanded-some-concepts-p ((label node-label) &optional (consider-cluster-p t))
(declare (ignorable consider-cluster-p))
(slot-value label 'unexpanded-some-concepts))
(defmethod has-unexpanded-all-concepts-p ((label node-label) &optional (consider-cluster-p t))
(declare (ignorable consider-cluster-p))
(slot-value label 'unexpanded-all-concepts))
(defmethod has-unexpanded-or-concepts-p ((label node-label) &optional (consider-cluster-p t))
(declare (ignorable consider-cluster-p))
(slot-value label 'unexpanded-or-concepts))
(defmethod has-unexpanded-attribute-exists-concepts-p ((label node-label) &optional (consider-cluster-p t))
(declare (ignorable consider-cluster-p))
(slot-value label 'unexpanded-attribute-exists-concepts))
(defmethod has-unexpanded-at-least-concepts-p ((label node-label) &optional (consider-cluster-p t))
(declare (ignorable consider-cluster-p))
(slot-value label 'unexpanded-at-least-concepts))
(defmethod has-unexpanded-at-most-concepts-p ((label node-label) &optional (consider-cluster-p t))
(declare (ignorable consider-cluster-p))
(slot-value label 'unexpanded-at-most-concepts))
;;;
;;;
;;;
(defmethod complete-p ((label node-label) &optional (consider-cluster-p t))
(declare (ignorable consider-cluster-p))
;;; all und at-most bewusst ausgespart!!
(with-slots (unexpanded-atomic-concepts
unexpanded-some-concepts
unexpanded-and-concepts
unexpanded-or-concepts
unexpanded-attribute-exists-concepts
unexpanded-at-least-concepts) label
(not (or unexpanded-atomic-concepts
unexpanded-some-concepts
unexpanded-and-concepts
unexpanded-or-concepts
unexpanded-attribute-exists-concepts
unexpanded-at-least-concepts))))
;;;
;;; Label Verwaltung
;;;
(timed-defmethod add-to-unexpanded ((label node-label) (concept concept))
;;; Position wichtig!
(let* ((node (of-node label))
(abox (in-graph node)))
(add-to-heaps abox node concept)
#+:use-membership-tables
(setf (gethash (list concept label) *unexpanded-table*) t)
(let ((slot (get-slot-for concept unexpanded)))
#+:use-avl-trees-for-labels
(insert-into-avl-tree concept (slot-value label slot) :key #'id)
#-:use-avl-trees-for-labels
(push concept (slot-value label slot)))
(unless (active-p node)
(activate-node abox node))
(unregister-deterministically-expanded abox node)
(adjust-blocking-dependencies abox node)))
(timed-defmethod add-to-unexpanded ((label node-label) (list list))
(dolist (concept list)
(add-to-unexpanded label concept)))
;;;
;;;
;;;
(timed-defmethod add-to-expanded ((label node-label) (concept concept))
#+:use-membership-tables
(setf (gethash (list concept label) *expanded-table*) t)
(let ((slot (get-slot-for concept expanded)))
#+:use-avl-trees-for-labels
(insert-into-avl-tree concept (slot-value label slot) :key #'id)
#-:use-avl-trees-for-labels
(push concept (slot-value label slot))))
(timed-defmethod add-to-expanded ((label node-label) (list list))
(dolist (concept list)
(add-to-expanded label concept)))
;;;
;;;
;;;
(timed-defmethod delete-from-unexpanded ((label node-label) (concept concept))
#+:use-membership-tables
(remhash (list concept label) *unexpanded-table*)
(let ((slot (get-slot-for concept unexpanded)))
#+:use-avl-trees-for-labels
(delete-from-avl-tree concept (slot-value label slot) :key #'id)
#-:use-avl-trees-for-labels
(setf (slot-value label slot)
(delete concept (slot-value label slot)))
;;; Position wichtig!
(let* ((node (of-node label))
(abox (in-graph node)))
(delete-from-heaps abox node concept))))
(timed-defmethod delete-from-unexpanded ((label node-label) (list list))
(dolist (concept list)
(delete-from-unexpanded label concept)))
;;;
;;;
;;;
(timed-defmethod delete-from-expanded ((label node-label) (concept concept))
#+:use-membership-tables
(remhash (list concept label) *expanded-table*)
(let ((slot (get-slot-for concept expanded)))
#+:use-avl-trees-for-labels
(delete-from-avl-tree concept (slot-value label slot) :key #'id)
#-:use-avl-trees-for-labels
(setf (slot-value label slot)
(delete concept (slot-value label slot)))))
(timed-defmethod delete-from-expanded ((label node-label) (list list))
(dolist (concept list)
(delete-from-expanded label concept)))
;;;
;;;
;;;
(timed-defmethod put-from-expanded-to-unexpanded ((concept concept) (label node-label))
(delete-from-expanded label concept)
(add-to-unexpanded label concept))
(timed-defmethod put-from-unexpanded-to-expanded ((concept concept) (label node-label))
(delete-from-unexpanded label concept)
(add-to-expanded label concept))
| 13,678 | Common Lisp | .lisp | 316 | 34.759494 | 107 | 0.662913 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 4db9fc6f82ef61365ab1b10dd6139c9dd2a559cea7770136937a622616fb448a | 12,541 | [
-1
] |
12,542 | specials.lisp | lambdamikel_DLMAPS/src/prover/specials.lisp | ;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;; Verwaltungslisten/Heaps fuehren? nur fuer ABOX1-Klasse!
;;; STANDARDMAESSIG IST ALLES AUS!!!
;;; nur durch Strategie-Objekte werden Kontexte / Specials gesetzt!
;;; also dort aendern, s. strategy.lisp
;;;
(defparameter *maintain-unexpanded-atomic-concepts-heap-p* nil)
(defparameter *maintain-unexpanded-atomic-concepts1-heap-p* nil)
(defparameter *maintain-unexpanded-and-concepts-heap-p* nil)
(defparameter *maintain-unexpanded-and-concepts-heap1-p* nil)
(defparameter *maintain-unexpanded-or-concepts-heap-p* nil)
(defparameter *maintain-unexpanded-or-concepts1-heap-p* nil)
(defparameter *maintain-unexpanded-some-concepts-heap-p* nil)
(defparameter *maintain-unexpanded-some-concepts1-heap-p* nil)
(defparameter *maintain-unexpanded-at-least-concepts-heap-p* nil)
(defparameter *maintain-unexpanded-at-least-concepts1-heap-p* nil)
(defparameter *maintain-unexpanded-attribute-exists-concepts-heap-p* nil)
(defparameter *maintain-unexpanded-attribute-exists-concepts1-heap-p* nil)
;;;
;;;
;;;
(defparameter *maintain-old-nodes-p* nil)
(defparameter *maintain-leaf-nodes-p* nil)
(defparameter *maintain-deactivated-nodes-p* nil)
(defparameter *maintain-active-nodes-p* nil)
(defparameter *maintain-cache-sat-nodes-p* nil)
(defparameter *maintain-blocked-nodes-p* nil)
;;;
;;; Syntax
;;;
(defparameter *cross-referencing-p* t)
(defparameter *syntactic-consistency-checking-p* nil)
(defparameter *syntactic-consistency-checking-of-some/all-conjuncts-p* nil)
(defparameter *create-negated-concept-p* t)
(defparameter *use-store-p* t)
(defparameter *insert-into-store-p* t)
(defvar *old-concept-p* nil)
(defvar *create-inverse-role-p* t)
;;;
;;; f. Debugging-Zwecke: checken mit Racer
;;; beim Klassifizieren der TBOx
;;;
(defparameter *racer-validation-p* nil)
(defparameter *logging-p* nil)
(defparameter *racer-tbox* 'racer-user::default)
;;;
;;;
;;;
(defparameter *reflexive-checks-p* t)
;;;
;;;
;;;
(defvar *start-time* 0)
(defvar *abox-init-required-p* t)
(defvar *time-for-node-creation* 0)
(defvar *time-for-edge-creation* 0)
(defvar *time-spend-in-undo* 0)
(defvar *no-of-undos* 0)
;;;
;;;
;;;
(defvar *rollback-active-p* nil)
(defvar *maintain-history-p* nil)
;;;
;;;
;;;
(defvar *how-many* nil)
(defvar *debug-p* nil)
(defvar *debug-node* nil)
(defvar *debug-concept* nil)
(defvar *announce-p* nil)
(defvar *show-prover-incarnations-p* nil)
(defvar *semantic-branching-p* t)
(defvar *maintain-prover-state-p* nil)
(defvar *check-if-still-blocked-p* t)
(defvar *reuse-nodes-p* nil)
(defvar *break-p* nil)
(defvar *visualize-p* nil)
(defvar *completion-found-hook* nil)
(defvar *compute-all-completions-p* nil)
(defvar *dont-invalidate-store-p* nil)
;;;
;;;
;;;
(defvar *blocking-enabled-p* nil)
(defvar *adjust-blocking-dependencies-p* t)
(defvar *delete-nodes-p* nil)
(defvar *combined-some-all-rule-p* nil)
(defvar *propagation-of-transitive-all-concepts-p* nil)
(defvar *dynamic-blocking-p* nil)
;;;
;;; Abox (Knoten)-Modelle
;;;
(defparameter *store-ind-models-p* nil)
(defparameter *max-no-of-ind-models-per-node* 3)
;;;
;;; Konzept-(Tableuax)-Modelle
;;;
(defparameter *max-no-of-concept-models* 3)
(defvar *use-told-subsumers-p* t)
(defvar *compute-told-subsumers-p* t)
(defvar *use-cached-models-p* t)
(defvar *cache-models-p* t)
(defvar *subtableau-caching-p* t)
(defvar *use-unsat-cache-p* t)
;;;
;;;
;;;
(defparameter *keep-det-assertions-p* nil)
(defparameter *compute-core-model-p* nil)
(defparameter *store-instance-retrieval-model-p* nil)
;;;
;;;
;;;
(defvar *abox* nil)
(defvar *clashes* nil)
(defvar *strategy* nil)
(defvar *temp-abox-name* 0)
(defvar *completions* nil)
(defvar *meta-constraints* nil)
;;;
;;;
;;;
(defvar *abox-dispatcher* nil)
(defvar *language-dispatcher* nil)
;;;
;;;
;;;
(defvar *all-tboxes* nil)
(defvar *node* nil)
(defvar *nodes* nil)
(defvar *concept* nil)
(defvar *taxonomy* nil)
;;;
;;;
;;;
(defvar *cur-store*)
(defvar *atoms-store*)
(defvar *and-store*)
(defvar *or-store*)
(defvar *some-store*)
(defvar *all-store*)
(defvar *at-least-store*)
(defvar *at-most-store*)
(defvar *roles-store*)
#+:use-membership-tables (defvar *expanded-table*)
#+:use-membership-tables (defvar *unexpanded-table*)
;;;
;;;
;;;
(defvar *all-instance-tests* 0)
(defvar *obvious-non-instance-hits* 0)
(defvar *obvious-instance-hits* 0)
(defvar *individual-instance-proofs* 0)
;;;
;;;
;;;
(defvar *initial-concept-sat-cache-hits* 0)
(defvar *initial-concept-unsat-cache-hits* 0)
(defvar *initial-concept-sat-cache-queries* 0)
(defvar *initial-concept-unsat-cache-queries* 0)
(defvar *mm-queries* 0)
(defvar *mm-hits* 0)
(defvar *concept-queries* 0)
(defvar *true-concept-queries* 0)
(defvar *sat-cache-queries* 0)
(defvar *sat-cache-hits* 0)
(defvar *concept-mm-queries* 0)
(defvar *concept-mm-hits* 0)
(defvar *true-abox-consistency-tests* 0)
(defvar *true-abox-subsumption-tests* 0)
(defvar *blocked-nodes* 0)
(defvar *created-nodes* 0)
(defvar *subsumes-queries* 0)
(defvar *true-subsumes-queries* 0)
(defvar *subsumes-mm-hits* 0)
(defvar *subsumes-ts-hits* 0)
;;;
;;;
;;;
(defvar *language* nil)
(defvar *cur-abox* nil)
(defvar *cur-tbox* nil)
;;;
;;;
;;;
(defvar *all-dls* nil)
;;;
;;;
;;;
#+:use-membership-tables
(defvar *create-membership-tables-p* t)
#-:use-membership-tables
(defvar *create-membership-tables-p* nil)
(defvar *all-aboxes* nil)
(defvar *avl-key-counter* 0)
;;;
;;;
;;;
(defmacro with-prover-standard-settings (&body body)
`(let ((*cross-referencing-p* t)
(*syntactic-consistency-checking-p* t)
(*syntactic-consistency-checking-of-some/all-conjuncts-p* nil)
(*create-negated-concept-p* t)
(*use-store-p* t)
(*insert-into-store-p* t)
(*create-inverse-role-p* t)
(*old-concept-p* nil)
(*semantic-branching-p* t)
(*maintain-prover-state-p* nil)
(*reuse-nodes-p* nil)
(*compute-all-completions-p* nil)
(*blocking-enabled-p* nil)
(*delete-nodes-p* nil)
(*combined-some-all-rule-p* nil)
(*propagation-of-transitive-all-concepts-p* nil)
(*dynamic-blocking-p* nil)
(*store-ind-models-p* nil)
(*max-no-of-ind-models-per-node* 3)
(*max-no-of-concept-models* 3)
(*use-told-subsumers-p* t)
(*compute-told-subsumers-p* t)
(*use-cached-models-p* t)
(*cache-models-p* t)
(*subtableau-caching-p* t)
(*use-unsat-cache-p* t)
(*keep-det-assertions-p* nil)
(*compute-core-model-p* nil)
(*store-instance-retrieval-model-p* nil))
,@body))
(defparameter *prover-specials*
(sort '(*strategy*
*MAINTAIN-DEACTIVATED-NODES-P*
*MAINTAIN-LEAF-NODES-P*
*MAINTAIN-CACHE-SAT-NODES-P*
*MAINTAIN-OLD-NODES-P*
*MAINTAIN-ACTIVE-NODES-P*
*MAINTAIN-BLOCKED-NODES-P*
*MAINTAIN-UNEXPANDED-SOME-CONCEPTS-HEAP-P*
*MAINTAIN-UNEXPANDED-SOME-CONCEPTS1-HEAP-P*
*MAINTAIN-UNEXPANDED-AT-LEAST-CONCEPTS-HEAP-P*
*MAINTAIN-UNEXPANDED-AT-LEAST-CONCEPTS1-HEAP-P*
*MAINTAIN-UNEXPANDED-ATTRIBUTE-EXISTS-CONCEPTS-HEAP-P*
*MAINTAIN-UNEXPANDED-ATTRIBUTE-EXISTS-CONCEPTS1-HEAP-P*
*MAINTAIN-UNEXPANDED-ATOMIC-CONCEPTS-HEAP-P*
*MAINTAIN-UNEXPANDED-ATOMIC-CONCEPTS1-HEAP-P*
*MAINTAIN-UNEXPANDED-OR-CONCEPTS-HEAP-P*
*MAINTAIN-UNEXPANDED-OR-CONCEPTS1-HEAP-P*
*MAINTAIN-UNEXPANDED-AND-CONCEPTS-HEAP-P*
*MAINTAIN-UNEXPANDED-AND-CONCEPTS-HEAP1-P*
*MAINTAIN-PROVER-STATE-P*
*cross-referencing-p*
*syntactic-consistency-checking-p*
*syntactic-consistency-checking-of-some/all-conjuncts-p*
*create-negated-concept-p*
*use-store-p*
*insert-into-store-p*
*old-concept-p*
*create-inverse-role-p*
*racer-validation-p*
*logging-p*
*racer-tbox*
*start-time*
*continuation-active-p*
*time-for-node-creation*
*time-for-edge-creation*
*time-spend-in-undo*
*no-of-undos*
*how-many*
*debug-p*
*announce-p*
*show-prover-incarnations-p*
*semantic-branching-p*
*maintain-prover-state-p*
*reuse-nodes-p*
*break-p*
*visualize-p*
*completion-found-hook*
*compute-all-completions-p*
*dont-invalidate-store-p*
*blocking-enabled-p*
*delete-nodes-p*
*combined-some-all-rule-p*
*propagation-of-transitive-all-concepts-p*
*dynamic-blocking-p*
*store-ind-models-p*
*max-no-of-ind-models-per-node*
*max-no-of-concept-models*
*use-told-subsumers-p*
*compute-told-subsumers-p*
*use-cached-models-p*
*cache-models-p*
*subtableau-caching-p*
*use-unsat-cache-p*
*keep-det-assertions-p*
*compute-core-model-p*
*store-instance-retrieval-model-p*
*abox*
*temp-abox-name*
*completions*
*meta-constraints*
*abox-dispatcher*
*language-dispatcher*
*all-tboxes*
*node*
*nodes*
*concept*
*taxonomy*
*cur-store*
*atoms-store*
*and-store*
*or-store*
*some-store*
*all-store*
*at-least-store*
*at-most-store*
*roles-store*
#+:use-membership-tables *expanded-table*
#+:use-membership-tables *unexpanded-table*
*initial-concept-sat-cache-hits*
*initial-concept-unsat-cache-hits*
*initial-concept-sat-cache-queries*
*initial-concept-unsat-cache-queries*
*mm-queries*
*mm-hits*
*concept-queries*
*true-concept-queries*
*sat-cache-queries*
*sat-cache-hits*
*concept-mm-queries*
*concept-mm-hits*
*true-abox-consistency-tests*
*true-abox-subsumption-tests*
*blocked-nodes*
*created-nodes*
*subsumes-queries*
*true-subsumes-queries*
*subsumes-mm-hits*
*subsumes-ts-hits*
*language*
*cur-abox*
*cur-tbox*
*all-dls*
#+:use-membership-tables
*create-membership-tables-p*
#-:use-membership-tables
*create-membership-tables-p*
*all-aboxes*
*avl-key-counter*)
#'string-lessp))
| 10,896 | Common Lisp | .lisp | 352 | 25.127841 | 75 | 0.646716 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | fcad23d68a7b9101ff4552a47295924fd3b65fcf45d4b4668ad8bb7d14f609ed | 12,542 | [
-1
] |
12,543 | alci-ra-minus-prover.lisp | lambdamikel_DLMAPS/src/prover/alci-ra-minus-prover.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(eval-when (:compile-toplevel :load-toplevel :execute)
(defpersistentclass rolebox-abox (abox rolebox-substrate)))
;;;
;;;
;;;
(eval-when (:compile-toplevel :load-toplevel :execute)
(defpersistentclass rolebox-abox-edge (rolebox-substrate-edge abox-edge)))
(defmethod inverse-edge ((edge rolebox-abox-edge))
(slot-value edge 'inverse-edge))
;;;
;;;
;;;
(defun make-role-from-lookup-result (rbox res)
(let ((*cur-rbox* rbox))
(when res
(if (cdr res)
(parse-role `(or ,@res))
(parse-role (first res))))))
(defmethod lookup ((substrate rolebox-abox) (r rolebox-abox-edge) (s rolebox-abox-edge))
(lookup (substrate-rbox substrate)
(description r) (description s))) ; edge -> label
(defmethod lookup ((rbox rolebox) (r edge-label) (s edge-label))
(lookup rbox
(textual-description r) ; label -> role
(textual-description s)))
(defmethod lookup ((rbox rolebox) (r simple-role) (s simple-role))
(make-role-from-lookup-result rbox
(lookup rbox
(textual-description r)
(textual-description s))))
(defmethod lookup ((rbox rolebox) (r or-role) (s or-role))
(make-role-from-lookup-result rbox
(lookup rbox
(rest (textual-description r)) ;; OR entfernen
(rest (textual-description s)))))
(defmethod lookup ((rbox rolebox) (r or-role) (s simple-role))
(make-role-from-lookup-result rbox
(lookup rbox
(rest (textual-description r))
(textual-description s))))
(defmethod lookup ((rbox rolebox) (r simple-role) (s or-role))
(make-role-from-lookup-result rbox
(lookup rbox
(textual-description r)
(rest (textual-description s)))))
;;;
;;;
;;;
(defmethod make-inverse-description ((rbox rolebox) (description edge-label))
(make-edge-description (type-of description)
(or (get-inverse-role (textual-description description))
(break "No inverse role for ~A?" (textual-description description))
(get-inverse-role (textual-description description)))))
;;;
;;;
;;;
(defmethod get-standard-node-class ((rolebox-abox rolebox-abox))
'rolebox-abox-node)
(defmethod get-standard-edge-class ((rolebox-abox rolebox-abox))
'rolebox-abox-edge)
;;;
;;;
;;;
(eval-when (:compile-toplevel :load-toplevel :execute)
(defpersistentclass rolebox-abox-node (abox-node rolebox-substrate-node)))
;;;
;;; Überladen! Denn nun sind, dank der Role Box, alle inversen Kanten
;;; explizit verzeichnet
;;;
(defmethod add-a-choice-point ((edge rolebox-abox-edge) choice-point &key &allow-other-keys)
(push choice-point (slot-value edge 'choice-points))
(push choice-point (slot-value (description (inverse-edge edge)) 'choice-points)))
(defmethod set-choice-points ((edge rolebox-abox-edge) choice-points &key &allow-other-keys)
(let ((points (ensure-list choice-points)))
(setf (slot-value edge 'choice-points) points)
(setf (slot-value (description (inverse-edge edge)) 'choice-points) points)))
(defmethod manager-fn ((sel-edge rolebox-abox-edge) edges processed-edges &rest args)
(declare (ignorable edges processed-edges args))
(call-next-method))
(defmethod edge-setter ((edge rolebox-abox-edge) (role simple-role) &key remaining &allow-other-keys)
(declare (ignore remaining))
(change-textual-description (description edge) role)
(change-textual-description (description (inverse-edge edge))
(get-inverse-role role))
edge)
;;;
;;;
;;;
(defmethod apply-rolebox-axioms ((substrate rolebox-abox) &rest args &key depends-on from-node &allow-other-keys)
(apply #'call-next-method substrate
:edge-constructor
#'(lambda (from to comp &key support)
(let ((edge
(create-edge substrate
from to
(make-edge-description
(get-standard-edge-description-class substrate)
comp)
:from-node from-node
:depends-on (append depends-on support))))
edge))
args))
(defrule rolebox-application (alci-ra-minus rolebox-abox)
(apply-rolebox-axioms abox)
(when *debug-p*
(announce "Edges after Rolebox Application: ")
(dolist (edge (get-edges abox))
(describe-object edge t)
(terpri))
(terpri))
+insert-body-code+)
;;;
;;;
;;;
(define-prover ((abox-sat alci-ra-minus rolebox-abox))
(:init
(start-main))
(:main
(perform (rolebox-application)
(:body
(perform (abox-enumeration)
(:body
(perform (deterministic-expansion)
(:body
(if clashes
(handle-clashes)
(perform (or-expansion)
(:positive
(if clashes
(handle-clashes)
(restart-main)))
(:negative
(perform (some-expansion)
(:positive
(if clashes
(handle-clashes)
(restart-main)))
(:negative
(success)))))))))
(:after-successful-clash-repair
(restart-main))))))
(:success
(completion-found)))
(defmethod reorder-ppi ((abox rolebox-abox))
(let* ((copy (copy abox))
(nodes (get-nodes copy))
(order nil)
(*cur-rbox* +rcc5-rolebox+))
(with-abox* (abox)
(loop while nodes do
(let ((smallest
(remove-if #'(lambda (n)
(get-role-successors n (parse-role 'pp)))
nodes)))
(when (or (not smallest)
(cdr smallest))
(break "~A No linear structure present! Tree structure? DAG?" smallest))
(let ((smallest (first smallest)))
(delete-node copy smallest)
(push smallest order)
(setf nodes (remove smallest nodes)))))
(scramble abox
:new-order (mapcar #'(lambda (node)
(find (id node)
(get-nodes abox)
:key #'id
:test #'=))
(reverse order))))))
(defmethod has-eq-edges-p ((abox rolebox-abox))
(let ((*cur-rbox* +rcc5-rolebox+))
(some #'(lambda (node)
(cdr (get-role-successors node (parse-role 'eq))))
(get-nodes abox))))
;;;
;;;
;;;
#|
(progn
(delete-all-tboxes)
(with-rbox (test
:delete-if-exists-p t
:roles (r s t)
:inverse-roles ((s r))
:reflexive-roles (t)
:axioms
((r r (s r t))))
(with-tbox (test :delete-if-exists-p t)
(with-abox (test :delete-if-exists-p t)
(instance a (some r (some r c)))
(instance a d)
(instance a (all r (not c)))
(instance a (all s (all (inv r) (all (inv r) (not d)))))
(true! (abox-consistent?))
(instance a (all t (not c)))
(false!
(abox-consistent-p *cur-abox*))))))
(progn
(delete-all-tboxes)
(with-rbox (test
:delete-if-exists-p t
:roles (r)
:inverse-roles ((r r))
:reflexive-roles (r)
:axioms
((r r (r))))
(with-tbox (test :delete-if-exists-p t
:type 'rolebox-abox)
(implies A B)
(equivalent A (some r E))
(equivalent C (all r B))
(setf *print-pretty* t)
;;; MIDELORA-BUG wenn reuse-nodes-p verwendet wird!!!
(princ (subsumes? c a :debug-p t :reuse-nodes-p nil :semantic-branching-p t))
;(visualize-taxonomy)
)))
(with-rbox (rcc5-rolebox)
(with-tbox (test :delete-if-exists-p t)
(with-abox (test :delete-if-exists-p t
:type 'rolebox-abox)
(ins a (and a
(all dr (not c))
(all po (not c))))
(ins b b)
(ins c c)
(rel a b dr)
(rel b c pp)
(true! (abox-consistent?))
(ins c (or (all (inv pp) (not a))
(all ppi (not a))))
(false! (abox-consistent?)))))
(progn
(delete-all-tboxes)
(with-rbox (rcc5-rolebox)
(with-abox (test :delete-if-exist-p t
:type 'rolebox-abox)
(instance a a)
(instance a (all eq b))
(true! (abox-consistent-p *cur-abox*))
(instance a (not b))
(false! (abox-consistent-p *cur-abox* )))))
;;;
;;; Härtetest! Funktioniert jetzt!!!
;;;
(progn
(delete-all-tboxes)
(with-rbox (rcc5-rolebox)
(setf *print-pretty* t)
(with-tbox (meta :delete-if-exists-p t
:type 'rolebox-abox)
(def* linear-time
(and (all dr bottom)
(all ec bottom)
(all po bottom)
(all ppi linear-time)
(all pp linear-time)))
(def* dense
(=> (some ppi top)
(some ppi (some ppi top))))
(def* right-bounded
(some ppi (and last-node
(all ppi bottom))))
(def* left-bounded
(some pp (and first-node
(all pp bottom))))
(def* left-unbounded
(all pp (some pp top)))
(def* right-unbounded
(all ppi (some ppi top)))
(with-abox (test :type 'rolebox-abox :delete-if-exists-p t)
(ins a (and linear-time
(some ppi (some ppi (some ppi (some ppi (some ppi (some ppi dead))))))
left-bounded
right-bounded))
(time (true! (abox-sat? test
:language +alci-ra-minus+
#+:clim
:completion-found-hook
#+:clim
#'(lambda (x) (visualize (reorder-ppi x)))
:debug-p nil)))))))
(progn
(delete-all-tboxes)
(with-rbox (rcc5-rolebox)
(with-tbox (test)
(with-abox (test)
(ins a (or (and (some pp (and c (all eq (not c)))))
(and (some dr (and c (all eq (not d)))))))
(true! (abox-sat? test))))))
(progn
(delete-all-tboxes)
(with-rbox (rcc5-rolebox)
(with-tbox (test)
(with-abox (test)
(ins a (and (some pp (some pp d))
(or (all pp (not d))
(some dr x))))
(true! (abox-sat? test))))))
(progn
(delete-all-tboxes)
(with-rbox (test
:delete-if-exists-p t
:roles (r s tt u w x)
:inverse-roles ((tt w))
:reflexive-roles (x)
:axioms
((r s (tt u))))
(with-tbox (test :delete-if-exists-p t)
(with-abox (test :delete-if-exists-p t)
(instance c (all w (not a)))
(instance a (all u (not c)))
(instance c c)
(instance a a)
(related a b r)
(related b c s)
(false!
(abox-consistent-p *cur-abox*
:visualize-p t))))))
|#
| 12,112 | Common Lisp | .lisp | 323 | 25.405573 | 113 | 0.514555 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 8c86d54b656fcad90975412b2abd4b559a2b7a584fa748ee56caf4f459feaeb7 | 12,543 | [
-1
] |
12,544 | simple-number-restrictions-expansion.lisp | lambdamikel_DLMAPS/src/prover/simple-number-restrictions-expansion.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(defrule simple-at-least-expansion (dl-with-number-restrictions abox)
(multiple-value-bind (at-least-concept node)
(select-at-least-concept abox *strategy* language)
(cond ((not node)
+insert-negative-code+ )
(t
(let ((role (role at-least-concept))
(n (n at-least-concept)))
(when *reuse-nodes-p*
(break "To be implemented"))
(announce "EXPANDING ~A : CREATING NEW NODE" node)
(register-as-expanded at-least-concept
:comment 'expand-at-least-concept-no-preconditions
:node node)
(loop-over-node-unexpanded-at-least-concepts (implied-at-least node)
(when (and (implies-p (role at-least-concept) (role implied-at-least))
(<= (n implied-at-least) n)
(not (eq implied-at-least at-least-concept)))
(register-as-expanded implied-at-least
:comment 'register-implied-at-least-concept
:node node
:depends-on (list (list node at-least-concept)))))
(let ((new-node
(create-anonymous-node abox
:depends-on (list (list node at-least-concept)))))
(relate node new-node role
:old-p nil
:multiplicity n
:depends-on (list (list node at-least-concept)))
(perform (compute-new-some-successor-label :new-node new-node
:node node
:role role
:concept at-least-concept))
+insert-positive-code+))))))
(defrule simple-at-most-merging (dl-with-number-restrictions abox)
(multiple-value-bind (bad-at-most-concept node edges m)
(select-violated-at-most-concept abox *strategy* language)
(declare (ignorable m))
(cond ((not node)
+insert-negative-code+)
(t
(let* ((new-choice-point (get-new-choice-point))
(collected-dependencies nil)
(memorized-action (get-current-action))
(sat nil)
(no (* 2 (n-over-k (length edges) 2))) ; (1 3) -> ((1 3) (3 1)) probieren!
(count 0)
(depends-on (cons (list node bad-at-most-concept)
edges)))
(loop-over-subsets-of-cardinality (partition edges 2)
(dolist (partition (list partition (reverse partition)))
(incf count)
(let* ((last-p (= count no)))
(announce "Trying partition ~A" partition)
(when last-p
(announce "This is the last partition!"))
(multiple-value-bind (merged-p not-mergeable-deps)
(try-to-merge node
partition
:new-choice-point new-choice-point
:depends-on depends-on
)
(if merged-p
(progn
(announce "Found mergable partition ~A" partition)
(multiple-value-bind (sub-sat deps)
+insert-positive-code+
(announce "Back on level ~A!" level)
(when *compute-all-completions-p*
(let ((*use-unsat-cache-p* nil))
(rollback-to abox memorized-action)))
(setf sat (or sat sub-sat))
(when (and (not sat)
(not *compute-all-completions-p*))
(push-all-to deps collected-dependencies))
;;; letzte Parition? -> in jedem Fall zurückkehren!
(when last-p
(return-from prover
(if sat
t
(if *compute-all-completions-p*
nil
(values nil
(sort-choice-points
(remove new-choice-point collected-dependencies)))))))
;;; nicht-letzte Partition
(when (not last-p)
(when (and sat (not *compute-all-completions-p*))
(return-from prover t))
(when (not sat)
(when (not (member new-choice-point deps))
;;;
;;; Clash Reason liegt nicht an der vorgenommen Partitionierung!
;;;
(return-from prover
(values nil
(sort-choice-points
(remove new-choice-point collected-dependencies)))))
(when (member new-choice-point deps)
;;;
;;; Clash Reason liegt an der Partition!
;;; Aufräumen und Weitermachen,
;;; nächste Partition aus der Schleife probieren
;;;
(when *debug-p*
(format t "~%*** BEFORE ROLLBACK:~%")
(describe-object abox t)
(loop-over-abox-nodes (node abox)
(describe-object node t)))
#+:use-dependency-directed-backtracking
(break "DEPENDENCY DIRECTED BACKTRACKING NOT FULLY UNDERSTOOD YET!")
#-:use-dependency-directed-backtracking
(progn
;;;
;;; einfaches BACKJUMPING
;;; chronologisches Abräumen
;;;
(rollback-to abox memorized-action node))
(when *debug-p*
(format t "~%*** AFTER ROLLBACK:~%")
(describe-object abox t)
(loop-over-abox-nodes (node abox)
(describe-object node t))))))))
;;; nodes waren nicht mergable!
(progn
(when (and (not sat)
(not *compute-all-completions-p*))
(push-all-to not-mergeable-deps collected-dependencies))
(when last-p
(return-from prover
(if sat
t
(if *compute-all-completions-p*
nil
(progn
(unless collected-dependencies
(break))
(values nil
(sort-choice-points collected-dependencies)))))))))))))
;;;
;;; diese Return wird ausgeführt, wenn cardinality = 0 war!
;;;
(return-from prover
(values nil
(sort-choice-points
(reduce #'append
(cons (get-choice-points bad-at-most-concept
:node node)
(mapcar #'get-choice-points edges)))))))))))
| 9,801 | Common Lisp | .lisp | 154 | 27.948052 | 103 | 0.378271 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 1b875655cac61230fa6c66a995e1555849ce086313e98b949e646f6d165ad939 | 12,544 | [
-1
] |
12,545 | alchn-prover.lisp | lambdamikel_DLMAPS/src/prover/alchn-prover.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(define-prover ((abox-sat alchn abox))
(:init
(cond ((zerop (1- (no-of-nodes abox)))
(loop-over-abox-nodes (node abox)
(register-label-is-stable abox node))
(with-strategy (+strategy+)
(start-main)))
(t
(perform (initial-abox-saturation)
(:body
(with-strategy (+abox-saturation-strategy+)
(loop-over-abox-nodes (node abox)
(register-label-is-stable abox node))
(perform (model-merging)
(:body
(start-main)))))))))
(:main
(perform (deterministic-expansion)
(:body
(if clashes
(handle-clashes)
(perform (or-expansion)
(:positive
(if clashes
(handle-clashes)
(restart-main)))
(:negative
(perform (simple-at-most-merging)
(:positive
(restart-main))
(:negative
(perform (identify-stable-nodes)
(:body
(perform (model-merging)
(:body
(perform (make-models-for-nodes)
(:body
(perform (some-expansion)
(:positive
(if clashes
(handle-clashes)
(next-round)))
(:negative
(perform (simple-at-least-expansion)
(:positive
(next-round))
(:negative
(perform (make-models-for-old-nodes)
(:body
(success))))))))))))))))))))))
(define-prover ((abox-sat alchn abox1))
(:init
(cond ((zerop (1- (no-of-nodes abox)))
(loop-over-abox-nodes (node abox)
(register-label-is-stable abox node))
(with-strategy (+trace-strategy+)
(start-main)))
(t
(perform (initial-abox-saturation)
(:body
(with-strategy (+trace-strategy+)
(loop-over-abox-nodes (node abox)
(register-label-is-stable abox node))
(perform (model-merging)
(:body
(start-main)))))))))
(:rollback
(let ((*maintain-active-nodes-p* t))
(rollback)))
(:main
(perform (focused-deterministic-expansion)
(:body
(if clashes
(handle-clashes)
(perform (or-expansion)
(:positive
(if clashes
(handle-clashes)
(restart-main)))
(:negative
(perform (simple-at-most-merging)
(:positive
(restart-main))
(:negative
(perform (identify-stable-nodes)
(:body
(perform (model-merging)
(:body
(perform (some-expansion)
(:positive
(if clashes
(handle-clashes)
(next-round)))
(:negative
(perform (simple-at-least-expansion)
(:positive
(next-round))
(:negative
(perform (pop-active-nodes-heap)
(:positive
(next-round))
(:negative
(perform (make-models-for-old-nodes)
(:body
(success))))))))))))))))))))))
#|
(progn
(progn
(delete-all-tboxes)
(delete-all-aboxes)
(with-abox (test :delete-if-exists-p t)
(related a a r)
(instance a (some r p))
(instance a (at-most 1 r))
(instance a (all r (some r p)))
(true! (abox-sat? test :debug-p t))))
(progn
(delete-all-tboxes)
(delete-all-aboxes)
(with-abox (test :delete-if-exists-p t)
(related a b r)
(related a c r)
(instance a (at-most 1 r))
(false! (abox-sat? test :debug-p t))))
(progn
(full-reset)
(define-primitive-role r)
(define-primitive-role s :parent r)
(related a b r)
(instance b b)
(instance a (some s (not b)))
(instance a (and a (at-most 1 r)))
(false! (abox-sat-p *cur-abox* :debug-p t)))
(progn
(delete-all-tboxes)
(delete-all-aboxes)
(with-abox (test :delete-if-exists-p t)
(related a f1 f)
(related a f2 f)
(instance a (at-most 1 f))
(false! (abox-sat? test :debug-p t))))
(progn
(full-reset)
(define-primitive-role r)
(define-primitive-role s :parent r)
(related a b r)
(instance a (some s top))
(instance a (at-most 1 r))
(true! (abox-sat-p *cur-abox* :debug-p t)))
(progn
(full-reset)
(define-primitive-role r)
(define-primitive-role s :parent r)
(related a b r)
(instance b (not c))
(instance a (some s c))
(instance a (at-most 1 r))
(false! (abox-sat-p *cur-abox* :debug-p t))))
|#
| 5,456 | Common Lisp | .lisp | 164 | 20.02439 | 65 | 0.457292 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 853e0fa3dddc402f0eca111a8681eb3a40d882ceac94cede246350de812b2576 | 12,545 | [
-1
] |
12,546 | midelora-lubm.lisp | lambdamikel_DLMAPS/src/prover/midelora-lubm.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
(setf (logical-pathname-translations "diss")
'(("lubm;**;*.*.*" "~/diss/kap7/LUBM/**/*.*")
("benchmark-results;**;*.*.*" "~/diss/kap7/benchmark-results/**/*.*")))
(defconstant +no-of-runs-per-query+ 1)
(defvar *file-stream* t)
(defvar *output-stream* t)
(defvar *global-prep* 0)
(defvar *global-exec* 0)
(defparameter *time* nil)
(defvar *load-time* nil)
(defvar *prep-time* nil)
(defvar *consistency-time* nil)
(defvar *inds* nil)
(defvar *results* nil)
(defvar *last-global* nil)
(eval-when (:compile-toplevel :load-toplevel :execute)
(defun ts::string-transform (string)
string))
(defun reset ()
(prover::delete-all-tboxes)
(ts::delete-all-queries))
(defmacro mtime (&body body)
`(if *time*
(time ,@body)
,@body))
(defmacro benchmark1 (universities departments no query vars)
`(let ((id ',(intern (format nil "LUBM-QUERY-~A" no)))
(number-of-answers nil)
(prep-time 0)
(exec-time 0))
(dotimes (i +no-of-runs-per-query+)
(let ((t1 (get-internal-run-time)))
(ts::midelora-prepare-query ,vars ,query :id id)
;; (format *output-stream* "~A" (thematic-substrate::describe-query id))
(let ((t2 (get-internal-run-time)))
(setf number-of-answers (length (ts::execute-query id)))
(incf exec-time (/ (- (get-internal-run-time) t2)
internal-time-units-per-second))
(incf prep-time (/ (- t2 t1)
internal-time-units-per-second)))))
(let ((mean-prep (/ prep-time +no-of-runs-per-query+))
(mean-exec (/ exec-time +no-of-runs-per-query+)))
(incf *global-prep* mean-prep)
(incf *global-exec* mean-exec)
(format *output-stream* "~%*** Universities: ~2,D Max. Deps: ~2,D Query: ~2,A Answers: ~12,D Prep-Time: ~12,D Exec-Time: ~12,D Total: ~12,D~%"
(1+ ,universities)
(if (null ,departments)
:all
(1+ ,departments))
,no
(if (null number-of-answers)
0
number-of-answers)
(float mean-prep)
(float mean-exec)
(+ (float mean-prep)
(float mean-exec)))
(format *file-stream*
"~2,D ~2,D ~2,A ~12,D ~12,D ~12,D ~12,D~%"
(1+ ,universities)
(if (null ,departments)
:all
(1+ ,departments))
,no
(if (null number-of-answers)
0
number-of-answers)
(float mean-prep)
(float mean-exec)
(+ (float mean-prep)
(float mean-exec)))
(force-output *file-stream*))))
(defmacro benchmark (universities departments no query vars)
`(benchmark1 ,universities ,departments ,no ',query ',vars))
;;; ======================================================================
(defun load-kbs (&optional (univs 1) (departments 1))
(declare (ignorable univs departments))
(reset)
;(let ((*package* (find-package :racer-user)))
; (load "~/diss/kap7/LUBM/lubm2.tbox"))
(princ univs)
(princ departments)
(let ((name (if (= univs 0)
(if departments
(format nil "lubm-0-~A" departments)
(format nil "lubm-1"))
(format nil "lubm-~A" univs))))
(princ name) (terpri)
(let ((*package* (find-package :prover)))
(load (format nil "/home/mi.wessel/diss/kap7/LUBM/~A.tbox" name))
;(load (format nil "/home/mi.wessel/diss/kap7/lubm.tbox.backup" name))
;(load (format nil "/home/mi.wessel/diss/kap7/LUBM/db-~A.abox" name))
(load (format nil "/home/mi.wessel/diss/kap7/LUBM/~A.abox" name)))
;;; (delete-all-nodes) ;;; fuer DB! alle Knoten/Kanten "virtuell"
(visualize-taxonomy)
;(in-abox lubm)
; (instance i top)
))
(defun prepare-lubm-data-n-universities (check-abox-consistency
n-universities max-n-departments)
(let ((t1a (get-internal-run-time)))
#+:allegro (princ "Stack Cushion: ")
#+:allegro (princ (system:stack-cushion))
#+:allegro (terpri)
(mtime (load-kbs n-universities max-n-departments))
(terpri)
(princ (current-abox))
(princ (current-abox))
(terpri)
(let ((t1b (get-internal-run-time)))
(setf *load-time*
(/ (- t1b t1a) internal-time-units-per-second))
(let ((t2a (get-internal-run-time)))
(format *output-stream* "~%~%ABox preparation ")
(format *output-stream* "done.~%")
(let ((t2b (get-internal-run-time)))
(when check-abox-consistency
(format *output-stream* "~%~%ABox consistency checking... ")
(terpri)
(princ (current-abox))
(princ (current-abox))
(terpri)
(mtime (prepare-abox-for-querying-and-sat-p (current-abox)))
(format *output-stream* "done.~%"))
(show-statistics)
(let ((t2c (get-internal-run-time)))
(setf *consistency-time*
(/ (- t2c t2b) internal-time-units-per-second))
(format *output-stream* "~%Compute index structures... ")
(ts::midelora-retrieve (?x) (?x top))
(format *output-stream* "done.~%")
(let ((t2d (get-internal-run-time)))
(setf *prep-time*
(/ (- t2d t2c) internal-time-units-per-second))
(setf *inds* (length (all-individuals)))
#+:Allegro (excl:gc t)
(format *output-stream*
#+:no-server
"~%Load: ~,20T~,4F ~%Preparation: ~,20T~,4F ~%Consistency: ~,20T~,4F ~%Index: ~,20T~,4F ~%Individuals: ~,20T~D ~%Concept Assertions: ~,20T~D ~%Role Assertions: ~,20T~D~%"
#-:no-server
"~%Load: ~,20T~,4F ~%Preparation: ~,20T~,4F ~%Consistency: ~,20T~,4F ~%Index: ~,20T~,4F~%"
(/ (- t1b t1a) internal-time-units-per-second)
(/ (- t2b t2a) internal-time-units-per-second)
(if check-abox-consistency
(/ (- t2c t2b) internal-time-units-per-second)
0)
(/ (- t2d t2c) internal-time-units-per-second)
#+:no-server (length (concept-instances top))
#+:no-server (length (all-concept-assertions))
#+:no-server (length (all-role-assertions))))))))))
;;; ======================================================================
(defun run-lubm-benchmark (benchmark-function
check-abox-consistency
&optional (univs 0) (min-deps 0) (max-deps min-deps))
(loop for deps1 from (if (null min-deps)
0
min-deps)
to (if (or (null max-deps) (not (zerop univs)))
0
max-deps)
do
(format *output-stream* "~%Initializing...~%")
(prepare-lubm-data-n-universities check-abox-consistency
univs
(if (or (null max-deps) (not (zerop univs)))
nil
deps1))
(format *output-stream* "~%Querying...~%")
(funcall benchmark-function
univs (if (or (null max-deps) (not (zerop univs)))
nil
deps1)))
(values))
(defun original-lubm (universities departments)
;;; Query 1
(with-abox-retrieval ( (current-abox) )
(benchmark universities
departments 1 (and
(?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#GraduateStudent|)
(?x |http://www.Department0.University0.edu/GraduateCourse0|
|http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#takesCourse|))
(?x))
;;; Query 2
(benchmark universities
departments 2 (and
(?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#GraduateStudent|)
(?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#University|)
(?z |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Department|)
(?x ?z |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#memberOf|)
(?z ?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#subOrganizationOf|)
(?x ?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#undergraduateDegreeFrom|))
(?x ?y ?z))
;;; Query 3
(benchmark universities
departments 3 (and
(?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Publication|)
(?x |http://www.Department0.University0.edu/AssistantProfessor0|
|http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#publicationAuthor|))
(?x |http://www.Department0.University0.edu/AssistantProfessor0|))
;;; Query 4
(benchmark universities
departments 4 (and (?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Professor|)
(?x |http://www.Department0.University0.edu|
|http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#worksFor|)
(?x (a |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#name|))
(?x (a |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#emailAddress|))
(?x (a |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#telephone|))
)
(?x ))
;;; Query 5
(benchmark universities
departments 5 (and (?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Person|)
(?x |http://www.Department0.University0.edu|
|http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#memberOf|))
(?x))
;;; Query 6
(benchmark universities
departments 6 (?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Student|)
(?x))
;;; Query 7
(benchmark universities
departments 7 (and (?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Student|)
(?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Course|)
(|http://www.Department0.University0.edu/AssociateProfessor0|
?y
|http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#teacherOf|)
(?x ?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#takesCourse|))
(?x ?y))
;;; Query 8
(benchmark universities
departments 8 (and (?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Student|)
(?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Department|)
(?x ?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#memberOf|)
(?y |http://www.University0.edu|
|http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#subOrganizationOf|)
(?x (a |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#emailAddress|)))
(?x ?y))
;;; Query 9
(benchmark universities
departments 9 (and (?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Student|)
(?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Faculty|)
(?z |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Course|)
(?x ?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#advisor|)
(?x ?z |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#takesCourse|)
(?y ?z |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#teacherOf|))
(?x ?y ?z))
;;; Query 10
(benchmark universities
departments 10 (and (?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Student|)
(?x |http://www.Department0.University0.edu/GraduateCourse0|
|http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#takesCourse|))
(?x))
;;; Query 11
(benchmark universities
departments 11 (and (?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#ResearchGroup|)
(?x |http://www.University0.edu|
|http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#subOrganizationOf|))
(?x))
;;; Query 12
(benchmark universities
departments 12 (and (?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Chair|)
(?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Department|)
(?x ?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#memberOf|)
(?y |http://www.University0.edu|
|http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#subOrganizationOf|))
(?x ?y))
;;; Query 13
(benchmark universities
departments 13 (and (?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Person|)
(|http://www.University0.edu|
?x
|http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#hasAlumnus|))
(?x))
;;; Query 14
(benchmark universities
departments 14 (?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#UndergraduateStudent|)
(?x))
))
(defun simple-lubm (universities departments)
(benchmark universities
departments 2 (and
(?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#GraduateStudent|)
(?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#University|)
(?z |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Department|)
(?x ?z |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#memberOf|)
(?z ?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#subOrganizationOf|)
(?x ?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#undergraduateDegreeFrom|))
(?x ?y ?z)))
(defun subsumption-lubm (universities departments)
(benchmark universities
departments 1
(?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Person|)
(?x))
(benchmark universities
departments 2
(and (?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Person|)
(?x ?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#worksFor|)
(?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Organization|))
(?x ?y))
(benchmark universities
departments 3
(?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Professor|)
(?x))
(benchmark universities
departments 4
(?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Chair|)
(?x))
(benchmark universities
departments 5
(and (?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Chair|)
(?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Department|)
(?x ?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#memberOf|))
(?x ?y))
(benchmark universities
departments 6
(and (?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Professor|)
(?x ?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#headOf|)
(?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Department|))
(?x ?y)))
(defun subsumption-lubm (universities departments)
(benchmark universities
departments 1
(?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Person|)
(?x))
(benchmark universities
departments 2
(and (?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Person|)
(?x ?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#worksFor|)
(?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Organization|))
(?x ?y))
(benchmark universities
departments 3
(?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Professor|)
(?x))
(benchmark universities
departments 4
(?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Student|)
(?x))
(benchmark universities
departments 5
(and (?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Student|)
(?x ?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#takesCourse|)
(?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#Course|))
(?x ?y))
(benchmark universities
departments 6
(and (?x |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#GraduateStudent|)
(?x ?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#takesCourse|)
(?y |http://www.lehigh.edu/%7Ezhp2/2004/0401/univ-bench.owl#GraduateCourse|))
(?x ?y)))
;;;
;;;
;;;
(defun run-lubm-tests (benchmark-function univs
&key (max-deps-univ-1 nil)
(check-abox-consistency t))
(let ((*global-prep* 0)
(*global-exec* 0))
(when (and (> univs 1) max-deps-univ-1)
(error "Maximum number of departments may only be specified ~
if only one university is processed."))
(pprint (ts::describe-query-processing-mode))
(run-lubm-benchmark benchmark-function
check-abox-consistency
(1- univs) (and max-deps-univ-1 (1- max-deps-univ-1)))
(format *output-stream* "Total preparation time: ~12,D Total execution time: ~12,D Rollback time: ~12,D~%"
(float *global-prep*)
(float *global-exec*)
(float (/ *time-spend-in-global-rollback* internal-time-units-per-second)))
(format *file-stream* "Prep ~12,D Exec ~12,D Global Rollback ~12,D~%"
(float *global-prep*)
(float *global-exec*)
(float (/ *time-spend-in-global-rollback* internal-time-units-per-second)))))
;;;
;;;
;;;
(defun test (univs &optional deps)
(setf *results* nil)
(loop as deps from 1 to 1 do
(full-reset)
(let ((ts::*multiprocess-queries* nil)
(settings 0))
(dolist (setting (list
;; ( :query-optimization :optimizer-use-cardinality-heuristics
;; :two-phase-query-processing-mode :query-repository :compiler)
(list t t nil nil nil nil)))
(if (sixth setting)
(setf ts::*compile-queries-p* t
ts::*compile-inline-p* t ;nil
ts::*runtime-evaluation-p* nil)
(setf ts::*compile-queries-p* nil
ts::*compile-inline-p* nil
ts::*runtime-evaluation-p* t))
(incf settings)
(with-open-file (*file-stream*
(format nil "diss:benchmark-results;result-univs-~A-deps-~A-setting-~A.res"
univs
deps
settings)
:direction :output
:if-exists :supersede
:if-does-not-exist :create)
(reset)
(ts::eval-nrql-settings
#'(lambda ()
(run-lubm-tests ;'original-lubm
'simple-lubm
univs
:check-abox-consistency t
:max-deps-univ-1 deps
))
:mode 3
:query-optimization (first setting)
:optimizer-use-cardinality-heuristics (second setting)
:two-phase-query-processing-mode (third setting)
:tuple-computation-mode :set-at-a-time
:query-repository (fourth setting)
:query-realization nil)
(push (list univs deps
*inds*
(float *load-time*)
(float *consistency-time*)
(float *prep-time*)
(float (/ *time-spend-in-global-rollback* internal-time-units-per-second))
*last-global*)
*results*)))))
(with-open-file
(*file-stream*
(format nil
"diss:benchmark-results;all-results.res")
:direction :output
:if-exists :supersede
:if-does-not-exist :create)
(pprint *results* *file-stream*)))
(defun subsumption-test ()
(full-reset)
(let ((ts::*multiprocess-queries* nil))
#+:allegro (system:set-stack-cushion nil)
(thematic-substrate::start-process
#+:allegro (system:set-stack-cushion nil)
(let ((ts::*multiprocess-queries* nil))
(setf ts::*compile-queries-p* nil
ts::*compile-inline-p* nil
ts::*runtime-evaluation-p* t)
(with-open-file (*file-stream*
"diss:benchmark-results;subsumption-test-midelora-result-1.res"
:direction :output
:if-exists :supersede
:if-does-not-exist :create)
(full-reset)
(ts::with-nrql-settings (:mode 3
:query-optimization t
:query-repository nil)
(run-lubm-tests 'subsumption-lubm 0
:check-abox-consistency t
)))
(with-open-file (*file-stream*
"diss:benchmark-results;subsumption-test-midelora-result-2.res"
:direction :output
:if-exists :supersede
:if-does-not-exist :create)
(full-reset)
(ts::with-nrql-settings (:mode 3
:query-optimization t
:query-repository t)
(run-lubm-tests 'subsumption-lubm 0
:check-abox-consistency t
)
(ts::show-current-qbox)))))))
| 23,040 | Common Lisp | .lisp | 471 | 35.152866 | 193 | 0.548387 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | d514724d697888ca2b0fe5f4afb3a1f3bd6919be42e24d001d9309c9b4c98daa | 12,546 | [
-1
] |
12,547 | kernel16.lisp | lambdamikel_DLMAPS/src/prover/kernel16.lisp | ;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(defvar *TIME-SPEND-IN-MAKE-CREATE-ACTION* 0)
(defvar *TIME-SPEND-IN-MAKE-PUT-TO-UNEXPANDED-ACTION* 0)
(defvar *TIME-SPEND-IN-MAKE-MOVE-FROM-UNEXPANDED-TO-EXPANDED* 0)
(defvar *TIME-SPEND-IN-MAKE-REGISTER-ADDITIONAL-DEPENDENCIES* 0)
(defvar *TIME-SPEND-IN-MAKE-CHANGE-STATE-ACTION* 0)
;;;
;;;
;;;
(defun get-current-choice-point ()
(choice-point-counter *cur-abox*))
(defun get-new-choice-point ()
(incf (choice-point-counter *cur-abox*)))
;;;
;;; Choice Point (Dependenz) Verwaltung
;;;
(timed-defmethod register-choice-points ((concept concept) (choice-points list) &key node (error-p t) &allow-other-keys)
(unless node
(error "Need a node!"))
(when *reflexive-checks-p*
(when (and error-p (get-choice-points concept :node node :error-p nil))
(error " ~A : ~A already has choice points!~%" node concept)))
(unless choice-points
(error "~A : ~A no choice points given!~%" node concept))
#+:use-avl-trees-for-choice-points
(avl-tree-insert (list concept (copy-list choice-points)) (slot-value node 'choice-points))
#-:use-avl-trees-for-choice-points
(push (list concept (copy-list choice-points)) (slot-value node 'choice-points)))
(timed-defmethod register-choice-points ((edge abox-edge) (choice-points list) &key (error-p t) &allow-other-keys)
(when *reflexive-checks-p*
(when (and error-p (get-choice-points edge :error-p nil))
(error "~A already has choice points!" edge)))
;;; die Kanten haben immer einfach Listen
(setf (slot-value edge 'choice-points) (copy-list choice-points)))
(defmethod register-choice-points ((objects list) (choice-points list) &rest args)
(dolist (object objects)
(apply #'register-choice-points object choice-points args)))
;;;
;;;
;;;
(timed-defmethod get-choice-points ((concept concept) &key node error-p)
(unless node
(error "Need a node!"))
(or #+:use-avl-trees-for-choice-points
(second (avl-tree-find concept (slot-value node 'choice-points)))
#-:use-avl-trees-for-choice-points
(second (find concept (slot-value node 'choice-points) :key #'first))
(when error-p
(describe-object node t)
(error "No choice points for ~A : ~A!" node concept))))
(timed-defmethod get-choice-points ((edge abox-edge) &key error-p &allow-other-keys)
(or (slot-value edge 'choice-points)
(when error-p (error "No choice points for ~A!" edge))))
(defmethod get-choice-points ((objects list) &rest args &key error-p &allow-other-keys)
(reduce #'append (mapcar #'(lambda (object)
(if (and (consp object)
(is-abox-node-p (first object)))
(apply #'get-choice-points (second object)
:node (first object)
:error-p error-p
args)
(apply #'get-choice-points object :error-p error-p args)))
objects)))
;;;
;;;
;;;
(timed-defmethod delete-choice-points ((concept concept) &key node)
(unless node
(error "Need a node!"))
(setf (slot-value node 'choice-points)
#+:use-avl-trees-for-choice-points
(avl-tree-delete concept (slot-value node 'choice-points))
#-:use-avl-trees-for-choice-points
(delete concept (slot-value node 'choice-points) :key #'first)))
(defmethod delete-choice-points ((edge edge) &key &allow-other-keys)
(setf (slot-value edge 'choice-points) nil))
(defmethod delete-choice-points ((objects list) &rest args)
(dolist (object objects)
(apply #'delete-choice-points object args)))
;;;
;;;
;;;
(defmethod get-clash-culprits ((node abox-node) (concept bottom-concept))
(list concept))
(defmethod get-clash-culprits ((node abox-node) (concept atomic-concept))
(list concept (get-negated-concept concept)))
(defmethod get-clash-culprits ((node abox-node) (concept and-concept))
(list concept (get-negated-concept concept)))
(defmethod get-clash-culprits ((node abox-node) (concept or-concept))
(append (list concept (get-negated-concept concept))
(mapcar #'get-negated-concept (arguments concept))))
(defmethod get-clash-culprits ((node abox-node) (concept some/all-concept))
(list concept (get-negated-concept concept)))
(defmethod get-clash-culprits ((node abox-node) (concept at-least-concept))
(list concept (get-negated-concept concept)))
(defmethod get-clash-culprits ((node abox-node) (concept at-most-concept))
(list concept (get-negated-concept concept)))
;;;
;;;
;;;
#+:use-dependency-directed-backtracking
(defmethod get-preconditioned-actions ((concept-assertion list))
(let ((node (first concept-assertion))
(concept (second concept-assertion)))
#+:use-avl-trees-for-actions
(second (avl-tree-find concept (slot-value node 'precondition-for-actions)))
#-:use-avl-trees-for-actions
(second (find concept (slot-value node 'precondition-for-actions) :key #'first))))
#+:use-dependency-directed-backtracking
(defmethod get-preconditioned-actions ((edge abox-edge))
(slot-value edge 'precondition-for-actions))
;;;
;;;
;;;
#+:use-dependency-directed-backtracking
(defmethod get-postconditioned-actions ((concept-assertion list))
(let ((node (first concept-assertion))
(concept (second concept-assertion)))
#+:use-avl-trees-for-actions
(second (avl-tree-find concept (slot-value node 'postcondition-for-actions)))
#-:use-avl-trees-for-actions
(second (find concept (slot-value node 'postcondition-for-actions) :key #'first))))
#+:use-dependency-directed-backtracking
(defmethod get-postconditioned-actions ((edge abox-edge))
(slot-value edge 'postcondition-for-actions))
;;;
;;;
;;;
(defstruct action
type
det-action-p
next-action
previous-action
triggered-by
triggers
comment
timestamp)
(defun get-current-action ()
;;; wird *nur* für den Aufbau der zeitlichen Ordnung verwendet!!!
(current-action *cur-abox*))
(defun set-to-current-action (action)
(setf (current-action *cur-abox*) action))
;;;
;;;
;;;
(defmacro undo-action1 (abox action)
`(let ((abox ,abox)
(action ,action))
(declare (ignorable abox))
(with-slots (next-action previous-action) action
(when next-action
(setf (slot-value next-action 'triggered-by)
(delete action (slot-value next-action 'triggered-by))))
(when previous-action
(setf (slot-value previous-action 'triggers)
(delete action (slot-value previous-action 'triggers))))
(when next-action
(setf (slot-value next-action 'previous-action) previous-action))
(when previous-action
(setf (slot-value previous-action 'next-action) next-action))
(when (eq action (current-action *cur-abox*))
;;; wurde die letzte Aktion gelöscht = zeitlich spaeteste?
;;; => *current-action* auf zeitlichen Vorgaenger setzen
;;; wenn es keine previous-action gibt, wird *current-action* NIL! okay!
(setf (current-action *cur-abox*) previous-action)))))
;;;
;;;
;;;
(defmacro init-action (action)
`(let ((action ,action))
(when (current-action *cur-abox*)
(setf (slot-value action 'previous-action) (current-action *cur-abox*)
(slot-value (current-action *cur-abox*) 'next-action) action))
(setf (slot-value action 'timestamp)
(incf (action-timestamp-counter *cur-abox*)))
(setf (current-action *cur-abox*) action)))
;;;
;;;
;;;
(defstruct (object-action (:include action))
object
pre)
(defmethod print-object ((action object-action) stream)
(with-slots (timestamp comment object pre) action
(format stream "#<~A @ ~A ~A:~% OBJECT ~A~% PRE ~A>"
(type-of action) timestamp comment object pre)))
(defstruct (create-edge-action (:include object-action)))
(defstruct (create-node-action (:include object-action)))
(defstruct (change-state-action (:include object-action))
state)
#|
(defstruct (delete-edge-action (:include object-action)))
(defstruct (delete-node-action (:include object-action)))
|#
;;;
;;;
;;;
(defmacro register-action-in-slot-of-constraint (action slot-name constraint)
`(let ((action ,action)
(constraint ,constraint))
(etypecase constraint
(edge
(push action (slot-value (description constraint)
,slot-name)))
(cons
(let ((node (first constraint))
(concept (second constraint)))
#+:use-avl-trees-for-actions
(let ((item (avl-tree-find concept
(slot-value (description node)
,slot-name))))
(if item
(setf (second item) (push action (second item)))
(avl-tree-insert (list concept (list action))
(slot-value (description node) ,slot-name))))
#-:use-avl-trees-for-actions
(let ((item (find concept (slot-value (description node)
,slot-name)
:key #'first)))
(if item ; (concept (action1 ... actionn))
(setf (second item) (push action (second item)))
(push (list concept (list action))
(slot-value (description node) ,slot-name)))))))))
(defmacro unregister-action-in-slot-of-constraint (action slot-name constraint)
`(let ((action ,action)
(constraint ,constraint))
(etypecase constraint
(edge
(setf (slot-value (description constraint) ,slot-name)
(delete action (slot-value (description constraint) ,slot-name))))
(cons
(let ((node (first constraint))
(concept (second constraint)))
#+:use-avl-trees-for-actions
(let ((item (avl-tree-find concept (slot-value (description node)
,slot-name))))
(when item
(setf (second item) (delete action (second item)))
(unless (second item)
(avl-tree-delete concept (slot-value (description node) ,slot-name)))))
#-:use-avl-trees-for-actions
(let ((item (find concept (slot-value (description node)
,slot-name)
:key #'first)))
(when item
(setf (second item) (delete action (second item)))
(unless (second item)
(setf (slot-value (description node) ,slot-name)
(delete concept (slot-value (description node) ,slot-name) :key #'first))))))))))
;;;
;;;
;;;
(defmacro init-object-action (action)
`(let ((action ,action))
(init-action action)
#+:use-dependency-directed-backtracking
(with-slots (pre object triggered-by) action
(dolist (constraint pre)
(register-action-in-slot-of-constraint action 'precondition-for-actions constraint)
(dolist (postconditioned-by-action
(get-postconditioned-actions constraint))
(push postconditioned-by-action
triggered-by)
(push action
(slot-value postconditioned-by-action 'triggers)))))
))
;;;
;;;
;;;
(defstruct (constraint-action (:include action))
pre
post
state)
(defmethod print-object ((action constraint-action) stream)
(with-slots (timestamp comment pre post det-action-p) action
(format stream "~%#<~A @ ~A, DET: ~A, COM: ~A:~% PRE: ~A~% POST: ~A>" (type-of action) timestamp det-action-p comment pre post)))
(defstruct (move-from-unexpanded-to-expanded-action (:include constraint-action)))
(defstruct (put-to-unexpanded-action (:include constraint-action)))
(defstruct (register-additional-dependencies-action (:include constraint-action)))
;;;
;;;
;;;
(defmacro init-constraint-action (action)
`(let ((action ,action))
(init-action action)
#+:use-dependency-directed-backtracking
(with-slots (pre post triggered-by) action
(dolist (constraint pre)
(register-action-in-slot-of-constraint action 'precondition-for-actions constraint)
(dolist (postconditioned-by-action
(get-postconditioned-actions constraint))
(push postconditioned-by-action
triggered-by)
(push action (slot-value postconditioned-by-action 'triggers))))
(dolist (constraint post)
(register-action-in-slot-of-constraint action 'postcondition-for-actions constraint)))
))
;;;
;;;
;;;
(defmacro get-state-vector-1 (object)
`(list ,object
(get-state-vector ,object)))
(defmacro register-action (action precondition-constraints postcondition-constraints
&key state-object comment det-action-p)
`(when *maintain-history-p*
(announce "Register action ~A" ',action)
(let ((precondition-constraints
,precondition-constraints)
(postcondition-constraints
,postcondition-constraints)
(state-object ,state-object)
(comment ,comment)
(det-action-p ,det-action-p))
(declare (ignorable precondition-constraints
postcondition-constraints
state-object
det-action-p
comment))
,(ecase action
;;; object actions: POST ist i.d.R. das erzeugte/geloeschte/modifizierte Objekt!
(change-state
`(with-timing (*time-spend-in-make-change-state-action*)
(let ((action
(make-change-state-action
:comment comment
:object postcondition-constraints
:pre precondition-constraints
:state (get-state-vector-1 (or state-object postcondition-constraints)))))
(init-object-action action)
action)))
(create
`(with-timing (*time-spend-in-make-create-action*)
(let ((action
(etypecase postcondition-constraints
(abox-edge
(make-create-edge-action
:comment comment
:object postcondition-constraints
:pre precondition-constraints))
(abox-node
(make-create-node-action
:comment comment
:object postcondition-constraints
:pre precondition-constraints)))))
(init-object-action action)
action)))
#|
(delete
`(let ((action
(etypecase precondition-constraints
(abox-edge
(make-delete-edge-action
:comment comment
:object precondition-constraints
:pre precondition-constraints))
(abox-node
(make-delete-node-action
:comment comment
:object precondition-constraints
:pre precondition-constraints)))))
(init-object-action action)
action))
|#
;;; constraint actions: PRE und POST
(put-to-unexpanded
`(with-timing (*time-spend-in-make-put-to-unexpanded-action*)
(let ((action
(make-put-to-unexpanded-action
:comment comment
:pre precondition-constraints
:post postcondition-constraints
:state (get-state-vector-1 state-object)
:det-action-p det-action-p)))
(init-constraint-action action)
action)))
(move-from-unexpanded-to-expanded
`(with-timing (*time-spend-in-make-move-from-unexpanded-to-expanded*)
(let ((action
(if (null precondition-constraints) ;;; keine Vorbedingungen!
(make-move-from-unexpanded-to-expanded-action
:comment comment
:pre postcondition-constraints ;;; KEIN Fehler!!!
:post postcondition-constraints
:state (get-state-vector-1 state-object)
:det-action-p det-action-p )
(make-move-from-unexpanded-to-expanded-action
:comment comment
:pre precondition-constraints
:post postcondition-constraints
:state (get-state-vector-1 state-object)))))
(init-constraint-action action)
action)))
(register-additional-dependencies
`(with-timing (*time-spend-in-make-register-additional-dependencies*)
(let ((action
(if (null precondition-constraints) ;;; keine Vorbedingungen!
(make-register-additional-dependencies-action
:comment comment
:pre postcondition-constraints ;;; KEIN Fehler!!!
:post postcondition-constraints
:state (when state-object
(get-state-vector-1 state-object)))
(make-register-additional-dependencies-action
:comment comment
:pre precondition-constraints
:post postcondition-constraints
:state (when state-object
(get-state-vector-1 state-object))))))
;;; (break "~A" action)
(init-constraint-action action)
action)))))))
;;;
;;;
;;;
(defmacro undo-object-action (abox action)
`(progn
(undo-action1 ,abox ,action)
#+:use-dependency-directed-backtracking
(with-slots (pre object) ,action
(dolist (constraint pre)
(unregister-action-in-slot-of-constraint ,action 'precondition-for-actions constraint)))))
(defmacro undo-constraint-action (abox action)
`(progn
(undo-action1 ,abox ,action)
#+:use-dependency-directed-backtracking
(with-slots (pre post) ,action
(dolist (constraint pre)
(unregister-action-in-slot-of-constraint action 'precondition-for-actions constraint))
(dolist (constraint post)
(unregister-action-in-slot-of-constraint action 'postcondition-for-actions constraint)))))
;;;
;;;
;;;
(defvar *time-spend-in-undo-create-edge-action* 0)
(defvar *time-spend-in-undo-create-node-action* 0)
(defvar *time-spend-in-undo-change-state-action* 0)
(defvar *time-spend-in-undo-put-to-unexpanded-action* 0)
(defvar *time-spend-in-undo-move-from-unexpanded-to-expanded-action* 0)
(defvar *time-spend-in-undo-register-additional-dependencies-action* 0)
;;;
;;;
;;;
(defmacro undo-action (abox action &optional to-node)
`(let ((*start-time* (get-internal-run-time))
(*rollback-active-p* t)
(*maintain-history-p* nil))
(incf *no-of-undos*)
(prog1
(etypecase ,action
;; create
(create-edge-action
(with-timing (*time-spend-in-undo-create-edge-action*)
(delete-edge ,abox (slot-value ,action 'object)
;; wichtig
:delete-inverse-p nil)
(undo-object-action ,abox ,action)))
(create-node-action
(with-timing (*time-spend-in-undo-create-node-action*)
(let ((node (slot-value ,action 'object)))
(delete-node ,abox node
;; wichtig; "create-edge"
;; erzeugt ja auch eine
;; protokollierende Aktion;
;; beim Undo gibt es sonst
;; einen Error, wenn das Loeschen
;; des Knotens eine automatisch
;; erzeugte reflexive Kante schon
;; mitloescht!
:delete-edges-p nil)
(when *use-unsat-cache-p*
(when (and (initial-concept node)
(if ,to-node
(or (is-successor-p node ,to-node)
(eq node (cur-clash-node abox)))
(eq node (cur-clash-node abox))))
(announce "Found unsatisfiable concept ~A" (initial-concept node))
(register-already-known-to-be-inconsistent abox node))))
(undo-object-action ,abox ,action)))
#|
;;; delete
(delete-edge-action
(let ((edge (slot-value ,action 'object)))
(register-edge edge))
(undo-object-action ,abox ,action))
(delete-node-action
(let ((node (slot-value ,action 'object)))
(register-node node))
(undo-object-action ,abox ,action))
|#
;; change state
(change-state-action
(with-timing (*time-spend-in-undo-change-state-action*)
(with-slots (object state) action
(let* ((state-object (first state))
(state (second state)))
(set-state-vector state-object state)))))
;; labels
(put-to-unexpanded-action
(with-timing (*time-spend-in-undo-put-to-unexpanded-action*)
(with-slots (post state) ,action
(dolist (post post)
(let ((concept (second post))
(node (first post)))
(delete-from-unexpanded node concept)
(delete-choice-points concept :node node)))
(undo-constraint-action ,abox ,action)
(let* ((state-object (first state))
(state (second state)))
(set-state-vector state-object state)))))
(move-from-unexpanded-to-expanded-action
(with-timing (*time-spend-in-undo-move-from-unexpanded-to-expanded-action*)
(with-slots (post state) ,action
(dolist (post post)
(let ((concept (second post))
(node (first post)))
(put-from-expanded-to-unexpanded concept node)))
(undo-constraint-action ,abox ,action)
(let* ((state-object (first state))
(state (second state)))
(set-state-vector state-object state)))))
;; deps (kaum verwendet)
(register-additional-dependencies-action
(with-timing (*time-spend-in-undo-register-additional-dependencies-action*)
(with-slots (pre post) ,action
(let ((pre-choice-points (get-choice-points pre)))
(dolist (post post)
(let* ((concept (second post))
(node (first post))
(points (get-choice-points concept :node node)))
(delete-choice-points concept :node node)
(register-choice-points concept
(remove-duplicates (cons 0 (set-difference points pre-choice-points)))
:node node)))))
(undo-constraint-action ,abox ,action))))
(incf *time-spend-in-undo*
(- (get-internal-run-time) *start-time*)))))
;;;
;;; Chronologisches Backtracking
;;;
(defmethod get-reverse-history ((abox abox))
(let* ((current (current-action abox)))
(when current
(loop while current
collect current
do
(setf current (slot-value current 'previous-action))))))
(defmethod get-history ((abox abox))
(let* ((current (current-action abox)))
(when current
(loop while (slot-value current 'previous-action)
do
(setf current (slot-value current 'previous-action)))
(loop while current
collect current
do
(setf current (slot-value current 'next-action))))))
(defmethod rollback-to ((abox abox) (action null) &optional to-node)
(declare (ignore to-node))
(announce "Rolling back from ~A to ~A" (current-action abox) action)
(undo-history abox (get-reverse-history abox)))
(defmethod rollback-to ((abox abox) (action action) &optional to-node)
(announce "Rolling back from ~A to ~A" (current-action abox) action)
(unless (current-action abox)
(error "No current action!"))
(let* ((current (current-action abox))
(history
(loop until (eq action current)
collect current
do
(setf current (slot-value current 'previous-action)))))
(undo-history abox history to-node)))
(defmethod undo-history ((abox abox) (history list) &optional to-node)
(announce "Undoing history of length ~A" (length history))
(dolist (action history)
(announce "Undoing ~A" action)
(undo-action abox action to-node))
(setf (cur-clash-node abox) nil)
(announce "Done."))
;;;
;;;
;;;
#+:use-dependency-directed-backtracking
(defun get-all-actions-triggered-by (constraint)
(let ((actions nil))
(labels ((do-it (action)
(unless (member action actions)
(push action actions)
(dolist (triggered-action (slot-value action 'triggers))
(do-it triggered-action)))))
(dolist (action (get-preconditioned-actions constraint))
(do-it action))
(sort actions #'> :key #'timestamp))))
#+:use-dependency-directed-backtracking
(defmethod rollback-all-depending-on ((abox abox) constraint)
(announce "Rollback all actions triggered by ~A" constraint)
(let ((actions (get-all-actions-triggered-by constraint)))
(undo-history abox actions)))
;;;
;;;
;;;
(timed-defmethod set-choice-points ((edge abox-edge) choice-points &key &allow-other-keys)
(setf (slot-value edge 'choice-points) (ensure-list choice-points)))
(timed-defmethod add-a-choice-point ((edge abox-edge) choice-point &key &allow-other-keys)
(push choice-point (slot-value edge 'choice-points)))
(timed-defmethod add-choice-points-for-edges ((abox abox) edges)
(let ((choice-points nil))
(dolist (edge edges)
(let ((point (get-new-choice-point)))
(push point choice-points)
(add-a-choice-point edge point)))
choice-points))
;;;
;;;
;;;
(timed-defmethod register-as-expanded ((concept concept) &key node depends-on comment)
(unless node
(error "Need a node!"))
(when *reflexive-checks-p*
(unless (unexpanded-p node concept)
(describe-object node t)
(error "Before putting ~A : ~A to EXPANDED, put it to UNEXPANDED!"
node concept))
(unless (get-choice-points concept :node node)
(describe-object node t)
(error "Register as expanded - no choice points for ~A : ~A!" node concept)))
(announce "I have expanded ~A : ~A" node concept)
(when depends-on
(announce "Depends on: ~A" depends-on)
(register-additional-dependencies concept
:node node
:depends-on depends-on
:error-p nil
:comment comment))
(register-action move-from-unexpanded-to-expanded
depends-on
(list (list node concept))
:state-object node
:comment comment)
(put-from-unexpanded-to-expanded concept node))
;;;
;;;
;;;
(timed-defmethod register-as-unexpanded ((concept concept) &key node new-choice-point depends-on comment)
(unless node
(error "Need a node!"))
(when *reflexive-checks-p*
(when (on-tableau-p node concept)
(error "~A : ~A already on tableau!" node concept)))
(announce "Register as unexpanded ~A : ~A" node concept)
(when depends-on
(announce "Depends on: ~A" depends-on))
(register-action put-to-unexpanded
depends-on
(list (list node concept))
:det-action-p (when (and (=> new-choice-point (zerop new-choice-point))
(every #'(lambda (x)
(zerop x))
(get-choice-points depends-on)))
t)
:state-object node
:comment comment)
(add-to-unexpanded node concept)
(register-choice-points-for concept
:node node
:new-choice-point new-choice-point
:depends-on depends-on)
(list concept) ; liefert die Lister der Konzept zurueck, die addiert wurden
)
(timed-defmethod register-as-unexpanded :around ((some-concept some-concept) &key node)
(let ((res (call-next-method)))
(when (role-domain (role some-concept))
(let* ((role (role some-concept))
(concept (role-domain role)))
(unless (on-tableau-p node concept)
(announce "Register role domain ~A of role ~A as unexpanded: ~A : ~A"
concept role node some-concept)
(setf res
(nconc res
(register-as-unexpanded concept
:node node
:depends-on
(list (list node some-concept))))))))
res))
(timed-defmethod register-as-unexpanded :around ((at-least-concept at-least-concept) &key node)
(let ((res (call-next-method)))
(when (role-domain (role at-least-concept))
(let* ((role (role at-least-concept))
(concept (role-domain role)))
(unless (on-tableau-p node concept)
(announce "Register role domain ~A of role ~A as unexpanded: ~A : ~A"
concept role node at-least-concept)
(setf res
(nconc res
(register-as-unexpanded concept
:node node
:depends-on
(list (list node at-least-concept))))))))
res))
;;;
;;;
;;;
(timed-defmethod register-as-unexpanded ((edge abox-edge) &rest args
&key
(register-choice-points-p t)
new-choice-point depends-on &allow-other-keys)
(when register-choice-points-p
(apply #'register-choice-points-for edge
:new-choice-point new-choice-point
:depends-on depends-on
args)))
;;;
;;;
;;;
#|
(timed-defmethod register-as-unexpanded ((constraints list) &rest args)
(dolist (constraint constraints)
(apply #'register-as-unexpanded constraint args)))
|#
;;;
;;;
;;;
(timed-defmethod register-additional-dependencies ((concept concept) &key (error-p t) node new-choice-point depends-on comment)
(when *reflexive-checks-p*
(unless (on-tableau-p node concept)
(error "~A : ~A is not on tableau!" node concept)))
(let ((depends-on ;(cons (list node concept)
;;; NEU, gloescht!
depends-on))
(announce "Register additional dependencies for ~A : ~A~%" node concept)
(when depends-on
(announce "Depends on: ~A" depends-on))
(register-action register-additional-dependencies
depends-on
(list (list node concept))
:state-object node
:comment comment)
(register-choice-points-for concept
:error-p error-p
:add-p t
:node node
:new-choice-point new-choice-point
:depends-on depends-on)))
(timed-defmethod register-additional-dependencies ((edge abox-edge) &key (error-p t) new-choice-point depends-on comment)
(let ((depends-on (cons edge depends-on)))
(announce "Register additional dependencies for ~A" edge)
(when depends-on
(announce "Depends on: ~A" depends-on))
(register-action register-additional-dependencies
depends-on
(list edge)
:state-object edge
:comment comment)
(register-choice-points-for edge
:error-p error-p
:add-p t
:new-choice-point new-choice-point
:depends-on depends-on)))
(defmethod register-additional-dependencies ((constraints list) &rest args)
(dolist (constraint constraints)
(apply #'register-additional-dependencies constraint args)))
;;;
;;;
;;;
;;;
(timed-defun register-choice-points-for (constraints
&key
node
(error-p t)
add-p
new-choice-point
depends-on
;; Liste vom Typ ((knoten konzept) edge ...)
&allow-other-keys
)
(let ((constraints (ensure-list constraints)))
(if depends-on
(let ((choice-points nil))
(loop as constraint in depends-on
do (etypecase constraint
(cons
(let ((node (first constraint))
(concept (second constraint)))
(dolist (point (get-choice-points concept :node node :error-p t))
(push point choice-points))))
(abox-edge
(dolist (point (get-choice-points constraint :error-p t))
(push point choice-points)))))
(let ((all-choice-points
(delete-duplicates
(if new-choice-point
(cons new-choice-point choice-points)
choice-points))))
(register-choice-points constraints
all-choice-points
:node node
:error-p (and error-p (not add-p)))))
;;
;; ELSE:
;; keine Constraint-Abhängigkeiten angegeben
;;
(if new-choice-point
(register-choice-points constraints (list new-choice-point)
:error-p (and error-p (not add-p))
:node node)
(when error-p
(error "No new-choice-point given for ~A!" constraints))))))
| 36,422 | Common Lisp | .lisp | 811 | 31.734895 | 137 | 0.564474 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | e4eb955b82741057dc71256cff34e7f0f0c0fcfcb8f1c21e70f5ffb5641b3441 | 12,547 | [
-1
] |
12,548 | creators.lisp | lambdamikel_DLMAPS/src/prover/creators.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
;;;
(defmethod create-abox-node ((abox abox) name-for-node
&rest args)
(apply #'create-node
abox name-for-node
(make-node-description (get-standard-node-description-class abox) nil)
args))
(defmethod create-node ((abox abox) (name-for-node symbol) (description node-label)
&rest args
&key
depends-on created-by
(old-p t)
&allow-other-keys)
(let ((*start-time* (get-internal-run-time)))
(let* ((created-by (or created-by depends-on))
(node (apply #'call-next-method
abox name-for-node description
:delete-if-exists-p nil
:old-p old-p
:created-by created-by
:edge-constructor #'(lambda (node ref-role)
(create-edge abox
node node
(make-edge-description
(get-standard-edge-description-class abox)
ref-role)
:created-by created-by
:create-inverse-p nil
:error-p nil))
args)))
(setf (slot-value (description node) 'of-node) node
(slot-value node 'cluster-nodes) (list node))
(when created-by
(register-action create created-by node))
(incf *time-for-node-creation*
(- (get-internal-run-time)
*start-time*))
node)))
(defmethod register-node ((node abox-node))
(let ((abox (in-graph node)))
(with-slots (all-nodes old-nodes node-table) abox
(when (is-abox1-p abox)
(if (not *use-avl-trees-for-abox1-p*)
(push node all-nodes)
(insert-into-avl-tree node all-nodes :key #'id))
(when (and *maintain-old-nodes-p* (old-p node))
(push node old-nodes)))
(activate-node abox node)
(when (or (old-p node)
(root-p node)
(not (is-abox1-p abox)))
(unless node-table
(setf node-table
(make-weak-hash-table :size 10 :rehash-size 100)))
(call-next-method)))))
;;;
;;;
;;;
(defmethod create-edge ((abox abox)
(from abox-node) (to abox-node)
(description edge-label)
&rest args
&key
(old-p t)
depends-on created-by
(new-choice-point 0)
&allow-other-keys)
(let ((*start-time* (get-internal-run-time)))
(let ((created-by (or created-by depends-on))
(edge (apply #'call-next-method abox from to
description
:created-by created-by
:old-p old-p
args)))
(unless *dont-invalidate-store-p*
(note-abox-has-changed abox)
(reset-sat-status from)
(reset-sat-status to)
;(reset-sat-status (concept-store (tbox abox)))
)
;;;
;;; Adresse verwalten
;;;
(incf (slot-value from 'succ-counter))
(setf (slot-value to 'address)
(cons (slot-value from 'succ-counter)
(slot-value from 'address)))
(setf (slot-value to 'rev-address)
(reverse (slot-value to 'address)))
;;;
;;; Blaetter
;;;
(apply #'register-as-unexpanded edge
:new-choice-point new-choice-point
args)
(when (inverse-edge edge)
(apply #'register-as-unexpanded (inverse-edge edge)
:new-choice-point new-choice-point
args))
(when created-by
(let ((created-by
(if (eq created-by t)
nil
created-by)))
(register-action create
created-by
edge)
(when (and (inverse-edge edge)
(not (eq (inverse-edge edge) edge)))
(register-action create
created-by
(inverse-edge edge)))))
(incf *time-for-edge-creation*
(- (get-internal-run-time)
*start-time*))
edge)))
(defmethod register-edge ((edge abox-edge))
(let ((abox (in-graph edge))
(from (from edge))
(to (to edge)))
(with-slots (all-edges edge-table) abox
(when (is-abox1-p abox)
(unless (cdr (outgoing from))
(setf (slot-value abox 'leaf-nodes)
(delete from (slot-value abox 'leaf-nodes))))
(if (not *use-avl-trees-for-abox1-p*)
(push edge all-edges)
(insert-into-avl-tree edge all-edges :key #'id)))
(if (or (old-p edge)
(not (is-abox1-p abox)))
(progn
(unless edge-table
(setf edge-table
(make-weak-hash-table :size 10 :rehash-size 100 :test #'equal)))
(call-next-method))
(progn
(push to (slot-value from 'successors))
(push from (slot-value to 'predecessors))
(push edge (slot-value from 'outgoing))
(push edge (slot-value to 'incoming)))))))
;;;
;;;
;;;
(defmethod relate ((from abox-node) (to abox-node) (description edge-label) &rest args)
(apply #'create-edge *cur-abox* from to description args))
(defmethod relate ((from abox-node) (to abox-node) role &rest args
&key description-type
&allow-other-keys)
(let* ((descr (make-edge-description
(or description-type
(get-standard-edge-description-class *cur-abox*)) role))
(role (textual-description descr)))
(declare (ignorable role))
(apply #'create-edge *cur-abox* from to descr args)))
(defmethod relate ((from symbol) (to symbol) role
&rest args &key (create-nodes-p t)
(node-type (get-standard-node-class *cur-abox*)) &allow-other-keys)
(apply #'relate
(or (apply #'find-node *cur-abox* from :error-p nil args)
(when create-nodes-p
(apply #'create-abox-node *cur-abox* from :type node-type args)))
(or (apply #'find-node *cur-abox* to :error-p nil args)
(when create-nodes-p
(apply #'create-abox-node *cur-abox* to :type node-type args)))
role
args))
;;;
;;;
;;;
(defmethod unrelate ((from abox-node) (to abox-node) role &rest args)
(unless (eq (in-graph from)
(in-graph to))
(error "Individuals must be in same ABox!"))
(let* ((abox (in-graph from))
(role (parse-role role))
(edges
(remove-if-not #'(lambda (edge)
(eq (role edge) role))
(apply #'get-edges-between abox from to args))))
(dolist (edge edges)
(apply #'delete-edge abox edge
:update-db-p t
args))))
(defmethod unrelate ((from symbol) (to symbol) role &rest args)
(apply #'unrelate
(apply #'find-node *cur-abox* from :error-p t args)
(apply #'find-node *cur-abox* to :error-p t args)
(parse-role role)
args))
;;;
;;;
;;;
(defun create-anonymous-node (abox &rest args)
(incf *created-nodes*)
(apply #'create-abox-node abox nil :old-p nil args))
| 8,069 | Common Lisp | .lisp | 200 | 26.1 | 102 | 0.494981 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | d9e5e2534b31cd46d740d5157665ee27e4550ebb92aed03ee8ef442e3aebe67e | 12,548 | [
-1
] |
12,549 | alchifn-rplus-prover.lisp | lambdamikel_DLMAPS/src/prover/alchifn-rplus-prover.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(define-prover ((abox-sat alchifn-rplus abox))
(:main
(perform (deterministic-expansion)
(:body
(if clashes
(handle-clashes)
(perform (or-expansion)
(:positive
(if clashes
(handle-clashes)
(restart-main)))
(:negative
(perform (simple-at-most-merging)
(:positive
(restart-main))
(:negative
(perform (block-nodes)
(:body
(perform (feature-expansion)
(:positive
(if clashes
(handle-clashes)
(restart-main)))
(:negative
(perform (some-expansion)
(:positive
(if clashes
(handle-clashes)
(restart-main)))
(:negative
(perform (simple-at-least-expansion)
(:positive
(if clashes
(handle-clashes)
(restart-main)))
(:negative
(success))))))))))))))))))
#|
(progn
(delete-all-tboxes)
(transitive r)
(deffeature f :parents r)
(unless (sat? (and (not c)
(some (inv f) c)
(at-most 1 f)
(all (inv r) (some (inv f) (and c (at-most 1 f)))))
:debug-p t)
(error "prover error")))
(progn
(delete-all-tboxes)
(transitive r)
(deffeature f :parents r)
(def d (and c (at-most 1 f) (some f (not c))))
(when (sat? (and (not c)
(at-most 1 f)
(some (inv f) d)
(all (inv r) (some (inv f) d)))
:debug-p t)
(error "prover-error"))
(delete-all-tboxes)
(when (sat? (and (some r (and c (some s (all (inv s) (all (inv r) (at-most 1 r))))))
(some r (and (not c) (some s (some r d)))))
:debug-p t)
(error "prover-error")))
(progn
(delete-all-tboxes)
(let ((*print-pretty* t))
(unless (sat? (and (some r (and c (some s (all (inv s)
(all (inv r) (at-most 1 r))))))
(some r (and (not d) (some s (some r d)))))
:debug-p t)
(error "prover-error"))))
(progn
(delete-all-tboxes)
(transitive r)
(defrole f :parents r)
(def d (and c (at-most 1 f) (some f (not c))))
(when (sat? (and (not c) (at-most 1 f)
(some (inv f) d)
(all (inv r) (some (inv f) d)))
:debug-p t)
(error "prover-error")))
|#
| 2,942 | Common Lisp | .lisp | 88 | 19.920455 | 86 | 0.417798 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | c7b6a15088d056e06d48d433d93d6e4644c62005d38f0d5b7210eb32921525c5 | 12,549 | [
-1
] |
12,550 | merging2.lisp | lambdamikel_DLMAPS/src/prover/merging2.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;; Merging etc.
;;;
(defun try-to-merge (node
partition
&key
depends-on
new-choice-point)
(let ((failed-choice-points (get-choice-points depends-on)))
(labels ((mergable-p (nodes)
(cond ((every #'old-p nodes)
;;; da alle Knoten "old" sind, gibt es keine Alternativen ->
;;; das at-most muss verhindert werden!
(values nil failed-choice-points))
((some #'(lambda (a)
(some #'(lambda (b)
(and (not (eq a b))
(intersection (created-by a)
(created-by b))))
nodes))
nodes)
(values nil failed-choice-points))
(t
(let ((clash-p nil))
(mapl #'(lambda (a)
(let ((a (first a))
(b (rest a)))
(dolist (b b)
(loop-over-node-concepts (ca a)
(when (on-tableau-p b (get-negated-concept ca))
;; (break)
;;; ordinärer Clash, müsste nicht hier abgehandelt werden,
;;; aber warum nicht...
(setf clash-p t)
(push-all-to (get-choice-points ca :node a)
failed-choice-points)
(push-all-to (get-choice-points (get-negated-concept ca) :node b)
failed-choice-points))))))
nodes)
(if clash-p
(values nil failed-choice-points)
t))))))
(let* ((edge-to-a (first partition))
(edge-to-b (second partition))
(a (if (eq node (from edge-to-a))
(to edge-to-a)
(from edge-to-a)))
(b (if (eq node (from edge-to-b))
(to edge-to-b)
(from edge-to-b)))
(nodes (list a b))
(abox (in-graph a))
(type (if (eq node (from edge-to-a))
(if (eq node (from edge-to-b))
'out-out
'out-in)
(if (eq node (from edge-to-b))
'in-out
'in-in))))
(labels ((create-merge-node ()
(register-action change-state nil edge-to-a)
(register-action change-state nil edge-to-b)
(ecase type
(out-out
(decf (slot-value edge-to-a 'multiplicity))
(decf (slot-value edge-to-b 'multiplicity)))
(in-out
(decf (slot-value edge-to-a 'inverse-multiplicity))
(decf (slot-value edge-to-b 'multiplicity)))
(out-in
(decf (slot-value edge-to-a 'multiplicity))
(decf (slot-value edge-to-b 'inverse-multiplicity))))
(let ((new-node
(create-anonymous-node abox
;;; wichtig! sonst werden fuer einen
;;; at-least-Constraint generierte Successors
;;; miteinander gemerged! s. (intersection ... ) in
;;; try-to-merge
:created-by (append (created-by a)
(created-by b))
:new-choice-point new-choice-point
:depends-on depends-on)))
(dolist (node nodes)
(register-action change-state nil node)
(when (and (=> (eq node a)
(ecase type
(out-out
(zerop (slot-value edge-to-a 'multiplicity)))
(in-out
(zerop (slot-value edge-to-a 'inverse-multiplicity)))
(out-in
(zerop (slot-value edge-to-a 'multiplicity)))))
(=> (eq node b)
(ecase type
(out-out
(zerop (slot-value edge-to-b 'multiplicity)))
(in-out
(zerop (slot-value edge-to-b 'multiplicity)))
(out-in
(zerop (slot-value edge-to-b 'inverse-multiplicity))))))
(setf (slot-value node 'deleted-p) t)
;(delete-node abox node)
)
(loop-over-node-concepts (concept node)
(unless (on-tableau-p new-node concept)
(register-as-unexpanded concept
:node new-node
:new-choice-point new-choice-point
:depends-on (cons (list node concept)
depends-on))))
(loop-over-node-expanded-concepts (concept node)
(unless (expanded-p new-node concept)
(register-as-expanded concept
:node new-node))))
new-node)))
(multiple-value-bind (mergable-p deps)
(mergable-p nodes)
(if (or (not mergable-p)
(ecase type
(out-out
(or (zerop (slot-value edge-to-a 'multiplicity))
(zerop (slot-value edge-to-b 'multiplicity))))
(in-out
(or
(zerop (slot-value edge-to-a 'inverse-multiplicity))
(zerop (slot-value edge-to-b 'multiplicity))))
(out-in
(or
(zerop (slot-value edge-to-a 'multiplicity))
(zerop (slot-value edge-to-b 'inverse-multiplicity))))))
(values nil deps)
(let ((new-node (create-merge-node))
(role nil))
(ecase type
(out-out
(setf role
(create-and-role (mapcar #'role partition))))
(in-out
(setf role
(create-and-role (list (slot-value (role edge-to-a) 'inverse-role)
(role edge-to-b)))))
(out-in
(setf role
(create-and-role (list (role edge-to-a)
(slot-value (role edge-to-b) 'inverse-role)))))
(in-in
(setf role
(create-and-role (list (slot-value (role edge-to-a) 'inverse-role)
(slot-value (role edge-to-b) 'inverse-role))))))
(relate node new-node role
:old-p nil
:new-choice-point new-choice-point
:depends-on depends-on)
;;;
;;; Tableau umbauen:
;;;
(dolist (node nodes)
(loop-over-role-successors (node nil) (succ edge)
(when (and (not (member edge partition)))
;;; multiplicity muss nicht betrachtet werden!
;;; die neuen Kanten sollen exakte Kopien sein!
(relate new-node succ (role edge)
:old-p nil
:new-choice-point new-choice-point
:depends-on (cons edge depends-on)
:multiplicity (multiplicity edge)
:inverse-multiplicity (inverse-multiplicity edge))))
(loop-over-role-predecessors (node nil) (succ edge)
(when (and (not (member edge partition)))
(relate succ new-node (role edge)
:old-p nil
:new-choice-point new-choice-point
:depends-on (cons edge depends-on)
:multiplicity (multiplicity edge)
:inverse-multiplicity (inverse-multiplicity edge)))))
;; (princ "****")
;; (visualize-abox (in-graph node)) (break)
new-node))))))))
| 10,647 | Common Lisp | .lisp | 180 | 26.533333 | 108 | 0.359676 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 031c201738b003544b527010af1eb232c714c993c096faf999c2d7eccf3305bf | 12,550 | [
-1
] |
12,551 | node-management.lisp | lambdamikel_DLMAPS/src/prover/node-management.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(timed-defmethod mark-deleted :after ((abox abox) (node abox-node))
;;: vorher wird deleted-p = T gesetzt,
;;; und deactivate aufgerufen!
;;; hier ist der Knoten noch nicht "physisch"
;;; geloescht
(announce "Deleting node ~A" node))
(timed-defmethod mark-deleted :after ((abox abox1) (node abox-node))
(with-slots (all-nodes old-nodes cache-sat-nodes) abox
(if (not *use-avl-trees-for-abox1-p*)
(setf all-nodes (delete node all-nodes))
(delete-from-avl-tree node all-nodes :key #'id))
(when (and *maintain-old-nodes-p* (old-p node))
;;; werden momentan nicht benutzt (-> vernachlaessigt )
(setf old-nodes (delete node old-nodes)))
(when *maintain-cache-sat-nodes-p*
(setf cache-sat-nodes
(delete node cache-sat-nodes)))))
;;;
;;;
;;;
(timed-defmethod delete-node ((abox abox) (node abox-node) &rest args)
(declare (ignorable args))
(call-next-method))
(timed-defmethod delete-node ((abox abox1) (node abox-node) &key (delete-edges-p t) &allow-other-keys)
(if (old-p node)
(call-next-method)
(progn
;;; wird sonst von substrate7.lisp erledigt!
(when delete-edges-p
(dolist (edge (outgoing node))
(delete-edge abox edge :error-p t))
(dolist (edge (incoming node))
(delete-edge abox edge :error-p t))))))
;;;
;;;
;;;
(timed-defmethod delete-node :before ((abox abox) (node abox-node) &rest args)
(declare (ignorable args))
;;; wichtig! :before!
;;; mark-deleted muss die Kontextinformation haben
(mark-deleted abox node))
;;;
;;;
;;;
(timed-defmethod activate-node :around ((abox abox) (node abox-node))
(announce "Activating node ~A" node)
(if (and *reflexive-checks-p* (active-p node))
(error "Can't activate ~A, is already active!" node)
(call-next-method)))
(defmethod activate-node :after ((abox abox) (node abox-node))
(unregister-deterministically-expanded abox node))
(defmethod activate-node :after ((abox abox1) (node abox-node))
(when *maintain-leaf-nodes-p*
(unless (outgoing node)
(pushnew node (slot-value abox 'leaf-nodes))))
(when *maintain-deactivated-nodes-p*
(setf (slot-value abox 'deactivated-nodes)
(delete node (slot-value abox 'deactivated-nodes))))
(when *maintain-active-nodes-p*
(when (and nil
*reflexive-checks-p*
(heap-find-item (slot-value abox 'active-nodes)
node))
(error "already on heap!"))
(heap-insert (slot-value abox 'active-nodes) node)))
;;;
;;;
;;;
(timed-defmethod deactivate-node :around ((abox abox) (node abox-node))
(if (and *reflexive-checks-p* (not (active-p node)))
(error "Can't deactivate ~A, is already deactivated!" node)
(call-next-method)))
(defmethod deactivate-node :after ((abox abox) (node abox-node))
(announce "Deactivating node ~A" node))
(defmethod deactivate-node :after ((abox abox1) (node abox-node))
(when *maintain-deactivated-nodes-p*
(push node (slot-value abox 'deactivated-nodes)))
(when *maintain-leaf-nodes-p*
(unless (outgoing node)
(setf (slot-value abox 'leaf-nodes)
(delete node (slot-value abox 'leaf-nodes)))
(dolist (in (incoming node))
(let ((pre (from in)))
(unless (cdr (outgoing pre))
(pushnew pre (slot-value abox 'leaf-nodes)))))))
(delete-from-all-heaps abox node)
(when *maintain-active-nodes-p*
(heap-remove-item (slot-value abox 'active-nodes) node)
(when (and nil *reflexive-checks-p* )
(when (heap-find-item (slot-value abox 'active-nodes) node)
(error "I've deactivated ~A, but ~A is still on active-nodes!" node)))))
;;;
;;;
;;;
(timed-defmethod unregister-deterministically-expanded ((abox abox) (node abox-node))
(setf (slot-value node 'deterministically-expanded-p) nil))
(timed-defmethod register-deterministically-expanded ((abox abox) (node abox-node))
(setf (slot-value node 'deterministically-expanded-p) t))
;;;
;;;
;;;
(defmethod get-state-vector ((node abox-node))
(with-slots (initial-concept
address
rev-address
succ-counter
old-p
active-p
checked-p
deleted-p
really-satisfiable-p
cache-satisfiable-p
deterministically-expanded-p
realized-p
stable-p
blocked-by
blocking-for
cluster-nodes) node
(list ;old-p
initial-concept
address
rev-address
succ-counter
active-p
checked-p
deleted-p
really-satisfiable-p
cache-satisfiable-p
deterministically-expanded-p
realized-p
stable-p
(copy-list blocked-by)
(copy-list blocking-for)
(copy-list cluster-nodes))))
(defmethod set-state-vector ((node abox-node) state &optional (maintain-index-structures-p t))
(declare (ignorable maintain-index-structures-p))
(let ((abox (in-graph node)))
(with-slots (initial-concept
address
rev-address
succ-counter
old-p
active-p
checked-p
deleted-p
really-satisfiable-p
cache-satisfiable-p
deterministically-expanded-p
realized-p
stable-p
blocked-by
blocking-for
cluster-nodes) node
(let ((old-state (list active-p
blocking-for
blocked-by
cache-satisfiable-p)))
;; fuer diese werden in ABox1 extra Indexstrukturen gepflegt!
(setf ;old-p (pop state)
initial-concept (pop state)
address (pop state)
rev-address (pop state)
succ-counter (pop state)
active-p (pop state)
checked-p (pop state)
deleted-p (pop state)
really-satisfiable-p (pop state)
cache-satisfiable-p (pop state)
deterministically-expanded-p (pop state)
realized-p (pop state)
stable-p (pop state)
blocked-by (pop state)
blocking-for (pop state)
cluster-nodes (pop state))
(let ((new-state (list active-p
blocking-for
blocked-by
cache-satisfiable-p)))
(when maintain-index-structures-p
(adjust-index-structures abox node old-state new-state)
(when *debug-p* (describe-object abox t))))))
abox))
;;;
;;;
;;;
(timed-defmethod adjust-index-structures ((abox abox) (node abox-node) old-state new-state)
(let ((old-active-p (pop old-state))
(old-blocking-for (pop old-state))
(old-blocked-by (pop old-state))
(old-cache-satisfiable-p (pop old-state))
(new-active-p (pop new-state))
(new-blocking-for (pop new-state))
(new-blocked-by (pop new-state))
(new-cache-satisfiable-p (pop new-state))
(*reflexive-checks-p* nil)
(*check-if-still-blocked-p* nil))
(unless *rollback-active-p*
(error "adjust index structures!"))
(when (and old-active-p (not new-active-p))
(deactivate-node abox node))
(when (and (not old-active-p) new-active-p)
(activate-node abox node))
(let ((+blocking-for
(set-difference new-blocking-for old-blocking-for))
(-blocking-for
(set-difference old-blocking-for new-blocking-for))
(+blocked-by
(set-difference new-blocked-by old-blocked-by))
(-blocked-by
(set-difference old-blocked-by new-blocked-by)))
(dolist (blocked +blocking-for)
(register-blocking-blocked abox node blocked))
(dolist (blocked -blocking-for)
(unregister-blocking-blocked abox node blocked))
(dolist (blocking +blocked-by)
(register-blocking-blocked abox blocking node))
(dolist (blocking -blocked-by)
(unregister-blocking-blocked abox blocking node)))
#|
(when (and old-blocked-by (not new-blocked-by))
(princ "adjust index structures") (terpri)
(unregister-blocking-blocked abox (first old-blocked-by) node))
(when (and new-blocked-by (not old-blocked-by))
(princ "adjust index structures") (terpri)
(register-blocking-blocked abox (first new-blocked-by) node)) |# ))
;;;
;;;
;;;
(defmethod blocked-p ((node abox-node))
(when (slot-value node 'blocked-by)
t))
(defmethod blocking-p ((node abox-node))
(when (slot-value node 'blocking-for)
t))
;;;
;;;
;;;
(timed-defmethod register-blocking-blocked ((abox abox) (blocking abox-node) (blocked abox-node))
(when (and *reflexive-checks-p* (blocked-p blocked))
(error "Node ~A is already blocked!" blocked))
(announce "Blocking ~A, blocked by ~A!" blocked blocking)
(incf *blocked-nodes*)
(deactivate-node abox blocked)
(push blocked (slot-value blocking 'blocking-for))
(push blocking (slot-value blocked 'blocked-by)))
(timed-defmethod register-blocking-blocked :after ((abox abox1) (blocking abox-node) (blocked abox-node))
(when *maintain-blocked-nodes-p*
(push blocked (slot-value (in-graph blocked) 'blocked-nodes))))
;;;
;;;
;;;
(timed-defmethod unregister-blocking-blocked ((abox abox) (blocking abox-node) (blocked abox-node))
(with-slots (blocked-by) blocked
(when (and *reflexive-checks-p* (not (blocked-p blocked)))
(error "Node ~A is not blocked!" blocked))
(if (and nil
;;; hier kann man nicht einfach wieder die Blockierung herstellen,
;;; dann kommt die Dependenzverwaltung durcheinander!!!!
*check-if-still-blocked-p*
(blocking-blocked-p (slot-value abox 'language) blocking blocked))
(progn
;;; immer noch blockiert?
;;; Blockierung beibehalten
t)
(progn
;;; Blockierung aufheben
(announce "Unblocking ~A, blocked by ~A!" blocked blocking)
(with-slots (blocking-for) blocking
(setf blocked-by (delete blocking blocked-by))
(setf blocking-for (delete blocked blocking-for)))
(unless (active-p blocked)
(activate-node abox blocked))))))
(timed-defmethod unregister-blocking-blocked :after ((abox abox1) (blocking abox-node) (blocked abox-node))
(when *maintain-blocked-nodes-p*
(unless (blocked-p blocked)
(setf (slot-value (in-graph blocked) 'blocked-nodes)
(delete blocked (slot-value (in-graph blocked) 'blocked-nodes))))))
;;;
;;;
;;;
(timed-defmethod adjust-blocking-dependencies ((abox abox) (node abox-node))
(when *adjust-blocking-dependencies-p*
(with-slots (blocked-by blocking-for) node
(let ((*reflexive-checks-p* nil))
;;; Unregister-blocking-blocked meckert sonst, da
;;; ja blocking-blocked-Beziehungen inkrementell
;;; (und nicht sofort) aufgeloest werden
(let ((blocked node))
(dolist (blocking blocked-by)
(unregister-blocking-blocked abox blocking blocked)))
(let ((blocking node))
(dolist (blocked blocking-for)
(unregister-blocking-blocked abox blocking blocked)))))))
;;;
;;;
;;;
(timed-defmethod add-to-unexpanded ((node abox-node) items)
(add-to-unexpanded (description node) items))
(timed-defmethod add-to-expanded ((node abox-node) items)
(add-to-expanded (description node) items))
;;;
;;;
;;;
(timed-defmethod delete-from-unexpanded ((node abox-node) items)
(delete-from-unexpanded (description node) items))
(timed-defmethod delete-from-expanded ((node abox-node) items)
(delete-from-expanded (description node) items))
;;;
;;;
;;;
(timed-defmethod put-from-expanded-to-unexpanded ((concept concept) (node abox-node))
(put-from-expanded-to-unexpanded concept (description node)))
(timed-defmethod put-from-unexpanded-to-expanded ((concept concept) (node abox-node))
(put-from-unexpanded-to-expanded concept (description node)))
;;;
;;;
;;;
(timed-defmethod add-to-heaps ((abox abox) (node abox-node) (concept concept))
t)
(timed-defmethod add-to-heaps ((abox abox1) (node abox-node) (concept concept))
(with-slots (nodes-not-and-expanded
nodes-not-atom-expanded
nodes-not-or-expanded
nodes-not-or-expanded1
nodes-not-some-expanded
nodes-not-some-expanded1
nodes-not-feature-expanded
nodes-not-feature-expanded1
nodes-not-at-least-expanded
nodes-not-at-least-expanded1) abox
(typecase concept
(atomic-concept
(when *maintain-unexpanded-atomic-concepts-heap-p*
(unless (has-unexpanded-atomic-concepts-p node)
(heap-insert nodes-not-atom-expanded node))))
(and-concept
(when *maintain-unexpanded-and-concepts-heap-p*
(unless (has-unexpanded-and-concepts-p node)
(heap-insert nodes-not-and-expanded node))))
(or-concept
(when *maintain-unexpanded-or-concepts1-heap-p*
(unless (has-unexpanded-or-concepts-p node)
;; dann ist er schon im Heap!
(heap-insert nodes-not-or-expanded1 node)))
(when *maintain-unexpanded-or-concepts-heap-p*
(unless (has-unexpanded-or-concepts-p node)
;; dann ist er schon im Heap!
(heap-insert nodes-not-or-expanded node))))
(at-least-concept
(when *maintain-unexpanded-at-least-concepts1-heap-p*
(unless (has-unexpanded-at-least-concepts-p node)
;; dann ist er schon im Heap!
(heap-insert nodes-not-at-least-expanded1 node)))
(when *maintain-unexpanded-at-least-concepts-heap-p*
(unless (has-unexpanded-at-least-concepts-p node)
(heap-insert nodes-not-at-least-expanded node))))
(attribute-exists-concept
(when *maintain-unexpanded-attribute-exists-concepts1-heap-p*
(unless (has-unexpanded-attribute-exists-concepts-p node)
(heap-insert nodes-not-feature-expanded1 node)))
(when *maintain-unexpanded-attribute-exists-concepts-heap-p*
(unless (has-unexpanded-attribute-exists-concepts-p node)
(heap-insert nodes-not-feature-expanded node))))
(some-concept
(when *maintain-unexpanded-some-concepts1-heap-p*
(unless (has-unexpanded-some-concepts-p node)
(heap-insert nodes-not-some-expanded1 node)))
(when *maintain-unexpanded-some-concepts-heap-p*
(unless (has-unexpanded-some-concepts-p node)
(heap-insert nodes-not-some-expanded node)))))))
(timed-defmethod delete-from-heaps ((abox abox) (node abox-node) (concept concept) &optional force-p)
(declare (ignorable force-p))
t)
(timed-defmethod delete-from-heaps ((abox abox1) (node abox-node) (concept concept) &optional force-p)
(with-slots (nodes-not-and-expanded
nodes-not-atom-expanded
nodes-not-det-expanded
nodes-not-or-expanded
nodes-not-or-expanded1
nodes-not-some-expanded
nodes-not-some-expanded1
nodes-not-feature-expanded
nodes-not-feature-expanded1
nodes-not-at-least-expanded
nodes-not-at-least-expanded1) abox
(typecase concept
(atomic-concept
(when *maintain-unexpanded-atomic-concepts-heap-p*
(when (or force-p (not (has-unexpanded-atomic-concepts-p node)))
(heap-remove-item nodes-not-atom-expanded node))))
(and-concept
(when *maintain-unexpanded-and-concepts-heap-p*
(when (or force-p (not (has-unexpanded-and-concepts-p node)))
(heap-remove-item nodes-not-and-expanded node))))
(or-concept
(when *maintain-unexpanded-or-concepts1-heap-p*
(when (or force-p (not (has-unexpanded-or-concepts-p node)))
(heap-remove-item nodes-not-or-expanded1 node)))
(when *maintain-unexpanded-or-concepts-heap-p*
(when (or force-p (not (has-unexpanded-or-concepts-p node)))
(heap-remove-item nodes-not-or-expanded node))))
(at-least-concept
(when *maintain-unexpanded-at-least-concepts1-heap-p*
(when (or force-p (not (has-unexpanded-at-least-concepts-p node)))
(heap-remove-item nodes-not-at-least-expanded1 node)))
(when *maintain-unexpanded-at-least-concepts-heap-p*
(when (or force-p (not (has-unexpanded-at-least-concepts-p node)))
(heap-remove-item nodes-not-at-least-expanded node))))
(attribute-exists-concept
(when *maintain-unexpanded-attribute-exists-concepts1-heap-p*
(when (or force-p (not (has-unexpanded-attribute-exists-concepts-p node)))
(heap-remove-item nodes-not-feature-expanded1 node)))
(when *maintain-unexpanded-attribute-exists-concepts-heap-p*
(when (or force-p (not (has-unexpanded-attribute-exists-concepts-p node)))
(heap-remove-item nodes-not-feature-expanded node))))
(some-concept
(when *maintain-unexpanded-some-concepts1-heap-p*
(when (or force-p (not (has-unexpanded-some-concepts-p node)))
(heap-remove-item nodes-not-some-expanded1 node)))
(when *maintain-unexpanded-some-concepts-heap-p*
(when (or force-p (not (has-unexpanded-some-concepts-p node)))
(heap-remove-item nodes-not-some-expanded node)))))))
;;;
;;;
;;;
(timed-defmethod delete-from-all-heaps ((abox abox1) (node abox-node))
(with-slots (nodes-not-and-expanded
nodes-not-atom-expanded
nodes-not-det-expanded
nodes-not-or-expanded
nodes-not-or-expanded1
nodes-not-some-expanded
nodes-not-some-expanded1
nodes-not-feature-expanded
nodes-not-feature-expanded1
nodes-not-at-least-expanded
nodes-not-at-least-expanded1) abox
(when *maintain-unexpanded-atomic-concepts-heap-p*
(heap-remove-item nodes-not-atom-expanded node))
(when *maintain-unexpanded-and-concepts-heap-p*
(heap-remove-item nodes-not-and-expanded node))
(when *maintain-unexpanded-or-concepts-heap-p*
(heap-remove-item nodes-not-or-expanded node))
(when *maintain-unexpanded-at-least-concepts-heap-p*
(heap-remove-item nodes-not-at-least-expanded node))
(when *maintain-unexpanded-attribute-exists-concepts-heap-p*
(heap-remove-item nodes-not-feature-expanded node))
(when *maintain-unexpanded-some-concepts-heap-p*
(heap-remove-item nodes-not-some-expanded node))
(when (old-p node)
(when *maintain-unexpanded-or-concepts1-heap-p*
(heap-remove-item nodes-not-or-expanded1 node))
(when *maintain-unexpanded-at-least-concepts1-heap-p*
(heap-remove-item nodes-not-at-least-expanded1 node))
(when *maintain-unexpanded-attribute-exists-concepts1-heap-p*
(heap-remove-item nodes-not-feature-expanded1 node))
(when *maintain-unexpanded-some-concepts1-heap-p*
(heap-remove-item nodes-not-some-expanded1 node)))))
;;;
;;;
;;;
(timed-defmethod register-already-known-to-be-satisfiable ((abox abox) (abox-node abox-node))
(when (initial-concept abox-node)
(register-concept-is-satisfiable (initial-concept abox-node))))
(timed-defmethod register-already-known-to-be-inconsistent ((abox abox) (abox-node abox-node))
(when (and *reflexive-checks-p* (not (initial-concept abox-node)))
(error "no initial concept!"))
(register-concept-is-inconsistent (initial-concept abox-node)))
;;;
;;;
;;;
(timed-defmethod register-cache-satisfiable ((abox abox) (abox-node abox-node))
(when (and *reflexive-checks-p* (cache-satisfiable-p abox-node))
(error "Node ~A is already registered as cache satisfiable!" abox-node))
(setf (slot-value abox-node 'cache-satisfiable-p) t))
(timed-defmethod register-cache-satisfiable :after ((abox abox1) (abox-node abox-node))
(delete-from-all-heaps abox abox-node)
(when *maintain-cache-sat-nodes-p*
(push abox-node (slot-value (in-graph abox-node) 'cache-sat-nodes))))
;;;
;;;
;;;
(timed-defmethod register-label-is-stable ((abox abox) (node abox-node))
(register-action change-state nil node)
(setf (stable-p node) t)
(when *reflexive-checks-p*
(when (initial-concept node)
(error "Node ~A alread has an initial concept!" node)))
(when (or (and *cache-models-p*
(root-or-old-p node))
*subtableau-caching-p*
;; beim Subtableau-caching werden ALLE
;; Knoten gecached
)
;; nur wenn das initial-concept gesetzt wird,
;; wird fuer diese Konzept in (defrule cache-models )
;; das Modell gespeichert! die Existenz von initial-concept
;; bestimmt also, was gecached wird!
(setf (slot-value node 'initial-concept)
(get-node-concept abox node))))
;;;
;;;
;;;
(defmethod get-node-concept ((abox abox) (node abox-node))
(let ((concepts nil))
(loop-over-node-concepts (concept node)
(push concept concepts))
(with-enabled-concept-store
(with-protected-concept-store
(make-and-concept concepts)))))
;;;
;;;
;;;
(timed-defmethod is-successor-p ((succ abox-node) (of abox-node))
(let ((nodes nil))
(labels ((do-it (node)
(unless (marked-p node)
(mark node)
(push node nodes)
(or (eq node of)
(some #'(lambda (in)
(do-it (from in)))
(incoming node))))))
(with-new-marking-context
(prog1
(do-it succ)
(unmark nodes))))))
;;;
;;;
;;;
(timed-defmethod activate-node ((abox abox) (item abox-item))
(register-action change-state nil item)
(setf (slot-value item 'active-p) t)
(register-action change-state nil item))
(timed-defmethod deactivate-node ((abox abox) (item abox-item))
(register-action change-state nil item)
(setf (slot-value item 'active-p) nil)
(register-action change-state nil item))
;;;
;;;
(timed-defmethod mark-deleted ((abox abox) (item abox-item))
(register-action change-state nil item)
(setf (slot-value item 'deleted-p) t)
(register-action change-state nil item)
(when (active-p item)
(deactivate-node abox item)))
(timed-defmethod unmark-deleted ((abox abox) (item abox-item))
(register-action change-state nil item)
(setf (slot-value item 'deleted-p) nil)
(register-action change-state nil item)
(unless (active-p item)
(activate-node abox item)))
| 23,408 | Common Lisp | .lisp | 557 | 33.524237 | 110 | 0.639487 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | ba1634eb7693d46d67c1917a87c8035898f7faeac3a6739e6eed43eaa64473fd | 12,551 | [
-1
] |
12,552 | tools.lisp | lambdamikel_DLMAPS/src/prover/tools.lisp | ;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(defun sort-choice-points (cps)
(sort (copy-list cps) #'>))
;;;
;;;
;;;
(defmacro avl-tree-insert (entry avl-tree)
;;; entry = (concept info)
`(insert-into-avl-tree ,entry ,avl-tree
:key #'first
:match-fn #'(lambda (x y)
(= (id x) (id y)))
:compare-fn #'(lambda (x y)
(< (id x) (id y)))))
(defmacro avl-tree-find (concept avl-tree)
`(find-in-avl-tree ,concept ,avl-tree
:apply-key-to-item-argument-p nil
:key #'first
:match-fn #'(lambda (x y)
(= (id x) (id y)))
:compare-fn #'(lambda (x y)
(< (id x) (id y)))))
(defmacro avl-tree-delete (concept avl-tree)
`(delete-from-avl-tree ,concept ,avl-tree
:apply-key-to-item-argument-p nil
:key #'first
:match-fn #'(lambda (x y)
(= (id x) (id y)))
:compare-fn #'(lambda (x y)
(< (id x) (id y)))))
;;;
;;; Modell Checking:
;;;
#|
(defmethod satisfied-p ((concept top-concept) (node abox-node))
t)
(defmethod satisfied-p ((concept bottom-concept) (node abox-node))
nil)
(defmethod satisfied-p ((concept atomic-concept) (node abox-node))
(eq (truth-value concept node) 'true))
(defmethod satisfied-p ((concept and-concept) (node abox-node))
(eq (truth-value concept node) 'true))
(defmethod satisfied-p ((concept or-concept) (node abox-node))
(eq (truth-value concept node) 'true))
(defmethod satisfied-p ((concept some-concept) (node abox-node))
(some #'(lambda (succ)
(satisfied-p (qualification concept) succ))
(get-role-successors node (role concept))))
(defmethod satisfied-p ((concept all-concept) (node abox-node))
(every #'(lambda (succ)
(satisfied-p (qualification concept) succ))
(get-role-successors node (role concept))))
(defmethod model-p ((abox abox) (concept concept))
(some #'(lambda (node)
(satisfied-p concept node))
(get-nodes abox)))
(defmethod globally-satisfied-p ((abox abox) (concept concept))
(every #'(lambda (node)
(satisfied-p concept node))
(get-nodes abox)))
|#
;;;
;;;
;;;
(defmethod get-expanded-concept-lists (node)
(let ((atoms nil)
(somes nil)
(alls nil)
(ands nil)
(ors nil)
(features nil)
(at-leasts nil)
(at-mosts nil))
(loop-over-node-slot (concept node expanded-atomic-concepts)
(push concept atoms))
(loop-over-node-slot (concept node expanded-and-concepts)
(push concept ands))
(loop-over-node-slot (concept node expanded-or-concepts)
(push concept ors))
(loop-over-node-slot (concept node expanded-some-concepts)
(push concept somes))
(loop-over-node-slot (concept node expanded-all-concepts)
(push concept alls))
(loop-over-node-slot (concept node expanded-attribute-exists-concepts)
(push concept features))
(loop-over-node-slot (concept node expanded-at-least-concepts)
(push concept at-leasts))
(loop-over-node-slot (concept node expanded-at-most-concepts)
(push concept at-mosts))
(values atoms ands ors somes alls features at-leasts at-mosts)))
(defmethod get-unexpanded-concept-lists (node)
(let ((atoms nil)
(somes nil)
(alls nil)
(ands nil)
(ors nil)
(features nil)
(at-leasts nil)
(at-mosts nil))
(loop-over-node-slot (concept node unexpanded-atomic-concepts)
(push concept atoms))
(loop-over-node-slot (concept node unexpanded-and-concepts)
(push concept ands))
(loop-over-node-slot (concept node unexpanded-or-concepts)
(push concept ors))
(loop-over-node-slot (concept node unexpanded-some-concepts)
(push concept somes))
(loop-over-node-slot (concept node unexpanded-all-concepts)
(push concept alls))
(loop-over-node-slot (concept node unexpanded-attribute-exists-concepts)
(push concept features))
(loop-over-node-slot (concept node unexpanded-at-least-concepts)
(push concept at-leasts))
(loop-over-node-slot (concept node unexpanded-at-most-concepts)
(push concept at-mosts))
(values atoms ands ors somes alls features at-leasts at-mosts)))
;;;
;;;
;;;
(defmethod describe-object ((node abox-node) stream)
(labels ((concepts (concepts)
(mapcar #'(lambda (c)
(list c (get-choice-points c :node node)))
concepts)))
(multiple-value-bind (u-atoms u-ands u-ors u-somes u-alls u-features u-at-leasts u-at-mosts)
(get-unexpanded-concept-lists node)
(multiple-value-bind (e-atoms e-ands e-ors e-somes e-alls e-features e-at-leasts e-at-mosts)
(get-expanded-concept-lists node)
(let ((u-atoms (sort u-atoms
#'string-lessp
:key #'(lambda (x) (symbol-name (name x)))))
(e-atoms (sort e-atoms
#'string-lessp
:key #'(lambda (x) (symbol-name (name x))))))
(format stream
"~%~%#<ABOX Node
ID ~W
NAME ~W
REPRESENTATIVE ~W
CLUSTER NODES ~W
OLD ~W
INITIAL CONCEPT ~W
CREATOR ~W
BLOCKED BY ~W
BLOCKING FOR ~W
ACTIVE ~W
STABLE ~W
DETERM.EXPANDED ~W
REALLY SAT ~W
CACHE SAT ~W
DELETED ~W
TOLD ~W
-------------------------------
UNEXPANDED POSITIVE ATOMS ~W
UNEXPANDED NEGATIVE ATOMS ~W
UNEXPANDED ANDS ~W
UNEXPANDED ORS ~W
UNEXPANDED SOMES ~W
UNEXPANDED ALLS ~W
UNEXPANDED FEATURES ~W
UNEXPANDED AT-LEAST ~W
UNEXPANDED AT-MOST ~W
-------------------------------
EXPANDED POSITIVE ATOMS ~W
EXPANDED NEGATIVE ATOMS ~W
EXPANDED ANDS ~W
EXPANDED ORS ~W
EXPANDED SOMES ~W
EXPANDED ALLS ~W
EXPANDED FEATURES ~W
EXPANDED AT-LEAST ~W
EXPANDED AT-MOST ~W~%>"
(slot-value node 'id)
(name node)
(representative-p node)
(mapcar #'id (cluster-nodes node))
(old-p node)
(initial-concept node)
(created-by node)
(slot-value node 'blocked-by)
(slot-value node 'blocking-for)
(slot-value node 'active-p)
(slot-value node 'stable-p)
(slot-value node 'deterministically-expanded-p)
(slot-value node 'really-satisfiable-p)
(slot-value node 'cache-satisfiable-p)
(slot-value node 'deleted-p)
(slot-value node 'told-concepts)
(concepts (remove-if #'negated-p u-atoms))
(concepts (remove-if-not #'negated-p u-atoms))
(concepts u-ands)
(concepts u-ors)
(concepts u-somes)
(concepts u-alls)
(concepts u-features)
(concepts u-at-leasts)
(concepts u-at-mosts)
(concepts (remove-if #'negated-p e-atoms))
(concepts (remove-if-not #'negated-p e-atoms))
(concepts e-ands)
(concepts e-ors)
(concepts e-somes)
(concepts e-alls)
(concepts e-features)
(concepts e-at-leasts)
(concepts e-at-mosts)))))))
(defmethod describe-object ((abox abox) stream)
(format stream
"#<~A ~A,
Nodes : ~A,
Old : ~A,
Active : ~A,
Inactive : ~A,
Blocked : ~A,
Leafs : ~A,
Cache Sat: ~A,
Edges: ~A>~%"
(type-of abox)
(name abox)
(mapcar #'id (get-nodes abox))
(mapcar #'id (get-old-nodes abox))
(mapcar #'id (get-active-nodes abox))
(mapcar #'id (get-deactivated-nodes abox))
(mapcar #'id (get-blocked-nodes abox))
(mapcar #'id (get-leaf-nodes abox))
(mapcar #'id (get-cache-sat-nodes abox))
(let ((*print-pretty* t))
(mapcar #'(lambda (x)
(format nil "(~A,~A):~A[~A] x ~A"
(id (from x)) (id (to x))
(multiplicity x)
(inverse-multiplicity x)
(textual-description (description x))))
(get-edges abox)))))
(defmethod describe-object :after ((abox abox1) stream)
(with-slots (active-nodes
cache-sat-nodes
deactivated-nodes
old-nodes
leaf-nodes
blocked-nodes
nodes-not-and-expanded
nodes-not-atom-expanded
nodes-not-det-expanded
nodes-not-or-expanded
nodes-not-or-expanded1
nodes-not-some-expanded
nodes-not-some-expanded1
nodes-not-feature-expanded
nodes-not-feature-expanded1
nodes-not-at-least-expanded
nodes-not-at-least-expanded1) abox
(format stream
"#<~A ~A, (M=Maintained) Index Structures:
Old : M=~A ~A,
Active : M=~A ~A,
Inactive : M=~A ~A,
Blocked : M=~A ~A,
Leafs : M=~A ~A,
Cache Sat: M=~A ~A,
nodes-not-or-expanded : M=~A, ~A,
nodes-not-or-expanded1 : M=~A, ~A,
nodes-not-some-expanded : M=~A, ~A,
nodes-not-some-expanded1 : M=~A, ~A,
nodes-not-feature-expanded : M=~A, ~A,
nodes-not-feature-expanded1 : M=~A, ~A,
nodes-not-at-least-expanded : M=~A, ~A,
nodes-not-at-least-expanded1 : M=~A, ~A>~%"
(type-of abox)
(name abox)
*maintain-old-nodes-p* (mapcar #'id old-nodes)
*maintain-active-nodes-p*
(if active-nodes
(mapcar #'id (heap-items active-nodes))
:no-heap)
*maintain-deactivated-nodes-p* (mapcar #'id deactivated-nodes)
*maintain-blocked-nodes-p* (mapcar #'id blocked-nodes)
*maintain-leaf-nodes-p* (mapcar #'id leaf-nodes)
*maintain-cache-sat-nodes-p* (mapcar #'id cache-sat-nodes)
*maintain-unexpanded-or-concepts-heap-p*
(mapcar #'id (heap-items nodes-not-or-expanded))
*maintain-unexpanded-or-concepts1-heap-p*
(mapcar #'id (heap-items nodes-not-or-expanded1))
*maintain-unexpanded-some-concepts-heap-p*
(mapcar #'id (heap-items nodes-not-some-expanded))
*maintain-unexpanded-some-concepts1-heap-p*
(mapcar #'id (heap-items nodes-not-some-expanded1))
*maintain-unexpanded-attribute-exists-concepts-heap-p*
(mapcar #'id (heap-items nodes-not-feature-expanded))
*maintain-unexpanded-attribute-exists-concepts1-heap-p*
(mapcar #'id (heap-items nodes-not-feature-expanded1))
*maintain-unexpanded-at-least-concepts-heap-p*
(mapcar #'id (heap-items nodes-not-at-least-expanded))
*maintain-unexpanded-at-least-concepts1-heap-p*
(mapcar #'id (heap-items nodes-not-at-least-expanded1)))))
(defmethod describe-object ((edge abox-edge) stream)
(let ((*print-pretty* t))
(format stream
"#<~A/~A = (~A/~A,~A/~A): ~A x ~A [~A] / ~A [~A], ~A x ~A>"
(name edge)
(id edge)
(name (from edge))
(id (from edge))
(name (to edge))
(id (to edge))
(multiplicity edge)
(role edge)
(slot-value edge 'choice-points)
(if (aux-description edge)
(textual-description (aux-description edge))
'none)
(if (aux-description edge)
(slot-value (aux-description edge) 'choice-points)
'())
(inverse-multiplicity edge)
`(inv ,(role edge)))))
;;;
;;;
;;;
(defmethod kind ((node abox-node))
(mapcar #'(lambda (x)
(sort x #'< :key #'id))
(cons (slot-value node 'told-concepts)
(multiple-value-call #'list (get-expanded-concept-lists node)))))
(defmethod kind ((edge abox-edge))
(role edge))
;;;
;;;
;;;
(defmethod info ((item abox-node) &key &allow-other-keys)
(format nil "ID:~A NAME:~A" (id item) (name item)))
(defmethod info ((item abox-edge) &key for-graph-visualizer-p)
(let ((*print-pretty* t))
(if for-graph-visualizer-p
(format nil "<~A,~A>: ~A-~A / ~A-(INV ~A)"
(id (from item))
(id (to item))
(multiplicity item)
(role item)
(inverse-multiplicity item)
(role item))
(format nil "~A/~A <~A,~A>: ~A-~A / ~A-(INV ~A),"
(name item)
(id item)
(id (from item)) (id (to item))
(multiplicity item)
(role item)
(inverse-multiplicity item)
(role item)))))
(defmethod info ((abox abox) &key &allow-other-keys)
(describe abox nil))
;;;
;;;
;;;
(defmethod print-object ((abox abox) stream)
(format stream "#<~A ~A/~A/~A>"
(type-of abox)
(name abox)
(id abox)
(satisfiable abox)))
(defmethod print-object ((item abox-node) stream)
(format stream "#<~A ~A>" (type-of item) (info item)))
(defmethod print-object ((item abox-edge) stream)
(format stream "#<~A ~A ~A>" (type-of item) (info item) (get-choice-points item)))
;;;
;;;
;;;
(defun latex-translate-concept (concept)
(if (symbolp concept)
(format nil "\\mi{~(~A~)}"
(stringsubst-char-with-string
(symbol-name concept)
#\-
"\\_"))
(let ((op (first concept)))
(case op
(not
(format nil "\\neg ~A"
(latex-translate-concept (second concept))))
((and or)
(let ((args
(splice-in
(if (eq op 'or)
"\\sqcup"
"\\sqcap")
(mapcar #'latex-translate-concept (rest concept)))))
(format nil "~A" args)))
(=>
(format nil "~A \\Rightarrow ~A"
(latex-translate-concept (second concept))
(latex-translate-concept (third concept))))
(<=
(format nil "~A \\Leftarrow ~A"
(latex-translate-concept (second concept))
(latex-translate-concept (third concept))))
(<=>
(format nil "~A \\Leftrightarrow ~A"
(latex-translate-concept (second concept))
(latex-translate-concept (third concept))))
(some
(format nil "( \\dex{\\rn{~A}}{~A} )"
(second concept)
(latex-translate-concept (third concept))))
(all
(format nil "( \\dax{\\rn{~A}}{~A} )"
(second concept)
(latex-translate-concept (third concept))))))))
#|
(defmethod latex-export ((obj tbox) fn)
(with-open-file (stream fn :direction :output :if-exists :supersede)
(format stream "\\begin{equalities}~%")
(dolist (def (reverse (definitions obj)))
(when (org-concept def)
(if (primitive-p def)
(format stream "\\tsubs{~A}{~A}~%"
(translate-concept (name def))
(translate-concept (org-concept def)))
(format stream "\\tequi{~A}{~A}~%"
(translate-concept (name def))
(translate-concept (org-concept def))))))
(format stream "\\end{equalities}~%")))
|#
;;;
;;;
;;;
(defun visualize-taxonomy (&optional (tbox *cur-tbox*))
(visualize-dag (taxonomy (find-tbox tbox :error-p t))
:view
#+:clim :graphically
#-:clim :textually))
#+:clim
(defun visualize-abox (&optional (abox *cur-abox*))
(visualize (find-abox abox :error-p t)))
(defun compute-all-subsets (set &optional (akku '(nil)))
(let ((newakku akku))
(mapl #'(lambda (lset)
(let ((item (first lset)))
(unless (some #'(lambda (set) (member item set)) newakku)
(dolist (expand akku)
(let ((new (cons item expand)))
(push new newakku)))
(setf newakku (compute-all-subsets (rest lset) newakku)))))
set)
newakku))
(defun compute-all-subsets-of-cardinality (set m)
(let ((all nil))
(labels ((do-it (set n)
(cond ((zerop n)
(list nil))
(t
(let ((local nil))
(mapl #'(lambda (res)
(let* ((item (first res))
(res (do-it (rest res) (1- n))))
(dolist (res res)
(push (cons item res) local)
(when (= m n)
(push (cons item res) all)))))
set)
local)))))
(do-it set m)
all)))
(defmacro loop-over-subsets-of-cardinality ((subset set card) &body body)
(let ((n (gensym))
(akku (gensym))
(remset (gensym))
(i (gensym)))
`(labels ((do-it (,remset ,n ,akku)
(if (zerop ,n)
(let ((,subset ,akku))
,@body)
(loop as ,remset on ,remset
as ,i = (first ,remset) do
(do-it (rest ,remset)
(1- ,n)
(cons ,i ,akku))))))
(do-it ,set ,card nil))))
;;;
;;;
;;;
(defun topo-sort (nodes smaller-p)
(labels ((do-it (root-nodes)
(let ((next-layer
(delete-duplicates
(remove-if-not #'(lambda (y)
(some #'(lambda (x)
(funcall smaller-p x y))
root-nodes))
nodes))))
(nconc root-nodes
(when next-layer
(do-it next-layer))))))
(let ((root-nodes
(remove-if #'(lambda (x)
(some #'(lambda (y)
(funcall smaller-p y x))
nodes))
nodes)))
(delete-duplicates (do-it root-nodes)))))
(defun find-cluster (nodes smaller-p)
(setf nodes (remove-duplicates nodes))
(labels ((do-it (start-node node cycle rem-nodes)
(if (member node cycle)
cycle
(let ((next-layer
(remove-if-not #'(lambda (y)
(funcall smaller-p node y))
rem-nodes)))
(let ((res nil))
(dolist (next next-layer)
(dolist (found
(do-it start-node next (cons node cycle)
(remove next rem-nodes)))
(push found res)))
res)))))
(let ((clusters nil))
(loop while nodes do
(let* ((node (first nodes))
(cluster
(do-it node node nil nodes)))
(setf nodes (set-difference nodes (cons node cluster)))
(when cluster (push cluster clusters))))
clusters)))
;;;
;;;
;;;
(defun concepts-left ()
(- (length *nodes*)
(position *node* *nodes*)))
(defun monitor ()
(loop (sleep 1)
(princ *concept*)
(princ " ")
(princ *node*)
(princ " ")
(princ (concepts-left))
(terpri)))
(defun statistics-monitor ()
(reset-statistics)
(loop (sleep 3)
(show-statistics)))
| 21,173 | Common Lisp | .lisp | 545 | 26.568807 | 98 | 0.502396 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 1b280031783ee29b03ac4f858bdb943dc436c7766bb1de65e1576a2a30cccea1 | 12,552 | [
-1
] |
12,553 | interface4.lisp | lambdamikel_DLMAPS/src/prover/interface4.lisp | ;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;; Interface: Reduktion aller Inferenzen auf ABox-Sat!
;;; Achtung: Consistent-p ist von descriptions.lisp geerbt
;;;
(defmethod consistent-p ((concept and-concept) &rest args
&key
subsumption-test-p
(use-cached-models-p *use-cached-models-p*)
&allow-other-keys)
(if (and use-cached-models-p
(register-concept-mm-query)
(models-of-concepts-mergeable-p
(get-language concept)
(arguments concept)))
(progn
(register-concept-mm-hit)
(=> subsumption-test-p
(register-subsumption-mm-hit))
(register-concept-is-satisfiable concept)
t)
(progn
(apply #'call-next-method concept args))))
;;;
;;;
;;;
#+:use-membership-tables
(defconstant +uex-table+
(make-weak-hash-table :size 10000 :rehash-size 10000 :test #'equalp))
#+:use-membership-tables
(defconstant +ex-table+
(make-weak-hash-table :size 10000 :rehash-size 10000 :test #'equalp))
(defmethod consistent-p :before ((concept concept) &rest args)
(declare (ignorable args))
(register-true-concept-query))
(defmethod consistent-p ((concept concept) &rest args
&key
(maintain-prover-state-p *maintain-prover-state-p* mps-specified-p)
subsumption-test-p
type
tbox
&allow-other-keys)
(let* ((tbox
(or tbox *cur-tbox*))
(type (or type
(get-abox-type-for-tbox (tbox concept))))
(name 'temp-abox)
(*dont-invalidate-store-p* t)
(*create-membership-tables-p* nil)
(*store-ind-models-p* nil))
(register-abox-consistency-test)
(when subsumption-test-p
(register-abox-subsumption-test))
(with-abox* (name
:tbox tbox
:type type
:language (get-language concept)
:delete-if-exists-p t)
#+:use-membership-tables
(progn
(clrhash +uex-table+)
(clrhash +ex-table+)
(setf (unexpanded-table *cur-abox*) +uex-table+)
(setf (expanded-table *cur-abox*) +ex-table+))
(let ((concept-sat-node (create-abox-node *cur-abox* 'temp :old-p nil)))
;; :old-p nil ist wichtig! sonst bringt das die Strategie durcheinander!!!
(node-instance concept-sat-node concept)
(let ((res (apply #'abox-sat-p *cur-abox*
:maintain-prover-state-p
(if mps-specified-p
maintain-prover-state-p
t)
;;; ist doch eine Einmal-ABox!
;;; warum soll ich ein Rollback machen?
;;; ist teuer!
;;;
;;; doch es gibt doch einen Grund:
;;; die Unsat-Caches werden dann gefuellt!!!
args)))
(delete-abox *cur-abox*)
(return-from consistent-p res))))))
;;;
;;;
;;;
(defmacro with-new-temp-abox-name (&body body)
`(let ((*temp-abox-name* (1+ *temp-abox-name*)))
,@body))
;;;
;;;
;;;
(defmethod inconsistent-p ((concept concept) &rest args)
(not (apply #'consistent-p concept args)))
(defmethod tautological-p ((concept concept) &rest args)
(apply #'inconsistent-p (get-negated-concept concept) args))
;;;
;;;
;;;
(defmethod sat-p ((concept concept) &rest args &key recompute-p &allow-other-keys)
(when recompute-p
(reset-sat-status concept))
(register-concept-query)
(apply #'consistent-p concept args))
(defmethod sat-p (concept &rest args &key tbox &allow-other-keys)
(let ((*cur-store* (if tbox
(concept-store tbox)
(concept-store *cur-tbox*))))
(apply #'sat-p (with-protected-concept-store
(parse-concept concept))
args)))
(defmethod sat-p ((abox abox) &rest args &key &allow-other-keys)
(apply #'abox-sat-p abox args))
;;;
;;; Implies-p ist von descriptions2.lisp geerbt!
;;;
(defmethod implies-p ((concept1 concept) (concept2 concept) &rest args
&key
(use-cached-models-p *use-cached-models-p*)
(cache-models-p *cache-models-p*)
(use-told-subsumers-p *use-told-subsumers-p*)
&allow-other-keys)
(register-subsumption-query)
(cond
;;; die Klauseln sind beim Klassifizieren nicht wirksam,
;;; da compute-node-children / parents schon optimiert sind
((and use-told-subsumers-p (member concept2 (told-subsumers concept1)))
(register-subsumption-ts-hit)
t)
((and use-told-subsumers-p
(member (get-negated-concept concept1) (told-subsumers (get-negated-concept concept2))))
(register-subsumption-ts-hit)
t)
((and use-told-subsumers-p
(member concept2 (told-subsumers (get-negated-concept concept1))))
(register-subsumption-ts-hit)
nil)
((and use-told-subsumers-p
(member concept1 (told-subsumers (get-negated-concept concept2))))
(register-subsumption-ts-hit)
nil)
(t
(let* ((concept2
(with-disabled-concept-store
(with-protected-concept-store
(make-not-concept concept2))))
(and-concept
(with-disabled-concept-store
(with-protected-concept-store
(make-and-concept
(list concept2 concept1))))))
(when use-cached-models-p
(when (already-known-to-be-satisfiable-p and-concept)
(return-from implies-p nil))
(when (already-known-to-be-inconsistent-p and-concept)
(return-from implies-p t))
(when (and (or (not (cached-models concept2))
;(not (instance-retrieval-model concept2))
)
cache-models-p)
(unless (apply #'sat-p concept2
;:store-instance-retrieval-model-p t
:cache-models-p t :recompute-p t args)
(return-from implies-p t)))
(when (and (or (not (cached-models concept1))
;(not (instance-retrieval-model concept1))
)
cache-models-p)
(unless (apply #'sat-p concept1
;:store-instance-retrieval-model-p t
:cache-models-p t :recompute-p t args)
(return-from implies-p t)))
(unless (cached-models concept1)
(error "No cached models for ~A?!" concept1))
;; (unless (instance-retrieval-model concept1)
;; (error "No instance retrieval model for ~A?!" concept1))
(unless (cached-models concept2)
(error "No cached models for ~A?!" concept2))
;; (unless (instance-retrieval-model concept2)
;; (error "No instance retrieval model for ~A?!" concept2)))
#| (when (models-surely-not-mergeable-p +dl+
(instance-retrieval-model concept2)
(instance-retrieval-model concept1))
(return-from implies-p t) |#
)
(register-true-subsumption-query)
(not
(apply #'sat-p and-concept
:subsumption-test-p t
args))))))
(defmethod implies-p ((b concept) (a top-concept) &rest args)
t)
(defmethod implies-p ((b top-concept) (a concept) &rest args)
nil)
(defmethod implies-p ((b concept) (a bottom-concept) &rest args)
nil)
(defmethod implies-p ((b bottom-concept) (a concept) &rest args)
t)
;;;
;;;
;;;
(defmethod subsumes-p ((concept1 concept) (concept2 concept) &rest args)
(apply #'implies-p concept2 concept1 args))
(defmethod subsumes-p (concept1 concept2 &rest args &key tbox &allow-other-keys)
(let ((*cur-store* (if tbox
(concept-store tbox)
(concept-store *cur-tbox*))))
(apply #'subsumes-p
(with-protected-concept-store (parse-concept concept1))
(with-protected-concept-store (parse-concept concept2))
args)))
;;;
;;;
;;;
(defmethod equivalent-p ((concept1 concept) (concept2 concept) &rest args)
(and (apply #'implies-p concept2 concept1 args)
(apply #'implies-p concept1 concept2 args)))
(defmethod equivalent-p (concept1 concept2 &rest args &key tbox &allow-other-keys)
(let ((*cur-store* (if tbox
(concept-store tbox)
(concept-store *cur-tbox*))))
(apply #'equivalent-p
(with-protected-concept-store (parse-concept concept1))
(with-protected-concept-store (parse-concept concept2))
args)))
;;;
;;; Eigene Syntax:
;;;
(defmacro sat? (expr &rest args)
`(sat-p (quote ,expr) ,@args))
(defmacro subsumes? (concept1 concept2 &rest args)
`(subsumes-p ',concept1 ',concept2 ,@args))
(defmacro equivalent? (concept1 concept2 &rest args)
`(equivalent-p ',concept1 ',concept2 ,@args))
| 9,511 | Common Lisp | .lisp | 233 | 29.579399 | 97 | 0.57146 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 13161c443f66acf9441b4399aad5a57b2cd637ab4f1e90bed51e790847426c9d | 12,553 | [
-1
] |
12,554 | abox-interface.lisp | lambdamikel_DLMAPS/src/prover/abox-interface.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
;;;
(defmethod node-instance ((ind abox-node) (concept concept) &rest args)
(declare (ignorable args))
(unless *dont-invalidate-store-p*
(note-abox-has-changed (in-graph ind))
(reset-sat-status ind))
(push concept (slot-value ind 'told-concepts)))
(defmethod node-forget ((ind abox-node) (concept concept) &rest args)
(declare (ignorable args))
(unless *dont-invalidate-store-p*
(note-abox-has-changed (in-graph ind))
(reset-sat-status ind))
(setf (slot-value ind 'told-concepts)
(delete concept (slot-value ind 'told-concepts))))
;;;
;;;
;;;
(defmethod node-instance ((ind abox-node) concept &rest args)
(apply #'node-instance ind
(with-protected-concept-store
(parse-concept (or concept 'top)))
args))
(defmethod node-forget ((ind abox-node) concept &rest args)
(apply #'node-forget ind
(with-protected-concept-store
(parse-concept (or concept 'top)))
args))
;;;
;;;
;;;
(defmethod node-instance ((ind symbol) concept &rest args)
(apply #'node-instance (or (apply #'find-node *cur-abox* ind :error-p nil args)
(apply #'create-abox-node *cur-abox* ind args))
concept
args))
(defmethod node-forget ((ind symbol) concept &rest args)
(apply #'node-forget (apply #'find-node *cur-abox* ind :error-p t args)
concept
args))
;;;
;;;
;;;
(defmethod prepare :around ((abox abox) (language dl))
(unless (prepared-p abox)
(call-next-method)))
(defmethod prepare ((abox abox) (language dl))
(with-slots (prepared-p
satisfiable
ready-for-retrieval
action-timestamp-counter
current-action
choice-point-counter
cur-clash-node
language
) abox
(setf satisfiable :not-tested
language nil
ready-for-retrieval nil
action-timestamp-counter 0
current-action nil
choice-point-counter 0
cur-clash-node nil)
#+:use-membership-tables
(progn
(clrhash (unexpanded-table abox))
(clrhash (expanded-table abox)))
(loop-over-abox-nodes (node abox)
(dolist (slot '(initial-concept
choice-points
really-satisfiable-p
cache-satisfiable-p
stable-p))
(setf (slot-value node slot) nil))
(reset-label (description node))
(reset-sat-status (in-graph node)))
(loop-over-abox-edges (edge abox)
(reset-label (description edge))
(with-protected-concept-store
(parse-concept `(some ,(role edge) top))))
;;; Sprache muss hier schon berechnet werden,
;;; wegen register-as-unexpadned -> adjust-blocking-dependencies -> language!
(setf language (get-language
(tbox abox)))
(register-told-concepts abox +dl+)
(prepare-index-structures abox)
(setf prepared-p t)
abox))
;;;
;;;
;;;
(defmethod prepare-index-structures ((abox abox))
t)
(defmethod prepare-index-structures ((abox abox1))
;;; initial werden nun alle Indexstrukturen vorbereitet,
;;; sie muessen ja spaeter nicht genutzt werden (beim Beweis!)
(let ((*maintain-old-nodes-p* nil)
(*maintain-leaf-nodes-p* nil)
(*maintain-deactivated-nodes-p* nil)
(*maintain-active-nodes-p* nil)
(*maintain-cache-sat-nodes-p* nil)
(*maintain-blocked-nodes-p* nil))
(with-slots (old-nodes
cache-sat-nodes
deactivated-nodes
leaf-nodes
blocked-nodes
active-nodes
nodes-not-and-expanded
nodes-not-atom-expanded
nodes-not-or-expanded
nodes-not-some-expanded
nodes-not-feature-expanded
nodes-not-at-least-expanded
nodes-not-or-expanded1
nodes-not-some-expanded1
nodes-not-feature-expanded1
nodes-not-at-least-expanded1) abox
(setf nodes-not-or-expanded1 (create-heap #'older-p)
nodes-not-some-expanded1 (create-heap #'older-p)
nodes-not-feature-expanded1 (create-heap #'older-p)
nodes-not-at-least-expanded1 (create-heap #'older-p))
(setf nodes-not-and-expanded (create-heap #'left-of-p)
nodes-not-atom-expanded (create-heap #'left-of-p)
nodes-not-or-expanded (create-heap #'left-of-p)
nodes-not-some-expanded (create-heap #'left-of-p)
nodes-not-feature-expanded (create-heap #'left-of-p)
nodes-not-at-least-expanded (create-heap #'left-of-p))
(loop-over-blocked-nodes (node abox)
(deactivate-node abox node))
(setf active-nodes (create-heap #'left-of-p))
(dolist (node (get-active-nodes abox))
(heap-insert active-nodes node))
(setf old-nodes (get-old-nodes abox)
cache-sat-nodes (get-cache-sat-nodes abox)
deactivated-nodes (get-deactivated-nodes abox)
leaf-nodes (get-leaf-nodes abox)
blocked-nodes (get-blocked-nodes abox))
(loop-over-abox-nodes (node abox)
(when (has-unexpanded-or-concepts-p node)
(heap-insert nodes-not-or-expanded node)
(heap-insert nodes-not-or-expanded1 node))
(when (has-unexpanded-attribute-exists-concepts-p node)
(heap-insert nodes-not-feature-expanded node)
(heap-insert nodes-not-feature-expanded1 node))
(when (has-unexpanded-some-concepts-p node)
(heap-insert nodes-not-some-expanded node)
(heap-insert nodes-not-some-expanded1 node))
(when (has-unexpanded-at-least-concepts-p node)
(heap-insert nodes-not-at-least-expanded node)
(heap-insert nodes-not-at-least-expanded1 node))))))
;;;
;;;
;;;
(defmethod register-told-concepts :around ((abox abox1) (language dl))
(let ((*maintain-unexpanded-atomic-concepts-heap-p* nil)
(*maintain-unexpanded-atomic-concepts1-heap-p* nil)
(*maintain-unexpanded-and-concepts-heap-p* nil)
(*maintain-unexpanded-and-concepts-heap1-p* nil)
(*maintain-unexpanded-or-concepts-heap-p* nil)
(*maintain-unexpanded-or-concepts1-heap-p* nil)
(*maintain-unexpanded-some-concepts-heap-p* nil)
(*maintain-unexpanded-some-concepts1-heap-p* nil)
(*maintain-unexpanded-at-least-concepts-heap-p* nil)
(*maintain-unexpanded-at-least-concepts1-heap-p* nil)
(*maintain-unexpanded-attribute-exists-concepts-heap-p* nil)
(*maintain-unexpanded-attribute-exists-concepts1-heap-p* nil))
(call-next-method)))
(defmethod register-told-concepts ((abox abox) (language dl))
(loop-over-abox-nodes (node abox)
(dolist (constraint *meta-constraints*)
(pushnew constraint
(slot-value node 'told-concepts))))
(loop-over-abox-edges (edge abox)
(let* ((role (role edge))
(domain (role-domain role))
(range (role-range role))
(from (from edge))
(to (to edge)))
(when domain
(pushnew domain (slot-value from 'told-concepts)))
(when range
(pushnew range (slot-value to 'told-concepts))))
(register-as-unexpanded edge
:comment 'initialize-present-edge-for-new-abox
;; choice points nur für
;; nicht-disjunktive vergeben;
:error-p nil
:new-choice-point
(unless (underspecified-p edge) 0)))
(let ((*adjust-blocking-dependencies-p* nil))
;;; Blockierungen beibehalten!
(loop-over-abox-nodes (node abox)
(dolist (concept (told-concepts node))
(if (on-tableau-p node (get-negated-concept concept))
(return-from register-told-concepts nil)
(unless (on-tableau-p node concept)
(register-as-unexpanded concept
:node node
:new-choice-point 0)))))))
(defmethod register-told-concepts-as-expanded ((abox abox) (language dl))
(let ((*reflexive-checks-p* nil))
;;; keine History-Objekte
(loop-over-abox-edges (edge abox)
(register-as-unexpanded edge
:comment 'initialize-present-edge-for-new-abox
;; choice points nur für
;; nicht-disjunktive vergeben;
:error-p nil
:new-choice-point
(unless (underspecified-p edge) 0)))
(let ((*adjust-blocking-dependencies-p* nil))
;;; Blockierungen beibehalten!
(loop-over-abox-nodes (node abox)
(dolist (concept (told-concepts node))
(register-as-expanded concept
:node node))))))
;;;
;;;
;;;
(defmethod abox-sat-p :around ((abox abox) &rest args &key recompute-p &allow-other-keys)
(if (or (eq (slot-value abox 'satisfiable) :not-tested)
recompute-p)
(setf (slot-value abox 'satisfiable)
(progn
(prepare abox +dl+)
(call-next-method)))
(slot-value abox 'satisfiable)))
(defmethod abox-sat-p :before ((abox abox) &rest args)
(prepare (tbox abox) +dl+))
(defmethod abox-sat-p ((abox abox) &rest args &key (language (get-language abox)) &allow-other-keys)
(apply #'prover-init
'abox-sat
(make-language language)
abox
args))
(defmethod abox-sat-p (abox &rest args)
(apply #'abox-sat-p
(find-abox abox :error-p t)
args))
;;;
;;; Eigene Macros
;;;
(defmacro abox-sat? (abox &rest args)
`(abox-sat-p (quote ,abox) ,@args))
(defmacro abox-sat*? (abox &rest args)
`(abox-sat-p ,abox ,@args))
;;;
;;;
;;;
(defmacro abox-realized*? (abox &rest args)
`(abox-realized-p ,abox ,@args))
;;;
;;;
;;;
(defmacro ins (name def &rest args)
`(node-instance ',name ',def ,@args))
(defmacro for (name def &rest args)
`(node-forget ',name ',def ,@args))
(defmacro rel (a b role &rest args)
`(relate ',a ',b ',role ,@args :error-p nil))
(defmacro unrel (a b role &rest args)
`(unrelate ',a ',b ',role ,@args))
(defmacro del (name &rest args)
`(delete-node *cur-abox* ',name ,@args))
| 10,678 | Common Lisp | .lisp | 269 | 30.219331 | 106 | 0.598849 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | a529082af5cc155a77f97c2eafc030c9abfc25a6fa00a5180aa0ff9ba958420b | 12,554 | [
-1
] |
12,555 | feature-expansion.lisp | lambdamikel_DLMAPS/src/prover/feature-expansion.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(defrule feature-expansion (dl-with-features abox)
(multiple-value-bind (ae-concept relevant-ae-concepts node)
(select-attribute-exists-concepts abox *strategy* language)
(cond ((not node)
+insert-negative-code+)
(t
(let* ((feature (role ae-concept))
(succs (apply #'append
(mapcar #'(lambda (f)
(get-role-successors node f))
(cons feature
(remove-if-not #'feature-p
(all-superroles feature))))))
;;; s. Beispiel im ALCHF-RPLUS-Prover f. Begruendung!
;;; eigentlich sollte das unnoetig sein -> look-for-somes in
;;; in deterministic-expansion.lisp? look-for-features?
(succ nil))
;;; (format t "SUccs: ~A" succs)
(when (cdr succs)
(error "Found more than one successor of ~A for feature ~A!" node feature))
(if succs
(let ((succ (first succs)))
(dolist (ae-concept relevant-ae-concepts)
(register-as-expanded
ae-concept
:comment 'expand-unexpanded-attribute-exists-concept-due-to-present-successor
:node node
:depends-on (created-by succ)))
(perform (compute-new-feature-successor-label
:succ succ
:node node
:ae-concept ae-concept
:relevant-ae-concepts relevant-ae-concepts)))
(progn
(dolist (ae-concept relevant-ae-concepts)
(register-as-expanded ae-concept
:comment 'expand-unexpanded-attribute-exists-concept-no-preconditions
:node node))
(unless succs
(announce "Expanding ~A : ~A, others: ~A - creating new node"
node ae-concept relevant-ae-concepts))
(setf succ (create-anonymous-node
abox
:depends-on (list (list node ae-concept))))
(let ((and-feature
(create-and-role (mapcar #'role relevant-ae-concepts)
:feature-p t)))
(relate node succ and-feature
:old-p nil
:depends-on (list (list node ae-concept)))
(perform (compute-new-feature-successor-label
:succ succ
:node node
:ae-concept ae-concept
:relevant-ae-concepts relevant-ae-concepts)))))
+insert-positive-code+)))))
;;;
;;;
;;;
(defrule compute-new-feature-successor-label (dl abox
:args (succ node ae-concept relevant-ae-concepts))
(dolist (ae-concept2 relevant-ae-concepts)
(let ((qualification (qualification ae-concept2))
(deps (list ;(list node ae-concept)
(list node ae-concept2))))
(unless (on-tableau-p succ qualification)
(let ((added (register-as-unexpanded qualification
:node succ
:depends-on deps)))
(check-for-clash succ added)))
(let ((role-range (role-range (role ae-concept2))))
(when role-range
(unless (on-tableau-p succ role-range)
(let ((added
(register-as-unexpanded role-range
:node succ
:depends-on deps)))
(check-for-clash succ added)))))))
(add-meta-constraints succ))
(defrule compute-new-feature-successor-label (dl-with-combined-some-all-rule abox
:args (succ node ae-concept relevant-ae-concepts))
(dolist (ae-concept2 relevant-ae-concepts)
(let ((qualification (qualification ae-concept2))
(deps (list ;(list node ae-concept)
(list node ae-concept2))))
(loop-over-node-all-concepts (all-concept node)
(when (implies-p (role ae-concept2) (role all-concept))
(let ((qualification (qualification all-concept))
(deps (cons (list node all-concept)
deps)))
(unless (on-tableau-p succ qualification)
(let ((added
(register-as-unexpanded qualification
:node succ
:depends-on deps)))
(check-for-clash succ added)))
(when (transitive-p all-concept)
(unless (on-tableau-p succ all-concept)
(let ((added
(register-as-unexpanded all-concept
:node succ
:comment 'found-applicable-transitive-all
:depends-on deps)))
(check-for-clash succ added)))))))
(unless (on-tableau-p succ qualification)
(let ((added
(register-as-unexpanded qualification
:node succ
:depends-on deps)))
(check-for-clash succ added)))
(let ((role-range (role-range (role ae-concept2))))
(when role-range
(unless (on-tableau-p succ role-range)
(let ((added
(register-as-unexpanded role-range
:node succ
:depends-on deps)))
(check-for-clash succ added)))))))
(add-meta-constraints succ)
(register-label-is-stable abox succ))
| 6,686 | Common Lisp | .lisp | 125 | 29.952 | 127 | 0.459212 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 9923d3c3bd1530710af838e0612b16da7137fcc4dbb9c4ba96d9c31e4ef0826c | 12,555 | [
-1
] |
12,556 | edge-management.lisp | lambdamikel_DLMAPS/src/prover/edge-management.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(timed-defmethod mark-deleted :after ((abox abox) (edge abox-edge))
t)
(timed-defmethod mark-deleted :after ((abox abox1) (edge abox-edge))
(with-slots (all-edges) abox
(if (not *use-avl-trees-for-abox1-p*)
(setf all-edges (delete edge all-edges))
(delete-from-avl-tree edge all-edges :key #'id))))
;;;
;;;
;;;
(timed-defmethod delete-edge ((abox abox) (edge abox-edge) &rest args)
(declare (ignorable args))
(call-next-method))
(timed-defmethod delete-edge ((abox abox1) (edge abox-edge) &rest args)
(declare (ignorable args))
(if (old-p edge)
(call-next-method)
(let ((from (from edge))
(to (to edge)))
;;; wird sonst von substrate7.lisp erledigt!
(setf (slot-value from 'successors) (delete to (slot-value from 'successors)))
(setf (slot-value to 'predecessors) (delete from (slot-value to 'predecessors)))
(setf (slot-value from 'outgoing) (delete edge (slot-value from 'outgoing)))
(setf (slot-value to 'incoming) (delete edge (slot-value to 'incoming))))))
(timed-defmethod delete-edge :after ((abox abox) (edge abox-edge) &rest args)
(declare (ignorable args))
(mark-deleted abox edge))
;;;
;;;
;;;
(defmethod get-state-vector ((edge abox-edge))
(with-slots (old-p
active-p
deleted-p
multiplicity
inverse-multiplicity) edge
(list ;old-p
active-p
deleted-p
multiplicity
inverse-multiplicity)))
(defmethod set-state-vector ((edge abox-edge) state &optional maintain-index-structures-p)
(declare (ignorable maintain-index-structures-p))
(with-slots (old-p
active-p
deleted-p
multiplicity
inverse-multiplicity) edge
(setf ;old-p (pop state)
active-p (pop state)
deleted-p (pop state)
multiplicity (pop state)
inverse-multiplicity (pop state))))
| 2,038 | Common Lisp | .lisp | 58 | 29.086207 | 90 | 0.639159 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 7da34e8f73c619a1edb89a24063b09de1ebf660402302a594957fb7c6db1ab9b | 12,556 | [
-1
] |
12,557 | strategy.lisp | lambdamikel_DLMAPS/src/prover/strategy.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(eval-when (:compile-toplevel :load-toplevel :execute)
(defmacro with-strategy ((strat) &body body)
`(let ((*strategy* ,strat))
(establish-context-for *strategy*
#'(lambda ()
,@body))))
(defpersistentclass strategy ())
(defpersistentclass trace-strategy (strategy))
(defpersistentclass abox-saturation-strategy (strategy))
;;;
;;;
;;;
(defmethod establish-context-for ((strategy strategy) fn)
(funcall fn))
(defmethod establish-context-for ((strategy abox-saturation-strategy) fn)
(let ((*maintain-unexpanded-or-concepts1-heap-p* t)
(*combined-some-all-rule-p* nil)
(*maintain-active-nodes-p* t)
)
(funcall fn)))
(defmethod establish-context-for ((strategy trace-strategy) fn)
(let ((*maintain-active-nodes-p* t))
(funcall fn)))
;;;
;;;
;;;
(defconstant +strategy+ (make-instance 'strategy))
(defconstant +trace-strategy+ (make-instance 'trace-strategy))
(defconstant +abox-saturation-strategy+ (make-instance 'abox-saturation-strategy))
)
| 1,216 | Common Lisp | .lisp | 35 | 28.542857 | 84 | 0.635112 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | c0a8567b9383084bba67561ec53e016761f7592fbd771f81d31bde0043a27b4f | 12,557 | [
-1
] |
12,558 | precompletion.lisp | lambdamikel_DLMAPS/src/prover/precompletion.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
#|
(defrule compute-precompletion (dl alch)
(labels ((do-it ()
(perform (deterministic-expansion)
(:body
(if clashes
(return-from compute-precompletion nil)
(perform (some-expansion)
(:positive
(if clashes
(return-from compute-precompletion nil)
(:negative
+insert-body-code+)))))))))
(let ((*combined-some-all-rule-p* nil))
(do-it)
t)))
(defrule compute-precompletion (dl alch)
(labels ((do-it ()
(perform (deterministic-expansion)
(:body
(if clashes
(handle-clashes)
(perform (some-expansion)
(:positive
(if clashes
(handle-clashes)
(:negative
+insert-body-code+)))))))))
(let ((*combined-some-all-rule-p* nil))
(do-it))))
|#
| 1,177 | Common Lisp | .lisp | 36 | 19.055556 | 64 | 0.437833 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 24a75dd7fea227544bb335e163b8ab8d7340ce20ce316bebd8951e2c0f70a31f | 12,558 | [
-1
] |
12,559 | or-expansion.lisp | lambdamikel_DLMAPS/src/prover/or-expansion.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(defrule or-expansion (dl abox)
(multiple-value-bind (disjuncts or-concept node)
(cond ((not *semantic-branching-p*)
;; branch syntactically
(multiple-value-bind (or-concept node)
(select-or-concept abox *strategy* language)
(when node
(values
(remove-if #'(lambda (x)
(or (on-tableau-p node x)
(on-tableau-p node (get-negated-concept x))))
(arguments or-concept))
or-concept
node))))
(t ;; semantic branching!
(multiple-value-bind (disjunct or-concept node)
(select-open-disjunct abox *strategy* language)
(when node
(values
(list disjunct (get-negated-concept disjunct))
;;; statische Auswahl!
;;; zunächst wird das Disjunct wahr gemacht -> "or-concept" wird wahr (-> expanded)
;;; dann wird das Disjunct falsch gemacht -> "or-concept" muss geht *nicht* auf expanded!!!
;;; beim Backtracking (vom 1. Disjunkt) muss also sichergestellt werden, dass "or-concept"
;;; wieder auf unexpanded gelegt wird! das macht die Dependenz-Verwaltung (remove-all-...)
;;; Sonst werden nämlich Alternativen übersehen...
or-concept
node)))))
(if (not (and node disjuncts))
;;; Nachfolgender Code für SOME-Expansion
+insert-negative-code+
(let ((sat nil)
(new-choice-point
(get-new-choice-point))
(collected-dependencies nil)
(memorized-action (get-current-action))
;(put-disjunct-to-unexpanded-action nil)
(disjuncts (copy-list disjuncts)))
(loop while disjuncts do
(let* ((disjunct (first disjuncts))
(last-p (not (cdr disjuncts))))
(announce "CHOICE POINT ~A. OR CONCEPT ~A : ~A, DISJUNCT ~A, ALL DISJUNCTS: ~A"
new-choice-point node or-concept
disjunct disjuncts)
(if *semantic-branching-p*
(announce "Semantic selection of ~A : ~A" node disjunct)
(announce "Syntactic selection of ~A : ~A" node disjunct))
(setf disjuncts (cdr disjuncts))
(let ((added
(register-as-unexpanded disjunct
:comment (if *semantic-branching-p*
'add-semantically-chosen-or-disjunct-to-unexpanded
'add-syntactically-chosen-or-disjunct-to-unexpanded)
:node node
:new-choice-point new-choice-point
:depends-on (list (list node or-concept)))))
;(setf put-disjunct-to-unexpanded-action (get-current-action))
(check-for-clash node added))
(multiple-value-bind (sub-sat deps)
+insert-positive-code+
;;;
;;; vollständiges chronologisches backtracking
;;; bei *compute-all-completions-p* erforderlich!
;;;
(when *compute-all-completions-p*
(let ((*use-unsat-cache-p* nil))
(rollback-to abox memorized-action)))
(setf sat (or sat sub-sat))
;;;
;;; dependencies machen keinen sinn
;;; bei *compute-all-completions-p*
;;;
(when (and (not sat)
(not *compute-all-completions-p*))
(dolist (dep deps)
(push dep collected-dependencies)))
;;; letztes Disjunkt? -> in jedem Fall zurückkehren!
(when last-p
(return-from prover
(if sat
t
(if *compute-all-completions-p*
nil
(values nil (remove new-choice-point collected-dependencies))))))
;;; nicht-letztes Disjunkt
(when (not last-p)
(when (and sat (not *compute-all-completions-p*))
(return-from prover t))
(when (not sat)
(when (not (member new-choice-point deps))
;;;
;;; Clash Reason liegt nicht am Disjunkt! -> Backtracking
;;; Achtung: hier ist *kein* Rollback notwendig!
;;; das Rollback wird immer von dem Veranlasst, der den
;;; den Choice Point aufgesetzt hat!
;;; Logischerweise werden dann auch die hier noch auf dem
;;; Tableaux vorhandenen Constraints zurückgenommen, da
;;; diese von dem "weiter unten liegenden Constraint "abhängen
;;;
(return-from prover
(values nil (remove new-choice-point collected-dependencies))))
(when (member new-choice-point deps)
;;;
;;; Clash Reason liegt am Disjunkt!
;;; Aufräumen und Weitermachen,
;;; nächstes Disjunkt aus der Schleife probieren
;;;
(when *debug-p*
(announce "BEFORE ROLLBACK:")
(describe-object abox t)
(loop-over-abox-nodes (node abox)
(describe-object node t)))
#+:use-dependency-directed-backtracking
(progn
(break "DEPENDENCY DIRECTED BACKTRACKING NOT FULLY UNDERSTOOD YET!")
;;(rollback-all-depending-on abox (list node disjunct))
;;(undo-action abox put-disjunct-to-unexpanded-action))
;;;
;;; das ist noch nicht die ganze Geschichte...
;;; vorerst auf Eis gelegt!
)
#-:use-dependency-directed-backtracking
(progn
;;;
;;; einfaches BACKJUMPING
;;; chronologisches Abräumen
;;;
(rollback-to abox memorized-action node))
(when *debug-p*
(announce "AFTER ROLLBACK:")
(describe-object abox t)
(loop-over-abox-nodes (node abox)
(describe-object node t))))
)))))
(error "Why am I here? ~A" disjuncts)))))
| 8,170 | Common Lisp | .lisp | 140 | 30.864286 | 112 | 0.445905 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 9150d6a92c72b23c301dbc9c59db2e98bff6221c2a25cc2f31348cc4f73b3763 | 12,559 | [
-1
] |
12,560 | abox-edges.lisp | lambdamikel_DLMAPS/src/prover/abox-edges.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(defpersistentclass abox-edge (substrate-edge abox-item)
((multiplicity :reader multiplicity :initarg :multiplicity :initform 1)
(inverse-multiplicity :reader inverse-multiplicity :initarg :inverse-multiplicity :initform 1)))
(defmethod copy-edge ((abox abox) (edge abox-edge) &rest args)
(declare (ignorable args))
(let ((copy (call-next-method))
(state (get-state-vector edge)))
(set-state-vector copy state)
(dolist (slot '(old-p
active-p
deleted-p
choice-points
;;; mit denen kann man zwar nicht weiterrechnen (da Referenzen auf
;;; alte Objekte enthalten!), aber gut fuer Inspektionszwecke!
precondition-for-actions
postcondition-for-actions
created-by))
(setf (slot-value copy slot) (copy-tree (slot-value edge slot))))
copy))
;;;
;;;
;;;
(defmethod inverse-edge ((edge abox-edge))
nil)
(defmethod role ((edge abox-edge))
(textual-description (description edge)))
;;;
;;; Unter der Annahme, dass in einer einfach ABox niemals
;;; inverse Kanten explizit verzeichnet werden!
;;; Dafür ist die "rolebox-abox" zuständig
;;;
(defmethod implies-p ((edge abox-edge) (role role) &rest args)
(implies-p (description edge) role))
;;;
;;;
;;;
(defmacro loop-over-role-successors ((node role) (succ edge-var) &body body)
(let ((var (gensym)))
(if (not role)
`(let ((,var nil))
;;; Keine Rolle ->
;;; enummeriert dann einfach die *ausgehenden* Kanten!
;;; incomming werden nicht betrachtet!
;;; unproblemeatisch; wird sowieso nur fuer den Aufbau
;;; von Modellen im Model Caching verwendet, und das
;;; funktioniert sowieso nicht fuer inverse Rollen
(loop-over-cluster-nodes (equi ,node)
(unless (deleted-p equi)
(dolist (,edge-var (outgoing equi))
(when (and (not (deleted-p ,edge-var))
;;; diese Funktionen werden (role = NIL!)
;; NUR zu "low level" Inspektion des Tableaus
;; verwendet! daher: Kanten muessen selbst
;; interpretiert werden !
;;;(not (zerop (multiplicity ,edge-var))))
(let ((,succ (representative
(to ,edge-var))))
(when (and (not (deleted-p ,succ)))
(push ,succ ,var)
,@body))))))))
`(block loop
(with-new-marking-context
(let ((role ,role)
(node ,node)
(,var nil))
(declare (ignorable node role ,var))
(unwind-protect
(typecase role
(simple-role
(loop-over-cluster-nodes (equi ,node)
(unless (deleted-p equi)
(dolist (,edge-var (outgoing equi))
(when (and (not (deleted-p ,edge-var))
(not (zerop (multiplicity ,edge-var))))
(when (implies-p ,edge-var
role)
(let ((,succ (representative
(to ,edge-var))))
(when (and (and (not (marked-p ,succ))
(not (deleted-p ,succ))))
(mark ,succ)
(push ,succ ,var)
,@body)))))))
(let ((inv-role (get-inverse-role role)))
(loop-over-cluster-nodes (equi ,node)
(unless (deleted-p equi)
(dolist (,edge-var (incoming equi))
(when (and (not (deleted-p ,edge-var))
(not (zerop (inverse-multiplicity ,edge-var))))
(when (implies-p ,edge-var
inv-role)
(let ((,succ (representative
(from ,edge-var))))
(when (and (and (not (marked-p ,succ))
(not (deleted-p ,succ))))
(mark ,succ)
(push ,succ ,var)
,@body))))))))
(loop-over-cluster-nodes (equi ,node)
(dolist (,succ (compute-virtual-successors (in-graph ,node)
equi role))
(when (and (and (not (marked-p ,succ))
(not (deleted-p ,succ))))
(mark ,succ)
(push ,succ ,var)
(let ((,edge-var
(materialize-virtual-edge (in-graph ,node)
,node ,succ ,role)))
(declare (ignorable ,edge-var))
,@body)))))
((or and-role or-role)
(break "support for complex roles: to be implemented!")))
(unmark ,var))))))))
(defmacro loop-over-role-predecessors ((node role) (pre edge-var) &body body)
(if (not role)
(let ((var (gensym)))
`(let ((,var nil))
;;; Keine Rolle ->
;;; enummeriert dann einfach die *eingehenden* Kanten!
;;; s. auch "loop-over-role-successors", role = NIL-Kommentar!
(loop-over-cluster-nodes (equi ,node)
(unless (deleted-p equi)
(dolist (,edge-var (incoming equi))
(when (and (not (deleted-p ,edge-var))
;; s. Kommentar loop-over-role-successors
;; (not (zerop (inverse-multiplicity ,edge-var)))
)
(let ((,pre (representative
(from ,edge-var))))
(unless (deleted-p ,pre)
(push ,pre ,var)
,@body))))))))
`(loop-over-role-successors (,node (get-inverse-role ,role)) (,pre ,edge-var)
,@body)))
;;;
;;;
;;;
;;;
(defmacro get-role-successors (node role)
`(let ((res nil))
(loop-over-role-successors (,node ,role) (succ edge-var)
(push succ res))
res))
(defmacro get-role-predecessors (node role)
`(let ((res nil))
(loop-over-role-predecessors (,node ,role) (pre edge-var)
(push pre res))
res))
| 8,709 | Common Lisp | .lisp | 153 | 28.254902 | 108 | 0.369136 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 5596cf6fd01ab0d7300dc791aef21e5c504e063022384e262892820c5b7a47a7 | 12,560 | [
-1
] |
12,561 | some-expansion2.lisp | lambdamikel_DLMAPS/src/prover/some-expansion2.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(defrule some-expansion (dl-with-somes abox)
(multiple-value-bind (some-concept node)
(select-some-concept abox *strategy* language)
(cond ((not node)
+insert-negative-code+ )
(t
(let* ((role (role some-concept))
(new-node nil))
(register-as-expanded some-concept
:comment 'expand-unexpanded-some-concept-no-preconditions
:node node)
(when *reuse-nodes-p*
(let* ((succs (get-role-successors node role)))
(announce "Performing Non-deterministic SOME expansion of ~A : ~A" node some-concept)
(announce "Found candidate successors: ~A" succs)
(let ((new-choice-point (get-new-choice-point))
(collected-dependencies nil)
(count 0)
(n (length succs))
(sat nil)
(memorized-action (get-current-action)))
(dolist (succ succs)
(incf count)
(announce "Performing Non-deterministic SOME expansion of ~A : ~A" node some-concept)
(announce "Trying ~Ath (of ~A) successor ~A. " count n succ)
(perform (compute-new-some-successor-label :new-node succ
:new-choice-point new-choice-point
:node node
:role role
:concept some-concept))
(multiple-value-bind (sub-sat deps)
+insert-positive-code+
;;;
;;; vollständiges chronologisches backtracking
;;; bei *compute-all-completions-p* erforderlich!
;;;
(when *compute-all-completions-p*
(let ((*use-unsat-cache-p* nil))
(rollback-to abox memorized-action)))
(setf sat (or sat sub-sat))
;;;
;;; dependencies machen keinen sinn
;;; bei *compute-all-completions-p*
;;;
(when (and (not sat)
(not *compute-all-completions-p*))
(setf collected-dependencies
(append deps collected-dependencies)))
(when (and sat (not *compute-all-completions-p*))
(return-from prover t))
(when (not sat)
(when (not (member new-choice-point deps))
;;;
;;; Clash hat anderen Grund als qual!
;;; Aufraeumen nicht notwendig, da der Clash-Beseitiger
;;; das durchfuehrt!
;;;
(return-from prover
(values nil (remove new-choice-point collected-dependencies))))
(when (member new-choice-point deps)
#+:use-dependency-directed-backtracking
(progn
(break "DEPENDENCY DIRECTED BACKTRACKING NOT FULLY UNDERSTOOD YET!"))
#-:use-dependency-directed-backtracking
(progn
;;;
;;; einfaches BACKJUMPING
;;; chronologisches Abräumen
;;;
(rollback-to abox memorized-action node)))))))))
;;;
;;; deterministischer Teil der Expansion
;;;
(announce "~%Performing deterministic SOME expansion of ~A : ~A" node some-concept)
(setf new-node
(create-anonymous-node
abox
:depends-on (list (list node some-concept))))
(relate node new-node role
:old-p nil
:depends-on (list (list node some-concept)))
(perform (compute-new-some-successor-label :new-node new-node
:node node
:role role
:concept some-concept))
+insert-positive-code+ )))))
;;;
;;;
;;;
(defrule compute-new-some-successor-label (dl abox :args (new-choice-point new-node node role concept))
(let ((Added
(register-as-unexpanded (qualification concept)
:new-choice-point new-choice-point
:node new-node
:depends-on (list (list node concept)))))
(check-for-clash new-node added))
(when (role-range role)
(unless (on-tableau-p new-node (role-range role))
(let ((added
(register-as-unexpanded (role-range role)
:new-choice-point new-choice-point
:node new-node
:depends-on (list (list node concept)))))
(check-for-clash new-node added))))
(add-meta-constraints new-node))
(defrule compute-new-some-successor-label (dl-with-combined-some-all-rule abox :args (new-choice-point new-node node role concept))
(let ((added
(register-as-unexpanded (qualification concept)
:new-choice-point new-choice-point
:node new-node
:depends-on (list (list node concept)))))
(check-for-clash new-node added))
(when (role-range role)
(unless (on-tableau-p new-node (role-range role))
(let ((added
(register-as-unexpanded (role-range role)
:new-choice-point new-choice-point
:node new-node
:depends-on (list (list node concept)))))
(check-for-clash new-node added))))
(loop-over-node-all-concepts (all node)
(when (implies-p role (role all))
(unless (on-tableau-p new-node (qualification all))
(let ((added
(register-as-unexpanded (qualification all)
:new-choice-point new-choice-point
:node new-node
:depends-on (list (list node concept)
(list node all)))))
(check-for-clash new-node added)))))
(add-meta-constraints new-node)
(unless (has-unexpanded-at-most-concepts-p node)
(register-label-is-stable abox new-node)))
(defrule compute-new-some-successor-label (alchf-rplus abox :args (new-choice-point new-node node role concept))
(let ((added
(register-as-unexpanded (qualification concept)
:new-choice-point new-choice-point
:node new-node
:depends-on (list (list node concept)))))
(check-for-clash new-node added)
(when (role-range role)
(unless (on-tableau-p new-node (role-range role))
(let ((added
(register-as-unexpanded (role-range role)
:new-choice-point new-choice-point
:node new-node
:depends-on (list (list node concept)))))
(check-for-clash new-node added))))
(loop-over-node-all-concepts (all node)
(when (implies-p role (role all))
(unless (on-tableau-p new-node (qualification all))
(let ((added
(register-as-unexpanded (qualification all)
:new-choice-point new-choice-point
:node new-node
:depends-on (list (list node concept)
(list node all)))))
(check-for-clash new-node added)))
(when (transitive-p all)
(unless (on-tableau-p new-node all)
(announce "Propagating transitive ALL ~A to ~A" all new-node)
(let ((added
(register-as-unexpanded all
:new-choice-point new-choice-point
:node new-node
:comment 'found-applicable-transitive-all
:depends-on (list (list node concept)
(list node all)))))
(check-for-clash new-node added)))))))
(add-meta-constraints new-node)
(unless (has-unexpanded-at-most-concepts-p node)
(register-label-is-stable abox new-node)))
| 10,180 | Common Lisp | .lisp | 177 | 31.135593 | 131 | 0.449903 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 6d677c0db1955457bafcfd12c5542fab0b6eafdf38504f71340c69792d303eec | 12,561 | [
-1
] |
12,562 | examples.lisp | lambdamikel_DLMAPS/src/prover/examples.lisp | ;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
(reset-store *cur-store*)
;;;
;;; Dependency Directed Backtracking Example
;;;
(with-knowledge-base (test test :delete-if-exists-p t)
(def* c a)
(ins a c)
(ins a (not a))
(princ (abox-sat-p *cur-abox*)))
(progn
(in-kb test test :delete-if-exists-p t)
(def* c a)
(ins a c)
(ins a (not a))
(princ (abox-sat-p *cur-abox*)))
(with-abox (test :delete-if-exists-p t)
(ins a (and (or c1 d1)
(or c2 d2)
(or c3 d3)
(or c4 d4)
(or c5 d5)
(or c6 d6)
(or c7 d7)
(or c8 d8)
(or c9 d9)
(some r (and c d))
(all r (or (and d (not c)) (and c (not d))))))
(setf *x* (list *cur-abox* *cur-substrate*))
(princ (abox-sat-p *cur-abox* :semantic-branching-p t :debug-p t)))
(with-abox (test :delete-if-exists-p t)
(ins a (and (all r bottom)
(or (some r c)
(some s d))
(all s (and e (not d)))))
(princ (abox-sat-p *cur-abox* :semantic-branching-p nil :debug-p t :compute-all-completions-p t))
(visualize *completions*))
(with-abox (test :delete-if-exists-p t)
(ins a (and (some r (and c d))
(all r (or (and d (not c))
(and c (not d))))))
(setf *x* (list *cur-abox* *cur-substrate*))
(princ (abox-sat-p *cur-abox* :semantic-branching-p t :debug-p t)))
(with-abox (test :delete-if-exists-p t)
(ins a (and (some r (and c d))
(all r (or (and d (not c))
(and c (not d))))))
(setf *x* (list *cur-abox* *cur-substrate*))
(princ (abox-sat-p *cur-abox* :semantic-branching-p t :debug-p t)))
;;;
;;; LTL (Linear Temporal Logic) Example
;;;
(with-rbox (rcc5-rolebox)
(with-tbox (meta :delete-if-exists-p t)
(def* linear-time
(and (all dr bottom)
(all ec bottom)
(all po bottom)
(all ppi linear-time)
(all pp linear-time)))
(def* dense
(=> (some ppi top)
(some ppi (some ppi top))))
(def* right-bounded
(some ppi (and last-node
(all ppi bottom))))
(def* left-bounded
(some pp (and first-node
(all pp bottom))))
(def* left-unbounded
(all pp (some pp top)))
(def* right-unbounded
(all ppi (some ppi top)))
(with-abox (test :delete-if-exists-p t)
(ins a (and (some ppi (some ppi (some ppi (some ppi dead))))
linear-time
left-bounded
right-bounded))
(princ (abox-sat-p *cur-abox*
:reuse-nodes-p t
:compute-all-completions-p nil :debug-p t :break-p nil))
(visualize *cur-abox*))))
;;;
;;; Basic ALCI ABox Consistency Checking
;;; Auf Substrat-Ebene!
;;;
(with-substrate (test :type 'abox :delete-if-exists-p t)
(node a (ncon (and a (some r c))))
(abox-sat-p *cur-substrate* :compute-all-completions-p t)
(visualize *completions*))
;;;
;;; "PO"-Free ALCI_RCC5 hat die Tree Model Property!
;;; "Church Rosser"-Rauten ("Joins") müssen dann linear angeordnet werden,
;;; weil nur noch (b,c) : PP oder (b,c) : PPI oder (b,c) : EQ möglich bleibt
;;;
(with-rbox (rcc5-rolebox)
(in-tbox meta :delete-if-exists-p t)
(setf *completions* nil)
(impl top (all po bottom))
(with-abox (test :delete-if-exists-p t)
(ins a a)
(ins b c)
(ins c c)
(rel a b pp)
(rel a c pp)
(princ (abox-sat-p *cur-abox*
:compute-all-completions-p t
:debug-p t
:use-cached-models-p nil
:cache-models-p nil
:break-p nil))
(visualize *completions*))))
;;;
;;; Ladner-Baum-Konstruktion für ALCI_RCC5
;;;
(with-rbox (rcc5-rolebox) ; tree models! LADNER-REDUCTION !!! PSPACE!!!
(kill)
(with-tbox (meta :delete-if-exists-p t)
(setf *completions* nil)
(impl top (all po bottom))
(impl q0 (and (not q1) (not q2) (not q3)
(all ppi (not q0*))))
(impl q1 (and (not q0) (not q2) (not q3)
(all ppi (not q1*))))
(impl q2 (and (not q0) (not q1) (not q3)
(all ppi (not q2*))))
;(impl q3 (and (not q0) (not q1) (not q2)
; (all ppi (not q3))))
(impl p1 (all eq p1))
(impl p2 (all eq p2))
(impl p3 (all eq p3))
;;;; (impl qo (all eq q0))
;;;; (impl q1 (all eq q1))
;;;; (impl q2 (all eq q2))
;;;; (impl (not p1) (all eq (not p1)) )
;;;; (impl (not p2) (all eq (not p2)) )
;;;; (impl (not p3) (all eq (not p3)) )
;;;; (impl (not qo) (all eq (not q0)) )
;;;; (impl (not q1) (all eq (not q1)) )
;;;; (impl (not q2) (all eq (not q2)) )
(def sp1 (and (=> p1 (all ppi p1))
(=> (not p1) (all ppi (not p1)))))
(def sp2 (and (=> p2 (all ppi p2))
(=> (not p2) (all ppi (not p2)))))
(def sp3 (and (=> p3 (all ppi p3))
(=> (not p3) (all ppi (not p3)))))
(def b0 (=> q0 (and (some ppi (and q1 p1))
(some ppi (and q1 (not p1))))))
(def b1 (=> q1 (and (some ppi (and q2 p2))
(some ppi (and q2 (not p2))))))
(def b2 (=> q2 (and (some ppi (and q3 p3))
(some ppi (and q3 (not p3))))))
(with-abox (test :delete-if-exists-p t)
(ins a (and q0
b0
(all ppi b1)
;(all ppi (all ppi b2))
(all ppi sp1) (all ppi (all ppi sp1))
;(all ppi (all ppi sp2))
))
(setf *abox* *cur-abox*)
(princ (abox-sat-p *abox* :compute-all-completions-p nil :break-p t :debug-p nil)))))
(with-rbox (rcc8-rolebox) ; tree models! LADNER-REDUCTION !!! PSPACE!!!
(kill)
(with-tbox (meta :delete-if-exists-p t)
(setf *completions* nil)
(impl odd (all tppi even))
(impl even (all tppi odd))
(impl odd (not even))
(impl even (not odd))
(impl top (and (all po bottom)
(all ec bottom)))
(impl q0 (and (not q1) (not q2) (not q3)
(all tppi (not q0))))
(impl q1 (and (not q0) (not q2) (not q3)
(all tppi (not q1))))
(impl q2 (and (not q0) (not q1) (not q3)
(all tppi (not q2))))
(impl q3 (and (not q0) (not q1) (not q2)
(all tppi (not q3))))
(impl p1 (all eq p1)) ; "make weak EQ semantics strong" (works only for trees!)
(impl p2 (all eq p2))
(impl p3 (all eq p3))
(def* sp1 (and (=> p1 (all tppi p1))
(=> (not p1) (all tppi (not p1)))))
(def* sp2 (and (=> p2 (all tppi p2))
(=> (not p2) (all tppi (not p2)))))
(def* sp3 (and (=> p3 (all tppi p3))
(=> (not p3) (all tppi (not p3)))))
(def* b0 (=> q0 (and (some tppi (and q1 p1))
(some tppi (and q1 (not p1))))))
(def* b1 (=> q1 (and (some tppi (and q2 p2))
(some tppi (and q2 (not p2))))))
(def* b2 (=> q2 (and (some tppi (and q3 p3))
(some tppi (and q3 (not p3))))))
(with-abox (test :delete-if-exists-p t)
(ins a (and q0
even
b0
(all tppi b1)
;(all tppi (all tppi b2))
(all tppi sp1) (all tppi (all tppi sp1))
;(all tppi (all tppi sp2))
))
(setf *abox* *cur-abox*)
(run #'(lambda ()
(princ (abox-sat-p *abox* :compute-all-completions-p nil :debug-p nil))
(visualize
;(mapcar #'reorder-ppi
;(remove-if #'has-eq-edges-p
*completions*))))))
;;;
;;; ALCI_RCC5 "Geo Example" (Stadt / Land / Fluss)
;;;
(with-rbox (rcc5-rolebox)
(with-tbox (geo-example :delete-if-exists-p t)
(def* area)
;;; Die Konzepte "City", "River", "Lake" und "Mountain" sind spezielle "Flaechen"
(def* country area)
(def* city area)
(def* river area)
(def* lake area)
(def* mountain area)
;;; "Deutschland" und die "Tschechische Republik" sind "Laender "
(def* germany country)
(def* czech-republic country)
;;; Ein "lokaler Fluss" ueberlappt sich nicht mit "Laendern"
(def local-river
(and river
(not (some po country))))
;;; Ein "nicht-lokaler Fluss" ueberlappt sich mit "Laendern"
(def non-local-river
(and river
(some po country)))
;;; Ein "Fluss der in einen See fliesst" in ein Fluss der einen See ueberlappt
(def river-flowing-into-a-lake
(and river
(some po lake)))
;;; Ein deutscher Fluss ist ein Fluss der in Deutschland enthalten ist
;;; und keine anderen Fluesse ueberlappt
(def german-river
(and river
(some pp germany)
(all po (not country))))
;;; Eine deutsche Stadt ist eine Stadt die in Deutschland enthalten ist
(def german-city
(and city
(all pp
(=> country germany))))
;;; Ein Stadt an einem Fluss ist eine Stadt die einen Fluss ueberlappt
(def city-at-river
(and city
(some po river)))
;;; Die Elbe ist ein Fluss der die Tschechische Republik und Deutschland kreuzt
(def* elbe
(and river
(some po czech-republic)
(some po germany)))
;;; Die "Binnen-Alster" ist ein Teich
(def* alster-lake
lake)
;;; Die Alster ist ein Fluss der in Deutschland enthalten ist
;;; und die Binnen-Alster ueberlappt
(def* alster
(and river
(some pp germany)
(some po alster-lake)
(all po (not country))
(all pp (=> country germany))))
;;; Hamburg ist eine Stadt die an der Alster liegt
(def* hamburg
(and city
(some po alster)))
;(princ (subsumes? german-city hamburg :type 'jepd-abox :debug-p t))
(setf *dag* (taxonomy *cur-tbox*
:debug-p nil
:recompute-p t
:resuse-nodes-p nil
:semantic-branching-p nil
:non-determinism-p t))
(princ *dag*)
(when (member 'hamburg
(mapcar #'dag-node-name
(dag-node-children (find 'german-river
(dag-nodes *dag*)
:key #'dag-node-name))))
(break))
(loop
(princ "*")
(unless (dag-isomorphic-p *dag*
(setf *ldag*
(taxonomy *cur-tbox*
;:reuse-nodes-p (one-of '(t nil))
:semantic-branching-p (one-of '(t nil))
:non-determinism-p (one-of '(t nil))
:use-cached-models-p nil
:cache-models-p nil
:recompute-p t)))
(princ *ldag*)
(break)))))
;;;
;;; Einfacher ALCI_RAMINUS-Test
;;; Interessant!!!
;;; Muss unerfuellbar sein!
;;;
(with-rbox (test :roles (id r s) :inverse-roles ((r r)) :delete-if-exists-p t :reflexive-roles (id)
:axioms ((r r r)
(id r s)))
(with-tbox (test :delete-if-exists-p t)
(with-abox (test :delete-if-exists-p t )
(ins a (and
a
(all s (not a))
(some r c)))
(princ (abox-sat-p *cur-abox* :debug-p t)))))
;;;
;;; einige einfache ALCI_RCC5 Tests
;;;
(with-rbox (rcc5-rolebox)
(with-abox (test :delete-if-exists-p t :language +alci-rcc+)
(ins a (and (some pp (some pp c)) (all pp e)))
(princ (abox-sat-p *cur-abox*))
(visualize *cur-abox*)))
(with-rbox (rcc5-rolebox)
(with-abox (test :delete-if-exists-p t :language +alci-rcc+)
(ins a (and a (all pp (not c)) (all eq (not c)) (all po (not c)) (all dr (not c)) (all ppi (not c))))
(ins b b)
(ins c c)
(rel a b po)
(rel b c po)
(setf z *cur-abox*)
(princ (abox-sat-p *cur-abox* :debug-p t :compute-all-completions-p t))
(terpri)))
(loop
(princ "+")
(reset-store *cur-store*)
(when (sat? (and (some po (some po (some po (some po c))))
(all po (not c))
(all dr (not c))
(all pp (not c))
(all ppi (not c))
(all eq (not c)))
:language +alci-rcc+
:rbox 'rcc5-rolebox
:use-rbox-p t
:break-p nil
:semantic-branching-p (one-of '(t nil))
:non-determinism-p (one-of '(t nil))
:reuse-nodes-p nil ; (one-of '(t nil))
:debug-p nil)
(error "!"))
(princ "-")
(unless (sat? (and (some po (some po (some po (some po c))))
(all po (not c))
(all dr (not c))
(all pp (not c))
(all ppi (not c))
(all eq d))
:language +alci-rcc+
:rbox 'rcc5-rolebox
:semantic-branching-p (one-of '(t nil))
:use-rbox-p t
:non-determinism-p (one-of '(t nil))
:reuse-nodes-p (one-of '(t nil))
:debug-p nil)
(error "!")))
(with-rbox (rcc5-rolebox)
(with-abox (test :delete-if-exists-p t :language +alci-rcc+)
(ins a a)
(ins b b)
(ins c c)
(rel a b dr)
(rel b c ppi)
(rel a c (or dr po pp eq ppi))
(setf *x* *cur-abox*)
(prepare *cur-abox* +alci-rcc+)
(compute-minimal-label *cur-abox*)
(visualize *cur-abox*)))
(with-rbox (rcc5-rolebox)
(loop (princ "*")
(unless (sat? (and (or (some dr (some pp c))
(some dr d))
(all po (not c))
(all dr (not d))
(all pp (not c)))
:semantic-branching-p t
:non-determinism-p t
:type 'jepd-abox :compute-all-completions-p t :debug-p nil)
(break)))
(visualize *completions*))
(princ (sat?
(and c d
(some r a) (all r (=> a b))
(or (and (all r (and c (some s d)))
(all r (=> c (all s (and (not d) (not e))))))
(all r (not b))
;;;xxx
)) :debug-p t :semantic-branching-p t))
(princ (sat? (and c
(some s
(and d (all (inv s) (not c)))))
:debug-p t))
(princ (sat?
(and c x
(or (some r (and d y (all (inv r) (not c))))
(some r (and d z
(or (all (inv r) (not c))
(some s (and e u
(or (all (inv s) (not d))
(some t (and f p
(or (all (inv t) (not e))
(all (inv t)
(=> e (all (inv s) (=> d (all (inv r)
(or (not x)
;;;xxx
)))))))))))))))))
:debug-p t
:semantic-branching-p (one-of '(t nil))
:non-determinism-p t))
;;;
;;; Konjunktive Aboxen!
;;;
(with-abox (test :delete-if-exists-p t)
(ins a (and a (or (all r (not b))
(all s (not b))
(all (and r s)
(not b)))))
(ins b (and b))
(rel a b r)
(rel a b s)
(princ (abox-sat-p *cur-abox* :debug-p t)))
;;;
;;; Disjunktive Aboxen!
;;;
(with-abox (test :delete-if-exists-p t)
(ins a (and a (all r (not b)) (all s (or (not b) (all (inv (or r s)) (not a))))))
(ins b (and b))
(rel a b (or r s ))
(setf *x* *cur-abox*)
(princ (abox-sat-p *cur-abox* :debug-p t)))
(with-abox (test :delete-if-exists-p t)
(ins a (and a
(some (or r s) b)
(all r (not b))
(all s (not cb))))
(setf *x* *cur-abox*)
(princ (abox-sat-p *cur-abox* :debug-p t)))
(with-abox (test :delete-if-exists-p t)
(ins a (and a
(all r (not b))
(all s (not b))))
(ins b (and b))
(rel a b (or r s))
(setf *x* *cur-abox*)
(princ (abox-sat-p *cur-abox* :debug-p t)))
(progn
(with-abox (test :delete-if-exists-p t)
(ins a (and a
(and (all ab1 (and (all bc1 (not c))
(all bc2 (not c))))
(all ab2 (and (all bc1 (not c))
(all bc2 (not c)))))))
(ins b b)
(ins c c)
(rel a b (or ab1 ab2))
(rel b c (or bc1 bc2))
(princ (abox-sat-p *cur-abox* :debug-p t))))
(progn
(with-abox (test :delete-if-exists-p t)
(ins a a)
(ins a1 a)
(ins a2 a)
(ins a3 a)
(ins b (and b (all s (not c)) (all t (not c))))
(ins c c)
(rel a b (or r s))
(rel a1 b (or r s u v w x y a b c))
(rel a2 b (or r s u v w x y a b c))
(rel a3 b (or r s u v w x y a b c))
(rel b c (or s t))
(princ (abox-sat-p *cur-abox* :debug-p t))))
;;;
;;;
;;;
(subrole r s)
(subrole s t)
(with-abox (test :delete-if-exists-p t)
(ins a (and a
(or (all s (not b))
(all r (not b))
(all t (not b))
(some s
(and (all (inv t) (not a))
(all (inv t) (not a)))))
(some r b)))
(princ (abox-sat-p *cur-abox* :debug-p t)))
;;;
;;; ALCHI_R+ !
;;;
(subrole r s)
(subrole s t)
(transitive s)
(with-abox (test :delete-if-exists-p t)
(ins a (and (some r (some s (some s (some r (some r (and c
(all (inv s) (not b))))))))
(or (all s (not c))
b)))
(princ (abox-sat-p *cur-abox* :debug-p t)))
;;;
;;; Demo: Rollen-Konjunktion / Disjunktion
;;:
(princ (sat? (and (some (or r s) c) (all r (not c)) (all s d) (all (or r s) (=> d (not c))))))
(princ (sat? (and (some (or r s) c) (all r (not c)) (all s d) (all (and r s) (=> d (not c))))))
(princ (sat? (and (some (and r s) c) (all r (not c)))))
(princ (sat? (and (some (and r s) c) (all (and r s) (not c)))))
(princ (sat? (and (some (and r s) c) (all (or r s) (not c)))))
(princ (sat? (and (some (and r s) c) (all (and r s t) (not c)))))
(subrole r s)
(subrole t r)
(subrole t s)
(princ (sat? (and (some (and r s) c) (all (and r s t) (not c)))))
(princ (sat? (and (some (and r s) c) (all s (not c)))))
(subrole r t)
(princ (sat? (and (some (and s r) c) (all (and s r t) (not c))) :debug-p t))
(subrole s t)
(princ (sat? (and (some (and s r) c) (all (and s r t) (not c)))))
(subrole s t r) ;;; !!
(princ (sat? (and (some s c) (all (and r t) (not c)))))
(with-rbox (rcc5-rolebox)
(with-abox (test :type 'rolebox-abox :delete-if-exists-p t)
(ins a (and a))
(ins b (and b))
(ins c (and c))
(ins d (and d))
(rel a b (or r s))
(rel b c (or r s))
(rel c d (or r s))
(rel b d (or r s))
(visualize (get-all-atomic-configurations *cur-abox*))))
(princ
(sat? (some pp (some pp c))
:debug-p t
:type 'jepd-abox
:visualize-p t
:rbox 'thematic-substrate::rcc5-rolebox ))
(with-abox (test :type 'abox :delete-if-exists-p t)
(ins a (and auto
(some has-part
(and (or motor
(some foobar huhu))
(all foobar
(some has-part
(or a b c
(some xz cdscdsc))))))))
(princ (abox-sat-p *cur-abox*
:compute-all-completions-p t))
(visualize *completions*))
| 22,108 | Common Lisp | .lisp | 558 | 25.989247 | 125 | 0.448652 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 09811978bd2d2233f3214e28d22065f0f70899855cc3f185990132e54e3334a6 | 12,562 | [
-1
] |
12,563 | settings.lisp | lambdamikel_DLMAPS/src/prover/settings.lisp | ;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
;(push :use-membership-tables *features*)
;(push :use-dependency-directed-backtracking *features*)
;(push :use-avl-trees-for-labels *features*)
;(push :use-avl-trees-for-choice-points *features*)
;(push :use-avl-trees-for-actions *features*)
;(push :use-avl-trees-for-models *features*)
| 389 | Common Lisp | .lisp | 11 | 33.545455 | 59 | 0.712737 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 0d301d00677a1ccff5b15bd0920ce307c78ba7a1ecf597d5a5719178baf77dcd | 12,563 | [
-1
] |
12,564 | concept-selection-test.lisp | lambdamikel_DLMAPS/src/prover/concept-selection-test.lisp | ;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(defmethod count-no-of-open-disjuncts ((node abox-node) (or-concept or-concept))
(loop as arg in (arguments or-concept)
when (and (not (on-tableau-p node arg))
(not (on-tableau-p node (get-negated-concept arg))))
sum 1))
;;;
;;; Code for syntactic branching
;;;
(defun get-or-score (node or-concept)
(declare (ignorable node or-concept))
1)
(defmethod select-or-concept ((abox abox) (language dl))
(let ((or nil)
(node nil)
(score nil))
(loop-over-abox-nodes (or-node abox nil)
(when (and (active-p or-node)
(has-unexpanded-or-concepts-p or-node nil))
(when *reflexive-checks-p*
(unless (deterministically-expanded-p or-node)
(error "SELECT-OR-CONCEPT: Strategy Error!")))
(loop-over-node-unexpanded-or-concepts (or-concept or-node nil)
(let ((new-score
(get-or-score or-node or-concept)))
(when (or (not or)
(> new-score score))
(setf score new-score)
(setf or or-concept node or-node)))))
(when or
(announce "~%+++ Selected OR CONCEPT ~A : ~A" node or)
(return-from select-or-concept
(values or node))))))
;;;
;;; Code for semantic branching
;;;
(defmethod select-open-disjunct ((abox abox) (language dl))
(let ((best-score nil)
(best nil)
(concept nil)
(best-node nil)
(score nil)
(ors-found-p nil))
(loop-over-abox-nodes (node abox)
(when (and (active-p node)
(has-unexpanded-or-concepts-p node nil))
(when *reflexive-checks-p*
(unless (deterministically-expanded-p node)
(error "SELECT-OPEN-DISJUNCT: Strategy Error!")))
(let ((score (get-node-score node)))
(when (or (not best-score)
(> score best-score))
(setf best-score score)
(setf best-node node)))))
(when best-node
(let ((open-disjuncts nil)
(ors nil)
(node best-node))
(loop-over-node-unexpanded-or-concepts (or-concept node nil)
(push or-concept ors)
(setf ors-found-p t)
(dolist (disjunct (arguments or-concept))
(when (and ;(not (on-tableau-p node disjunct)) ;; kann nicht auftreten!
(not (on-tableau-p node (get-negated-concept disjunct))))
;;(return-from select-open-disjunct
;; (values disjunct or-concept node))
(push (list disjunct or-concept) open-disjuncts))))
(dolist (disjunct-and-or open-disjuncts)
(let ((disjunct (first disjunct-and-or))
(or-concept2 (second disjunct-and-or)))
(dolist (disjunct (list disjunct (get-negated-concept disjunct)))
(let ((score 0))
#|
(dolist (or-concept ors)
(when (member disjunct (arguments or-concept))
(incf score))) |#
(setf score
(get-node-score node))
(unless (zerop score)
;;; ein solches Disjunkt bewirkt nichts,
;;; ist in keiner Disjunktion ein Argument!
(when (or (not best)
(> score best-score))
(setf best-node node
concept or-concept2
best disjunct
best-score score)))))))
(when (and ors-found-p (not best))
(error "Could not select disjunct!"))
(when best
(announce "~%+++ Selected OPEN DISJUNCT ~A OF ~A : ~A" best concept best-node)
(return-from select-open-disjunct
(values best concept best-node)))))))
;;;
;;;
;;;
;;;
;;;
;;;
;;;
;;;
;;;
;;;
(defun get-at-least-score (node at-least-concept)
(- 1000000000
(tools:maximum (get-choice-points at-least-concept :node node))))
(defmethod select-at-least-concept ((abox abox) (language dl))
(let ((node
(or
(get-oldest-node-satisfying1 abox ; wichtig! sonst falsch!
#'(lambda (x)
(and (active-p x)
(old-p x)
(has-unexpanded-at-least-concepts-p x nil))))
(get-youngest-node-satisfying1 abox ; Tiefensuche!
#'(lambda (x)
(and (active-p x)
(has-unexpanded-at-least-concepts-p x nil)))))))
(when node
(let ((at-least nil)
(score nil))
(loop-over-node-unexpanded-at-least-concepts (at-least-concept node nil)
(let ((new-score
(get-at-least-score node at-least-concept)))
(when (or (not at-least)
(> new-score score))
(setf score new-score)
(setf at-least at-least-concept))))
(when at-least
(announce "~%+++ Selected AT-LEAST CONCEPT ~A : ~A" node at-least)
(return-from select-at-least-concept
(values at-least node)))))))
;;;
;;;
;;;
(defmethod select-violated-at-most-concept ((abox abox) (language dl))
(loop-over-abox-nodes (node abox)
(let ((role-n-entries nil))
(when (and (active-p node)
(has-unexpanded-at-most-concepts-p node))
(when *reflexive-checks-p*
(unless (deterministically-expanded-p node)
(error "Strategy Error!")))
;;; kleinstes (at-most n R) pro Rolle R raussuchen
(loop-over-node-unexpanded-at-most-concepts (at-most-concept node)
(unless (is-top-concept-p (qualification at-most-concept))
(error "To be implemented!"))
(let ((role-n (assoc (role at-most-concept)
role-n-entries)))
(if role-n
(setf (second role-n)
(if (< (n at-most-concept)
(n (second role-n)))
at-most-concept
(second role-n)))
(push (list (role at-most-concept) at-most-concept) role-n-entries))))
;;;
(dolist (role-n role-n-entries)
(let* ((role (first role-n))
(at-most-concept (second role-n))
(n (n at-most-concept))
(m 0)
(edges nil))
(loop-over-role-successors (node role) (succ edge)
;;; (format t "~% ~A ~A ~A ~A" node role succ edge)
(if (eq node (from edge))
(unless (zerop (multiplicity edge))
(push edge edges)
(incf m (multiplicity edge)))
(unless (zerop (inverse-multiplicity edge))
(push edge edges)
(incf m (inverse-multiplicity edge)))))
(when (> m n)
(announce "~%+++ Selected violated AT-MOST CONCEPT ~A : ~A" node at-most-concept)
(announce "~%+++ Edges found: ~A" edges)
(return-from select-violated-at-most-concept
(values at-most-concept node edges m)))))))))
;;;
;;;
;;;
(defmethod select-attribute-exists-concepts ((abox abox) (language dl))
(let ((node
(or (get-oldest-node-satisfying1 abox ; wichig! sonst falsch!
;;; s. Gegenbeispiel in alchfnrplus-prover.lisp!
#'(lambda (x)
(and (active-p x)
(old-p x)
(has-unexpanded-attribute-exists-concepts-p x))))
(get-youngest-node-satisfying1 abox
#'(lambda (x)
(and (active-p x)
(has-unexpanded-attribute-exists-concepts-p x))))))
(ae-concept nil)
(ae-concepts nil)
(relevant-ae-concepts nil)
(score nil))
(when node
(loop-over-node-unexpanded-attribute-exists-concepts (concept node nil)
(let ((new-score
(get-some-score node ae-concept)))
(when (or (not ae-concept)
(> new-score score))
(setf score new-score)
(setf ae-concept concept))
(push concept ae-concepts)))
(push ae-concept relevant-ae-concepts)
(when ae-concept
(announce "~%+++ Selected ATTRIBUTE-EXISTS CONCEPT ~A : ~A" node ae-concept)
(let* ((found t))
(loop while found do
(setf found nil)
(let ((x
(find-if #'(lambda (x)
(some #'(lambda (y)
(has-common-parent-feature (role x) (role y)))
relevant-ae-concepts))
ae-concepts)))
(when x
(setf found t)
(setf ae-concepts (delete x ae-concepts))
(push x relevant-ae-concepts)))))
(setf relevant-ae-concepts
(delete-duplicates relevant-ae-concepts))
(announce "~%+++ Selected group of ATTRIBUTE-EXISTS CONCEPTS ~A : ~A" node relevant-ae-concepts)
(values ae-concept relevant-ae-concepts node)))))
| 10,040 | Common Lisp | .lisp | 229 | 28.419214 | 105 | 0.494219 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 4e26bf2f38f32f85394f1290f56f6814536e5b3b5751b7995aca211d935ed00c | 12,564 | [
-1
] |
12,565 | model-merging4.lisp | lambdamikel_DLMAPS/src/prover/model-merging4.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(defrule make-models-for-nodes (dl-with-model-merging abox)
(when *cache-models-p*
;;;
;;; Blätter identifizieren
;;;
(let ((leaf-nodes nil) ; Tableau-Blaetter (keine alten)
(satisfiable-nodes nil)) ; Knoten, die sicher erfuellbar sind
(labels ((do-it (node)
(when (not (or (old-p node)
(root-p node)))
;;; vollstaendig expandierte Blätter identifizieren
(when (and (active-p node)
(stable-p node) ; fuer ALCHN erforderlich!
(complete-p node))
;; (describe-object node t)
(deactivate-node abox node))
;;; inaktive Sammeln
;;; ein Knoten ist inaktiv, wenn
;;; 1. soeben deaktiviert, oder
;;; 2. blockiert, oder
;;; 3. als erfuellbar bekannt (dann cache-satisfiable-p = T)
(when (and (not (active-p node))
(stable-p node)
(=> *blocking-enabled-p*
(not (blocked-p node))))
(push node leaf-nodes)))))
(announce "All leaf nodes : ~A" (get-leaf-nodes abox))
(announce "All blocked nodes: ~A" (get-blocked-nodes abox))
(loop-over-leaf-nodes (node abox)
;;; haben niemals aktive Nachfolger!
(do-it node))
(loop-over-blocked-nodes (node abox)
;;; haben niemals aktive Nachfolger!
(do-it node)))
(announce "Identified leaf nodes: ~A" leaf-nodes)
;;;
;;; Knoten identifizieren, die nun *sicher* als erfuellbar bekannt sind.
;;; Von den Blaettern beginnen!
;;;
(labels ((mark-sat-nodes (node)
(when (=> *blocking-enabled-p*
;;; kann ausgeschaltet werden
;;; wenn das Tableaux am Ende
;;; als Erfuellbar bekannt ist,
;;; koennen auch von geblockten Knoten
;;; Modelle erzeugt werden!
;;; s. cache-and-delete-Anwendung
;;; vor (success) im ALCH-Prover
(not (blocked-p node)))
;;; geblockte Knoten oder Vorgaenger von
;;; geblockten Knoten koennen dann niemals
;;; als really-satisfiable-p markiert werden
(announce "Node ~A = ~A ~A" node
(outgoing node)
(mapcar #'(lambda (out)
(really-satisfiable-p (to out)))
;; natuerlich auch wahr fuer Blaetter!
(outgoing node)))
(when (every #'(lambda (out)
(really-satisfiable-p (to out)))
;; natuerlich auch wahr fuer Blaetter!
(outgoing node))
(when (and (stable-p node)
(or (cache-satisfiable-p node)
(blocked-p node)
(complete-p node)))
(unless (really-satisfiable-p node)
(when (active-p node)
(deactivate-node abox node))
(setf (really-satisfiable-p node) t)
(push node satisfiable-nodes))
(dolist (in (incoming node))
(mark-sat-nodes (from in))))))))
(dolist (leaf leaf-nodes)
(mark-sat-nodes leaf))
(loop-over-cache-sat-nodes (leaf abox)
(mark-sat-nodes leaf)))
(announce "Identified satisfiable nodes: ~A" satisfiable-nodes)
;;;
;;;
;;;
(when *cache-models-p*
(dolist (node satisfiable-nodes) ; hier sind niemals alte Knoten enthalten
(announce "Cache building, now considering node ~A" node)
;;; hierdurch werden evtl. weitere Caches gefuellt!!!
;;; (durch Konzept-Xreferencing):
(when (initial-concept node)
(register-already-known-to-be-satisfiable abox node))
(when (and (not (cache-satisfiable-p node))
(not (blocked-p node)))
(announce "~A is not cache satisfiable and not blocked -> concept model can be created" node)
;;; nur wenn die Nachfolger expandiert wurden, kann
;;; ein Modell erzeugt werden!
(when (every #'(lambda (outgoing)
(not (active-p (to outgoing))))
(outgoing node))
(announce "Successors of ~A are inactive" node)
;;; die ausgehenden eines nicht-alten Knotens sind
;;; ebenfalls nicht alt
;;; Konzept-Modelle
(let ((model
(make-model-from-node node)))
(when (initial-concept node)
(announce "~A has initial concept ~A" node (initial-concept node))
(if (< (length (cached-models
(initial-concept node)))
*max-no-of-concept-models*)
(progn
(announce "Making concept model for initial concept ~A of node ~A"
(initial-concept node)
node)
;(register-concept-model (get-node-concept abox node) model)
(register-concept-model (initial-concept node) model))
(announce "Already ~A models for initial concept ~A of node ~A"
*max-no-of-concept-models*
(initial-concept node)
node))))))))))
+insert-body-code+)
(defrule delete-nodes (dl abox)
(when *delete-nodes-p*
(let ((change t))
(loop while change do
(setf change nil)
(loop-over-leaf-nodes (node abox)
(unless (active-p node)
(delete-node abox node)
(setf change t))))))
+insert-body-code+)
(defrule make-models-for-old-nodes (dl-with-model-merging abox)
;;; darf nur vor (success) gerufen werden!
(when (or *store-ind-models-p* *cache-models-p*)
(loop-over-nodes (node abox)
(when (and (not (already-known-to-be-inconsistent-p node))
(or (old-p node)
(root-p node)))
;;; geblockte sind niemals alt (oder root)!
(announce "Cache building (old nodes), now considering node ~A" node)
(when (initial-concept node)
(register-already-known-to-be-satisfiable abox node))
(unless (cache-satisfiable-p node)
(when (and *store-ind-models-p*
(< (length (ind-models node))
*max-no-of-ind-models-per-node*))
(announce "Making ind model for node ~A" node)
(push (make-model-from-node node)
(slot-value node 'ind-models)))
;;; Achtung! Ind und Concept Models fuer alte Knoten sind nicht
;;; das selbe! Denn in einer ABox mit mehr als einem Knoten haben
;;; die Knoten kein initial-concept! (da ja das Label erst durch
;;; die erforderliche Precompletion stabil wird, die ist jedoch
;;; nichtdeterministisch)
(when (initial-concept node)
;;; hierdurch werden Caches gefuellt!
(register-already-known-to-be-satisfiable abox node))
(when (and *cache-models-p*
(initial-concept node)
(< (length (cached-models
(initial-concept node)))
*max-no-of-concept-models*))
(announce "Making concept model for initial concept ~A of node ~A"
(initial-concept node)
node)
(let ((model (make-model-from-node node)))
(register-concept-model (initial-concept node) model)
;(register-concept-model (get-node-concept abox node) model)
))))))
+insert-body-code+)
;;;
;;;
;;;
(defrule pop-active-nodes-heap (dl abox1)
;;; nur fuer Tiefensuche-Strategie mit ABOX1 !!!
(with-slots (active-nodes) abox
(let ((node (heap-peek active-nodes)))
;;; keine Regel war anwendbar auf den aktuell aktiven Knoten ->
;;; Knoten ist complete, deaktivieren, naechster Knoten vom Heap
;;; wird aktueller Knoten
;;; (Tiefensuche)
(if node
(progn
(unless (active-p node)
(error "Found a deactivated node on active-nodes heap: ~A!" node))
(when (or (not (complete-p node))
(blocked-p node)
(cache-satisfiable-p node))
(describe-object node t)
(error "deactivate nodes: ~A!" node))
(deactivate-node abox node)
;;; hier tritt nun Backtracking fuer den BLOCKIERENDEN Knoten
;;; auf, also ist der fertig expandiert -> nun steht auch der
;;; Erfuellbarkeitsstatus aller evtl. blockierten Nachfolger positiv fest,
;;; vorher nicht!
(when *blocking-enabled-p*
(dolist (blocked (slot-value node 'blocking-for))
(setf *bb* (list node blocked ))
(unless (deleted-p blocked)
(loop-between-blocked-blocking (var blocked node)
(setf (really-satisfiable-p var) t)))))
;;;
;;; weiter
;;;
(when (every #'(lambda (out)
;;; also: entweder Complete oder Cache-Sat Hit!
(or (really-satisfiable-p (to out))
;; (blocked-p (to out)) falsch
(already-known-to-be-satisfiable-p (to out))))
(outgoing node))
(setf (really-satisfiable-p node) t)
(when *cache-models-p*
(announce "Cache building, now considering node ~A" node)
(when (initial-concept node)
(register-already-known-to-be-satisfiable abox node))
(let ((model
(make-model-from-node node)))
(when (and (initial-concept node)
(< (length (cached-models
(initial-concept node)))
*max-no-of-concept-models*))
(announce "Making concept model for initial concept ~A of node ~A"
(initial-concept node)
node)
;(register-concept-model (get-node-concept abox node) model)
(register-concept-model (initial-concept node) model)))))
+insert-positive-code+)
(progn
+insert-negative-code+)))))
;;;
;;;
;;;
(defrule model-merging (dl-with-model-merging abox :args (node))
(when *use-cached-models-p*
(labels ((do-it (node)
(when (and (active-p node)
(stable-p node)
(not (complete-p node))
;; kann fuer ALCHN vorkommen!
(not (checked-p node)))
;;;
;;; Unsat Cache
;;;
(announce "Checking Unsat Cache for stable node ~A" node)
(when (and *use-unsat-cache-p*
(initial-concept node)
(register-initial-concept-unsat-cache-query)
(already-known-to-be-inconsistent-p node))
(setf (cur-clash-node abox) nil)
(register-initial-concept-unsat-cache-hit)
;;;
;;; Backtracking ausloesen!
;;;
(let ((cps
#| Aua! das war wohl nix...
(sort
(copy-list
(if (is-and-concept-p (initial-concept node))
(get-choice-points (arguments (initial-concept node))
:node node)
(get-choice-points (initial-concept node)
:node node)))
#'>) |#
(sort
(copy-list
(get-choice-points
(multiple-value-call #'list
(get-unexpanded-concept-lists node))
:node node))
#'>)))
(when *debug-p*
(describe-object node t)
(announce "Returning choice points: ~A" cps)
(announce "Choice points: ~A : ~A"
(multiple-value-call #'list (get-unexpanded-concept-lists node))
(get-choice-points (multiple-value-call #'list
(get-unexpanded-concept-lists node))
:node node)))
(return-from prover
(values nil cps))))
;;;
;;; Sat Cache und Model Merging
;;;
(announce "Checking Sat Cache for stable node ~A" node)
(register-sat-cache-query)
(cond ((and (initial-concept node)
(=> *store-ind-models-p*
;; die muessen expandiert werden, sonst hab ich kein Modell!
(not (root-or-old-p node)))
(progn
(register-initial-concept-sat-cache-query)
(or (cached-models (initial-concept node))
(already-known-to-be-satisfiable-p node))))
(register-initial-concept-sat-cache-hit)
(register-sat-cache-hit)
(announce "Found cached model for initial concept ~A of stable node ~A"
(initial-concept node)
node)
(register-already-known-to-be-satisfiable abox node)
(register-cache-satisfiable abox node)
(deactivate-node abox node))
;;
;; das initial-concept wird beim Aufruf von "register-label-is-stable"
;; gesetzt; dort wird ein AND-Konzept geparsed, und wenn bereits eines
;; im Concept-Store mit cached-model ist, bin ich fein raus!
;;
;; ansonsten: versuche, ob mergeable
;; wenn mergeable, könnte man auch die gemergten Modelle (to be implemented!)
;; als Modell fuer initial-concept nehmen!
;;
;; wenn das alles fehlschlaegt, wird der Knoten expandiert, und am Ende,
;; wenn er compelte-p ist, wird sein Modell gecached fuer initial-concept!
;; s. mode-caching-rule
;;
( (let ((concepts nil))
(when (=> *store-ind-models-p*
;; die muessen expandiert werden, sonst hab ich kein Modell!
(not (root-or-old-p node)))
(loop-over-node-unexpanded-concepts (concept node)
(push concept concepts))
(register-mm-query)
(models-of-concepts-mergeable-p language concepts)))
(announce "Unexpanded concepts ~A of stable node ~A are mergeable"
(get-unexpanded-concept-lists node)
node)
(register-mm-success)
(register-sat-cache-hit)
(register-already-known-to-be-satisfiable abox node)
(register-cache-satisfiable abox node)
(deactivate-node abox node)
(announce "Found MM cache hit of stable node ~A" node))))
;;;
;;;
;;;
(setf (checked-p node) t)))
(if node
(do-it node)
(loop-over-active-nodes (node abox)
(do-it node)))
+insert-body-code+)))
(defrule identify-stable-nodes (alchn abox)
(let ((changed t))
(loop while changed do
(setf changed nil)
(loop-over-active-nodes (node abox)
(when (and (not (stable-p node))
(every #'(lambda (in)
(let ((pre (from in)))
(and (not (has-unexpanded-generating-concepts-p pre))
(stable-p pre))))
(incoming node)))
(announce "Identified node ~A as stable!" node)
(setf changed t)
(register-label-is-stable abox node)))))
+insert-body-code+)
| 19,144 | Common Lisp | .lisp | 357 | 30.815126 | 105 | 0.461547 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 34b8f90895c4df30da94fdcdea2c03984c34a9ad5288f826e77cec6defbdf287 | 12,565 | [
-1
] |
12,566 | alchf-rplus-prover.lisp | lambdamikel_DLMAPS/src/prover/alchf-rplus-prover.lisp | ;; -*- 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))))
|#
| 6,620 | Common Lisp | .lisp | 160 | 24.2 | 89 | 0.432815 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 388d5660e885b47cde5a070ec03832b446b34141490f01b0654b903d2af76179 | 12,566 | [
-1
] |
12,567 | game2.lisp | lambdamikel_DLMAPS/src/prover/game2.lisp | (define-primitive-role has-location :feature t :inverse contains :range generic-container)
(define-primitive-role has-exit :domain room :range exit)
(define-primitive-role has-counterpart :range exit)
(define-primitive-role leads-to :feature t :range room)
(define-primitive-role shows)
(define-primitive-role has-colour)
(define-primitive-role wears)
(define-primitive-role has-detail)
(define-primitive-role fits-in)
;;; domain & range restrictions for roles
(implies (and generic-container (exactly 0 contains)) (and empty (not full)))
(implies (and generic-container (at-least 1 contains)) (and full (not empty)))
(disjoint empty full)
;;; define "here-object" and "inventory-object"
(equivalent here (and *top* (some contains player)))
(equivalent here-object (and object (all has-location here)))
(equivalent inventory-object (and object (all has-location player)))
;;; define "visible" and "accessible"
(equivalent visible (or here (all has-location here) (all has-location (and visible open))
(some contains (and open (some contains player)))
(all has-location (some contains (and open (some contains player))))))
(equivalent accessible (or here (all has-location here) (all has-location (and accessible open))))
;;; concepts
(equivalent generic-container (or player room container-object))
(disjoint room object)
(disjoint room player)
(disjoint object player)
(disjoint exit player)
(implies takeable object)
(implies edible object)
(implies drinkable object)
(implies container-object object)
(implies open-close-container (and container-object open-closed locked-unlocked))
(implies fore-exit exit)
(implies aft-exit exit)
(implies port-exit exit)
(implies starboard-exit exit)
(implies transport-tube exit)
;(implies exit (and open-closed locked-unlocked))
(implies open open-closed)
(implies closed open-closed)
(implies locked locked-unlocked)
(implies unlocked locked-unlocked)
(implies locked closed)
(disjoint open closed)
(disjoint locked unlocked)
(disjoint has-power has-no-power)
(implies light object)
(implies light-on light)
(implies light-off light)
(disjoint light-on light-off)
(implies full (not crushed))
(implies crushed empty)
(disjoint crushed uncrushed)
(equivalent green-object (and object (some has-colour green-colour)))
(equivalent silver-object (and object (some has-colour silver-colour)))
(equivalent golden-object (and object (some has-colour golden-colour)))
(equivalent white-object (and object (some has-colour white-colour)))
(equivalent yellow-object (and object (some has-colour yellow-colour)))
(equivalent brown-object (and object (some has-colour brown-colour)))
(equivalent red-object (and object (some has-colour red-colour)))
(equivalent black-object (and object (some has-colour black-colour)))
(equivalent blue-object (and object (some has-colour blue-colour)))
;;; Player
(implies player (and open big-sized))
(implies head object)
(implies mouth object)
(implies hand object)
(implies uniform takeable)
(implies shirt object)
(implies trousers object)
(implies shoe object)
(implies badge (and object small-sized))
(implies watch (and takeable small-sized))
(implies translator (and takeable tiny-sized))
(implies id-card (and takeable small-sized))
(implies credit-card (and takeable small-sized))
(implies coin (and takeable tiny-sized))
(implies galakmidcoin coin)
(implies box open-close-container)
(implies isotopes (and takeable edible medium-sized))
;;; Scooter
(implies seating (and container-object open))
(implies couch (and seating big-sized))
(implies couch-leg (and object small-sized))
(implies seat (and object big-sized))
(implies hatch (and exit big-sized))
(implies window (and transparent medium-sized))
(implies space (and room huge-sized))
(implies space-station (and object huge-sized))
(implies slot (and object small-sized))
(implies spaceform (and takeable small-sized))
(implies button (and object small-sized))
(implies scooter (and object huge-sized))
;;; Toolbox
(implies toolbox (and takeable medium-sized open-close-container))
(implies bracelet (and takeable small-sized))
(implies glue (and takeable small-sized))
(implies tube (and takeable small-sized))
(implies cap (and takeable small-sized))
(implies bottle (and takeable transparent))
(implies nutrientpaste (and takeable edible small-sized))
(implies saw takeable)
(implies hacksaw (and saw medium-sized))
(implies syringe (and takeable small-sized))
(implies needle (and takeable tiny-sized))
(implies plunger (and takeable small-sized))
(implies hydraulicram (and takeable medium-sized))
;;; Hall-j
(implies bulkhead (and exit open-closed locked-unlocked))
;;; Hall-l
(implies barrier (and object transparent big-sized))
;;; Hall-p
(implies sign (and object readable medium-sized))
;;; SanFac
(implies stall (and room big-sized))
(implies sink (and container-object medium-sized))
(implies trashcan (and container-object takeable small-sized))
(implies rubbish (and object small-sized))
(implies toiletroll (and object takeable small-sized))
;;; Waiting Room
(implies door (and open-closed exit))
(implies magazine (and takeable readable small-sized))
(implies book (and takeable readable small-sized))
(implies drill (and takeable small-sized))
(implies implement (and takeable small-sized))
(implies hosing (and takeable small-sized))
;;; Laboratory
(implies device (and object big-sized))
(implies devicemonitor (and object medium-sized))
(implies maze (and takeable small-sized))
(implies headset (and takeable small-sized))
;;; Sick Bay
(implies cage (and container-object big-sized))
(implies bar (and takeable medium-sized))
(implies fussbudget (and not-so-easy-to-kill big-sized))
;;; Directors Office
(implies cabinet (and open-close-container big-sized))
(implies key (and takeable small-sized))
(implies desk (and container-object open big-sized))
(implies outlet (and object small-sized))
(implies manual (and takeable medium-sized))
(implies computer (and takeable medium-sized))
(implies screen (and readable object)) ; AND INSERTED ---RM
(implies cord object)
(implies plug object)
(implies keyboard object)
(implies paper (and takeable readable small-sized))
;;; Lounge
(implies planet (and object huge-sized))
(implies table (and container-object big-sized))
(implies chair (and seating medium-sized))
(implies centimidcoin coin)
(implies dispenser (and container-object locked big-sized))
(implies carpet (and object big-sized))
(implies display (and object small-sized))
(implies tray (and container-object open))
(implies colamonitor (and object small-sized))
(implies cable object)
(implies coinstore (and container-object open))
(implies zorkmidcoin coin)
(implies refundbutton button)
(implies can (and takeable drinkable small-sized (or crushed uncrushed)))
(implies standardcolacan can)
(implies dietcolacan can)
;;; Teleport Room
(implies teleporter (and object huge-sized))
(implies transporterpad (and object big-sized))
(implies controlpanel (and object medium-sized))
;;; Map Room
(implies map (and object medium-sized))
;;; Control Station
(implies monitor (and object medium-sized))
;;; Briefing Room
(implies photo object)
(implies robot (and object big-sized))
(implies tag (and object small-sized))
;;; Store
(implies adapter (and takeable small-sized))
(implies fruit (and edible takeable small-sized))
(implies crate (and wooden takeable medium-sized))
(implies board (and wooden takeable medium-sized))
;;; Computer Room
(implies kid (and not-so-easy-to-kill big-sized))
(implies terminal (and object medium-sized))
(in-abox game-initial)
;;; define colour objects
(instance green green-colour)
(instance silver silver-colour)
(instance golden golden-colour)
(instance white white-colour)
(instance yellow yellow-colour)
(instance brown brown-colour)
(instance red red-colour)
(instance black black-colour)
(instance blue blue-colour)
(instance myself (and player alive not-so-easy-to-kill))
(related myself couch1 has-location)
(instance mouth1 mouth)
(instance head1 head)
(instance hand1 hand)
(instance hand2 hand)
(related head1 mouth1 has-detail)
(related myself head1 has-detail)
(related myself hand1 has-detail)
(related myself hand2 has-detail)
(instance uniform1 uniform)
(instance badge1 badge)
(instance badge2 badge)
(instance shirt1 shirt)
(instance trousers1 trousers)
(instance shoe1 shoe)
(instance shoe2 shoe)
(related uniform1 badge1 has-detail)
(related uniform1 badge2 has-detail)
(related uniform1 shirt1 has-detail)
(related uniform1 trousers1 has-detail)
(related uniform1 shoe1 has-detail)
(related uniform1 shoe2 has-detail)
(instance watch1 watch)
(instance translator1 translator)
(related myself uniform1 wears)
(related myself watch1 wears)
(related myself translator1 wears)
(instance id-card1 id-card)
(related id-card1 white has-colour)
(related id-card1 myself has-location)
(instance credit-card1 credit-card)
(related credit-card1 blue has-colour)
(related credit-card1 myself has-location)
(instance coin1 galakmidcoin)
(related coin1 golden has-colour)
(related coin1 myself has-location)
(instance isotopes-box1 (and box closed))
(related isotopes-box1 silver has-colour)
(related isotopes-box1 yellow has-colour)
(related isotopes-box1 black has-colour)
(related isotopes-box1 myself has-location)
(instance isotopes1 isotopes)
(related isotopes1 isotopes-box1 has-location)
;;; Scooter
(instance scooter-bridge room)
(instance space1 space)
(instance station1 space-station)
(related station1 space1 has-location)
(related station1 silver has-colour)
(related window1 space1 shows)
(related window1 station1 shows)
(instance port1 docking-port)
(related station1 port1 has-detail)
(instance couch1 couch)
(related couch1 brown has-colour)
(related couch1 black has-colour)
(related couch1 scooter-bridge has-location)
(instance couchleg1 couch-leg)
(related couch1 couchleg1 has-detail)
(instance couchleg2 couch-leg)
(related couch1 couchleg2 has-detail)
(instance couchleg3 couch-leg)
(related couch1 couchleg3 has-detail)
(instance couchleg4 couch-leg)
(related couch1 couchleg4 has-detail)
(instance slot1 slot)
(related slot1 couch1 has-location)
(instance spaceform1 spaceform)
(instance button0 button)
(related button0 couch1 has-location)
(related button0 red has-colour)
(instance hatch1 hatch)
(instance window1 window)
(related hatch1 window1 has-detail)
(related hatch1 silver has-colour)
(related hatch1 scooter-bridge has-location)
(instance hatch1 (and locked fore-exit))
(related scooter-bridge hatch1 has-exit)
(related hatch1 space1 leads-to)
(instance scooter1 scooter)
(related scooter1 space1 has-location)
(related scooter1 silver has-colour)
;;; Toolbox
(instance toolbox1 toolbox)
(related toolbox1 scooter-bridge has-location)
(related toolbox1 silver has-colour)
(instance bracelet1 bracelet)
(related bracelet1 toolbox1 has-location)
(related bracelet1 golden has-colour)
(instance glue1 glue)
(related glue1 toolbox1 has-location)
(related glue1 yellow has-colour)
(related glue1 glue1-cap has-detail)
(related glue1 glue1-bottle has-detail)
(instance glue1-cap cap)
(related glue1-cap black has-colour)
(instance glue1-bottle bottle)
(instance nutrientpaste1 (and nutrientpaste full))
(related nutrientpaste1 toolbox1 has-location)
(related nutrientpaste1 green has-colour)
(related nutrientpaste1 nutrientpaste1-cap has-detail)
(related nutrientpaste1 nutrientpaste1-tube has-detail)
(instance nutrientpaste1-cap cap)
(related nutrientpaste1-cap black has-colour)
(instance nutrientpaste1-tube tube)
(related nutrientpaste1-tube green has-colour)
(instance hacksaw1 hacksaw)
(related hacksaw1 toolbox1 has-location)
(related hacksaw1 red has-colour)
(related hacksaw1 silver has-colour)
(related hacksaw1 hacksaw1-grip has-detail)
(related hacksaw1 hacksaw1-blade has-detail)
(instance hacksaw1-grip grip)
(related hacksaw1-grip red has-colour)
(instance hacksaw1-blade blade)
(related hacksaw1-blade silver has-colour)
(instance hydraulicram1 hydraulicram)
(related hydraulicram1 habitation-bulkhead fits-in)
(related hydraulicram1 computerroom-bulkhead fits-in)
;;; Docking-Port
(instance docking-port room)
(related docking-port docking-port-tube1 has-exit)
(instance docking-port-tube1 transport-tube)
(related docking-port-tube1 hall-m leads-to)
(related docking-port-tube1 docking-port has-location)
;;; Hall-j
(instance hall-j room)
(related hall-j hall-j-maproom-exit has-exit)
(instance hall-j-maproom-exit fore-exit)
(related hall-j-maproom-exit maproom leads-to)
(related hall-j-maproom-exit hall-j has-location)
(related hall-j hall-j-teleportroom-exit has-exit)
(instance hall-j-teleportroom-exit aft-exit)
(related hall-j-teleportroom-exit teleportroom leads-to)
(related hall-j-teleportroom-exit hall-j has-location)
(related hall-j habitation-bulkhead has-exit)
(instance habitation-bulkhead (and port-exit locked))
(related habitation-bulkhead computerroom leads-to)
(related habitation-bulkhead hall-j has-location)
(related habitation-bulkhead computerroom-bulkhead has-counterpart)
(related hall-j hall-j-hall-k-exit has-exit)
(instance hall-j-hall-k-exit starboard-exit)
(related hall-j-hall-k-exit hall-k leads-to)
(related hall-j-hall-k-exit hall-j has-location)
;;; Hall-k
(instance hall-k room)
(related hall-k hall-k-briefingroom-exit has-exit)
(instance hall-k-briefingroom-exit fore-exit)
(related hall-k-briefingroom-exit briefingroom leads-to)
(related hall-k-briefingroom-exit hall-k has-location)
(related hall-k hall-k-stationcontrol-exit has-exit)
(instance hall-k-stationcontrol-exit aft-exit)
(related hall-k-stationcontrol-exit stationcontrol leads-to)
(related hall-k-stationcontrol-exit hall-k has-location)
(related hall-k hall-k-hall-l-exit has-exit)
(instance hall-k-hall-l-exit starboard-exit)
(related hall-k-hall-l-exit hall-l leads-to)
(related hall-k-hall-l-exit hall-k has-location)
(related hall-k hall-k-hall-j-exit has-exit)
(instance hall-k-hall-j-exit port-exit)
(related hall-k-hall-j-exit hall-j leads-to)
(related hall-k-hall-j-exit hall-k has-location)
;;; Hall-l
(instance hall-l room)
(related hall-l hall-l-hall-k-exit has-exit)
(instance hall-l-hall-k-exit port-exit)
(related hall-l-hall-k-exit hall-k leads-to)
(related hall-l-hall-k-exit hall-l has-location)
(related hall-l hall-l-hall-m-exit has-exit)
(instance hall-l-hall-m-exit starboard-exit)
(related hall-l-hall-m-exit hall-m leads-to)
(related hall-l-hall-m-exit hall-l has-location)
(related hall-l hall-l-office-exit has-exit)
(instance hall-l-office-exit aft-exit)
(related hall-l-office-exit office leads-to)
(related hall-l-office-exit hall-l has-location)
(related hall-l hall-l-store-exit has-exit)
(instance hall-l-store-exit (and fore-exit barrier locked))
(related hall-l-store-exit store leads-to)
(related hall-l-store-exit hall-l has-location)
(related hall-l-store-exit store-hall-l-exit has-counterpart)
;;; Hall-m
(instance hall-m room)
(related hall-m hall-m-tube1 has-exit)
(instance hall-m-tube1 transport-tube)
(related hall-m-tube1 docking-port leads-to)
(related hall-m-tube1 hall-m has-location)
(related hall-m hall-m-hall-n-exit has-exit)
(instance hall-m-hall-n-exit starboard-exit)
(related hall-m-hall-n-exit hall-n leads-to)
(related hall-m-hall-n-exit hall-m has-location)
(related hall-m hall-m-hall-l-exit has-exit)
(instance hall-m-hall-l-exit port-exit)
(related hall-m-hall-l-exit hall-l leads-to)
(related hall-m-hall-l-exit hall-m has-location)
;;; Hall-n
(instance hall-n room)
(related hall-n hall-n-tube1 has-exit)
(instance hall-n-tube1 transport-tube)
(related hall-n-tube1 lounge leads-to)
(related hall-n-tube1 hall-n has-location)
(related hall-n hall-n-sickbay-exit has-exit)
(instance hall-n-sickbay-exit fore-exit)
(related hall-n-sickbay-exit sickbay leads-to)
(related hall-n-sickbay-exit hall-n has-location)
(related hall-n hall-n-hall-m-exit has-exit)
(instance hall-n-hall-m-exit port-exit)
(related hall-n-hall-m-exit hall-m leads-to)
(related hall-n-hall-m-exit hall-n has-location)
(related hall-n hall-n-hall-o-exit has-exit)
(instance hall-n-hall-o-exit starboard-exit)
(related hall-n-hall-o-exit hall-o leads-to)
(related hall-n-hall-o-exit hall-n has-location)
;;; Hall-o
(instance hall-o room)
(related hall-o hall-o-hall-p-exit has-exit)
(instance hall-o-hall-p-exit starboard-exit)
(related hall-o-hall-p-exit hall-p leads-to)
(related hall-o-hall-p-exit hall-o has-location)
(related hall-o hall-o-hall-n-exit has-exit)
(instance hall-o-hall-n-exit port-exit)
(related hall-o-hall-n-exit hall-n leads-to)
(related hall-o-hall-n-exit hall-o has-location)
(related hall-o hall-o-lab-exit has-exit)
(instance hall-o-lab-exit fore-exit)
(related hall-o-lab-exit lab leads-to)
(related hall-o-lab-exit hall-o has-location)
;;; Hall-p
(instance hall-p room)
(related hall-p hall-p-hall-o-exit has-exit)
(instance hall-p-hall-o-exit port-exit)
(related hall-p-hall-o-exit hall-o leads-to)
(related hall-p-hall-o-exit hall-p has-location)
(related hall-p engineering-bulkhead has-exit)
(instance engineering-bulkhead (and starboard-exit locked))
;;; (related engineering-bulkhead ???? leads-to)
(related engineering-bulkhead hall-p has-location)
(related hall-p hall-p-sanfac-exit has-exit)
(instance hall-p-sanfac-exit fore-exit)
(related hall-p-sanfac-exit sanfac leads-to)
(related hall-p-sanfac-exit hall-p has-location)
(related hall-p hall-p-waitingroom-exit has-exit)
(instance hall-p-waitingroom-exit aft-exit)
(related hall-p-waitingroom-exit waitingroom leads-to)
(related hall-p-waitingroom-exit hall-p has-location)
(instance sign1 sign)
(related sign1 white has-colour)
(related sign1 red has-colour)
(related engineering-bulkhead sign1 has-detail)
;;; SanFac Room
(instance sanfac room)
(related sanfac sanfac-hall-p-exit has-exit)
(instance sanfac-hall-p-exit aft-exit)
(related sanfac-hall-p-exit hall-p leads-to)
(related sanfac-hall-p-exit sanfac has-location)
(instance stall1 stall)
(related stall1 sanfac has-location)
(related stall1 white has-colour)
(instance sink1 sink)
(related sink1 sanfac has-location)
(related sink1 yellow has-colour)
(instance trashcan1 trashcan)
(related trashcan1 sanfac has-location)
(related trashcan1 yellow has-colour)
(instance rubbish1 rubbish)
(related rubbish1 trashcan1 has-location)
(related rubbish1 brown has-colour)
(instance toiletroll1 toiletroll)
(related toiletroll1 trashcan1 has-location)
(related toiletroll1 brown has-colour)
;;; Waiting Room
(instance waitingroom room)
(related waitingroom waitingroom-hall-p-exit has-exit)
(instance waitingroom-hall-p-exit fore-exit)
(related waitingroom-hall-p-exit hall-p leads-to)
(related waitingroom-hall-p-exit waitingroom has-location)
(related waitingroom waitingroom-dentistroom-exit has-exit)
(instance waitingroom-dentistroom-exit (and port-exit locked))
(related waitingroom-dentistroom-exit dentistroom leads-to)
(related waitingroom-dentistroom-exit waitingroom has-location)
(related waitingroom-dentistroom-exit dentistroom-waitingroom-exit has-counterpart)
(instance table3 table)
(related table3 waitingroom has-location)
(related table3 red has-colour)
(instance magazine1 magazine)
(instance magazine2 magazine)
(instance magazine3 magazine)
(instance book1 book)
(related magazine1 table3 has-location)
(related magazine2 table3 has-location)
(related magazine3 table3 has-location)
(related book1 table3 has-location)
;;; Dentistroom
(instance dentistroom room)
(related dentistroom dentistroom-waitingroom-exit has-exit)
(instance dentistroom-waitingroom-exit (and starboard-exit locked))
(related dentistroom-waitingroom-exit waitingroom leads-to)
(related dentistroom-waitingroom-exit dentistroom has-location)
(related dentistroom-waitingroom-exit waitingroom-dentistroom-exit has-counterpart)
(instance chair3 chair)
(related chair3 red has-colour)
(related chair3 dentistroom has-location)
(instance drill1 drill)
(related drill1 dentistroom has-location)
(instance implement1 implement)
(related implement1 dentistroom has-location)
(instance hosing1 hosing)
(related hosing1 dentistroom has-location)
;;; Laboratory
(instance lab room)
(related lab lab-hall-o-exit has-exit)
(instance lab-hall-o-exit aft-exit)
(related lab-hall-o-exit hall-o leads-to)
(related lab-hall-o-exit lab has-location)
(instance device1 device)
(related device1 lab has-location)
(instance devicemonitor1 devicemonitor)
(related device1 devicemonitor1 has-detail)
(instance device2 device)
(related device2 lab has-location)
(instance devicemonitor2 devicemonitor)
(related device2 devicemonitor2 has-detail)
(instance device3 device)
(related device3 lab has-location)
(instance devicemonitor3 devicemonitor)
(related device3 devicemonitor3 has-detail)
(instance maze1 maze)
(related maze1 black has-colour)
(related maze1 lab has-location)
(instance headset1 headset)
(related headset1 black has-colour)
(related maze1 headset1 has-detail)
;;; Lounge
(instance lounge room)
(related lounge lounge-tube1 has-exit)
(instance lounge-tube1 transport-tube)
(related lounge-tube1 hall-n leads-to)
(related lounge-tube1 lounge has-location)
(instance window2 window)
(related window2 lounge has-location)
(instance planet1 planet)
(related planet1 green has-colour)
(related planet1 space1 has-location)
(related window2 planet1 shows)
(related window2 space1 shows)
(instance carpet1 carpet)
(related carpet1 lounge has-location)
(related carpet1 yellow has-colour)
(instance table1 table)
(related table1 lounge has-location)
(related table1 brown has-colour)
(instance table2 table)
(related table2 lounge has-location)
(related table2 brown has-colour)
(instance chair1 chair)
(related chair1 lounge has-location)
(related chair1 brown has-colour)
(instance chair2 chair)
(related chair2 lounge has-location)
(related chair2 brown has-colour)
(instance coin2 centimidcoin)
(related coin2 table1 has-location)
(related coin2 silver has-colour)
(instance dispenser1 dispenser)
(related dispenser1 lounge has-location)
(related dispenser1 red has-colour)
(related dispenser1 white has-colour)
(instance display1 display)
(related dispenser1 display1 has-detail)
(instance tray1 tray)
(related dispenser1 tray1 has-detail)
(instance pre-tray1 tray)
(instance button1 button)
(related dispenser1 button1 has-detail)
(related button1 white has-colour)
(instance button2 button)
(related dispenser1 button2 has-detail)
(related button2 white has-colour)
(instance button3 button)
(related dispenser1 button3 has-detail)
(related button3 white has-colour)
(instance button4 button)
(related dispenser1 button4 has-detail)
(related button4 white has-colour)
(instance button5 button)
(related dispenser1 button5 has-detail)
(related button5 white has-colour)
(instance button6 button)
(related dispenser1 button6 has-detail)
(related button6 white has-colour)
(instance light1 light-on)
(related dispenser1 light1 has-detail)
(instance light2 light-on)
(related dispenser1 light2 has-detail)
(instance light3 light-off)
(related dispenser1 light3 has-detail)
(instance light4 light-off)
(related dispenser1 light4 has-detail)
(instance light5 light-off)
(related dispenser1 light5 has-detail)
(instance light6 light-off)
(related dispenser1 light6 has-detail)
(instance slot2 slot)
(related dispenser1 slot2 has-detail)
(instance colamonitor1 colamonitor)
(related dispenser1 colamonitor1 has-detail)
(instance cable1 cable)
(related colamonitor1 cable1 has-detail)
(instance coinstore1 coinstore)
(related dispenser1 coinstore1 has-detail)
(related coinstore1 silver has-colour)
(instance zorkmidcoin1 zorkmidcoin)
(related zorkmidcoin1 dispenser1 has-location)
(related zorkmidcoin1 golden has-colour)
(instance refundbutton1 refundbutton)
(related dispenser1 refundbutton1 has-detail)
(related refundbutton1 black has-colour)
(instance standardcolacan1 (and standardcolacan full))
(related standardcolacan1 red has-colour)
(related standardcolacan1 dispenser1 has-location)
(instance dietcolacan1 (and dietcolacan full))
(related dietcolacan1 white has-colour)
(related dietcolacan1 dispenser1 has-location)
;;; Sick Bay
(instance sickbay room)
(related sickbay sickbay-hall-n-exit has-exit)
(instance sickbay-hall-n-exit aft-exit)
(related sickbay-hall-n-exit hall-n leads-to)
(related sickbay-hall-n-exit sickbay has-location)
(instance syringe1 syringe)
(instance needle1 needle)
(instance plunger1 plunger)
(related syringe1 needle1 has-detail)
(related syringe1 plunger1 has-detail)
(related syringe1 sickbay has-location)
(instance cage1 (and cage locked))
(instance bar1 bar)
(instance bar2 bar)
(related cage1 sickbay has-location)
(related cage1 silver has-colour)
(related cage1 bar1 has-detail)
(related cage1 bar2 has-detail)
(related bar1 silver has-colour)
(related bar2 silver has-colour)
(instance fussbudget1 (and fussbudget alive))
(related fussbudget1 cage1 has-location)
;;; Station Control
(instance stationcontrol room)
(related stationcontrol stationcontrol-hall-k-exit has-exit)
(instance stationcontrol-hall-k-exit fore-exit)
(related stationcontrol-hall-k-exit hall-k leads-to)
(related stationcontrol-hall-k-exit stationcontrol has-location)
(instance monitor1 monitor)
(related monitor1 stationcontrol has-location)
(instance monitor2 monitor)
(related monitor2 stationcontrol has-location)
(instance monitor3 monitor)
(related monitor3 stationcontrol has-location)
(instance monitor4 monitor)
(related monitor4 stationcontrol has-location)
(instance monitor5 monitor)
(related monitor5 stationcontrol has-location)
(instance monitor6 monitor)
(related monitor6 stationcontrol has-location)
;;; Briefing Room
(instance briefingroom room)
(related briefingroom briefingroom-hall-k-exit has-exit)
(instance briefingroom-hall-k-exit aft-exit)
(related briefingroom-hall-k-exit hall-k leads-to)
(related briefingroom-hall-k-exit briefingroom has-location)
(instance photo1 photo)
(related photo1 briefingroom has-location)
(instance robot1 robot)
(related photo1 robot1 shows)
(instance table4 table)
(related table4 briefingroom has-location)
(related table4 black has-colour)
(instance tag1 tag)
(related tag1 table4 has-location)
(related tag1 black has-colour)
(instance tag2 tag)
(related tag2 table4 has-location)
(related tag2 black has-colour)
(instance tag3 tag)
(related tag3 table4 has-location)
(related tag3 black has-colour)
(instance tag4 tag)
(related tag4 table4 has-location)
(related tag4 black has-colour)
(instance chair4 chair)
(related chair4 briefingroom has-location)
(related chair4 black has-colour)
;;; Directors Office
(instance directorsoffice room)
(related directorsoffice directorsoffice-hall-l-exit has-exit)
(instance directorsoffice-hall-l-exit fore-exit)
(related directorsoffice-hall-l-exit hall-l leads-to)
(related directorsoffice-hall-l-exit directorsoffice has-location)
(instance desk1 desk)
(related desk1 black has-colour)
(related desk1 directorsoffice has-location)
(instance cabinet1 (and cabinet closed))
(related cabinet1 directorsoffice has-location)
(instance key1 key)
(related key1 silver has-colour)
(related key1 cabinet1 has-location)
(related key1 toolbox1 fits-in)
(related key1 waitingroom-dentistroom-exit fits-in)
(related key1 dentistroom-waitingroom-exit fits-in)
(instance outlet1 outlet)
(related outlet1 white has-colour)
(related outlet1 directorsoffice has-location)
(instance manual1 manual)
(related manual1 white has-colour)
(related manual1 cabinet1 has-location)
(instance computer1 computer)
(related computer1 black has-colour)
(related computer1 desk1 has-location)
(instance screen1 screen)
(related computer1 screen1 has-detail)
(instance cord1 cord)
(related cord1 black has-colour)
(related computer1 cord1 has-detail)
(instance plug1 plug)
(related plug1 black has-colour)
(related cord1 plug1 has-detail)
(instance keyboard1 keyboard)
(related keyboard1 black has-colour)
(related computer1 keyboard1 has-detail)
(instance paper1 paper)
(related paper1 white has-colour)
(related paper1 desk1 has-location)
;;; Teleport Room
(instance teleportroom room)
(related teleportroom teleportroom-hall-j-exit has-exit)
(instance teleportroom-hall-j-exit fore-exit)
(related teleportroom-hall-j-exit hall-j leads-to)
(related teleportroom-hall-j-exit teleportroom has-location)
(instance teleporter1 teleporter)
(related teleporter1 teleportroom has-location)
(instance transporterpad1 transporterpad)
(related teleporter1 transporterpad1 has-detail)
(instance controlpanel1 controlpanel)
(related teleporter1 controlpanel1 has-detail)
(instance button7 button)
(related button7 red has-colour)
(related controlpanel1 button7 has-detail)
;;; Map Room
(instance maproom room)
(related maproom maproom-hall-j-exit has-exit)
(instance maproom-hall-j-exit aft-exit)
(related maproom-hall-j-exit hall-j leads-to)
(related maproom-hall-j-exit maproom has-location)
(instance spacestationmap1 map)
(instance colonymap1 map)
(instance elevatormap1 map)
(related spacestationmap1 maproom has-location)
(related colonymap1 maproom has-location)
(related elevatormap1 maproom has-location)
;;; Store
(instance store room)
(related store store-hall-l-exit has-exit)
(instance store-hall-l-exit (and aft-exit barrier locked))
(related store-hall-l-exit hall-l leads-to)
(related store-hall-l-exit store has-location)
(related store-hall-l-exit hall-l-store-exit has-counterpart)
(instance adapter1 adapter)
(related adapter1 black has-colour)
(related adapter1 store has-location)
(instance fruit1 fruit)
(related fruit1 crate1 has-location)
(instance fruit2 fruit)
(related fruit2 crate1 has-location)
(instance fruit3 fruit)
(related fruit3 crate1 has-location)
(instance crate1 crate)
(related crate1 brown has-colour)
(related crate1 store has-location)
(instance board1 board)
(related board1 brown has-colour)
(related crate1 board1 has-detail)
(instance board2 board)
(related board2 brown has-colour)
(related crate2 board1 has-detail)
(instance board3 board)
(related board3 brown has-colour)
(related crate3 board1 has-detail)
;;; Computer Room
(instance computerroom room)
(related computerroom computerroom-bulkhead has-exit)
(instance computerroom-bulkhead (and starboard-exit locked))
(related computerroom-bulkhead hall-j leads-to)
(related computerroom-bulkhead computerroom has-location)
(related computerroom-bulkhead habitation-bulkhead has-counterpart)
(instance kid1 (and kid alive))
(related kid1 computerroom has-location)
(instance kid2 (and kid alive))
(related kid2 computerroom has-location)
(instance terminal1 terminal)
(related terminal1 computerroom has-location)
| 30,585 | Common Lisp | .lisp | 1 | 30,581 | 30,585 | 0.787968 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 396fee8fc63b98385f36be41fb7194d049426da7a7379216e701a80c4628f5a7 | 12,567 | [
-1
] |
12,568 | alchif-rplus-prover.lisp | lambdamikel_DLMAPS/src/prover/alchif-rplus-prover.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(define-prover ((abox-sat alchif-rplus abox))
(:main
(perform (deterministic-expansion)
(:body
(if clashes
(handle-clashes)
(perform (or-expansion)
(:positive
(if clashes
(handle-clashes)
(restart-main)))
(:negative
(perform (block-nodes)
(:body
(perform (feature-expansion)
(:positive
(if clashes
(handle-clashes)
(restart-main)))
(:negative
(perform (some-expansion)
(:positive
(if clashes
(handle-clashes)
(restart-main)))
(:negative
(success))))))))))))))
| 955 | Common Lisp | .lisp | 32 | 16.3125 | 60 | 0.414581 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 4fbb9c4a50ac9e069dd22e76ba0402ed9c1f29595ab17a5387f127bf0d487bf0 | 12,568 | [
-1
] |
12,569 | macros.lisp | lambdamikel_DLMAPS/src/prover/macros.lisp | ;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(defmacro defvar1 (&rest body)
`(#+:lispworks SYSTEM::WITHOUT-WARNING-ON-REDEFINITION
#-:lispworks progn
(defvar ,@body)))
(defmacro defparameter1 (&rest body)
`(#+:lispworks SYSTEM::WITHOUT-WARNING-ON-REDEFINITION
#-:lispworks progn
(defparameter ,@body)))
;;;
;;;
;;;
(defmacro with-logging (&body body)
`(with-open-file (stream "prover.log" :direction :output
:if-exists :supersede
:if-does-not-exist :create)
(setf *stream* stream)
(let* ((*standard-output* stream)
(*print-pretty* t)
(*debug-io* *standard-output*)
(*error-output* *standard-output*)
(*trace-output* *standard-output*))
(handler-case
,@body
(error (error)
(format *standard-output* "~%~%******** ERROR ~A ************~%" error)
(loop-over-abox-nodes (node *abox*)
(describe-object node *standard-output*))
(force-output *standard-output*)
'error)))))
(defmacro timed-defmethod (name &body body)
(let ((var-name
(intern (format nil "*TIME-SPEND-IN-~A*" name)))
(body1 (last body)))
`(progn
(defvar1 ,var-name 0)
(defmethod ,name ,@(butlast body)
(let ((*start-time* (get-internal-run-time)))
(unwind-protect
,@body1
(incf ,var-name (- (get-internal-run-time) *start-time*))))))))
(defmacro timed-defun (name &body body)
(let ((var-name
(intern (format nil "*TIME-SPEND-IN-~A*" name)))
(body1 (last body)))
`(progn
(defvar1 ,var-name 0)
(defun ,name ,@(butlast body)
(let ((*start-time* (get-internal-run-time)))
(unwind-protect
,@body1
(incf ,var-name (- (get-internal-run-time) *start-time*))))))))
(defmacro true! (body)
`(unless ,body
(error "~A must evaluate to TRUE!" ',body)))
(defmacro false! (body)
`(when ,body
(error "~A must evaluate to FALSE!" ',body)))
(defmacro push-all-to (add to-list &key (remove-duplicates-p t))
(let ((var1 (gensym))
(var2 (gensym)))
`(let ((,var2 ,add))
(dolist (,var1 ,add)
(push ,var1 ,to-list))
,(when remove-duplicates-p
`(setf ,to-list
(remove-duplicates ,to-list)))
,var2)))
;;;
;;;
;;;
;;;
(defmacro with-tbox* ((name &rest args &key delete-if-exists-p &allow-other-keys) &rest body)
`(let* ((*cur-tbox*
(when ,name
(or (and ,(not delete-if-exists-p) (find-tbox ,name))
(make-tbox ,name ,@args))))
(*cur-store* (concept-store *cur-tbox*)))
,@body))
(defmacro in-tbox* (name &rest args &key delete-if-exists-p &allow-other-keys)
`(progn
(setf *cur-tbox*
(when ,name
(or (and ,(not delete-if-exists-p) (find-tbox ,name))
(make-tbox ,name ,@args))))
(setf *cur-store*
(concept-store *cur-tbox*))
*cur-tbox*))
;;;
;;;
;;;
(defmacro with-tbox ((name &rest args) &rest body)
`(with-tbox* ( (quote ,name) ,@args)
,@body))
(defmacro in-tbox (name &rest args)
`(in-tbox* (quote ,name) ,@args))
;;;
;;;
;;;
(defmacro with-abox ((name &rest args &key type delete-if-exists-p &allow-other-keys)
&rest body)
`(with-substrate (,name ,@args
:delete-if-exists-p ,delete-if-exists-p
:type (or ,type
(get-abox-type-for-tbox *cur-tbox*)))
,@body))
(defmacro in-abox (name &optional tbox &rest args &key type delete-if-exists-p &allow-other-keys)
(if tbox
`(with-tbox (,tbox)
(in-substrate ,name ,@args
:delete-if-exists-p ,delete-if-exists-p
:type (or ,type
(get-abox-type-for-tbox *cur-tbox*))))
`(in-substrate ,name ,@args
:delete-if-exists-p ,delete-if-exists-p
:type (or ,type
(get-abox-type-for-tbox *cur-tbox*)))))
;;;
;;; die "*"-Varianten evaluieren das "name"-Argument!
;;; s. with-substrate* etc. in substrate7.lisp
;;;
(defmacro with-abox* ((name &rest args &key type delete-if-exists-p &allow-other-keys)
&rest body)
`(with-substrate* (,name ,@args
:delete-if-exists-p ,delete-if-exists-p
:type (or ,type
(get-abox-type-for-tbox *cur-tbox*)))
,@body))
(defmacro in-abox* (name &rest args &key type delete-if-exists-p &allow-other-keys)
`(in-substrate* ,name ,@args
:delete-if-exists-p ,delete-if-exists-p
:type (or ,type
(get-abox-type-for-tbox *cur-tbox*))))
;;;
;;;
;;;
(defmacro in-knowledge-base (tbox abox &rest args)
`(progn
(in-tbox ,tbox ,@args)
(in-abox ,abox ,@args)))
(defmacro with-knowledge-base ((tbox abox &rest args) &body body)
`(with-tbox (,tbox ,@args)
(with-abox (,abox ,@args)
,@body)))
;;;
;;;
;;;
(defmacro in-knowledge-base* (tbox abox &rest args)
`(progn
(in-tbox* ,tbox ,@args)
(in-abox* ,abox ,@args)))
(defmacro with-knowledge-base* ((tbox abox &rest args) &body body)
`(with-tbox* (,tbox ,@args)
(with-abox* (,abox ,@args)
,@body)))
;;;
;;;
;;;
(defmacro with-kb ((tbox abox &rest args) &body body)
`(with-knowledge-base (,tbox ,abox ,@args)
,@body))
(defmacro with-kb* ((tbox abox &rest args) &body body)
`(with-knowledge-base* (,tbox ,abox ,@args)
,@body))
(defmacro in-kb (tbox abox &rest args)
`(in-knowledge-base ,tbox ,abox ,@args))
(defmacro in-kb* (tbox abox &rest args)
`(in-knowledge-base* ,tbox ,abox ,@args))
;;;
;;;
;;;
(defmacro with-timing ((var) &body body)
`(let ((*start-time* (get-internal-run-time)))
(unwind-protect
(progn ,@body)
(incf ,var (- (get-internal-run-time) *start-time*)))))
| 6,374 | Common Lisp | .lisp | 180 | 26.438889 | 98 | 0.532184 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | e18d35f7c5aea1501f1a1c3076f10075c498e757ff1234ee485ad1a4301dc8be | 12,569 | [
-1
] |
12,570 | file-interface.lisp | lambdamikel_DLMAPS/src/prover/file-interface.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
(defmethod save-tbox ((tbox tbox) filename)
(with-open-file (stream filename :direction :output :if-exists :supersede)
(format stream "(in-tbox ~A)" (name tbox))
(dolist (role (get-all-roles tbox))
(when (parse-name role)
(if (feature-p role)
(format stream "~%(define-primitive-attribute")
(format stream "~%(define-primitive-role"))
(format stream " ~A"
(parse-name role) )
(when (superroles role)
(format stream " :parents ~A"
(mapcar #'parse-name (superroles role))))
(when (parse-name (get-inverse-role role))
(format stream " :inverse ~A"
(parse-name (get-inverse-role role))))
(unless (is-top-concept-p (role-domain role))
(format stream " :domain ~A"
(unparse (role-domain role))))
(unless (is-top-concept-p (role-range role))
(format stream " :range ~A"
(unparse (role-range role))))
(if (transitive-p role)
(format stream " :transitive T)")
(format stream ")"))))
(dolist (axiom (get-simple-axioms tbox))
(if (primitive-p axiom)
(format stream "~%(define-primitive-concept ")
(format stream "~%(define-concept "))
(format stream "~A ~A)"
(unparse (left axiom))
(unparse (right axiom))))
(dolist (axiom (get-gcis tbox))
(unless (primitive-p axiom)
(error "Found bad GCI ~A!" axiom))
(format stream "~%(implies ~A ~A)"
(unparse (left axiom))
(unparse (right axiom))))))
| 1,756 | Common Lisp | .lisp | 40 | 33 | 76 | 0.546682 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 160afbe314e856590167a6cab28e6be51933b1395fe9816613f6dca92afa7fe1 | 12,570 | [
-1
] |
12,571 | abox-saturation.lisp | lambdamikel_DLMAPS/src/prover/abox-saturation.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(defrule initial-abox-saturation (dl-with-combined-some-all-rule abox)
;;; das muss so gemacht werden!
;;; Denn sonst ist z.B. die ABOx
;;;
;;; ((instance a (or (all r c) (all r d)))
;;; (related a b r)
;;; (instance b (and (not c) (not d))))
;;;
;;; consistent, wegen combined-some-all-rule-p-
;;; Kopplung
(let ((start-time2 nil))
(labels ((do-it ()
(perform (deterministic-expansion :language-type dl)
(:body
(if clashes
(handle-clashes)
(perform (or-expansion)
(:positive
(if clashes
(handle-clashes)
(do-it)))
(:negative
(unless start-time2 (break "no start time2!"))
(incf *time-spend-in-initial-abox-saturation*
(- (get-internal-run-time)
start-time2))
+insert-body-code+)))))))
#|
;;; geht so nicht, weiteres Markierungsattribut erforderlich
(every #'(lambda (node)
(deactivate-all-nodes abox)
(spreading-activation node)
(if (zerop (1- (no-of-nodes abox)))
(progn
(loop-over-abox-nodes (node abox)
(register-label-is-stable node))
+insert-body-code+)
(let ((*combined-some-all-rule-p* nil))
(perform (abox-enumeration)
(:body
(do-it))
(:after-successful-clash-repair
(do-it))))))
(compute-cluster abox))
|#
(with-strategy (+abox-saturation-strategy+)
(perform (abox-enumeration)
(:body
(setf start-time2 (get-internal-run-time))
(do-it))
(:after-successful-clash-repair
(setf start-time2 (get-internal-run-time))
(do-it)))))))
;;;
;;;
;;;
#|
(defmethod compute-cluster ((abox abox))
;;; fuer demnaechst
(deactivate-all-nodes abox)
(let ((cluster nil))
(loop-over-abox-nodes (node abox)
(unless (active-p node)
(push node cluster)
(spreading-activation node)))
cluster))
(defmethod deactivate-all-nodes ((abox abox))
(loop-over-abox-nodes (node abox)
(when (active-p node)
(deactivate node))))
(defmethod spreading-activation ((node abox-node))
(unless (active-p node)
(activate node)
(dolist (out (outgoing node))
(spreading-activation (to out)))
(dolist (in (incoming node))
(spreading-activation (from in)))))
|#
| 2,939 | Common Lisp | .lisp | 83 | 23.337349 | 70 | 0.503991 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | af296f9809efcb1c32eaebf872a78e97705f654964994b40b1a153d1d4e7d86b | 12,571 | [
-1
] |
12,572 | alchi-prover.lisp | lambdamikel_DLMAPS/src/prover/alchi-prover.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(define-prover ((abox-sat alchi abox))
(:init
(start-main))
(:main
(perform (deterministic-expansion)
(:body
(if clashes
(handle-clashes)
(perform (or-expansion)
(:positive
(if clashes
(handle-clashes)
(restart-main)))
(:negative
(perform (some-expansion)
(:positive
(if clashes
(handle-clashes)
(restart-main)))
(:negative
(success)))))))))
(:success
(completion-found)))
| 713 | Common Lisp | .lisp | 28 | 15.678571 | 60 | 0.464809 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | a6552ee63386be43add35e70819eab327761404cee334a68afd626a70f1df758 | 12,572 | [
-1
] |
12,573 | syntax9.lisp | lambdamikel_DLMAPS/src/prover/syntax9.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(defmacro with-disabled-concept-store (&body body)
`(let ((*use-store-p* nil)
(*cross-referencing-p* nil)
(*insert-into-store-p* nil)
(*create-negated-concept-p* nil))
,@body))
(defmacro with-enabled-concept-store (&body body)
`(let ((*use-store-p* t)
(*insert-into-store-p* t)
(*create-negated-concept-p* t))
,@body))
(defmacro with-lookup-in-concept-store-enabled (&body body)
`(let ((*use-store-p* t)
(*insert-into-store-p* nil)
(*create-negated-concept-p* nil))
,@body))
(defmacro with-protected-concept-store (&body body)
`(let ((*dont-invalidate-store-p* t))
,@body))
;;;
;;;
;;;
(defpersistentclass role (description) ;;; abstrakt
((inverse-role :initform nil :initarg :inverse-role)
(symmetric-role :reader symmetric-role :initform nil :initarg :symmetric-role)
(id :reader id)
(parse-name :reader parse-name :initarg :parse-name :initform nil)
(role-domain :accessor role-domain :initform nil :initarg :role-domain)
(role-range :accessor role-range :initform nil :initarg :role-range)
(superroles :reader superroles :initform nil :initarg :superroles)
(subroles :reader subroles :initform nil :initarg :subroles)
(all-superroles :reader all-superroles :initform nil :initarg :all-superroles)
(all-subroles :reader all-subroles :initform nil :initarg :all-subroles)
(textually-used-p :accessor textually-used-p :initform nil :initarg :textually-used-p)
(rbox :reader rbox :initform nil :initarg :rbox)
(concept-store :reader concept-store :initform nil :initarg :concept-store)
(tbox :reader tbox :initform nil :initarg :tbox)
;;; es gibt komplexe Features! z.B. (and f g)!
(feature-p :reader feature-p :initform nil :initarg :feature-p)))
(defpersistentclass simple-role (role)
((inverse-p :reader inverse-p :initarg :inverse-p :initform nil)
(transitive-p :reader transitive-p :initform nil :initarg :transitive-p)))
;;;
;;;
;;;
(defpersistentclass and/or-role (role) ;;; abstrakt
((arguments :reader arguments :initarg :arguments)))
(defpersistentclass and-role (and/or-role))
(defpersistentclass or-role (and/or-role))
;;;
;;;
;;;
(defmethod inverse-p ((role role))
;;; weil (inv (and r s)) ->
;;; (and (inv r) (inv s))
;;; gewandelt wird!
nil)
(defmethod transitive-p ((role role))
nil)
;;;
;;;
;;;
(defun or-role-p (role)
(typep role 'or-role))
(defun and-role-p (role)
(typep role 'and-role))
(defun simple-role-p (role)
(typep role 'simple-role))
;;;
;;;
;;;
(defmethod print-object ((role role) stream)
(if (feature-p role)
(format stream "#<FEATURE ~A ~A>" (type-of role) (textual-description role))
(format stream "#<~A ~A>" (type-of role) (textual-description role))))
(defmethod print-object ((role simple-role) stream)
(if *print-pretty*
(format stream "~A" (textual-description role))
(call-next-method)))
(defmethod print-object ((role and-role) stream)
(if *print-pretty*
(format stream "(AND~{ ~A~})" (arguments role))
(call-next-method)))
(defmethod print-object ((role or-role) stream)
(if *print-pretty*
(format stream "(OR~{ ~A~})" (arguments role))
(call-next-method)))
;;;
;;;
;;;
(defmethod underspecified-p ((role role) &rest args)
nil)
(defmethod underspecified-p ((role or-role) &rest args)
;;; per Def. hat eine OR-ROLE mind. 2 Argumente! (or r) -> r durch Parser
t)
;;;
;;;
;;;
(defpersistentclass concept (description)
;;; Achtung - die von description geerbten Slots inconsistent, satsifiable, etc.
;;; werden hier als offensichtlich inconsistent, satisfiable etc. gedeutet!
((referenced-by :accessor referenced-by :initform nil :initarg :referenced-by)
(referenced-by-ors :accessor referenced-by-ors :initform nil :initarg :referenced-by-ors)
(referenced-by-ands :accessor referenced-by-ands :initform nil :initarg :referenced-by-ands)
(or-ref-counter :reader or-ref-counter :initform 0)
(and-ref-counter :reader and-ref-counter :initform 0)
(boolean-concept-p :reader boolean-concept-p :initform nil)
(all-atoms)
(all-store-roles)
(marked-p :accessor marked-p :initform nil)
(id :reader id)
(old-p :reader old-p :initarg :old-p)
(negated-concept :reader negated-concept :initform nil :initarg :negated-concept)
(told-subsumers :accessor told-subsumers :initform nil)
(cached-models :reader cached-models :initform nil)
(instance-retrieval-model :accessor instance-retrieval-model :initform nil)
(language :initform nil :initarg :language)
(constructors :accessor constructors :initform nil)
(concept-store :reader concept-store :initform nil :initarg :concept-store)
(tbox :reader tbox :initform nil :initarg :tbox)))
;;;
;;;
;;;
(defmethod reset-sat-status :after ((concept concept))
(with-slots (cached-models instance-retrieval-model) concept
(setf cached-models nil
instance-retrieval-model nil)
(dolist (ref (referenced-by concept))
(when (or (is-some-concept-p ref)
(is-or-concept-p ref)
(is-at-least-concept-p ref)
(is-all-concept-p ref)
(is-at-most-concept-p ref))
(reset-sat-status ref)))))
;;;
;;;
;;;
(defmethod register-concept-model ((concept concept) model)
(with-slots (cached-models) concept
(push model cached-models)
(register-concept-is-satisfiable concept)))
;;;
;;;
;;;
(defun make-weak-hash-table (&rest args)
(let ((table (apply #'make-hash-table args)))
;(hcl:set-hash-table-weak table :key)
table))
(defpersistentclass concept-store ()
((name :reader name :initarg :name)
(prepared-p :reader prepared-p :initform nil)
(tbox :reader tbox :initform nil :initarg :tbox)
(language :initform nil :initarg :language)
(role-hierarchies-p :accessor role-hierarchies-p :initform nil)
(inverse-roles-p :accessor inverse-roles-p :initform nil)
(transitive-roles-p :accessor transitive-roles-p :initform nil)
(features-p :accessor features-p :initform nil)
(complex-roles-p :accessor complex-roles-p :initform nil)
(all-concepts :accessor all-concepts :initform nil)
(all-store-roles :accessor all-store-roles :initform nil)
(atoms :initform (make-weak-hash-table :size 1000 :rehash-size 1000 :test #'equal))
(all-atoms :accessor all-atoms :initform nil)
(positive-atoms :accessor positive-atoms :initform nil)
(negative-atoms :accessor negative-atoms :initform nil)
(ands :initform (make-weak-hash-table :size 10000 :rehash-size 10000 :test #'equal))
(ors :initform (make-weak-hash-table :size 10000 :rehash-size 10000 :test #'equal))
(somes :initform (make-weak-hash-table :size 1000 :rehash-size 1000 :test #'equal))
(alls :initform (make-weak-hash-table :size 1000 :rehash-size 1000 :test #'equal))
(roles :initform (make-weak-hash-table :size 100 :rehash-size 100 :test #'equal))
(at-leasts :initform (make-weak-hash-table :size 1000 :rehash-size 1000 :test #'equal))
(at-mosts :initform (make-weak-hash-table :size 100 :rehash-size 100 :test #'equal))
(id-counter :initform 0 :accessor id-counter)
(role-counter :initform 0 :accessor role-counter)
(constructors :accessor constructors :initform nil)))
(defun make-concept-store (&optional name tbox)
(make-instance 'concept-store
:tbox tbox
:name (or name 'anonymous-store)))
;;;
;;;
;;;
(defmethod reset-sat-status ((store concept-store))
(setf (slot-value store 'prepared-p) nil)
store)
;;;
;;;
;;;
(defmethod print-object ((store concept-store) stream)
(format stream "#<Store ~A>" (name store)))
(defmethod print-store-statistics ((store concept-store))
(with-slots (id-counter all-concepts atoms ands ors somes alls at-leasts at-mosts roles) store
(format t "*** Statistics of concept store ~A:~%
ID COUNTER : ~A
ALL CONCEPTS : ~A
ATOMIC CONCEPTS: ~A
AND CONCEPTS: ~A
OR CONCEPTS: ~A
SOME CONCEPTS: ~A
ALL CONCEPTS: ~A
AT LEAST CONCEPTS: ~A
AT MOST CONCEPTS: ~A
ROLES : ~A~%~%"
store
id-counter
(length all-concepts)
(hash-table-count atoms)
(hash-table-count ands)
(hash-table-count ors)
(hash-table-count somes)
(hash-table-count alls)
(hash-table-count at-leasts)
(hash-table-count at-mosts)
(hash-table-count roles))))
(defun statistics ()
(print-store-statistics *cur-store*))
;;;
;;;
;;;
(defmacro with-concept-store ((store) &body body)
`(with-slots (atoms ands ors somes alls
at-leasts at-mosts roles) ,store
(let ((*cur-store* ,store)
(*atoms-store* atoms)
(*and-store* ands)
(*or-store* ors)
(*some-store* somes)
(*all-store* alls)
(*at-least-store* at-leasts)
(*at-most-store* at-mosts)
(*roles-store* roles))
,@body)))
(defmacro in-concept-store (store)
`(with-slots (atoms ands ors somes alls
at-leasts at-mosts
roles) ,store
(setf *cur-store* ,store)
(setf *atoms-store* atoms
*and-store* ands
*or-store* ors
*some-store* somes
*all-store* alls
*at-least-store* at-leasts
*at-most-store* at-mosts
*roles-store* roles)
*cur-store*))
;;;
;;;
;;;
(defmethod clear-store ((store concept-store))
#+:clim (reset-kinds) ; f. Graph Visualizer
(with-slots (id-counter atoms
all-atoms
positive-atoms
negative-atoms
ands ors somes alls
at-leasts at-mosts roles
all-concepts
inverse-roles-p
transitive-roles-p
features-p
role-hierarchies-p
complex-roles-p
language
) store
(setf id-counter 0)
(clrhash ands)
(clrhash ors)
(clrhash somes)
(clrhash alls)
(clrhash at-leasts)
(clrhash at-mosts)
(clrhash atoms)
(clrhash roles)
(setf positive-atoms nil
negative-atoms nil
all-atoms nil
all-concepts nil
language nil
role-hierarchies-p nil
complex-roles-p nil
inverse-roles-p nil
transitive-roles-p nil
features-p nil))
store)
;;;
;;;
;;;
(defun find-role (description)
(when *use-store-p*
(with-concept-store (*cur-store*)
(gethash description *roles-store*))))
;;;
;;;
;;;
(defun parse-feature (description)
(parse-role description :feature-p t))
(defun parse-role (description &key feature-p textually-used-p)
(labels ((create-role (type description &rest args)
(let ((role
(apply #'make-instance type
:textual-description
description
:old-p *old-concept-p*
:rbox *cur-rbox*
:constructor-sym 'reparse-role
:create-inverse-role-p *create-inverse-role-p*
:allow-other-keys t
args)))
role))
(make-role (description &optional top-level-p)
(unless description
(error "Bad NULL description given to parse-role!"))
(let ((description
(cond ((and *cur-rbox*
(or (symbolp description)
(and (consp description)
(eq 'inv (first description))
;;; weil role in NF -> (second description) ist symbol
(symbolp (get-role *cur-rbox* description))
;;; symbolp, iff inverse rolle in role box verzeichnet
)))
(get-role *cur-rbox* description))
(t description))))
(or (find-role description)
(let ((role
(if (symbolp description)
(create-role 'simple-role
description
:feature-p (and top-level-p feature-p))
(ecase (first description)
(inv
(create-role 'simple-role
description
:feature-p (and top-level-p feature-p)
:inverse-p t))
(or
;; was spricht dagegen??
;; (when feature-p
;; (error "*** BAD FEATURE SYNTAX: ~A" description))
(create-role 'or-role
description
:feature-p (and top-level-p feature-p)
:arguments (mapcar #'make-role (rest description))))
(and
;; was spricht dagegen??
;; (when feature-p
;; (error "*** BAD FEATURE SYNTAX: ~A" description))
(create-role 'and-role
description
:feature-p (and top-level-p feature-p)
:arguments (mapcar #'make-role (rest description))))))))
role))))
(make-role-nf (description &optional inv-p)
;; (princ description) (terpri)
(if (symbolp description)
(cond (*cur-rbox*
(if inv-p
(get-role *cur-rbox* `(inv ,description))
(get-role *cur-rbox* description)))
(t
(if inv-p
`(inv ,description)
description)))
(ecase (first description)
(inv
(make-role-nf (second description)
(if inv-p nil t)))
(or
(let* ((args
(remove-duplicates
(mapcar #'(lambda (x)
(make-role-nf x inv-p))
(rest description))
:test #'equal))
(or-args
(apply #'append
(mapcar #'rest
(remove-if-not #'(lambda (x)
(and (consp x)
(eq (first x) 'or)))
args))))
(atomic-args
(append (sort (remove-if-not #'symbolp args)
#'string-lessp
:key #'symbol-name)
(sort (remove-if-not #'(lambda (x)
(and (consp x)
(eq (first x) 'inv)))
args)
#'string-lessp
:key #'(lambda (x) (symbol-name (second x))))))
(and-args (remove-if-not #'(lambda (x)
(and (consp x)
(eq (first x) 'and)))
args))
(all-args (append atomic-args
or-args
and-args)))
(if (cdr all-args)
(remove nil
`(or
,@atomic-args
,@or-args
,@and-args))
(first all-args))))
(and (let* ((args
(remove-duplicates
(mapcar #'(lambda (x)
(make-role-nf x inv-p))
(rest description))
:test #'equal))
(and-args
(apply #'append
(mapcar #'rest
(remove-if-not #'(lambda (x)
(and (consp x)
(eq (first x) 'and)))
args))))
(or-args
(mapcar #'rest
(remove-if-not #'(lambda (x)
(and (consp x)
(eq (first x) 'or)))
args)))
(atomic-args
(append (sort (remove-if-not #'symbolp args)
#'string-lessp
:key #'symbol-name)
(sort (remove-if-not #'(lambda (x)
(and (consp x)
(eq (first x) 'inv)))
args)
#'string-lessp
:key #'(lambda (x) (symbol-name (second x))))))
(prod (newprod
(append or-args
(mapcar #'list atomic-args)
(mapcar #'list and-args)))))
(if (not (cdr prod))
(if (cdr (first prod))
`(and ,@(first prod))
(first (first prod)))
(if prod
`(or ,@(mapcar #'(lambda (prod)
`(and ,@prod))
prod))
`(and ,@atomic-args ,@and-args)))))))))
(let* ((role
(if (is-role-p description)
description
(make-role (make-role-nf description) t))))
(setf (textually-used-p role)
(or (textually-used-p role)
textually-used-p))
;; einige Inverse werden nur "auf Vorrat" produziert,
;; kommen aber nicht literal in der KB vor ->
;; Problem fuer "get-language"
(if *create-inverse-role-p*
(values role (get-inverse-role role))
role))))
;;;
;;;
;;;
(defmethod initialize-instance :after ((role role) &rest initargs &key dont-initialize-p)
(unless dont-initialize-p
(with-concept-store (*cur-store*)
(push role (all-store-roles *cur-store*))
(setf (slot-value role 'id) (incf (role-counter *cur-store*)))
(register-name-for-role role (textual-description role))
(setf (slot-value role 'tbox) (tbox *cur-store*))
(setf (slot-value role 'concept-store) *cur-store*))))
(defmethod register-name-for-role ((role role) name)
(setf (gethash name *roles-store*) role))
;;;
;;;
;;;
(defmethod prepare ((store concept-store) (dl dl))
(with-slots (prepared-p
all-concepts) store
(unless prepared-p
(dolist (concept all-concepts)
(reset-sat-status concept))
(compute-language store))
store))
(defmethod compute-language ((store concept-store))
(with-slots (language
prepared-p
all-store-roles
role-hierarchies-p
inverse-roles-p
complex-roles-p
transitive-roles-p
features-p
all-concepts
constructors) store
(setf constructors nil
role-hierarchies-p nil
inverse-roles-p nil
complex-roles-p nil
transitive-roles-p nil
features-p nil)
(dolist (c all-concepts)
(dolist (c (constructors c))
(pushnew c (constructors *cur-store*))))
(dolist (role all-store-roles)
(let ((inv-role (get-inverse-role role)))
(when (textually-used-p role)
(when (is-and/or-role-p role)
(setf complex-roles-p t))
(when (superroles role)
(setf role-hierarchies-p t))
(when (textually-used-p inv-role)
(setf inverse-roles-p t))
(when (transitive-p role)
(setf transitive-roles-p t))
(when (feature-p role)
(setf features-p t)))))
(setf prepared-p t)
(with-concept-store (store)
(let* ((constructors (constructors store))
(inverse-roles-p (inverse-roles-p store))
(transitive-roles-p (transitive-roles-p store))
(features-p (features-p store))
(complex-roles-p (complex-roles-p store))
(role-hierarchies-p (role-hierarchies-p store))
(i inverse-roles-p)
(f features-p)
(n (or (member 'unqualified-at-least constructors)
(member 'unqualified-at-most constructors)))
(q (or (member 'qualified-at-least constructors)
(member 'qualified-at-most constructors)))
(r transitive-roles-p))
(declare (ignorable role-hierarchies-p))
(setf language
(if (or complex-roles-p q)
(to-be-implemented 'dl)
(if i
(if r
(if f
(if n
+alchifn-rplus+
+alchif-rplus+)
(if n
+alchifn-rplus+
+alchi-rplus+))
(if f
(if n
+alchifn-rplus+
+alchif-rplus+)
(if n
+alchifn-rplus+
+alchi+)))
(if r
(if f
(if n
+alchfn-rplus+
+alchf-rplus+)
(if n
+alchfn-rplus+
+alchf-rplus+))
(if f
(if n
+alchfn-rplus+
+alchf+)
(if n
+alchn+
+alch+))))))))
store))
;;;
;;;
;;;
(defmethod register-inverses ((role role) (inv-role role))
(setf (slot-value role 'inverse-role) inv-role
(slot-value inv-role 'inverse-role) role))
(defmethod get-inverse-role ((role role))
(or (slot-value role 'inverse-role)
(when *create-inverse-role-p*
(let* ((*create-inverse-role-p* nil)
(inv-role
(parse-role (list 'inv (textual-description role)))))
(register-inverses role inv-role)
inv-role))))
;;;
;;;
;;;
(defmethod implies-p ((i role) (j role) &rest args)
;;; fängt alle nicht spezifizierten Fälle ab
nil)
;;;
;;;
;;;
(defmethod implies-p ((i simple-role) (j simple-role) &rest args)
(or (eq i j)
#|
(equal (textual-description i)
(textual-description j))
(some #'(lambda (j)
(implies-p i j))
(subroles j)) |#
(member j (all-superroles i))))
(defmethod implies-p ((i simple-role) (j or-role) &rest args)
(some #'(lambda (j)
(implies-p i j))
(arguments j)))
(defmethod implies-p ((i simple-role) (j and-role) &rest args)
(every #'(lambda (j)
(implies-p i j))
(arguments j)))
;;;
;;;
;;;
(defmethod implies-p ((i or-role) (j or-role) &rest args)
(every #'(lambda (i)
(implies-p i j))
(arguments i)))
(defmethod implies-p ((i or-role) (j and-role) &rest args)
(every #'(lambda (j)
(implies-p i j))
(arguments j)))
;;;
;;;
;;;
(defmethod implies-p ((i and-role) (j simple-role) &rest args)
(some #'(lambda (i)
(implies-p i j))
(arguments i)))
(defmethod implies-p ((i and-role) (j and-role) &rest args)
(every #'(lambda (j)
(implies-p i j))
(arguments j)))
(defmethod implies-p ((i and-role) (j or-role) &rest args)
(some #'(lambda (j)
(implies-p i j))
(arguments j)))
;;;
;;;
;;;
(defpersistentclass atomic-concept (concept)
((name :reader name :initarg :name)
(boolean-concept-p :initform t)
(primitive-p :accessor primitive-p :initform nil)
(cyclic-p :accessor cyclic-p :initform nil) ; f. blocking
(ts-cyclic-p :accessor ts-cyclic-p :initform nil) ; f. Told Subsumer Bestimmung!
(negated-p :accessor negated-p :initform nil :initarg :negated-p)
(references-atoms :accessor references-atoms :initform nil
:initarg :references-atoms)
(constructors :initform '(atoms))))
(defpersistentclass top-concept (atomic-concept)
((boolean-concept-p :initform t)
;; denn TOP => ... -Axiome sind immer GCIs!
(inconsistent :initform nil)
(satisfiable :initform t)
(tautological :initform t)
(negated-p :initform nil)
(name :initform 'top)
(constructors :initform '(top))))
(defpersistentclass bottom-concept (atomic-concept)
((boolean-concept-p :initform t)
(inconsistent :initform t)
(satisfiable :initform nil)
(tautological :initform nil)
(negated-p :initform nil)
(name :initform 'bottom)
(constructors :initform '(bottom))))
;;;
;;;
;;;
(defpersistentclass and/or-concept (concept)
((arguments :reader arguments :initarg :arguments)
(arg-counter :reader arg-counter)
(atomic-arguments :reader atomic-arguments)))
;;;
;;;
;;;
(defun no-of-atoms ()
(hash-table-count *atoms-store*))
(defun no-of-ands ()
(hash-table-count *and-store*))
(defun no-of-ors ()
(hash-table-count *or-store*))
(defun no-of-somes ()
(hash-table-count *some-store*))
(defun no-of-alls ()
(hash-table-count *all-store*))
(defun no-of-at-leasts ()
(hash-table-count *at-least-store*))
(defun no-of-at-mosts ()
(hash-table-count *at-most-store*))
(defun no-of-concepts ()
(+ (no-of-atoms)
(no-of-ands)
(no-of-ors)
(no-of-somes)
(no-of-alls)
(no-of-at-leasts)
(no-of-at-mosts)))
;;;
;;;
;;;
(defpersistentclass and-concept (and/or-concept)
((modal-successor-sets :reader modal-successor-sets :initform nil)
(constructors :initform '(and))))
(defpersistentclass or-concept (and/or-concept)
((constructors :initform '(or))))
(defpersistentclass some/all-concept (concept)
((role :reader role :initarg :role)
(qualification :reader qualification :initarg :qualification)
(boolean-concept-p :initform nil)))
(defpersistentclass some-concept (some/all-concept))
(defpersistentclass attribute-exists-concept (some-concept))
#|
(defpersistentclass concrete-attribute-exists-concept (concept))
|#
(defpersistentclass at-least/most-concept (some/all-concept)
((n :reader n :initarg :n)))
(defpersistentclass at-least-concept (at-least/most-concept))
(defpersistentclass at-most-concept (at-least/most-concept))
(defpersistentclass all-concept (some/all-concept))
;;;
;;;
(defmethod reset-sat-status :after ((concept and-concept))
(with-slots (arguments) concept
(dolist (arg arguments)
(reset-sat-status arg))))
;;;
;;;
;;;
(defmethod initialize-instance :after ((concept concept) &rest initargs &key dont-initialize-p)
(unless dont-initialize-p
(setf (slot-value concept 'id) (incf (id-counter *cur-store*)))
(setf (slot-value concept 'tbox) (tbox *cur-store*))
(setf (slot-value concept 'concept-store) *cur-store*)
(when *insert-into-store-p*
(insert-into-store concept))))
(defmethod initialize-instance :after ((concept and/or-concept) &rest initargs &key dont-initialize-p)
(unless dont-initialize-p
(setf (slot-value concept 'atomic-arguments)
(remove-if-not #'is-atomic-concept-p (arguments concept))
(slot-value concept 'boolean-concept-p)
(every #'boolean-concept-p (arguments concept))
(constructors concept)
(delete-duplicates (reduce #'append (mapcar #'constructors (arguments concept))))
(slot-value concept 'arg-counter)
(length (arguments concept)))))
(defmethod initialize-instance :after ((concept and-concept) &rest initargs &key dont-initialize-p)
(unless dont-initialize-p
(when *syntactic-consistency-checking-p*
(when *syntactic-consistency-checking-of-some/all-conjuncts-p*
(setf (slot-value concept 'modal-successor-sets)
(let* ((args (arguments concept))
(alls (remove-if-not #'is-all-concept-p args))
(somes (remove-if-not #'is-some-concept-p args))
(res nil))
(dolist (some somes)
(let* ((role (role some))
(alls (loop as all in alls when
(eq (role all) role)
collect all))
(concept (make-and-concept
(list (qualification some)
(mapcar #'qualification alls)))))
(push (list role alls somes concept) res)))
res)))
(check-if-obviously-inconsistent-p concept))))
(defmethod initialize-instance :after ((concept or-concept) &rest initargs &key dont-initialize-p)
(unless dont-initialize-p
(when *syntactic-consistency-checking-p*
(check-if-obviously-inconsistent-p concept))))
(defmethod initialize-instance :after ((concept some-concept) &rest initargs &key dont-initialize-p)
(unless dont-initialize-p
(when *syntactic-consistency-checking-p*
(check-if-obviously-inconsistent-p concept))
(setf (constructors concept)
(remove-duplicates
(cons (if (is-top-concept-p (qualification concept))
'unqualified-some
'qualified-some)
(constructors (qualification concept)))))))
(defmethod initialize-instance :after ((concept all-concept) &rest initargs &key dont-initialize-p)
(unless dont-initialize-p
(when *syntactic-consistency-checking-p*
(check-if-obviously-inconsistent-p concept))
(setf (constructors concept)
(remove-duplicates
(cons 'all
(constructors (qualification concept)))))))
(defmethod initialize-instance :after ((concept at-least-concept) &rest initargs &key dont-initialize-p)
(unless dont-initialize-p
(when *syntactic-consistency-checking-p*
(check-if-obviously-inconsistent-p concept))
(setf (constructors concept)
(remove-duplicates
(cons (if (is-top-concept-p (qualification concept))
'unqualified-at-least
'at-least)
(constructors (qualification concept)))))))
(defmethod initialize-instance :after ((concept at-most-concept) &rest initargs &key dont-initialize-p)
(unless dont-initialize-p
(when *syntactic-consistency-checking-p*
(check-if-obviously-inconsistent-p concept))
(setf (constructors concept)
(remove-duplicates
(cons (if (is-top-concept-p (qualification concept))
'unqualified-at-most
'at-most)
(constructors (qualification concept)))))))
;;;
;;;
;;;
(defun order (args)
(sort args #'< :key #'id))
(defmethod insert-into-store ((concept concept))
t)
(defmethod insert-into-store :after ((concept concept))
(unless *dont-invalidate-store-p*
;;; wird nur invalidiert, wenn
;;; der Prover nicht laeuft, sonst ewiges
;;; reprepare, es werden ja temporaere Konzepte
;;; angelegt beim Beweisen! aber die Sprache
;;; aendert sich dann nciht mehr!
(reset-sat-status *cur-store*))
(push concept (all-concepts *cur-store*)))
(defmethod insert-into-store ((concept atomic-concept))
(setf (gethash (original-description concept) *atoms-store*) concept)
(push concept (all-atoms (concept-store concept)))
(if (negated-p concept)
(push concept (negative-atoms (concept-store concept)))
(push concept (positive-atoms (concept-store concept)))))
(defmethod insert-into-store ((concept and-concept))
(let ((args (arguments concept)))
(setf (gethash (arguments concept) *and-store*) concept)
(when *cross-referencing-p*
(mapc #'(lambda (arg)
(pushnew concept (referenced-by arg))
(unless (member concept (referenced-by-ands arg))
(incf (slot-value arg 'and-ref-counter))
(push concept (referenced-by-ands arg))))
args))))
(defmethod insert-into-store ((concept or-concept))
(let ((args (arguments concept)))
(setf (gethash (arguments concept) *or-store*) concept)
(when *cross-referencing-p*
(mapc #'(lambda (arg)
(pushnew concept (referenced-by arg))
(unless (member concept (referenced-by-ors arg))
(incf (slot-value arg 'or-ref-counter))
(push concept (referenced-by-ors arg))))
args))))
(defmethod insert-into-store ((concept some-concept))
(let ((qual (qualification concept)))
(when *cross-referencing-p*
(push concept (referenced-by qual)))
(setf (gethash (list (role concept) qual) *some-store*) concept)))
(defmethod insert-into-store ((concept all-concept))
(let ((qual (qualification concept)))
(when *cross-referencing-p*
(push concept (referenced-by qual)))
(setf (gethash (list (role concept) qual) *all-store*) concept)))
(defmethod insert-into-store ((concept at-least-concept))
(let ((qual (qualification concept))
(n (n concept)))
(when *cross-referencing-p*
(push concept (referenced-by qual)))
(setf (gethash (list n (role concept) qual) *at-least-store*) concept)))
(defmethod insert-into-store ((concept at-most-concept))
(let ((qual (qualification concept))
(n (n concept)))
(when *cross-referencing-p*
(push concept (referenced-by qual)))
(setf (gethash (list n (role concept) qual) *at-most-store*) concept)))
;;;
;;;
;;;
(defmethod print-object ((concept atomic-concept) stream)
(if *print-pretty*
(if (negated-p concept)
(format stream "(NOT ~A)" (name concept))
(format stream "~A" (name concept)))
(if (negated-p concept)
(format stream "#<(NOT ~A|~A)>" (name concept) (id concept))
(format stream "#<~A|~A>" (name concept) (id concept)))))
(defmethod print-object ((concept top-concept) stream)
(if *print-pretty*
(format stream "TOP")
(format stream "#<TOP>")))
(defmethod print-object ((concept bottom-concept) stream)
(if *print-pretty*
(format stream "BOTTOM")
(format stream "#<BOTTOM>")))
(defmethod print-object ((concept and-concept) stream)
(if *print-pretty*
(format stream "(AND~{ ~A~})" (arguments concept))
(format stream "#<(AND~{ ~A~}|~A)>" (arguments concept) (id concept))))
(defmethod print-object ((concept or-concept) stream)
(if *print-pretty*
(format stream "(OR~{ ~A~})" (arguments concept))
(format stream "#<(OR~{ ~A~}|~A)>" (arguments concept) (id concept))))
(defmethod print-object ((concept some-concept) stream)
(if *print-pretty*
(format stream "(SOME ~A ~A)" (role concept) (qualification concept))
(format stream "#<(SOME ~A ~A)|~A>" (role concept) (qualification concept) (id concept))))
(defmethod print-object ((concept all-concept) stream)
(if *print-pretty*
(format stream "(ALL ~A ~A)" (role concept) (qualification concept))
(format stream "#<(ALL ~A ~A)|~A>" (role concept) (qualification concept) (id concept))))
(defmethod print-object ((concept at-least-concept) stream)
(if *print-pretty*
(format stream "(AT-LEAST ~A ~A ~A)" (n concept) (role concept) (qualification concept))
(format stream "#<(AT-LEAST ~A ~A ~A)|~A>" (n concept) (role concept) (qualification concept) (id concept))))
(defmethod print-object ((concept at-most-concept) stream)
(if *print-pretty*
(format stream "(AT-MOST ~A ~A ~A)" (n concept) (role concept) (qualification concept))
(format stream "#<(AT-MOST ~A ~A ~A)|~A>" (n concept) (role concept) (qualification concept) (id concept))))
;;;
;;;
;;;
(defmethod unparse ((item null))
nil)
(defmethod unparse ((item cons))
(cons (unparse (car item))
(unparse (cdr item))))
(defmethod unparse ((role role))
(let ((*print-pretty* t)
(*package* (find-package :prover)))
(if (not (inverse-p role))
(read-from-string
(format nil "|~A|" (print-object role nil)))
`(inv ,(unparse (slot-value role 'inverse-role))))))
(defmethod unparse ((concept concept))
(let ((*print-pretty* t)
(*package* (find-package :prover)))
(read-from-string
(format nil "|~A|" (print-object concept nil)))))
;;;
;;;
;;;
(defmethod get-negated-description ((concept concept))
(get-negated-concept concept))
;;;
;;;
;;;
(defmethod get-negated-concept :around ((concept concept))
(with-concept-store ((concept-store concept))
(let ((*create-negated-concept-p* nil))
(call-next-method))))
(defmethod get-negated-concept ((concept bottom-concept))
(or (negated-concept concept)
(register-duals
(make-top-concept)
concept)))
(defmethod get-negated-concept ((concept top-concept))
(or (negated-concept concept)
(register-duals
(make-bottom-concept)
concept)))
(defmethod get-negated-concept ((concept atomic-concept))
(or (negated-concept concept)
(register-duals
(make-atomic-concept (if (negated-p concept)
(name concept)
`(not ,(name concept))))
concept)))
(defmethod get-negated-concept ((concept and-concept))
(or (negated-concept concept)
(register-duals
(make-or-concept (mapcar #'get-negated-concept
(arguments concept)))
concept)))
(defmethod get-negated-concept ((concept or-concept))
(or (negated-concept concept)
(register-duals
(make-and-concept (mapcar #'get-negated-concept
(arguments concept)))
concept)))
(defmethod get-negated-concept ((concept some-concept))
(or (negated-concept concept)
(register-duals
(make-all-concept
(role concept)
(get-negated-concept (qualification concept)))
concept)))
(defmethod get-negated-concept ((concept all-concept))
(or (negated-concept concept)
(register-duals
(make-some-concept
(role concept)
(get-negated-concept (qualification concept)))
concept)))
(defmethod get-negated-concept ((concept at-least-concept))
(or (negated-concept concept)
(register-duals
(make-at-most-concept
(1- (n concept))
(role concept)
(qualification concept))
concept)))
(defmethod get-negated-concept ((concept at-most-concept))
(or (negated-concept concept)
(register-duals
(make-at-least-concept
(1+ (n concept))
(role concept)
(qualification concept))
concept)))
;;;
;;;
;;;
(defun register-duals (cona conb)
(setf (slot-value cona 'negated-concept) conb
(slot-value conb 'negated-concept) cona)
cona)
;;;
;;;
;;;
(defun find-atomic-concept (expr)
(when *use-store-p*
(gethash expr *atoms-store*)))
(defun find-and-concept (args)
(when *use-store-p*
(gethash args *and-store*)))
(defun find-or-concept (args)
(when *use-store-p*
(gethash args *or-store*)))
(defun find-some-concept (role qual)
(when *use-store-p*
(gethash (list role qual) *some-store*)))
(defun find-all-concept (role qual)
(when *use-store-p*
(gethash (list role qual) *all-store*)))
(defun find-at-least-concept (n role qual)
(when *use-store-p*
(gethash (list n role qual) *at-least-store*)))
(defun find-at-most-concept (n role qual)
(when *use-store-p*
(gethash (list n role qual) *at-most-store*)))
;;;
;;;
;;;
(defun make-top-concept ()
(with-concept-store (*cur-store*)
(let ((concept (or (find-atomic-concept 'top)
(make-instance 'top-concept
:original-description 'top
:old-p *old-concept-p*))))
(if *create-negated-concept-p*
(values concept
(get-negated-concept concept))
concept))))
(defun make-bottom-concept ()
(with-concept-store (*cur-store*)
(let ((concept (or (find-atomic-concept 'bottom)
(make-instance 'bottom-concept
:original-description 'bottom
:old-p *old-concept-p*))))
(if *create-negated-concept-p*
(values concept
(get-negated-concept concept))
concept))))
;;;
;;;
;;;
(defun make-not-concept (arg)
(unless (get-negated-concept arg)
(error "Can't get negated concept of ~A!" arg))
(values (negated-concept arg)
arg))
(defun make-atomic-concept (expr)
(with-concept-store (*cur-store*)
(if (atomic-concept*-p expr)
(let ((concept (or (find-atomic-concept expr)
(make-instance 'atomic-concept
:original-description expr
:name (if (symbolp expr)
expr
(second expr))
:old-p *old-concept-p*
:negated-p
(if (symbolp expr)
nil
(and (consp expr)
(not (cddr expr))
(eq (first expr) 'not)))))))
(if *create-negated-concept-p*
(values concept
(get-negated-concept concept))
concept))
(error "Bad concept: ~A!" expr))))
(defun make-and-concept (args)
(with-concept-store (*cur-store*)
(if (every #'is-concept-p args)
(let ((fargs nil))
(dolist (arg args)
(unless (is-top-concept-p arg)
(if (is-and-concept-p arg)
(dolist (arg (arguments arg))
(unless (is-top-concept-p arg)
(push arg fargs)))
(push arg fargs))))
(let ((args (order (remove-duplicates fargs))))
(if (not args)
(make-top-concept)
(if (cdr args)
(let ((concept
(or (find-and-concept args)
(make-instance 'and-concept
:original-description `(and ,@args)
:old-p *old-concept-p*
:arguments args))))
(if *create-negated-concept-p*
(values concept
(get-negated-concept concept))
concept))
(if *create-negated-concept-p*
(values (first args)
(get-negated-concept (first args)))
(first args))))))
(error "Bad concept: (AND ~A)!" args))))
(defun make-or-concept (args)
(with-concept-store (*cur-store*)
(if (every #'is-concept-p args)
(let ((fargs nil))
(dolist (arg args)
(unless (is-bottom-concept-p arg)
(if (is-or-concept-p arg)
(dolist (arg (arguments arg))
(unless (is-bottom-concept-p arg)
(push arg fargs)))
(push arg fargs))))
(let ((args (order (remove-duplicates fargs))))
(if (not args)
(make-bottom-concept)
(if (cdr args)
(let ((concept
(or (find-or-concept args)
(make-instance 'or-concept
:original-description `(or ,@args)
:old-p *old-concept-p*
:arguments args))))
(if *create-negated-concept-p*
(values concept
(get-negated-concept concept))
concept))
(if *create-negated-concept-p*
(values (first args)
(get-negated-concept (first args)))
(first args))))))
(error "Bad concept: (OR ~A)!" args))))
(defun make-some-concept (role qualification)
(with-concept-store (*cur-store*)
(if (and (typep role 'role)
(typep qualification 'concept))
(let ((concept
(or (find-some-concept role qualification)
(make-instance (if (feature-p role)
'attribute-exists-concept
'some-concept)
:original-description `(some ,role ,qualification)
:role role
:old-p *old-concept-p*
:qualification qualification))))
(if *create-negated-concept-p*
(values concept
(get-negated-concept concept))
concept))
(error "Bad concept: (SOME ~A ~A)!" role qualification))))
(defun make-all-concept (role qualification)
(with-concept-store (*cur-store*)
(if (and (typep role 'role)
(typep qualification 'concept))
(let ((concept
(or (find-all-concept role qualification)
(make-instance 'all-concept
:original-description `(all ,role ,qualification)
:role role
:old-p *old-concept-p*
:qualification qualification))))
(if *create-negated-concept-p*
(values concept
(get-negated-concept concept))
concept))
(error "Bad concept: (ALL ~A ~A)!" role qualification))))
(defun make-at-least-concept (n role qualification)
(with-concept-store (*cur-store*)
(if (and (typep role 'role)
(integerp n)
(not (minusp n))
(typep qualification 'concept))
(cond ((zerop n)
(make-top-concept))
((zerop (1- n))
(make-some-concept role qualification))
(t
(let ((concept
(or (find-at-least-concept n role qualification)
(make-instance 'at-least-concept
:old-p *old-concept-p*
:original-description `(at-least ,n ,role ,qualification)
:role role
:n n
:qualification qualification))))
(if *create-negated-concept-p*
(values concept
(get-negated-concept concept))
concept))))
(error "Bad concept: (AT-LEAST ~A ~A ~A)!" n role qualification))))
(defun make-at-most-concept (n role qualification)
(with-concept-store (*cur-store*)
(if (and (typep role 'role)
(integerp n)
(not (minusp n))
(typep qualification 'concept))
(cond ((zerop n)
(make-all-concept role (get-negated-concept qualification)))
(t
(let ((concept
(or (find-at-most-concept n role qualification)
(make-instance 'at-most-concept
:old-p *old-concept-p*
:original-description `(at-most ,n ,role ,qualification)
:role role
:n n
:qualification qualification))))
(if *create-negated-concept-p*
(values concept
(get-negated-concept concept))
concept))))
(error "Bad concept: (AT-MOST ~A ~A ~A)!" n role qualification))))
;;;
;;;
;;;
(defun atomic-concept*-p (term)
(or (symbolp term)
(and (consp term)
(eq (first term) 'not)
(symbolp (second term)))))
(defun top-concept*-p (concept)
(or (eq concept 'top)
(eq concept '*top*)
(eq concept '+top+)
(eq concept t)))
(defun bottom-concept*-p (concept)
(or (eq concept 'bottom)
(eq concept 'bot)
(eq concept '*bot*)
(eq concept '+bot+)
(eq concept '*bottom*)
(eq concept nil)))
(defun all-concept*-p (concept)
(and (consp concept)
(eq (first concept) 'all)
(cddr concept)
(not (cdddr concept))))
(defun at-least-concept*-p (concept)
(and (consp concept)
(eq (first concept) 'at-least)
;; (cdddr concept)
(not (cddddr concept))))
(defun at-most-concept*-p (concept)
(and (consp concept)
(eq (first concept) 'at-most)
;; (cdddr concept)
(not (cddddr concept))))
(defun exactly-concept*-p (concept)
(and (consp concept)
(eq (first concept) 'exactly)
;; (cdddr concept)
(not (cddddr concept))))
(defun or-concept*-p (concept)
(and (consp concept)
(eq (first concept) 'or)))
(defun and-concept*-p (concept)
(and (consp concept)
(eq (first concept) 'and)))
(defun implies-concept*-p (concept)
(and (consp concept)
(eq (first concept) '=>)
(cddr concept)
(not (cdddr concept))))
(defun implied-by-concept*-p (concept)
(and (consp concept)
(eq (first concept) '<=)
(cddr concept)
(not (cdddr concept))))
(defun equivalent-concept*-p (concept)
(and (consp concept)
(eq (first concept) '<=>)
(cddr concept)
(not (cdddr concept))))
(defun some-concept*-p (concept)
(and (consp concept)
(eq (first concept) 'some)
(cddr concept)
(not (cdddr concept))))
(defun cd-concept*-p (concept)
(and (consp concept)
(let ((op (first concept)))
(member op '(a an no string= string<> min max < > <= >= =)))))
;;;
;;;
;;;
(defun flatten (concept)
(if (consp concept)
(let ((op (first concept)))
(case op
((and or => <= <=>)
(if (and (consp concept)
(null (cddr concept)))
(flatten (second concept))
`(,op ,@(remove-duplicates
(mapcan #'(lambda (x)
(let ((res (flatten x)))
(if (and (consp res)
(eq (first res) op))
(rest res)
(list res))))
(rest concept))))))
((some all)
`(,op ,(second concept)
,(flatten (third concept))))
((at-least at-most exactly)
`(,op ,(second concept)
,(third concept)
,(flatten (fourth concept))))
(not
`(,op ,(flatten (second concept))))))
concept))
(defun parse-concept (concept)
(labels ((do-it (concept)
(cond ((top-concept*-p concept)
(make-top-concept))
((bottom-concept*-p concept)
(make-bottom-concept))
((and (consp concept) ;;; wichtig! reihenfolge!
(eq (first concept) 'not))
(make-not-concept (do-it (second concept))))
((atomic-concept*-p concept)
(make-atomic-concept concept))
((and-concept*-p concept)
(make-and-concept (mapcar #'do-it (rest concept))))
((or-concept*-p concept)
(make-or-concept (mapcar #'do-it (rest concept))))
((some-concept*-p concept)
(make-some-concept (parse-role (second concept)
:textually-used-p t)
(do-it (third concept))))
((all-concept*-p concept)
(make-all-concept (parse-role (second concept)
:textually-used-p t)
(do-it (third concept))))
((at-least-concept*-p concept)
(make-at-least-concept (second concept)
(parse-role (third concept)
:textually-used-p t)
(if (fourth concept)
(do-it (fourth concept))
(make-top-concept))))
((at-most-concept*-p concept)
(make-at-most-concept (second concept)
(parse-role (third concept)
:textually-used-p t)
(if (fourth concept)
(do-it (fourth concept))
(make-top-concept))))
((exactly-concept*-p concept)
(do-it `(and (at-least ,@(rest concept))
(at-most ,@(rest concept)))))
;;; =>, <=, <=>
((implies-concept*-p concept)
(make-or-concept (list (make-not-concept (do-it (second concept)))
(do-it (third concept)))))
((implied-by-concept*-p concept)
(make-or-concept (list (make-not-concept (do-it (third concept)))
(do-it (second concept)))))
((equivalent-concept*-p concept)
(make-and-concept
(list (make-or-concept (list (make-not-concept (do-it (second concept)))
(do-it (third concept))))
(make-or-concept (list (make-not-concept (do-it (third concept)))
(do-it (second concept)))))))
;;; RacerPro Dummies
((cd-concept*-p concept)
(make-top-concept))
;;;
;;;
;;
(t (error "Unable to parse ~A!" concept)))))
(if (is-concept-p concept)
concept
(let ((concept (do-it concept)))
(if *syntactic-consistency-checking-p*
(cond ((check-if-obviously-inconsistent-p concept)
(make-bottom-concept))
((check-if-obviously-tautological-p concept)
(make-top-concept))
(t concept))
concept)))))
;;;
;;;
;;;
(defmethod check-if-obviously-inconsistent-p :around ((concept concept))
(when *syntactic-consistency-checking-p*
(when (eq (slot-value concept 'inconsistent) :not-tested)
(let ((res (call-next-method)))
(when res ;; Achtung - der Algorithmus ist unvollstaendig!
(setf (slot-value concept 'inconsistent) t)
(setf (slot-value concept 'satisfiable) nil)
(setf (slot-value concept 'tautological) nil)))))
(eq (slot-value concept 'inconsistent) t))
(defmethod check-if-obviously-inconsistent-p ((concept bottom-concept))
t)
(defmethod check-if-obviously-inconsistent-p ((concept top-concept))
nil)
(defmethod check-if-obviously-inconsistent-p ((concept atomic-concept))
nil)
(defmethod check-if-obviously-inconsistent-p ((concept and-concept))
(or (some #'check-if-obviously-inconsistent-p (arguments concept))
(some #'(lambda (atom)
(member (get-negated-concept atom)
(atomic-arguments concept)))
(atomic-arguments concept))
(some #'(lambda (modal-set)
(check-if-obviously-inconsistent-p (fourth modal-set)))
(modal-successor-sets concept))))
(defmethod check-if-obviously-inconsistent-p ((concept or-concept))
(every #'check-if-obviously-inconsistent-p (arguments concept)))
(defmethod check-if-obviously-inconsistent-p ((concept some-concept))
(check-if-obviously-inconsistent-p (qualification concept)))
(defmethod check-if-obviously-inconsistent-p ((concept all-concept))
nil)
(defmethod check-if-obviously-inconsistent-p ((concept at-least-concept))
(check-if-obviously-inconsistent-p (qualification concept)))
(defmethod check-if-obviously-inconsistent-p ((concept at-most-concept))
nil)
;;;
;;;
;;;
(defmethod check-if-obviously-tautological-p :around ((concept concept))
(when *syntactic-consistency-checking-p*
(when (eq (slot-value concept 'tautological) :not-tested)
(let ((res (call-next-method)))
(when res
(setf (slot-value concept 'tautological) t)
(setf (slot-value concept 'satisfiable) t)
(setf (slot-value concept 'inconsistent) nil)))))
(eq (slot-value concept 'tautological) t))
(defmethod check-if-obviously-tautological-p ((concept concept))
(check-if-obviously-inconsistent-p (get-negated-concept concept)))
;;;
;;;
;;;
(defmethod already-known-to-be-inconsistent-p ((concept concept))
(eq (slot-value concept 'inconsistent) t))
(defmethod already-known-to-be-tautological-p ((concept concept))
(eq (slot-value concept 'tautological) t))
(defmethod already-known-to-be-satisfiable-p ((concept concept))
(eq (slot-value concept 'satisfiable) t))
;;;
;;;
;;;
(defmethod register-concept-is-satisfiable ((concept concept))
(unless (already-known-to-be-satisfiable-p concept)
(with-slots (inconsistent satisfiable tautological) concept
(setf inconsistent nil
satisfiable t
tautological :not-tested)
(dolist (ref (referenced-by concept))
(when (or (is-some-concept-p ref)
(is-or-concept-p ref)
(is-at-least-concept-p ref)
(is-all-concept-p ref)
(is-at-most-concept-p ref))
(register-concept-is-satisfiable ref))))))
(defmethod register-concept-is-satisfiable :after ((concept and-concept))
(with-slots (arguments) concept
(dolist (arg arguments)
(register-concept-is-satisfiable arg))))
;;;
;;;
;;;
(defmethod register-concept-is-inconsistent ((concept concept))
(unless (already-known-to-be-inconsistent-p concept)
(with-slots (inconsistent satisfiable tautological) concept
(setf inconsistent t
satisfiable nil
tautological :not-tested)
(dolist (ref (referenced-by-ands concept))
(register-concept-is-inconsistent ref))
(dolist (ref (referenced-by concept))
(when (or (is-some-concept-p ref)
(is-at-least-concept-p ref))
(register-concept-is-inconsistent ref))))
(register-concept-is-satisfiable (get-negated-concept concept))))
(defmethod register-concept-is-inconsistent :after ((concept or-concept))
(with-slots (arguments) concept
(dolist (arg arguments)
(register-concept-is-inconsistent arg))))
;;;
;;;
(defmethod transitive-p ((all-concept all-concept))
(transitive-p (role all-concept)))
;;;
;;;
;;;
(defun scramble-ids ()
(when *cur-store*
(with-slots (atoms ands ors somes alls id-counter) *cur-store*
(let ((ids (reorder (loop as i from 0 to id-counter collect i))))
(dolist (slot '(atoms ands ors somes alls))
(let ((table (slot-value *cur-store* slot)))
(loop as concept being the hash-value of table do
(setf (slot-value concept 'id)
(pop ids))
(unless ids
(error "!")))))
(princ ids)))))
;;;
;;;
;;;
(defmethod get-all-atoms :around ((concept concept))
(if (slot-boundp concept 'all-atoms)
(slot-value concept 'all-atoms)
(setf (slot-value concept 'all-atoms)
(call-next-method))))
(defmethod get-all-atoms ((concept top-concept))
(list concept))
(defmethod get-all-atoms ((concept bottom-concept))
(list concept))
(defmethod get-all-atoms ((concept atomic-concept))
(list concept))
(defmethod get-all-atoms ((concept and/or-concept))
(let ((res nil))
(loop as arg in (arguments concept) do
(if (is-atomic-concept-p arg)
(push arg res)
(dolist (arg (get-all-atoms arg))
(push arg res))))
(remove-duplicates res)))
(defmethod get-all-atoms ((concept some/all-concept))
(get-all-atoms (qualification concept)))
;;;
;;;
;;;
(defmethod get-all-roles :around ((concept concept))
(if (slot-boundp concept 'all-store-roles) ; auch die features etc.
(slot-value concept 'all-store-roles)
(setf (slot-value concept 'all-store-roles)
(call-next-method))))
(defmethod get-all-roles ((concept atomic-concept))
nil)
(defmethod get-all-roles ((concept some/all-concept))
(cons (role concept)
(get-all-roles (qualification concept))))
(defmethod get-all-roles ((concept and/or-concept))
(let ((res nil))
(loop as arg in (arguments concept) do
(dolist (role (get-all-roles arg))
(push role res)))
(remove-duplicates res)))
;;;
;;;
;;;
(defmethod get-language ((concept-store concept-store) &optional recompute-p)
(declare (ignorable recompute-p))
(prepare concept-store +dl+)
(slot-value concept-store 'language))
(defmethod get-language ((concept concept) &optional recompute-p)
(declare (ignorable recompute-p))
(prepare (concept-store concept) +dl+)
(when recompute-p ; wichtig
(compute-language (concept-store concept)))
(slot-value (concept-store concept) 'language))
| 66,557 | Common Lisp | .lisp | 1,576 | 28.73033 | 113 | 0.523561 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 50af910d657e3241968f69c471b357859f7e816afeb0acb5f0b245af8dcc7d8a | 12,573 | [
-1
] |
12,574 | abox-queries3.lisp | lambdamikel_DLMAPS/src/prover/abox-queries3.lisp | ;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: PROVER -*-
(in-package :PROVER)
;;;
;;;
;;;
(defconstant +marker+ (gensym "M"))
(defun error-abox-inconsistent (abox)
(error "ABox ~A is inconsistent!" abox))
(defvar *time-spend-in-individual-instance-rollback* 0)
(defvar *time-spend-in-individual-instance-rollback2* 0)
(defvar *time-spend-in-global-rollback* 0)
(defvar *time-spend-in-individual-instance-register-told-concepts* 0)
(defvar *time-spend-in-individual-instance-init-abox* 0)
(defvar *time-spend-in-individual-instance-abox-sat* 0)
(defvar *retrieval-context* nil)
(defvar *rollback-to* nil)
(defvar *rollback-from* nil)
;;;
;;;
;;;
(defmacro with-abox-retrieval ((abox) &body body)
`(let ((*retrieval-context* :prepare)
(*rollback-to* nil))
(unwind-protect
(progn ,@body)
(when (eq *retrieval-context* :established)
(global-rollback ,abox)))))
(defmethod global-rollback ((abox abox) &key
(rollback-from *rollback-from*)
(rollback-to *rollback-to*))
(announce "Leaving Abox retrieval context, global rollback!")
(with-timing (*time-spend-in-global-rollback*)
(let ((*MAINTAIN-UNEXPANDED-SOME-CONCEPTS1-HEAP-P* nil)
(*MAINTAIN-UNEXPANDED-AT-LEAST-CONCEPTS-HEAP-P* nil)
(*MAINTAIN-UNEXPANDED-ATOMIC-CONCEPTS1-HEAP-P* nil)
(*MAINTAIN-DEACTIVATED-NODES-P* nil)
(*MAINTAIN-LEAF-NODES-P* nil)
(*MAINTAIN-UNEXPANDED-AT-LEAST-CONCEPTS1-HEAP-P* nil)
(*MAINTAIN-UNEXPANDED-ATTRIBUTE-EXISTS-CONCEPTS-HEAP-P* nil)
(*MAINTAIN-CACHE-SAT-NODES-P* nil)
(*MAINTAIN-UNEXPANDED-ATOMIC-CONCEPTS-HEAP-P* nil)
(*MAINTAIN-UNEXPANDED-OR-CONCEPTS1-HEAP-P* nil)
(*MAINTAIN-OLD-NODES-P* nil)
(*MAINTAIN-UNEXPANDED-AND-CONCEPTS-HEAP-P* nil)
(*MAINTAIN-UNEXPANDED-OR-CONCEPTS-HEAP-P* nil)
(*MAINTAIN-ACTIVE-NODES-P* nil)
(*MAINTAIN-UNEXPANDED-AND-CONCEPTS-HEAP1-P* nil)
(*MAINTAIN-UNEXPANDED-ATTRIBUTE-EXISTS-CONCEPTS1-HEAP-P* nil)
(*MAINTAIN-UNEXPANDED-SOME-CONCEPTS-HEAP-P* nil)
(*MAINTAIN-BLOCKED-NODES-P* nil))
(setf (slot-value abox 'current-action) rollback-from)
(rollback-to abox rollback-to))))
(define-prover ((concept-instances dl abox) &key concept continuation)
(:rollback :no)
(:init
(announce "CONCEPT INSTANCES PROVER")
(let* ((res nil)
(negated (get-negated-concept concept))
(action nil)
(init-performed-p nil)
(same-loop-abox-init-done-p nil)
(count 0)
(pos 0)
(nodes nil)
(n 1)
(lastpos nil)
(instance nil)
(instance-found nil))
(labels ((do-it ()
(block prover
(with-clash-handler
(dolist (node nodes)
(incf *all-instance-tests*)
(when *debug-p*
(princ "CHECKING NODE ") (princ node) (terpri)
(princ concept)
(terpri)
(describe-object node t)
(describe-object abox t))
(incf count)
(setf pos (floor (+ 0.5 (* 30 (/ count n)))))
(setf clashes nil)
(setf instance nil)
(cond ((obvious-non-instance abox node concept)
(incf *obvious-non-instance-hits*)
t)
((obvious-instance abox node concept)
(incf *obvious-instance-hits*)
(setf instance t)
(push node res))
(t
(labels ((abox-sat ()
(loop-over-abox-nodes (node abox)
(when (initial-concept node)
(break "initial concept 1 : ~A!" node)))
(let ((action (get-current-action)))
(prog1
(or (let ((added ; macht den einen Knoten wieder aktiv!
(register-as-unexpanded negated
:node node
:new-choice-point 0)))
(check-for-clash node added)
clashes)
(with-timing (*time-spend-in-individual-instance-abox-sat*)
(incf *individual-instance-proofs*)
(prover-init
'abox-sat
language
abox
:compute-core-model-p nil
:store-ind-models-p t
:keep-det-assertions-p nil
:maintain-prover-state-p t)))
(announce ">>>> CONCEPT INSTANCES: Now rolling back!")
(with-timing (*time-spend-in-individual-instance-rollback*)
(let ((*maintain-active-nodes-p* t))
(rollback-to abox action)))
(loop-over-abox-nodes (node abox)
(when (initial-concept node)
(break "initial concept2 ~A !" node)))
(reset-cached-sat-result abox)))))
(when (if (or (not *abox-init-required-p*)
(eq *retrieval-context* :established)
same-loop-abox-init-done-p )
(with-strategy (+abox-saturation-strategy+)
(not (abox-sat)))
(let ((*abox-init-required-p* nil))
(when (eq *retrieval-context* :prepare)
(setf *retrieval-context* :established)
(setf *rollback-to* (get-current-action)))
(setf same-loop-abox-init-done-p t
init-performed-p t)
(setf action (get-current-action))
;(visualize abox) (break)
(announce ">>>> CONCEPT INSTANCES: Now performing initial deterministic expansion")
(with-timing (*time-spend-in-individual-instance-register-told-concepts*)
(register-told-concepts abox language)
(prepare-index-structures abox))
(loop-over-abox-nodes (node abox)
(when (initial-concept node)
(break "initial concept!")))
(announce ">>>> CONCEPT INSTANCES: Initial deterministic expansion")
(let ((start-time1
(get-internal-run-time)))
(with-strategy (+abox-saturation-strategy+)
(perform (deterministic-expansion :language-type dl)
(:body
(announce "Done!")
;(visualize abox) (break)
(incf *time-spend-in-individual-instance-init-abox*
(- (get-internal-run-time) start-time1))
(setf *rollback-from* (get-current-action))
(if clashes
;;; kann eigentlich nicht vorkommen!
(error-abox-inconsistent abox)
(not (abox-sat)))))))))
(setf instance t)
(push node res)))))
(when (and instance continuation)
(funcall continuation node))
(setf instance-found (or instance-found instance))
(when (and t ; *debug-p*
(or (not lastpos)
(not (= pos lastpos))))
(loop as i from (or lastpos 0) to (1- pos) do
(if instance-found
(princ "+")
(princ "-")))
(setf instance-found nil)
(setf lastpos pos)))
(when t ; *debug-p*
(terpri))
(when (and init-performed-p
(not *retrieval-context*))
(global-rollback abox :rollback-to action))
res))))
(loop-over-abox-nodes (node abox)
(when (old-p node)
(push node nodes)))
(setf n (length nodes))
(when t ; *debug-p*
(terpri)
(loop as i from 0 to 29 do (princ "="))
(terpri))
(do-it)))))
(define-prover ((individual-instance-p dl abox) &key node concept)
(:rollback :no)
(:init
(announce "INDIVIDUAL INSTANCE?")
(incf *all-instance-tests*)
(let* ((negated (get-negated-concept concept))
(action nil)
(init-performed-p nil)
(instance nil))
(labels ((do-it ()
(block prover
(with-clash-handler
(setf clashes nil)
(setf instance nil)
(cond ((obvious-non-instance abox node concept)
(incf *obvious-non-instance-hits*)
t)
((obvious-instance abox node concept)
(incf *obvious-instance-hits*)
(setf instance t))
(t (labels ((abox-sat ()
(let ((action (get-current-action)))
(prog1
(or (let ((added ; macht den einen Knoten wieder aktiv!
(register-as-unexpanded negated
:node node
:new-choice-point 0)))
(check-for-clash node added)
clashes)
(with-timing (*time-spend-in-individual-instance-abox-sat*)
(incf *individual-instance-proofs*)
(prover-init
'abox-sat
language
abox
:compute-core-model-p nil
:store-ind-models-p nil
:keep-det-assertions-p nil
:maintain-prover-state-p t)))
(announce ">>>> INDIVIDUAL INSTANCE-P: Now rolling back!")
(with-timing (*time-spend-in-individual-instance-rollback*)
(let ((*maintain-active-nodes-p* t))
(rollback-to abox action)))
(reset-cached-sat-result abox)))))
(when (if (or (not *abox-init-required-p*)
(eq *retrieval-context* :established))
(not (abox-sat))
(let ((*abox-init-required-p* nil))
; (visualize abox) (break)
(when (eq *retrieval-context* :prepare)
(setf *retrieval-context* :established)
(setf *rollback-to* (get-current-action)))
(announce ">>>> INDIVIDUAL INSTANCE-P: Now performing initial deterministic expansion")
(setf init-performed-p t)
(setf action (get-current-action))
(with-timing (*time-spend-in-individual-instance-register-told-concepts*)
(register-told-concepts abox language)
(prepare-index-structures abox))
(announce ">>>> INDIVIDUAL INSTANCE-P: Initial deterministic expansion")
(let ((start-time1
(get-internal-run-time)))
(with-strategy (+abox-saturation-strategy+)
(perform (deterministic-expansion :language-type dl)
(:body
(announce "Done!")
(incf *time-spend-in-individual-instance-init-abox*
(- (get-internal-run-time) start-time1))
(setf *rollback-from* (get-current-action))
(if clashes
;;; kann eigentlich nicht vorkommen!
(error-abox-inconsistent abox)
(not (abox-sat)))))))))
(setf instance t)))))
(when (and init-performed-p
(not *retrieval-context*))
(global-rollback abox :rollback-to action))
instance))))
(do-it)))))
#|
(define-prover ((simple-individual-instance-p dl abox) &key node concept)
(:rollback :no)
(:init
(announce "INDIVIDUAL INSTANCE?")
(let* ((negated (get-negated-concept concept))
(instance nil))
(labels ((do-it ()
(setf instance nil)
(cond ((obvious-non-instance abox node concept)
t)
((obvious-instance abox node concept)
(setf instance t))
(t (labels ((abox-sat ()
(let ((action nil))
(prog1
(or (let ((added ; macht den einen Knoten wieder aktiv!
(register-as-unexpanded negated
:node node
:new-choice-point 0)))
(setf action (get-current-action))
(block prover ; wird nicht benutzt als Ausgang
(with-clash-handler
(check-for-clash node added)
clashes)))
(with-timing (*time-spend-in-individual-instance-abox-sat*)
(prover-init
'abox-sat
language
abox
:compute-core-model-p nil
:store-ind-models-p nil
:keep-det-assertions-p nil
:maintain-prover-state-p nil)))
(undo-action abox action)
(reset-cached-sat-result abox)))))
(unless (abox-sat)
(setf instance t)))))
instance))
(do-it)))))
|#
;;;
;;;
;;;
(defun related-p (abox from to role &rest args)
(let* ((abox (find-abox abox :error-p t))
(from (find-node abox from :error-p t))
(to (find-node abox to :error-p t)))
(with-abox* (abox)
(if (apply #'prepare-abox-for-querying-and-sat-p abox args)
(let* ((role (parse-role role))
(marker
(with-protected-concept-store
(get-negated-concept
(parse-concept +marker+))))
(concept
(with-protected-concept-store
(parse-concept `(all ,(unparse role) ,+marker+)))))
(node-instance from concept)
(node-instance to marker)
(prog1
(not (apply #'abox-sat-p abox args))
(node-forget from concept)
(node-forget to marker)))
(error-abox-inconsistent abox)))))
;;;
;;;
;;;
(defmethod obvious-instance ((abox abox) node concept)
(cond ((is-top-concept-p concept)
t)
((is-bottom-concept-p concept)
nil)
(t
(cond ((member concept (told-concepts node))
t)
((member (negated-concept concept) (told-concepts node))
nil)
(t
(let ((negated (negated-concept concept)))
(unless (core-model node)
(break "no core models for ~A?" node))
(unless (instance-retrieval-model negated)
(break "no instance retrieval model for ~A?" negated))
(models-surely-not-mergeable-p +dl+
(core-model node)
(instance-retrieval-model negated))))))))
(defmethod obvious-non-instance ((abox abox) node concept)
(cond ((is-bottom-concept-p concept)
t)
((is-top-concept-p concept)
nil)
((member concept (told-concepts node))
nil)
(t
(let ((negated (negated-concept concept)))
(if (member negated (told-concepts node))
t
(progn
(unless (ind-models node)
(break "no ind models for ~A?" node))
(unless (cached-models negated)
(break "no concept models for ~A?" negated))
(or (some #'(lambda (ma)
(some #'(lambda (mb)
(models-mergeable-p +alchn+ ma mb))
(cached-models negated)))
(ind-models node))
(obvious-instance abox node negated))))))))
;;;
;;;
;;;
(defun instance-p (abox node concept &rest args &key language)
(let* ((abox (find-abox abox :error-p t))
(node (find-node abox node :error-p t)))
(with-protected-concept-store
(with-abox* (abox)
(let* ((concept (parse-concept concept))
(language (or language (get-language concept t)))
(res
(apply #'compute-models-and-sat-p concept args))
(abox-sat-p
(apply #'prepare-abox-for-querying-and-sat-p abox args)))
(if abox-sat-p
(ecase res
(:top t)
(:yes (cond ((obvious-non-instance abox node concept)
nil)
((obvious-instance abox node concept)
t)
(t
(apply #'prover-init
'individual-instance-p
(make-language language)
abox
:debug-p nil ; t
:node node
:concept concept
args))))
(:no nil))
(error-abox-inconsistent abox)))))))
(defun retrieve-concept-instances (abox concept &rest args
&key language continuation
&allow-other-keys)
(let* ((abox (find-abox abox :error-p t)))
(with-protected-concept-store
(with-abox* (abox)
(let* ((concept (parse-concept concept))
(language (or language (get-language concept t)))
(res
(apply #'compute-models-and-sat-p concept args))
(abox-sat-p
(apply #'prepare-abox-for-querying-and-sat-p abox args)))
(if abox-sat-p
(case res
(:top
(let ((res nil))
(loop-over-old-nodes (node abox)
(when (old-p node)
(when continuation
(funcall continuation node))
(push node res)))
res))
(:yes (let ((res
(apply #'prover-init
'concept-instances
(make-language language)
abox
:concept concept
:continuation continuation
args)))
res))
(:no nil))
(error-abox-inconsistent abox)))))))
(defun retrieve-role-fillers (abox ind role &rest args
&key language continuation
&allow-other-keys)
(let* ((abox (find-abox abox :error-p t))
(node (find-node abox ind :error-p t))
(language (or language (get-language abox))))
(with-protected-concept-store
(with-abox* (abox)
(let* ((role (parse-role role))
(marker
(parse-concept +marker+))
(concept
(parse-concept `(all ,(unparse role) ,+marker+))))
(node-instance node concept)
(prog1
(apply #'retrieve-concept-instances abox marker
:continuation continuation
:language language
args)
(node-forget node concept)))))))
;;;
;;;
;;;
(defmethod compute-models-and-sat-p ((concept concept) &rest args)
(announce "Compute models and sat-p!")
(let ((negated (get-negated-concept concept)))
(if (or (already-known-to-be-satisfiable-p concept)
(cached-models concept)
(apply #'sat-p concept
:store-instance-retrieval-model-p t
:store-ind-models-p t
:maintain-prover-state-p nil
:recompute-p t
args))
(progn
(when (or (not (instance-retrieval-model concept))
(not (cached-models concept)))
(apply #'sat-p concept
:store-instance-retrieval-model-p t
:maintain-prover-state-p nil
:store-ind-models-p t
:recompute-p t
args))
(if (or (already-known-to-be-satisfiable-p negated)
(cached-models negated)
(apply #'sat-p negated
:store-instance-retrieval-model-p t
:maintain-prover-state-p nil
:store-ind-models-p t
:recompute-p t
args))
(progn
(when (or (not (instance-retrieval-model negated))
(not (cached-models negated)))
(apply #'sat-p negated
:maintain-prover-state-p nil
:store-instance-retrieval-model-p t
:store-ind-models-p t
:recompute-p t
args))
:yes)
:top))
:no)))
;;;
;;;
;;;
(defmethod prepare-abox-for-querying-and-sat-p ((abox abox) &rest args)
(announce "Prepare abox for querying and sat-p!")
(if (slot-value abox 'ready-for-retrieval)
t
(prog1
(apply #'abox-consistent-p abox
:recompute-p t
:store-ind-models-p t
:compute-core-model-p t
:maintain-prover-state-p nil
args)
(setf (slot-value abox 'ready-for-retrieval) t))))
#|
(progn
(full-reset)
(with-kb (test test :delete-if-exists-p t)
(instance a (or (all r c) (all r d)))
(related a b r)
(prepare-abox-for-querying-and-sat-p *cur-abox*)
(with-abox-retrieval (*cur-abox*)
(princ (retrieve-concept-instances *cur-abox* '(or c d)))
(princ (individual-instance? a (or (all r (or c d)) x)))
(princ (retrieve-concept-instances *cur-abox* '(or c d ))))))
|#
#|
(defun abox-queries-test ()
(delete-all-tboxes)
(instance i c)
(instance j d)
(related i j r)
(pprint (ts::midelora-retrieve (?x ?y) (and (?x c) (?x ?y r) (?y d))))
(pprint (ts::midelora-retrieve (?x) (and (i ?x r) (?x d)))))
|#
| 29,418 | Common Lisp | .lisp | 536 | 27.041045 | 127 | 0.404576 | lambdamikel/DLMAPS | 8 | 0 | 0 | GPL-3.0 | 9/19/2024, 11:26:57 AM (Europe/Amsterdam) | 5469c2fbbd57dca27fea385c609e4d99243c439542bad76d0beadcd8b0c36c79 | 12,574 | [
-1
] |
12,575 | simple-kaon-test.lisp | lambdamikel_DLMAPS/src/prover/simple-kaon-test.lisp |