ASF GitHub Bot commented on RYA-295:

GitHub user jessehatfield opened a pull request:


    RYA-295 owl:allValuesFrom inference

    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at
    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
    ## Description
    Inference applies owl:allValuesFrom semantics for queries including 
statement patterns of the form "?x rdf:type :DefinedClass".
    An owl:allValuesFrom property restriction is a universal class expression: 
it defines type T1 to be the set of individuals such that, for a given property 
p and type T2, all values of that property (i.e. all objects of triples where 
the predicate is p and the subject belongs to T1) have type T2. Therefore, if 
an individual is known to belong to the universal class expression (T1), then 
it can be inferred that all of its values for the property belong to the value 
type (T2). This is similar to rdfs:range except that it only applies when the 
subject of the triple belongs to the appropriate class expression.
    InferenceEngine, at refresh time, stores information about 
owl:allValuesFrom restrictions (universal class expressions). These definitions 
can then be accessed by the value type: getAllValuesFromByValueType(<value 
type>) returns every (restriction type, property) pair.
    AllValuesFromVisitor processes statement patterns of the form "?x rdf:type 
:T2", and if :T2 is the value type for any owl:allValuesFrom restriction 
according to the inference engine, it replaces the statement pattern with a 
union: of 1) that same statement pattern (in case the type is explicitly 
asserted or can be inferred by some other rule); and 2) a subquery of the form 
"?y \:p ?x . ?y rdf:type :T1" for the appropriate (restriction type, property) 
    RdfCloudTripleStoreConnection calls the visitor along with the other 
inference logic. Because the original statement pattern is preserved as one 
branch of the union, other visitors can still apply if there are other ways to 
derive the type.
    Added a simple example of a query that relies on this inference to 
    ### Tests
    Unit test to verify that InferenceEngine stores and returns the schema; 
unit test to verify that AllValuesFromVisitor rewrites queries of the proper 
form; integration test to verify correct results for sample 
ontology+instances+query relying on allValuesFrom inference.
    ### Links
    ### Checklist
    - [ ] Code Review
    - [ ] Squash Commits
    #### People To Reivew

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/jessehatfield/incubator-rya 

Alternatively you can review and apply these changes as the patch at:


To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #201
commit 55eae37e2f4aaef2f8cd41c735241c2ae85b88af
Author: Jesse Hatfield <jesse.hatfi...@parsons.com>
Date:   2017-08-08T19:58:10Z

    RYA-295 owl:allValuesFrom inference


> 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
>            Assignee: 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 }
> { ?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

Reply via email to