 ;; TODO TODO: fix names.
 ;; TODO: turn kill back on
 
+;; --> TODO: merge stubs and subproblems!
 
 (set! *warn-on-reflection* true)
 

            (do (reset! state :go) (summaries/summary-changed! s))))))))


;; Note: we must always wrap in S-A stub to get effects out of logger.
(defmethod get-stub :Atomic [[_ fs :as n] inp-set]
  (let [cache-key [n (if *state-abstraction* (fs/extract-context fs inp-set) inp-set)]
        output-collect #(if *collect-equal-outputs* (make-output-collecting-stub %) %)
        make-stub #(output-collect (make-atomic-stub n %))]
    (if-let [^HashMap dc *decompose-cache*]
      (if *state-abstraction*
        (let [stub (util/cache-with dc cache-key (make-stub (fs/get-logger fs inp-set)))]
          (make-state-abstracted-stub stub inp-set))   
        (util/cache-with dc cache-key (make-stub inp-set)))
      (make-stub inp-set))))

;; TO do names properly, outers should always guard inners. ?
;; 
(comment
 (defmethod get-stub :OC [[_ inner-n :as n] inp-set]
            (make-output-collecting-stub (get-stub inner-n inp-set)))

;; Gotta go all the way in.
 (defmethod get-stub :SA [[_ inner-n :as n] inp-set]
            (make-state-abstracted-stub (get-stub inner-n (fs/get-logger )))

            (make-output-collecting-stub (get-stub inner-n inp-set))))




;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   Sequences    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defn- make-fs-seq-name [fs-seq]
  (assert (seq fs-seq))
  ((if *left-recursive* left-factor right-factor)
   (map wrapped-atomic-name fs-seq)))

;; TODO: flatten as well?
(comment
  (defn norm-name [n]
   (case (first n)
     :Atomic n
     :Pair   [:Pair (norm-name (nth n 1)) (norm-name (nth n 2))]
     :SA     (norm-name (second n))
     :OC     (norm-name (second n)))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;      Atomic       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

