diff options
author | Federico Igne <federico.igne@cs.ox.ac.uk> | 2020-11-13 18:51:17 +0000 |
---|---|---|
committer | Federico Igne <federico.igne@cs.ox.ac.uk> | 2020-11-13 18:51:17 +0000 |
commit | 9e1549537b22851c360b05460098c9e1cee4dcaa (patch) | |
tree | 5a55f60586befa7fa41275b0389d3d498b2408f2 /src | |
parent | 903983b48d49e17e035bd233d94cd5cb58661a19 (diff) | |
download | RSAComb-9e1549537b22851c360b05460098c9e1cee4dcaa.tar.gz RSAComb-9e1549537b22851c360b05460098c9e1cee4dcaa.zip |
Add first implementation of top and equality axiomatization
This is a first stab of the axiomatization. For equality we are deriving
owl:sameAs triples (not ideal) and did not yet introduced "substitution"
rules.
Diffstat (limited to 'src')
-rw-r--r-- | src/main/scala/rsacomb/RSAOntology.scala | 60 |
1 files changed, 58 insertions, 2 deletions
diff --git a/src/main/scala/rsacomb/RSAOntology.scala b/src/main/scala/rsacomb/RSAOntology.scala index 03b3765..dcd9c63 100644 --- a/src/main/scala/rsacomb/RSAOntology.scala +++ b/src/main/scala/rsacomb/RSAOntology.scala | |||
@@ -19,7 +19,12 @@ 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, Negation} | 22 | import tech.oxfordsemantic.jrdfox.logic.datalog.{ |
23 | Rule, | ||
24 | TupleTableAtom, | ||
25 | Negation, | ||
26 | BodyFormula | ||
27 | } | ||
23 | import tech.oxfordsemantic.jrdfox.logic.expression.{ | 28 | import tech.oxfordsemantic.jrdfox.logic.expression.{ |
24 | Term, | 29 | Term, |
25 | Variable, | 30 | Variable, |
@@ -37,6 +42,7 @@ import scalax.collection.GraphEdge.UnDiEdge | |||
37 | /* Debug only */ | 42 | /* Debug only */ |
38 | import org.semanticweb.owlapi.dlsyntax.renderer.DLSyntaxObjectRenderer | 43 | import org.semanticweb.owlapi.dlsyntax.renderer.DLSyntaxObjectRenderer |
39 | import tech.oxfordsemantic.jrdfox.logic._ | 44 | import tech.oxfordsemantic.jrdfox.logic._ |
45 | import org.semanticweb.owlapi.model.OWLObjectInverseOf | ||
40 | 46 | ||
41 | object RSAOntology {} | 47 | object RSAOntology {} |
42 | /* Wrapper trait for the implicit class `RSAOntology`. | 48 | /* Wrapper trait for the implicit class `RSAOntology`. |
@@ -82,6 +88,9 @@ trait RSAOntology { | |||
82 | .map(RDFoxUtil.owlapi2rdfox) | 88 | .map(RDFoxUtil.owlapi2rdfox) |
83 | .toList | 89 | .toList |
84 | 90 | ||
91 | lazy val concepts: List[OWLClass] = | ||
92 | ontology.getClassesInSignature().asScala.toList | ||
93 | |||
85 | lazy val roles: List[OWLObjectPropertyExpression] = | 94 | lazy val roles: List[OWLObjectPropertyExpression] = |
86 | axioms | 95 | axioms |
87 | .flatMap(_.objectPropertyExpressionsInSignature) | 96 | .flatMap(_.objectPropertyExpressionsInSignature) |
@@ -459,11 +468,58 @@ trait RSAOntology { | |||
459 | .flatMap(additional) | 468 | .flatMap(additional) |
460 | } | 469 | } |
461 | 470 | ||
471 | private lazy val topAxioms: List[Rule] = | ||
472 | concepts.map(c => { | ||
473 | val x = Variable.create("X") | ||
474 | Rule.create( | ||
475 | TupleTableAtom.rdf(x, IRI.RDF_TYPE, IRI.THING), | ||
476 | TupleTableAtom.rdf(x, IRI.RDF_TYPE, c.getIRI) | ||
477 | ) | ||
478 | }) ++ | ||
479 | roles.map(r => { | ||
480 | val x = Variable.create("X") | ||
481 | val y = Variable.create("Y") | ||
482 | val iri: IRI = r match { | ||
483 | case x: OWLObjectProperty => x.getIRI | ||
484 | case x: OWLObjectInverseOf => | ||
485 | IRI.create(x.getNamedProperty.getIRI.getIRIString ++ "_inv") | ||
486 | case x => x.getNamedProperty.getIRI | ||
487 | } | ||
488 | Rule.create( | ||
489 | List( | ||
490 | TupleTableAtom.rdf(x, IRI.RDF_TYPE, IRI.THING), | ||
491 | TupleTableAtom.rdf(y, IRI.RDF_TYPE, IRI.THING) | ||
492 | ).asJava, | ||
493 | List[BodyFormula](TupleTableAtom.rdf(x, iri, y)).asJava | ||
494 | ) | ||
495 | }) | ||
496 | |||
497 | private val equalityAxioms: List[Rule] = { | ||
498 | val x = Variable.create("X") | ||
499 | val y = Variable.create("Y") | ||
500 | val z = Variable.create("Z") | ||
501 | List( | ||
502 | Rule.create( | ||
503 | TupleTableAtom.rdf(x, IRI.SAME_AS, x), | ||
504 | TupleTableAtom.rdf(x, IRI.RDF_TYPE, IRI.THING) | ||
505 | ), | ||
506 | Rule.create( | ||
507 | TupleTableAtom.rdf(y, IRI.SAME_AS, x), | ||
508 | TupleTableAtom.rdf(x, IRI.SAME_AS, y) | ||
509 | ), | ||
510 | Rule.create( | ||
511 | TupleTableAtom.rdf(x, IRI.SAME_AS, z), | ||
512 | TupleTableAtom.rdf(x, IRI.SAME_AS, y), | ||
513 | TupleTableAtom.rdf(y, IRI.SAME_AS, z) | ||
514 | ) | ||
515 | ) | ||
516 | } | ||
517 | |||
462 | val rules: List[Rule] = { | 518 | val rules: List[Rule] = { |
463 | // Compute rules from ontology axioms | 519 | // Compute rules from ontology axioms |
464 | val rules = axioms.flatMap(_.accept(this.ProgramGenerator)) | 520 | val rules = axioms.flatMap(_.accept(this.ProgramGenerator)) |
465 | // Return full set of rules | 521 | // Return full set of rules |
466 | rules ++ rolesAdditionalRules ++ NIs | 522 | rules ++ rolesAdditionalRules ++ topAxioms ++ equalityAxioms ++ NIs |
467 | } | 523 | } |
468 | 524 | ||
469 | object ProgramGenerator | 525 | object ProgramGenerator |