(defn is-safe?
"Is the rule safe according to the datalog protocol?"
[rule]
(let [hv (literal-vars (:head rule))
bpv (apply union (map positive-vars (:body rule)))
bnv (apply union (map negative-vars (:body rule)))
ehv (difference hv bpv)
env (difference bnv bpv)]
(when-not (empty? ehv)
(throwf "Head vars %s not bound in body in rule %s" ehv rule))
(when-not (empty? env)
(throwf "Body vars %s not bound in negative positions in rule %s" env rule))
rule))
Comments top
No comments for is-safe?. Log in to add a comment.