PREFIX rsyn: SELECT ?b ?y WHERE { ?b rsyn:type rsyn:Bag . ?b ?x ?y . FILTER ( ! ( ( str(?x) = str(rsyn:type) ) && ( str(?y) = str(rsyn:Bag) ) ) ) . }