          (+ [c c c])
          (- [d d d]))
    (Knowledge. #{[2 3 4] [:a :b :c] [:b :c :d]} #{[1 2 3]} #{}))
+
+  (rule {:name :quux :quux x}
+        (> {:name :the :foo x} {:bar x}))
   )

  ((query (+ed [a b])
          (+ [a b]))
   (Knowledge. #{} #{[1 2]} #{}))

  ((set-q 'x '[b c] '[[a b c] [b c d]]) (Knowledge. #{[1 2 3] [2 3 4] [3 4 5] [2 8 9] [8 9 5]} #{} #{}))

  ((query (set x [b c]
               [a b c]

    (if (seq? clause)
      #{}
      (match/vars clause))))

(defn preds-in [clause]
  ;; TODO check not nil
  (condp op? clause
    '+ed #{(:name (second clause))}
    '-ed #{(:name (second clause))}
    'set (apply clojure.set/union (map preds-in (nthnext clause 3)))
    (if (seq? clause)
      #{}
      #{(:name clause)})))

(defn preds-out [clause]
  ;; TODO check not nil
  (condp op? clause
        '+ #{(:name (second clause))}
        '- #{(:name (second clause))}
        '+s #{:any}
        '-s #{:any}
        '> (let [from-name (:name (nth clause 1))
                 to-name (:name (nth clause 2))]
             (check from-name)
             (check (or (nil? to-name) (= from-name to-name)))
             #{(:name (nth clause 1))})
        #{}))

(def empty-q
  (with-meta
