typedb
typedb copied to clipboard
Incorrect validation for negated attribute values in rules (invalidates valid rules)
Description
The following rule is invalidated because of a cyclical negation, but the negation is on a different attribute value in the antecedent to the one inferred by the consequent.
rule if-data-source-not-trusted-then-untrusted:
when {
$ds isa data_source;
not { $ds has is_trusted true;};
}
then {
$ds has is_trusted false;
};
Environment
- Windows or Ubuntu
- TypeDB 2.8.0
Reproducible Steps
Steps to create the smallest reproducible scenario:
- Load the following schema:
define
is_trusted sub attribute, value boolean;
data_source sub entity, owns is_trusted;
rule if-data-source-not-trusted-then-untrusted:
when {
$ds isa data_source;
not { $ds has is_trusted true;};
}
then {
$ds has is_trusted false;
};
Expected Output
A successful schema commit
Actual Output
Validation error:
Invalid Rule Write: A cycle containing negation(s) that can cause inference contradictions has been detected in rules:
if-data-source-not-trusted-then-untrusted ->
if-data-source-not-trusted-then-untrusted
Additional information
If the rule contains a more general not { $ds has is_trusted $it;}; in the antecedent, then validation should still fail.
Moved case with relations to different issue , because it's a different fix #6599
PR #6628 adds support for this. It's currently in our development branch so should be included in the next release.