cgrand / enlivez

8 stars 0 forks source link

lifting ors #38

Closed cgrand closed 4 years ago

cgrand commented 5 years ago

Imagine a rule such as:

(defrule is-all-powerful [user] 
 (info user name group) (or (= "root" user) (= group "admin")) 

I want to lift the or out the rule to go to plain datalog.

My first idea was to lift ors as rules but then in this case we would have the following rules

xxx(name, group) :- eq(user, "root")
xxx(name, group) :- eq(group, "admin")

which violates the constraint that all variables appearing in the head must be grounded.

cgrand commented 5 years ago

So I guess I have to split the parent rule

(defrule is-all-powerful 
  ([user]
    (info user name group) (= "root" user))
  ([user]
    (info user name group) (= "admin" group)))
cgrand commented 5 years ago

Going all DNF on this is brutal but it's a quick working solution.

cgrand commented 4 years ago

I ended doing things differently: when I encounter an or I lift everything that's right of it in a rule.