Skip to content

Commit 70328ca

Browse files
fix: repair no_multiple_inverse_properties.sparql (#490) (#817)
1 parent c6d6f93 commit 70328ca

2 files changed

Lines changed: 158 additions & 10 deletions

File tree

.github/deployment/sparql/no_multiple_inverse_properties.sparql

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,23 @@
55
# Severity:
66
# Error
77

8-
PREFIX owl: <http://www.w3.org/2002/07/owl#>
8+
PREFIX owl: <http://www.w3.org/2002/07/owl#>
99

10-
SELECT ?property1 ?property2 ?error
10+
SELECT DISTINCT ?property ?inverse1 ?inverse2 ?error
1111
WHERE
1212
{
1313
{
14-
?property owl:inverseOf ?property1.
15-
?property owl:inverseOf ?property2.
16-
FILTER (?property1 != ?property2)
14+
{ ?property owl:inverseOf ?inverse1 }
15+
UNION
16+
{ ?inverse1 owl:inverseOf ?property }
1717
}
18-
UNION
1918
{
20-
?property1 owl:inverseOf ?property.
21-
?property2 owl:inverseOf ?property.
22-
FILTER (?property1 != ?property2)
19+
{ ?property owl:inverseOf ?inverse2 }
20+
UNION
21+
{ ?inverse2 owl:inverseOf ?property }
2322
}
23+
FILTER (?inverse1 != ?inverse2)
24+
FILTER (STR(?inverse1) < STR(?inverse2))
2425
BIND (concat("ERROR: Object property ", str(?property), " has more than one inverse.") AS ?error)
25-
}
26+
}
27+
ORDER BY ?property
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
@prefix owl: <http://www.w3.org/2002/07/owl#> .
2+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
3+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
4+
@prefix test: <https://example.org/test#> .
5+
6+
<https://example.org/test>
7+
rdf:type owl:Ontology ;
8+
rdfs:label "Toy ontology for no_multiple_inverse_properties.sparql" .
9+
10+
# -----------------------------------------------------------------------
11+
# SHOULD TRIGGER — property declared as inverseOf two distinct properties
12+
13+
test:parentOf
14+
rdf:type owl:ObjectProperty ;
15+
owl:inverseOf test:childOf ;
16+
owl:inverseOf test:hasParent ;
17+
rdfs:label "parent of" .
18+
19+
test:childOf
20+
rdf:type owl:ObjectProperty ;
21+
rdfs:label "child of" .
22+
23+
test:hasParent
24+
rdf:type owl:ObjectProperty ;
25+
rdfs:label "has parent" .
26+
27+
# -----------------------------------------------------------------------
28+
# SHOULD TRIGGER — mixed direction: one inverse forward, one backward
29+
# test:teaches owl:inverseOf test:learnedBy (forward)
30+
# test:taughtBy owl:inverseOf test:teaches (backward, so teaches also has taughtBy as an inverse)
31+
32+
test:teaches
33+
rdf:type owl:ObjectProperty ;
34+
owl:inverseOf test:learnedBy ;
35+
rdfs:label "teaches" .
36+
37+
test:taughtBy
38+
rdf:type owl:ObjectProperty ;
39+
owl:inverseOf test:teaches ;
40+
rdfs:label "taught by" .
41+
42+
test:learnedBy
43+
rdf:type owl:ObjectProperty ;
44+
rdfs:label "learned by" .
45+
46+
# -----------------------------------------------------------------------
47+
# SHOULD TRIGGER — both inverses declared backward
48+
# test:wasBuiltBy owl:inverseOf test:builds (backward)
49+
# test:wasCreatedBy owl:inverseOf test:builds (backward)
50+
# => test:builds has two inverses: wasBuiltBy and wasCreatedBy
51+
52+
test:builds
53+
rdf:type owl:ObjectProperty ;
54+
rdfs:label "builds" .
55+
56+
test:wasBuiltBy
57+
rdf:type owl:ObjectProperty ;
58+
owl:inverseOf test:builds ;
59+
rdfs:label "was built by" .
60+
61+
test:wasCreatedBy
62+
rdf:type owl:ObjectProperty ;
63+
owl:inverseOf test:builds ;
64+
rdfs:label "was created by" .
65+
66+
# -----------------------------------------------------------------------
67+
# SHOULD TRIGGER — three inverses declared forward (produces 3 violation pairs)
68+
69+
test:contains
70+
rdf:type owl:ObjectProperty ;
71+
owl:inverseOf test:isIn ;
72+
owl:inverseOf test:isInsideOf ;
73+
owl:inverseOf test:isEncompassedBy ;
74+
rdfs:label "contains" .
75+
76+
test:isIn
77+
rdf:type owl:ObjectProperty ;
78+
rdfs:label "is in" .
79+
80+
test:isInsideOf
81+
rdf:type owl:ObjectProperty ;
82+
rdfs:label "is inside of" .
83+
84+
test:isEncompassedBy
85+
rdf:type owl:ObjectProperty ;
86+
rdfs:label "is encompassed by" .
87+
88+
# -----------------------------------------------------------------------
89+
# SHOULD NOT TRIGGER — property with exactly one inverse (forward only)
90+
91+
test:employs
92+
rdf:type owl:ObjectProperty ;
93+
owl:inverseOf test:employedBy ;
94+
rdfs:label "employs" .
95+
96+
test:employedBy
97+
rdf:type owl:ObjectProperty ;
98+
rdfs:label "employed by" .
99+
100+
# -----------------------------------------------------------------------
101+
# SHOULD NOT TRIGGER — property with no declared inverse
102+
103+
test:likes
104+
rdf:type owl:ObjectProperty ;
105+
rdfs:label "likes" .
106+
107+
# -----------------------------------------------------------------------
108+
# SHOULD NOT TRIGGER — single inverse declared backward only
109+
# test:isOwnedBy declares itself as owl:inverseOf test:owns, so
110+
# test:owns has exactly one inverse (test:isOwnedBy)
111+
112+
test:owns
113+
rdf:type owl:ObjectProperty ;
114+
rdfs:label "owns" .
115+
116+
test:isOwnedBy
117+
rdf:type owl:ObjectProperty ;
118+
owl:inverseOf test:owns ;
119+
rdfs:label "is owned by" .
120+
121+
# -----------------------------------------------------------------------
122+
# SHOULD NOT TRIGGER — self-inverse (symmetric property)
123+
# isSiblingOf owl:inverseOf isSiblingOf: both ?inv1 and ?inv2 resolve to
124+
# isSiblingOf, so FILTER(?inv1 != ?inv2) eliminates the row
125+
126+
test:isSiblingOf
127+
rdf:type owl:ObjectProperty ;
128+
owl:inverseOf test:isSiblingOf ;
129+
rdfs:label "is sibling of" .
130+
131+
# -----------------------------------------------------------------------
132+
# SHOULD NOT TRIGGER — inverse declared redundantly in both directions
133+
# isRelatedTo owl:inverseOf isAssociatedWith
134+
# isAssociatedWith owl:inverseOf isRelatedTo
135+
# These are the same single inverse pair stated twice; each property has
136+
# exactly one inverse
137+
138+
test:isRelatedTo
139+
rdf:type owl:ObjectProperty ;
140+
owl:inverseOf test:isAssociatedWith ;
141+
rdfs:label "is related to" .
142+
143+
test:isAssociatedWith
144+
rdf:type owl:ObjectProperty ;
145+
owl:inverseOf test:isRelatedTo ;
146+
rdfs:label "is associated with" .

0 commit comments

Comments
 (0)