   proper subsets of initial-set. This is needed for computing the
   stem-base."
   [implications initial-set]
-  (loop [conclusions []
-	 impls implications
-	 unused-impls []]
+  (loop [conclusions  [],
+         impls        implications,
+         unused-impls []]
     (if (empty? impls)
       [(apply union initial-set conclusions) unused-impls]
       (let [impl (first impls)]
-	(if (and (proper-subset? (premise impl) initial-set)
-		 (not (subset? (conclusion impl) initial-set)))
-	  (recur (conj conclusions (conclusion impl))
-		 (rest impls)
-		 unused-impls)
-	  (recur conclusions
-		 (rest impls)
-		 (conj unused-impls impl)))))))
+        (if (and (proper-subset? (premise impl) initial-set)
+                 (not (subset? (conclusion impl) initial-set)))
+          (recur (conj conclusions (conclusion impl))
+                 (rest impls)
+                 unused-impls)
+          (recur conclusions
+                 (rest impls)
+                 (conj unused-impls impl)))))))
 
 (defn clop-by-implications*
   "Returns closure operator given by implications. Closed sets are
   computed from implications with premises being proper subsets."
   [implications]
-  (binding [add-immediate-elements add-immediate-elements*]
-    (partial close-under-implications implications)))
+  (fn [set]
+    (loop [set set,
+           impls implications]
+      (let [[new impls] (add-immediate-elements* impls set)]
+        (if (= new set)
+          new
+          (recur new impls))))))
 
 (defn stem-base
   "Returns stem base of given context. Uses background-knowledge as

  implications."
  [implication implications]
  (subset? (conclusion implication)
	   (close-under-implications implications (premise implication))))

(defn minimal-implication-set?
  "Checks whether given set of implications is minimal, i.e. no


(ns conexp.fca.implications
  (:use conexp.base
        conexp.fca.contexts)
  (:import [java.util HashMap HashSet]))

(ns-doc "Implications for Formal Concept Analysis")

;;;

