Discussion Forum

Rule returns invalid results

I have the problem that my rule returns invalid results. Somehow grakn seems to know this but does not consider this knowledge when inferring:

My rule

$x type actuator-effect-direction-1 sub rule when {
    $actuator isa actuator; 
    $pipe isa pipe; 
    ($actuator, $pipe) isa productFlow, has validFrom $vF1, has validUntil $vU1; 
    ($pipe, $x) isa baseRelation, has validFrom $vF2, has validUntil $vU2; 
    $actuator != $x; 
}  then  { 
    (origin: $actuator, end: $x) isa effect; 
}; 

returns

grakn> match $o has ID $i1; $e isa event, has ID $i2; $x(end:$e, origin:$o) isa effect; get; limit 10;
{$e id V12528 isa pumpOn; $i1 "N18" isa ID; $x id V41226248 (end: id V12528, origin: id V40968232) isa effect; $i2 "1" isa ID; $o id V40968232 isa rPump;}
{$e id V12528 isa pumpOn; $i1 "Pump18" isa ID; $x id V41226248 (end: id V12528, origin: id V40968232) isa effect; $i2 "1" isa ID; $o id V40968232 isa rPump;}

according to my schema pumpOn can not play the role end in the relationship effect. To exclude it from the results I wanted to add not{$x isa pumpOn;}; to the rule but I get the following message when committing:

INVALID_ARGUMENT: InvalidKBException-A structural validation error has occurred. Please correct the [`1`] errors found.
Rule [actuator-effect-direction-1] attempts to define a rule containing a relation pattern with type [pumpOn] that cannot play role [end] in relation [effect]

and if I undefine the rule I get the following output:

pumpwerk> undefine actuator-effect-direction-1 sub rule;
{}
pumpwerk> commit
INVALID_ARGUMENT: InvalidKBException-A structural validation error has occurred. Please correct the [`27`] errors found.
The type [valveOpen] of role player [V40997056] is not allowed to play Role [end]
The type [valveClose] of role player [V90208] is not allowed to play Role [end]
The type [pumpOff] of role player [V73872] is not allowed to play Role [end]

I adapted my queries as a first workaround:
In my schema pumpOff/ON, valveOn/Off inherit from event. Therefore I assumed the following queries should give me the same reslults, but they don’t. The first query returns results including pumpOff/ON, valveOn/Off playing the role end.

match $x($e) isa effect; not{$e isa event;}; get;
match $x($e) isa effect; not{$e isa pumpOff;}; not{$e isa valveClose;}; not{$e isa valveOpen;}; not{$e isa pumpOn;};  get;

As a second work around I added this to the rule $event sub event; not { $x isa junction; $x isa $event; }; which gives me the following rule:

actuator-effect-direction-1 sub rule when {
    $actuator isa actuator; 
    $pipe isa pipe; 
    ($actuator, $pipe) isa productFlow, has validFrom $vF1, has validUntil $vU1; 
    ($pipe, $x) isa baseRelation, has validFrom $vF2, has validUntil $vU2; 
    $actuator != $x; 
    $event sub event; not { $x isa junction; $x isa $event; }; }; 
} then { 
     (origin: $actuator, end: $x) isa effect; 
}; 

This rule can be committed and if I query effect relations there are non with an event as role player, but the query match $o isa junction; $x($o) isa effect; get; limit 10; gives me plenty results…


I am using Grakn 1.6.2.
Thanks for your help!

Hello,

Could you provide us with a set of steps to reproduce the issue? Or if you could share the dataset. I looked at the dataset that @joshua has and couldn’t reproduce it.

Hi @ctrotha sorry to get to this so late! I tried to reproduce the error with both the dataset you shared with me directly, and with the distribution you sent Kasper. My schema + data insert queries don’t cause what you’re seeing (but I suspect it is incomplete)

Kasper’s database distribution however is also not complete, as I don’t see the type effect being declared, nor any rules. Do you still have a copy of the database that causes the error still handy?

Thanks!
Josh