;; creating rules (defmacro rule-if (a op b then c) (cond ((equal op 'and) `(lambda () (when (and (exist-in-facts? ',a) (exist-in-facts? ',b)) (add-fact ',c)))) ((equal op 'or) `(lambda () (when (or (exist-in-facts? ',a) (exist-in-facts? ',b)) (add-fact ',c)))) ((equal op 'xor) `(lambda () (when (or (and (exist-in-facts? ',a) (not (exist-in-facts? ',b))) (and (not (exist-in-facts? ',a)) (exist-in-facts? ',b))) (add-fact ',c))))))