| 1 |
package bugs.debug; |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
import static org.junit.Assert.*; |
| 9 |
import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.*; |
| 10 |
|
| 11 |
import java.util.Arrays; |
| 12 |
import java.util.HashSet; |
| 13 |
import java.util.Set; |
| 14 |
|
| 15 |
import org.junit.Ignore; |
| 16 |
import org.junit.Test; |
| 17 |
import org.semanticweb.owlapi.apibinding.OWLManager; |
| 18 |
import org.semanticweb.owlapi.model.IRI; |
| 19 |
import org.semanticweb.owlapi.model.OWLAxiom; |
| 20 |
import org.semanticweb.owlapi.model.OWLClass; |
| 21 |
import org.semanticweb.owlapi.model.OWLClassExpression; |
| 22 |
import org.semanticweb.owlapi.model.OWLDataFactory; |
| 23 |
import org.semanticweb.owlapi.model.OWLDataProperty; |
| 24 |
import org.semanticweb.owlapi.model.OWLDataRange; |
| 25 |
import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; |
| 26 |
import org.semanticweb.owlapi.model.OWLDatatype; |
| 27 |
import org.semanticweb.owlapi.model.OWLFacetRestriction; |
| 28 |
import org.semanticweb.owlapi.model.OWLLiteral; |
| 29 |
import org.semanticweb.owlapi.model.OWLNamedIndividual; |
| 30 |
import org.semanticweb.owlapi.model.OWLObjectProperty; |
| 31 |
import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; |
| 32 |
import org.semanticweb.owlapi.model.OWLOntology; |
| 33 |
import org.semanticweb.owlapi.model.OWLOntologyCreationException; |
| 34 |
import org.semanticweb.owlapi.model.OWLOntologyManager; |
| 35 |
import org.semanticweb.owlapi.reasoner.OWLReasoner; |
| 36 |
import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; |
| 37 |
import org.semanticweb.owlapi.vocab.OWL2Datatype; |
| 38 |
import org.semanticweb.owlapi.vocab.OWLFacet; |
| 39 |
import org.semanticweb.owlapi.vocab.XSDVocabulary; |
| 40 |
|
| 41 |
import testbase.TestBase; |
| 42 |
import conformancetests.Changed; |
| 43 |
import conformancetests.JUnitRunner; |
| 44 |
import conformancetests.TestClasses; |
| 45 |
|
| 46 |
@Ignore("disabling for release") |
| 47 |
@SuppressWarnings("javadoc") |
| 48 |
public class FppBrokenTestCase extends TestBase { |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
@Test |
| 56 |
|
| 57 |
|
| 58 |
public void testPlus_and_Minus_Zero_are_Distinct() { |
| 59 |
String premise = "Prefix(:=<http://example.org/>)\n" |
| 60 |
+ "Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)\n" |
| 61 |
+ "Ontology(\n" |
| 62 |
+ " Declaration(NamedIndividual(:Meg))\n" |
| 63 |
+ " Declaration(DataProperty(:numberOfChildren))\n" |
| 64 |
+ " DataPropertyAssertion(:numberOfChildren :Meg \"+0.0\"^^xsd:float) \n" |
| 65 |
+ " DataPropertyAssertion(:numberOfChildren :Meg \"-0.0\"^^xsd:float) \n" |
| 66 |
+ " FunctionalDataProperty(:numberOfChildren)\n" + ')'; |
| 67 |
String conclusion = ""; |
| 68 |
String id = "Plus_and_Minus_Zero_are_Distinct"; |
| 69 |
TestClasses tc = TestClasses.valueOf("INCONSISTENCY"); |
| 70 |
String d = "For floats and double, +0.0 and -0.0 are distinct values, which contradicts the functionality for numberOfChildren."; |
| 71 |
JUnitRunner r = new JUnitRunner(premise, conclusion, id, tc, d); |
| 72 |
r.setReasonerFactory(factory()); |
| 73 |
r.run(); |
| 74 |
} |
| 75 |
|
| 76 |
@Test |
| 77 |
@Changed(reason = "old test appears to use the wrong value") |
| 78 |
|
| 79 |
|
| 80 |
public void testDatatype_Float_Discrete_001() |
| 81 |
throws OWLOntologyCreationException { |
| 82 |
OWLDataProperty dp = DataProperty(IRI("http://example.org/ontology/dp")); |
| 83 |
OWLDatatype f = Datatype(OWL2Datatype.XSD_FLOAT.getIRI()); |
| 84 |
OWLAxiom ax1 = Declaration(dp); |
| 85 |
OWLLiteral f0 = Literal(0F); |
| 86 |
OWLLiteral f1 = Literal(Float.MIN_NORMAL); |
| 87 |
OWLFacetRestriction min = FacetRestriction(OWLFacet.MIN_EXCLUSIVE, f0); |
| 88 |
OWLFacetRestriction max = FacetRestriction(OWLFacet.MAX_EXCLUSIVE, f1); |
| 89 |
OWLDataSomeValuesFrom superClass = DataSomeValuesFrom(dp, |
| 90 |
DatatypeRestriction(f, min, max)); |
| 91 |
OWLClass c = Class(IRI("http://example.org/ontology/c")); |
| 92 |
OWLAxiom ax3 = SubClassOf(c, superClass); |
| 93 |
OWLAxiom ax2 = ClassAssertion(c, |
| 94 |
NamedIndividual(IRI("http://example.org/ontology/a"))); |
| 95 |
OWLOntology o = OWLManager.createOWLOntologyManager().createOntology( |
| 96 |
new HashSet<>(Arrays.asList(ax1, ax2, ax3))); |
| 97 |
OWLReasoner r = factory().createReasoner(o); |
| 98 |
assertFalse(r.isConsistent()); |
| 99 |
} |
| 100 |
|
| 101 |
@Test |
| 102 |
|
| 103 |
|
| 104 |
public void testContradicting_dateTime_restrictions() { |
| 105 |
String premise = "Prefix(:=<http://example.org/>)\n" |
| 106 |
+ "Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)\n" |
| 107 |
+ "Ontology(\n" |
| 108 |
+ " Declaration(NamedIndividual(:a))\n" |
| 109 |
+ " Declaration(DataProperty(:dp))\n" |
| 110 |
+ " Declaration(Class(:A))\n" |
| 111 |
+ " SubClassOf(:A \n" |
| 112 |
+ " DataHasValue(:dp \"2007-10-08T20:44:11.656+01:00\"^^xsd:dateTime)) \n" |
| 113 |
+ " SubClassOf(:A \n" |
| 114 |
+ " DataAllValuesFrom(:dp DatatypeRestriction(\n" |
| 115 |
+ " xsd:dateTime \n" |
| 116 |
+ " xsd:minInclusive \"2008-07-08T20:44:11.656+01:00\"^^xsd:dateTime \n" |
| 117 |
+ " xsd:maxInclusive \"2008-10-08T20:44:11.656+01:00\"^^xsd:dateTime)\n" |
| 118 |
+ " )\n" + " ) \n" + " ClassAssertion(:A :a)\n" + ')'; |
| 119 |
String conclusion = ""; |
| 120 |
String id = "Contradicting_dateTime_restrictions"; |
| 121 |
TestClasses tc = TestClasses.valueOf("INCONSISTENCY"); |
| 122 |
String d = "The individual a must have a dp filler that is a date from 2007, but the restrictions on dp allow only values from 2008, which makes the ontology inconsistent."; |
| 123 |
JUnitRunner r = new JUnitRunner(premise, conclusion, id, tc, d); |
| 124 |
r.setReasonerFactory(factory()); |
| 125 |
r.run(); |
| 126 |
} |
| 127 |
|
| 128 |
@Test |
| 129 |
|
| 130 |
|
| 131 |
public void testContradicting_dateTime_restrictions_programmatic() |
| 132 |
throws OWLOntologyCreationException { |
| 133 |
Set<OWLAxiom> axioms = new HashSet<>(); |
| 134 |
OWLClass A = Class(IRI("http://example.org/A")); |
| 135 |
OWLNamedIndividual a = NamedIndividual(IRI("http://example.org/a")); |
| 136 |
OWLDataProperty dp = DataProperty(IRI("http://example.org/dp")); |
| 137 |
OWLDatatype type = Datatype(OWL2Datatype.XSD_DATE_TIME.getIRI()); |
| 138 |
OWLLiteral lit1 = Literal("2007-10-08T20:44:11.656+01:00", type); |
| 139 |
OWLLiteral lit2 = Literal("2008-10-08T20:44:11.656+01:00", type); |
| 140 |
OWLLiteral lit3 = Literal("2008-07-08T20:44:11.656+01:00", type); |
| 141 |
OWLFacetRestriction min = FacetRestriction(OWLFacet.MIN_INCLUSIVE, lit3); |
| 142 |
OWLFacetRestriction max = FacetRestriction(OWLFacet.MAX_INCLUSIVE, lit2); |
| 143 |
axioms.add(Declaration(A)); |
| 144 |
axioms.add(SubClassOf(A, |
| 145 |
DataAllValuesFrom(dp, DatatypeRestriction(type, max, min)))); |
| 146 |
axioms.add(SubClassOf(A, DataHasValue(dp, lit1))); |
| 147 |
axioms.add(Declaration(dp)); |
| 148 |
axioms.add(Declaration(a)); |
| 149 |
axioms.add(ClassAssertion(A, a)); |
| 150 |
OWLOntology o = OWLManager.createOWLOntologyManager().createOntology( |
| 151 |
axioms); |
| 152 |
assertFalse(factory().createReasoner(o).isConsistent()); |
| 153 |
} |
| 154 |
|
| 155 |
@Test |
| 156 |
|
| 157 |
|
| 158 |
public void testInconsistent_Byte_Filler() { |
| 159 |
String premise = "Prefix(:=<http://example.org/>)\n" |
| 160 |
+ "Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)\n" |
| 161 |
+ "Ontology(\n" |
| 162 |
+ " Declaration(NamedIndividual(:a))\n" |
| 163 |
+ " Declaration(DataProperty(:dp))\n" |
| 164 |
+ " Declaration(Class(:A))\n" |
| 165 |
+ " SubClassOf(:A DataAllValuesFrom(:dp xsd:byte)) \n" |
| 166 |
+ " ClassAssertion(:A :a)\n" |
| 167 |
+ " ClassAssertion(\n" |
| 168 |
+ " DataSomeValuesFrom(:dp DataOneOf(\"6542145\"^^xsd:integer)) :a\n" |
| 169 |
+ " )\n" + ')'; |
| 170 |
String conclusion = ""; |
| 171 |
String id = "Inconsistent_Byte_Filler"; |
| 172 |
TestClasses tc = TestClasses.valueOf("INCONSISTENCY"); |
| 173 |
String d = "The individual a must have the integer 6542145 as dp filler, but all fillers must also be bytes. Since 6542145 is not byte, the ontology is inconsistent."; |
| 174 |
JUnitRunner r = new JUnitRunner(premise, conclusion, id, tc, d); |
| 175 |
r.setReasonerFactory(factory()); |
| 176 |
r.run(); |
| 177 |
} |
| 178 |
|
| 179 |
|
| 180 |
@Test |
| 181 |
|
| 182 |
|
| 183 |
public void testWebOnt_AnnotationProperty_002() { |
| 184 |
String premise = "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:owl=\"http://www.w3.org/2002/07/owl#\" xmlns:first=\"http://www.w3.org/2002/03owlt/AnnotationProperty/premises002#\"\n" |
| 185 |
+ "xml:base=\"http://www.w3.org/2002/03owlt/AnnotationProperty/premises002\" >\n" |
| 186 |
+ "<owl:Ontology/>\n" |
| 187 |
+ "<owl:Class rdf:ID=\"A\">" |
| 188 |
+ " <first:ap>" |
| 189 |
+ " <owl:Class rdf:ID=\"B\"/>" |
| 190 |
+ " </first:ap>" |
| 191 |
+ "</owl:Class>" |
| 192 |
+ "<owl:AnnotationProperty rdf:ID=\"ap\"/>" + "</rdf:RDF>"; |
| 193 |
String conclusion = "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:owl=\"http://www.w3.org/2002/07/owl#\"" |
| 194 |
+ " xmlns:first=\"http://www.w3.org/2002/03owlt/AnnotationProperty/premises002#\"\n" |
| 195 |
+ " xml:base=\"http://www.w3.org/2002/03owlt/AnnotationProperty/conclusions002\" >\n" |
| 196 |
+ " <owl:Ontology/>\n" |
| 197 |
+ " <owl:Class rdf:about=\"premises002#A\">" |
| 198 |
+ " <first:ap>" |
| 199 |
+ " <owl:Thing />" |
| 200 |
+ " </first:ap>" |
| 201 |
+ " </owl:Class>" |
| 202 |
+ " <owl:AnnotationProperty rdf:about=\"premises002#ap\"/>" |
| 203 |
+ "</rdf:RDF>"; |
| 204 |
String id = "WebOnt_AnnotationProperty_002"; |
| 205 |
TestClasses tc = TestClasses.valueOf("POSITIVE_IMPL"); |
| 206 |
String d = "In OWL 1, this test was used to expose differences between the RDF Based and Direct semantics. In OWL 2, the entailment ontology holds under both semantics. Under the OWL 2 Direct Semantics, annotations in the conclusion ontology are ignored, so the only axiom evaluated in ClassAssertion(owl:Thing _:x). Under the OWL 2 RDF Based semantics, annotations are relevant, and in this test, the entailment holds."; |
| 207 |
JUnitRunner r = new JUnitRunner(premise, conclusion, id, tc, d); |
| 208 |
r.setReasonerFactory(factory()); |
| 209 |
r.run(); |
| 210 |
} |
| 211 |
|
| 212 |
@Test |
| 213 |
|
| 214 |
|
| 215 |
public void testDifferent() throws OWLOntologyCreationException { |
| 216 |
OWLOntologyManager m = OWLManager.createOWLOntologyManager(); |
| 217 |
OWLOntology o = m.createOntology(); |
| 218 |
OWLNamedIndividual x = NamedIndividual(IRI("urn:test:x")); |
| 219 |
OWLNamedIndividual y = NamedIndividual(IRI("urn:test:y")); |
| 220 |
OWLDataProperty p = DataProperty(IRI("urn:test:p")); |
| 221 |
OWLLiteral date1 = Literal("2008-07-08T20:44:11.656+01:00", |
| 222 |
OWL2Datatype.XSD_DATE_TIME); |
| 223 |
OWLLiteral date2 = Literal("2008-07-10T20:44:11.656+01:00", |
| 224 |
OWL2Datatype.XSD_DATE_TIME); |
| 225 |
m.addAxiom(o, DataPropertyAssertion(p, x, date1)); |
| 226 |
m.addAxiom(o, DataPropertyAssertion(p, y, date2)); |
| 227 |
m.addAxiom(o, FunctionalDataProperty(p)); |
| 228 |
m.addAxiom(o, SameIndividual(x, y)); |
| 229 |
OWLReasoner r = factory().createReasoner(o); |
| 230 |
assertFalse( |
| 231 |
"Ontology was supposed to be inconsistent!\n" |
| 232 |
+ o.getLogicalAxioms(), r.isConsistent()); |
| 233 |
} |
| 234 |
|
| 235 |
@Test |
| 236 |
|
| 237 |
|
| 238 |
public void testBetween() throws OWLOntologyCreationException { |
| 239 |
OWLOntologyManager m = OWLManager.createOWLOntologyManager(); |
| 240 |
OWLOntology o = m.createOntology(); |
| 241 |
OWLNamedIndividual x = NamedIndividual(IRI("urn:test:x")); |
| 242 |
OWLClass c = Class(IRI("urn:test:c")); |
| 243 |
OWLDataProperty p = DataProperty(IRI("urn:test:p")); |
| 244 |
OWLLiteral date1 = Literal("2008-07-08T20:44:11.656+01:00", |
| 245 |
OWL2Datatype.XSD_DATE_TIME); |
| 246 |
OWLLiteral date3 = Literal("2008-07-09T20:44:11.656+01:00", |
| 247 |
OWL2Datatype.XSD_DATE_TIME); |
| 248 |
OWLLiteral date2 = Literal("2008-07-10T20:44:11.656+01:00", |
| 249 |
OWL2Datatype.XSD_DATE_TIME); |
| 250 |
OWLDataRange range = DatatypeRestriction( |
| 251 |
Datatype(OWL2Datatype.XSD_DATE_TIME.getIRI()), |
| 252 |
FacetRestriction(OWLFacet.MIN_INCLUSIVE, date1), |
| 253 |
FacetRestriction(OWLFacet.MAX_INCLUSIVE, date2)); |
| 254 |
OWLClassExpression psome = DataSomeValuesFrom(p, range); |
| 255 |
m.addAxiom(o, EquivalentClasses(c, psome)); |
| 256 |
m.addAxiom(o, DataPropertyAssertion(p, x, date3)); |
| 257 |
m.addAxiom(o, FunctionalDataProperty(p)); |
| 258 |
OWLReasoner r = factory().createReasoner(o); |
| 259 |
assertTrue(r.isConsistent()); |
| 260 |
assertTrue( |
| 261 |
"x was supposed to be an instance of c!\n" |
| 262 |
+ o.getLogicalAxioms(), |
| 263 |
r.isEntailed(ClassAssertion(c, x))); |
| 264 |
} |
| 265 |
|
| 266 |
@Test |
| 267 |
|
| 268 |
|
| 269 |
public void testEqualDate() throws OWLOntologyCreationException { |
| 270 |
OWLOntologyManager m = OWLManager.createOWLOntologyManager(); |
| 271 |
OWLOntology o = m.createOntology(); |
| 272 |
OWLDataFactory f = m.getOWLDataFactory(); |
| 273 |
OWLNamedIndividual x = f |
| 274 |
.getOWLNamedIndividual(IRI.create("urn:test:x")); |
| 275 |
OWLNamedIndividual y = f |
| 276 |
.getOWLNamedIndividual(IRI.create("urn:test:y")); |
| 277 |
OWLDataProperty p = f.getOWLDataProperty(IRI.create("urn:test:p")); |
| 278 |
OWLLiteral date = f.getOWLLiteral("2008-07-08", |
| 279 |
f.getOWLDatatype(XSDVocabulary.DATE.getIRI())); |
| 280 |
m.addAxiom(o, f.getOWLDataPropertyAssertionAxiom(p, x, date)); |
| 281 |
m.addAxiom(o, f.getOWLDataPropertyAssertionAxiom(p, y, date)); |
| 282 |
m.addAxiom(o, f.getOWLFunctionalDataPropertyAxiom(p)); |
| 283 |
m.addAxiom(o, f.getOWLSameIndividualAxiom(x, y)); |
| 284 |
OWLReasoner r = factory().createReasoner(o); |
| 285 |
assertTrue( |
| 286 |
"Ontology was supposed to be consistent!\n" |
| 287 |
+ o.getLogicalAxioms(), r.isConsistent()); |
| 288 |
} |
| 289 |
|
| 290 |
@Test |
| 291 |
|
| 292 |
|
| 293 |
public void testDifferentDate() throws OWLOntologyCreationException { |
| 294 |
OWLOntologyManager m = OWLManager.createOWLOntologyManager(); |
| 295 |
OWLOntology o = m.createOntology(); |
| 296 |
OWLDataFactory f = m.getOWLDataFactory(); |
| 297 |
OWLNamedIndividual x = f |
| 298 |
.getOWLNamedIndividual(IRI.create("urn:test:x")); |
| 299 |
OWLNamedIndividual y = f |
| 300 |
.getOWLNamedIndividual(IRI.create("urn:test:y")); |
| 301 |
OWLDataProperty p = f.getOWLDataProperty(IRI.create("urn:test:p")); |
| 302 |
OWLLiteral date1 = f.getOWLLiteral("2008-07-08", |
| 303 |
f.getOWLDatatype(XSDVocabulary.DATE.getIRI())); |
| 304 |
OWLLiteral date2 = f.getOWLLiteral("2008-07-10", |
| 305 |
f.getOWLDatatype(XSDVocabulary.DATE.getIRI())); |
| 306 |
m.addAxiom(o, f.getOWLDataPropertyAssertionAxiom(p, x, date1)); |
| 307 |
m.addAxiom(o, f.getOWLDataPropertyAssertionAxiom(p, y, date2)); |
| 308 |
m.addAxiom(o, f.getOWLFunctionalDataPropertyAxiom(p)); |
| 309 |
m.addAxiom(o, f.getOWLSameIndividualAxiom(x, y)); |
| 310 |
OWLReasoner r = factory().createReasoner(o); |
| 311 |
assertFalse( |
| 312 |
"Ontology was supposed to be inconsistent!\n" |
| 313 |
+ o.getLogicalAxioms(), r.isConsistent()); |
| 314 |
} |
| 315 |
|
| 316 |
@Test |
| 317 |
|
| 318 |
|
| 319 |
public void testBetweenDate() throws OWLOntologyCreationException { |
| 320 |
OWLOntologyManager m = OWLManager.createOWLOntologyManager(); |
| 321 |
OWLOntology o = m.createOntology(); |
| 322 |
OWLDataFactory f = m.getOWLDataFactory(); |
| 323 |
OWLNamedIndividual x = f |
| 324 |
.getOWLNamedIndividual(IRI.create("urn:test:x")); |
| 325 |
OWLClass c = f.getOWLClass(IRI.create("urn:test:c")); |
| 326 |
OWLDataProperty p = f.getOWLDataProperty(IRI.create("urn:test:p")); |
| 327 |
OWLLiteral date1 = f.getOWLLiteral("2008-07-08", |
| 328 |
f.getOWLDatatype(XSDVocabulary.DATE.getIRI())); |
| 329 |
OWLLiteral date3 = f.getOWLLiteral("2008-07-09", |
| 330 |
f.getOWLDatatype(XSDVocabulary.DATE.getIRI())); |
| 331 |
OWLLiteral date2 = f.getOWLLiteral("2008-07-10", |
| 332 |
f.getOWLDatatype(XSDVocabulary.DATE.getIRI())); |
| 333 |
OWLDataRange range = f.getOWLDatatypeRestriction( |
| 334 |
f.getOWLDatatype(OWL2Datatype.XSD_DATE_TIME.getIRI()), |
| 335 |
f.getOWLFacetRestriction(OWLFacet.MIN_INCLUSIVE, date1), |
| 336 |
f.getOWLFacetRestriction(OWLFacet.MAX_INCLUSIVE, date2)); |
| 337 |
OWLClassExpression psome = f.getOWLDataSomeValuesFrom(p, range); |
| 338 |
m.addAxiom(o, f.getOWLEquivalentClassesAxiom(c, psome)); |
| 339 |
m.addAxiom(o, f.getOWLDataPropertyAssertionAxiom(p, x, date3)); |
| 340 |
m.addAxiom(o, f.getOWLFunctionalDataPropertyAxiom(p)); |
| 341 |
OWLReasoner r = factory().createReasoner(o); |
| 342 |
assertTrue( |
| 343 |
"x was supposed to be an instance of c!\n" |
| 344 |
+ o.getLogicalAxioms(), |
| 345 |
r.isEntailed(f.getOWLClassAssertionAxiom(c, x))); |
| 346 |
} |
| 347 |
|
| 348 |
@Test |
| 349 |
|
| 350 |
|
| 351 |
public void testDatatype_DataComplementOf_001() { |
| 352 |
String premise = "<?xml version=\"1.0\"?>\n" + "<rdf:RDF\n" |
| 353 |
+ " xml:base = \"http://example.org/\" xmlns = \"http://example.org/\" xmlns:owl = \"http://www.w3.org/2002/07/owl#\" xmlns:rdf = \"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:rdfs= \"http://www.w3.org/2000/01/rdf-schema#\" >\n" |
| 354 |
+ '\n' + "<owl:Ontology/>\n" + '\n' + "<owl:DatatypeProperty rdf:about=\"p\" />\n" + '\n' |
| 355 |
+ "<rdf:Description rdf:about=\"p\">\n" + " <rdfs:range>\n" + " <rdfs:Datatype>\n" |
| 356 |
+ " <owl:datatypeComplementOf rdf:resource=\"http://www.w3.org/2001/XMLSchema#positiveInteger\" /></rdfs:Datatype></rdfs:range></rdf:Description>\n" |
| 357 |
+ '\n' + "<rdf:Description rdf:about=\"i\">\n" |
| 358 |
+ " <p rdf:datatype=\"http://www.w3.org/2001/XMLSchema#negativeInteger\">-1</p>\n" |
| 359 |
+ " <p rdf:datatype=\"http://www.w3.org/2001/XMLSchema#string\">A string</p></rdf:Description>\n" |
| 360 |
+ '\n' + "</rdf:RDF>"; |
| 361 |
String conclusion = ""; |
| 362 |
String id = "Datatype_DataComplementOf_001"; |
| 363 |
TestClasses tc = TestClasses.valueOf("CONSISTENCY"); |
| 364 |
String d = "Demonstrates that the complement of a datatype contains literals from other datatypes."; |
| 365 |
JUnitRunner r = new JUnitRunner(premise, conclusion, id, tc, d); |
| 366 |
r.setReasonerFactory(factory()); |
| 367 |
r.run(); |
| 368 |
} |
| 369 |
|
| 370 |
@Test |
| 371 |
|
| 372 |
|
| 373 |
public void testWebOnt_I5_8_007() throws OWLOntologyCreationException { |
| 374 |
OWLOntologyManager m = OWLManager.createOWLOntologyManager(); |
| 375 |
OWLDataFactory f = m.getOWLDataFactory(); |
| 376 |
OWLOntology o = m.createOntology(); |
| 377 |
OWLDataProperty p = f.getOWLDataProperty(IRI.create("urn:p")); |
| 378 |
m.addAxiom( |
| 379 |
o, |
| 380 |
f.getOWLDataPropertyRangeAxiom(p, |
| 381 |
f.getOWLDatatype(OWL2Datatype.XSD_SHORT.getIRI()))); |
| 382 |
OWLReasoner r = factory().createReasoner(o); |
| 383 |
assertFalse("unsigned byte should not be inferred", r.isEntailed(f |
| 384 |
.getOWLDataPropertyRangeAxiom(p, |
| 385 |
f.getOWLDatatype(OWL2Datatype.XSD_UNSIGNED_BYTE |
| 386 |
.getIRI())))); |
| 387 |
} |
| 388 |
|
| 389 |
@Test |
| 390 |
|
| 391 |
|
| 392 |
public void testWebOnt_miscellaneous_202() { |
| 393 |
String premise = |
| 394 |
"Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)\n" |
| 395 |
+ "Prefix(owl:=<http://www.w3.org/2002/07/owl#>)\n" |
| 396 |
+ "Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)\n" |
| 397 |
+ "Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)\n" |
| 398 |
+ "Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)\n" |
| 399 |
+ "Ontology(\n" + "Declaration(DataProperty(<urn:fp>))\n" |
| 400 |
+ "FunctionalDataProperty(<urn:fp>)\n" |
| 401 |
+ "ClassAssertion(owl:Thing <urn:id2>)\n" |
| 402 |
+ "DataPropertyAssertion(<urn:fp> <urn:id2> \"<br></br>\n\n" |
| 403 |
+ "<img></img>\"^^rdf:XMLLiteral)\n" |
| 404 |
+ "DataPropertyAssertion(<urn:fp> <urn:id2> \"<br></br>\n" |
| 405 |
+ "<img></img>\"^^rdf:XMLLiteral)\n" + ')'; |
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
String conclusion = ""; |
| 411 |
String id = "WebOnt_miscellaneous_202"; |
| 412 |
TestClasses tc = TestClasses.valueOf("CONSISTENCY"); |
| 413 |
String d = "This shows that insignificant whitespace in an rdf:XMLLiteral is not significant within OWL."; |
| 414 |
JUnitRunner r = new JUnitRunner(premise, conclusion, id, tc, d); |
| 415 |
r.setReasonerFactory(factory()); |
| 416 |
r.run(); |
| 417 |
} |
| 418 |
|
| 419 |
@Test |
| 420 |
|
| 421 |
|
| 422 |
public void testWebOnt_I4_6_004() { |
| 423 |
String premise = "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:owl=\"http://www.w3.org/2002/07/owl#\"\n" |
| 424 |
+ " xml:base=\"http://www.w3.org/2002/03owlt/I4.6/premises004\" >\n" |
| 425 |
+ " <owl:Ontology/>\n" |
| 426 |
+ " <owl:Class rdf:about=\"nonconclusions004#C1\">\n" |
| 427 |
+ " <owl:equivalentClass>\n" |
| 428 |
+ " <owl:Class rdf:about=\"nonconclusions004#C2\"/></owl:equivalentClass></owl:Class>\n" |
| 429 |
+ "</rdf:RDF>"; |
| 430 |
String conclusion = "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:owl=\"http://www.w3.org/2002/07/owl#\"\n" |
| 431 |
+ " xml:base=\"http://www.w3.org/2002/03owlt/I4.6/nonconclusions004\" >\n" |
| 432 |
+ " <owl:Ontology/>\n" |
| 433 |
+ " <owl:Class rdf:ID=\"C1\">\n" |
| 434 |
+ " <owl:sameAs>\n" |
| 435 |
+ " <owl:Class rdf:ID=\"C2\"/></owl:sameAs></owl:Class>\n" |
| 436 |
+ "</rdf:RDF>"; |
| 437 |
String id = "WebOnt_I4_6_004"; |
| 438 |
TestClasses tc = TestClasses.valueOf("NEGATIVE_IMPL"); |
| 439 |
String d = "owl:sameAs is stronger than owl:equivalentClass."; |
| 440 |
JUnitRunner r = new JUnitRunner(premise, conclusion, id, tc, d); |
| 441 |
r.setReasonerFactory(factory()); |
| 442 |
r.run(); |
| 443 |
} |
| 444 |
|
| 445 |
@Test |
| 446 |
|
| 447 |
public void testQualified_cardinality_boolean() { |
| 448 |
String premise = "Prefix( : = <http://example.org/test#> )\n" |
| 449 |
+ "Prefix( xsd: = <http://www.w3.org/2001/XMLSchema#> )\n" |
| 450 |
+ '\n' |
| 451 |
+ "Ontology(<http://owl.semanticweb.org/page/Special:GetOntology/Qualified-cardinality-boolean?m=p>\n" |
| 452 |
+ " Declaration(NamedIndividual(:a))\n" |
| 453 |
+ " Declaration(Class(:A))\n" |
| 454 |
+ " Declaration(DataProperty(:dp))\n" + '\n' |
| 455 |
+ " SubClassOf(:A DataExactCardinality(2 :dp xsd:boolean))\n" |
| 456 |
+ '\n' + " ClassAssertion(:A :a)\n" + ')'; |
| 457 |
String conclusion = "Prefix( : = <http://example.org/test#> )\n" |
| 458 |
+ "Prefix( xsd: = <http://www.w3.org/2001/XMLSchema#> )\n" |
| 459 |
+ '\n' |
| 460 |
+ "Ontology(<http://owl.semanticweb.org/page/Special:GetOntology/Qualified-cardinality-boolean?m=c>\n" |
| 461 |
+ " Declaration(DataProperty(:dp))\n" + '\n' |
| 462 |
+ " DataPropertyAssertion(:dp :a \"true\"^^xsd:boolean)\n" |
| 463 |
+ " DataPropertyAssertion(:dp :a \"false\"^^xsd:boolean)\n" |
| 464 |
+ ')'; |
| 465 |
String id = "Qualified_cardinality_boolean"; |
| 466 |
TestClasses tc = TestClasses.valueOf("POSITIVE_IMPL"); |
| 467 |
String d = "According to qualified cardinality restriction individual a should have two boolean values. Since there are only two boolean values, the data property assertions can be entailed."; |
| 468 |
JUnitRunner r = new JUnitRunner(premise, conclusion, id, tc, d); |
| 469 |
r.setReasonerFactory(factory()); |
| 470 |
r.run(); |
| 471 |
} |
| 472 |
|
| 473 |
@Test |
| 474 |
|
| 475 |
|
| 476 |
public void testConsistent_Datatype_restrictions_with_Different_Types() { |
| 477 |
String premise = "Prefix(:=<http://example.org/>)\n" |
| 478 |
+ "Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)\n" |
| 479 |
+ "Ontology(\n" |
| 480 |
+ " Declaration(NamedIndividual(:a))\n" |
| 481 |
+ " Declaration(DataProperty(:dp))\n" |
| 482 |
+ " Declaration(Class(:A))\n" |
| 483 |
+ " SubClassOf(:A " |
| 484 |
+ "DataAllValuesFrom(:dp DataOneOf(\"3\"^^xsd:integer \"4\"^^xsd:int))) \n" |
| 485 |
+ " SubClassOf(:A " |
| 486 |
+ "DataAllValuesFrom(:dp DataOneOf(\"2\"^^xsd:short \"3\"^^xsd:int)))\n" |
| 487 |
+ " ClassAssertion(:A :a)\n" |
| 488 |
+ " ClassAssertion(DataSomeValuesFrom(:dp DataOneOf(\"3\"^^xsd:integer)) :a\n" |
| 489 |
+ " )\n" + ')'; |
| 490 |
String conclusion = ""; |
| 491 |
String id = "Consistent_Datatype_restrictions_with_Different_Types"; |
| 492 |
TestClasses tc = TestClasses.valueOf("CONSISTENCY"); |
| 493 |
String d = "The individual a must have dp fillers that are in the sets {3, 4} and {2, 3} (different types are used, but shorts and ints are integers). Furthermore, the dp filler must be 3, but since 3 is in both sets, the ontology is consistent."; |
| 494 |
JUnitRunner r = new JUnitRunner(premise, conclusion, id, tc, d); |
| 495 |
r.setReasonerFactory(factory()); |
| 496 |
r.run(); |
| 497 |
} |
| 498 |
|
| 499 |
@Test |
| 500 |
|
| 501 |
public void testUnsatisfiableClasses() throws OWLOntologyCreationException { |
| 502 |
OWLOntologyManager mngr = OWLManager.createOWLOntologyManager(); |
| 503 |
OWLOntology ont = mngr.createOntology(); |
| 504 |
OWLDataFactory df = OWLManager.getOWLDataFactory(); |
| 505 |
OWLDataProperty dp = df.getOWLDataProperty(IRI |
| 506 |
.create("urn:test:datap1")); |
| 507 |
mngr.addAxiom(ont, |
| 508 |
df.getOWLDataPropertyDomainAxiom(dp, df.getOWLNothing())); |
| 509 |
OWLReasonerFactory fac = factory(); |
| 510 |
OWLReasoner r = fac.createNonBufferingReasoner(ont); |
| 511 |
assertEquals(r.getBottomDataPropertyNode().toString(), 2, r |
| 512 |
.getBottomDataPropertyNode().getEntities().size()); |
| 513 |
} |
| 514 |
|
| 515 |
@Test |
| 516 |
|
| 517 |
public void testWebOnt_I5_8_009() { |
| 518 |
String premise = "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\" xmlns:owl=\"http://www.w3.org/2002/07/owl#\"\n" |
| 519 |
+ " xml:base=\"http://www.w3.org/2002/03owlt/I5.8/premises009\" >\n" |
| 520 |
+ " <owl:Ontology/>\n" |
| 521 |
+ " <owl:DatatypeProperty rdf:ID=\"p\">\n" |
| 522 |
+ " <rdfs:range rdf:resource=\n" |
| 523 |
+ " \"http://www.w3.org/2001/XMLSchema#nonNegativeInteger\" />\n" |
| 524 |
+ " <rdfs:range rdf:resource=\n" |
| 525 |
+ " \"http://www.w3.org/2001/XMLSchema#nonPositiveInteger\" /></owl:DatatypeProperty></rdf:RDF>"; |
| 526 |
String conclusion = "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\" xmlns:owl=\"http://www.w3.org/2002/07/owl#\"\n" |
| 527 |
+ " xml:base=\"http://www.w3.org/2002/03owlt/I5.8/conclusions009\" >\n" |
| 528 |
+ " <owl:Ontology/>\n" |
| 529 |
+ " <owl:DatatypeProperty rdf:about=\"premises009#p\">\n" |
| 530 |
+ " <rdfs:range rdf:resource=\n" |
| 531 |
+ " \"http://www.w3.org/2001/XMLSchema#short\" /></owl:DatatypeProperty>\n" |
| 532 |
+ '\n' + "</rdf:RDF>"; |
| 533 |
String id = "WebOnt_I5_8_009"; |
| 534 |
TestClasses tc = TestClasses.valueOf("POSITIVE_IMPL"); |
| 535 |
String d = "0 is the only xsd:nonNegativeInteger which is\n" |
| 536 |
+ "also an xsd:nonPositiveInteger. 0 is an\n" + "xsd:short."; |
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
JUnitRunner r = new JUnitRunner(premise, conclusion, id, tc, d); |
| 541 |
r.setReasonerFactory(factory()); |
| 542 |
r.run(); |
| 543 |
} |
| 544 |
|
| 545 |
@Test |
| 546 |
|
| 547 |
public void testWebOnt_I5_8_010() { |
| 548 |
String premise = "Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)\n" |
| 549 |
+ "Ontology(\n" |
| 550 |
+ "Declaration(DataProperty(<urn:t#p>))\n" |
| 551 |
+ "DataPropertyRange(<urn:t#p> xsd:nonNegativeInteger)\n" |
| 552 |
+ "ClassAssertion(DataSomeValuesFrom(<urn:t#p> xsd:nonPositiveInteger) <urn:t#john>)\n)"; |
| 553 |
String conclusion = "Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)\n" |
| 554 |
+ "Prefix(owl:=<http://www.w3.org/2002/07/owl#>)\n" |
| 555 |
+ "Ontology(\nDeclaration(DataProperty(<urn:t#p>))\n" |
| 556 |
+ "ClassAssertion(owl:Thing <urn:t#john>)\n" |
| 557 |
+ "DataPropertyAssertion(<urn:t#p> <urn:t#john> \"0\"^^xsd:int)\n)"; |
| 558 |
String id = "WebOnt_I5_8_010"; |
| 559 |
TestClasses tc = TestClasses.valueOf("POSITIVE_IMPL"); |
| 560 |
String d = "0 is the only xsd:nonNegativeInteger which is also an xsd:nonPositiveInteger."; |
| 561 |
JUnitRunner r = new JUnitRunner(premise, conclusion, id, tc, d); |
| 562 |
r.setReasonerFactory(factory()); |
| 563 |
|
| 564 |
r.run(); |
| 565 |
} |
| 566 |
|
| 567 |
@Test |
| 568 |
|
| 569 |
public void testWebOnt_I5_8_008() { |
| 570 |
String premise = "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\" xmlns:owl=\"http://www.w3.org/2002/07/owl#\"\n" |
| 571 |
+ " xml:base=\"http://www.w3.org/2002/03owlt/I5.8/premises008\" >\n" |
| 572 |
+ " <owl:Ontology/>\n" |
| 573 |
+ " <owl:DatatypeProperty rdf:ID=\"p\">\n" |
| 574 |
+ " <rdfs:range rdf:resource=\"http://www.w3.org/2001/XMLSchema#short\" />\n" |
| 575 |
+ " <rdfs:range rdf:resource=\"http://www.w3.org/2001/XMLSchema#unsignedInt\" />" |
| 576 |
+ "</owl:DatatypeProperty></rdf:RDF>"; |
| 577 |
String conclusion = "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\" xmlns:owl=\"http://www.w3.org/2002/07/owl#\"\n" |
| 578 |
+ " xml:base=\"http://www.w3.org/2002/03owlt/I5.8/conclusions008\" >\n<owl:Ontology/>\n" |
| 579 |
+ " <owl:DatatypeProperty rdf:about=\"premises008#p\">\n" |
| 580 |
+ " <rdfs:range rdf:resource=\"http://www.w3.org/2001/XMLSchema#unsignedShort\" /></owl:DatatypeProperty></rdf:RDF>"; |
| 581 |
String id = "WebOnt_I5_8_008"; |
| 582 |
TestClasses tc = TestClasses.valueOf("POSITIVE_IMPL"); |
| 583 |
String d = "-1 is an xsd:short that is not an xsd:unsignedShort; 100000 is an " |
| 584 |
+ "xsd:unsignedInt that is not an xsd:unsignedShort; but there are no\n" |
| 585 |
+ "xsd:unsignedShort which are neither xsd:short nor xsd:unsignedInt"; |
| 586 |
|
| 587 |
|
| 588 |
JUnitRunner r = new JUnitRunner(premise, conclusion, id, tc, d); |
| 589 |
r.setReasonerFactory(factory()); |
| 590 |
r.run(); |
| 591 |
} |
| 592 |
|
| 593 |
@Test |
| 594 |
|
| 595 |
public void testWebOnt_someValuesFrom_003() { |
| 596 |
String premise = "Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)\n" |
| 597 |
+ "Prefix(owl:=<http://www.w3.org/2002/07/owl#>)\n" |
| 598 |
+ "Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)\n" |
| 599 |
+ "Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)\n" |
| 600 |
+ "Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)\n" |
| 601 |
+ "Ontology(\n" |
| 602 |
+ "Declaration(Class(<urn:person>))\n" |
| 603 |
+ "EquivalentClasses(<urn:person> ObjectSomeValuesFrom(<urn:parent> <urn:person>))\n" |
| 604 |
+ "Declaration(ObjectProperty(<urn:parent>))\n" |
| 605 |
+ "ClassAssertion(<urn:person> <urn:fred>))"; |
| 606 |
String conclusion = "Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)\n" |
| 607 |
+ "Prefix(owl:=<http://www.w3.org/2002/07/owl#>)\n" |
| 608 |
+ "Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)\n" |
| 609 |
+ "Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)\n" |
| 610 |
+ "Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)\n" |
| 611 |
+ "Ontology(\n" |
| 612 |
+ "Declaration(ObjectProperty(<urn:parent>))\n" |
| 613 |
+ |
| 614 |
|
| 615 |
|
| 616 |
"ObjectPropertyAssertion(<urn:parent> <urn:fred> _:genid2)\n" |
| 617 |
+ "ClassAssertion(owl:Thing _:genid3)\n" |
| 618 |
+ "ClassAssertion(owl:Thing _:genid2)\n" |
| 619 |
+ "ObjectPropertyAssertion(<urn:parent> _:genid2 _:genid3))"; |
| 620 |
|
| 621 |
|
| 622 |
String id = "WebOnt_someValuesFrom_003"; |
| 623 |
TestClasses tc = TestClasses.valueOf("POSITIVE_IMPL"); |
| 624 |
String d = "A simple infinite loop for implementors to avoid."; |
| 625 |
JUnitRunner r = new JUnitRunner(premise, conclusion, id, tc, d); |
| 626 |
r.setReasonerFactory(factory()); |
| 627 |
r.run(); |
| 628 |
} |
| 629 |
|
| 630 |
@Test |
| 631 |
|
| 632 |
public void testsomevaluesfrom2bnode() throws OWLOntologyCreationException { |
| 633 |
|
| 634 |
|
| 635 |
OWLOntologyManager m = OWLManager.createOWLOntologyManager(); |
| 636 |
OWLDataFactory f = m.getOWLDataFactory(); |
| 637 |
OWLOntology o = m.createOntology(); |
| 638 |
OWLObjectProperty p = f.getOWLObjectProperty(IRI.create("urn:p")); |
| 639 |
OWLNamedIndividual a = f.getOWLNamedIndividual(IRI.create("urn:a")); |
| 640 |
OWLObjectSomeValuesFrom c = f.getOWLObjectSomeValuesFrom(p, |
| 641 |
f.getOWLThing()); |
| 642 |
m.addAxiom(o, f.getOWLClassAssertionAxiom(c, a)); |
| 643 |
OWLReasoner r = factory().createReasoner(o); |
| 644 |
assertTrue(r.isEntailed(f.getOWLObjectPropertyAssertionAxiom(p, a, |
| 645 |
f.getOWLAnonymousIndividual()))); |
| 646 |
} |
| 647 |
} |