[ https://issues.apache.org/jira/browse/RYA-295?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16092144#comment-16092144 ]
Jesse Hatfield commented on RYA-295: ------------------------------------ In general, if we have{quote}:A owl:onProperty :p . :A owl:allValuesFrom :B {quote} then this means:{quote}x is an A *if and only if*, for all y, *if* (x p y) *then* y is a B.{quote} As described above, we can never deduce the second half ("for all y, if ... then") just from the data, because of the open-world assumption. Therefore the only implication we need to consider is bq. *If* x is an A *then* for all y, *if* (x p y) *then* y is a B. Equivalently: bq. *If* there exists some x *such that* (x is an A) AND (x p y) *then* y is a B. This is the same kind of expression we can derive from owl:someValuesFrom, described in [RYA-294], but in the reverse direction: inferring the object's type if there exist some subject who has it as a value. We can use the same approach. In the inference engine: {code}allValuesFromByValueType <- Map<valueType, Map<property, restrictionType)> for (restrictionType, property) in propertyRestrictions: for valueType in query(property owl:allValuesFrom ?valueType): allValuesFromByValueType[valueType][property] <- restrictionType ... getAllValuesFromImplying(type): // return (property, restriction type) pairs that would imply this type results <- List<(property, restrictionType)> for sufficientType <- type UNION getAllSubClasses(type): if sufficientType in allValuesFromByValueType: results.addAll(allValuesFromByValueType[sufficientType]) return results{code} And a visitor: {code}meet(StatementPattern originalSP): if originalSP like (?object rdf:type :C1): // Assume the type in question is explicitly given in the query, not a variable node <- originalSP for (property, restrictionType) in inferenceEngine.getAllValuesFromImplying(C1): option <- InferJoin(StatementPattern(?subject, property, ?object), StatementPattern(?subject, rdf:type, restrictionType)) node <- InferUnion(node, option) originalSP.replaceWith(node){code} > Implement owl:allValuesFrom inference > ------------------------------------- > > Key: RYA-295 > URL: https://issues.apache.org/jira/browse/RYA-295 > Project: Rya > Issue Type: Sub-task > Components: sail > Reporter: Jesse Hatfield > > An *{{owl:allValuesFrom}}* restriction defines the set of resources for > which, given a particular predicate and other type, every value of that > predicate is a member of that type. Note that there may be no values at all. > For example, the ontology may state that resources of type {{:Person}} have > all values from {{:Person}} for type {{:parent}}: that is, a person's parents > are all people as well. Therefore, a pattern of the form {{?x rdf:type > :Person}} should be expanded to: > {noformat} > { ?y rdf:type :Person . > ?y :parent ?x } > UNION > { ?x rdf:type :Person } > {noformat} > i.e. we can infer {{?x}}'s personhood from the fact that child {{?y}} is > known to satisfy the restriction. > Notes: > -We can infer "x is a person, therefore all of x's parents are people". But > we can't infer "all of x's parents are people, therefore x is a person", > because of the open world semantics: we don't know that the parents given by > the data are in fact all of x's parents. (If there were also a cardinality > restriction and we could presume consistency, then we could infer this in the > right circumstances, but this is outside the scope of basic allValuesFrom > support.) This differs with most other property restriction rules in that we > can't infer that an object belongs to the class defined by the restriction, > but rather use the fact that an object is already known to belong in that > class in order to infer something about its neighbors in the graph (the types > of the values). > -The example above could be applied recursively, but to implement this as a > simple query rewrite we'll need to limit recursion depth (and interactions > with other rules, for the same reasons). -- This message was sent by Atlassian JIRA (v6.4.14#64029)