Fix arguments for consistency checks
rdf/entailment/d.scm
23 | 23 | #:export (consistent-graph? | |
24 | 24 | entails?)) | |
25 | 25 | ||
26 | - | (define (consistent-graph? graph) | |
26 | + | (define (consistent-graph? graph vocabulary) | |
27 | 27 | (define consistent-data? | |
28 | 28 | (match-lambda | |
29 | 29 | (($ rdf-literal form ($ rdf-datatype _ _ lexical? _ _ _) _) | |
30 | 30 | (lexical? form)) | |
31 | 31 | (_ #t))) | |
32 | 32 | ||
33 | - | (match graph | |
33 | + | (match (recognize graph vocabulary) | |
34 | 34 | ('() #t) | |
35 | 35 | ((($ rdf-triple subject predicate object) graph ...) | |
36 | 36 | (and (consistent-data? subject) (consistent-data? object) | |
37 | - | (consistent-graph? graph))))) | |
37 | + | (consistent-graph? graph vocabulary))))) | |
38 | 38 | ||
39 | 39 | ;; G entails E if E has an instance (where blank nodes are replaced by literals | |
40 | 40 | ;; or IRIs) that is a subgraph of G. | |
… | |||
163 | 163 | g2))) | |
164 | 164 | (validate-mapping mapping g1 g2))))) | |
165 | 165 | ||
166 | - | (define (entails? g e) | |
166 | + | (define (entails? g e vocabulary) | |
167 | 167 | "Return true if g entails e" | |
168 | - | (or (not (consistent-graph? g)) | |
169 | - | (let* ((constraints (fold (lambda (t constraints) | |
170 | - | (list 'and (generate-constraints t g) constraints)) | |
171 | - | 'none e)) | |
172 | - | (disjunctions (to-disjunctions constraints))) | |
173 | - | (if (equal? disjunctions 'bot) | |
174 | - | #f | |
175 | - | (let loop ((disjunctions (filter sat? disjunctions))) | |
176 | - | (match disjunctions | |
177 | - | ('() #f) | |
178 | - | ((mapping disjunctions ...) | |
179 | - | (if (validate-mapping mapping e g) | |
180 | - | #t | |
181 | - | (loop disjunctions))))))))) | |
168 | + | (let ((g (recognize g vocabulary))) | |
169 | + | (or (not (consistent-graph? g vocabulary)) | |
170 | + | (let* ((constraints (fold (lambda (t constraints) | |
171 | + | (list 'and (generate-constraints t g) | |
172 | + | constraints)) | |
173 | + | 'none e)) | |
174 | + | (disjunctions (to-disjunctions constraints))) | |
175 | + | (if (equal? disjunctions 'bot) | |
176 | + | #f | |
177 | + | (let loop ((disjunctions (filter sat? disjunctions))) | |
178 | + | (match disjunctions | |
179 | + | ('() #f) | |
180 | + | ((mapping disjunctions ...) | |
181 | + | (if (validate-mapping mapping e g) | |
182 | + | #t | |
183 | + | (loop disjunctions)))))))))) |
rdf/entailment/rdf.scm
52 | 52 | (null? | |
53 | 53 | (filter | |
54 | 54 | (lambda (t) | |
55 | - | (not (compatible (cdr t)))) | |
55 | + | (not (compatible? (cdr t)))) | |
56 | 56 | type-mappings)) | |
57 | 57 | (let* ((t (car graph))) | |
58 | 58 | (if (equal? (rdf-triple-predicate t) (rdf-iri "type")) | |
… | |||
64 | 64 | (assoc-ref type-mappings | |
65 | 65 | (rdf-triple-subject t)) | |
66 | 66 | '()))))))))) | |
67 | - | (and (d:consistent-graph? graph) | |
68 | - | (compatible-types? graph))) | |
67 | + | ||
68 | + | (and (d:consistent-graph? graph vocabulary) | |
69 | + | (compatible-types? (recognize graph vocabulary)))) | |
69 | 70 | ||
70 | 71 | ;; G entails E if E has an instance (where blank nodes are replaced by literals | |
71 | 72 | ;; or IRIs) that is a subgraph of G. | |
… | |||
192 | 193 | "Return true if g entails e" | |
193 | 194 | (let ((g (recognize g vocabulary))) | |
194 | 195 | (or (not (consistent-graph? g vocabulary)) | |
195 | - | (d:entails? (augment g) e)))) | |
196 | + | (d:entails? (augment g) e vocabulary)))) |
rdf/entailment/rdfs.scm
42 | 42 | (valid-subclasses? graph))) | |
43 | 43 | ((_ graph ...) | |
44 | 44 | (valid-subclasses? graph)))) | |
45 | - | (and (valid-subclasses? graph) | |
45 | + | (and (valid-subclasses? (recognize graph vocabulary)) | |
46 | 46 | (rdf:consistent-graph? graph vocabulary))) | |
47 | 47 | ||
48 | 48 | ;; G entails E if E has an instance (where blank nodes are replaced by literals | |
… | |||
316 | 316 | (let* ((g (recognize g vocabulary))) | |
317 | 317 | (or (not (consistent-graph? g vocabulary)) | |
318 | 318 | (d:entails? (augment g (rdf-vocabulary-datatypes vocabulary)) | |
319 | - | (recognize e vocabulary))))) | |
319 | + | e vocabulary)))) |