user7420209
user7420209

Reputation: 225

Rule error in Grakn: "rule does not form a valid clause, as it contains a multi-atom head"

I have a rule that is failing to commit. This is the rule:

when {
    $t isa person; 
    $car isa car; 
    $t2 isa person; 
    $r ($t, $car) isa ownership;     
    $r2 ($t2, $car) isa ownership;     
}, then {
    $car has age 23; 
    ($car, $t2) isa ownership; 
};

This is the error that I get after I commit this:

INVALID_ARGUMENT: InvalidKBException-A structural validation error has occurred. Please correct the [`1`] errors found. 
The rule [rule-32] does not form a valid clause, as it contains a multi-atom head
. Please check server logs for the stack trace.
All uncommitted data is cleared

Upvotes: 0

Views: 41

Answers (2)

lolski
lolski

Reputation: 17511

What @Jon T said is correct, and therefore the solution specific to your problem is to split the rule into two rules.

Both rules will have an identical when clause where the then clause has exactly one conclusion:

when {
    $t isa person; 
    $car isa car; 
    $t2 isa person; 
    $r ($t, $car) isa ownership;     
    $r2 ($t2, $car) isa ownership;     
}, then {
    $car has age 23; 
};

when {
    $t isa person; 
    $car isa car; 
    $t2 isa person; 
    $r ($t, $car) isa ownership;     
    $r2 ($t2, $car) isa ownership;     
}, then {
    ($car, $t2) isa ownership; 
};

Upvotes: 0

Jon T
Jon T

Reputation: 108

A rule can only infer one fact:

In Graql, the “when” part of the rule is required to be a conjunctive pattern, whereas the “then” should be atomic - each rule can derive a single fact only

docs

Upvotes: 1

Related Questions