robot
robot copied to clipboard
Add option to relax to recursively relax
Example:
Prefix: : <http://x.org/>
Ontology: <http://x.org>
ObjectProperty: hasPart
ObjectProperty: inheresIn
Class: P1
EquivalentTo: hasPart some (Q and inheresIn some E)
Class: P2
EquivalentTo: Foo and (hasPart some (Q and inheresIn some E))
Class: Q
Class: E
Class: Foo
Example of current relax (filtering equivalence just for illustration purposes):
robot relax -i nested-relax-test.omn remove --axioms "equivalent"
gives:
Class: <http://x.org/P1>
SubClassOf:
<http://x.org/hasPart> some
(<http://x.org/Q>
and (<http://x.org/inheresIn> some <http://x.org/E>))
Class: <http://x.org/P2>
SubClassOf:
<http://x.org/Foo>,
<http://x.org/hasPart> some
(<http://x.org/Q>
and (<http://x.org/inheresIn> some <http://x.org/E>))
in both cases the inner expressions are intersections. The goal of relax is to weaken to axioms that use SubClassOf and restrictions only.
Desired:
Class: <http://x.org/P1>
SubClassOf:
<http://x.org/hasPart> some <http://x.org/Q>,
<http://x.org/hasPart> some <http://x.org/inheresIn> some <http://x.org/E>
Class: <http://x.org/P2>
SubClassOf:
<http://x.org/Foo>,
<http://x.org/hasPart> some <http://x.org/Q>
<http://x.org/hasPart> some <http://x.org/inheresIn> some <http://x.org/E>
side note: it could be argued that end goals are better served by using robot/materialize or relation-graph with suitable blank-node hopping property chains, this may be true, but I think there is a logical coherence in having relax operate recursively.
- X=Y => X sub Y
- X sub A and ... => X sub A
- X sub (R1 some R2 some ... Rn some (A and ...)) => X sub (R1 some R2 some ... Rn some (A)). [for any n >= 1]
I think that makes sense and is easy to implement. Your 1/2 are already in relax. 3 as a rewrite weakens the semantics of the logical statements somewhat compared to the old relax. In particular in conjunction with remove --axioms "equivalent" this DL query wont work anymore unless R is functional: R some (A and ...B). Since this is at the heart of the idea of relax, its fine, I just wanted to mention it for completeness..
Once we are all agreed I will make a PR. The question is now if the current relax behaviour constitute a bug (i.e. it should have been recursive all along) or whether this is an addition feature, in which case we would have to add a parameter --recursive to relax. I guess some argument can be made though that the default of this should be "true".
I think that makes sense and is easy to implement. Your 1/2 are already in relax. 3 as a rewrite weakens the semantics of the logical statements somewhat compared to the old relax. In particular in conjunction with remove --axioms "equivalent" this DL query wont work anymore unless R is functional: R some (A and ...B). Since this is at the heart of the idea of relax, its fine, I just wanted to mention it for completeness..
I think that is fine. Another way to think about this is the target profile excluding intersectionOf, so queries with intersectionOf would be incomplete.
Once we are all agreed I will make a PR. The question is now if the current relax behaviour constitute a bug (i.e. it should have been recursive all along) or whether this is an addition feature, in which case we would have to add a parameter --recursive to relax. I guess some argument can be made though that the default of this should be "true".
I think it is most in keeping with current robot practice to add a new parameter with default false.
[minor: fixing a typo in my original comment, I originally had n<= 1!]
Although not a priority, for completeness, the --recursive option should also recurse over the min 1=>some rule too
i.e. my rule 1, the "somes" should be treated as matching EITHER 'some' OR 'min 1'
i.e
Class: P3
EquivalentTo: Foo and (hasPart min 1 (hasPart min 1 E))
should relax to
Class: P3
SubClassOf: Foo,
hasPart some (hasPart some E)
(yes this is an odd example since hasPart is usually transitive but this is just for illustration...)