Why inference doesn't work?

When testing the rule-based inference, can’t get the expected answer, need some help to figure out why.

shema:

define

ID sub attribute, value string;
x sub attribute, value long;

next sub relation, owns ID, relates left, relates right;
zhi sub entity, owns ID, owns x, plays next:left, plays next:right;

rule r1: when {
    $z1 isa zhi, has x $x1, has ID $n1;
    $z2 isa zhi, has x $x2, has ID $n2;
    $n1 = $n2;
    $x2 = 1;
    $x1 = 0;
} then {
    (left: $z1, right: $z2) isa next;
};

data:

insert  $e isa zhi, has ID "sz", has x 0;
insert  $e isa zhi, has ID "sz", has x 1;
insert  $e isa zhi, has ID "sz", has x 2;
insert  $e isa zhi, has ID "sz", has x 3;

insert  $e isa zhi, has ID "s", has x 0;
insert  $e isa zhi, has ID "s", has x 1;
insert  $e isa zhi, has ID "s", has x 2;
insert  $e isa zhi, has ID "s", has x 3;

query:

match $r isa next; fetch $r:ID;

As shown, it’s a simple test about rule based inference for a relation next. For the entity ‘zhi’ with the same ID, as long as x value is 0/1, the two ‘zhi’ have a relation ‘next’.

I’ve run the schema, inserted data and query with no error, but I can’t get the expect answer. Actually no result at all:

## Result> Fetch query did not retrieve any data from the database.

What’s wrong here?

Thanks for your help.

Hi @zack !

Did you enable the “infer” Option when running the read query?
See here for more information TypeDB | Docs > Manual > Inference

I did NOT, my bad. Thanks for your help!