              (make-interleaving-hla (map (comp vector first) chunk) bad-vars))))))))
 
 (defn make-precond-set-hla [precond-map] 
-  (SAS-Precond-Set-HLA (doall (map (partial apply make-precond-hla) (sort-by (comp - *var-levels* key) precond-map)))
-                       (atom :dummy)))
-
+  (SAS-Precond-Set-HLA 
+   precond-map
+   (doall (map (partial apply make-precond-hla) (sort-by (comp - *var-levels* key) precond-map)))
+   (atom :dummy)))
+
+(defn trivially-satisfied-precond-set? [a s]
+  (if (= (type a) ::SAS-Compiled-HLA) (recur (:orig-hla a) s)
+      (and (= (type a) ::SAS-Precond-Set-HLA)
+           (every? (fn [p] (= (env/get-var s (:var p)) (:dst-val p)))
+                   (:ordered-preconds a)))))
 
 ; (loop [init-sets init-sets, ordered-preconds ordered-preconds, used-vars #{}]
 ;        (when-let [[f & r] (seq ordered-preconds)]        

(defn default-compile-hla-noflatten [hla retain-type-set]
;  (println "compiling-noflatten" (env/action-name hla))
  (or (get *compile-cache* hla)
      (let [chla (make-compiled-hla (env/action-name hla) (type hla) (precond-var-set hla) (effect-sets hla))]
        (.put *compile-cache* hla chla)
        (set-compiled-hla-refinements chla
                                      (doall (for [[p r] (pre-ref-pairs hla)] [p (compile-refinement r retain-type-set)])))

  hierarchy/HighLevelAction
    (immediate-refinements- [s]
      (let [[stalled-refs rest-refs] (split-with #(= (hla-type (first %)) ::SAS-Precond-Set-HLA) refinements)]
;        (println "\n\n" s "\n" (map (comp env/action-name first) refinements))
;        (println (map count [stalled-refs rest-refs]))
;        (println (map #(map type %) rest-refs))
        (if-let [[target-ref & more-refs] (seq rest-refs)]
