Recognize augmented triples
rdf/entailment/rdf.scm
| 36 | 36 | (cons (cons k v) (alist-set lst key val)))))) | |
| 37 | 37 | ||
| 38 | 38 | (define (compatible? types) | |
| 39 | - | (match types | |
| 39 | + | (match (filter rdf-datatype? types) | |
| 40 | 40 | (() #t) | |
| 41 | 41 | ((_) #t) | |
| 42 | 42 | ((a b ...) | |
… | |||
| 63 | 63 | (or | |
| 64 | 64 | (assoc-ref type-mappings | |
| 65 | 65 | (rdf-triple-subject t)) | |
| 66 | - | '()))))))))) | |
| 66 | + | '())))) | |
| 67 | + | (loop (cdr graph) type-mappings)))))) | |
| 67 | 68 | ||
| 68 | 69 | (and (d:consistent-graph? graph vocabulary) | |
| 69 | - | (compatible-types? (augment (recognize graph vocabulary))))) | |
| 70 | + | (compatible-types? (augment (recognize graph vocabulary) vocabulary)))) | |
| 70 | 71 | ||
| 71 | 72 | ;; G entails E if E has an instance (where blank nodes are replaced by literals | |
| 72 | 73 | ;; or IRIs) that is a subgraph of G. | |
… | |||
| 121 | 122 | answer))) | |
| 122 | 123 | (loop answer g)))))) | |
| 123 | 124 | ||
| 124 | - | (define (augment g) | |
| 125 | + | (define (augment g vocabulary) | |
| 125 | 126 | (let* ((g (append rdf-axioms g)) | |
| 126 | 127 | (g (append | |
| 127 | 128 | (append-map rdf-axioms-container (rdf-container-properties g)) | |
| 128 | 129 | g))) | |
| 129 | - | (let loop ((g g)) | |
| 130 | + | (let loop ((g (recognize g vocabulary))) | |
| 130 | 131 | (let ((augment-set | |
| 131 | 132 | (let loop2 ((g2 g) (augment-set '())) | |
| 132 | 133 | (match g2 | |
… | |||
| 155 | 156 | augment-set)))))))) | |
| 156 | 157 | (if (null? augment-set) | |
| 157 | 158 | g | |
| 158 | - | (loop (append augment-set g))))))) | |
| 159 | + | (loop (append (recognize augment-set vocabulary) g))))))) | |
| 159 | 160 | ||
| 160 | 161 | (define (equiv? n1 n2) | |
| 161 | 162 | (match (list n1 n2) | |
… | |||
| 192 | 193 | (define (entails? g e vocabulary) | |
| 193 | 194 | "Return true if g entails e" | |
| 194 | 195 | (let* ((g (recognize g vocabulary)) | |
| 195 | - | (g (augment g)) | |
| 196 | + | (g (augment g vocabulary)) | |
| 196 | 197 | (e (recognize e vocabulary))) | |
| 197 | 198 | (or (not (consistent-graph? g vocabulary)) | |
| 198 | 199 | (d:entails? g e vocabulary)))) | |
rdf/entailment/rdfs.scm
| 42 | 42 | (valid-subclasses? graph))) | |
| 43 | 43 | ((_ graph ...) | |
| 44 | 44 | (valid-subclasses? graph)))) | |
| 45 | - | (and (valid-subclasses? (augment (recognize graph vocabulary) | |
| 46 | - | (rdf-vocabulary-datatypes vocabulary))) | |
| 45 | + | (and (valid-subclasses? (augment (recognize graph vocabulary) vocabulary)) | |
| 47 | 46 | (rdf:consistent-graph? graph vocabulary))) | |
| 48 | 47 | ||
| 49 | 48 | ;; G entails E if E has an instance (where blank nodes are replaced by literals | |
… | |||
| 259 | 258 | '())))) | |
| 260 | 259 | graph)))) | |
| 261 | 260 | ||
| 262 | - | (define (augment g d) | |
| 261 | + | (define (augment g voc) | |
| 263 | 262 | (let* ((g (append rdfs-axioms g)) | |
| 264 | - | (g (append (rdfs-axioms-types d) g)) | |
| 263 | + | (g (append (rdfs-axioms-types (rdf-vocabulary-datatypes voc)) g)) | |
| 265 | 264 | (g (append | |
| 266 | 265 | ;; rdfs1 | |
| 267 | 266 | (map | |
| 268 | 267 | (lambda (t) | |
| 269 | 268 | (make-rdf-triple t (rdf-iri "type") (rdfs-iri "Datatype"))) | |
| 270 | - | d))) | |
| 269 | + | (rdf-vocabulary-datatypes voc)))) | |
| 271 | 270 | (g (append | |
| 272 | 271 | (append-map rdfs-axioms-container (rdf-container-properties g)) | |
| 273 | 272 | g))) | |
… | |||
| 279 | 278 | (augment-set | |
| 280 | 279 | (if (null? graph) | |
| 281 | 280 | g | |
| 282 | - | (pk 'entailments | |
| 283 | - | (get-entailments | |
| 284 | - | graph subclasses subprops ranges | |
| 285 | - | domains types))))) | |
| 281 | + | (recognize | |
| 282 | + | (get-entailments | |
| 283 | + | graph subclasses subprops ranges | |
| 284 | + | domains types) | |
| 285 | + | voc)))) | |
| 286 | 286 | (match augment-set | |
| 287 | 287 | (() (if added? | |
| 288 | 288 | (loop graph subclasses subprops ranges domains types) | |
… | |||
| 315 | 315 | (define (entails? g e vocabulary) | |
| 316 | 316 | "Return true if g entails e recognizing d" | |
| 317 | 317 | (let* ((g (recognize g vocabulary)) | |
| 318 | - | (g (augment g (rdf-vocabulary-datatypes vocabulary))) | |
| 318 | + | (g (augment g vocabulary)) | |
| 319 | 319 | (e (recognize e vocabulary))) | |
| 320 | 320 | (or (not (consistent-graph? g vocabulary)) | |
| 321 | 321 | (d:entails? g e vocabulary)))) | |