Terms are equivalent only if they are both well-formed

Julien LepillerSun Apr 05 16:18:11+0200 2020

8cffbc4

Terms are equivalent only if they are both well-formed

rdf/entailment/d.scm

132132
133133
(define (equiv? n1 n2)
134134
  (match (list n1 n2)
135-
    ((($ rdf-literal l1 ($ rdf-datatype _ _ _ _ lexical->value1 _) lang1)
136-
      ($ rdf-literal l2 ($ rdf-datatype _ _ _ _ lexical->value2 _) lang2))
135+
    ((($ rdf-literal l1 ($ rdf-datatype _ _ lexical1? _ lexical->value1 _) lang1)
136+
      ($ rdf-literal l2 ($ rdf-datatype _ _ lexical2? _ lexical->value2 _) lang2))
137137
     (and (equal? (and lang1 (string-downcase lang1))
138138
                  (and lang2 (string-downcase lang2)))
139-
          (equal? (lexical->value1 l1))
140-
          (equal? (lexical->value2 l2))))
139+
          (lexical1? l1)
140+
          (lexical2? l2)
141+
          (equal? (lexical->value1 l1) (lexical->value2 l2))))
141142
    (_ (equal? n1 n2))))
142143
143144
(define (validate-mapping mapping g1 g2)

rdf/entailment/rdf.scm

158158
            g
159159
            (loop (append (recognize augment-set vocabulary) g)))))))
160160
161-
(define (equiv? n1 n2)
162-
  (match (list n1 n2)
163-
    ((($ rdf-literal l1 ($ rdf-datatype _ _ _ _ lexical->value1 _) lang1)
164-
      ($ rdf-literal l2 ($ rdf-datatype _ _ _ _ lexical->value2 _) lang2))
165-
     (and (equal? lang1 lang2)
166-
          (equal? (lexical->value1 l1))
167-
          (equal? (lexical->value2 l2))))
168-
    (_ (equal? n1 n2))))
169-
170-
(define (validate-mapping mapping g1 g2)
171-
  (match g1
172-
    ('() #t)
173-
    ((t1 g1 ...)
174-
     (and (not (null? (filter
175-
                        (lambda (t2)
176-
                          (let ((s1 (rdf-triple-subject t1))
177-
                                (s2 (rdf-triple-subject t2))
178-
                                (p1 (rdf-triple-predicate t1))
179-
                                (p2 (rdf-triple-predicate t2))
180-
                                (o1 (rdf-triple-object t1))
181-
                                (o2 (rdf-triple-object t2)))
182-
                            (and
183-
                              (if (blank-node? s1)
184-
                                  (equiv? (assoc-ref mapping s1) s2)
185-
                                  (equiv? s1 s2))
186-
                              (equal? p1 p2)
187-
                              (if (blank-node? o1)
188-
                                  (equiv? (assoc-ref mapping o1) o2)
189-
                                  (equiv? o1 o2)))))
190-
                        g2)))
191-
          (validate-mapping mapping g1 g2)))))
192-
193161
(define (entails? g e vocabulary)
194162
  "Return true if g entails e"
195163
  (let* ((g (recognize g vocabulary))