问题
I have the following case which I'm trying write an RDF/OWL rule for. The goal is to improve consistency checking in the resulting data base.
I have a class called "Expression" and a class called "Manifestation", they can be related by "hasManifestation".
It easy to enough to restrict the domain and range accordingly so that the domain of "hasManifestation" is "Expression" and the Range is "Manifestation".
But I want to go one step further.
Expressions and Manifestation have a property called structure level, level 1, 2, 3, 4
So an Expression at level 1 should always be related through "hasManifestation" to a "Manifestation" also at level 1, never at level 2, 3, etc.
Likewise an Expression at level 2 should always be related to a Manifestation at level 2 never at level 1 or 3, etc.
So I want write a rule for the Domain and Range of "hasManifestation" that goes something like the following:
Range: Y must be a Manifestation and if the value of the Domain is level Z, then Y must be level Z
Domain: X must be an Expression and if the value of the Range is level Z, then X is level X.
I think I can write this in predicate logic as follows: E = expression, M=manifestation, L=level, R=Range, D=Domain
Range: y(My and (xz)(Dx and Lxz) -> (Lyz))
Domain: x(Ex and (yz)(Ry and Lyz) -> (Lxz))
I might be messing that up somewhere, but hopefully you get the idea of what I would like to do. But how could I write this as an OWL statement in ttl.
Any advice is much appreciated.
回答1:
You can use hasValue
restrictions to express this, but not at the domain and range level of the property - restricting it on the property requires a property for each level.
So, you could create a general concept inclusion axiom, along the lines of:
(<urn:test:Expression> and (<urn:test:hasLevel> value 1)) subclassOf
(<urn:test:hasManifestation> some (<urn:test:Manifestation> and (<urn:test:hasLevel> value 1)))
(example rewritten in Manchester Syntax - GCIs cannot actually be written in this syntax but it's easier to read)
In Functional syntax, the axiom looks like this:
SubClassOf(
ObjectIntersectionOf(
Expression
DataHasValue(hasLevel "1"^^xsd:integer)
)
ObjectSomeValuesFrom(hasManifestation
ObjectIntersectionOf(
Manifestation
DataHasValue(hasLevel "1"^^xsd:integer)
)
)
)
In Turtle:
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@base <http://www.w3.org/2002/07/owl#> .
[ rdf:type owl:Ontology] .
<urn:test:hasManifestation> rdf:type owl:ObjectProperty .
<urn:test:hasLevel> rdf:type owl:DatatypeProperty .
<urn:test:Expression> rdf:type owl:Class .
<urn:test:Manifestation> rdf:type owl:Class .
[ owl:intersectionOf ( <urn:test:Expression>
[ rdf:type owl:Restriction ;
owl:onProperty <urn:test:hasLevel> ;
owl:hasValue 1
]
) ;
rdf:type owl:Class ;
rdfs:subClassOf [ rdf:type owl:Restriction ;
owl:onProperty <urn:test:hasManifestation> ;
owl:someValuesFrom [ owl:intersectionOf ( <urn:test:Manifestation>
[ rdf:type owl:Restriction ;
owl:onProperty <urn:test:hasLevel> ;
owl:hasValue 1
]) ;
rdf:type owl:Class
]
]
] .
If you choose to use multiple properties, it's easier to declare domains and ranges but you have to use multiple properties:
hasManifestation1 domain exist hasLevel (hasValue 1)
hasManifestation1 range exist hasLevel (hasValue 1)
and so on (no need to modify existing domain and range expressions as multiple axioms are already implying intersection of the class expressions).
来源:https://stackoverflow.com/questions/61130810/how-to-write-rdf-domain-and-range-restriction-based-on-property-value-rather-tha