User-defined rules not working as expected

I am trying to confirm the functionality for user-defined rules, using Stardog 7.0.1. I have this reduced data set

:Control_19 a :Control ;
rdfs:label "Control 19" ;
:hasOwnerOrg :Organization_25 ;
:partOf_c :BusinessProcessCategory_20,
:BusinessProcessCategory_56 .

IF {
?control a :Control;
:hasOwnerOrg ?org ;
:partOf_c ?category ;
.

BIND (URI(CONCAT('http://data.test.com/', 
    SHA1(CONCAT(STR(?control), STR(?org), STR(?category)))))
    as ?orgProcessInCategory)            

}
THEN {
?orgProcessInCategory a :OrgProcessInCategory ;
:hasRelSubject ?org ;
:hasRelObject ?category ;
.
}

When I do the basic ?s ?p ?o query, I expect to see the explicitly asserted triples plus the 6 inferred triples (reasoning is enabled and set to SL, which is supposed to run user-defined rules).

I validated my logic by inverting the rule into a construct query, i.e.

construct
{
?orgProcessInCategory a :OrgProcessInCategory ;
onto:hasRelSubject ?org ;
onto:hasRelObject ?category ;
.
}
where
{
?control a :Control;
:hasOwnerOrg ?org ;
:partOf_c ?category ;
.

BIND (URI(CONCAT('http://data.test.com/', 
    SHA1(CONCAT(STR(?control), STR(?org), STR(?category)))))
    as ?orgProcessInCategory)            

}

And that produces the expected results. So, there must be something basic I am missing - any hints?

You've got two problems here. It looks like you're trying to create a new individual in a SWRL rule. Stardog has support for that but it needs to be done using the UUID() function. I'm not sure what happens when you do it this way. I suspect you'll see some warnings in the logs but I'm not positive.

The second problem is multiple atoms in the head portion of your rule. It will be executed as separate rules for each atom in the head.

See the documentation here for details https://www.stardog.com/docs/#_new_individuals_with_swrl

Thank you, I missed that portion of the documentation, and certainly using UUID() is not valid when multiple atoms are present in the rule head. I will utilize a different approach.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.