brian
/
bad-datalog
Archived
1
0
Fork 0

drop anonymous variables when considering if negation is safe

fresh-start
Brian Hicks 2021-01-05 20:27:31 -06:00
parent e8aa5eb333
commit 7a4c963ee7
2 changed files with 9 additions and 0 deletions

View File

@ -89,6 +89,7 @@ isNegationSafe (Rule _ body_) =
|> (\{ positive, negative } ->
negative
|> Set.dropIf (Set.memberOf positive)
|> Set.dropIf ((==) Term.Anonymous)
|> Set.isEmpty
)

View File

@ -38,6 +38,14 @@ ruleTest =
, negative (atom "reachable" [ variable "a", variable "b" ])
]
|> Expect.ok
, test "negative terms which are introduced outside the head are still allowed if they appear in positive form" <|
\_ ->
rule
(atom "peopleWithoutEmails" [ variable "Name" ])
[ positive (atom "people" [ variable "Id", variable "Name" ])
, negative (atom "peopleToEmails" [ variable "Id", anonymous ])
]
|> Expect.ok
, test "negative terms are not allowed if they don't also appear in a positive form" <|
\_ ->
rule