Hi Martynas,
As Adrian says the problem is your "unless". That makes this a
non-monotonic problem hence you needing to use the noValue predicate.
Jena rules work OK in the monotonic case that they were designed for but
allowing noValue and its kin that was a mistake and the engine isn't
well suited to this sort of usage.
That said I would have expected your first rule to work, it's the second
case that is tricky. NoValue only allows you to check for absence of a
triple whereas you need to check for absence of a triple pattern. So your:
...
noValue(?template<http://www.w3.org/ns/ldt#param> ?subArg),
noValue(?subArg <http://spinrdf.org/spl#predicate> ?predicate)
...
will stop the rule firing if the template has any param, rather than if
it has a param with the given predicate. There's no equivalent of
noValue for such predicate chains. You could write one but you would
still be dealing with non-monotonic rules and I wouldn't guarantee it
would work as you expect.
Dave
On 28/09/16 20:20, Martynas Jusevičius wrote:
Hey,
is it possible to express such condition using Jena rules:
"Subclasses inherit parameter arguments from superclasses, unless an
argument with the same predicate already is a subclass parameter"?
For example
# 1
:SuperClass ldt:param [ a ldt:Argument ; spl:predicate foaf:name ],
[ a ldt:Argument ; spl:predicate dct:title ] .
:SubClass rdfs:subClassOf :SuperClass .
should infer new triples:
:SubClass ldt:param [ a ldt:Argument ; spl:predicate foaf:name ],
[ a ldt:Argument ; spl:predicate dct:title ] .
# 2
:SuperClass ldt:param [ a ldt:Argument ; spl:predicate foaf:name ],
[ a ldt:Argument ; spl:predicate dct:title ] .
:SubClass rdfs:subClassOf :SuperClass ;
ldt:param [ a ldt:Argument ; spl:predicate dct:title ] ,
[ a ldt:Argument ; spl:predicate sioc:name ] .
should infer new triples:
:SubClass ldt:param [ a ldt:Argument ; spl:predicate foaf:name ] .
# no dct:title param inferred, because it exists already
What I use currently is this:
[arg1: (?template rdf:type <http://www.w3.org/ns/ldt#Template>),
(?template <http://www.w3.org/ns/ldt#param> ?arg), (?arg rdf:type
<http://www.w3.org/ns/ldt#Argument>), (?subTemplate rdfs:subClassOf
?template), (?subTemplate rdf:type
<http://www.w3.org/ns/ldt#Template>), noValue(?subTemplate
<http://www.w3.org/ns/ldt#param>) -> (?subTemplate
<http://www.w3.org/ns/ldt#param> ?arg)]
[arg2: (?template rdf:type <http://www.w3.org/ns/ldt#Template>),
(?template <http://www.w3.org/ns/ldt#param> ?arg), (?arg rdf:type
<http://www.w3.org/ns/ldt#Argument>), (?subTemplate rdfs:subClassOf
?template), (?subTemplate rdf:type
<http://www.w3.org/ns/ldt#Template>), (?arg
<http://spinrdf.org/spl#predicate> ?predicate), (?subTemplate
<http://www.w3.org/ns/ldt#param> ?subArg), noValue(?template
<http://www.w3.org/ns/ldt#param> ?subArg), noValue(?subArg
<http://spinrdf.org/spl#predicate> ?predicate) -> (?subTemplate
<http://www.w3.org/ns/ldt#param> ?arg)]
Sometimes I get desired results, sometimes only a single param is inferred.
Are the rules wrong or is this can't be done with monotonic rules?
Thanks,
Martynas