Github user jessehatfield commented on a diff in the pull request: https://github.com/apache/incubator-rya/pull/180#discussion_r132230928 --- Diff: sail/src/main/java/org/apache/rya/rdftriplestore/inference/InferenceEngine.java --- @@ -142,6 +143,53 @@ public void refreshGraph() throws InferenceEngineException { } } + // Add unions to the subclass graph: if c owl:unionOf LIST(c1, c2, ... cn), then any + // instances of c1, c2, ... or cn are also instances of c, meaning c is a superclass + // of all the rest. + // (In principle, an instance of c is likewise implied to be at least one of the other + // types, but this fact is ignored for now to avoid nondeterministic reasoning.) + iter = RyaDAOHelper.query(ryaDAO, null, OWL.UNIONOF, null, conf); + try { + while (iter.hasNext()) { + Statement st = iter.next(); + Value unionType = st.getSubject(); + // Traverse the list of types constituting the union + Value current = st.getObject(); + while (current instanceof Resource && !RDF.NIL.equals(current)) { + Resource listNode = (Resource) current; + CloseableIteration<Statement, QueryEvaluationException> listIter = RyaDAOHelper.query(ryaDAO, + listNode, RDF.FIRST, null, conf); + try { + if (listIter.hasNext()) { + Statement firstStatement = listIter.next(); + if (firstStatement.getObject() instanceof Resource) { + Resource subclass = (Resource) firstStatement.getObject(); + Statement subclassStatement = vf.createStatement(subclass, RDFS.SUBCLASSOF, unionType); + addStatementEdge(graph, RDFS.SUBCLASSOF.stringValue(), subclassStatement); + } + } + } finally { + listIter.close(); + } + listIter = RyaDAOHelper.query(ryaDAO, listNode, RDF.REST, null, conf); + try { + if (listIter.hasNext()) { + current = listIter.next().getObject(); --- End diff -- Yep, a union is given as a linked list so we just walk down adding subclass statements until we get to a node with no rdf:rest or with rdf:rest equal to rdf:nil. If the list is poorly-formed or someone tries to express the union using the wrong collection type ([describes unionOf expression](https://www.w3.org/TR/owl2-rdf-based-semantics/#Semantic_Conditions_for_Boolean_Connectives) | [gives interpretation of sequence](https://www.w3.org/TR/owl2-rdf-based-semantics/#Semantic_Conditions)) then it won't work. In most cases that just means the intended union isn't fully represented, but I suppose if it were somehow a cyclical list, we'd end up in an infinite loop.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---