 
 ;; efficient simulator sets (by meng)
 
-(defn single-edge->double-edge-graph
+(defn- single-edge->double-edge-graph
   "Given a single-edged graph G (i.e. a graph with a neighbours
   function on it) returns a structure with a :pre and a :post function
   on it. This function is part of the implementation for
   efficient-simulator-sets."
   [G]
-  (loop [pre-map {},
+  (loop [pre-map    (transient {}),
          vertex-set (vertices G)]
-    (if-not (empty? vertex-set)
+    (if (not-empty vertex-set)
       (let [v (first vertex-set)]
-        (recur (reduce #(update-in %1 [%2] conj v)
+        (recur (reduce #(assoc! %1 %2 (conj (get %1 %2) v))
                        pre-map
                        ((neighbours G) v))
                (rest vertex-set)))

  [tbox-map]
  (if (empty? tbox-map)
    tbox-map
    (let [new-names (new-names),
          ;; doall needed to store new names in new-names!
          normalized-map (doall
                          (into {} (map (fn [[A def-A]]
                                          [A (set (map #(normalize-term % new-names) def-A))])
                                        tbox-map))),
          new-names-map (introduce-auxiliary-definitions (get-names new-names))]
      (into normalized-map new-names-map))))

;; normalizing algorithm -- squeezing the concept graph

  (if (and (compound? term)
           (= 'exists (operator term)))
    (let [[r B] (arguments term),
          norm  (normalize-for-goal B
                                    #(and (atomic? %)
                                          (not (tbox-target-pair? %))
                                          (not (primitive? %)))
                                    new-names)]
      (make-dl-expression (expression-language term)
                          (list 'exists r norm)))
    (normalize-for-goal term
