 
 ;;; TITANIC Implementation
 
-(defvar- closure nil
-  "Holds the closures of sets. To be rebound.")
-(defvar- set-weight nil
-  "Holds the weights of sets. To be rebound.")
-
 (defn- titanic-closure
   "Computes the closure of X by the weights of its subsets. The
   following restrictions apply:

      together with their weights, ordered by their weights,
    - X is a member of keys.

  Also note that the variables «closure» and «set-weight» have to be
  rebound."
  [X X-weight base-set keys]
  (let [keys (map first (take-while #(not= (second %) X-weight) keys))]
    (loop [Y        (apply union X (map #(closure (disj X %)) X)),
           elements (difference base-set Y)]

        Y))))

(defn- titanic-generate
  "Computes the next candidate set."
  [base-set key-set]
  (set-of next [A key-set,
                m (difference base-set A),
