Unexpected SPARQL FILTER results

Does the following query work for you? It works for me in Blazegraph, in which your original query also doesn't work.

SELECT DISTINCT ?s1 ?s2 {
  ?s1 ?p ?o . ?s2 ?p ?o .
  FILTER NOT EXISTS {
    ?s1 ?p ?o . ?s2 ?p ?o . 
    ?s1 ?p1 ?o1 . FILTER NOT EXISTS { ?s2 ?p1 ?o1 } }
  FILTER NOT EXISTS {
    ?s1 ?p ?o . ?s2 ?p ?o .
    ?s2 ?p2 ?o2 . FILTER NOT EXISTS { ?s1 ?p2 ?o2 } }
  FILTER (STR(?s1) < STR(?s2))
}

If so, then this article is probably related: The Problem of Correlation and Substitution in SPARQL.

2 Likes