I know it's a hack but something I find useful (and I've seen other people do this as well) is to group datatype properties under a super-property. For ontologies with real data you often end up with many data properties. It can be useful in tools like Protégé to group properties together under super-properties. E.g., all the properties related to the Person class under a personProperty super property. The problem is that when you run the reasoner, you end up essentially doubling the number of datatype property values with useless triples. Also, most reasoners don't allow you to turn this off. E.g., in Protégé with Pellet you can uncheck the super properties box in Reasoner>Configure but it does it anyway. This just happened to me with a large ontology in AllegroGraph and it caused problems for our GUI because it was cluttered with all these redundant values. I wrote the following query to remove these redundant triples:
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
DELETE {?s ?sp ?o.}
WHERE {?sp a owl:DatatypeProperty.
?dp rdfs:subPropertyOf ?sp.
?s ?sp ?o.
FILTER(?sp != ?dp)}
I first wrote it without the FILTER but that ended up deleting all the data property values because properties are relations in logic and relations are sets and a set is always a subset of itself. So without the FILTER statement you end up deleting all your datatype property values. Also, if you want to exclude one or more super-properties from the deletion (i.e., in that case you DO want those extra triples) you can just add the name of that datatype property into the FILTER. E.g., suppose you want to retain the extra values for ex:fooSuperProperty. Just add the appropriate IRI for the ex prefix and do:
DELETE {?s ?sp ?o.}
WHERE {?sp a owl:DatatypeProperty.
?dp rdfs:subPropertyOf ?sp.
?s ?sp ?o.
FILTER(?sp != ?dp && ?sp != ex:fooSuperProperty)}
I've added this as a new file with comments in my GitHub repository of useful SPARQL queries: https://github.com/mdebellis/SPARQL_Tools
Comments