Google Groups

Incorrect query results


Robert Butler Jun 27, 2012 5:40 PM
Posted in group: Stardog
I've isolated a case where reasoning returns incorrect results for the QL profile (haven't tested the others). My ontology has two properties that are the inverse of each other. This bug came up because I unintentionally made my insert code assert both the property and it's inverse instead of leaving one direction to inference. Below are simplified versions of the 3 queries I'm running and a description of the issue.

I've attached a complete test that does the following:

1) loads the data with both inverse properties asserted
2) runs the queries and prints info about the output
3) deletes one of the directions of the inverse property
4) runs the queries and prints info with the correct results

A basic description of the problem with the queries is as follows:

Query 1 (works):
SELECT
WHERE {
?obj2 :property ?obj1 .
top level patterns
}

Query 2 (fails):
SELECT
WHERE {
?obj1 :inverseProperty ?obj2 .
top level patterns
{
triple patterns
} UNION {
triple patterns
}
}

Query 3 (fails):
SELECT
WHERE {
?obj2 :property ?obj1 .
top level patterns
{
triple patterns
} UNION {
triple patterns
}

Notice that query 2 has "inverseProperty". In the test data, both happen to be asserted but the ":property" will normally be inferred by QL. Also note that all three queries should always have ?obj1 bindings for all result bindings.

The results returned are as follows:
Reasoning: NONE - Inverse properties asserted
query 1 (correct):
- 3 results
- 0 result bindings missing ?obj1
- 3 unique values for ?obj1
query 2 (correct):
- 12 results
- 0 missing ?objX bindings
- 3 unique values for ?obj1
query 3 (correct):
- 12 results
- 0 missing ?objX bindings
- 3 unique values for ?obj1

Reasoning: QL - Inverse properties asserted
query 1 (correct):
- 3 results
- 0 result bindings missing ?obj1
- 3 unique values for ?obj1
query 2 (incorrect):
- 56 results
- 53 missing ?objX bindings
- 3 unique values for ?obj1
query 3 (incorrect):
- 56 results
- 53 missing ?objX bindings
- 3 unique values for ?obj1

Reasoning: NONE - Inverse properties removed
query 1 (correct):
- 0 results
- 0 result bindings missing ?obj1
- 0 unique values for ?obj1
query 2 (correct):
- 12 results
- 0 missing ?objX bindings
- 3 unique values for ?obj1
query 3 (correct):
- 0 results
- 0 missing ?objX bindings
- 0 unique values for ?obj1

Reasoning: QL - Inverse properties removed
query 1 (correct):
- 3 results
- 0 result bindings missing ?obj1
- 3 unique values for ?obj1
query 2 (incorrect):
- 12 results
- 0 missing ?objX bindings
- 3 unique values for ?obj1
query 3 (incorrect):
- 12 results
- 0 missing ?objX bindings
- 3 unique values for ?obj1


Query 2 & 3 appear to execute as the following with QL and inverses asserted:
SELECT
WHERE {
{
?obj2 :property ?obj1 .
top level patterns
} UNION {
{
triple patterns
} UNION {
triple patterns
}
}

Sample data (with ontology included), queries and test code are included in the attached zip.