Given a set of bound column names, return an adorned sip for this
rule. A set of intensional predicates should be provided to
determine what should be adorned.
(defn compute-sip
"Given a set of bound column names, return an adorned sip for this
rule. A set of intensional predicates should be provided to
determine what should be adorned."
[bindings i-preds rule]
(let [next-lit (fn [bv body]
(or (first (drop-while
#(not (literal-appropriate? bv %))
body))
(first (drop-while (complement positive?) body))))
adorn (fn [lit bvs]
(if (i-preds (literal-predicate lit))
(let [bnds (union (get-cs-from-vs lit bvs)
(get-self-bound-cs lit))]
(adorned-literal lit bnds))
lit))
new-h (adorned-literal (:head rule) bindings)]
(loop [bound-vars (get-vs-from-cs (:head rule) bindings)
body (:body rule)
sip []]
(if-let [next (next-lit bound-vars body)]
(recur (union bound-vars (literal-vars next))
(remove #(= % next) body)
(conj sip (adorn next bound-vars)))
(build-rule new-h (concat sip body))))))
Comments top
No comments for compute-sip. Log in to add a comment.