Skip to content

Instantly share code, notes, and snippets.

@niklasl
Last active July 4, 2025 16:17
Show Gist options
  • Save niklasl/cf8871f82564749153d929f747228ef3 to your computer and use it in GitHub Desktop.
Save niklasl/cf8871f82564749153d929f747228ef3 to your computer and use it in GitHub Desktop.
OWL-powered truth generation
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix : <http://example.org/ns#>
base <http://example.org/>
# TBox:
:Truth rdfs:subClassOf [ owl:onProperty rdf:reifies ; owl:allValuesFrom :Fact ] .
:Fact owl:equivalentClass [ owl:onProperty _:selfOfTypeFact ; owl:hasSelf true ] ,
[ owl:onProperty rdf:predicate ;
owl:allValuesFrom [ owl:onProperty owl:propertyChainAxiom ;
owl:hasValue (
[ owl:inverseOf rdf:subject ]
_:selfOfTypeFact
rdf:object
) ] ] .
# ABox:
[] a :Truth ;
rdf:reifies [ rdf:subject <some> ; rdf:predicate :such ; rdf:object <thing> ] ,
[ rdf:subject <other> ; rdf:predicate :such ; rdf:object <stuff> ] .
# Entails:
# <some> :such <thing> .
# <other> :such <stuff> .
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix : <http://example.org/ns#>
base <http://example.org/>
# TBox:
:Truth rdfs:subClassOf [ owl:onProperty rdf:reifies ; owl:allValuesFrom :Fact ] .
[ owl:onProperty _:a_Fact ; owl:hasSelf true ] owl:equivalentClass :Fact .
_:factSubject
rdfs:subPropertyOf [ owl:inverseOf rdf:type ] ;
owl:propertyChainAxiom ( _:a_Fact rdf:tripleSubject ) .
_:factPredicate
rdfs:subPropertyOf owl:onProperty ;
owl:propertyChainAxiom ( _:a_Fact rdf:triplePredicate ) .
_:factObject
rdfs:subPropertyOf owl:hasValue ;
owl:propertyChainAxiom ( _:a_Fact rdf:tripleObject ) .
# ABox:
[] a :Truth ;
rdf:reifies [ rdf:tripleSubject <some> ; rdf:triplePredicate :such1 ; rdf:tripleObject <thing> ] ,
[ rdf:tripleSubject <other> ; rdf:triplePredicate :such2 ; rdf:tripleObject <stuff> ] .
# Entails:
# <some> :such1 <thing> .
# <other> :such2 <stuff> .
@niklasl
Copy link
Author

niklasl commented Jul 12, 2024

@pchampin
Copy link

Wow, that's super clever :-)

However, I don't think it really works as you expect.
If you replaced your Abox with the following (replacing :such with :such1 and :such2):

[] a :Truth ;
  rdf:reifies [ rdf:subject <some> ; rdf:predicate :such1 ; rdf:object <thing> ] ,
      [ rdf:subject <other> ; rdf:predicate :such2 ; rdf:object <stuff> ] .

I believe it wouldn't it entail all the following:

<some> :such1 <thing> .
<other> :such1 <stuff> . # you probably don't want that one
<some> :such2 <thing> . # you probably don't want that one either
<other> :such2 <stuff> . 

@pchampin
Copy link

Also, I am not sure that your example complies with OWL-RL. More precisely, I suspect that using owl:propertyChainAxiom as the value of owl:onProperty does not fit in the syntactic restrictions of OWL-RL, or even the syntactic structure of OWL as such.

@niklasl
Copy link
Author

niklasl commented Jul 13, 2024

Thank you @pchampin for noting this!

You're absolutely right; this appears to say that any property used as a reified predicate in any of these "facts" hold between all subject, objects pairs of every "fact"! That's certainly not desired. (Never use an all-quantifier without checking for more false positives!)

Also yes, that is an important caveat: this may very well be "ill-formed" OWL. Entailing more OWL rules like this is rather hazardous...

@niklasl
Copy link
Author

niklasl commented Jul 4, 2025

Added variant which seems to fare better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment