diff options
| author | Federico Igne <federico.igne@cs.ox.ac.uk> | 2020-11-09 18:15:30 +0000 |
|---|---|---|
| committer | Federico Igne <federico.igne@cs.ox.ac.uk> | 2020-11-09 18:15:30 +0000 |
| commit | 6364c8afcece09230fa256613b4d28aede79e40d (patch) | |
| tree | 0763035c1fd303b7cb42fb0e4ab202f2136cf7f4 /src | |
| parent | b60f60013c560a4d481e95f762e6a7c31c7a5ad2 (diff) | |
| download | RSAComb-6364c8afcece09230fa256613b4d28aede79e40d.tar.gz RSAComb-6364c8afcece09230fa256613b4d28aede79e40d.zip | |
Fix `notIn` implementation in canonical model
The informal definition provided by the paper in wrong, and it turns out
`notIn` just means "not in".
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/scala/rsacomb/RSAOntology.scala | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/main/scala/rsacomb/RSAOntology.scala b/src/main/scala/rsacomb/RSAOntology.scala index 60008a2..8d6fe8c 100644 --- a/src/main/scala/rsacomb/RSAOntology.scala +++ b/src/main/scala/rsacomb/RSAOntology.scala | |||
| @@ -19,7 +19,7 @@ import org.semanticweb.owlapi.model.{IRI => OWLIRI} | |||
| 19 | import uk.ac.manchester.cs.owl.owlapi.OWLObjectPropertyImpl | 19 | import uk.ac.manchester.cs.owl.owlapi.OWLObjectPropertyImpl |
| 20 | 20 | ||
| 21 | import tech.oxfordsemantic.jrdfox.client.{UpdateType, DataStoreConnection} | 21 | import tech.oxfordsemantic.jrdfox.client.{UpdateType, DataStoreConnection} |
| 22 | import tech.oxfordsemantic.jrdfox.logic.datalog.{Rule, TupleTableAtom} | 22 | import tech.oxfordsemantic.jrdfox.logic.datalog.{Rule, TupleTableAtom, Negation} |
| 23 | import tech.oxfordsemantic.jrdfox.logic.expression.{ | 23 | import tech.oxfordsemantic.jrdfox.logic.expression.{ |
| 24 | Term, | 24 | Term, |
| 25 | Variable, | 25 | Variable, |
| @@ -97,11 +97,11 @@ trait RSAOntology { | |||
| 97 | val unsafe = this.unsafeRoles | 97 | val unsafe = this.unsafeRoles |
| 98 | 98 | ||
| 99 | /* DEBUG: print rules in DL syntax and unsafe roles */ | 99 | /* DEBUG: print rules in DL syntax and unsafe roles */ |
| 100 | val renderer = new DLSyntaxObjectRenderer() | 100 | //val renderer = new DLSyntaxObjectRenderer() |
| 101 | println("\nDL rules:") | 101 | //println("\nDL rules:") |
| 102 | axioms.foreach(x => println(renderer.render(x))) | 102 | //axioms.foreach(x => println(renderer.render(x))) |
| 103 | println("\nUnsafe roles:") | 103 | //println("\nUnsafe roles:") |
| 104 | println(unsafe) | 104 | //println(unsafe) |
| 105 | 105 | ||
| 106 | /* Ontology convertion into LP rules */ | 106 | /* Ontology convertion into LP rules */ |
| 107 | val datalog = for { | 107 | val datalog = for { |
| @@ -116,8 +116,8 @@ trait RSAOntology { | |||
| 116 | } yield rule | 116 | } yield rule |
| 117 | 117 | ||
| 118 | /* DEBUG: print datalog rules */ | 118 | /* DEBUG: print datalog rules */ |
| 119 | println("\nDatalog roles:") | 119 | //println("\nDatalog roles:") |
| 120 | datalog.foreach(println) | 120 | //datalog.foreach(println) |
| 121 | 121 | ||
| 122 | // Open connection with RDFox | 122 | // Open connection with RDFox |
| 123 | val (server, data) = RDFoxUtil.openConnection("RSACheck") | 123 | val (server, data) = RDFoxUtil.openConnection("RSACheck") |
| @@ -147,7 +147,7 @@ trait RSAOntology { | |||
| 147 | /* Build graph | 147 | /* Build graph |
| 148 | */ | 148 | */ |
| 149 | val graph = this.rsaGraph(data); | 149 | val graph = this.rsaGraph(data); |
| 150 | println(graph) | 150 | //println(graph) |
| 151 | 151 | ||
| 152 | // Close connection to RDFox | 152 | // Close connection to RDFox |
| 153 | RDFoxUtil.closeConnection(server, data) | 153 | RDFoxUtil.closeConnection(server, data) |
| @@ -426,20 +426,21 @@ trait RSAOntology { | |||
| 426 | private def rules1(axiom: OWLSubClassOfAxiom): List[Rule] = { | 426 | private def rules1(axiom: OWLSubClassOfAxiom): List[Rule] = { |
| 427 | val unfold = ontology.unfold(axiom).toList | 427 | val unfold = ontology.unfold(axiom).toList |
| 428 | // Fresh Variables | 428 | // Fresh Variables |
| 429 | val v0 = IRI.create("v0_" ++ axiom.hashCode.toString) | 429 | val v0 = RSA.internal("v0_" ++ axiom.hashCode.toString) |
| 430 | val varX = Variable.create("X") | 430 | val varX = Variable.create("X") |
| 431 | // Predicates | 431 | // Predicates |
| 432 | val atomA: TupleTableAtom = { | 432 | val atomA: TupleTableAtom = { |
| 433 | val cls = axiom.getSubClass.asInstanceOf[OWLClass].getIRI | 433 | val cls = axiom.getSubClass.asInstanceOf[OWLClass].getIRI |
| 434 | TupleTableAtom.rdf(varX, IRI.RDF_TYPE, cls) | 434 | TupleTableAtom.rdf(varX, IRI.RDF_TYPE, cls) |
| 435 | } | 435 | } |
| 436 | def notIn(t: Term): TupleTableAtom = { | 436 | def in(t: Term): TupleTableAtom = { |
| 437 | TupleTableAtom.rdf( | 437 | TupleTableAtom.rdf( |
| 438 | t, | 438 | t, |
| 439 | RSA.internal("notIn"), | 439 | RSA.internal("IN"), |
| 440 | RSA.internal(unfold.hashCode.toString) | 440 | RSA.internal(unfold.hashCode.toString) |
| 441 | ) | 441 | ) |
| 442 | } | 442 | } |
| 443 | def notIn(t: Term): Negation = Negation.create(in(t)) | ||
| 443 | val roleRf: TupleTableAtom = { | 444 | val roleRf: TupleTableAtom = { |
| 444 | val visitor = | 445 | val visitor = |
| 445 | new RDFoxPropertyExprConverter(varX, v0, RSASuffix.Forward) | 446 | new RDFoxPropertyExprConverter(varX, v0, RSASuffix.Forward) |
| @@ -461,7 +462,7 @@ trait RSAOntology { | |||
| 461 | // returning facts as `Rule`s with true body. While this is correct | 462 | // returning facts as `Rule`s with true body. While this is correct |
| 462 | // there is an easier way to import facts into RDFox. Are we able to | 463 | // there is an easier way to import facts into RDFox. Are we able to |
| 463 | // do that? | 464 | // do that? |
| 464 | val facts = unfold.map(x => Rule.create(notIn(x))) | 465 | val facts = unfold.map(x => Rule.create(in(x))) |
| 465 | val rules = List( | 466 | val rules = List( |
| 466 | Rule.create(roleRf, atomA, notIn(varX)), | 467 | Rule.create(roleRf, atomA, notIn(varX)), |
| 467 | Rule.create(atomB, atomA, notIn(varX)) | 468 | Rule.create(atomB, atomA, notIn(varX)) |
| @@ -476,9 +477,9 @@ trait RSAOntology { | |||
| 476 | .getProperty | 477 | .getProperty |
| 477 | if (ontology.confl(roleR) contains roleR) { | 478 | if (ontology.confl(roleR) contains roleR) { |
| 478 | // Fresh Variables | 479 | // Fresh Variables |
| 479 | val v0 = IRI.create("v0_" ++ axiom.hashCode.toString) | 480 | val v0 = RSA.internal("v0_" ++ axiom.hashCode.toString) |
| 480 | val v1 = IRI.create("v1_" ++ axiom.hashCode.toString) | 481 | val v1 = RSA.internal("v1_" ++ axiom.hashCode.toString) |
| 481 | val v2 = IRI.create("v2_" ++ axiom.hashCode.toString) | 482 | val v2 = RSA.internal("v2_" ++ axiom.hashCode.toString) |
| 482 | // Predicates | 483 | // Predicates |
| 483 | def atomA(t: Term): TupleTableAtom = { | 484 | def atomA(t: Term): TupleTableAtom = { |
| 484 | val cls = axiom.getSubClass.asInstanceOf[OWLClass].getIRI | 485 | val cls = axiom.getSubClass.asInstanceOf[OWLClass].getIRI |
| @@ -516,7 +517,7 @@ trait RSAOntology { | |||
| 516 | .asInstanceOf[OWLObjectSomeValuesFrom] | 517 | .asInstanceOf[OWLObjectSomeValuesFrom] |
| 517 | .getProperty | 518 | .getProperty |
| 518 | // Fresh Variables | 519 | // Fresh Variables |
| 519 | val v1 = IRI.create("v1_" ++ axiom.hashCode.toString) | 520 | val v1 = RSA.internal("v1_" ++ axiom.hashCode.toString) |
| 520 | // Predicates | 521 | // Predicates |
| 521 | def atomA(t: Term): TupleTableAtom = { | 522 | def atomA(t: Term): TupleTableAtom = { |
| 522 | val cls = axiom.getSubClass.asInstanceOf[OWLClass].getIRI | 523 | val cls = axiom.getSubClass.asInstanceOf[OWLClass].getIRI |
